curl-library
Re: write callback
Date: Wed, 25 Jul 2001 15:45:23 +0800
"Judith NATAF" <jnataf_at_telisma.com> wrote:
> While using the write callback for the received data,
>
> size_t write_data(void *ptr, size_t size, size_t nmemb, void * stream)
>
> I don't want to do a simple "fwrite", but need to give some additional
datas
> to the callback (the name of the file for exemple).
What you need to do is put those into your own structure, and then pass
a pointer to that.
So something like the following...
// amongst everything else, you'd get
// "a is 10, b is 1337"
typedef struct {
int a, b;
// other stuff
} myStruct;
size_t my_write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
myStruct *myData;
myData = (myStruct *)stream;
printf("a is %d, b is %d", myData->a, myData->b);
// everything else ...
}
main(..) {
.....
MyStruct dat;
dat.a = 10;
dat.b = 1337;
curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, my_write_data);
curl_easy_setopt(curlHandle, CURLOPT_FILE, &dat);
/* get it! */
curl_easy_perform(curlHandle);
.....
}
-- Andrew Francis locust_at_familyhealth.com.au _______________________________________________ Curl-library mailing list http://curl.haxx.se/libcurl/Received on 2001-07-25