CURLOPT_WRITEDATA.md (1585B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_WRITEDATA 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_HEADERDATA (3) 9 - CURLOPT_READDATA (3) 10 - CURLOPT_WRITEFUNCTION (3) 11 Protocol: 12 - All 13 Added-in: 7.9.7 14 --- 15 16 # NAME 17 18 CURLOPT_WRITEDATA - pointer passed to the write callback 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WRITEDATA, void *pointer); 26 ~~~ 27 28 # DESCRIPTION 29 30 A data *pointer* to pass to the write callback. If you use the 31 CURLOPT_WRITEFUNCTION(3) option, this is the pointer you get in that 32 callback's fourth and last argument. If you do not use a write callback, you 33 must make *pointer* a 'FILE *' (cast to 'void *') as libcurl passes this 34 to *fwrite(3)* when writing data. 35 36 The internal CURLOPT_WRITEFUNCTION(3) writes the data to the FILE * 37 given with this option, or to stdout if this option has not been set. 38 39 If you are using libcurl as a Windows DLL, you **MUST** use a 40 CURLOPT_WRITEFUNCTION(3) if you set this option or you might experience 41 crashes. 42 43 # DEFAULT 44 45 stdout 46 47 # %PROTOCOLS% 48 49 # EXAMPLE 50 51 A common technique is to use the write callback to store the incoming data 52 into a dynamically growing allocated buffer, and then this 53 CURLOPT_WRITEDATA(3) is used to point to a struct or the buffer to store data 54 in. Like in the *getinmemory* example: 55 https://curl.se/libcurl/c/getinmemory.html 56 57 # HISTORY 58 59 This option was formerly known as CURLOPT_FILE, the name CURLOPT_WRITEDATA(3) 60 was added in 7.9.7. 61 62 # %AVAILABILITY% 63 64 # RETURN VALUE 65 66 This returns CURLE_OK.