CURLOPT_XFERINFODATA(3)
β¨ CURLOPT_XFERINFODATA(3) β¨
okay bestie, welcome to the libcurl manual page for CURLOPT_XFERINFODATA π
this one lives in the Library Functions Manual and honestly it's giving "small but mighty" β it's literally just a pointer, but it's the pointer that makes your progress callback not be lonely π«Ά
πΈ NAME πΈ
CURLOPT_XFERINFODATA β the pointer you pass to the progress callback π
π SYNOPSIS π
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XFERINFODATA, void *pointer);
π¦ DESCRIPTION π¦
So here's the vibe: you pass in a pointer, and libcurl does not touch it. Not even a little. It just holds onto it and hands it right back to you as the first argument of the progress callback that you set with CURLOPT_XFERINFOFUNCTION(3). That's it. That's the whole job. iconic behavior honestly π
And plot twist β this is an alias for CURLOPT_PROGRESSDATA(3). same energy, different name, iykyk β¨
π DEFAULT π
NULL
(no pointer, no problem β just nothing passed along π)
π PROTOCOLS π
This functionality affects all supported protocols π like, all of them, no cap.
β EXAMPLE β
ok so imagine you've got a struct you wanna smuggle into your callback β here's how the girlies do it:
struct progress {
char *private;
size_t size;
};
static int progress_cb(void *clientp,
curl_off_t dltotal,
curl_off_t dlnow,
curl_off_t ultotal,
curl_off_t ulnow)
{
struct progress *memory = clientp;
printf("private ptr: %p\n", memory->private);
/* use the values */
return 0; /* all is good */
}
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
struct progress data;
/* pass struct to callback */
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &data);
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_cb);
}
}
see how clientp in the callback is literally your &data? that's the whole trick bestie π§ the pointer comes back to you completely untouched, main character energy fr fr π₯
π AVAILABILITY π
Added in curl 7.32.0 β so she's been around a minute π
π RETURN VALUE π
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK π non-zero means an error occurred π β go check libcurl-errors(3) for the deets.
π SEE ALSO π
ok that's the whole page, go forth and pass pointers responsibly ππβ¨
ngl the actual manual says this page comes from libcurl and is dated 2026-10-12 β so yeah, that's the source, the version, and the date, all cute and accounted for π«Άπ slay.
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms