~ubuntu-branches/ubuntu/quantal/curl/quantal

« back to all changes in this revision

Viewing changes to docs/libcurl/libcurl.3

  • Committer: Bazaar Package Importer
  • Author(s): Domenico Andreoli
  • Date: 2002-03-12 19:06:21 UTC
  • Revision ID: james.westby@ubuntu.com-20020312190621-iqx7k9cipo5d0ifr
Tags: upstream-7.9.5
ImportĀ upstreamĀ versionĀ 7.9.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.\" You can view this file with:
 
2
.\" nroff -man [file]
 
3
.\" $Id: libcurl.3,v 1.1 2002/03/04 10:09:49 bagder Exp $
 
4
.\"
 
5
.TH libcurl 5 "14 August 2001" "libcurl 7.8.1" "libcurl overview"
 
6
.SH NAME
 
7
libcurl \- client-side URL transfers
 
8
.SH DESCRIPTION
 
9
This is an overview on how to use libcurl in your C programs. There are
 
10
specific man pages for each function mentioned in here. There's also the
 
11
libcurl-the-guide document for a complete tutorial to programming with
 
12
libcurl.
 
13
 
 
14
libcurl can also be used directly from within your Java, PHP, Perl, Ruby or
 
15
Tcl programs as well, look elsewhere for documentation on this!
 
16
 
 
17
All applications that use libcurl should call \fIcurl_global_init()\fP exactly
 
18
once before any libcurl function can be used. After all usage of libcurl is
 
19
complete, it \fBmust\fP call \fIcurl_global_cleanup()\fP. In between those two
 
20
calls, you can use libcurl as described below.
 
21
 
 
22
When using libcurl you init your session and get a handle, which you use as
 
23
input to the following interface functions you use. Use \fIcurl_easy_init()\fP
 
24
to get the handle.
 
25
 
 
26
You continue by setting all the options you want in the upcoming transfer,
 
27
most important among them is the URL itself (you can't transfer anything
 
28
without a specified URL as you may have figured out yourself). You might want
 
29
to set some callbacks as well that will be called from the library when data
 
30
is available etc.  \fIcurl_easy_setopt()\fP is there for this.
 
31
 
 
32
When all is setup, you tell libcurl to perform the transfer using
 
33
\fIcurl_easy_perform()\fP.  It will then do the entire operation and won't
 
34
return until it is done (successfully or not).
 
35
 
 
36
After the transfer has been made, you can set new options and make another
 
37
transfer, or if you're done, cleanup the session by calling
 
38
\fIcurl_easy_cleanup()\fP.  If you want persistant connections, you don't
 
39
cleanup immediately, but instead run ahead and perform other transfers using
 
40
the same handle. See the chapter below for Persistant Connections.
 
41
 
 
42
There is also a series of other helpful functions to use. They are:
 
43
 
 
44
.RS
 
45
.TP 10
 
46
.B curl_version()
 
47
displays the libcurl version
 
48
.TP
 
49
.B curl_getdate()
 
50
converts a date string to time_t
 
51
.TP
 
52
.B curl_getenv()
 
53
portable environment variable reader
 
54
.TP
 
55
.B curl_easy_getinfo()
 
56
get information about a performed transfer
 
57
.TP
 
58
.B curl_formadd()
 
59
helps building a HTTP form POST
 
60
.TP
 
61
.B curl_formfree()
 
62
free a list built with curl_formparse()/curl_formadd()
 
63
.TP
 
64
.B curl_slist_append()
 
65
builds a linked list
 
66
.TP
 
67
.B curl_slist_free_all()
 
68
frees a whole curl_slist
 
69
.TP
 
70
.B curl_mprintf()
 
71
portable printf() functions
 
72
.TP
 
73
.B curl_strequal()
 
74
portable case insensitive string comparisons
 
75
.RE
 
76
 
 
77
.SH "LINKING WITH LIBCURL"
 
78
Starting with 7.7.2 (on unix-like machines), there's a tool named curl-config
 
79
that gets installed with the rest of the curl stuff when 'make install' is
 
80
performed.
 
81
 
 
82
curl-config is added to make it easier for applications to link with libcurl
 
83
and developers to learn about libcurl and how to use it.
 
84
 
 
85
Run 'curl-config --libs' to get the (additional) linker options you need to
 
86
link with the particular version of libcurl you've installed.
 
87
 
 
88
For details, see the curl-config.1 man page.
 
89
.SH "LIBCURL SYMBOL NAMES"
 
90
All public functions in the libcurl interface are prefixed with 'curl_' (with
 
91
a lowercase c). You can find other functions in the library source code, but
 
92
other prefixes indicate the functions are private and may change without
 
93
further notice in the next release.
 
94
 
 
95
Only use documented functions and functionality!
 
96
.SH "PORTABILITY"
 
97
libcurl works
 
98
.B exactly
 
99
the same, on any of the platforms it compiles and builds on.
 
100
 
 
101
There's only one caution, and that is the win32 platform that may(*) require
 
102
you to init the winsock stuff before you use the libcurl functions. Details on
 
103
this are noted on the curl_easy_init() man page.
 
104
 
 
105
(*) = it appears as if users of the cygwin environment get this done
 
106
automatically, also libcurl 7.8.1 and later can handle this for you.
 
107
.SH "THREADS"
 
108
Never ever call curl-functions simultaneously using the same handle from
 
109
several threads. libcurl is thread-safe and can be used in any number of
 
110
threads, but you must use separate curl handles if you want to use libcurl in
 
111
more than one thread simultaneously.
 
112
.SH "PERSISTANT CONNECTIONS"
 
113
With libcurl 7.7, persistant connections were added. Persistant connections
 
114
means that libcurl can re-use the same connection for several transfers, if
 
115
the conditions are right.
 
116
 
 
117
libcurl will *always* attempt to use persistant connections. Whenever you use
 
118
curl_easy_perform(), libcurl will attempt to use an existing connection to do
 
119
the transfer, and if none exists it'll open a new one that will be subject
 
120
for re-use on a possible following call to curl_easy_perform().
 
121
 
 
122
To allow libcurl to take full advantage of persistant connections, you should
 
123
do as many of your file transfers as possible using the same curl
 
124
handle. When you call curl_easy_cleanup(), all the possibly open connections
 
125
held by libcurl will be closed and forgotten.
 
126
 
 
127
Note that the options set with curl_easy_setopt() will be used in on every
 
128
repeat curl_easy_perform() call
 
129
.SH "COMPATIBILITY WITH OLDER LIBCURLS"
 
130
Repeated curl_easy_perform() calls on the same handle were not supported in
 
131
pre-7.7 versions, and caused confusion and undefined behaviour.
 
132