CURLOPT_READDATA.3 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. .\" generated by cd2nroff 0.1 from CURLOPT_READDATA.md
  2. .TH CURLOPT_READDATA 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_READDATA \- pointer passed to the read callback
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_READDATA, void *pointer);
  9. .fi
  10. .SH DESCRIPTION
  11. Data \fIpointer\fP to pass to the file read function. If you use the
  12. \fICURLOPT_READFUNCTION(3)\fP option, this is the pointer you get as input in
  13. the fourth argument to the callback.
  14. If you do not specify a read callback but instead rely on the default internal
  15. read function, this data must be a valid readable FILE * (cast to \(aqvoid *\(aq).
  16. If you are using libcurl as a DLL on Windows, you must use the
  17. \fICURLOPT_READFUNCTION(3)\fP callback if you set this option, otherwise you
  18. might experience crashes.
  19. .SH DEFAULT
  20. stdin
  21. .SH PROTOCOLS
  22. This functionality affects all supported protocols
  23. .SH EXAMPLE
  24. .nf
  25. struct MyData {
  26. void *custom;
  27. };
  28. int main(void)
  29. {
  30. CURL *curl = curl_easy_init();
  31. struct MyData this;
  32. if(curl) {
  33. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  34. /* pass pointer that gets passed in to the
  35. CURLOPT_READFUNCTION callback */
  36. curl_easy_setopt(curl, CURLOPT_READDATA, &this);
  37. curl_easy_perform(curl);
  38. }
  39. }
  40. .fi
  41. .SH HISTORY
  42. This option was once known by the older name CURLOPT_INFILE, the name
  43. \fICURLOPT_READDATA(3)\fP was introduced in 7.9.7.
  44. .SH AVAILABILITY
  45. Added in curl 7.9.7
  46. .SH RETURN VALUE
  47. This returns CURLE_OK.
  48. .SH SEE ALSO
  49. .BR CURLOPT_HEADERDATA (3),
  50. .BR CURLOPT_READFUNCTION (3),
  51. .BR CURLOPT_WRITEDATA (3),
  52. .BR CURLOPT_WRITEFUNCTION (3)