CURLOPT_WRITEDATA.3 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. .\" generated by cd2nroff 0.1 from CURLOPT_WRITEDATA.md
  2. .TH CURLOPT_WRITEDATA 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_WRITEDATA \- pointer passed to the write callback
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WRITEDATA, void *pointer);
  9. .fi
  10. .SH DESCRIPTION
  11. A data \fIpointer\fP to pass to the write callback. If you use the
  12. \fICURLOPT_WRITEFUNCTION(3)\fP option, this is the pointer you get in that
  13. callback\(aqs fourth and last argument. If you do not use a write callback, you
  14. must make \fIpointer\fP a \(aqFILE \fI\(aq (cast to \(aqvoid \fP\(aq) as libcurl passes this
  15. to \fIfwrite(3)\fP when writing data.
  16. The internal \fICURLOPT_WRITEFUNCTION(3)\fP writes the data to the FILE *
  17. given with this option, or to stdout if this option has not been set.
  18. If you are using libcurl as a Windows DLL, you \fBMUST\fP use a
  19. \fICURLOPT_WRITEFUNCTION(3)\fP if you set this option or you might experience
  20. crashes.
  21. .SH DEFAULT
  22. stdout
  23. .SH PROTOCOLS
  24. This functionality affects all supported protocols
  25. .SH EXAMPLE
  26. A common technique is to use the write callback to store the incoming data
  27. into a dynamically growing allocated buffer, and then this
  28. \fICURLOPT_WRITEDATA(3)\fP is used to point to a struct or the buffer to store data
  29. in. Like in the getinmemory example:
  30. https://curl.se/libcurl/c/getinmemory.html
  31. .SH HISTORY
  32. This option was formerly known as CURLOPT_FILE, the name \fICURLOPT_WRITEDATA(3)\fP
  33. was added in 7.9.7.
  34. .SH AVAILABILITY
  35. Added in curl 7.9.7
  36. .SH RETURN VALUE
  37. This returns CURLE_OK.
  38. .SH SEE ALSO
  39. .BR CURLOPT_HEADERDATA (3),
  40. .BR CURLOPT_READDATA (3),
  41. .BR CURLOPT_WRITEFUNCTION (3)