xref: /curl/docs/libcurl/opts/CURLOPT_DEBUGDATA.md (revision 5a488251)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_DEBUGDATA
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_DEBUGFUNCTION (3)
9  - CURLOPT_STDERR (3)
10Protocol:
11  - All
12Added-in: 7.9.6
13---
14
15# NAME
16
17CURLOPT_DEBUGDATA - pointer passed to the debug callback
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DEBUGDATA, void *pointer);
25~~~
26
27# DESCRIPTION
28
29Pass a *pointer* to whatever you want passed in to your
30CURLOPT_DEBUGFUNCTION(3) in the last void * argument. This pointer is
31not used by libcurl, it is only passed to the callback.
32
33# DEFAULT
34
35NULL
36
37# %PROTOCOLS%
38
39# EXAMPLE
40
41~~~c
42struct data {
43  void *custom;
44};
45
46static int my_trace(CURL *handle, curl_infotype type,
47                    char *data, size_t size,
48                    void *clientp)
49{
50  struct data *mine = clientp;
51  printf("our ptr: %p\n", mine->custom);
52
53  /* output debug info */
54}
55
56int main(void)
57{
58  CURL *curl;
59  CURLcode res;
60  struct data my_tracedata;
61
62  curl = curl_easy_init();
63  if(curl) {
64    curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
65
66    curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &my_tracedata);
67
68    /* the DEBUGFUNCTION has no effect until we enable VERBOSE */
69    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
70
71    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
72    res = curl_easy_perform(curl);
73
74    /* always cleanup */
75    curl_easy_cleanup(curl);
76  }
77  return 0;
78}
79~~~
80
81# %AVAILABILITY%
82
83# RETURN VALUE
84
85Returns CURLE_OK
86