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