cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to retrieve "context" information in write/read callbacks?

From: Michal Marek <mmarek_at_suse.cz>
Date: Wed, 06 Feb 2008 18:19:31 +0100

Andrea Funtò wrote:
> etc. A callback registering function looks like:
> void set_my_callback(callback_function_ptr_t fx_ptr, void *
> callback_data);
> and when you actually use it in a C++ class, you can do something like:
> set_my_callback(<static method of my class>, (void *)this);
> so the "stub" callback you provide in the <static member of the class> can
> go back to object orientation by grabbing and casting as appropriate the
> callback_data.
> Unfortunately I cannot see this feature in libcurl: if I register a write
> callback with curl_easy_setopt(CURLOPT_WRITEFUNCTION), I can only provide a
> pointer to the memory area to be filled by libcurl before invoking my
> callback (through CURLOPT_WRITEDATA).

??

How is
curl_easy_setopt(CURLOPT_WRITEFUNCTION, <static method of my class>);
curl_easy_setopt(CURLOPT_WRITEDATA, (void *)this);
different from
set_my_callback(<static method of my class>, (void *)this);
?

Michal
Received on 2008-02-06