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