curl-library
Re: Callback and writefunction
Date: Sat, 23 Jul 2005 20:10:46 -0000
On Sat, Jul 23, 2005, Sue Stones <cyberstones_at_gmail.com> said:
> I am trying to use curl to download webpages for processing but am
> having problems. Whenever I use libcurl I find that the download
> doesn't finish and it crashes my program. When I use curl manually on
> the command line I have no problems.
>
> I am wondering if the its something to do with callback and write
> function, but I cannot find anything that explains what callback is,
> or what the writefunction should do. All I have found in the
> documentation seems to assume that the reader is already familiar with
> these concepts, and it simply states that they are necessary.
>
> Is there any explanation anywhere. Can someone explaine these things?
>
check out the examples that come with the curl source. the prototype is
also in the manual: http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
under 'CALLBACK OPTIONS'
basically, you register a callback function and a void pointer with
libcurl, before you perform().
every time libcurl gets some chunk of data from the server, it will call
your callback, and provide (among other things) a pointer to the incoming
data, and your original void pointer. your callback could copy the data
from the input to the output buffer, or print it to stdout, etc. that will
depend on your needs.
return value from the callback is important, watch out for that.
allan
Received on 2005-07-23