cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Doesn't fwrite() return the number of objects written, not the number of bytes?

From: Denis Bondarev <asterganster_at_gmail.com>
Date: Thu, 30 Jul 2009 13:00:34 +0300

Hello I learn how use CURLOPT_WRITEFUNCTION and how write result in file too
on http://www.livedevice.com/ground/curl_builder_c++/curl_builder_c++.html
This site on Russian language.

2009/7/29 ðÅÔßÒ é×ÁÎÏ× <petar.n.ivanov_at_abv.bg>

> Hi guys,
>
> I was just writing a simple FTP-based application that needs to download
> files from an FTP server. I am passing a FILE pointer to my CURLOPT_WRITEFUNCTION.
> I return (size * fwrite(buffer, size, nmemb, stream) ). I do this because
> 'man fwrite' says that fwrite() returns nmemb in case successful. Is this
> correct? Does the write callback really needs to return the number of bytes
> processed? It may overflow, as the return value is also size_t. The FTP
> example here: http://curl.haxx.se/lxr/source/docs/examples/ftpget.c
> returns fwrite() only. Or maybe I am missing something?
>
> Thanks.
>
> BR,
> Peter
>
Received on 2009-07-30