da7cc0793decf7ac161a051a3bf5fe79f2414a3a
[platform/upstream/curl.git] / include / curl / curl.h
1 #ifndef __CURL_CURL_H
2 #define __CURL_CURL_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
11  *
12  * This software is licensed as described in the file COPYING, which
13  * you should have received as part of this distribution. The terms
14  * are also available at http://curl.haxx.se/docs/copyright.html.
15  *
16  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17  * copies of the Software, and permit persons to whom the Software is
18  * furnished to do so, under the terms of the COPYING file.
19  *
20  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21  * KIND, either express or implied.
22  *
23  * $Id$
24  ***************************************************************************/
25
26 /* If you have problems, all libcurl docs and details are found here:
27    http://curl.haxx.se/libcurl/
28 */
29
30 #include "curlver.h" /* the libcurl version defines */
31
32 /*
33  * Define WIN32 when build target is Win32 API
34  */
35
36 #if (defined(_WIN32) || defined(__WIN32__)) && \
37      !defined(WIN32) && !defined(__SYMBIAN32__)
38 #define WIN32
39 #endif
40
41 #include <stdio.h>
42 #include <limits.h>
43
44 /* The include stuff here below is mainly for time_t! */
45 #ifdef vms
46 # include <types.h>
47 # include <time.h>
48 #else
49 # include <sys/types.h>
50 # include <time.h>
51 #endif /* defined (vms) */
52
53 #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) && \
54   !defined(__CYGWIN__) || defined(__MINGW32__)
55 #if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H))
56 /* The check above prevents the winsock2 inclusion if winsock.h already was
57    included, since they can't co-exist without problems */
58 #include <winsock2.h>
59 #include <ws2tcpip.h>
60 #endif
61 #else
62
63 /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
64    libc5-based Linux systems. Only include it on system that are known to
65    require it! */
66 #if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
67     defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY)
68 #include <sys/select.h>
69 #endif
70
71 #ifndef _WIN32_WCE
72 #include <sys/socket.h>
73 #endif
74 #if !defined(WIN32) || !defined(__WATCOMC__)
75 #include <sys/time.h>
76 #endif
77 #include <sys/types.h>
78 #endif
79
80 #ifdef __BEOS__
81 #include <support/SupportDefs.h>
82 #endif
83
84 #ifdef  __cplusplus
85 extern "C" {
86 #endif
87
88 typedef void CURL;
89
90 /*
91  * Decorate exportable functions for Win32 and Symbian OS DLL linking.
92  * This avoids using a .def file for building libcurl.dll.
93  */
94 #if (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)) && \
95      !defined(CURL_STATICLIB)
96 #if defined(BUILDING_LIBCURL)
97 #define CURL_EXTERN  __declspec(dllexport)
98 #else
99 #define CURL_EXTERN  __declspec(dllimport)
100 #endif
101 #else
102
103 #ifdef CURL_HIDDEN_SYMBOLS
104 /*
105  * This definition is used to make external definitions visible in the
106  * shared library when symbols are hidden by default.  It makes no
107  * difference when compiling applications whether this is set or not,
108  * only when compiling the library.
109  */
110 #define CURL_EXTERN CURL_EXTERN_SYMBOL
111 #else
112 #define CURL_EXTERN
113 #endif
114 #endif
115
116 /*
117  * We want the typedef curl_off_t setup for large file support on all
118  * platforms. We also provide a CURL_FORMAT_OFF_T define to use in *printf
119  * format strings when outputting a variable of type curl_off_t.
120  *
121  * Note: "pocc -Ze" is MSVC compatibility mode and this sets _MSC_VER!
122  */
123
124 #if (defined(_MSC_VER) && !defined(__POCC__)) || (defined(__LCC__) && \
125      defined(WIN32))
126 /* MSVC */
127 #ifdef _WIN32_WCE
128   typedef long curl_off_t;
129 #define CURL_FORMAT_OFF_T "%ld"
130 #else
131   typedef signed __int64 curl_off_t;
132 #define CURL_FORMAT_OFF_T "%I64d"
133 #endif
134 #else /* (_MSC_VER && !__POCC__) || (__LCC__ && WIN32) */
135 #if (defined(__GNUC__) && defined(WIN32)) || defined(__WATCOMC__)
136 /* gcc on windows or Watcom */
137   typedef long long curl_off_t;
138 #define CURL_FORMAT_OFF_T "%I64d"
139 #else /* GCC or Watcom on Windows  */
140 #if defined(__ILEC400__)
141 /* OS400 C compiler. */
142   typedef long long curl_off_t;
143 #define CURL_FORMAT_OFF_T "%lld"
144 #else /* OS400 C compiler. */
145
146 /* "normal" POSIX approach, do note that this does not necessarily mean that
147    the type is >32 bits, see the SIZEOF_CURL_OFF_T define for that! */
148   typedef off_t curl_off_t;
149
150 /* Check a range of defines to detect large file support. On Linux it seems
151    none of these are set by default, so if you don't explicitly switches on
152    large file support, this define will be made for "small file" support. */
153 #ifndef _FILE_OFFSET_BITS
154 #define _FILE_OFFSET_BITS 0 /* to prevent warnings in the check below */
155 #define UNDEF_FILE_OFFSET_BITS
156 #endif
157 #ifndef FILESIZEBITS
158 #define FILESIZEBITS 0 /* to prevent warnings in the check below */
159 #define UNDEF_FILESIZEBITS
160 #endif
161
162 #if defined(_LARGE_FILES) || (_FILE_OFFSET_BITS > 32) || (FILESIZEBITS > 32) \
163    || defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE)
164   /* For now, we assume at least one of these to be set for large files to
165      work! */
166 #define CURL_FORMAT_OFF_T "%lld"
167 #else /* LARGE_FILE support */
168 #define CURL_FORMAT_OFF_T "%ld"
169 #endif
170 #endif /* OS400 C compiler. */
171 #endif /* GCC or Watcom on Windows */
172 #endif /* (_MSC_VER && !__POCC__) || (__LCC__ && WIN32) */
173
174 #ifdef UNDEF_FILE_OFFSET_BITS
175 /* this was defined above for our checks, undefine it again */
176 #undef _FILE_OFFSET_BITS
177 #endif
178
179 #ifdef UNDEF_FILESIZEBITS
180 /* this was defined above for our checks, undefine it again */
181 #undef FILESIZEBITS
182 #endif
183
184 #ifndef curl_socket_typedef
185 /* socket typedef */
186 #ifdef WIN32
187 typedef SOCKET curl_socket_t;
188 #define CURL_SOCKET_BAD INVALID_SOCKET
189 #else
190 typedef int curl_socket_t;
191 #define CURL_SOCKET_BAD -1
192 #endif
193 #define curl_socket_typedef
194 #endif /* curl_socket_typedef */
195
196 struct curl_httppost {
197   struct curl_httppost *next;       /* next entry in the list */
198   char *name;                       /* pointer to allocated name */
199   long namelength;                  /* length of name length */
200   char *contents;                   /* pointer to allocated data contents */
201   long contentslength;              /* length of contents field */
202   char *buffer;                     /* pointer to allocated buffer contents */
203   long bufferlength;                /* length of buffer field */
204   char *contenttype;                /* Content-Type */
205   struct curl_slist* contentheader; /* list of extra headers for this form */
206   struct curl_httppost *more;       /* if one field name has more than one
207                                        file, this link should link to following
208                                        files */
209   long flags;                       /* as defined below */
210 #define HTTPPOST_FILENAME (1<<0)    /* specified content is a file name */
211 #define HTTPPOST_READFILE (1<<1)    /* specified content is a file name */
212 #define HTTPPOST_PTRNAME (1<<2)     /* name is only stored pointer
213                                        do not free in formfree */
214 #define HTTPPOST_PTRCONTENTS (1<<3) /* contents is only stored pointer
215                                        do not free in formfree */
216 #define HTTPPOST_BUFFER (1<<4)      /* upload file from buffer */
217 #define HTTPPOST_PTRBUFFER (1<<5)   /* upload file from pointer contents */
218 #define HTTPPOST_CALLBACK (1<<6)    /* upload file contents by using the
219                                        regular read callback to get the data
220                                        and pass the given pointer as custom
221                                        pointer */
222
223   char *showfilename;               /* The file name to show. If not set, the
224                                        actual file name will be used (if this
225                                        is a file part) */
226   void *userp;                      /* custom pointer used for
227                                        HTTPPOST_CALLBACK posts */
228 };
229
230 typedef int (*curl_progress_callback)(void *clientp,
231                                       double dltotal,
232                                       double dlnow,
233                                       double ultotal,
234                                       double ulnow);
235
236 #ifndef CURL_MAX_WRITE_SIZE
237   /* Tests have proven that 20K is a very bad buffer size for uploads on
238      Windows, while 16K for some odd reason performed a lot better.
239      We do the ifndef check to allow this value to easier be changed at build
240      time for those who feel adventurous. */
241 #define CURL_MAX_WRITE_SIZE 16384
242 #endif
243 /* This is a magic return code for the write callback that, when returned,
244    will signal libcurl to pause receiving on the current transfer. */
245 #define CURL_WRITEFUNC_PAUSE 0x10000001
246 typedef size_t (*curl_write_callback)(char *buffer,
247                                       size_t size,
248                                       size_t nitems,
249                                       void *outstream);
250
251 /* This is a return code for the read callback that, when returned, will
252    signal libcurl to immediately abort the current transfer. */
253 #define CURL_READFUNC_ABORT 0x10000000
254 /* This is a return code for the read callback that, when returned, will
255    signal libcurl to pause sending data on the current transfer. */
256 #define CURL_READFUNC_PAUSE 0x10000001
257 typedef int (*curl_seek_callback)(void *instream,
258                                   curl_off_t offset,
259                                   int origin); /* 'whence' */
260
261 typedef size_t (*curl_read_callback)(char *buffer,
262                                       size_t size,
263                                       size_t nitems,
264                                       void *instream);
265
266 typedef enum  {
267   CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */
268   CURLSOCKTYPE_LAST   /* never use */
269 } curlsocktype;
270
271 typedef int (*curl_sockopt_callback)(void *clientp,
272                                      curl_socket_t curlfd,
273                                      curlsocktype purpose);
274
275 struct curl_sockaddr {
276   int family;
277   int socktype;
278   int protocol;
279   unsigned int addrlen; /* addrlen was a socklen_t type before 7.18.0 but it
280                            turned really ugly and painful on the systems that
281                            lack this type */
282   struct sockaddr addr;
283 };
284
285 typedef curl_socket_t
286 (*curl_opensocket_callback)(void *clientp,
287                             curlsocktype purpose,
288                             struct curl_sockaddr *address);
289
290 #ifndef CURL_NO_OLDIES
291   /* not used since 7.10.8, will be removed in a future release */
292 typedef int (*curl_passwd_callback)(void *clientp,
293                                     const char *prompt,
294                                     char *buffer,
295                                     int buflen);
296 #endif
297
298 typedef enum {
299   CURLIOE_OK,            /* I/O operation successful */
300   CURLIOE_UNKNOWNCMD,    /* command was unknown to callback */
301   CURLIOE_FAILRESTART,   /* failed to restart the read */
302   CURLIOE_LAST           /* never use */
303 } curlioerr;
304
305 typedef enum  {
306   CURLIOCMD_NOP,         /* no operation */
307   CURLIOCMD_RESTARTREAD, /* restart the read stream from start */
308   CURLIOCMD_LAST         /* never use */
309 } curliocmd;
310
311 typedef curlioerr (*curl_ioctl_callback)(CURL *handle,
312                                          int cmd,
313                                          void *clientp);
314
315 /*
316  * The following typedef's are signatures of malloc, free, realloc, strdup and
317  * calloc respectively.  Function pointers of these types can be passed to the
318  * curl_global_init_mem() function to set user defined memory management
319  * callback routines.
320  */
321 typedef void *(*curl_malloc_callback)(size_t size);
322 typedef void (*curl_free_callback)(void *ptr);
323 typedef void *(*curl_realloc_callback)(void *ptr, size_t size);
324 typedef char *(*curl_strdup_callback)(const char *str);
325 typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size);
326
327 /* the kind of data that is passed to information_callback*/
328 typedef enum {
329   CURLINFO_TEXT = 0,
330   CURLINFO_HEADER_IN,    /* 1 */
331   CURLINFO_HEADER_OUT,   /* 2 */
332   CURLINFO_DATA_IN,      /* 3 */
333   CURLINFO_DATA_OUT,     /* 4 */
334   CURLINFO_SSL_DATA_IN,  /* 5 */
335   CURLINFO_SSL_DATA_OUT, /* 6 */
336   CURLINFO_END
337 } curl_infotype;
338
339 typedef int (*curl_debug_callback)
340        (CURL *handle,      /* the handle/transfer this concerns */
341         curl_infotype type, /* what kind of data */
342         char *data,        /* points to the data */
343         size_t size,       /* size of the data pointed to */
344         void *userptr);    /* whatever the user please */
345
346 /* All possible error codes from all sorts of curl functions. Future versions
347    may return other values, stay prepared.
348
349    Always add new return codes last. Never *EVER* remove any. The return
350    codes must remain the same!
351  */
352
353 typedef enum {
354   CURLE_OK = 0,
355   CURLE_UNSUPPORTED_PROTOCOL,    /* 1 */
356   CURLE_FAILED_INIT,             /* 2 */
357   CURLE_URL_MALFORMAT,           /* 3 */
358   CURLE_OBSOLETE4,               /* 4 - NOT USED */
359   CURLE_COULDNT_RESOLVE_PROXY,   /* 5 */
360   CURLE_COULDNT_RESOLVE_HOST,    /* 6 */
361   CURLE_COULDNT_CONNECT,         /* 7 */
362   CURLE_FTP_WEIRD_SERVER_REPLY,  /* 8 */
363   CURLE_REMOTE_ACCESS_DENIED,    /* 9 a service was denied by the server
364                                     due to lack of access - when login fails
365                                     this is not returned. */
366   CURLE_OBSOLETE10,              /* 10 - NOT USED */
367   CURLE_FTP_WEIRD_PASS_REPLY,    /* 11 */
368   CURLE_OBSOLETE12,              /* 12 - NOT USED */
369   CURLE_FTP_WEIRD_PASV_REPLY,    /* 13 */
370   CURLE_FTP_WEIRD_227_FORMAT,    /* 14 */
371   CURLE_FTP_CANT_GET_HOST,       /* 15 */
372   CURLE_OBSOLETE16,              /* 16 - NOT USED */
373   CURLE_FTP_COULDNT_SET_TYPE,    /* 17 */
374   CURLE_PARTIAL_FILE,            /* 18 */
375   CURLE_FTP_COULDNT_RETR_FILE,   /* 19 */
376   CURLE_OBSOLETE20,              /* 20 - NOT USED */
377   CURLE_QUOTE_ERROR,             /* 21 - quote command failure */
378   CURLE_HTTP_RETURNED_ERROR,     /* 22 */
379   CURLE_WRITE_ERROR,             /* 23 */
380   CURLE_OBSOLETE24,              /* 24 - NOT USED */
381   CURLE_UPLOAD_FAILED,           /* 25 - failed upload "command" */
382   CURLE_READ_ERROR,              /* 26 - couldn't open/read from file */
383   CURLE_OUT_OF_MEMORY,           /* 27 */
384   /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error
385            instead of a memory allocation error if CURL_DOES_CONVERSIONS
386            is defined
387   */
388   CURLE_OPERATION_TIMEDOUT,      /* 28 - the timeout time was reached */
389   CURLE_OBSOLETE29,              /* 29 - NOT USED */
390   CURLE_FTP_PORT_FAILED,         /* 30 - FTP PORT operation failed */
391   CURLE_FTP_COULDNT_USE_REST,    /* 31 - the REST command failed */
392   CURLE_OBSOLETE32,              /* 32 - NOT USED */
393   CURLE_RANGE_ERROR,             /* 33 - RANGE "command" didn't work */
394   CURLE_HTTP_POST_ERROR,         /* 34 */
395   CURLE_SSL_CONNECT_ERROR,       /* 35 - wrong when connecting with SSL */
396   CURLE_BAD_DOWNLOAD_RESUME,     /* 36 - couldn't resume download */
397   CURLE_FILE_COULDNT_READ_FILE,  /* 37 */
398   CURLE_LDAP_CANNOT_BIND,        /* 38 */
399   CURLE_LDAP_SEARCH_FAILED,      /* 39 */
400   CURLE_OBSOLETE40,              /* 40 - NOT USED */
401   CURLE_FUNCTION_NOT_FOUND,      /* 41 */
402   CURLE_ABORTED_BY_CALLBACK,     /* 42 */
403   CURLE_BAD_FUNCTION_ARGUMENT,   /* 43 */
404   CURLE_OBSOLETE44,              /* 44 - NOT USED */
405   CURLE_INTERFACE_FAILED,        /* 45 - CURLOPT_INTERFACE failed */
406   CURLE_OBSOLETE46,              /* 46 - NOT USED */
407   CURLE_TOO_MANY_REDIRECTS ,     /* 47 - catch endless re-direct loops */
408   CURLE_UNKNOWN_TELNET_OPTION,   /* 48 - User specified an unknown option */
409   CURLE_TELNET_OPTION_SYNTAX ,   /* 49 - Malformed telnet option */
410   CURLE_OBSOLETE50,              /* 50 - NOT USED */
411   CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint
412                                      wasn't verified fine */
413   CURLE_GOT_NOTHING,             /* 52 - when this is a specific error */
414   CURLE_SSL_ENGINE_NOTFOUND,     /* 53 - SSL crypto engine not found */
415   CURLE_SSL_ENGINE_SETFAILED,    /* 54 - can not set SSL crypto engine as
416                                     default */
417   CURLE_SEND_ERROR,              /* 55 - failed sending network data */
418   CURLE_RECV_ERROR,              /* 56 - failure in receiving network data */
419   CURLE_OBSOLETE57,              /* 57 - NOT IN USE */
420   CURLE_SSL_CERTPROBLEM,         /* 58 - problem with the local certificate */
421   CURLE_SSL_CIPHER,              /* 59 - couldn't use specified cipher */
422   CURLE_SSL_CACERT,              /* 60 - problem with the CA cert (path?) */
423   CURLE_BAD_CONTENT_ENCODING,    /* 61 - Unrecognized transfer encoding */
424   CURLE_LDAP_INVALID_URL,        /* 62 - Invalid LDAP URL */
425   CURLE_FILESIZE_EXCEEDED,       /* 63 - Maximum file size exceeded */
426   CURLE_USE_SSL_FAILED,          /* 64 - Requested FTP SSL level failed */
427   CURLE_SEND_FAIL_REWIND,        /* 65 - Sending the data requires a rewind
428                                     that failed */
429   CURLE_SSL_ENGINE_INITFAILED,   /* 66 - failed to initialise ENGINE */
430   CURLE_LOGIN_DENIED,            /* 67 - user, password or similar was not
431                                     accepted and we failed to login */
432   CURLE_TFTP_NOTFOUND,           /* 68 - file not found on server */
433   CURLE_TFTP_PERM,               /* 69 - permission problem on server */
434   CURLE_REMOTE_DISK_FULL,        /* 70 - out of disk space on server */
435   CURLE_TFTP_ILLEGAL,            /* 71 - Illegal TFTP operation */
436   CURLE_TFTP_UNKNOWNID,          /* 72 - Unknown transfer ID */
437   CURLE_REMOTE_FILE_EXISTS,      /* 73 - File already exists */
438   CURLE_TFTP_NOSUCHUSER,         /* 74 - No such user */
439   CURLE_CONV_FAILED,             /* 75 - conversion failed */
440   CURLE_CONV_REQD,               /* 76 - caller must register conversion
441                                     callbacks using curl_easy_setopt options
442                                     CURLOPT_CONV_FROM_NETWORK_FUNCTION,
443                                     CURLOPT_CONV_TO_NETWORK_FUNCTION, and
444                                     CURLOPT_CONV_FROM_UTF8_FUNCTION */
445   CURLE_SSL_CACERT_BADFILE,      /* 77 - could not load CACERT file, missing
446                                     or wrong format */
447   CURLE_REMOTE_FILE_NOT_FOUND,   /* 78 - remote file not found */
448   CURLE_SSH,                     /* 79 - error from the SSH layer, somewhat
449                                     generic so the error message will be of
450                                     interest when this has happened */
451
452   CURLE_SSL_SHUTDOWN_FAILED,     /* 80 - Failed to shut down the SSL
453                                     connection */
454   CURLE_AGAIN,                   /* 81 - socket is not ready for send/recv,
455                                     wait till it's ready and try again (Added
456                                     in 7.18.2) */
457   CURLE_SSL_CRL_BADFILE,         /* 82 - could not load CRL file, missing or
458                                     wrong format (Added in 7.19.0) */
459   CURLE_SSL_ISSUER_ERROR,        /* 83 - Issuer check failed.  (Added in
460                                     7.19.0) */
461   CURL_LAST /* never use! */
462 } CURLcode;
463
464 #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
465                           the obsolete stuff removed! */
466
467 /* Backwards compatibility with older names */
468
469 /* The following were added in 7.17.1 */
470 /* These are scheduled to disappear by 2009 */
471 #define CURLE_SSL_PEER_CERTIFICATE CURLE_PEER_FAILED_VERIFICATION
472
473 /* The following were added in 7.17.0 */
474 /* These are scheduled to disappear by 2009 */
475 #define CURLE_OBSOLETE CURLE_OBSOLETE50 /* noone should be using this! */
476 #define CURLE_BAD_PASSWORD_ENTERED CURLE_OBSOLETE46
477 #define CURLE_BAD_CALLING_ORDER CURLE_OBSOLETE44
478 #define CURLE_FTP_USER_PASSWORD_INCORRECT CURLE_OBSOLETE10
479 #define CURLE_FTP_CANT_RECONNECT CURLE_OBSOLETE16
480 #define CURLE_FTP_COULDNT_GET_SIZE CURLE_OBSOLETE32
481 #define CURLE_FTP_COULDNT_SET_ASCII CURLE_OBSOLETE29
482 #define CURLE_FTP_WEIRD_USER_REPLY CURLE_OBSOLETE12
483 #define CURLE_FTP_WRITE_ERROR CURLE_OBSOLETE20
484 #define CURLE_LIBRARY_NOT_FOUND CURLE_OBSOLETE40
485 #define CURLE_MALFORMAT_USER CURLE_OBSOLETE24
486 #define CURLE_SHARE_IN_USE CURLE_OBSOLETE57
487 #define CURLE_URL_MALFORMAT_USER CURLE_OBSOLETE4
488
489 #define CURLE_FTP_ACCESS_DENIED CURLE_REMOTE_ACCESS_DENIED
490 #define CURLE_FTP_COULDNT_SET_BINARY CURLE_FTP_COULDNT_SET_TYPE
491 #define CURLE_FTP_QUOTE_ERROR CURLE_QUOTE_ERROR
492 #define CURLE_TFTP_DISKFULL CURLE_REMOTE_DISK_FULL
493 #define CURLE_TFTP_EXISTS CURLE_REMOTE_FILE_EXISTS
494 #define CURLE_HTTP_RANGE_ERROR CURLE_RANGE_ERROR
495 #define CURLE_FTP_SSL_FAILED CURLE_USE_SSL_FAILED
496
497 /* The following were added earlier */
498
499 #define CURLE_OPERATION_TIMEOUTED CURLE_OPERATION_TIMEDOUT
500
501 #define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR
502 #define CURLE_HTTP_PORT_FAILED CURLE_INTERFACE_FAILED
503 #define CURLE_FTP_COULDNT_STOR_FILE CURLE_UPLOAD_FAILED
504
505 #define CURLE_FTP_PARTIAL_FILE CURLE_PARTIAL_FILE
506 #define CURLE_FTP_BAD_DOWNLOAD_RESUME CURLE_BAD_DOWNLOAD_RESUME
507
508 /* This was the error code 50 in 7.7.3 and a few earlier versions, this
509    is no longer used by libcurl but is instead #defined here only to not
510    make programs break */
511 #define CURLE_ALREADY_COMPLETE 99999
512
513 #endif /*!CURL_NO_OLDIES*/
514
515 /* This prototype applies to all conversion callbacks */
516 typedef CURLcode (*curl_conv_callback)(char *buffer, size_t length);
517
518 typedef CURLcode (*curl_ssl_ctx_callback)(CURL *curl,    /* easy handle */
519                                           void *ssl_ctx, /* actually an
520                                                             OpenSSL SSL_CTX */
521                                           void *userptr);
522
523 typedef enum {
524   CURLPROXY_HTTP = 0,   /* added in 7.10 */
525   CURLPROXY_SOCKS4 = 4, /* support added in 7.15.2, enum existed already
526                            in 7.10 */
527   CURLPROXY_SOCKS5 = 5, /* added in 7.10 */
528   CURLPROXY_SOCKS4A = 6, /* added in 7.18.0 */
529   CURLPROXY_SOCKS5_HOSTNAME = 7 /* Use the SOCKS5 protocol but pass along the
530                                    host name rather than the IP address. added
531                                    in 7.18.0 */
532 } curl_proxytype;  /* this enum was added in 7.10 */
533
534 #define CURLAUTH_NONE         0       /* nothing */
535 #define CURLAUTH_BASIC        (1<<0)  /* Basic (default) */
536 #define CURLAUTH_DIGEST       (1<<1)  /* Digest */
537 #define CURLAUTH_GSSNEGOTIATE (1<<2)  /* GSS-Negotiate */
538 #define CURLAUTH_NTLM         (1<<3)  /* NTLM */
539 #define CURLAUTH_ANY ~0               /* all types set */
540 #define CURLAUTH_ANYSAFE (~CURLAUTH_BASIC)
541
542 #define CURLSSH_AUTH_ANY       ~0     /* all types supported by the server */
543 #define CURLSSH_AUTH_NONE      0      /* none allowed, silly but complete */
544 #define CURLSSH_AUTH_PUBLICKEY (1<<0) /* public/private key files */
545 #define CURLSSH_AUTH_PASSWORD  (1<<1) /* password */
546 #define CURLSSH_AUTH_HOST      (1<<2) /* host key files */
547 #define CURLSSH_AUTH_KEYBOARD  (1<<3) /* keyboard interactive */
548 #define CURLSSH_AUTH_DEFAULT CURLSSH_AUTH_ANY
549
550 #define CURL_ERROR_SIZE 256
551
552 /* parameter for the CURLOPT_USE_SSL option */
553 typedef enum {
554   CURLUSESSL_NONE,    /* do not attempt to use SSL */
555   CURLUSESSL_TRY,     /* try using SSL, proceed anyway otherwise */
556   CURLUSESSL_CONTROL, /* SSL for the control connection or fail */
557   CURLUSESSL_ALL,     /* SSL for all communication or fail */
558   CURLUSESSL_LAST     /* not an option, never use */
559 } curl_usessl;
560
561 #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
562                           the obsolete stuff removed! */
563
564 /* Backwards compatibility with older names */
565 /* These are scheduled to disappear by 2009 */
566
567 #define CURLFTPSSL_NONE CURLUSESSL_NONE
568 #define CURLFTPSSL_TRY CURLUSESSL_TRY
569 #define CURLFTPSSL_CONTROL CURLUSESSL_CONTROL
570 #define CURLFTPSSL_ALL CURLUSESSL_ALL
571 #define CURLFTPSSL_LAST CURLUSESSL_LAST
572 #define curl_ftpssl curl_usessl
573 #endif /*!CURL_NO_OLDIES*/
574
575 /* parameter for the CURLOPT_FTP_SSL_CCC option */
576 typedef enum {
577   CURLFTPSSL_CCC_NONE,    /* do not send CCC */
578   CURLFTPSSL_CCC_PASSIVE, /* Let the server initiate the shutdown */
579   CURLFTPSSL_CCC_ACTIVE,  /* Initiate the shutdown */
580   CURLFTPSSL_CCC_LAST     /* not an option, never use */
581 } curl_ftpccc;
582
583 /* parameter for the CURLOPT_FTPSSLAUTH option */
584 typedef enum {
585   CURLFTPAUTH_DEFAULT, /* let libcurl decide */
586   CURLFTPAUTH_SSL,     /* use "AUTH SSL" */
587   CURLFTPAUTH_TLS,     /* use "AUTH TLS" */
588   CURLFTPAUTH_LAST /* not an option, never use */
589 } curl_ftpauth;
590
591 /* parameter for the CURLOPT_FTP_FILEMETHOD option */
592 typedef enum {
593   CURLFTPMETHOD_DEFAULT,   /* let libcurl pick */
594   CURLFTPMETHOD_MULTICWD,  /* single CWD operation for each path part */
595   CURLFTPMETHOD_NOCWD,     /* no CWD at all */
596   CURLFTPMETHOD_SINGLECWD, /* one CWD to full dir, then work on file */
597   CURLFTPMETHOD_LAST       /* not an option, never use */
598 } curl_ftpmethod;
599
600 /* long may be 32 or 64 bits, but we should never depend on anything else
601    but 32 */
602 #define CURLOPTTYPE_LONG          0
603 #define CURLOPTTYPE_OBJECTPOINT   10000
604 #define CURLOPTTYPE_FUNCTIONPOINT 20000
605 #define CURLOPTTYPE_OFF_T         30000
606
607 /* name is uppercase CURLOPT_<name>,
608    type is one of the defined CURLOPTTYPE_<type>
609    number is unique identifier */
610 #ifdef CINIT
611 #undef CINIT
612 #endif
613 /*
614  * Figure out if we can use the ## operator, which is supported by ISO/ANSI C
615  * and C++. Some compilers support it without setting __STDC__ or __cplusplus
616  * so we need to carefully check for them too. We don't use configure-checks
617  * for these since we want these headers to remain generic and working for all
618  * platforms.
619  */
620 #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
621   defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
622   defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
623   defined(__ILEC400__)
624   /* This compiler is believed to have an ISO compatible preprocessor */
625 #define CURL_ISOCPP
626 #else
627   /* This compiler is believed NOT to have an ISO compatible preprocessor */
628 #undef CURL_ISOCPP
629 #endif
630
631 #ifdef CURL_ISOCPP
632 #define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number
633 #else
634 /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
635 #define LONG          CURLOPTTYPE_LONG
636 #define OBJECTPOINT   CURLOPTTYPE_OBJECTPOINT
637 #define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
638 #define OFF_T         CURLOPTTYPE_OFF_T
639 #define CINIT(name,type,number) CURLOPT_/**/name = type + number
640 #endif
641
642 /*
643  * This macro-mania below setups the CURLOPT_[what] enum, to be used with
644  * curl_easy_setopt(). The first argument in the CINIT() macro is the [what]
645  * word.
646  */
647
648 typedef enum {
649   /* This is the FILE * or void * the regular output should be written to. */
650   CINIT(FILE, OBJECTPOINT, 1),
651
652   /* The full URL to get/put */
653   CINIT(URL,  OBJECTPOINT, 2),
654
655   /* Port number to connect to, if other than default. */
656   CINIT(PORT, LONG, 3),
657
658   /* Name of proxy to use. */
659   CINIT(PROXY, OBJECTPOINT, 4),
660
661   /* "name:password" to use when fetching. */
662   CINIT(USERPWD, OBJECTPOINT, 5),
663
664   /* "name:password" to use with proxy. */
665   CINIT(PROXYUSERPWD, OBJECTPOINT, 6),
666
667   /* Range to get, specified as an ASCII string. */
668   CINIT(RANGE, OBJECTPOINT, 7),
669
670   /* not used */
671
672   /* Specified file stream to upload from (use as input): */
673   CINIT(INFILE, OBJECTPOINT, 9),
674
675   /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE
676    * bytes big. If this is not used, error messages go to stderr instead: */
677   CINIT(ERRORBUFFER, OBJECTPOINT, 10),
678
679   /* Function that will be called to store the output (instead of fwrite). The
680    * parameters will use fwrite() syntax, make sure to follow them. */
681   CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11),
682
683   /* Function that will be called to read the input (instead of fread). The
684    * parameters will use fread() syntax, make sure to follow them. */
685   CINIT(READFUNCTION, FUNCTIONPOINT, 12),
686
687   /* Time-out the read operation after this amount of seconds */
688   CINIT(TIMEOUT, LONG, 13),
689
690   /* If the CURLOPT_INFILE is used, this can be used to inform libcurl about
691    * how large the file being sent really is. That allows better error
692    * checking and better verifies that the upload was successful. -1 means
693    * unknown size.
694    *
695    * For large file support, there is also a _LARGE version of the key
696    * which takes an off_t type, allowing platforms with larger off_t
697    * sizes to handle larger files.  See below for INFILESIZE_LARGE.
698    */
699   CINIT(INFILESIZE, LONG, 14),
700
701   /* POST static input fields. */
702   CINIT(POSTFIELDS, OBJECTPOINT, 15),
703
704   /* Set the referrer page (needed by some CGIs) */
705   CINIT(REFERER, OBJECTPOINT, 16),
706
707   /* Set the FTP PORT string (interface name, named or numerical IP address)
708      Use i.e '-' to use default address. */
709   CINIT(FTPPORT, OBJECTPOINT, 17),
710
711   /* Set the User-Agent string (examined by some CGIs) */
712   CINIT(USERAGENT, OBJECTPOINT, 18),
713
714   /* If the download receives less than "low speed limit" bytes/second
715    * during "low speed time" seconds, the operations is aborted.
716    * You could i.e if you have a pretty high speed connection, abort if
717    * it is less than 2000 bytes/sec during 20 seconds.
718    */
719
720   /* Set the "low speed limit" */
721   CINIT(LOW_SPEED_LIMIT, LONG, 19),
722
723   /* Set the "low speed time" */
724   CINIT(LOW_SPEED_TIME, LONG, 20),
725
726   /* Set the continuation offset.
727    *
728    * Note there is also a _LARGE version of this key which uses
729    * off_t types, allowing for large file offsets on platforms which
730    * use larger-than-32-bit off_t's.  Look below for RESUME_FROM_LARGE.
731    */
732   CINIT(RESUME_FROM, LONG, 21),
733
734   /* Set cookie in request: */
735   CINIT(COOKIE, OBJECTPOINT, 22),
736
737   /* This points to a linked list of headers, struct curl_slist kind */
738   CINIT(HTTPHEADER, OBJECTPOINT, 23),
739
740   /* This points to a linked list of post entries, struct HttpPost */
741   CINIT(HTTPPOST, OBJECTPOINT, 24),
742
743   /* name of the file keeping your private SSL-certificate */
744   CINIT(SSLCERT, OBJECTPOINT, 25),
745
746   /* password for the SSL or SSH private key */
747   CINIT(KEYPASSWD, OBJECTPOINT, 26),
748
749   /* send TYPE parameter? */
750   CINIT(CRLF, LONG, 27),
751
752   /* send linked-list of QUOTE commands */
753   CINIT(QUOTE, OBJECTPOINT, 28),
754
755   /* send FILE * or void * to store headers to, if you use a callback it
756      is simply passed to the callback unmodified */
757   CINIT(WRITEHEADER, OBJECTPOINT, 29),
758
759   /* point to a file to read the initial cookies from, also enables
760      "cookie awareness" */
761   CINIT(COOKIEFILE, OBJECTPOINT, 31),
762
763   /* What version to specifically try to use.
764      See CURL_SSLVERSION defines below. */
765   CINIT(SSLVERSION, LONG, 32),
766
767   /* What kind of HTTP time condition to use, see defines */
768   CINIT(TIMECONDITION, LONG, 33),
769
770   /* Time to use with the above condition. Specified in number of seconds
771      since 1 Jan 1970 */
772   CINIT(TIMEVALUE, LONG, 34),
773
774   /* 35 = OBSOLETE */
775
776   /* Custom request, for customizing the get command like
777      HTTP: DELETE, TRACE and others
778      FTP: to use a different list command
779      */
780   CINIT(CUSTOMREQUEST, OBJECTPOINT, 36),
781
782   /* HTTP request, for odd commands like DELETE, TRACE and others */
783   CINIT(STDERR, OBJECTPOINT, 37),
784
785   /* 38 is not used */
786
787   /* send linked-list of post-transfer QUOTE commands */
788   CINIT(POSTQUOTE, OBJECTPOINT, 39),
789
790   /* Pass a pointer to string of the output using full variable-replacement
791      as described elsewhere. */
792   CINIT(WRITEINFO, OBJECTPOINT, 40),
793
794   CINIT(VERBOSE, LONG, 41),      /* talk a lot */
795   CINIT(HEADER, LONG, 42),       /* throw the header out too */
796   CINIT(NOPROGRESS, LONG, 43),   /* shut off the progress meter */
797   CINIT(NOBODY, LONG, 44),       /* use HEAD to get http document */
798   CINIT(FAILONERROR, LONG, 45),  /* no output on http error codes >= 300 */
799   CINIT(UPLOAD, LONG, 46),       /* this is an upload */
800   CINIT(POST, LONG, 47),         /* HTTP POST method */
801   CINIT(DIRLISTONLY, LONG, 48),  /* return bare names when listing directories */
802
803   CINIT(APPEND, LONG, 50),       /* Append instead of overwrite on upload! */
804
805   /* Specify whether to read the user+password from the .netrc or the URL.
806    * This must be one of the CURL_NETRC_* enums below. */
807   CINIT(NETRC, LONG, 51),
808
809   CINIT(FOLLOWLOCATION, LONG, 52),  /* use Location: Luke! */
810
811   CINIT(TRANSFERTEXT, LONG, 53), /* transfer data in text/ASCII format */
812   CINIT(PUT, LONG, 54),          /* HTTP PUT */
813
814   /* 55 = OBSOLETE */
815
816   /* Function that will be called instead of the internal progress display
817    * function. This function should be defined as the curl_progress_callback
818    * prototype defines. */
819   CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56),
820
821   /* Data passed to the progress callback */
822   CINIT(PROGRESSDATA, OBJECTPOINT, 57),
823
824   /* We want the referrer field set automatically when following locations */
825   CINIT(AUTOREFERER, LONG, 58),
826
827   /* Port of the proxy, can be set in the proxy string as well with:
828      "[host]:[port]" */
829   CINIT(PROXYPORT, LONG, 59),
830
831   /* size of the POST input data, if strlen() is not good to use */
832   CINIT(POSTFIELDSIZE, LONG, 60),
833
834   /* tunnel non-http operations through a HTTP proxy */
835   CINIT(HTTPPROXYTUNNEL, LONG, 61),
836
837   /* Set the interface string to use as outgoing network interface */
838   CINIT(INTERFACE, OBJECTPOINT, 62),
839
840   /* Set the krb4/5 security level, this also enables krb4/5 awareness.  This
841    * is a string, 'clear', 'safe', 'confidential' or 'private'.  If the string
842    * is set but doesn't match one of these, 'private' will be used.  */
843   CINIT(KRBLEVEL, OBJECTPOINT, 63),
844
845   /* Set if we should verify the peer in ssl handshake, set 1 to verify. */
846   CINIT(SSL_VERIFYPEER, LONG, 64),
847
848   /* The CApath or CAfile used to validate the peer certificate
849      this option is used only if SSL_VERIFYPEER is true */
850   CINIT(CAINFO, OBJECTPOINT, 65),
851
852   /* 66 = OBSOLETE */
853   /* 67 = OBSOLETE */
854
855   /* Maximum number of http redirects to follow */
856   CINIT(MAXREDIRS, LONG, 68),
857
858   /* Pass a long set to 1 to get the date of the requested document (if
859      possible)! Pass a zero to shut it off. */
860   CINIT(FILETIME, LONG, 69),
861
862   /* This points to a linked list of telnet options */
863   CINIT(TELNETOPTIONS, OBJECTPOINT, 70),
864
865   /* Max amount of cached alive connections */
866   CINIT(MAXCONNECTS, LONG, 71),
867
868   /* What policy to use when closing connections when the cache is filled
869      up */
870   CINIT(CLOSEPOLICY, LONG, 72),
871
872   /* 73 = OBSOLETE */
873
874   /* Set to explicitly use a new connection for the upcoming transfer.
875      Do not use this unless you're absolutely sure of this, as it makes the
876      operation slower and is less friendly for the network. */
877   CINIT(FRESH_CONNECT, LONG, 74),
878
879   /* Set to explicitly forbid the upcoming transfer's connection to be re-used
880      when done. Do not use this unless you're absolutely sure of this, as it
881      makes the operation slower and is less friendly for the network. */
882   CINIT(FORBID_REUSE, LONG, 75),
883
884   /* Set to a file name that contains random data for libcurl to use to
885      seed the random engine when doing SSL connects. */
886   CINIT(RANDOM_FILE, OBJECTPOINT, 76),
887
888   /* Set to the Entropy Gathering Daemon socket pathname */
889   CINIT(EGDSOCKET, OBJECTPOINT, 77),
890
891   /* Time-out connect operations after this amount of seconds, if connects
892      are OK within this time, then fine... This only aborts the connect
893      phase. [Only works on unix-style/SIGALRM operating systems] */
894   CINIT(CONNECTTIMEOUT, LONG, 78),
895
896   /* Function that will be called to store headers (instead of fwrite). The
897    * parameters will use fwrite() syntax, make sure to follow them. */
898   CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79),
899
900   /* Set this to force the HTTP request to get back to GET. Only really usable
901      if POST, PUT or a custom request have been used first.
902    */
903   CINIT(HTTPGET, LONG, 80),
904
905   /* Set if we should verify the Common name from the peer certificate in ssl
906    * handshake, set 1 to check existence, 2 to ensure that it matches the
907    * provided hostname. */
908   CINIT(SSL_VERIFYHOST, LONG, 81),
909
910   /* Specify which file name to write all known cookies in after completed
911      operation. Set file name to "-" (dash) to make it go to stdout. */
912   CINIT(COOKIEJAR, OBJECTPOINT, 82),
913
914   /* Specify which SSL ciphers to use */
915   CINIT(SSL_CIPHER_LIST, OBJECTPOINT, 83),
916
917   /* Specify which HTTP version to use! This must be set to one of the
918      CURL_HTTP_VERSION* enums set below. */
919   CINIT(HTTP_VERSION, LONG, 84),
920
921   /* Specifically switch on or off the FTP engine's use of the EPSV command. By
922      default, that one will always be attempted before the more traditional
923      PASV command. */
924   CINIT(FTP_USE_EPSV, LONG, 85),
925
926   /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */
927   CINIT(SSLCERTTYPE, OBJECTPOINT, 86),
928
929   /* name of the file keeping your private SSL-key */
930   CINIT(SSLKEY, OBJECTPOINT, 87),
931
932   /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */
933   CINIT(SSLKEYTYPE, OBJECTPOINT, 88),
934
935   /* crypto engine for the SSL-sub system */
936   CINIT(SSLENGINE, OBJECTPOINT, 89),
937
938   /* set the crypto engine for the SSL-sub system as default
939      the param has no meaning...
940    */
941   CINIT(SSLENGINE_DEFAULT, LONG, 90),
942
943   /* Non-zero value means to use the global dns cache */
944   CINIT(DNS_USE_GLOBAL_CACHE, LONG, 91), /* To become OBSOLETE soon */
945
946   /* DNS cache timeout */
947   CINIT(DNS_CACHE_TIMEOUT, LONG, 92),
948
949   /* send linked-list of pre-transfer QUOTE commands (Wesley Laxton)*/
950   CINIT(PREQUOTE, OBJECTPOINT, 93),
951
952   /* set the debug function */
953   CINIT(DEBUGFUNCTION, FUNCTIONPOINT, 94),
954
955   /* set the data for the debug function */
956   CINIT(DEBUGDATA, OBJECTPOINT, 95),
957
958   /* mark this as start of a cookie session */
959   CINIT(COOKIESESSION, LONG, 96),
960
961   /* The CApath directory used to validate the peer certificate
962      this option is used only if SSL_VERIFYPEER is true */
963   CINIT(CAPATH, OBJECTPOINT, 97),
964
965   /* Instruct libcurl to use a smaller receive buffer */
966   CINIT(BUFFERSIZE, LONG, 98),
967
968   /* Instruct libcurl to not use any signal/alarm handlers, even when using
969      timeouts. This option is useful for multi-threaded applications.
970      See libcurl-the-guide for more background information. */
971   CINIT(NOSIGNAL, LONG, 99),
972
973   /* Provide a CURLShare for mutexing non-ts data */
974   CINIT(SHARE, OBJECTPOINT, 100),
975
976   /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default),
977      CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A and CURLPROXY_SOCKS5. */
978   CINIT(PROXYTYPE, LONG, 101),
979
980   /* Set the Accept-Encoding string. Use this to tell a server you would like
981      the response to be compressed. */
982   CINIT(ENCODING, OBJECTPOINT, 102),
983
984   /* Set pointer to private data */
985   CINIT(PRIVATE, OBJECTPOINT, 103),
986
987   /* Set aliases for HTTP 200 in the HTTP Response header */
988   CINIT(HTTP200ALIASES, OBJECTPOINT, 104),
989
990   /* Continue to send authentication (user+password) when following locations,
991      even when hostname changed. This can potentially send off the name
992      and password to whatever host the server decides. */
993   CINIT(UNRESTRICTED_AUTH, LONG, 105),
994
995   /* Specifically switch on or off the FTP engine's use of the EPRT command ( it
996      also disables the LPRT attempt). By default, those ones will always be
997      attempted before the good old traditional PORT command. */
998   CINIT(FTP_USE_EPRT, LONG, 106),
999
1000   /* Set this to a bitmask value to enable the particular authentications
1001      methods you like. Use this in combination with CURLOPT_USERPWD.
1002      Note that setting multiple bits may cause extra network round-trips. */
1003   CINIT(HTTPAUTH, LONG, 107),
1004
1005   /* Set the ssl context callback function, currently only for OpenSSL ssl_ctx
1006      in second argument. The function must be matching the
1007      curl_ssl_ctx_callback proto. */
1008   CINIT(SSL_CTX_FUNCTION, FUNCTIONPOINT, 108),
1009
1010   /* Set the userdata for the ssl context callback function's third
1011      argument */
1012   CINIT(SSL_CTX_DATA, OBJECTPOINT, 109),
1013
1014   /* FTP Option that causes missing dirs to be created on the remote server */
1015   CINIT(FTP_CREATE_MISSING_DIRS, LONG, 110),
1016
1017   /* Set this to a bitmask value to enable the particular authentications
1018      methods you like. Use this in combination with CURLOPT_PROXYUSERPWD.
1019      Note that setting multiple bits may cause extra network round-trips. */
1020   CINIT(PROXYAUTH, LONG, 111),
1021
1022   /* FTP option that changes the timeout, in seconds, associated with
1023      getting a response.  This is different from transfer timeout time and
1024      essentially places a demand on the FTP server to acknowledge commands
1025      in a timely manner. */
1026   CINIT(FTP_RESPONSE_TIMEOUT, LONG, 112),
1027
1028   /* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to
1029      tell libcurl to resolve names to those IP versions only. This only has
1030      affect on systems with support for more than one, i.e IPv4 _and_ IPv6. */
1031   CINIT(IPRESOLVE, LONG, 113),
1032
1033   /* Set this option to limit the size of a file that will be downloaded from
1034      an HTTP or FTP server.
1035
1036      Note there is also _LARGE version which adds large file support for
1037      platforms which have larger off_t sizes.  See MAXFILESIZE_LARGE below. */
1038   CINIT(MAXFILESIZE, LONG, 114),
1039
1040   /* See the comment for INFILESIZE above, but in short, specifies
1041    * the size of the file being uploaded.  -1 means unknown.
1042    */
1043   CINIT(INFILESIZE_LARGE, OFF_T, 115),
1044
1045   /* Sets the continuation offset.  There is also a LONG version of this;
1046    * look above for RESUME_FROM.
1047    */
1048   CINIT(RESUME_FROM_LARGE, OFF_T, 116),
1049
1050   /* Sets the maximum size of data that will be downloaded from
1051    * an HTTP or FTP server.  See MAXFILESIZE above for the LONG version.
1052    */
1053   CINIT(MAXFILESIZE_LARGE, OFF_T, 117),
1054
1055   /* Set this option to the file name of your .netrc file you want libcurl
1056      to parse (using the CURLOPT_NETRC option). If not set, libcurl will do
1057      a poor attempt to find the user's home directory and check for a .netrc
1058      file in there. */
1059   CINIT(NETRC_FILE, OBJECTPOINT, 118),
1060
1061   /* Enable SSL/TLS for FTP, pick one of:
1062      CURLFTPSSL_TRY     - try using SSL, proceed anyway otherwise
1063      CURLFTPSSL_CONTROL - SSL for the control connection or fail
1064      CURLFTPSSL_ALL     - SSL for all communication or fail
1065   */
1066   CINIT(USE_SSL, LONG, 119),
1067
1068   /* The _LARGE version of the standard POSTFIELDSIZE option */
1069   CINIT(POSTFIELDSIZE_LARGE, OFF_T, 120),
1070
1071   /* Enable/disable the TCP Nagle algorithm */
1072   CINIT(TCP_NODELAY, LONG, 121),
1073
1074   /* 122 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
1075   /* 123 OBSOLETE. Gone in 7.16.0 */
1076   /* 124 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
1077   /* 125 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
1078   /* 126 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
1079   /* 127 OBSOLETE. Gone in 7.16.0 */
1080   /* 128 OBSOLETE. Gone in 7.16.0 */
1081
1082   /* When FTP over SSL/TLS is selected (with CURLOPT_USE_SSL), this option
1083      can be used to change libcurl's default action which is to first try
1084      "AUTH SSL" and then "AUTH TLS" in this order, and proceed when a OK
1085      response has been received.
1086
1087      Available parameters are:
1088      CURLFTPAUTH_DEFAULT - let libcurl decide
1089      CURLFTPAUTH_SSL     - try "AUTH SSL" first, then TLS
1090      CURLFTPAUTH_TLS     - try "AUTH TLS" first, then SSL
1091   */
1092   CINIT(FTPSSLAUTH, LONG, 129),
1093
1094   CINIT(IOCTLFUNCTION, FUNCTIONPOINT, 130),
1095   CINIT(IOCTLDATA, OBJECTPOINT, 131),
1096
1097   /* 132 OBSOLETE. Gone in 7.16.0 */
1098   /* 133 OBSOLETE. Gone in 7.16.0 */
1099
1100   /* zero terminated string for pass on to the FTP server when asked for
1101      "account" info */
1102   CINIT(FTP_ACCOUNT, OBJECTPOINT, 134),
1103
1104   /* feed cookies into cookie engine */
1105   CINIT(COOKIELIST, OBJECTPOINT, 135),
1106
1107   /* ignore Content-Length */
1108   CINIT(IGNORE_CONTENT_LENGTH, LONG, 136),
1109
1110   /* Set to non-zero to skip the IP address received in a 227 PASV FTP server
1111      response. Typically used for FTP-SSL purposes but is not restricted to
1112      that. libcurl will then instead use the same IP address it used for the
1113      control connection. */
1114   CINIT(FTP_SKIP_PASV_IP, LONG, 137),
1115
1116   /* Select "file method" to use when doing FTP, see the curl_ftpmethod
1117      above. */
1118   CINIT(FTP_FILEMETHOD, LONG, 138),
1119
1120   /* Local port number to bind the socket to */
1121   CINIT(LOCALPORT, LONG, 139),
1122
1123   /* Number of ports to try, including the first one set with LOCALPORT.
1124      Thus, setting it to 1 will make no additional attempts but the first.
1125   */
1126   CINIT(LOCALPORTRANGE, LONG, 140),
1127
1128   /* no transfer, set up connection and let application use the socket by
1129      extracting it with CURLINFO_LASTSOCKET */
1130   CINIT(CONNECT_ONLY, LONG, 141),
1131
1132   /* Function that will be called to convert from the
1133      network encoding (instead of using the iconv calls in libcurl) */
1134   CINIT(CONV_FROM_NETWORK_FUNCTION, FUNCTIONPOINT, 142),
1135
1136   /* Function that will be called to convert to the
1137      network encoding (instead of using the iconv calls in libcurl) */
1138   CINIT(CONV_TO_NETWORK_FUNCTION, FUNCTIONPOINT, 143),
1139
1140   /* Function that will be called to convert from UTF8
1141      (instead of using the iconv calls in libcurl)
1142      Note that this is used only for SSL certificate processing */
1143   CINIT(CONV_FROM_UTF8_FUNCTION, FUNCTIONPOINT, 144),
1144
1145   /* if the connection proceeds too quickly then need to slow it down */
1146   /* limit-rate: maximum number of bytes per second to send or receive */
1147   CINIT(MAX_SEND_SPEED_LARGE, OFF_T, 145),
1148   CINIT(MAX_RECV_SPEED_LARGE, OFF_T, 146),
1149
1150   /* Pointer to command string to send if USER/PASS fails. */
1151   CINIT(FTP_ALTERNATIVE_TO_USER, OBJECTPOINT, 147),
1152
1153   /* callback function for setting socket options */
1154   CINIT(SOCKOPTFUNCTION, FUNCTIONPOINT, 148),
1155   CINIT(SOCKOPTDATA, OBJECTPOINT, 149),
1156
1157   /* set to 0 to disable session ID re-use for this transfer, default is
1158      enabled (== 1) */
1159   CINIT(SSL_SESSIONID_CACHE, LONG, 150),
1160
1161   /* allowed SSH authentication methods */
1162   CINIT(SSH_AUTH_TYPES, LONG, 151),
1163
1164   /* Used by scp/sftp to do public/private key authentication */
1165   CINIT(SSH_PUBLIC_KEYFILE, OBJECTPOINT, 152),
1166   CINIT(SSH_PRIVATE_KEYFILE, OBJECTPOINT, 153),
1167
1168   /* Send CCC (Clear Command Channel) after authentication */
1169   CINIT(FTP_SSL_CCC, LONG, 154),
1170
1171   /* Same as TIMEOUT and CONNECTTIMEOUT, but with ms resolution */
1172   CINIT(TIMEOUT_MS, LONG, 155),
1173   CINIT(CONNECTTIMEOUT_MS, LONG, 156),
1174
1175   /* set to zero to disable the libcurl's decoding and thus pass the raw body
1176      data to the application even when it is encoded/compressed */
1177   CINIT(HTTP_TRANSFER_DECODING, LONG, 157),
1178   CINIT(HTTP_CONTENT_DECODING, LONG, 158),
1179
1180   /* Permission used when creating new files and directories on the remote
1181      server for protocols that support it, SFTP/SCP/FILE */
1182   CINIT(NEW_FILE_PERMS, LONG, 159),
1183   CINIT(NEW_DIRECTORY_PERMS, LONG, 160),
1184
1185   /* Obey RFC 2616/10.3.2 and keep POSTs as POSTs after a 301 */
1186   CINIT(POST301, LONG, 161),
1187
1188   /* used by scp/sftp to verify the host's public key */
1189   CINIT(SSH_HOST_PUBLIC_KEY_MD5, OBJECTPOINT, 162),
1190
1191   /* Callback function for opening socket (instead of socket(2)). Optionally,
1192      callback is able change the address or refuse to connect returning
1193      CURL_SOCKET_BAD.  The callback should have type
1194      curl_opensocket_callback */
1195   CINIT(OPENSOCKETFUNCTION, FUNCTIONPOINT, 163),
1196   CINIT(OPENSOCKETDATA, OBJECTPOINT, 164),
1197
1198   /* POST volatile input fields. */
1199   CINIT(COPYPOSTFIELDS, OBJECTPOINT, 165),
1200
1201   /* set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy */
1202   CINIT(PROXY_TRANSFER_MODE, LONG, 166),
1203
1204   /* Callback function for seeking in the input stream */
1205   CINIT(SEEKFUNCTION, FUNCTIONPOINT, 167),
1206   CINIT(SEEKDATA, OBJECTPOINT, 168),
1207
1208   /* CRL file */
1209   CINIT(CRLFILE, OBJECTPOINT, 169),
1210
1211   /* Issuer certificate */
1212   CINIT(ISSUERCERT, OBJECTPOINT, 170),
1213
1214   /* (IPv6) Address scope */
1215   CINIT(ADDRESS_SCOPE, LONG, 171),
1216
1217   CURLOPT_LASTENTRY /* the last unused */
1218 } CURLoption;
1219
1220 #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
1221                           the obsolete stuff removed! */
1222
1223 /* Backwards compatibility with older names */
1224 /* These are scheduled to disappear by 2009 */
1225
1226 /* The following were added in 7.17.0 */
1227 #define CURLOPT_SSLKEYPASSWD CURLOPT_KEYPASSWD
1228 #define CURLOPT_FTPAPPEND CURLOPT_APPEND
1229 #define CURLOPT_FTPLISTONLY CURLOPT_DIRLISTONLY
1230 #define CURLOPT_FTP_SSL CURLOPT_USE_SSL
1231
1232 /* The following were added earlier */
1233
1234 #define CURLOPT_SSLCERTPASSWD CURLOPT_KEYPASSWD
1235 #define CURLOPT_KRB4LEVEL CURLOPT_KRBLEVEL
1236
1237 #else
1238 /* This is set if CURL_NO_OLDIES is defined at compile-time */
1239 #undef CURLOPT_DNS_USE_GLOBAL_CACHE /* soon obsolete */
1240 #endif
1241
1242
1243   /* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host
1244      name resolves addresses using more than one IP protocol version, this
1245      option might be handy to force libcurl to use a specific IP version. */
1246 #define CURL_IPRESOLVE_WHATEVER 0 /* default, resolves addresses to all IP
1247                                      versions that your system allows */
1248 #define CURL_IPRESOLVE_V4       1 /* resolve to ipv4 addresses */
1249 #define CURL_IPRESOLVE_V6       2 /* resolve to ipv6 addresses */
1250
1251   /* three convenient "aliases" that follow the name scheme better */
1252 #define CURLOPT_WRITEDATA CURLOPT_FILE
1253 #define CURLOPT_READDATA  CURLOPT_INFILE
1254 #define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER
1255
1256   /* These enums are for use with the CURLOPT_HTTP_VERSION option. */
1257 enum {
1258   CURL_HTTP_VERSION_NONE, /* setting this means we don't care, and that we'd
1259                              like the library to choose the best possible
1260                              for us! */
1261   CURL_HTTP_VERSION_1_0,  /* please use HTTP 1.0 in the request */
1262   CURL_HTTP_VERSION_1_1,  /* please use HTTP 1.1 in the request */
1263
1264   CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */
1265 };
1266
1267   /* These enums are for use with the CURLOPT_NETRC option. */
1268 enum CURL_NETRC_OPTION {
1269   CURL_NETRC_IGNORED,     /* The .netrc will never be read.
1270                            * This is the default. */
1271   CURL_NETRC_OPTIONAL,    /* A user:password in the URL will be preferred
1272                            * to one in the .netrc. */
1273   CURL_NETRC_REQUIRED,    /* A user:password in the URL will be ignored.
1274                            * Unless one is set programmatically, the .netrc
1275                            * will be queried. */
1276   CURL_NETRC_LAST
1277 };
1278
1279 enum {
1280   CURL_SSLVERSION_DEFAULT,
1281   CURL_SSLVERSION_TLSv1,
1282   CURL_SSLVERSION_SSLv2,
1283   CURL_SSLVERSION_SSLv3,
1284
1285   CURL_SSLVERSION_LAST /* never use, keep last */
1286 };
1287
1288
1289 typedef enum {
1290   CURL_TIMECOND_NONE,
1291
1292   CURL_TIMECOND_IFMODSINCE,
1293   CURL_TIMECOND_IFUNMODSINCE,
1294   CURL_TIMECOND_LASTMOD,
1295
1296   CURL_TIMECOND_LAST
1297 } curl_TimeCond;
1298
1299
1300 /* curl_strequal() and curl_strnequal() are subject for removal in a future
1301    libcurl, see lib/README.curlx for details */
1302 CURL_EXTERN int (curl_strequal)(const char *s1, const char *s2);
1303 CURL_EXTERN int (curl_strnequal)(const char *s1, const char *s2, size_t n);
1304
1305 /* name is uppercase CURLFORM_<name> */
1306 #ifdef CFINIT
1307 #undef CFINIT
1308 #endif
1309
1310 #ifdef CURL_ISOCPP
1311 #define CFINIT(name) CURLFORM_ ## name
1312 #else
1313 /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
1314 #define CFINIT(name) CURLFORM_/**/name
1315 #endif
1316
1317 typedef enum {
1318   CFINIT(NOTHING),        /********* the first one is unused ************/
1319
1320   /*  */
1321   CFINIT(COPYNAME),
1322   CFINIT(PTRNAME),
1323   CFINIT(NAMELENGTH),
1324   CFINIT(COPYCONTENTS),
1325   CFINIT(PTRCONTENTS),
1326   CFINIT(CONTENTSLENGTH),
1327   CFINIT(FILECONTENT),
1328   CFINIT(ARRAY),
1329   CFINIT(OBSOLETE),
1330   CFINIT(FILE),
1331
1332   CFINIT(BUFFER),
1333   CFINIT(BUFFERPTR),
1334   CFINIT(BUFFERLENGTH),
1335
1336   CFINIT(CONTENTTYPE),
1337   CFINIT(CONTENTHEADER),
1338   CFINIT(FILENAME),
1339   CFINIT(END),
1340   CFINIT(OBSOLETE2),
1341
1342   CFINIT(STREAM),
1343
1344   CURLFORM_LASTENTRY /* the last unused */
1345 } CURLformoption;
1346
1347 #undef CFINIT /* done */
1348
1349 /* structure to be used as parameter for CURLFORM_ARRAY */
1350 struct curl_forms {
1351   CURLformoption option;
1352   const char     *value;
1353 };
1354
1355 /* use this for multipart formpost building */
1356 /* Returns code for curl_formadd()
1357  *
1358  * Returns:
1359  * CURL_FORMADD_OK             on success
1360  * CURL_FORMADD_MEMORY         if the FormInfo allocation fails
1361  * CURL_FORMADD_OPTION_TWICE   if one option is given twice for one Form
1362  * CURL_FORMADD_NULL           if a null pointer was given for a char
1363  * CURL_FORMADD_MEMORY         if the allocation of a FormInfo struct failed
1364  * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used
1365  * CURL_FORMADD_INCOMPLETE     if the some FormInfo is not complete (or error)
1366  * CURL_FORMADD_MEMORY         if a HttpPost struct cannot be allocated
1367  * CURL_FORMADD_MEMORY         if some allocation for string copying failed.
1368  * CURL_FORMADD_ILLEGAL_ARRAY  if an illegal option is used in an array
1369  *
1370  ***************************************************************************/
1371 typedef enum {
1372   CURL_FORMADD_OK, /* first, no error */
1373
1374   CURL_FORMADD_MEMORY,
1375   CURL_FORMADD_OPTION_TWICE,
1376   CURL_FORMADD_NULL,
1377   CURL_FORMADD_UNKNOWN_OPTION,
1378   CURL_FORMADD_INCOMPLETE,
1379   CURL_FORMADD_ILLEGAL_ARRAY,
1380   CURL_FORMADD_DISABLED, /* libcurl was built with this disabled */
1381
1382   CURL_FORMADD_LAST /* last */
1383 } CURLFORMcode;
1384
1385 /*
1386  * NAME curl_formadd()
1387  *
1388  * DESCRIPTION
1389  *
1390  * Pretty advanced function for building multi-part formposts. Each invoke
1391  * adds one part that together construct a full post. Then use
1392  * CURLOPT_HTTPPOST to send it off to libcurl.
1393  */
1394 CURL_EXTERN CURLFORMcode curl_formadd(struct curl_httppost **httppost,
1395                                       struct curl_httppost **last_post,
1396                                       ...);
1397
1398 /*
1399  * callback function for curl_formget()
1400  * The void *arg pointer will be the one passed as second argument to
1401  *   curl_formget().
1402  * The character buffer passed to it must not be freed.
1403  * Should return the buffer length passed to it as the argument "len" on
1404  *   success.
1405  */
1406 typedef size_t (*curl_formget_callback)(void *arg, const char *buf, size_t len);
1407
1408 /*
1409  * NAME curl_formget()
1410  *
1411  * DESCRIPTION
1412  *
1413  * Serialize a curl_httppost struct built with curl_formadd().
1414  * Accepts a void pointer as second argument which will be passed to
1415  * the curl_formget_callback function.
1416  * Returns 0 on success.
1417  */
1418 CURL_EXTERN int curl_formget(struct curl_httppost *form, void *arg,
1419                              curl_formget_callback append);
1420 /*
1421  * NAME curl_formfree()
1422  *
1423  * DESCRIPTION
1424  *
1425  * Free a multipart formpost previously built with curl_formadd().
1426  */
1427 CURL_EXTERN void curl_formfree(struct curl_httppost *form);
1428
1429 /*
1430  * NAME curl_getenv()
1431  *
1432  * DESCRIPTION
1433  *
1434  * Returns a malloc()'ed string that MUST be curl_free()ed after usage is
1435  * complete. DEPRECATED - see lib/README.curlx
1436  */
1437 CURL_EXTERN char *curl_getenv(const char *variable);
1438
1439 /*
1440  * NAME curl_version()
1441  *
1442  * DESCRIPTION
1443  *
1444  * Returns a static ascii string of the libcurl version.
1445  */
1446 CURL_EXTERN char *curl_version(void);
1447
1448 /*
1449  * NAME curl_easy_escape()
1450  *
1451  * DESCRIPTION
1452  *
1453  * Escapes URL strings (converts all letters consider illegal in URLs to their
1454  * %XX versions). This function returns a new allocated string or NULL if an
1455  * error occurred.
1456  */
1457 CURL_EXTERN char *curl_easy_escape(CURL *handle,
1458                                    const char *string,
1459                                    int length);
1460
1461 /* the previous version: */
1462 CURL_EXTERN char *curl_escape(const char *string,
1463                               int length);
1464
1465
1466 /*
1467  * NAME curl_easy_unescape()
1468  *
1469  * DESCRIPTION
1470  *
1471  * Unescapes URL encoding in strings (converts all %XX codes to their 8bit
1472  * versions). This function returns a new allocated string or NULL if an error
1473  * occurred.
1474  * Conversion Note: On non-ASCII platforms the ASCII %XX codes are
1475  * converted into the host encoding.
1476  */
1477 CURL_EXTERN char *curl_easy_unescape(CURL *handle,
1478                                      const char *string,
1479                                      int length,
1480                                      int *outlength);
1481
1482 /* the previous version */
1483 CURL_EXTERN char *curl_unescape(const char *string,
1484                                 int length);
1485
1486 /*
1487  * NAME curl_free()
1488  *
1489  * DESCRIPTION
1490  *
1491  * Provided for de-allocation in the same translation unit that did the
1492  * allocation. Added in libcurl 7.10
1493  */
1494 CURL_EXTERN void curl_free(void *p);
1495
1496 /*
1497  * NAME curl_global_init()
1498  *
1499  * DESCRIPTION
1500  *
1501  * curl_global_init() should be invoked exactly once for each application that
1502  * uses libcurl
1503  */
1504 CURL_EXTERN CURLcode curl_global_init(long flags);
1505
1506 /*
1507  * NAME curl_global_init_mem()
1508  *
1509  * DESCRIPTION
1510  *
1511  * curl_global_init() or curl_global_init_mem() should be invoked exactly once
1512  * for each application that uses libcurl.  This function can be used to
1513  * initialize libcurl and set user defined memory management callback
1514  * functions.  Users can implement memory management routines to check for
1515  * memory leaks, check for mis-use of the curl library etc.  User registered
1516  * callback routines with be invoked by this library instead of the system
1517  * memory management routines like malloc, free etc.
1518  */
1519 CURL_EXTERN CURLcode curl_global_init_mem(long flags,
1520                                           curl_malloc_callback m,
1521                                           curl_free_callback f,
1522                                           curl_realloc_callback r,
1523                                           curl_strdup_callback s,
1524                                           curl_calloc_callback c);
1525
1526 /*
1527  * NAME curl_global_cleanup()
1528  *
1529  * DESCRIPTION
1530  *
1531  * curl_global_cleanup() should be invoked exactly once for each application
1532  * that uses libcurl
1533  */
1534 CURL_EXTERN void curl_global_cleanup(void);
1535
1536 /* linked-list structure for the CURLOPT_QUOTE option (and other) */
1537 struct curl_slist {
1538   char *data;
1539   struct curl_slist *next;
1540 };
1541
1542 /*
1543  * NAME curl_slist_append()
1544  *
1545  * DESCRIPTION
1546  *
1547  * Appends a string to a linked list. If no list exists, it will be created
1548  * first. Returns the new list, after appending.
1549  */
1550 CURL_EXTERN struct curl_slist *curl_slist_append(struct curl_slist *,
1551                                                  const char *);
1552
1553 /*
1554  * NAME curl_slist_free_all()
1555  *
1556  * DESCRIPTION
1557  *
1558  * free a previously built curl_slist.
1559  */
1560 CURL_EXTERN void curl_slist_free_all(struct curl_slist *);
1561
1562 /*
1563  * NAME curl_getdate()
1564  *
1565  * DESCRIPTION
1566  *
1567  * Returns the time, in seconds since 1 Jan 1970 of the time string given in
1568  * the first argument. The time argument in the second parameter is unused
1569  * and should be set to NULL.
1570  */
1571 CURL_EXTERN time_t curl_getdate(const char *p, const time_t *unused);
1572
1573 #define CURLINFO_STRING   0x100000
1574 #define CURLINFO_LONG     0x200000
1575 #define CURLINFO_DOUBLE   0x300000
1576 #define CURLINFO_SLIST    0x400000
1577 #define CURLINFO_MASK     0x0fffff
1578 #define CURLINFO_TYPEMASK 0xf00000
1579
1580 typedef enum {
1581   CURLINFO_NONE, /* first, never use this */
1582   CURLINFO_EFFECTIVE_URL    = CURLINFO_STRING + 1,
1583   CURLINFO_RESPONSE_CODE    = CURLINFO_LONG   + 2,
1584   CURLINFO_TOTAL_TIME       = CURLINFO_DOUBLE + 3,
1585   CURLINFO_NAMELOOKUP_TIME  = CURLINFO_DOUBLE + 4,
1586   CURLINFO_CONNECT_TIME     = CURLINFO_DOUBLE + 5,
1587   CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6,
1588   CURLINFO_SIZE_UPLOAD      = CURLINFO_DOUBLE + 7,
1589   CURLINFO_SIZE_DOWNLOAD    = CURLINFO_DOUBLE + 8,
1590   CURLINFO_SPEED_DOWNLOAD   = CURLINFO_DOUBLE + 9,
1591   CURLINFO_SPEED_UPLOAD     = CURLINFO_DOUBLE + 10,
1592   CURLINFO_HEADER_SIZE      = CURLINFO_LONG   + 11,
1593   CURLINFO_REQUEST_SIZE     = CURLINFO_LONG   + 12,
1594   CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG   + 13,
1595   CURLINFO_FILETIME         = CURLINFO_LONG   + 14,
1596   CURLINFO_CONTENT_LENGTH_DOWNLOAD   = CURLINFO_DOUBLE + 15,
1597   CURLINFO_CONTENT_LENGTH_UPLOAD     = CURLINFO_DOUBLE + 16,
1598   CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17,
1599   CURLINFO_CONTENT_TYPE     = CURLINFO_STRING + 18,
1600   CURLINFO_REDIRECT_TIME    = CURLINFO_DOUBLE + 19,
1601   CURLINFO_REDIRECT_COUNT   = CURLINFO_LONG   + 20,
1602   CURLINFO_PRIVATE          = CURLINFO_STRING + 21,
1603   CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG   + 22,
1604   CURLINFO_HTTPAUTH_AVAIL   = CURLINFO_LONG   + 23,
1605   CURLINFO_PROXYAUTH_AVAIL  = CURLINFO_LONG   + 24,
1606   CURLINFO_OS_ERRNO         = CURLINFO_LONG   + 25,
1607   CURLINFO_NUM_CONNECTS     = CURLINFO_LONG   + 26,
1608   CURLINFO_SSL_ENGINES      = CURLINFO_SLIST  + 27,
1609   CURLINFO_COOKIELIST       = CURLINFO_SLIST  + 28,
1610   CURLINFO_LASTSOCKET       = CURLINFO_LONG   + 29,
1611   CURLINFO_FTP_ENTRY_PATH   = CURLINFO_STRING + 30,
1612   CURLINFO_REDIRECT_URL     = CURLINFO_STRING + 31,
1613   CURLINFO_PRIMARY_IP       = CURLINFO_STRING + 32,
1614   CURLINFO_APPCONNECT_TIME  = CURLINFO_DOUBLE + 33,
1615   /* Fill in new entries below here! */
1616
1617   CURLINFO_LASTONE          = 33
1618 } CURLINFO;
1619
1620 /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as
1621    CURLINFO_HTTP_CODE */
1622 #define CURLINFO_HTTP_CODE CURLINFO_RESPONSE_CODE
1623
1624 typedef enum {
1625   CURLCLOSEPOLICY_NONE, /* first, never use this */
1626
1627   CURLCLOSEPOLICY_OLDEST,
1628   CURLCLOSEPOLICY_LEAST_RECENTLY_USED,
1629   CURLCLOSEPOLICY_LEAST_TRAFFIC,
1630   CURLCLOSEPOLICY_SLOWEST,
1631   CURLCLOSEPOLICY_CALLBACK,
1632
1633   CURLCLOSEPOLICY_LAST /* last, never use this */
1634 } curl_closepolicy;
1635
1636 #define CURL_GLOBAL_SSL (1<<0)
1637 #define CURL_GLOBAL_WIN32 (1<<1)
1638 #define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)
1639 #define CURL_GLOBAL_NOTHING 0
1640 #define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL
1641
1642
1643 /*****************************************************************************
1644  * Setup defines, protos etc for the sharing stuff.
1645  */
1646
1647 /* Different data locks for a single share */
1648 typedef enum {
1649   CURL_LOCK_DATA_NONE = 0,
1650   /*  CURL_LOCK_DATA_SHARE is used internally to say that
1651    *  the locking is just made to change the internal state of the share
1652    *  itself.
1653    */
1654   CURL_LOCK_DATA_SHARE,
1655   CURL_LOCK_DATA_COOKIE,
1656   CURL_LOCK_DATA_DNS,
1657   CURL_LOCK_DATA_SSL_SESSION,
1658   CURL_LOCK_DATA_CONNECT,
1659   CURL_LOCK_DATA_LAST
1660 } curl_lock_data;
1661
1662 /* Different lock access types */
1663 typedef enum {
1664   CURL_LOCK_ACCESS_NONE = 0,   /* unspecified action */
1665   CURL_LOCK_ACCESS_SHARED = 1, /* for read perhaps */
1666   CURL_LOCK_ACCESS_SINGLE = 2, /* for write perhaps */
1667   CURL_LOCK_ACCESS_LAST        /* never use */
1668 } curl_lock_access;
1669
1670 typedef void (*curl_lock_function)(CURL *handle,
1671                                    curl_lock_data data,
1672                                    curl_lock_access locktype,
1673                                    void *userptr);
1674 typedef void (*curl_unlock_function)(CURL *handle,
1675                                      curl_lock_data data,
1676                                      void *userptr);
1677
1678 typedef void CURLSH;
1679
1680 typedef enum {
1681   CURLSHE_OK,  /* all is fine */
1682   CURLSHE_BAD_OPTION, /* 1 */
1683   CURLSHE_IN_USE,     /* 2 */
1684   CURLSHE_INVALID,    /* 3 */
1685   CURLSHE_NOMEM,      /* out of memory */
1686   CURLSHE_LAST /* never use */
1687 } CURLSHcode;
1688
1689 typedef enum {
1690   CURLSHOPT_NONE,  /* don't use */
1691   CURLSHOPT_SHARE,   /* specify a data type to share */
1692   CURLSHOPT_UNSHARE, /* specify which data type to stop sharing */
1693   CURLSHOPT_LOCKFUNC,   /* pass in a 'curl_lock_function' pointer */
1694   CURLSHOPT_UNLOCKFUNC, /* pass in a 'curl_unlock_function' pointer */
1695   CURLSHOPT_USERDATA,   /* pass in a user data pointer used in the lock/unlock
1696                            callback functions */
1697   CURLSHOPT_LAST  /* never use */
1698 } CURLSHoption;
1699
1700 CURL_EXTERN CURLSH *curl_share_init(void);
1701 CURL_EXTERN CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...);
1702 CURL_EXTERN CURLSHcode curl_share_cleanup(CURLSH *);
1703
1704 /****************************************************************************
1705  * Structures for querying information about the curl library at runtime.
1706  */
1707
1708 typedef enum {
1709   CURLVERSION_FIRST,
1710   CURLVERSION_SECOND,
1711   CURLVERSION_THIRD,
1712   CURLVERSION_FOURTH,
1713   CURLVERSION_LAST /* never actually use this */
1714 } CURLversion;
1715
1716 /* The 'CURLVERSION_NOW' is the symbolic name meant to be used by
1717    basically all programs ever that want to get version information. It is
1718    meant to be a built-in version number for what kind of struct the caller
1719    expects. If the struct ever changes, we redefine the NOW to another enum
1720    from above. */
1721 #define CURLVERSION_NOW CURLVERSION_FOURTH
1722
1723 typedef struct {
1724   CURLversion age;          /* age of the returned struct */
1725   const char *version;      /* LIBCURL_VERSION */
1726   unsigned int version_num; /* LIBCURL_VERSION_NUM */
1727   const char *host;         /* OS/host/cpu/machine when configured */
1728   int features;             /* bitmask, see defines below */
1729   const char *ssl_version;  /* human readable string */
1730   long ssl_version_num;     /* not used anymore, always 0 */
1731   const char *libz_version; /* human readable string */
1732   /* protocols is terminated by an entry with a NULL protoname */
1733   const char * const *protocols;
1734
1735   /* The fields below this were added in CURLVERSION_SECOND */
1736   const char *ares;
1737   int ares_num;
1738
1739   /* This field was added in CURLVERSION_THIRD */
1740   const char *libidn;
1741
1742   /* These field were added in CURLVERSION_FOURTH */
1743
1744   /* Same as '_libiconv_version' if built with HAVE_ICONV */
1745   int iconv_ver_num;
1746
1747   const char *libssh_version; /* human readable string */
1748
1749 } curl_version_info_data;
1750
1751 #define CURL_VERSION_IPV6      (1<<0)  /* IPv6-enabled */
1752 #define CURL_VERSION_KERBEROS4 (1<<1)  /* kerberos auth is supported */
1753 #define CURL_VERSION_SSL       (1<<2)  /* SSL options are present */
1754 #define CURL_VERSION_LIBZ      (1<<3)  /* libz features are present */
1755 #define CURL_VERSION_NTLM      (1<<4)  /* NTLM auth is supported */
1756 #define CURL_VERSION_GSSNEGOTIATE (1<<5) /* Negotiate auth support */
1757 #define CURL_VERSION_DEBUG     (1<<6)  /* built with debug capabilities */
1758 #define CURL_VERSION_ASYNCHDNS (1<<7)  /* asynchronous dns resolves */
1759 #define CURL_VERSION_SPNEGO    (1<<8)  /* SPNEGO auth */
1760 #define CURL_VERSION_LARGEFILE (1<<9)  /* supports files bigger than 2GB */
1761 #define CURL_VERSION_IDN       (1<<10) /* International Domain Names support */
1762 #define CURL_VERSION_SSPI      (1<<11) /* SSPI is supported */
1763 #define CURL_VERSION_CONV      (1<<12) /* character conversions are
1764                                           supported */
1765
1766 /*
1767  * NAME curl_version_info()
1768  *
1769  * DESCRIPTION
1770  *
1771  * This function returns a pointer to a static copy of the version info
1772  * struct. See above.
1773  */
1774 CURL_EXTERN curl_version_info_data *curl_version_info(CURLversion);
1775
1776 /*
1777  * NAME curl_easy_strerror()
1778  *
1779  * DESCRIPTION
1780  *
1781  * The curl_easy_strerror function may be used to turn a CURLcode value
1782  * into the equivalent human readable error string.  This is useful
1783  * for printing meaningful error messages.
1784  */
1785 CURL_EXTERN const char *curl_easy_strerror(CURLcode);
1786
1787 /*
1788  * NAME curl_share_strerror()
1789  *
1790  * DESCRIPTION
1791  *
1792  * The curl_share_strerror function may be used to turn a CURLSHcode value
1793  * into the equivalent human readable error string.  This is useful
1794  * for printing meaningful error messages.
1795  */
1796 CURL_EXTERN const char *curl_share_strerror(CURLSHcode);
1797
1798 /*
1799  * NAME curl_easy_pause()
1800  *
1801  * DESCRIPTION
1802  *
1803  * The curl_easy_pause function pauses or unpauses transfers. Select the new
1804  * state by setting the bitmask, use the convenience defines below.
1805  *
1806  */
1807 CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask);
1808
1809 #define CURLPAUSE_RECV      (1<<0)
1810 #define CURLPAUSE_RECV_CONT (0)
1811
1812 #define CURLPAUSE_SEND      (1<<2)
1813 #define CURLPAUSE_SEND_CONT (0)
1814
1815 #define CURLPAUSE_ALL       (CURLPAUSE_RECV|CURLPAUSE_SEND)
1816 #define CURLPAUSE_CONT      (CURLPAUSE_RECV_CONT|CURLPAUSE_SEND_CONT)
1817
1818 #ifdef  __cplusplus
1819 }
1820 #endif
1821
1822 /* unfortunately, the easy.h and multi.h include files need options and info
1823   stuff before they can be included! */
1824 #include "easy.h" /* nothing in curl is fun without the easy stuff */
1825 #include "multi.h"
1826
1827 /* the typechecker doesn't work in C++ (yet) */
1828 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && \
1829     !defined(__cplusplus) && !defined(CURL_DISABLE_TYPECHECK)
1830 #include "typecheck-gcc.h"
1831 #else
1832 #if defined(__STDC__) && (__STDC__ >= 1)
1833 /* This preprocessor magic that replaces a call with the exact same call is
1834    only done to make sure application authors pass exactly three arguments
1835    to these functions. */
1836 #define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param)
1837 #define curl_easy_getinfo(handle,info,arg) curl_easy_getinfo(handle,info,arg)
1838 #define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
1839 #define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
1840 #endif /* __STDC__ >= 1 */
1841 #endif /* gcc >= 4.3 && !__cplusplus */
1842
1843 #endif /* __CURL_CURL_H */