aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2014-10-21 13:40:38 +0200
committerDaniel Stenberg <daniel@haxx.se>2014-10-21 13:40:38 +0200
commit4cb7aa067cb3fb01601dd5d164be8cefe6042211 (patch)
tree259d3d545060b10d6f0bc0da7c20bd3d4c84a2df
parent411103251130767daab1b0d966a674b6b822707e (diff)
opts: provide more and updated examples
-rw-r--r--docs/libcurl/opts/CURLOPT_RANGE.32
-rw-r--r--docs/libcurl/opts/CURLOPT_RESUME_FROM.320
-rw-r--r--docs/libcurl/opts/CURLOPT_RESUME_FROM_LARGE.323
-rw-r--r--docs/libcurl/opts/CURLOPT_SSLVERSION.32
-rw-r--r--docs/libcurl/opts/CURLOPT_UPLOAD.323
-rw-r--r--docs/libcurl/opts/CURLOPT_USE_SSL.312
-rw-r--r--docs/libcurl/opts/CURLOPT_VERBOSE.36
7 files changed, 80 insertions, 8 deletions
diff --git a/docs/libcurl/opts/CURLOPT_RANGE.3 b/docs/libcurl/opts/CURLOPT_RANGE.3
index 25c3f6502..f5dd555ce 100644
--- a/docs/libcurl/opts/CURLOPT_RANGE.3
+++ b/docs/libcurl/opts/CURLOPT_RANGE.3
@@ -46,7 +46,7 @@ NULL
HTTP, FTP, FILE, RTSP and SFTP.
.SH EXAMPLE
.nf
-curl = curl_easy_init();
+CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
diff --git a/docs/libcurl/opts/CURLOPT_RESUME_FROM.3 b/docs/libcurl/opts/CURLOPT_RESUME_FROM.3
index c61fd3b65..c25c6466b 100644
--- a/docs/libcurl/opts/CURLOPT_RESUME_FROM.3
+++ b/docs/libcurl/opts/CURLOPT_RESUME_FROM.3
@@ -45,10 +45,28 @@ If you need to resume a transfer beyond the 2GB limit, use
.SH PROTOCOLS
HTTP, FTP, SFTP, FILE
.SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+ curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com");
+
+ /* resume upload at byte index 200 */
+ curl_easy_setopt(curl, CURLOPT_RESUME_FROM, 200L);
+
+ /* ask for upload */
+ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+
+ /* set total data amount to expect */
+ curl_easy_setopt(curl, CURLOPT_INFILESIZE, size_of_file);
+
+ /* Perform the request */
+ curl_easy_perform(curl);
+}
+.fi
.SH AVAILABILITY
Always
.SH RETURN VALUE
Returns CURLE_OK
.SH "SEE ALSO"
.BR CURLOPT_RESUME_FROM_LARGE "(3), " CURLOPT_RANGE "(3), "
+.BR CURLOPT_INFILESIZE "(3), "
diff --git a/docs/libcurl/opts/CURLOPT_RESUME_FROM_LARGE.3 b/docs/libcurl/opts/CURLOPT_RESUME_FROM_LARGE.3
index 59c83107b..bcb30af4e 100644
--- a/docs/libcurl/opts/CURLOPT_RESUME_FROM_LARGE.3
+++ b/docs/libcurl/opts/CURLOPT_RESUME_FROM_LARGE.3
@@ -44,10 +44,31 @@ source file to the remote target file.
.SH PROTOCOLS
HTTP, FTP, SFTP, FILE
.SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+ curl_off_t resume_position = GET_IT_SOMEHOW;
+ curl_off_t file_size = GET_IT_SOMEHOW_AS_WELL;
+
+ curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com");
+
+ /* resuming upload at this position, possibly beyond 2GB */
+ curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, resume_position);
+
+ /* ask for upload */
+ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+
+ /* set total data amount to expect */
+ curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_size);
+
+ /* Perform the request */
+ curl_easy_perform(curl);
+}
+.fi
.SH AVAILABILITY
Added in 7.11.0
.SH RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
.SH "SEE ALSO"
.BR CURLOPT_RESUME_FROM "(3), " CURLOPT_RANGE "(3), "
+.BR CURLOPT_INFILESIZE_LARGE "(3), "
diff --git a/docs/libcurl/opts/CURLOPT_SSLVERSION.3 b/docs/libcurl/opts/CURLOPT_SSLVERSION.3
index 095897bb3..9b558f495 100644
--- a/docs/libcurl/opts/CURLOPT_SSLVERSION.3
+++ b/docs/libcurl/opts/CURLOPT_SSLVERSION.3
@@ -55,7 +55,7 @@ CURL_SSLVERSION_DEFAULT
All TLS based protocols: HTTPS, FTPS, IMAPS, POP3, SMTPS etc.
.SH EXAMPLE
.nf
-curl = curl_easy_init();
+CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
diff --git a/docs/libcurl/opts/CURLOPT_UPLOAD.3 b/docs/libcurl/opts/CURLOPT_UPLOAD.3
index 8d815906d..d24bd289e 100644
--- a/docs/libcurl/opts/CURLOPT_UPLOAD.3
+++ b/docs/libcurl/opts/CURLOPT_UPLOAD.3
@@ -47,7 +47,28 @@ must specify the size.
.SH PROTOCOLS
Most
.SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+ /* we want to use our own read function */
+ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+
+ /* enable uploading */
+ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+
+ /* specify target */
+ curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile");
+
+ /* now specify which pointer to pass to our callback */
+ curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
+
+ /* Set the size of the file to upload */
+ curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)fsize);
+
+ /* Now run off and do what you've been told! */
+ curl_easy_perform(curl);
+}
+.fi
.SH AVAILABILITY
Always
.SH RETURN VALUE
diff --git a/docs/libcurl/opts/CURLOPT_USE_SSL.3 b/docs/libcurl/opts/CURLOPT_USE_SSL.3
index 81e6752f2..348f1b0c8 100644
--- a/docs/libcurl/opts/CURLOPT_USE_SSL.3
+++ b/docs/libcurl/opts/CURLOPT_USE_SSL.3
@@ -48,6 +48,18 @@ CURLUSESSL_NONE
.SH PROTOCOLS
FTP, SMTP, POP3, IMAP
.SH EXAMPLE
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+ curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/file.ext");
+
+ /* require use of SSL for this, or fail */
+ curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
+
+ /* Perform the request */
+ curl_easy_perform(curl);
+}
+.fi
.SH AVAILABILITY
Added in 7.11.0. This option was known as CURLOPT_FTP_SSL up to 7.16.4, and
the constants were known as CURLFTPSSL_*
diff --git a/docs/libcurl/opts/CURLOPT_VERBOSE.3 b/docs/libcurl/opts/CURLOPT_VERBOSE.3
index 4841a7b9f..732b8c415 100644
--- a/docs/libcurl/opts/CURLOPT_VERBOSE.3
+++ b/docs/libcurl/opts/CURLOPT_VERBOSE.3
@@ -44,14 +44,14 @@ To also get all the protocol data sent and received, consider using the
All
.SH EXAMPLE
.nf
-curl = curl_easy_init();
+CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
- /* ask libcurl to show us the verbose output */
+ /* ask libcurl to show us the verbose output */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
- /* Perform the request */
+ /* Perform the request */
curl_easy_perform(curl);
}
.fi