cURL / Mailing Lists / curl-users / Single Mail

curl-users

File Download

From: lakshmi <lakshmi_at_dikshatech.com>
Date: Thu, 24 Mar 2011 11:47:43 +0530

Hi,

Can you just let me know what the below piece of code does ?? A sample
program from curl ..

When the out->stream is NULL, it enters only once inside the if
condition but if it's not NULL, it keeps looping for many number of times !

Please suggest ??

static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void
*stream)
{
  struct FtpFile *out=(struct FtpFile *)stream;
  if(out && !out->stream) {
    /* open file for writing */
    out->stream=fopen(out->filename, "wb");
    if(!out->stream)
      return -1; /* failure, can't open file to write */
  }
  return fwrite(buffer, size, nmemb, out->stream);
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-03-24