xref: /curl/docs/libcurl/opts/CURLOPT_PRIVATE.md (revision 5a488251)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_PRIVATE
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_PRIVATE (3)
9  - CURLOPT_STDERR (3)
10  - CURLOPT_VERBOSE (3)
11Protocol:
12  - All
13Added-in: 7.10.3
14---
15
16# NAME
17
18CURLOPT_PRIVATE - store a private pointer
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PRIVATE, void *pointer);
26~~~
27
28# DESCRIPTION
29
30Pass a void * as parameter, pointing to data that should be associated with
31this curl handle. The pointer can subsequently be retrieved using
32curl_easy_getinfo(3) with the CURLINFO_PRIVATE(3) option. libcurl itself
33never does anything with this data.
34
35# DEFAULT
36
37NULL
38
39# %PROTOCOLS%
40
41# EXAMPLE
42
43~~~c
44struct private {
45  void *custom;
46};
47
48int main(void)
49{
50  CURL *curl = curl_easy_init();
51  struct private secrets;
52  if(curl) {
53    struct private *extracted;
54    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
55
56    /* store a pointer to our private struct */
57    curl_easy_setopt(curl, CURLOPT_PRIVATE, &secrets);
58
59    curl_easy_perform(curl);
60
61    /* we can extract the private pointer again too */
62    curl_easy_getinfo(curl, CURLINFO_PRIVATE, &extracted);
63  }
64}
65~~~
66
67# %AVAILABILITY%
68
69# RETURN VALUE
70
71Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
72