CURLMOPT_TIMERDATA.3 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. .\" generated by cd2nroff 0.1 from CURLMOPT_TIMERDATA.md
  2. .TH CURLMOPT_TIMERDATA 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLMOPT_TIMERDATA \- custom pointer to pass to timer callback
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_TIMERDATA, void *pointer);
  9. .fi
  10. .SH DESCRIPTION
  11. A data \fBpointer\fP to pass to the timer callback set with the
  12. \fICURLMOPT_TIMERFUNCTION(3)\fP option.
  13. This pointer is not touched by libcurl but is only be passed in to the timer
  14. callback\(aqs \fBclientp\fP argument.
  15. .SH DEFAULT
  16. NULL
  17. .SH PROTOCOLS
  18. This functionality affects all supported protocols
  19. .SH EXAMPLE
  20. .nf
  21. struct priv {
  22. void *custom;
  23. };
  24. static int timerfunc(CURLM *multi, long timeout_ms, void *clientp)
  25. {
  26. struct priv *mydata = clientp;
  27. printf("our ptr: %p\\n", mydata->custom);
  28. if(timeout_ms) {
  29. /* this is the new single timeout to wait for */
  30. }
  31. else {
  32. /* delete the timeout, nothing to wait for now */
  33. }
  34. }
  35. int main(void)
  36. {
  37. struct priv mydata;
  38. CURLM *multi = curl_multi_init();
  39. curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc);
  40. curl_multi_setopt(multi, CURLMOPT_TIMERDATA, &mydata);
  41. }
  42. .fi
  43. .SH AVAILABILITY
  44. Added in curl 7.16.0
  45. .SH RETURN VALUE
  46. Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
  47. .SH SEE ALSO
  48. .BR CURLMOPT_SOCKETFUNCTION (3),
  49. .BR CURLMOPT_TIMERFUNCTION (3)