cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Get what WRITEFUNCTION will return ?

From: Jeff Pohlmeyer <yetanothergeek_at_gmail.com>
Date: Sat, 26 Feb 2011 09:07:55 -0600

On Sat, Feb 26, 2011 at 8:49 AM, Iskander Ben mahmoud wrote:
> There is any way to get what WriteFunction will return ?
>
> size_t verif_function(void *ptr, size_t size, size_t nmemb, void *userdata)
> {
>    if(strlen(ptr)>144)
>     return 0;
>    else
>     return 1;
> }

Your write function should return (size*nmemb), which is also the
number of bytes contained in ptr. So you don't need strlen, and using
it on binary data is almost sure to cause you more problems.

Returning any value other than (size*nmemb) will cause libcurl to
cancel the transfer.

 - Jeff

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