cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: CURLOPT_WRITEFUNCTION - cannot make it working...

From: Paolo Piacentini <paolopiace_at_hotmail.com>
Date: Sat, 4 Jun 2011 22:48:26 -0700

I finally made it working. The big problem is that, with NO doubt, curl_easy_perform changes (corrupts?) the initialization of the vars in the user data structure (say data_struct) passed to CURLOPT_WRITEDATA. Therefore, the write-back function defined with CURLOPT_WRITEFUNCTION *cannot* rely on the user initialization.

Interestingly, curl_easy_perform changes the initialization of any size_t var in the data_struct to a random value around 3.07e+9 *. Therefore, the first time the write-back function is called, it sees such value assigned to all size_t variable of data_struct.

Hence, in order to make the write-back function to initialize the storing of data, I'm checking a (any) size_t vars in data_struct. If it's higher than 3e+9 it means that the write-back function has been called for the very first time.

After that, curl_easy_perform leaves the data_struct alone, with some
exception: I noticed that it resets all the vars in the data_struct
(literally!) sometimes/somehow while receiving the data of the thread.
But this might be a design feature as it does not create problems.

(*) I'm on Ubuntu 10.04; g++ 4.4.3; libcurl/7.19.7 GnuTLS/2.8.5 zlib/1.2.3.3 libidn/1.1
                                               

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-06-05