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