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