curl-library
About write call function
Date: Wed, 14 May 2008 11:25:57 +0530
Hi All;
For receiving the data coming from server I set below option and
write ReadCallback function. In ReadCallback function I am storing data in
char Http_Rx_Data[102400] and char *http_ptr= &Http_Rx_Data[0];
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ReadCallback);
int totalsize;
void ReadCallback( char *data_ptr, size_t size, size_t nmemb, char *data)
{
unsigned int data_size;
data_size = size * nmemb;
if ((totalsize+data_size) <= 102400)
{
memcpy(http_ptr,data_ptr,data_size);
http_ptr+=data_size;
totalsize += data_size;
printf("\n ReadCallback - totalsize = %d \n",totalsize);
fflush(stdout);
}
else
{
totalsize = 0;
http_ptr = &Http_Rx_Data[0];
memcpy(http_ptr,data_ptr,data_size);
http_ptr+=data_size;
totalsize += data_size;
printf("\n ReadCallback - totalsize = %d \n",totalsize);
fflush(stdout);
}
}
Actually my doubt is if we want to write the data to our defined buffer it
is possible instead of file write. Actually I saw after curl_easy_perform
response was
CURLE_WRITE_ERROR.
Another way I also tried http_ptr =data; this is failed. Actually if we do
http_ptr =data & memcpy(http_ptr,data_ptr,data_size);
then we will not able to write the data what we define buffer
Http_Rx_Data[102400];
Please suggest me how we can write data to our own defined buffer using
write call back function.
Thank you.
Regards;
Ajeet Kumar Singh
Received on 2008-05-14