cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Best way to issue member-callback after curl_multi_info_read returns CURLMSG_DONE

From: Yehezkel Horowitz <horowity_at_checkpoint.com>
Date: Mon, 18 Nov 2013 13:02:37 +0000

> // THIS IS WHAT I WANT TO CALL
> // memberfunction:
> Void onFinishedMemberCallback(...){
> //use collected data, callback owner and cleanup
> }

> // THIS IS ALL I CAN CALL
> Static Void onFinishedOrOtherEventCallback(..., CURL* easy_handle){
> //THIS IS WHAT I NEED:
> Void* pWriteData;
> curl_easy_getopt(easy_handle, CURLOPT_WRITEDATA, pWriteData);
> HTTPRequest* req = (HTTPRequest*) pWriteData;
> req->onFinishedMemberCallback(...);

Did you looked at http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPT_PRIVATE
And corresponding http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html#CURLINFO_PRIVATE ?

You can attach any "data" you want to the curl easy handle, and get it back (with correct down-cast).
I think this should do the job for you (with no changes in curl code).

HTH

Yehezkel

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-11-18