CURLOPT_DEBUGDATA(3)

πŸ’… CURLOPT_DEBUGDATA β€” pointer passed to the debug callback πŸŽ€

okay bestie, welcome to the CURLOPT_DEBUGDATA(3) page from the Library Functions Manual ✨ this one is short, sweet, and honestly kinda iconic: it's all about handing your fave debug callback a little pointer of your very own 🫢


✨ NAME ✨

CURLOPT_DEBUGDATA β€” a pointer that gets passed straight to the debug callback πŸ’–


🌸 SYNOPSIS 🌸

#include <curl/curl.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: you pass in a pointer to literally whatever you want, and libcurl hands that same pointer to your CURLOPT_DEBUGFUNCTION(3) as its last void * argument πŸ’«

That's it. That's the whole job. libcurl does not use this pointer itself β€” it just passes it along to the callback, no cap 😌


πŸŽ€ DEFAULT πŸŽ€

NULL


🌈 PROTOCOLS 🌈

This functionality affects all supported protocols ✨


πŸ’œ EXAMPLE πŸ’œ

struct data {
  void *custom;
};

static int my_trace(CURL *handle, curl_infotype type,
                    char *data, size_t size,
                    void *clientp)
{
  struct data *mine = clientp;
  printf("our ptr: %p\n", mine->custom);

  /* output debug info */
  return 0;
}

int main(void)
{
  CURL *curl;
  CURLcode result;
  struct data my_tracedata;

  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);

    curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &my_tracedata);

    /* the DEBUGFUNCTION has no effect until we enable VERBOSE */
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
    result = curl_easy_perform(curl);

    /* always cleanup */
    curl_easy_cleanup(curl);
  }
  return 0;
}

⭐ AVAILABILITY ⭐

Added in curl 7.9.6 🧚


πŸ”₯ RETURN VALUE πŸ”₯

curl_easy_setopt(3) returns a CURLcode indicating success or error πŸ’…

CURLE_OK (0) means everything was OK β€” slay. A non-zero value means an error occurred, so go check libcurl-errors(3) bestie 😭


πŸ‘‘ SEE ALSO πŸ‘‘


that's the whole page, bestie β€” short, useful, and lowkey adorable πŸ’– this little icon was brought to you by libcurl, dated 2026-10-12, and yes she ate πŸ“βœ¨

πŸ“¦ where this page comes from