I have the following question: how can i write data returning with http-response in char *
buffer? I\'ve found several approaches:
CURLOPT_
Actually CURLOPT_WRITEDATA and CURLOPT_WRITEFUNCTION can be used with any pointer type. As long as your function is compatible with that pointer type.
For example:
...
client_t *client;
CURL *conn;
...
curl_easy_setopt(conn, CURLOPT_WRITEFUNCTION, read_data);
curl_easy_setopt(conn, CURLOPT_WRITEDATA, client);
...
static size_t read_data(void *ptr,
size_t size,
size_t nmemb,
client_t *client)
{
memcpy(client->data, ptr, size * nmemb);
return size * nmemb;
}