Can someone explain the arguments to write function used for the curl option CURLOPT_WRITEFUNCTION

Can someone explain the arguments to write function used for the curl option CURLOPT_WRITEFUNCTION

Apparently size is the size of one data item, nmemb is the number of data items. My guess is that its some internal implementation detail. The real data size = size * nmemb.

The documentation for the callback function: https://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html

Example code:
https://github.com/curl/curl/blob/master/docs/examples/getinmemory.c

This is designed for the function such as: size_t fwrite(const void* buffer, size_t size, size_t count, FILE* stream);

FILE* out = fopen(out.html, w);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)out);
curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, fwrite);

So we need not to add more code for fwrite as it is!

Can someone explain the arguments to write function used for the curl option CURLOPT_WRITEFUNCTION

Leave a Reply

Your email address will not be published.