curl-library
RE: Binary data
Date: Sun, 6 Apr 2003 14:43:09 +0200 (CEST)
On Sun, 6 Apr 2003, Sigal Algranaty wrote:
What libcurl version on what platform is this?
> I don't know what's the problem, but I can't make it work. All I wanna do
> is download binary file.
Can you make the curl command line tool to work? If so, then you know libcurl
works and downloads it fine if used correctly.
> That's my program. Seem quite simple, but what happens is really weird.
> Either the file that I'm opening is left empty, or it is filled with data
> that is not an image.
You really *SHOULD* see what return code you get from curl_easy_perform().
What if it returns an error? Then use the CURLOPT_ERRORBUFFER option to set a
error message buffer to get a descriptive message to read.
> Can anyone please tell me what I'm doing wrong?
I could only see one immidiate minor problem:
> size_t write_callback(void *buffer,
> size_t size,
> size_t nitems,
> void *userp)
> {
> FILE *file = (FILE *)userp;
> size_t write;
> size *= nitems;
> write = fwrite(buffer, size, nitems, file);
> return size;
This function should return 'write', the number of bytes that fwrite()
actually wrote, so that libcurl can properly bail out on write errors.
-- Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs. ------------------------------------------------------- This SF.net email is sponsored by: ValueWeb: Dedicated Hosting for just $79/mo with 500 GB of bandwidth! No other company gives more support or power for your dedicated server http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/Received on 2003-04-06