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