CURLINFO_PRIVATE.md (1483B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLINFO_PRIVATE 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_PRIVATE (3) 9 - curl_easy_getinfo (3) 10 - curl_easy_setopt (3) 11 Protocol: 12 - All 13 Added-in: 7.10.3 14 --- 15 16 # NAME 17 18 CURLINFO_PRIVATE - get the private pointer 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRIVATE, char **private); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a pointer to a char pointer to receive the pointer to the private data 31 associated with the curl handle (set with the CURLOPT_PRIVATE(3)). 32 Please note that for internal reasons, the value is returned as a char 33 pointer, although effectively being a 'void *'. 34 35 # %PROTOCOLS% 36 37 # EXAMPLE 38 39 ~~~c 40 int main(void) 41 { 42 CURL *curl = curl_easy_init(); 43 if(curl) { 44 CURLcode res; 45 void *pointer = (void *)0x2345454; 46 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); 47 48 /* set the private pointer */ 49 curl_easy_setopt(curl, CURLOPT_PRIVATE, pointer); 50 res = curl_easy_perform(curl); 51 52 /* extract the private pointer again */ 53 res = curl_easy_getinfo(curl, CURLINFO_PRIVATE, &pointer); 54 55 if(res) 56 printf("error: %s\n", curl_easy_strerror(res)); 57 58 curl_easy_cleanup(curl); 59 } 60 } 61 ~~~ 62 63 # %AVAILABILITY% 64 65 # RETURN VALUE 66 67 curl_easy_getinfo(3) returns a CURLcode indicating success or error. 68 69 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 70 libcurl-errors(3).