diff options
Diffstat (limited to 'docs/examples/ftpuploadresume.c')
-rw-r--r-- | docs/examples/ftpuploadresume.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/docs/examples/ftpuploadresume.c b/docs/examples/ftpuploadresume.c index 06827ca52..641563404 100644 --- a/docs/examples/ftpuploadresume.c +++ b/docs/examples/ftpuploadresume.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -36,7 +36,8 @@ /* The MinGW headers are missing a few Win32 function definitions, you shouldn't need this if you use VC++ */ #if defined(__MINGW32__) && !defined(__MINGW64__) -int __cdecl _snscanf(const char * input, size_t length, const char * format, ...); +int __cdecl _snscanf(const char * input, size_t length, + const char * format, ...); #endif @@ -49,7 +50,7 @@ size_t getcontentlengthfunc(void *ptr, size_t size, size_t nmemb, void *stream) /* _snscanf() is Win32 specific */ r = _snscanf(ptr, size * nmemb, "Content-Length: %ld\n", &len); - if (r) /* Microsoft: we don't read the specs */ + if(r) /* Microsoft: we don't read the specs */ *((long *) stream) = len; return size * nmemb; @@ -67,7 +68,7 @@ size_t readfunc(void *ptr, size_t size, size_t nmemb, void *stream) FILE *f = stream; size_t n; - if (ferror(f)) + if(ferror(f)) return CURL_READFUNC_ABORT; n = fread(ptr, size, nmemb, f) * size; @@ -85,7 +86,7 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath, int c; f = fopen(localpath, "rb"); - if (f == NULL) { + if(!f) { perror(NULL); return 0; } @@ -94,7 +95,7 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath, curl_easy_setopt(curlhandle, CURLOPT_URL, remotepath); - if (timeout) + if(timeout) curl_easy_setopt(curlhandle, CURLOPT_FTP_RESPONSE_TIMEOUT, timeout); curl_easy_setopt(curlhandle, CURLOPT_HEADERFUNCTION, getcontentlengthfunc); @@ -105,14 +106,15 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath, curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, readfunc); curl_easy_setopt(curlhandle, CURLOPT_READDATA, f); - curl_easy_setopt(curlhandle, CURLOPT_FTPPORT, "-"); /* disable passive mode */ + /* disable passive mode */ + curl_easy_setopt(curlhandle, CURLOPT_FTPPORT, "-"); curl_easy_setopt(curlhandle, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L); curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 1L); - for (c = 0; (r != CURLE_OK) && (c < tries); c++) { + for(c = 0; (r != CURLE_OK) && (c < tries); c++) { /* are we resuming? */ - if (c) { /* yes */ + if(c) { /* yes */ /* determine the length of the file already written */ /* @@ -127,7 +129,7 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath, curl_easy_setopt(curlhandle, CURLOPT_HEADER, 1L); r = curl_easy_perform(curlhandle); - if (r != CURLE_OK) + if(r != CURLE_OK) continue; curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 0L); @@ -146,7 +148,7 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath, fclose(f); - if (r == CURLE_OK) + if(r == CURLE_OK) return 1; else { fprintf(stderr, "%s\n", curl_easy_strerror(r)); @@ -161,7 +163,8 @@ int main(int c, char **argv) curl_global_init(CURL_GLOBAL_ALL); curlhandle = curl_easy_init(); - upload(curlhandle, "ftp://user:pass@example.com/path/file", "C:\\file", 0, 3); + upload(curlhandle, "ftp://user:pass@example.com/path/file", "C:\\file", + 0, 3); curl_easy_cleanup(curlhandle); curl_global_cleanup(); |