3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
26 * If you have libcurl problems, all docs and details are found here:
27 * http://curl.haxx.se/libcurl/
29 * curl-library mailing list subscription and unsubscription web interface:
30 * http://cool.haxx.se/mailman/listinfo/curl-library/
33 #include "curlver.h" /* libcurl version defines */
34 #include "curlbuild.h" /* libcurl build definitions */
35 #include "curlrules.h" /* libcurl rules enforcement */
38 * Define WIN32 when build target is Win32 API
41 #if (defined(_WIN32) || defined(__WIN32__)) && \
42 !defined(WIN32) && !defined(__SYMBIAN32__)
49 #if defined(__FreeBSD__) && (__FreeBSD__ >= 2)
50 /* Needed for __FreeBSD_version symbol definition */
51 #include <osreldate.h>
54 /* The include stuff here below is mainly for time_t! */
55 #include <sys/types.h>
58 #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) && \
59 !defined(__CYGWIN__) || defined(__MINGW32__)
60 #if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H))
61 /* The check above prevents the winsock2 inclusion if winsock.h already was
62 included, since they can't co-exist without problems */
68 /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
69 libc5-based Linux systems. Only include it on system that are known to
71 #if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
72 defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \
74 (defined(__FreeBSD_version) && (__FreeBSD_version < 800000))
75 #include <sys/select.h>
79 #include <sys/socket.h>
81 #if !defined(WIN32) && !defined(__WATCOMC__) && !defined(__VXWORKS__)
84 #include <sys/types.h>
88 #include <support/SupportDefs.h>
98 * Decorate exportable functions for Win32 and Symbian OS DLL linking.
99 * This avoids using a .def file for building libcurl.dll.
101 #if (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)) && \
102 !defined(CURL_STATICLIB)
103 #if defined(BUILDING_LIBCURL)
104 #define CURL_EXTERN __declspec(dllexport)
106 #define CURL_EXTERN __declspec(dllimport)
110 #ifdef CURL_HIDDEN_SYMBOLS
112 * This definition is used to make external definitions visible in the
113 * shared library when symbols are hidden by default. It makes no
114 * difference when compiling applications whether this is set or not,
115 * only when compiling the library.
117 #define CURL_EXTERN CURL_EXTERN_SYMBOL
123 #ifndef curl_socket_typedef
126 typedef SOCKET curl_socket_t;
127 #define CURL_SOCKET_BAD INVALID_SOCKET
129 typedef int curl_socket_t;
130 #define CURL_SOCKET_BAD -1
132 #define curl_socket_typedef
133 #endif /* curl_socket_typedef */
135 struct curl_httppost {
136 struct curl_httppost *next; /* next entry in the list */
137 char *name; /* pointer to allocated name */
138 long namelength; /* length of name length */
139 char *contents; /* pointer to allocated data contents */
140 long contentslength; /* length of contents field */
141 char *buffer; /* pointer to allocated buffer contents */
142 long bufferlength; /* length of buffer field */
143 char *contenttype; /* Content-Type */
144 struct curl_slist* contentheader; /* list of extra headers for this form */
145 struct curl_httppost *more; /* if one field name has more than one
146 file, this link should link to following
148 long flags; /* as defined below */
149 #define HTTPPOST_FILENAME (1<<0) /* specified content is a file name */
150 #define HTTPPOST_READFILE (1<<1) /* specified content is a file name */
151 #define HTTPPOST_PTRNAME (1<<2) /* name is only stored pointer
152 do not free in formfree */
153 #define HTTPPOST_PTRCONTENTS (1<<3) /* contents is only stored pointer
154 do not free in formfree */
155 #define HTTPPOST_BUFFER (1<<4) /* upload file from buffer */
156 #define HTTPPOST_PTRBUFFER (1<<5) /* upload file from pointer contents */
157 #define HTTPPOST_CALLBACK (1<<6) /* upload file contents by using the
158 regular read callback to get the data
159 and pass the given pointer as custom
162 char *showfilename; /* The file name to show. If not set, the
163 actual file name will be used (if this
165 void *userp; /* custom pointer used for
166 HTTPPOST_CALLBACK posts */
169 typedef int (*curl_progress_callback)(void *clientp,
175 #ifndef CURL_MAX_WRITE_SIZE
176 /* Tests have proven that 20K is a very bad buffer size for uploads on
177 Windows, while 16K for some odd reason performed a lot better.
178 We do the ifndef check to allow this value to easier be changed at build
179 time for those who feel adventurous. The practical minimum is about
180 400 bytes since libcurl uses a buffer of this size as a scratch area
181 (unrelated to network send operations). */
182 #define CURL_MAX_WRITE_SIZE 16384
185 #ifndef CURL_MAX_HTTP_HEADER
186 /* The only reason to have a max limit for this is to avoid the risk of a bad
187 server feeding libcurl with a never-ending header that will cause reallocs
189 #define CURL_MAX_HTTP_HEADER (100*1024)
193 /* This is a magic return code for the write callback that, when returned,
194 will signal libcurl to pause receiving on the current transfer. */
195 #define CURL_WRITEFUNC_PAUSE 0x10000001
196 typedef size_t (*curl_write_callback)(char *buffer,
203 /* enumeration of file types */
205 CURLFILETYPE_FILE = 0,
206 CURLFILETYPE_DIRECTORY,
207 CURLFILETYPE_SYMLINK,
208 CURLFILETYPE_DEVICE_BLOCK,
209 CURLFILETYPE_DEVICE_CHAR,
210 CURLFILETYPE_NAMEDPIPE,
212 CURLFILETYPE_DOOR, /* is possible only on Sun Solaris now */
214 CURLFILETYPE_UNKNOWN /* should never occur */
217 #define CURLFINFOFLAG_KNOWN_FILENAME (1<<0)
218 #define CURLFINFOFLAG_KNOWN_FILETYPE (1<<1)
219 #define CURLFINFOFLAG_KNOWN_TIME (1<<2)
220 #define CURLFINFOFLAG_KNOWN_PERM (1<<3)
221 #define CURLFINFOFLAG_KNOWN_UID (1<<4)
222 #define CURLFINFOFLAG_KNOWN_GID (1<<5)
223 #define CURLFINFOFLAG_KNOWN_SIZE (1<<6)
224 #define CURLFINFOFLAG_KNOWN_HLINKCOUNT (1<<7)
226 /* Content of this structure depends on information which is known and is
227 achievable (e.g. by FTP LIST parsing). Please see the url_easy_setopt(3) man
228 page for callbacks returning this structure -- some fields are mandatory,
229 some others are optional. The FLAG field has special meaning. */
230 struct curl_fileinfo {
232 curlfiletype filetype;
241 /* If some of these fields is not NULL, it is a pointer to b_data. */
246 char *target; /* pointer to the target filename of a symlink */
251 /* used internally */
257 /* return codes for CURLOPT_CHUNK_BGN_FUNCTION */
258 #define CURL_CHUNK_BGN_FUNC_OK 0
259 #define CURL_CHUNK_BGN_FUNC_FAIL 1 /* tell the lib to end the task */
260 #define CURL_CHUNK_BGN_FUNC_SKIP 2 /* skip this chunk over */
262 /* if splitting of data transfer is enabled, this callback is called before
263 download of an individual chunk started. Note that parameter "remains" works
264 only for FTP wildcard downloading (for now), otherwise is not used */
265 typedef long (*curl_chunk_bgn_callback)(const void *transfer_info,
269 /* return codes for CURLOPT_CHUNK_END_FUNCTION */
270 #define CURL_CHUNK_END_FUNC_OK 0
271 #define CURL_CHUNK_END_FUNC_FAIL 1 /* tell the lib to end the task */
273 /* If splitting of data transfer is enabled this callback is called after
274 download of an individual chunk finished.
275 Note! After this callback was set then it have to be called FOR ALL chunks.
276 Even if downloading of this chunk was skipped in CHUNK_BGN_FUNC.
277 This is the reason why we don't need "transfer_info" parameter in this
278 callback and we are not interested in "remains" parameter too. */
279 typedef long (*curl_chunk_end_callback)(void *ptr);
281 /* return codes for FNMATCHFUNCTION */
282 #define CURL_FNMATCHFUNC_MATCH 0 /* string corresponds to the pattern */
283 #define CURL_FNMATCHFUNC_NOMATCH 1 /* pattern doesn't match the string */
284 #define CURL_FNMATCHFUNC_FAIL 2 /* an error occurred */
286 /* callback type for wildcard downloading pattern matching. If the
287 string matches the pattern, return CURL_FNMATCHFUNC_MATCH value, etc. */
288 typedef int (*curl_fnmatch_callback)(void *ptr,
292 /* These are the return codes for the seek callbacks */
293 #define CURL_SEEKFUNC_OK 0
294 #define CURL_SEEKFUNC_FAIL 1 /* fail the entire transfer */
295 #define CURL_SEEKFUNC_CANTSEEK 2 /* tell libcurl seeking can't be done, so
296 libcurl might try other means instead */
297 typedef int (*curl_seek_callback)(void *instream,
299 int origin); /* 'whence' */
301 /* This is a return code for the read callback that, when returned, will
302 signal libcurl to immediately abort the current transfer. */
303 #define CURL_READFUNC_ABORT 0x10000000
304 /* This is a return code for the read callback that, when returned, will
305 signal libcurl to pause sending data on the current transfer. */
306 #define CURL_READFUNC_PAUSE 0x10000001
308 typedef size_t (*curl_read_callback)(char *buffer,
314 CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */
315 CURLSOCKTYPE_LAST /* never use */
318 /* The return code from the sockopt_callback can signal information back
320 #define CURL_SOCKOPT_OK 0
321 #define CURL_SOCKOPT_ERROR 1 /* causes libcurl to abort and return
322 CURLE_ABORTED_BY_CALLBACK */
323 #define CURL_SOCKOPT_ALREADY_CONNECTED 2
325 typedef int (*curl_sockopt_callback)(void *clientp,
326 curl_socket_t curlfd,
327 curlsocktype purpose);
329 struct curl_sockaddr {
333 unsigned int addrlen; /* addrlen was a socklen_t type before 7.18.0 but it
334 turned really ugly and painful on the systems that
336 struct sockaddr addr;
339 typedef curl_socket_t
340 (*curl_opensocket_callback)(void *clientp,
341 curlsocktype purpose,
342 struct curl_sockaddr *address);
345 CURLIOE_OK, /* I/O operation successful */
346 CURLIOE_UNKNOWNCMD, /* command was unknown to callback */
347 CURLIOE_FAILRESTART, /* failed to restart the read */
348 CURLIOE_LAST /* never use */
352 CURLIOCMD_NOP, /* no operation */
353 CURLIOCMD_RESTARTREAD, /* restart the read stream from start */
354 CURLIOCMD_LAST /* never use */
357 typedef curlioerr (*curl_ioctl_callback)(CURL *handle,
362 * The following typedef's are signatures of malloc, free, realloc, strdup and
363 * calloc respectively. Function pointers of these types can be passed to the
364 * curl_global_init_mem() function to set user defined memory management
367 typedef void *(*curl_malloc_callback)(size_t size);
368 typedef void (*curl_free_callback)(void *ptr);
369 typedef void *(*curl_realloc_callback)(void *ptr, size_t size);
370 typedef char *(*curl_strdup_callback)(const char *str);
371 typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size);
373 /* the kind of data that is passed to information_callback*/
376 CURLINFO_HEADER_IN, /* 1 */
377 CURLINFO_HEADER_OUT, /* 2 */
378 CURLINFO_DATA_IN, /* 3 */
379 CURLINFO_DATA_OUT, /* 4 */
380 CURLINFO_SSL_DATA_IN, /* 5 */
381 CURLINFO_SSL_DATA_OUT, /* 6 */
385 typedef int (*curl_debug_callback)
386 (CURL *handle, /* the handle/transfer this concerns */
387 curl_infotype type, /* what kind of data */
388 char *data, /* points to the data */
389 size_t size, /* size of the data pointed to */
390 void *userptr); /* whatever the user please */
392 /* All possible error codes from all sorts of curl functions. Future versions
393 may return other values, stay prepared.
395 Always add new return codes last. Never *EVER* remove any. The return
396 codes must remain the same!
401 CURLE_UNSUPPORTED_PROTOCOL, /* 1 */
402 CURLE_FAILED_INIT, /* 2 */
403 CURLE_URL_MALFORMAT, /* 3 */
404 CURLE_NOT_BUILT_IN, /* 4 - [was obsoleted in August 2007 for
405 7.17.0, reused in April 2011 for 7.21.5] */
406 CURLE_COULDNT_RESOLVE_PROXY, /* 5 */
407 CURLE_COULDNT_RESOLVE_HOST, /* 6 */
408 CURLE_COULDNT_CONNECT, /* 7 */
409 CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */
410 CURLE_REMOTE_ACCESS_DENIED, /* 9 a service was denied by the server
411 due to lack of access - when login fails
412 this is not returned. */
413 CURLE_OBSOLETE10, /* 10 - NOT USED */
414 CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */
415 CURLE_OBSOLETE12, /* 12 - NOT USED */
416 CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */
417 CURLE_FTP_WEIRD_227_FORMAT, /* 14 */
418 CURLE_FTP_CANT_GET_HOST, /* 15 */
419 CURLE_OBSOLETE16, /* 16 - NOT USED */
420 CURLE_FTP_COULDNT_SET_TYPE, /* 17 */
421 CURLE_PARTIAL_FILE, /* 18 */
422 CURLE_FTP_COULDNT_RETR_FILE, /* 19 */
423 CURLE_OBSOLETE20, /* 20 - NOT USED */
424 CURLE_QUOTE_ERROR, /* 21 - quote command failure */
425 CURLE_HTTP_RETURNED_ERROR, /* 22 */
426 CURLE_WRITE_ERROR, /* 23 */
427 CURLE_OBSOLETE24, /* 24 - NOT USED */
428 CURLE_UPLOAD_FAILED, /* 25 - failed upload "command" */
429 CURLE_READ_ERROR, /* 26 - couldn't open/read from file */
430 CURLE_OUT_OF_MEMORY, /* 27 */
431 /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error
432 instead of a memory allocation error if CURL_DOES_CONVERSIONS
435 CURLE_OPERATION_TIMEDOUT, /* 28 - the timeout time was reached */
436 CURLE_OBSOLETE29, /* 29 - NOT USED */
437 CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */
438 CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */
439 CURLE_OBSOLETE32, /* 32 - NOT USED */
440 CURLE_RANGE_ERROR, /* 33 - RANGE "command" didn't work */
441 CURLE_HTTP_POST_ERROR, /* 34 */
442 CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */
443 CURLE_BAD_DOWNLOAD_RESUME, /* 36 - couldn't resume download */
444 CURLE_FILE_COULDNT_READ_FILE, /* 37 */
445 CURLE_LDAP_CANNOT_BIND, /* 38 */
446 CURLE_LDAP_SEARCH_FAILED, /* 39 */
447 CURLE_OBSOLETE40, /* 40 - NOT USED */
448 CURLE_FUNCTION_NOT_FOUND, /* 41 */
449 CURLE_ABORTED_BY_CALLBACK, /* 42 */
450 CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */
451 CURLE_OBSOLETE44, /* 44 - NOT USED */
452 CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */
453 CURLE_OBSOLETE46, /* 46 - NOT USED */
454 CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */
455 CURLE_UNKNOWN_OPTION, /* 48 - User specified an unknown option */
456 CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */
457 CURLE_OBSOLETE50, /* 50 - NOT USED */
458 CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint
459 wasn't verified fine */
460 CURLE_GOT_NOTHING, /* 52 - when this is a specific error */
461 CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */
462 CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as
464 CURLE_SEND_ERROR, /* 55 - failed sending network data */
465 CURLE_RECV_ERROR, /* 56 - failure in receiving network data */
466 CURLE_OBSOLETE57, /* 57 - NOT IN USE */
467 CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */
468 CURLE_SSL_CIPHER, /* 59 - couldn't use specified cipher */
469 CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */
470 CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized transfer encoding */
471 CURLE_LDAP_INVALID_URL, /* 62 - Invalid LDAP URL */
472 CURLE_FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */
473 CURLE_USE_SSL_FAILED, /* 64 - Requested FTP SSL level failed */
474 CURLE_SEND_FAIL_REWIND, /* 65 - Sending the data requires a rewind
476 CURLE_SSL_ENGINE_INITFAILED, /* 66 - failed to initialise ENGINE */
477 CURLE_LOGIN_DENIED, /* 67 - user, password or similar was not
478 accepted and we failed to login */
479 CURLE_TFTP_NOTFOUND, /* 68 - file not found on server */
480 CURLE_TFTP_PERM, /* 69 - permission problem on server */
481 CURLE_REMOTE_DISK_FULL, /* 70 - out of disk space on server */
482 CURLE_TFTP_ILLEGAL, /* 71 - Illegal TFTP operation */
483 CURLE_TFTP_UNKNOWNID, /* 72 - Unknown transfer ID */
484 CURLE_REMOTE_FILE_EXISTS, /* 73 - File already exists */
485 CURLE_TFTP_NOSUCHUSER, /* 74 - No such user */
486 CURLE_CONV_FAILED, /* 75 - conversion failed */
487 CURLE_CONV_REQD, /* 76 - caller must register conversion
488 callbacks using curl_easy_setopt options
489 CURLOPT_CONV_FROM_NETWORK_FUNCTION,
490 CURLOPT_CONV_TO_NETWORK_FUNCTION, and
491 CURLOPT_CONV_FROM_UTF8_FUNCTION */
492 CURLE_SSL_CACERT_BADFILE, /* 77 - could not load CACERT file, missing
494 CURLE_REMOTE_FILE_NOT_FOUND, /* 78 - remote file not found */
495 CURLE_SSH, /* 79 - error from the SSH layer, somewhat
496 generic so the error message will be of
497 interest when this has happened */
499 CURLE_SSL_SHUTDOWN_FAILED, /* 80 - Failed to shut down the SSL
501 CURLE_AGAIN, /* 81 - socket is not ready for send/recv,
502 wait till it's ready and try again (Added
504 CURLE_SSL_CRL_BADFILE, /* 82 - could not load CRL file, missing or
505 wrong format (Added in 7.19.0) */
506 CURLE_SSL_ISSUER_ERROR, /* 83 - Issuer check failed. (Added in
508 CURLE_FTP_PRET_FAILED, /* 84 - a PRET command failed */
509 CURLE_RTSP_CSEQ_ERROR, /* 85 - mismatch of RTSP CSeq numbers */
510 CURLE_RTSP_SESSION_ERROR, /* 86 - mismatch of RTSP Session Identifiers */
511 CURLE_FTP_BAD_FILE_LIST, /* 87 - unable to parse FTP file list */
512 CURLE_CHUNK_FAILED, /* 88 - chunk callback reported error */
514 CURL_LAST /* never use! */
517 #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
518 the obsolete stuff removed! */
520 /* Backwards compatibility with older names */
522 /* The following were added in 7.21.5, April 2011 */
523 #define CURLE_UNKNOWN_TELNET_OPTION CURLE_UNKNOWN_OPTION
525 /* The following were added in 7.17.1 */
526 /* These are scheduled to disappear by 2009 */
527 #define CURLE_SSL_PEER_CERTIFICATE CURLE_PEER_FAILED_VERIFICATION
529 /* The following were added in 7.17.0 */
530 /* These are scheduled to disappear by 2009 */
531 #define CURLE_OBSOLETE CURLE_OBSOLETE50 /* noone should be using this! */
532 #define CURLE_BAD_PASSWORD_ENTERED CURLE_OBSOLETE46
533 #define CURLE_BAD_CALLING_ORDER CURLE_OBSOLETE44
534 #define CURLE_FTP_USER_PASSWORD_INCORRECT CURLE_OBSOLETE10
535 #define CURLE_FTP_CANT_RECONNECT CURLE_OBSOLETE16
536 #define CURLE_FTP_COULDNT_GET_SIZE CURLE_OBSOLETE32
537 #define CURLE_FTP_COULDNT_SET_ASCII CURLE_OBSOLETE29
538 #define CURLE_FTP_WEIRD_USER_REPLY CURLE_OBSOLETE12
539 #define CURLE_FTP_WRITE_ERROR CURLE_OBSOLETE20
540 #define CURLE_LIBRARY_NOT_FOUND CURLE_OBSOLETE40
541 #define CURLE_MALFORMAT_USER CURLE_OBSOLETE24
542 #define CURLE_SHARE_IN_USE CURLE_OBSOLETE57
543 #define CURLE_URL_MALFORMAT_USER CURLE_OBSOLETE4
545 #define CURLE_FTP_ACCESS_DENIED CURLE_REMOTE_ACCESS_DENIED
546 #define CURLE_FTP_COULDNT_SET_BINARY CURLE_FTP_COULDNT_SET_TYPE
547 #define CURLE_FTP_QUOTE_ERROR CURLE_QUOTE_ERROR
548 #define CURLE_TFTP_DISKFULL CURLE_REMOTE_DISK_FULL
549 #define CURLE_TFTP_EXISTS CURLE_REMOTE_FILE_EXISTS
550 #define CURLE_HTTP_RANGE_ERROR CURLE_RANGE_ERROR
551 #define CURLE_FTP_SSL_FAILED CURLE_USE_SSL_FAILED
553 /* The following were added earlier */
555 #define CURLE_OPERATION_TIMEOUTED CURLE_OPERATION_TIMEDOUT
557 #define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR
558 #define CURLE_HTTP_PORT_FAILED CURLE_INTERFACE_FAILED
559 #define CURLE_FTP_COULDNT_STOR_FILE CURLE_UPLOAD_FAILED
561 #define CURLE_FTP_PARTIAL_FILE CURLE_PARTIAL_FILE
562 #define CURLE_FTP_BAD_DOWNLOAD_RESUME CURLE_BAD_DOWNLOAD_RESUME
564 /* This was the error code 50 in 7.7.3 and a few earlier versions, this
565 is no longer used by libcurl but is instead #defined here only to not
566 make programs break */
567 #define CURLE_ALREADY_COMPLETE 99999
569 #endif /*!CURL_NO_OLDIES*/
571 /* This prototype applies to all conversion callbacks */
572 typedef CURLcode (*curl_conv_callback)(char *buffer, size_t length);
574 typedef CURLcode (*curl_ssl_ctx_callback)(CURL *curl, /* easy handle */
575 void *ssl_ctx, /* actually an
580 CURLPROXY_HTTP = 0, /* added in 7.10, new in 7.19.4 default is to use
582 CURLPROXY_HTTP_1_0 = 1, /* added in 7.19.4, force to use CONNECT
584 CURLPROXY_SOCKS4 = 4, /* support added in 7.15.2, enum existed already
586 CURLPROXY_SOCKS5 = 5, /* added in 7.10 */
587 CURLPROXY_SOCKS4A = 6, /* added in 7.18.0 */
588 CURLPROXY_SOCKS5_HOSTNAME = 7 /* Use the SOCKS5 protocol but pass along the
589 host name rather than the IP address. added
591 } curl_proxytype; /* this enum was added in 7.10 */
593 #define CURLAUTH_NONE 0 /* nothing */
594 #define CURLAUTH_BASIC (1<<0) /* Basic (default) */
595 #define CURLAUTH_DIGEST (1<<1) /* Digest */
596 #define CURLAUTH_GSSNEGOTIATE (1<<2) /* GSS-Negotiate */
597 #define CURLAUTH_NTLM (1<<3) /* NTLM */
598 #define CURLAUTH_DIGEST_IE (1<<4) /* Digest with IE flavour */
599 #define CURLAUTH_ONLY (1<<31) /* used together with a single other
600 type to force no auth or just that
602 #define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE) /* all fine types set */
603 #define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC|CURLAUTH_DIGEST_IE))
605 #define CURLSSH_AUTH_ANY ~0 /* all types supported by the server */
606 #define CURLSSH_AUTH_NONE 0 /* none allowed, silly but complete */
607 #define CURLSSH_AUTH_PUBLICKEY (1<<0) /* public/private key files */
608 #define CURLSSH_AUTH_PASSWORD (1<<1) /* password */
609 #define CURLSSH_AUTH_HOST (1<<2) /* host key files */
610 #define CURLSSH_AUTH_KEYBOARD (1<<3) /* keyboard interactive */
611 #define CURLSSH_AUTH_DEFAULT CURLSSH_AUTH_ANY
613 #define CURL_ERROR_SIZE 256
616 const char *key; /* points to a zero-terminated string encoded with base64
617 if len is zero, otherwise to the "raw" data */
627 /* this is the set of return values expected from the curl_sshkeycallback
630 CURLKHSTAT_FINE_ADD_TO_FILE,
632 CURLKHSTAT_REJECT, /* reject the connection, return an error */
633 CURLKHSTAT_DEFER, /* do not accept it, but we can't answer right now so
634 this causes a CURLE_DEFER error but otherwise the
635 connection will be left intact etc */
636 CURLKHSTAT_LAST /* not for use, only a marker for last-in-list */
639 /* this is the set of status codes pass in to the callback */
641 CURLKHMATCH_OK, /* match */
642 CURLKHMATCH_MISMATCH, /* host found, key mismatch! */
643 CURLKHMATCH_MISSING, /* no matching host/key found */
644 CURLKHMATCH_LAST /* not for use, only a marker for last-in-list */
648 (*curl_sshkeycallback) (CURL *easy, /* easy handle */
649 const struct curl_khkey *knownkey, /* known */
650 const struct curl_khkey *foundkey, /* found */
651 enum curl_khmatch, /* libcurl's view on the keys */
652 void *clientp); /* custom pointer passed from app */
654 /* parameter for the CURLOPT_USE_SSL option */
656 CURLUSESSL_NONE, /* do not attempt to use SSL */
657 CURLUSESSL_TRY, /* try using SSL, proceed anyway otherwise */
658 CURLUSESSL_CONTROL, /* SSL for the control connection or fail */
659 CURLUSESSL_ALL, /* SSL for all communication or fail */
660 CURLUSESSL_LAST /* not an option, never use */
663 #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
664 the obsolete stuff removed! */
666 /* Backwards compatibility with older names */
667 /* These are scheduled to disappear by 2009 */
669 #define CURLFTPSSL_NONE CURLUSESSL_NONE
670 #define CURLFTPSSL_TRY CURLUSESSL_TRY
671 #define CURLFTPSSL_CONTROL CURLUSESSL_CONTROL
672 #define CURLFTPSSL_ALL CURLUSESSL_ALL
673 #define CURLFTPSSL_LAST CURLUSESSL_LAST
674 #define curl_ftpssl curl_usessl
675 #endif /*!CURL_NO_OLDIES*/
677 /* parameter for the CURLOPT_FTP_SSL_CCC option */
679 CURLFTPSSL_CCC_NONE, /* do not send CCC */
680 CURLFTPSSL_CCC_PASSIVE, /* Let the server initiate the shutdown */
681 CURLFTPSSL_CCC_ACTIVE, /* Initiate the shutdown */
682 CURLFTPSSL_CCC_LAST /* not an option, never use */
685 /* parameter for the CURLOPT_FTPSSLAUTH option */
687 CURLFTPAUTH_DEFAULT, /* let libcurl decide */
688 CURLFTPAUTH_SSL, /* use "AUTH SSL" */
689 CURLFTPAUTH_TLS, /* use "AUTH TLS" */
690 CURLFTPAUTH_LAST /* not an option, never use */
693 /* parameter for the CURLOPT_FTP_CREATE_MISSING_DIRS option */
695 CURLFTP_CREATE_DIR_NONE, /* do NOT create missing dirs! */
696 CURLFTP_CREATE_DIR, /* (FTP/SFTP) if CWD fails, try MKD and then CWD
697 again if MKD succeeded, for SFTP this does
699 CURLFTP_CREATE_DIR_RETRY, /* (FTP only) if CWD fails, try MKD and then CWD
700 again even if MKD failed! */
701 CURLFTP_CREATE_DIR_LAST /* not an option, never use */
704 /* parameter for the CURLOPT_FTP_FILEMETHOD option */
706 CURLFTPMETHOD_DEFAULT, /* let libcurl pick */
707 CURLFTPMETHOD_MULTICWD, /* single CWD operation for each path part */
708 CURLFTPMETHOD_NOCWD, /* no CWD at all */
709 CURLFTPMETHOD_SINGLECWD, /* one CWD to full dir, then work on file */
710 CURLFTPMETHOD_LAST /* not an option, never use */
713 /* CURLPROTO_ defines are for the CURLOPT_*PROTOCOLS options */
714 #define CURLPROTO_HTTP (1<<0)
715 #define CURLPROTO_HTTPS (1<<1)
716 #define CURLPROTO_FTP (1<<2)
717 #define CURLPROTO_FTPS (1<<3)
718 #define CURLPROTO_SCP (1<<4)
719 #define CURLPROTO_SFTP (1<<5)
720 #define CURLPROTO_TELNET (1<<6)
721 #define CURLPROTO_LDAP (1<<7)
722 #define CURLPROTO_LDAPS (1<<8)
723 #define CURLPROTO_DICT (1<<9)
724 #define CURLPROTO_FILE (1<<10)
725 #define CURLPROTO_TFTP (1<<11)
726 #define CURLPROTO_IMAP (1<<12)
727 #define CURLPROTO_IMAPS (1<<13)
728 #define CURLPROTO_POP3 (1<<14)
729 #define CURLPROTO_POP3S (1<<15)
730 #define CURLPROTO_SMTP (1<<16)
731 #define CURLPROTO_SMTPS (1<<17)
732 #define CURLPROTO_RTSP (1<<18)
733 #define CURLPROTO_RTMP (1<<19)
734 #define CURLPROTO_RTMPT (1<<20)
735 #define CURLPROTO_RTMPE (1<<21)
736 #define CURLPROTO_RTMPTE (1<<22)
737 #define CURLPROTO_RTMPS (1<<23)
738 #define CURLPROTO_RTMPTS (1<<24)
739 #define CURLPROTO_GOPHER (1<<25)
740 #define CURLPROTO_ALL (~0) /* enable everything */
742 /* long may be 32 or 64 bits, but we should never depend on anything else
744 #define CURLOPTTYPE_LONG 0
745 #define CURLOPTTYPE_OBJECTPOINT 10000
746 #define CURLOPTTYPE_FUNCTIONPOINT 20000
747 #define CURLOPTTYPE_OFF_T 30000
749 /* name is uppercase CURLOPT_<name>,
750 type is one of the defined CURLOPTTYPE_<type>
751 number is unique identifier */
757 #define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number
759 /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
760 #define LONG CURLOPTTYPE_LONG
761 #define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
762 #define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
763 #define OFF_T CURLOPTTYPE_OFF_T
764 #define CINIT(name,type,number) CURLOPT_/**/name = type + number
768 * This macro-mania below setups the CURLOPT_[what] enum, to be used with
769 * curl_easy_setopt(). The first argument in the CINIT() macro is the [what]
774 /* This is the FILE * or void * the regular output should be written to. */
775 CINIT(FILE, OBJECTPOINT, 1),
777 /* The full URL to get/put */
778 CINIT(URL, OBJECTPOINT, 2),
780 /* Port number to connect to, if other than default. */
781 CINIT(PORT, LONG, 3),
783 /* Name of proxy to use. */
784 CINIT(PROXY, OBJECTPOINT, 4),
786 /* "name:password" to use when fetching. */
787 CINIT(USERPWD, OBJECTPOINT, 5),
789 /* "name:password" to use with proxy. */
790 CINIT(PROXYUSERPWD, OBJECTPOINT, 6),
792 /* Range to get, specified as an ASCII string. */
793 CINIT(RANGE, OBJECTPOINT, 7),
797 /* Specified file stream to upload from (use as input): */
798 CINIT(INFILE, OBJECTPOINT, 9),
800 /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE
801 * bytes big. If this is not used, error messages go to stderr instead: */
802 CINIT(ERRORBUFFER, OBJECTPOINT, 10),
804 /* Function that will be called to store the output (instead of fwrite). The
805 * parameters will use fwrite() syntax, make sure to follow them. */
806 CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11),
808 /* Function that will be called to read the input (instead of fread). The
809 * parameters will use fread() syntax, make sure to follow them. */
810 CINIT(READFUNCTION, FUNCTIONPOINT, 12),
812 /* Time-out the read operation after this amount of seconds */
813 CINIT(TIMEOUT, LONG, 13),
815 /* If the CURLOPT_INFILE is used, this can be used to inform libcurl about
816 * how large the file being sent really is. That allows better error
817 * checking and better verifies that the upload was successful. -1 means
820 * For large file support, there is also a _LARGE version of the key
821 * which takes an off_t type, allowing platforms with larger off_t
822 * sizes to handle larger files. See below for INFILESIZE_LARGE.
824 CINIT(INFILESIZE, LONG, 14),
826 /* POST static input fields. */
827 CINIT(POSTFIELDS, OBJECTPOINT, 15),
829 /* Set the referrer page (needed by some CGIs) */
830 CINIT(REFERER, OBJECTPOINT, 16),
832 /* Set the FTP PORT string (interface name, named or numerical IP address)
833 Use i.e '-' to use default address. */
834 CINIT(FTPPORT, OBJECTPOINT, 17),
836 /* Set the User-Agent string (examined by some CGIs) */
837 CINIT(USERAGENT, OBJECTPOINT, 18),
839 /* If the download receives less than "low speed limit" bytes/second
840 * during "low speed time" seconds, the operations is aborted.
841 * You could i.e if you have a pretty high speed connection, abort if
842 * it is less than 2000 bytes/sec during 20 seconds.
845 /* Set the "low speed limit" */
846 CINIT(LOW_SPEED_LIMIT, LONG, 19),
848 /* Set the "low speed time" */
849 CINIT(LOW_SPEED_TIME, LONG, 20),
851 /* Set the continuation offset.
853 * Note there is also a _LARGE version of this key which uses
854 * off_t types, allowing for large file offsets on platforms which
855 * use larger-than-32-bit off_t's. Look below for RESUME_FROM_LARGE.
857 CINIT(RESUME_FROM, LONG, 21),
859 /* Set cookie in request: */
860 CINIT(COOKIE, OBJECTPOINT, 22),
862 /* This points to a linked list of headers, struct curl_slist kind */
863 CINIT(HTTPHEADER, OBJECTPOINT, 23),
865 /* This points to a linked list of post entries, struct curl_httppost */
866 CINIT(HTTPPOST, OBJECTPOINT, 24),
868 /* name of the file keeping your private SSL-certificate */
869 CINIT(SSLCERT, OBJECTPOINT, 25),
871 /* password for the SSL or SSH private key */
872 CINIT(KEYPASSWD, OBJECTPOINT, 26),
874 /* send TYPE parameter? */
875 CINIT(CRLF, LONG, 27),
877 /* send linked-list of QUOTE commands */
878 CINIT(QUOTE, OBJECTPOINT, 28),
880 /* send FILE * or void * to store headers to, if you use a callback it
881 is simply passed to the callback unmodified */
882 CINIT(WRITEHEADER, OBJECTPOINT, 29),
884 /* point to a file to read the initial cookies from, also enables
885 "cookie awareness" */
886 CINIT(COOKIEFILE, OBJECTPOINT, 31),
888 /* What version to specifically try to use.
889 See CURL_SSLVERSION defines below. */
890 CINIT(SSLVERSION, LONG, 32),
892 /* What kind of HTTP time condition to use, see defines */
893 CINIT(TIMECONDITION, LONG, 33),
895 /* Time to use with the above condition. Specified in number of seconds
897 CINIT(TIMEVALUE, LONG, 34),
901 /* Custom request, for customizing the get command like
902 HTTP: DELETE, TRACE and others
903 FTP: to use a different list command
905 CINIT(CUSTOMREQUEST, OBJECTPOINT, 36),
907 /* HTTP request, for odd commands like DELETE, TRACE and others */
908 CINIT(STDERR, OBJECTPOINT, 37),
912 /* send linked-list of post-transfer QUOTE commands */
913 CINIT(POSTQUOTE, OBJECTPOINT, 39),
915 /* Pass a pointer to string of the output using full variable-replacement
916 as described elsewhere. */
917 CINIT(WRITEINFO, OBJECTPOINT, 40),
919 CINIT(VERBOSE, LONG, 41), /* talk a lot */
920 CINIT(HEADER, LONG, 42), /* throw the header out too */
921 CINIT(NOPROGRESS, LONG, 43), /* shut off the progress meter */
922 CINIT(NOBODY, LONG, 44), /* use HEAD to get http document */
923 CINIT(FAILONERROR, LONG, 45), /* no output on http error codes >= 300 */
924 CINIT(UPLOAD, LONG, 46), /* this is an upload */
925 CINIT(POST, LONG, 47), /* HTTP POST method */
926 CINIT(DIRLISTONLY, LONG, 48), /* return bare names when listing directories */
928 CINIT(APPEND, LONG, 50), /* Append instead of overwrite on upload! */
930 /* Specify whether to read the user+password from the .netrc or the URL.
931 * This must be one of the CURL_NETRC_* enums below. */
932 CINIT(NETRC, LONG, 51),
934 CINIT(FOLLOWLOCATION, LONG, 52), /* use Location: Luke! */
936 CINIT(TRANSFERTEXT, LONG, 53), /* transfer data in text/ASCII format */
937 CINIT(PUT, LONG, 54), /* HTTP PUT */
941 /* Function that will be called instead of the internal progress display
942 * function. This function should be defined as the curl_progress_callback
943 * prototype defines. */
944 CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56),
946 /* Data passed to the progress callback */
947 CINIT(PROGRESSDATA, OBJECTPOINT, 57),
949 /* We want the referrer field set automatically when following locations */
950 CINIT(AUTOREFERER, LONG, 58),
952 /* Port of the proxy, can be set in the proxy string as well with:
954 CINIT(PROXYPORT, LONG, 59),
956 /* size of the POST input data, if strlen() is not good to use */
957 CINIT(POSTFIELDSIZE, LONG, 60),
959 /* tunnel non-http operations through a HTTP proxy */
960 CINIT(HTTPPROXYTUNNEL, LONG, 61),
962 /* Set the interface string to use as outgoing network interface */
963 CINIT(INTERFACE, OBJECTPOINT, 62),
965 /* Set the krb4/5 security level, this also enables krb4/5 awareness. This
966 * is a string, 'clear', 'safe', 'confidential' or 'private'. If the string
967 * is set but doesn't match one of these, 'private' will be used. */
968 CINIT(KRBLEVEL, OBJECTPOINT, 63),
970 /* Set if we should verify the peer in ssl handshake, set 1 to verify. */
971 CINIT(SSL_VERIFYPEER, LONG, 64),
973 /* The CApath or CAfile used to validate the peer certificate
974 this option is used only if SSL_VERIFYPEER is true */
975 CINIT(CAINFO, OBJECTPOINT, 65),
980 /* Maximum number of http redirects to follow */
981 CINIT(MAXREDIRS, LONG, 68),
983 /* Pass a long set to 1 to get the date of the requested document (if
984 possible)! Pass a zero to shut it off. */
985 CINIT(FILETIME, LONG, 69),
987 /* This points to a linked list of telnet options */
988 CINIT(TELNETOPTIONS, OBJECTPOINT, 70),
990 /* Max amount of cached alive connections */
991 CINIT(MAXCONNECTS, LONG, 71),
993 /* What policy to use when closing connections when the cache is filled
995 CINIT(CLOSEPOLICY, LONG, 72),
999 /* Set to explicitly use a new connection for the upcoming transfer.
1000 Do not use this unless you're absolutely sure of this, as it makes the
1001 operation slower and is less friendly for the network. */
1002 CINIT(FRESH_CONNECT, LONG, 74),
1004 /* Set to explicitly forbid the upcoming transfer's connection to be re-used
1005 when done. Do not use this unless you're absolutely sure of this, as it
1006 makes the operation slower and is less friendly for the network. */
1007 CINIT(FORBID_REUSE, LONG, 75),
1009 /* Set to a file name that contains random data for libcurl to use to
1010 seed the random engine when doing SSL connects. */
1011 CINIT(RANDOM_FILE, OBJECTPOINT, 76),
1013 /* Set to the Entropy Gathering Daemon socket pathname */
1014 CINIT(EGDSOCKET, OBJECTPOINT, 77),
1016 /* Time-out connect operations after this amount of seconds, if connects
1017 are OK within this time, then fine... This only aborts the connect
1018 phase. [Only works on unix-style/SIGALRM operating systems] */
1019 CINIT(CONNECTTIMEOUT, LONG, 78),
1021 /* Function that will be called to store headers (instead of fwrite). The
1022 * parameters will use fwrite() syntax, make sure to follow them. */
1023 CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79),
1025 /* Set this to force the HTTP request to get back to GET. Only really usable
1026 if POST, PUT or a custom request have been used first.
1028 CINIT(HTTPGET, LONG, 80),
1030 /* Set if we should verify the Common name from the peer certificate in ssl
1031 * handshake, set 1 to check existence, 2 to ensure that it matches the
1032 * provided hostname. */
1033 CINIT(SSL_VERIFYHOST, LONG, 81),
1035 /* Specify which file name to write all known cookies in after completed
1036 operation. Set file name to "-" (dash) to make it go to stdout. */
1037 CINIT(COOKIEJAR, OBJECTPOINT, 82),
1039 /* Specify which SSL ciphers to use */
1040 CINIT(SSL_CIPHER_LIST, OBJECTPOINT, 83),
1042 /* Specify which HTTP version to use! This must be set to one of the
1043 CURL_HTTP_VERSION* enums set below. */
1044 CINIT(HTTP_VERSION, LONG, 84),
1046 /* Specifically switch on or off the FTP engine's use of the EPSV command. By
1047 default, that one will always be attempted before the more traditional
1049 CINIT(FTP_USE_EPSV, LONG, 85),
1051 /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */
1052 CINIT(SSLCERTTYPE, OBJECTPOINT, 86),
1054 /* name of the file keeping your private SSL-key */
1055 CINIT(SSLKEY, OBJECTPOINT, 87),
1057 /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */
1058 CINIT(SSLKEYTYPE, OBJECTPOINT, 88),
1060 /* crypto engine for the SSL-sub system */
1061 CINIT(SSLENGINE, OBJECTPOINT, 89),
1063 /* set the crypto engine for the SSL-sub system as default
1064 the param has no meaning...
1066 CINIT(SSLENGINE_DEFAULT, LONG, 90),
1068 /* Non-zero value means to use the global dns cache */
1069 CINIT(DNS_USE_GLOBAL_CACHE, LONG, 91), /* To become OBSOLETE soon */
1071 /* DNS cache timeout */
1072 CINIT(DNS_CACHE_TIMEOUT, LONG, 92),
1074 /* send linked-list of pre-transfer QUOTE commands */
1075 CINIT(PREQUOTE, OBJECTPOINT, 93),
1077 /* set the debug function */
1078 CINIT(DEBUGFUNCTION, FUNCTIONPOINT, 94),
1080 /* set the data for the debug function */
1081 CINIT(DEBUGDATA, OBJECTPOINT, 95),
1083 /* mark this as start of a cookie session */
1084 CINIT(COOKIESESSION, LONG, 96),
1086 /* The CApath directory used to validate the peer certificate
1087 this option is used only if SSL_VERIFYPEER is true */
1088 CINIT(CAPATH, OBJECTPOINT, 97),
1090 /* Instruct libcurl to use a smaller receive buffer */
1091 CINIT(BUFFERSIZE, LONG, 98),
1093 /* Instruct libcurl to not use any signal/alarm handlers, even when using
1094 timeouts. This option is useful for multi-threaded applications.
1095 See libcurl-the-guide for more background information. */
1096 CINIT(NOSIGNAL, LONG, 99),
1098 /* Provide a CURLShare for mutexing non-ts data */
1099 CINIT(SHARE, OBJECTPOINT, 100),
1101 /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default),
1102 CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A and CURLPROXY_SOCKS5. */
1103 CINIT(PROXYTYPE, LONG, 101),
1105 /* Set the Accept-Encoding string. Use this to tell a server you would like
1106 the response to be compressed. */
1107 CINIT(ENCODING, OBJECTPOINT, 102),
1109 /* Set pointer to private data */
1110 CINIT(PRIVATE, OBJECTPOINT, 103),
1112 /* Set aliases for HTTP 200 in the HTTP Response header */
1113 CINIT(HTTP200ALIASES, OBJECTPOINT, 104),
1115 /* Continue to send authentication (user+password) when following locations,
1116 even when hostname changed. This can potentially send off the name
1117 and password to whatever host the server decides. */
1118 CINIT(UNRESTRICTED_AUTH, LONG, 105),
1120 /* Specifically switch on or off the FTP engine's use of the EPRT command ( it
1121 also disables the LPRT attempt). By default, those ones will always be
1122 attempted before the good old traditional PORT command. */
1123 CINIT(FTP_USE_EPRT, LONG, 106),
1125 /* Set this to a bitmask value to enable the particular authentications
1126 methods you like. Use this in combination with CURLOPT_USERPWD.
1127 Note that setting multiple bits may cause extra network round-trips. */
1128 CINIT(HTTPAUTH, LONG, 107),
1130 /* Set the ssl context callback function, currently only for OpenSSL ssl_ctx
1131 in second argument. The function must be matching the
1132 curl_ssl_ctx_callback proto. */
1133 CINIT(SSL_CTX_FUNCTION, FUNCTIONPOINT, 108),
1135 /* Set the userdata for the ssl context callback function's third
1137 CINIT(SSL_CTX_DATA, OBJECTPOINT, 109),
1139 /* FTP Option that causes missing dirs to be created on the remote server.
1140 In 7.19.4 we introduced the convenience enums for this option using the
1141 CURLFTP_CREATE_DIR prefix.
1143 CINIT(FTP_CREATE_MISSING_DIRS, LONG, 110),
1145 /* Set this to a bitmask value to enable the particular authentications
1146 methods you like. Use this in combination with CURLOPT_PROXYUSERPWD.
1147 Note that setting multiple bits may cause extra network round-trips. */
1148 CINIT(PROXYAUTH, LONG, 111),
1150 /* FTP option that changes the timeout, in seconds, associated with
1151 getting a response. This is different from transfer timeout time and
1152 essentially places a demand on the FTP server to acknowledge commands
1153 in a timely manner. */
1154 CINIT(FTP_RESPONSE_TIMEOUT, LONG, 112),
1155 #define CURLOPT_SERVER_RESPONSE_TIMEOUT CURLOPT_FTP_RESPONSE_TIMEOUT
1157 /* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to
1158 tell libcurl to resolve names to those IP versions only. This only has
1159 affect on systems with support for more than one, i.e IPv4 _and_ IPv6. */
1160 CINIT(IPRESOLVE, LONG, 113),
1162 /* Set this option to limit the size of a file that will be downloaded from
1163 an HTTP or FTP server.
1165 Note there is also _LARGE version which adds large file support for
1166 platforms which have larger off_t sizes. See MAXFILESIZE_LARGE below. */
1167 CINIT(MAXFILESIZE, LONG, 114),
1169 /* See the comment for INFILESIZE above, but in short, specifies
1170 * the size of the file being uploaded. -1 means unknown.
1172 CINIT(INFILESIZE_LARGE, OFF_T, 115),
1174 /* Sets the continuation offset. There is also a LONG version of this;
1175 * look above for RESUME_FROM.
1177 CINIT(RESUME_FROM_LARGE, OFF_T, 116),
1179 /* Sets the maximum size of data that will be downloaded from
1180 * an HTTP or FTP server. See MAXFILESIZE above for the LONG version.
1182 CINIT(MAXFILESIZE_LARGE, OFF_T, 117),
1184 /* Set this option to the file name of your .netrc file you want libcurl
1185 to parse (using the CURLOPT_NETRC option). If not set, libcurl will do
1186 a poor attempt to find the user's home directory and check for a .netrc
1188 CINIT(NETRC_FILE, OBJECTPOINT, 118),
1190 /* Enable SSL/TLS for FTP, pick one of:
1191 CURLFTPSSL_TRY - try using SSL, proceed anyway otherwise
1192 CURLFTPSSL_CONTROL - SSL for the control connection or fail
1193 CURLFTPSSL_ALL - SSL for all communication or fail
1195 CINIT(USE_SSL, LONG, 119),
1197 /* The _LARGE version of the standard POSTFIELDSIZE option */
1198 CINIT(POSTFIELDSIZE_LARGE, OFF_T, 120),
1200 /* Enable/disable the TCP Nagle algorithm */
1201 CINIT(TCP_NODELAY, LONG, 121),
1203 /* 122 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
1204 /* 123 OBSOLETE. Gone in 7.16.0 */
1205 /* 124 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
1206 /* 125 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
1207 /* 126 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
1208 /* 127 OBSOLETE. Gone in 7.16.0 */
1209 /* 128 OBSOLETE. Gone in 7.16.0 */
1211 /* When FTP over SSL/TLS is selected (with CURLOPT_USE_SSL), this option
1212 can be used to change libcurl's default action which is to first try
1213 "AUTH SSL" and then "AUTH TLS" in this order, and proceed when a OK
1214 response has been received.
1216 Available parameters are:
1217 CURLFTPAUTH_DEFAULT - let libcurl decide
1218 CURLFTPAUTH_SSL - try "AUTH SSL" first, then TLS
1219 CURLFTPAUTH_TLS - try "AUTH TLS" first, then SSL
1221 CINIT(FTPSSLAUTH, LONG, 129),
1223 CINIT(IOCTLFUNCTION, FUNCTIONPOINT, 130),
1224 CINIT(IOCTLDATA, OBJECTPOINT, 131),
1226 /* 132 OBSOLETE. Gone in 7.16.0 */
1227 /* 133 OBSOLETE. Gone in 7.16.0 */
1229 /* zero terminated string for pass on to the FTP server when asked for
1231 CINIT(FTP_ACCOUNT, OBJECTPOINT, 134),
1233 /* feed cookies into cookie engine */
1234 CINIT(COOKIELIST, OBJECTPOINT, 135),
1236 /* ignore Content-Length */
1237 CINIT(IGNORE_CONTENT_LENGTH, LONG, 136),
1239 /* Set to non-zero to skip the IP address received in a 227 PASV FTP server
1240 response. Typically used for FTP-SSL purposes but is not restricted to
1241 that. libcurl will then instead use the same IP address it used for the
1242 control connection. */
1243 CINIT(FTP_SKIP_PASV_IP, LONG, 137),
1245 /* Select "file method" to use when doing FTP, see the curl_ftpmethod
1247 CINIT(FTP_FILEMETHOD, LONG, 138),
1249 /* Local port number to bind the socket to */
1250 CINIT(LOCALPORT, LONG, 139),
1252 /* Number of ports to try, including the first one set with LOCALPORT.
1253 Thus, setting it to 1 will make no additional attempts but the first.
1255 CINIT(LOCALPORTRANGE, LONG, 140),
1257 /* no transfer, set up connection and let application use the socket by
1258 extracting it with CURLINFO_LASTSOCKET */
1259 CINIT(CONNECT_ONLY, LONG, 141),
1261 /* Function that will be called to convert from the
1262 network encoding (instead of using the iconv calls in libcurl) */
1263 CINIT(CONV_FROM_NETWORK_FUNCTION, FUNCTIONPOINT, 142),
1265 /* Function that will be called to convert to the
1266 network encoding (instead of using the iconv calls in libcurl) */
1267 CINIT(CONV_TO_NETWORK_FUNCTION, FUNCTIONPOINT, 143),
1269 /* Function that will be called to convert from UTF8
1270 (instead of using the iconv calls in libcurl)
1271 Note that this is used only for SSL certificate processing */
1272 CINIT(CONV_FROM_UTF8_FUNCTION, FUNCTIONPOINT, 144),
1274 /* if the connection proceeds too quickly then need to slow it down */
1275 /* limit-rate: maximum number of bytes per second to send or receive */
1276 CINIT(MAX_SEND_SPEED_LARGE, OFF_T, 145),
1277 CINIT(MAX_RECV_SPEED_LARGE, OFF_T, 146),
1279 /* Pointer to command string to send if USER/PASS fails. */
1280 CINIT(FTP_ALTERNATIVE_TO_USER, OBJECTPOINT, 147),
1282 /* callback function for setting socket options */
1283 CINIT(SOCKOPTFUNCTION, FUNCTIONPOINT, 148),
1284 CINIT(SOCKOPTDATA, OBJECTPOINT, 149),
1286 /* set to 0 to disable session ID re-use for this transfer, default is
1288 CINIT(SSL_SESSIONID_CACHE, LONG, 150),
1290 /* allowed SSH authentication methods */
1291 CINIT(SSH_AUTH_TYPES, LONG, 151),
1293 /* Used by scp/sftp to do public/private key authentication */
1294 CINIT(SSH_PUBLIC_KEYFILE, OBJECTPOINT, 152),
1295 CINIT(SSH_PRIVATE_KEYFILE, OBJECTPOINT, 153),
1297 /* Send CCC (Clear Command Channel) after authentication */
1298 CINIT(FTP_SSL_CCC, LONG, 154),
1300 /* Same as TIMEOUT and CONNECTTIMEOUT, but with ms resolution */
1301 CINIT(TIMEOUT_MS, LONG, 155),
1302 CINIT(CONNECTTIMEOUT_MS, LONG, 156),
1304 /* set to zero to disable the libcurl's decoding and thus pass the raw body
1305 data to the application even when it is encoded/compressed */
1306 CINIT(HTTP_TRANSFER_DECODING, LONG, 157),
1307 CINIT(HTTP_CONTENT_DECODING, LONG, 158),
1309 /* Permission used when creating new files and directories on the remote
1310 server for protocols that support it, SFTP/SCP/FILE */
1311 CINIT(NEW_FILE_PERMS, LONG, 159),
1312 CINIT(NEW_DIRECTORY_PERMS, LONG, 160),
1314 /* Set the behaviour of POST when redirecting. Values must be set to one
1315 of CURL_REDIR* defines below. This used to be called CURLOPT_POST301 */
1316 CINIT(POSTREDIR, LONG, 161),
1318 /* used by scp/sftp to verify the host's public key */
1319 CINIT(SSH_HOST_PUBLIC_KEY_MD5, OBJECTPOINT, 162),
1321 /* Callback function for opening socket (instead of socket(2)). Optionally,
1322 callback is able change the address or refuse to connect returning
1323 CURL_SOCKET_BAD. The callback should have type
1324 curl_opensocket_callback */
1325 CINIT(OPENSOCKETFUNCTION, FUNCTIONPOINT, 163),
1326 CINIT(OPENSOCKETDATA, OBJECTPOINT, 164),
1328 /* POST volatile input fields. */
1329 CINIT(COPYPOSTFIELDS, OBJECTPOINT, 165),
1331 /* set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy */
1332 CINIT(PROXY_TRANSFER_MODE, LONG, 166),
1334 /* Callback function for seeking in the input stream */
1335 CINIT(SEEKFUNCTION, FUNCTIONPOINT, 167),
1336 CINIT(SEEKDATA, OBJECTPOINT, 168),
1339 CINIT(CRLFILE, OBJECTPOINT, 169),
1341 /* Issuer certificate */
1342 CINIT(ISSUERCERT, OBJECTPOINT, 170),
1344 /* (IPv6) Address scope */
1345 CINIT(ADDRESS_SCOPE, LONG, 171),
1347 /* Collect certificate chain info and allow it to get retrievable with
1348 CURLINFO_CERTINFO after the transfer is complete. (Unfortunately) only
1349 working with OpenSSL-powered builds. */
1350 CINIT(CERTINFO, LONG, 172),
1352 /* "name" and "pwd" to use when fetching. */
1353 CINIT(USERNAME, OBJECTPOINT, 173),
1354 CINIT(PASSWORD, OBJECTPOINT, 174),
1356 /* "name" and "pwd" to use with Proxy when fetching. */
1357 CINIT(PROXYUSERNAME, OBJECTPOINT, 175),
1358 CINIT(PROXYPASSWORD, OBJECTPOINT, 176),
1360 /* Comma separated list of hostnames defining no-proxy zones. These should
1361 match both hostnames directly, and hostnames within a domain. For
1362 example, local.com will match local.com and www.local.com, but NOT
1363 notlocal.com or www.notlocal.com. For compatibility with other
1364 implementations of this, .local.com will be considered to be the same as
1365 local.com. A single * is the only valid wildcard, and effectively
1366 disables the use of proxy. */
1367 CINIT(NOPROXY, OBJECTPOINT, 177),
1369 /* block size for TFTP transfers */
1370 CINIT(TFTP_BLKSIZE, LONG, 178),
1373 CINIT(SOCKS5_GSSAPI_SERVICE, OBJECTPOINT, 179),
1376 CINIT(SOCKS5_GSSAPI_NEC, LONG, 180),
1378 /* set the bitmask for the protocols that are allowed to be used for the
1379 transfer, which thus helps the app which takes URLs from users or other
1380 external inputs and want to restrict what protocol(s) to deal
1381 with. Defaults to CURLPROTO_ALL. */
1382 CINIT(PROTOCOLS, LONG, 181),
1384 /* set the bitmask for the protocols that libcurl is allowed to follow to,
1385 as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs
1386 to be set in both bitmasks to be allowed to get redirected to. Defaults
1387 to all protocols except FILE and SCP. */
1388 CINIT(REDIR_PROTOCOLS, LONG, 182),
1390 /* set the SSH knownhost file name to use */
1391 CINIT(SSH_KNOWNHOSTS, OBJECTPOINT, 183),
1393 /* set the SSH host key callback, must point to a curl_sshkeycallback
1395 CINIT(SSH_KEYFUNCTION, FUNCTIONPOINT, 184),
1397 /* set the SSH host key callback custom pointer */
1398 CINIT(SSH_KEYDATA, OBJECTPOINT, 185),
1400 /* set the SMTP mail originator */
1401 CINIT(MAIL_FROM, OBJECTPOINT, 186),
1403 /* set the SMTP mail receiver(s) */
1404 CINIT(MAIL_RCPT, OBJECTPOINT, 187),
1406 /* FTP: send PRET before PASV */
1407 CINIT(FTP_USE_PRET, LONG, 188),
1409 /* RTSP request method (OPTIONS, SETUP, PLAY, etc...) */
1410 CINIT(RTSP_REQUEST, LONG, 189),
1412 /* The RTSP session identifier */
1413 CINIT(RTSP_SESSION_ID, OBJECTPOINT, 190),
1415 /* The RTSP stream URI */
1416 CINIT(RTSP_STREAM_URI, OBJECTPOINT, 191),
1418 /* The Transport: header to use in RTSP requests */
1419 CINIT(RTSP_TRANSPORT, OBJECTPOINT, 192),
1421 /* Manually initialize the client RTSP CSeq for this handle */
1422 CINIT(RTSP_CLIENT_CSEQ, LONG, 193),
1424 /* Manually initialize the server RTSP CSeq for this handle */
1425 CINIT(RTSP_SERVER_CSEQ, LONG, 194),
1427 /* The stream to pass to INTERLEAVEFUNCTION. */
1428 CINIT(INTERLEAVEDATA, OBJECTPOINT, 195),
1430 /* Let the application define a custom write method for RTP data */
1431 CINIT(INTERLEAVEFUNCTION, FUNCTIONPOINT, 196),
1433 /* Turn on wildcard matching */
1434 CINIT(WILDCARDMATCH, LONG, 197),
1436 /* Directory matching callback called before downloading of an
1437 individual file (chunk) started */
1438 CINIT(CHUNK_BGN_FUNCTION, FUNCTIONPOINT, 198),
1440 /* Directory matching callback called after the file (chunk)
1441 was downloaded, or skipped */
1442 CINIT(CHUNK_END_FUNCTION, FUNCTIONPOINT, 199),
1444 /* Change match (fnmatch-like) callback for wildcard matching */
1445 CINIT(FNMATCH_FUNCTION, FUNCTIONPOINT, 200),
1447 /* Let the application define custom chunk data pointer */
1448 CINIT(CHUNK_DATA, OBJECTPOINT, 201),
1450 /* FNMATCH_FUNCTION user pointer */
1451 CINIT(FNMATCH_DATA, OBJECTPOINT, 202),
1453 /* send linked-list of name:port:address sets */
1454 CINIT(RESOLVE, OBJECTPOINT, 203),
1456 /* Set a username for authenticated TLS */
1457 CINIT(TLSAUTH_USERNAME, OBJECTPOINT, 204),
1459 /* Set a password for authenticated TLS */
1460 CINIT(TLSAUTH_PASSWORD, OBJECTPOINT, 205),
1462 /* Set authentication type for authenticated TLS */
1463 CINIT(TLSAUTH_TYPE, OBJECTPOINT, 206),
1465 CURLOPT_LASTENTRY /* the last unused */
1468 #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
1469 the obsolete stuff removed! */
1471 /* Backwards compatibility with older names */
1472 /* These are scheduled to disappear by 2011 */
1474 /* This was added in version 7.19.1 */
1475 #define CURLOPT_POST301 CURLOPT_POSTREDIR
1477 /* These are scheduled to disappear by 2009 */
1479 /* The following were added in 7.17.0 */
1480 #define CURLOPT_SSLKEYPASSWD CURLOPT_KEYPASSWD
1481 #define CURLOPT_FTPAPPEND CURLOPT_APPEND
1482 #define CURLOPT_FTPLISTONLY CURLOPT_DIRLISTONLY
1483 #define CURLOPT_FTP_SSL CURLOPT_USE_SSL
1485 /* The following were added earlier */
1487 #define CURLOPT_SSLCERTPASSWD CURLOPT_KEYPASSWD
1488 #define CURLOPT_KRB4LEVEL CURLOPT_KRBLEVEL
1491 /* This is set if CURL_NO_OLDIES is defined at compile-time */
1492 #undef CURLOPT_DNS_USE_GLOBAL_CACHE /* soon obsolete */
1496 /* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host
1497 name resolves addresses using more than one IP protocol version, this
1498 option might be handy to force libcurl to use a specific IP version. */
1499 #define CURL_IPRESOLVE_WHATEVER 0 /* default, resolves addresses to all IP
1500 versions that your system allows */
1501 #define CURL_IPRESOLVE_V4 1 /* resolve to ipv4 addresses */
1502 #define CURL_IPRESOLVE_V6 2 /* resolve to ipv6 addresses */
1504 /* three convenient "aliases" that follow the name scheme better */
1505 #define CURLOPT_WRITEDATA CURLOPT_FILE
1506 #define CURLOPT_READDATA CURLOPT_INFILE
1507 #define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER
1508 #define CURLOPT_RTSPHEADER CURLOPT_HTTPHEADER
1510 /* These enums are for use with the CURLOPT_HTTP_VERSION option. */
1512 CURL_HTTP_VERSION_NONE, /* setting this means we don't care, and that we'd
1513 like the library to choose the best possible
1515 CURL_HTTP_VERSION_1_0, /* please use HTTP 1.0 in the request */
1516 CURL_HTTP_VERSION_1_1, /* please use HTTP 1.1 in the request */
1518 CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */
1522 * Public API enums for RTSP requests
1525 CURL_RTSPREQ_NONE, /* first in list */
1526 CURL_RTSPREQ_OPTIONS,
1527 CURL_RTSPREQ_DESCRIBE,
1528 CURL_RTSPREQ_ANNOUNCE,
1532 CURL_RTSPREQ_TEARDOWN,
1533 CURL_RTSPREQ_GET_PARAMETER,
1534 CURL_RTSPREQ_SET_PARAMETER,
1535 CURL_RTSPREQ_RECORD,
1536 CURL_RTSPREQ_RECEIVE,
1537 CURL_RTSPREQ_LAST /* last in list */
1540 /* These enums are for use with the CURLOPT_NETRC option. */
1541 enum CURL_NETRC_OPTION {
1542 CURL_NETRC_IGNORED, /* The .netrc will never be read.
1543 * This is the default. */
1544 CURL_NETRC_OPTIONAL, /* A user:password in the URL will be preferred
1545 * to one in the .netrc. */
1546 CURL_NETRC_REQUIRED, /* A user:password in the URL will be ignored.
1547 * Unless one is set programmatically, the .netrc
1548 * will be queried. */
1553 CURL_SSLVERSION_DEFAULT,
1554 CURL_SSLVERSION_TLSv1,
1555 CURL_SSLVERSION_SSLv2,
1556 CURL_SSLVERSION_SSLv3,
1558 CURL_SSLVERSION_LAST /* never use, keep last */
1564 CURL_TLSAUTH_LAST /* never use, keep last */
1567 /* symbols to use with CURLOPT_POSTREDIR.
1568 CURL_REDIR_POST_301 and CURL_REDIR_POST_302 can be bitwise ORed so that
1569 CURL_REDIR_POST_301 | CURL_REDIR_POST_302 == CURL_REDIR_POST_ALL */
1571 #define CURL_REDIR_GET_ALL 0
1572 #define CURL_REDIR_POST_301 1
1573 #define CURL_REDIR_POST_302 2
1574 #define CURL_REDIR_POST_ALL (CURL_REDIR_POST_301|CURL_REDIR_POST_302)
1579 CURL_TIMECOND_IFMODSINCE,
1580 CURL_TIMECOND_IFUNMODSINCE,
1581 CURL_TIMECOND_LASTMOD,
1587 /* curl_strequal() and curl_strnequal() are subject for removal in a future
1588 libcurl, see lib/README.curlx for details */
1589 CURL_EXTERN int (curl_strequal)(const char *s1, const char *s2);
1590 CURL_EXTERN int (curl_strnequal)(const char *s1, const char *s2, size_t n);
1592 /* name is uppercase CURLFORM_<name> */
1598 #define CFINIT(name) CURLFORM_ ## name
1600 /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
1601 #define CFINIT(name) CURLFORM_/**/name
1605 CFINIT(NOTHING), /********* the first one is unused ************/
1611 CFINIT(COPYCONTENTS),
1612 CFINIT(PTRCONTENTS),
1613 CFINIT(CONTENTSLENGTH),
1614 CFINIT(FILECONTENT),
1621 CFINIT(BUFFERLENGTH),
1623 CFINIT(CONTENTTYPE),
1624 CFINIT(CONTENTHEADER),
1631 CURLFORM_LASTENTRY /* the last unused */
1634 #undef CFINIT /* done */
1636 /* structure to be used as parameter for CURLFORM_ARRAY */
1638 CURLformoption option;
1642 /* use this for multipart formpost building */
1643 /* Returns code for curl_formadd()
1646 * CURL_FORMADD_OK on success
1647 * CURL_FORMADD_MEMORY if the FormInfo allocation fails
1648 * CURL_FORMADD_OPTION_TWICE if one option is given twice for one Form
1649 * CURL_FORMADD_NULL if a null pointer was given for a char
1650 * CURL_FORMADD_MEMORY if the allocation of a FormInfo struct failed
1651 * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used
1652 * CURL_FORMADD_INCOMPLETE if the some FormInfo is not complete (or error)
1653 * CURL_FORMADD_MEMORY if a curl_httppost struct cannot be allocated
1654 * CURL_FORMADD_MEMORY if some allocation for string copying failed.
1655 * CURL_FORMADD_ILLEGAL_ARRAY if an illegal option is used in an array
1657 ***************************************************************************/
1659 CURL_FORMADD_OK, /* first, no error */
1661 CURL_FORMADD_MEMORY,
1662 CURL_FORMADD_OPTION_TWICE,
1664 CURL_FORMADD_UNKNOWN_OPTION,
1665 CURL_FORMADD_INCOMPLETE,
1666 CURL_FORMADD_ILLEGAL_ARRAY,
1667 CURL_FORMADD_DISABLED, /* libcurl was built with this disabled */
1669 CURL_FORMADD_LAST /* last */
1673 * NAME curl_formadd()
1677 * Pretty advanced function for building multi-part formposts. Each invoke
1678 * adds one part that together construct a full post. Then use
1679 * CURLOPT_HTTPPOST to send it off to libcurl.
1681 CURL_EXTERN CURLFORMcode curl_formadd(struct curl_httppost **httppost,
1682 struct curl_httppost **last_post,
1686 * callback function for curl_formget()
1687 * The void *arg pointer will be the one passed as second argument to
1689 * The character buffer passed to it must not be freed.
1690 * Should return the buffer length passed to it as the argument "len" on
1693 typedef size_t (*curl_formget_callback)(void *arg, const char *buf, size_t len);
1696 * NAME curl_formget()
1700 * Serialize a curl_httppost struct built with curl_formadd().
1701 * Accepts a void pointer as second argument which will be passed to
1702 * the curl_formget_callback function.
1703 * Returns 0 on success.
1705 CURL_EXTERN int curl_formget(struct curl_httppost *form, void *arg,
1706 curl_formget_callback append);
1708 * NAME curl_formfree()
1712 * Free a multipart formpost previously built with curl_formadd().
1714 CURL_EXTERN void curl_formfree(struct curl_httppost *form);
1717 * NAME curl_getenv()
1721 * Returns a malloc()'ed string that MUST be curl_free()ed after usage is
1722 * complete. DEPRECATED - see lib/README.curlx
1724 CURL_EXTERN char *curl_getenv(const char *variable);
1727 * NAME curl_version()
1731 * Returns a static ascii string of the libcurl version.
1733 CURL_EXTERN char *curl_version(void);
1736 * NAME curl_easy_escape()
1740 * Escapes URL strings (converts all letters consider illegal in URLs to their
1741 * %XX versions). This function returns a new allocated string or NULL if an
1744 CURL_EXTERN char *curl_easy_escape(CURL *handle,
1748 /* the previous version: */
1749 CURL_EXTERN char *curl_escape(const char *string,
1754 * NAME curl_easy_unescape()
1758 * Unescapes URL encoding in strings (converts all %XX codes to their 8bit
1759 * versions). This function returns a new allocated string or NULL if an error
1761 * Conversion Note: On non-ASCII platforms the ASCII %XX codes are
1762 * converted into the host encoding.
1764 CURL_EXTERN char *curl_easy_unescape(CURL *handle,
1769 /* the previous version */
1770 CURL_EXTERN char *curl_unescape(const char *string,
1778 * Provided for de-allocation in the same translation unit that did the
1779 * allocation. Added in libcurl 7.10
1781 CURL_EXTERN void curl_free(void *p);
1784 * NAME curl_global_init()
1788 * curl_global_init() should be invoked exactly once for each application that
1789 * uses libcurl and before any call of other libcurl functions.
1791 * This function is not thread-safe!
1793 CURL_EXTERN CURLcode curl_global_init(long flags);
1796 * NAME curl_global_init_mem()
1800 * curl_global_init() or curl_global_init_mem() should be invoked exactly once
1801 * for each application that uses libcurl. This function can be used to
1802 * initialize libcurl and set user defined memory management callback
1803 * functions. Users can implement memory management routines to check for
1804 * memory leaks, check for mis-use of the curl library etc. User registered
1805 * callback routines with be invoked by this library instead of the system
1806 * memory management routines like malloc, free etc.
1808 CURL_EXTERN CURLcode curl_global_init_mem(long flags,
1809 curl_malloc_callback m,
1810 curl_free_callback f,
1811 curl_realloc_callback r,
1812 curl_strdup_callback s,
1813 curl_calloc_callback c);
1816 * NAME curl_global_cleanup()
1820 * curl_global_cleanup() should be invoked exactly once for each application
1823 CURL_EXTERN void curl_global_cleanup(void);
1825 /* linked-list structure for the CURLOPT_QUOTE option (and other) */
1828 struct curl_slist *next;
1832 * NAME curl_slist_append()
1836 * Appends a string to a linked list. If no list exists, it will be created
1837 * first. Returns the new list, after appending.
1839 CURL_EXTERN struct curl_slist *curl_slist_append(struct curl_slist *,
1843 * NAME curl_slist_free_all()
1847 * free a previously built curl_slist.
1849 CURL_EXTERN void curl_slist_free_all(struct curl_slist *);
1852 * NAME curl_getdate()
1856 * Returns the time, in seconds since 1 Jan 1970 of the time string given in
1857 * the first argument. The time argument in the second parameter is unused
1858 * and should be set to NULL.
1860 CURL_EXTERN time_t curl_getdate(const char *p, const time_t *unused);
1862 /* info about the certificate chain, only for OpenSSL builds. Asked
1863 for with CURLOPT_CERTINFO / CURLINFO_CERTINFO */
1864 struct curl_certinfo {
1865 int num_of_certs; /* number of certificates with information */
1866 struct curl_slist **certinfo; /* for each index in this array, there's a
1867 linked list with textual information in the
1868 format "name: value" */
1871 #define CURLINFO_STRING 0x100000
1872 #define CURLINFO_LONG 0x200000
1873 #define CURLINFO_DOUBLE 0x300000
1874 #define CURLINFO_SLIST 0x400000
1875 #define CURLINFO_MASK 0x0fffff
1876 #define CURLINFO_TYPEMASK 0xf00000
1879 CURLINFO_NONE, /* first, never use this */
1880 CURLINFO_EFFECTIVE_URL = CURLINFO_STRING + 1,
1881 CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2,
1882 CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE + 3,
1883 CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE + 4,
1884 CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5,
1885 CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6,
1886 CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE + 7,
1887 CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE + 8,
1888 CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE + 9,
1889 CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE + 10,
1890 CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11,
1891 CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12,
1892 CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13,
1893 CURLINFO_FILETIME = CURLINFO_LONG + 14,
1894 CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE + 15,
1895 CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE + 16,
1896 CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17,
1897 CURLINFO_CONTENT_TYPE = CURLINFO_STRING + 18,
1898 CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19,
1899 CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20,
1900 CURLINFO_PRIVATE = CURLINFO_STRING + 21,
1901 CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG + 22,
1902 CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23,
1903 CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24,
1904 CURLINFO_OS_ERRNO = CURLINFO_LONG + 25,
1905 CURLINFO_NUM_CONNECTS = CURLINFO_LONG + 26,
1906 CURLINFO_SSL_ENGINES = CURLINFO_SLIST + 27,
1907 CURLINFO_COOKIELIST = CURLINFO_SLIST + 28,
1908 CURLINFO_LASTSOCKET = CURLINFO_LONG + 29,
1909 CURLINFO_FTP_ENTRY_PATH = CURLINFO_STRING + 30,
1910 CURLINFO_REDIRECT_URL = CURLINFO_STRING + 31,
1911 CURLINFO_PRIMARY_IP = CURLINFO_STRING + 32,
1912 CURLINFO_APPCONNECT_TIME = CURLINFO_DOUBLE + 33,
1913 CURLINFO_CERTINFO = CURLINFO_SLIST + 34,
1914 CURLINFO_CONDITION_UNMET = CURLINFO_LONG + 35,
1915 CURLINFO_RTSP_SESSION_ID = CURLINFO_STRING + 36,
1916 CURLINFO_RTSP_CLIENT_CSEQ = CURLINFO_LONG + 37,
1917 CURLINFO_RTSP_SERVER_CSEQ = CURLINFO_LONG + 38,
1918 CURLINFO_RTSP_CSEQ_RECV = CURLINFO_LONG + 39,
1919 CURLINFO_PRIMARY_PORT = CURLINFO_LONG + 40,
1920 CURLINFO_LOCAL_IP = CURLINFO_STRING + 41,
1921 CURLINFO_LOCAL_PORT = CURLINFO_LONG + 42,
1922 /* Fill in new entries below here! */
1924 CURLINFO_LASTONE = 42
1927 /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as
1928 CURLINFO_HTTP_CODE */
1929 #define CURLINFO_HTTP_CODE CURLINFO_RESPONSE_CODE
1932 CURLCLOSEPOLICY_NONE, /* first, never use this */
1934 CURLCLOSEPOLICY_OLDEST,
1935 CURLCLOSEPOLICY_LEAST_RECENTLY_USED,
1936 CURLCLOSEPOLICY_LEAST_TRAFFIC,
1937 CURLCLOSEPOLICY_SLOWEST,
1938 CURLCLOSEPOLICY_CALLBACK,
1940 CURLCLOSEPOLICY_LAST /* last, never use this */
1943 #define CURL_GLOBAL_SSL (1<<0)
1944 #define CURL_GLOBAL_WIN32 (1<<1)
1945 #define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)
1946 #define CURL_GLOBAL_NOTHING 0
1947 #define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL
1950 /*****************************************************************************
1951 * Setup defines, protos etc for the sharing stuff.
1954 /* Different data locks for a single share */
1956 CURL_LOCK_DATA_NONE = 0,
1957 /* CURL_LOCK_DATA_SHARE is used internally to say that
1958 * the locking is just made to change the internal state of the share
1961 CURL_LOCK_DATA_SHARE,
1962 CURL_LOCK_DATA_COOKIE,
1964 CURL_LOCK_DATA_SSL_SESSION,
1965 CURL_LOCK_DATA_CONNECT,
1969 /* Different lock access types */
1971 CURL_LOCK_ACCESS_NONE = 0, /* unspecified action */
1972 CURL_LOCK_ACCESS_SHARED = 1, /* for read perhaps */
1973 CURL_LOCK_ACCESS_SINGLE = 2, /* for write perhaps */
1974 CURL_LOCK_ACCESS_LAST /* never use */
1977 typedef void (*curl_lock_function)(CURL *handle,
1978 curl_lock_data data,
1979 curl_lock_access locktype,
1981 typedef void (*curl_unlock_function)(CURL *handle,
1982 curl_lock_data data,
1985 typedef void CURLSH;
1988 CURLSHE_OK, /* all is fine */
1989 CURLSHE_BAD_OPTION, /* 1 */
1990 CURLSHE_IN_USE, /* 2 */
1991 CURLSHE_INVALID, /* 3 */
1992 CURLSHE_NOMEM, /* out of memory */
1993 CURLSHE_LAST /* never use */
1997 CURLSHOPT_NONE, /* don't use */
1998 CURLSHOPT_SHARE, /* specify a data type to share */
1999 CURLSHOPT_UNSHARE, /* specify which data type to stop sharing */
2000 CURLSHOPT_LOCKFUNC, /* pass in a 'curl_lock_function' pointer */
2001 CURLSHOPT_UNLOCKFUNC, /* pass in a 'curl_unlock_function' pointer */
2002 CURLSHOPT_USERDATA, /* pass in a user data pointer used in the lock/unlock
2003 callback functions */
2004 CURLSHOPT_LAST /* never use */
2007 CURL_EXTERN CURLSH *curl_share_init(void);
2008 CURL_EXTERN CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...);
2009 CURL_EXTERN CURLSHcode curl_share_cleanup(CURLSH *);
2011 /****************************************************************************
2012 * Structures for querying information about the curl library at runtime.
2020 CURLVERSION_LAST /* never actually use this */
2023 /* The 'CURLVERSION_NOW' is the symbolic name meant to be used by
2024 basically all programs ever that want to get version information. It is
2025 meant to be a built-in version number for what kind of struct the caller
2026 expects. If the struct ever changes, we redefine the NOW to another enum
2028 #define CURLVERSION_NOW CURLVERSION_FOURTH
2031 CURLversion age; /* age of the returned struct */
2032 const char *version; /* LIBCURL_VERSION */
2033 unsigned int version_num; /* LIBCURL_VERSION_NUM */
2034 const char *host; /* OS/host/cpu/machine when configured */
2035 int features; /* bitmask, see defines below */
2036 const char *ssl_version; /* human readable string */
2037 long ssl_version_num; /* not used anymore, always 0 */
2038 const char *libz_version; /* human readable string */
2039 /* protocols is terminated by an entry with a NULL protoname */
2040 const char * const *protocols;
2042 /* The fields below this were added in CURLVERSION_SECOND */
2046 /* This field was added in CURLVERSION_THIRD */
2049 /* These field were added in CURLVERSION_FOURTH */
2051 /* Same as '_libiconv_version' if built with HAVE_ICONV */
2054 const char *libssh_version; /* human readable string */
2056 } curl_version_info_data;
2058 #define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */
2059 #define CURL_VERSION_KERBEROS4 (1<<1) /* kerberos auth is supported */
2060 #define CURL_VERSION_SSL (1<<2) /* SSL options are present */
2061 #define CURL_VERSION_LIBZ (1<<3) /* libz features are present */
2062 #define CURL_VERSION_NTLM (1<<4) /* NTLM auth is supported */
2063 #define CURL_VERSION_GSSNEGOTIATE (1<<5) /* Negotiate auth support */
2064 #define CURL_VERSION_DEBUG (1<<6) /* built with debug capabilities */
2065 #define CURL_VERSION_ASYNCHDNS (1<<7) /* asynchronous dns resolves */
2066 #define CURL_VERSION_SPNEGO (1<<8) /* SPNEGO auth */
2067 #define CURL_VERSION_LARGEFILE (1<<9) /* supports files bigger than 2GB */
2068 #define CURL_VERSION_IDN (1<<10) /* International Domain Names support */
2069 #define CURL_VERSION_SSPI (1<<11) /* SSPI is supported */
2070 #define CURL_VERSION_CONV (1<<12) /* character conversions supported */
2071 #define CURL_VERSION_CURLDEBUG (1<<13) /* debug memory tracking supported */
2072 #define CURL_VERSION_TLSAUTH_SRP (1<<14) /* TLS-SRP auth is supported */
2075 * NAME curl_version_info()
2079 * This function returns a pointer to a static copy of the version info
2080 * struct. See above.
2082 CURL_EXTERN curl_version_info_data *curl_version_info(CURLversion);
2085 * NAME curl_easy_strerror()
2089 * The curl_easy_strerror function may be used to turn a CURLcode value
2090 * into the equivalent human readable error string. This is useful
2091 * for printing meaningful error messages.
2093 CURL_EXTERN const char *curl_easy_strerror(CURLcode);
2096 * NAME curl_share_strerror()
2100 * The curl_share_strerror function may be used to turn a CURLSHcode value
2101 * into the equivalent human readable error string. This is useful
2102 * for printing meaningful error messages.
2104 CURL_EXTERN const char *curl_share_strerror(CURLSHcode);
2107 * NAME curl_easy_pause()
2111 * The curl_easy_pause function pauses or unpauses transfers. Select the new
2112 * state by setting the bitmask, use the convenience defines below.
2115 CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask);
2117 #define CURLPAUSE_RECV (1<<0)
2118 #define CURLPAUSE_RECV_CONT (0)
2120 #define CURLPAUSE_SEND (1<<2)
2121 #define CURLPAUSE_SEND_CONT (0)
2123 #define CURLPAUSE_ALL (CURLPAUSE_RECV|CURLPAUSE_SEND)
2124 #define CURLPAUSE_CONT (CURLPAUSE_RECV_CONT|CURLPAUSE_SEND_CONT)
2130 /* unfortunately, the easy.h and multi.h include files need options and info
2131 stuff before they can be included! */
2132 #include "easy.h" /* nothing in curl is fun without the easy stuff */
2135 /* the typechecker doesn't work in C++ (yet) */
2136 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && \
2137 ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && \
2138 !defined(__cplusplus) && !defined(CURL_DISABLE_TYPECHECK)
2139 #include "typecheck-gcc.h"
2141 #if defined(__STDC__) && (__STDC__ >= 1)
2142 /* This preprocessor magic that replaces a call with the exact same call is
2143 only done to make sure application authors pass exactly three arguments
2144 to these functions. */
2145 #define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param)
2146 #define curl_easy_getinfo(handle,info,arg) curl_easy_getinfo(handle,info,arg)
2147 #define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
2148 #define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
2149 #endif /* __STDC__ >= 1 */
2150 #endif /* gcc >= 4.3 && !__cplusplus */
2152 #endif /* __CURL_CURL_H */