cURL / Mailing Lists / curl-library / Single Mail

curl-library

Question on example: ftpuploadresume.c

From: Ambarish Mitra <ambarish_mitra_at_persistent.co.in>
Date: Wed, 12 Nov 2008 16:52:49 +0530

This example (ftpuploadresume.c) demonstrates the "resume an upload to an
FTP server". This example is given in the docs/example directory.

In the receive header callback function, it finds out the response header
Content-Length. Code snippet:

long uploaded_len = 0;

curl_easy_setopt(curlhandle, CURLOPT_HEADERFUNCTION, getcontentlengthfunc);
curl_easy_setopt(curlhandle, CURLOPT_HEADERDATA, &uploaded_len);

size_t getcontentlengthfunc(void *ptr, size_t size, size_t nmemb, void
*stream) {
        int r;
        long len = 0;

        /* _snscanf() is Win32 specific */
        r = _snscanf(ptr, size * nmemb, "Content-Length: %ld\n", &len);

        if (r) /* Microsoft: we don't read the specs */
                *((long *) stream) = len;

        return size * nmemb;
}

My question is: Is this code specific to Win32? Will it not work for
Solaris/Linux? I ask this since _snscanf is specific to Win32 only.

DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.
Received on 2008-11-12