cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLOPT_WRITEFUNCTION Callback

From: David Haugh <supercool_dave_at_yahoo.com>
Date: Sat, 20 Feb 2010 11:42:29 -0800 (PST)

Here is my code:
    CURL *d;
    d = curl_easy_init();
    fp = fopen(argv[2], "w");

    // Set libcurl options
    curl_easy_setopt(d, CURLOPT_URL, finalURL);
    curl_easy_setopt(d, CURLOPT_WRITEFUNCTION, NULL);
    curl_easy_setopt(d, CURLOPT_WRITEDATA, fp);
    curl_easy_setopt(d, CURLOPT_USERAGENT, "Mozilla/4.0");
    
    res = curl_easy_perform(d);
            
    fclose(fp);
    curl_easy_cleanup(c);

The curl_easy_setopt docs for CURLOPT_WRITEFUNCTION say: Set this option to NULL to get the internal default function. The
internal default function will write the data to the FILE * given with
CURLOPT_WRITEDATA. So shouldn't it be writing whatever it gets from finalURL to fp? Because the file pointed to by fp is completely blank no matter what the inputs to the program are. Help?

      

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-02-20