quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

CURLOPT_DEBUGDATA.md (1697B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: CURLOPT_DEBUGDATA
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - CURLOPT_DEBUGFUNCTION (3)
      9   - CURLOPT_STDERR (3)
     10 Protocol:
     11   - All
     12 Added-in: 7.9.6
     13 ---
     14 
     15 # NAME
     16 
     17 CURLOPT_DEBUGDATA - pointer passed to the debug callback
     18 
     19 # SYNOPSIS
     20 
     21 ~~~c
     22 #include <curl/curl.h>
     23 
     24 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DEBUGDATA, void *pointer);
     25 ~~~
     26 
     27 # DESCRIPTION
     28 
     29 Pass a *pointer* to whatever you want passed in to your
     30 CURLOPT_DEBUGFUNCTION(3) in the last void * argument. This pointer is
     31 not used by libcurl, it is only passed to the callback.
     32 
     33 # DEFAULT
     34 
     35 NULL
     36 
     37 # %PROTOCOLS%
     38 
     39 # EXAMPLE
     40 
     41 ~~~c
     42 struct data {
     43   void *custom;
     44 };
     45 
     46 static 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   return 0;
     55 }
     56 
     57 int main(void)
     58 {
     59   CURL *curl;
     60   CURLcode res;
     61   struct data my_tracedata;
     62 
     63   curl = curl_easy_init();
     64   if(curl) {
     65     curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
     66 
     67     curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &my_tracedata);
     68 
     69     /* the DEBUGFUNCTION has no effect until we enable VERBOSE */
     70     curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
     71 
     72     curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
     73     res = curl_easy_perform(curl);
     74 
     75     /* always cleanup */
     76     curl_easy_cleanup(curl);
     77   }
     78   return 0;
     79 }
     80 ~~~
     81 
     82 # %AVAILABILITY%
     83 
     84 # RETURN VALUE
     85 
     86 curl_easy_setopt(3) returns a CURLcode indicating success or error.
     87 
     88 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     89 libcurl-errors(3).