CURLOPT_PREREQDATA.3 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. .\" generated by cd2nroff 0.1 from CURLOPT_PREREQDATA.md
  2. .TH CURLOPT_PREREQDATA 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_PREREQDATA \- pointer passed to the pre\-request callback
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PREREQDATA, void *pointer);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a \fIpointer\fP that is untouched by libcurl and passed as the first
  12. argument in the pre\-request callback set with \fICURLOPT_PREREQFUNCTION(3)\fP.
  13. .SH DEFAULT
  14. NULL
  15. .SH PROTOCOLS
  16. This functionality affects all supported protocols
  17. .SH EXAMPLE
  18. .nf
  19. struct priv {
  20. void *custom;
  21. };
  22. static int prereq_callback(void *clientp,
  23. char *conn_primary_ip,
  24. char *conn_local_ip,
  25. int conn_primary_port,
  26. int conn_local_port)
  27. {
  28. printf("Connection made to %s:%d\\n", conn_primary_ip, conn_primary_port);
  29. return CURL_PREREQFUNC_OK;
  30. }
  31. int main(void)
  32. {
  33. struct priv prereq_data;
  34. CURL *curl = curl_easy_init();
  35. if(curl) {
  36. curl_easy_setopt(curl, CURLOPT_PREREQFUNCTION, prereq_callback);
  37. curl_easy_setopt(curl, CURLOPT_PREREQDATA, &prereq_data);
  38. curl_easy_perform(curl);
  39. }
  40. }
  41. .fi
  42. .SH AVAILABILITY
  43. Added in curl 7.80.0
  44. .SH RETURN VALUE
  45. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  46. .SH SEE ALSO
  47. .BR CURLINFO_PRIMARY_IP (3),
  48. .BR CURLINFO_PRIMARY_PORT (3),
  49. .BR CURLOPT_PREREQFUNCTION (3)