CURLOPT_PRIVATE.3 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. .\" generated by cd2nroff 0.1 from CURLOPT_PRIVATE.md
  2. .TH CURLOPT_PRIVATE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_PRIVATE \- store a private pointer
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PRIVATE, void *pointer);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a void * as parameter, pointing to data that should be associated with
  12. this curl handle. The pointer can subsequently be retrieved using
  13. \fIcurl_easy_getinfo(3)\fP with the \fICURLINFO_PRIVATE(3)\fP option. libcurl itself
  14. never does anything with this data.
  15. .SH DEFAULT
  16. NULL
  17. .SH PROTOCOLS
  18. This functionality affects all supported protocols
  19. .SH EXAMPLE
  20. .nf
  21. struct private {
  22. void *custom;
  23. };
  24. int main(void)
  25. {
  26. CURL *curl = curl_easy_init();
  27. struct private secrets;
  28. if(curl) {
  29. struct private *extracted;
  30. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  31. /* store a pointer to our private struct */
  32. curl_easy_setopt(curl, CURLOPT_PRIVATE, &secrets);
  33. curl_easy_perform(curl);
  34. /* we can extract the private pointer again too */
  35. curl_easy_getinfo(curl, CURLINFO_PRIVATE, &extracted);
  36. }
  37. }
  38. .fi
  39. .SH AVAILABILITY
  40. Added in curl 7.10.3
  41. .SH RETURN VALUE
  42. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  43. .SH SEE ALSO
  44. .BR CURLINFO_PRIVATE (3),
  45. .BR CURLOPT_STDERR (3),
  46. .BR CURLOPT_VERBOSE (3)