aboutsummaryrefslogtreecommitdiff
path: root/docs/examples
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2010-02-16 13:32:45 +0000
committerYang Tse <yangsita@gmail.com>2010-02-16 13:32:45 +0000
commit46b112bcd439f4413925a7300d66a3e6f148765e (patch)
treec925ce0c32a0af8bbcf427187c3838d005e3218b /docs/examples
parentf442dd6496c8710c4000a078e8085238fdaa7545 (diff)
replaced tabs with spaces
Diffstat (limited to 'docs/examples')
-rw-r--r--docs/examples/anyauthput.c2
-rw-r--r--docs/examples/ftpuploadresume.c152
2 files changed, 77 insertions, 77 deletions
diff --git a/docs/examples/anyauthput.c b/docs/examples/anyauthput.c
index c96f3c180..d0c65cf1b 100644
--- a/docs/examples/anyauthput.c
+++ b/docs/examples/anyauthput.c
@@ -136,7 +136,7 @@ int main(int argc, char **argv)
/* and give the size of the upload, this supports large file sizes
on systems that have general support for it */
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
- (curl_off_t)file_info.st_size);
+ (curl_off_t)file_info.st_size);
/* tell libcurl we can use "any" auth, which lets the lib pick one, but it
also costs one extra round-trip and possibly sending of all the PUT
diff --git a/docs/examples/ftpuploadresume.c b/docs/examples/ftpuploadresume.c
index 362711c33..d20c4a9c6 100644
--- a/docs/examples/ftpuploadresume.c
+++ b/docs/examples/ftpuploadresume.c
@@ -34,126 +34,126 @@ int __cdecl _snscanf(const char * input, size_t length, const char * format, ...
/* parse headers for Content-Length */
size_t getcontentlengthfunc(void *ptr, size_t size, size_t nmemb, void *stream) {
- int r;
- long len = 0;
+ int r;
+ long len = 0;
- /* _snscanf() is Win32 specific */
- r = _snscanf(ptr, size * nmemb, "Content-Length: %ld\n", &len);
+ /* _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;
+ if (r) /* Microsoft: we don't read the specs */
+ *((long *) stream) = len;
- return size * nmemb;
+ return size * nmemb;
}
/* discard downloaded data */
size_t discardfunc(void *ptr, size_t size, size_t nmemb, void *stream) {
- return size * nmemb;
+ return size * nmemb;
}
/* read data to upload */
size_t readfunc(void *ptr, size_t size, size_t nmemb, void *stream)
{
- FILE *f = stream;
- size_t n;
+ FILE *f = stream;
+ size_t n;
- if (ferror(f))
- return CURL_READFUNC_ABORT;
+ if (ferror(f))
+ return CURL_READFUNC_ABORT;
- n = fread(ptr, size, nmemb, f) * size;
+ n = fread(ptr, size, nmemb, f) * size;
- return n;
+ return n;
}
int upload(CURL *curlhandle, const char * remotepath, const char * localpath,
long timeout, long tries)
{
- FILE *f;
- long uploaded_len = 0;
- CURLcode r = CURLE_GOT_NOTHING;
- int c;
+ FILE *f;
+ long uploaded_len = 0;
+ CURLcode r = CURLE_GOT_NOTHING;
+ int c;
- f = fopen(localpath, "rb");
- if (f == NULL) {
- perror(NULL);
- return 0;
- }
+ f = fopen(localpath, "rb");
+ if (f == NULL) {
+ perror(NULL);
+ return 0;
+ }
- curl_easy_setopt(curlhandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(curlhandle, CURLOPT_UPLOAD, 1L);
- curl_easy_setopt(curlhandle, CURLOPT_URL, remotepath);
+ curl_easy_setopt(curlhandle, CURLOPT_URL, remotepath);
- if (timeout)
- curl_easy_setopt(curlhandle, CURLOPT_FTP_RESPONSE_TIMEOUT, timeout);
+ if (timeout)
+ curl_easy_setopt(curlhandle, CURLOPT_FTP_RESPONSE_TIMEOUT, timeout);
- curl_easy_setopt(curlhandle, CURLOPT_HEADERFUNCTION, getcontentlengthfunc);
- curl_easy_setopt(curlhandle, CURLOPT_HEADERDATA, &uploaded_len);
+ 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_WRITEFUNCTION, discardfunc);
- curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, readfunc);
- curl_easy_setopt(curlhandle, CURLOPT_READDATA, f);
+ curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, readfunc);
+ curl_easy_setopt(curlhandle, CURLOPT_READDATA, f);
- curl_easy_setopt(curlhandle, CURLOPT_FTPPORT, "-"); /* disable passive mode */
- curl_easy_setopt(curlhandle, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L);
+ curl_easy_setopt(curlhandle, CURLOPT_FTPPORT, "-"); /* disable passive mode */
+ curl_easy_setopt(curlhandle, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L);
- curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 1L);
- for (c = 0; (r != CURLE_OK) && (c < tries); c++) {
- /* are we resuming? */
- if (c) { /* yes */
- /* determine the length of the file already written */
+ for (c = 0; (r != CURLE_OK) && (c < tries); c++) {
+ /* are we resuming? */
+ if (c) { /* yes */
+ /* determine the length of the file already written */
- /*
- * With NOBODY and NOHEADER, libcurl will issue a SIZE
- * command, but the only way to retrieve the result is
- * to parse the returned Content-Length header. Thus,
- * getcontentlengthfunc(). We need discardfunc() above
- * because HEADER will dump the headers to stdout
- * without it.
- */
- curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 1L);
- curl_easy_setopt(curlhandle, CURLOPT_HEADER, 1L);
+ /*
+ * With NOBODY and NOHEADER, libcurl will issue a SIZE
+ * command, but the only way to retrieve the result is
+ * to parse the returned Content-Length header. Thus,
+ * getcontentlengthfunc(). We need discardfunc() above
+ * because HEADER will dump the headers to stdout
+ * without it.
+ */
+ curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 1L);
+ curl_easy_setopt(curlhandle, CURLOPT_HEADER, 1L);
- r = curl_easy_perform(curlhandle);
- if (r != CURLE_OK)
- continue;
+ r = curl_easy_perform(curlhandle);
+ if (r != CURLE_OK)
+ continue;
- curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 0L);
- curl_easy_setopt(curlhandle, CURLOPT_HEADER, 0L);
+ curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 0L);
+ curl_easy_setopt(curlhandle, CURLOPT_HEADER, 0L);
- fseek(f, uploaded_len, SEEK_SET);
+ fseek(f, uploaded_len, SEEK_SET);
- curl_easy_setopt(curlhandle, CURLOPT_APPEND, 1L);
- }
- else { /* no */
- curl_easy_setopt(curlhandle, CURLOPT_APPEND, 0L);
- }
+ curl_easy_setopt(curlhandle, CURLOPT_APPEND, 1L);
+ }
+ else { /* no */
+ curl_easy_setopt(curlhandle, CURLOPT_APPEND, 0L);
+ }
- r = curl_easy_perform(curlhandle);
- }
+ r = curl_easy_perform(curlhandle);
+ }
- fclose(f);
+ fclose(f);
- if (r == CURLE_OK)
- return 1;
- else {
- fprintf(stderr, "%s\n", curl_easy_strerror(r));
- return 0;
- }
+ if (r == CURLE_OK)
+ return 1;
+ else {
+ fprintf(stderr, "%s\n", curl_easy_strerror(r));
+ return 0;
+ }
}
int main(int c, char **argv) {
- CURL *curlhandle = NULL;
+ CURL *curlhandle = NULL;
- curl_global_init(CURL_GLOBAL_ALL);
- curlhandle = curl_easy_init();
+ curl_global_init(CURL_GLOBAL_ALL);
+ curlhandle = curl_easy_init();
- upload(curlhandle, "ftp://user:pass@host/path/file", "C:\\file", 0, 3);
+ upload(curlhandle, "ftp://user:pass@host/path/file", "C:\\file", 0, 3);
- curl_easy_cleanup(curlhandle);
- curl_global_cleanup();
+ curl_easy_cleanup(curlhandle);
+ curl_global_cleanup();
- return 0;
+ return 0;
}