CURLOPT_READDATA.md (1597B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_READDATA 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_HEADERDATA (3) 9 - CURLOPT_READFUNCTION (3) 10 - CURLOPT_WRITEDATA (3) 11 - CURLOPT_WRITEFUNCTION (3) 12 Protocol: 13 - All 14 Added-in: 7.9.7 15 --- 16 17 # NAME 18 19 CURLOPT_READDATA - pointer passed to the read callback 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_READDATA, void *pointer); 27 ~~~ 28 29 # DESCRIPTION 30 31 Data *pointer* to pass to the file read function. If you use the 32 CURLOPT_READFUNCTION(3) option, this is the pointer you get as input in 33 the fourth argument to the callback. 34 35 If you do not specify a read callback but instead rely on the default internal 36 read function, this data must be a valid readable FILE * (cast to 'void *'). 37 38 If you are using libcurl as a DLL on Windows, you must use the 39 CURLOPT_READFUNCTION(3) callback if you set this option, otherwise you 40 might experience crashes. 41 42 # DEFAULT 43 44 stdin 45 46 # %PROTOCOLS% 47 48 # EXAMPLE 49 50 ~~~c 51 struct MyData { 52 void *custom; 53 }; 54 55 int main(void) 56 { 57 CURL *curl = curl_easy_init(); 58 struct MyData this; 59 if(curl) { 60 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 61 62 /* pass pointer that gets passed in to the 63 CURLOPT_READFUNCTION callback */ 64 curl_easy_setopt(curl, CURLOPT_READDATA, &this); 65 66 curl_easy_perform(curl); 67 } 68 } 69 ~~~ 70 71 # HISTORY 72 73 This option was once known by the older name CURLOPT_INFILE, the name 74 CURLOPT_READDATA(3) was introduced in 7.9.7. 75 76 # %AVAILABILITY% 77 78 # RETURN VALUE 79 80 This returns CURLE_OK.