xref: /curl/docs/libcurl/opts/CURLINFO_PRIVATE.md (revision e3fe0200)
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
13---
14
15# NAME
16
17CURLINFO_PRIVATE - get the private pointer
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRIVATE, char **private);
25~~~
26
27# DESCRIPTION
28
29Pass a pointer to a char pointer to receive the pointer to the private data
30associated with the curl handle (set with the CURLOPT_PRIVATE(3)).
31Please note that for internal reasons, the value is returned as a char
32pointer, although effectively being a 'void *'.
33
34# EXAMPLE
35
36~~~c
37int main(void)
38{
39  CURL *curl = curl_easy_init();
40  if(curl) {
41    CURLcode res;
42    void *pointer = (void *)0x2345454;
43    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
44
45    /* set the private pointer */
46    curl_easy_setopt(curl, CURLOPT_PRIVATE, pointer);
47    res = curl_easy_perform(curl);
48
49    /* extract the private pointer again */
50    res = curl_easy_getinfo(curl, CURLINFO_PRIVATE, &pointer);
51
52    if(res)
53      printf("error: %s\n", curl_easy_strerror(res));
54
55    curl_easy_cleanup(curl);
56  }
57}
58~~~
59
60# AVAILABILITY
61
62Added in 7.10.3
63
64# RETURN VALUE
65
66Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
67