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