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