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