curl-library
Documentation Issue: WRITEFUNCTION, HEADERFUNCTION, et all vs man fwrite(3)
Date: Thu, 9 Dec 2010 14:14:29 -0800
Hi;
Here is what the linux manpage says about the return value of fwrite:
RETURN VALUE
fread() and fwrite() return the number of items successfully read or written (i.e., not the number of characters).
Here is what the curl C API docs say about the return value for the function that implements
CURLOPT_WRITEFUNCTION
Function pointer that should match the following prototype: size_t function( void *ptr, size_t size, size_t nmemb, void *userdata); This function gets called by libcurl as soon as there is data received that needs to be saved. The size of the data pointed to by ptr is size multiplied with nmemb, it will not be zero terminated. Return the number of bytes actually taken care of.
here is the sample implementation in ftpgetresp.c:
static size_t
write_response(void *ptr, size_t size, size_t nmemb, void *data)
{
FILE *writehere = (FILE *)data;
return fwrite(ptr, size, nmemb, writehere);
}
So, based on the fwrite manpage, this function should be returning the value of nmemb, not size*nmemb as the curl manpages and sample code seem to suggest.
It seems to me that both documents can not be correct. Am I misunderstanding something?
tnx!
johnu
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-12-09