curl*3: added small examples

and some minor edits
This commit is contained in:
Daniel Stenberg
2014-11-25 14:25:02 +01:00
parent 7eb7f7c32d
commit 0beda1a388
5 changed files with 61 additions and 9 deletions

View File

@@ -52,6 +52,16 @@ safely remove all the strings you've previously told libcurl to use, as it
won't use them anymore now. won't use them anymore now.
.SH RETURN VALUE .SH RETURN VALUE
None None
.SH EXAMPLE
.nf
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
.fi
.SH "SEE ALSO" .SH "SEE ALSO"
.BR curl_easy_init "(3), " .BR curl_easy_init "(3), "

View File

@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@@ -26,13 +26,13 @@ curl_easy_escape - URL encodes the given string
.SH SYNOPSIS .SH SYNOPSIS
.B #include <curl/curl.h> .B #include <curl/curl.h>
.sp .sp
.BI "char *curl_easy_escape( CURL *" curl ", char *" url ", int "length " );" .BI "char *curl_easy_escape( CURL *" curl ", char *" string ", int "length " );"
.ad .ad
.SH DESCRIPTION .SH DESCRIPTION
This function converts the given input string to an URL encoded string and This function converts the given input \fBstring\fP to an URL encoded string
returns that as a new allocated string. All input characters that are not a-z, and returns that as a new allocated string. All input characters that are not
A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL escaped" version a-z, A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL escaped"
(%NN where NN is a two-digit hexadecimal number). version (%NN where NN is a two-digit hexadecimal number).
If the \fBlength\fP argument is set to 0 (zero), \fIcurl_easy_escape(3)\fP If the \fBlength\fP argument is set to 0 (zero), \fIcurl_easy_escape(3)\fP
uses strlen() on the input \fBurl\fP to find out the size. uses strlen() on the input \fBurl\fP to find out the size.
@@ -42,5 +42,16 @@ You must \fIcurl_free(3)\fP the returned string when you're done with it.
Added in 7.15.4 and replaces the old \fIcurl_escape(3)\fP function. Added in 7.15.4 and replaces the old \fIcurl_escape(3)\fP function.
.SH RETURN VALUE .SH RETURN VALUE
A pointer to a zero terminated string or NULL if it failed. A pointer to a zero terminated string or NULL if it failed.
.SH EXAMPLE
.nf
CURL *curl = curl_easy_init();
if(curl) {
char *output = curl_easy_escape(curl, "data to convert", 15);
if(output) {
printf("Encoded: %s\n", output);
curl_free(output);
}
}}
.fi
.SH "SEE ALSO" .SH "SEE ALSO"
.BR curl_easy_unescape "(3), " curl_free "(3), " RFC 2396 .BR curl_easy_unescape "(3), " curl_free "(3), " RFC 3986

View File

@@ -44,5 +44,16 @@ this function.
.SH RETURN VALUE .SH RETURN VALUE
If this function returns NULL, something went wrong and you cannot use the If this function returns NULL, something went wrong and you cannot use the
other curl functions. other curl functions.
.SH EXAMPLE
.nf
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
.fi
.SH "SEE ALSO" .SH "SEE ALSO"
.BR curl_easy_cleanup "(3), " curl_global_init "(3), " curl_easy_reset "(3)" .BR curl_easy_cleanup "(3), " curl_global_init "(3), " curl_easy_reset "(3), "
.BR curl_easy_perform "(3) "

View File

@@ -21,7 +21,7 @@
.\" ************************************************************************** .\" **************************************************************************
.TH curl_easy_perform 3 "5 Mar 2001" "libcurl 7.7" "libcurl Manual" .TH curl_easy_perform 3 "5 Mar 2001" "libcurl 7.7" "libcurl Manual"
.SH NAME .SH NAME
curl_easy_perform - Perform a file transfer curl_easy_perform - perform a blocking file transfer
.SH SYNOPSIS .SH SYNOPSIS
.B #include <curl/curl.h> .B #include <curl/curl.h>
.sp .sp
@@ -58,6 +58,16 @@ CURLE_OK (0) means everything was ok, non-zero means an error occurred as
defines - see \fIlibcurl-errors(3)\fP. If the \fBCURLOPT_ERRORBUFFER(3)\fP was defines - see \fIlibcurl-errors(3)\fP. If the \fBCURLOPT_ERRORBUFFER(3)\fP was
set with \fIcurl_easy_setopt(3)\fP there will be a readable error message in set with \fIcurl_easy_setopt(3)\fP there will be a readable error message in
the error buffer when non-zero is returned. the error buffer when non-zero is returned.
.SH EXAMPLE
.nf
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}}
.fi
.SH "SEE ALSO" .SH "SEE ALSO"
.BR curl_easy_init "(3), " curl_easy_setopt "(3), " .BR curl_easy_init "(3), " curl_easy_setopt "(3), "
.BR curl_multi_add_handle "(3), " curl_multi_perform "(3), " .BR curl_multi_add_handle "(3), " curl_multi_perform "(3), "

View File

@@ -499,6 +499,16 @@ the library is too old to support it or the option was removed in a recent
version, this function will return \fICURLE_UNKNOWN_OPTION\fP. If support for version, this function will return \fICURLE_UNKNOWN_OPTION\fP. If support for
the option was disabled at compile-time, it will return the option was disabled at compile-time, it will return
\fICURLE_NOT_BUILT_IN\fP. \fICURLE_NOT_BUILT_IN\fP.
.SH EXAMPLE
.nf
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}}
.fi
.SH "SEE ALSO" .SH "SEE ALSO"
.BR curl_easy_init "(3), " curl_easy_cleanup "(3), " curl_easy_reset "(3), " .BR curl_easy_init "(3), " curl_easy_cleanup "(3), " curl_easy_reset "(3), "
.BR curl_multi_setopt "(3), " .BR curl_multi_setopt "(3), "