xref: /curl/docs/libcurl/opts/CURLINFO_PRIVATE.md (revision 5a488251)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.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)
11Protocol:
12  - All
13Added-in: 7.10.3
14---
15
16# NAME
17
18CURLINFO_PRIVATE - get the private pointer
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRIVATE, char **private);
26~~~
27
28# DESCRIPTION
29
30Pass a pointer to a char pointer to receive the pointer to the private data
31associated with the curl handle (set with the CURLOPT_PRIVATE(3)).
32Please note that for internal reasons, the value is returned as a char
33pointer, although effectively being a 'void *'.
34
35# %PROTOCOLS%
36
37# EXAMPLE
38
39~~~c
40int 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
67Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
68