curl-library
RE: Problems with Http download under windows
Date: Mon, 30 Jun 2008 11:05:14 -0700
Loic Quertenmont wrote:
>
> I have just found the error
>
> FILE * fp = fopen(out_file, "w");
> -->
> FILE * fp = fopen(out_file, "wb");
>
> Because we are working with binary files and not txt file.
> the strange thing is that it works perfectly under linux (strange
strange
> ;) )
>
> 2008/6/30, Joe Nardone <jnardone_at_gmail.com>:
> > > curl_easy_setopt(session, CURLOPT_WRITEFUNCTION, fwrite);
> >
> > What is your implementation of the "fwrite" function?
> >
> > If this is the c-library "fwrite" then you have not read the docs
right.
> >
> > j
> >
Basically, you are using the default behavior of libcurl, but doing so
in a way which may confuse future maintainers of your code.
All you really have to do is
- perform your fopen() call with whatever options you want,
- pass the FILE * variable to libcurl via the CURLOPT_WRITEDATA option,
and
- set the write callback function to NULL.
Libcurl will guarantee that this works across all platforms, and not
just linux.
See
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTWRITEFUNCTION
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTWRITEDATA
Cheers,
Gary
Received on 2008-06-30