CURLOPT_PROGRESSDATA(3)

πŸ’… CURLOPT_PROGRESSDATA(3) β€” the libcurl fam, Library Functions Manual energy ✨

okay bestie, so this one is like... a page from the libcurl manual, and it's genuinely so simple it's kind of iconic? no cap. it's literally just "hey, hold this pointer for me" 🫢


πŸŽ€ NAME πŸŽ€

CURLOPT_PROGRESSDATA β€” the pointer you pass along to the progress callback πŸ’«


✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROGRESSDATA, void *pointer);

look at her. one line. no notes. πŸ‘‘


🌸 DESCRIPTION 🌸

so here's the vibe: you hand libcurl a pointer, and libcurl is so well-behaved about it β€” it does not touch it. like, not even a little. it just holds it gently 🫢 and then passes it straight back to you as the first argument in the progress callback you set with CURLOPT_PROGRESSFUNCTION(3).

that's it. that's the whole function. it's giving "designated bag-holder" and honestly? we love that for us πŸ’…


πŸ¦‹ DEFAULT πŸ¦‹

NULL

(as in, nothing. no pointer. resting state. πŸ™ˆ)


🌈 PROTOCOLS 🌈

this functionality affects all supported protocols β€” every single one of them, no favorites, we don't play that game πŸ’–


πŸ“ EXAMPLE πŸ“

okay so this is the part where it gets cute β€” look at this little struct living its best life:

struct progress {
  char *private;
  size_t size;
};

static int progress_callback(void *clientp,
                             double dltotal,
                             double dlnow,
                             double ultotal,
                             double ulnow)
{
  struct progress *memory = clientp;
  printf("private: %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_PROGRESSDATA, &data);
    curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);

    curl_easy_perform(curl);
  }
}

see how clientp in the callback is literally the &data we passed in? that's the whole trick bestie, that's the magic trick 🧚✨ and yes, the return 0; means "all is good" β€” that's a direct quote from the source, i'm not making that up 😭


⭐ AVAILABILITY ⭐

Added in curl 7.1 β€” she's an elder, she's been here since the beginning, respect her πŸ‘‘


πŸ’€ 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 😭 β€” see libcurl-errors(3) for the full tea

πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie!! no crumbs, we ate πŸ½οΈπŸ’…

sign-off szn: this little gem comes to you from libcurl, dated 2026-10-12 β€” go forth and pass your pointers with confidence, you're gonna slay πŸ«ΆπŸŽ€πŸ¦‹

πŸ“¦ where this page comes from