Movatterモバイル変換


[0]ホーム

URL:


API Overview
Docs
API: easyAPI: multiAPI: shareAPI: URLAPI: WebSocketEnvironment varsErrorsExamplesSecuritySymbolsTutorial
easy setopt optionseasy getinfo optionsmulti setopt optionsTLS options
Functions
All functionscurl_easy_getinfocurl_easy_initcurl_easy_performcurl_easy_resetcurl_easy_setoptcurl_multi_add_handlecurl_multi_initcurl_multi_performcurl_multi_remove_handlecurl_multi_setopt
curl /libcurl /API /Examples /ftpuploadresume.c

ftpuploadresume.c

Related:
All functions
File a bug
Symbols
View in git
View raw
 ###  size_t( *ptr, size_t size, size_t nmemb, *stream){ r; len = 0;   r = sscanf(ptr,, &len);(r)    *(( *) stream) = len;  size * nmemb;}  size_t( *ptr, size_t size, size_t nmemb, *stream){  ()ptr;  ()stream; size * nmemb;}  size_t( *ptr, size_t size, size_t nmemb, *stream){  FILE *f = stream;  size_t n; (ferror(f)) CURL_READFUNC_ABORT;   n = fread(ptr, size, nmemb, f) * size;  n;}  (CURL *curlhandle, *remotepath, *localpath, timeout, tries){  FILE *f; uploaded_len = 0;  CURLcode r = CURLE_GOT_NOTHING; c;   f = fopen(localpath,);(!f) {#     perror(NULL);# 0;  } curl_easy_setopt(curlhandle,CURLOPT_UPLOAD, 1L); curl_easy_setopt(curlhandle,CURLOPT_URL, remotepath); (timeout)curl_easy_setopt(curlhandle,CURLOPT_SERVER_RESPONSE_TIMEOUT, timeout); curl_easy_setopt(curlhandle,CURLOPT_HEADERFUNCTION, getcontentlengthfunc);curl_easy_setopt(curlhandle,CURLOPT_HEADERDATA, &uploaded_len); curl_easy_setopt(curlhandle,CURLOPT_WRITEFUNCTION, discardfunc); curl_easy_setopt(curlhandle,CURLOPT_READFUNCTION, readfunc);curl_easy_setopt(curlhandle,CURLOPT_READDATA, f); curl_easy_setopt(curlhandle,CURLOPT_FTPPORT,); curl_easy_setopt(curlhandle,CURLOPT_ACCEPTTIMEOUT_MS, 7000L); curl_easy_setopt(curlhandle,CURLOPT_FTP_CREATE_MISSING_DIRS, 1L); curl_easy_setopt(curlhandle,CURLOPT_VERBOSE, 1L); (c = 0; (r != CURLE_OK) && (c < tries); c++) {(c) { curl_easy_setopt(curlhandle,CURLOPT_NOBODY, 1L);curl_easy_setopt(curlhandle,CURLOPT_HEADER, 1L);       r =curl_easy_perform(curlhandle);(r != CURLE_OK)curl_easy_setopt(curlhandle,CURLOPT_NOBODY, 0L);curl_easy_setopt(curlhandle,CURLOPT_HEADER, 0L);       fseek(f, uploaded_len, SEEK_SET); curl_easy_setopt(curlhandle,CURLOPT_APPEND, 1L);    } {curl_easy_setopt(curlhandle,CURLOPT_APPEND, 0L);    }     r =curl_easy_perform(curlhandle);  }   fclose(f); (r == CURLE_OK) 1; {    fprintf(stderr,,curl_easy_strerror(r)); 0;  }} (){  CURL *curlhandle = NULL; curl_global_init(CURL_GLOBAL_ALL);  curlhandle =curl_easy_init();   upload(curlhandle,,,         0, 3); curl_easy_cleanup(curlhandle);curl_global_cleanup();  0;}

Notice

This source code example issimplified and ignores returncodes and error checks to a large extent. We do this to highlight the libcurlfunction calls and related options and reduce unrelated code.

A real-world application will of course properly check every return value andexit correctly at the first serious error.


[8]ページ先頭

©2009-2025 Movatter.jp