(ignore the comments about number of evaluations if you are passing string literals or just regular variables as parameters to macro, they are intended to warn you not to do stuff like P_STR("name", str++) )
Name
P_STR("paramname", "param value")
Description
string argument, both first and second arguments are evaluated twice.
Name
P_LSTR("paramname", "param value", value_len)
Description
String argument, with know value length. Value does not need to be null terminated, value and value_len are evaluated just once, paramname is evaluated twice.
Name
P_NUM("paramname", uin64_t_num_value)
Description
Number argument, name is evaluated twice, the number just once.
Name
P_BOOL("paramname", bool)
Description
Bool can be anything that can evaluate as true/false (pointer, number). The bool argument is evaluated once, the name twice.
Name
apisock *api_connect();
Description
Connect to an api server, on failure return NULL.
Name
apisock *api_connect_ssl();
Description
Connect to an api server via SSL, on failure return NULL.
Name
void api_close(apisock *sock);
Description
Closes connection to the server.
Name
binresult *send_command(apisock *sock, const char *command, ...);
Description
Sends a command to the server and return result. This is a macro, evaluating the command parameter twice. The ... stands for any number of parameters. NULL indicates an error, non-NULL result will be the command's response and needs to be deallocated with free().
Name
binresult *send_command_nb(apisock *sock, const char *command, ...);
Description
Same as send_command, but does not read the result from the api server. On failure returns NULL, on success returns PTR_OK, which does not need to be freed. You are supposed to read the result with get_result() when you are ready to do so.
Name
*send_data_command(apisock *sock, const char *command, uint64_t datalen, ...);
Description
Same as send_command_nb, but indicates that you will be sending data with the request. You are supposed to write datalen bytes to the connection after this call (if it's successful) with writeall() and get the result with get_result().
Name
*get_result(apisock *sock);
Description
Reads and parses the first waiting result sent command . Non-NULL return value indicates success and needs to be deallocated with free().
Name
int writeall(apisock *sock, const void *ptr, size_t len);
Description
Writes all the len bytes at *ptr to the socket and returns 0 on success and -1 on error.
Name
ssize_t readall(apisock *sock, void *ptr, size_t len);
Description
Reads all len bytes from the socket to *ptr and returns the number of bytes read (always len) or -1 on error.