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