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