diff options
Diffstat (limited to 'docs/examples/ftpupload.c')
-rw-r--r-- | docs/examples/ftpupload.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/docs/examples/ftpupload.c b/docs/examples/ftpupload.c index 1b7bbf26a..75356d86a 100644 --- a/docs/examples/ftpupload.c +++ b/docs/examples/ftpupload.c @@ -50,16 +50,17 @@ variable's memory when passed in to it from an app like this. */ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) { - curl_off_t nread; + unsigned long nread; /* in real-world cases, this would probably get this data differently as this fread() stuff is exactly what the library already would do by default internally */ size_t retcode = fread(ptr, size, nmemb, stream); - nread = (curl_off_t)retcode; + if(retcode > 0) { + nread = (unsigned long)retcode; + fprintf(stderr, "*** We read %lu bytes from file\n", nread); + } - fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T - " bytes from file\n", nread); return retcode; } @@ -69,7 +70,7 @@ int main(void) CURLcode res; FILE *hd_src; struct stat file_info; - curl_off_t fsize; + unsigned long fsize; struct curl_slist *headerlist = NULL; static const char buf_1 [] = "RNFR " UPLOAD_FILE_AS; @@ -80,9 +81,9 @@ int main(void) printf("Couldn't open '%s': %s\n", LOCAL_FILE, strerror(errno)); return 1; } - fsize = (curl_off_t)file_info.st_size; + fsize = (unsigned long)file_info.st_size; - printf("Local file size: %" CURL_FORMAT_CURL_OFF_T " bytes.\n", fsize); + printf("Local file size: %lu bytes.\n", fsize); /* get a FILE * of the same file */ hd_src = fopen(LOCAL_FILE, "rb"); |