Sortix cisortix manual
This manual documents Sortix cisortix. You can instead view this document in the latest official manual.
CURLOPT_READFUNCTION(3) | curl_easy_setopt options | CURLOPT_READFUNCTION(3) |
NAME
CURLOPT_READFUNCTION - read callback for data uploadsSYNOPSIS
#include <curl/curl.h>
size_t read_callback(char *buffer, size_t size, size_t nitems, void *userdata);
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_READFUNCTION, read_callback);
DESCRIPTION
Pass a pointer to your callback function, as the prototype shows above.DEFAULT
The default internal read callback is fread().PROTOCOLS
This is used for all protocols when doing uploads.EXAMPLE
size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userdata)
{
FILE *readhere = (FILE *)userdata;
curl_off_t nread;
/* copy as much data as possible into the 'ptr' buffer, but no more than
'size' * 'nmemb' bytes! */
size_t retcode = fread(ptr, size, nmemb, readhere);
nread = (curl_off_t)retcode;
fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T
" bytes from file\n", nread);
return retcode;
}
void setup(char *uploadthis)
{
FILE *file = fopen(uploadthis, "rb");
CURLcode result;
/* set callback to use */
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* pass in suitable argument to callback */
curl_easy_setopt(curl, CURLOPT_READDATA, (void *)file);
result = curl_easy_perform(curl);
}
AVAILABILITY
CURL_READFUNC_PAUSE return code was added in 7.18.0 and CURL_READFUNC_ABORT was added in 7.12.1.RETURN VALUE
This will return CURLE_OK.SEE ALSO
CURLOPT_READDATA(3), CURLOPT_WRITEFUNCTION(3), CURLOPT_SEEKFUNCTION(3), CURLOPT_UPLOAD(3), CURLOPT_POST(3), CURLOPT_UPLOAD_BUFFERSIZE(3),May 17, 2022 | libcurl 7.84.0 |