curl.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. #ifndef __CURL_CURL_H
  2. #define __CURL_CURL_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2002, Daniel Stenberg, <[email protected]>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at http://curl.haxx.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. * $Id$
  24. ***************************************************************************/
  25. #include <stdio.h>
  26. /* The include stuff here is mainly for time_t! */
  27. #ifdef vms
  28. # include <types.h>
  29. # include <time.h>
  30. #else
  31. # include <sys/types.h>
  32. # ifdef TIME_WITH_SYS_TIME
  33. # include <sys/time.h>
  34. # include <time.h>
  35. # else
  36. # ifdef HAVE_SYS_TIME_H
  37. # include <sys/time.h>
  38. # else
  39. # include <time.h>
  40. # endif
  41. # endif
  42. #endif /* defined (vms) */
  43. #ifndef TRUE
  44. #define TRUE 1
  45. #endif
  46. #ifndef FALSE
  47. #define FALSE 0
  48. #endif
  49. #include "types.h"
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53. /* stupid #define trick to preserve functionality with older code, but
  54. making it use our name space for the future */
  55. #define HttpPost curl_httppost
  56. struct curl_httppost {
  57. struct curl_httppost *next; /* next entry in the list */
  58. char *name; /* pointer to allocated name */
  59. long namelength; /* length of name length */
  60. char *contents; /* pointer to allocated data contents */
  61. long contentslength; /* length of contents field */
  62. /* CMC: Added support for buffer uploads */
  63. char *buffer; /* pointer to allocated buffer contents */
  64. long bufferlength; /* length of buffer field */
  65. char *contenttype; /* Content-Type */
  66. struct curl_slist* contentheader; /* list of extra headers for this form */
  67. struct curl_httppost *more; /* if one field name has more than one file, this
  68. link should link to following files */
  69. long flags; /* as defined below */
  70. #define HTTPPOST_FILENAME (1<<0) /* specified content is a file name */
  71. #define HTTPPOST_READFILE (1<<1) /* specified content is a file name */
  72. #define HTTPPOST_PTRNAME (1<<2) /* name is only stored pointer
  73. do not free in formfree */
  74. #define HTTPPOST_PTRCONTENTS (1<<3) /* contents is only stored pointer
  75. do not free in formfree */
  76. /* CMC: Added support for buffer uploads */
  77. #define HTTPPOST_BUFFER (1<<4) /* upload file from buffer */
  78. #define HTTPPOST_PTRBUFFER (1<<5) /* upload file from pointer contents */
  79. char *showfilename; /* The file name to show. If not set, the actual
  80. file name will be used (if this is a file part) */
  81. };
  82. typedef int (*curl_progress_callback)(void *clientp,
  83. double dltotal,
  84. double dlnow,
  85. double ultotal,
  86. double ulnow);
  87. /* Tests have proven that 20K is a very bad buffer size for uploads on
  88. Windows, while 16K for some odd reason performed a lot better. */
  89. #define CURL_MAX_WRITE_SIZE 16384
  90. typedef size_t (*curl_write_callback)(char *buffer,
  91. size_t size,
  92. size_t nitems,
  93. void *outstream);
  94. typedef size_t (*curl_read_callback)(char *buffer,
  95. size_t size,
  96. size_t nitems,
  97. void *instream);
  98. typedef int (*curl_passwd_callback)(void *clientp,
  99. const char *prompt,
  100. char *buffer,
  101. int buflen);
  102. /* the kind of data that is passed to information_callback*/
  103. typedef enum {
  104. CURLINFO_TEXT = 0,
  105. CURLINFO_HEADER_IN, /* 1 */
  106. CURLINFO_HEADER_OUT, /* 2 */
  107. CURLINFO_DATA_IN, /* 3 */
  108. CURLINFO_DATA_OUT, /* 4 */
  109. CURLINFO_END
  110. } curl_infotype;
  111. typedef int (*curl_debug_callback)
  112. (CURL *handle, /* the handle/transfer this concerns */
  113. curl_infotype type, /* what kind of data */
  114. char *data, /* points to the data */
  115. size_t size, /* size of the data pointed to */
  116. void *userp); /* whatever the user please */
  117. /* All possible error codes from all sorts of curl functions. Future versions
  118. may return other values, stay prepared.
  119. Always add new return codes last. Never *EVER* remove any. The return
  120. codes must remain the same!
  121. */
  122. typedef enum {
  123. CURLE_OK = 0,
  124. CURLE_UNSUPPORTED_PROTOCOL, /* 1 */
  125. CURLE_FAILED_INIT, /* 2 */
  126. CURLE_URL_MALFORMAT, /* 3 */
  127. CURLE_URL_MALFORMAT_USER, /* 4 */
  128. CURLE_COULDNT_RESOLVE_PROXY, /* 5 */
  129. CURLE_COULDNT_RESOLVE_HOST, /* 6 */
  130. CURLE_COULDNT_CONNECT, /* 7 */
  131. CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */
  132. CURLE_FTP_ACCESS_DENIED, /* 9 */
  133. CURLE_FTP_USER_PASSWORD_INCORRECT, /* 10 */
  134. CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */
  135. CURLE_FTP_WEIRD_USER_REPLY, /* 12 */
  136. CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */
  137. CURLE_FTP_WEIRD_227_FORMAT, /* 14 */
  138. CURLE_FTP_CANT_GET_HOST, /* 15 */
  139. CURLE_FTP_CANT_RECONNECT, /* 16 */
  140. CURLE_FTP_COULDNT_SET_BINARY, /* 17 */
  141. CURLE_PARTIAL_FILE, /* 18 */
  142. CURLE_FTP_COULDNT_RETR_FILE, /* 19 */
  143. CURLE_FTP_WRITE_ERROR, /* 20 */
  144. CURLE_FTP_QUOTE_ERROR, /* 21 */
  145. CURLE_HTTP_RETURNED_ERROR, /* 22 */
  146. CURLE_WRITE_ERROR, /* 23 */
  147. CURLE_MALFORMAT_USER, /* 24 - user name is illegally specified */
  148. CURLE_FTP_COULDNT_STOR_FILE, /* 25 - failed FTP upload */
  149. CURLE_READ_ERROR, /* 26 - could open/read from file */
  150. CURLE_OUT_OF_MEMORY, /* 27 */
  151. CURLE_OPERATION_TIMEOUTED, /* 28 - the timeout time was reached */
  152. CURLE_FTP_COULDNT_SET_ASCII, /* 29 - TYPE A failed */
  153. CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */
  154. CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */
  155. CURLE_FTP_COULDNT_GET_SIZE, /* 32 - the SIZE command failed */
  156. CURLE_HTTP_RANGE_ERROR, /* 33 - RANGE "command" didn't work */
  157. CURLE_HTTP_POST_ERROR, /* 34 */
  158. CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */
  159. CURLE_BAD_DOWNLOAD_RESUME, /* 36 - couldn't resume download */
  160. CURLE_FILE_COULDNT_READ_FILE, /* 37 */
  161. CURLE_LDAP_CANNOT_BIND, /* 38 */
  162. CURLE_LDAP_SEARCH_FAILED, /* 39 */
  163. CURLE_LIBRARY_NOT_FOUND, /* 40 */
  164. CURLE_FUNCTION_NOT_FOUND, /* 41 */
  165. CURLE_ABORTED_BY_CALLBACK, /* 42 */
  166. CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */
  167. CURLE_BAD_CALLING_ORDER, /* 44 */
  168. CURLE_HTTP_PORT_FAILED, /* 45 - HTTP Interface operation failed */
  169. CURLE_BAD_PASSWORD_ENTERED, /* 46 - my_getpass() returns fail */
  170. CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */
  171. CURLE_UNKNOWN_TELNET_OPTION, /* 48 - User specified an unknown option */
  172. CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */
  173. CURLE_OBSOLETE, /* 50 - removed after 7.7.3 */
  174. CURLE_SSL_PEER_CERTIFICATE, /* 51 - peer's certificate wasn't ok */
  175. CURLE_GOT_NOTHING, /* 52 - when this is a specific error */
  176. CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */
  177. CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as
  178. default */
  179. CURLE_SEND_ERROR, /* 55 - failed sending network data */
  180. CURLE_RECV_ERROR, /* 56 - failure in receiving network data */
  181. CURLE_SHARE_IN_USE, /* 57 - share is in use */
  182. CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */
  183. CURLE_SSL_CIPHER, /* 59 - couldn't use specified cipher */
  184. CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */
  185. CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized transfer encoding */
  186. CURL_LAST /* never use! */
  187. } CURLcode;
  188. /* Make a spelling correction for the operation timed-out define */
  189. #define CURLE_OPERATION_TIMEDOUT CURLE_OPERATION_TIMEOUTED
  190. #define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR
  191. typedef enum {
  192. CURLPROXY_HTTP = 0,
  193. CURLPROXY_SOCKS4 = 4,
  194. CURLPROXY_SOCKS5 = 5
  195. } curl_proxytype;
  196. /* this was the error code 50 in 7.7.3 and a few earlier versions, this
  197. is no longer used by libcurl but is instead #defined here only to not
  198. make programs break */
  199. #define CURLE_ALREADY_COMPLETE 99999
  200. /* This is just to make older programs not break: */
  201. #define CURLE_FTP_PARTIAL_FILE CURLE_PARTIAL_FILE
  202. #define CURLE_FTP_BAD_DOWNLOAD_RESUME CURLE_BAD_DOWNLOAD_RESUME
  203. #define CURL_ERROR_SIZE 256
  204. /* long may be 32 or 64 bits, but we should never depend on anything else
  205. but 32 */
  206. #define CURLOPTTYPE_LONG 0
  207. #define CURLOPTTYPE_OBJECTPOINT 10000
  208. #define CURLOPTTYPE_FUNCTIONPOINT 20000
  209. /* name is uppercase CURLOPT_<name>,
  210. type is one of the defined CURLOPTTYPE_<type>
  211. number is unique identifier */
  212. #ifdef CINIT
  213. #undef CINIT
  214. #endif
  215. /*
  216. * Figure out if we can use the ## operator, which is supported by ISO/ANSI C
  217. * and C++. Some compilers support it without setting __STDC__ or __cplusplus
  218. * so we need to carefully check for them too. We don't use configure-checks
  219. * for these since we want these headers to remain generic and working for all
  220. * platforms.
  221. */
  222. #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
  223. defined(__HP_aCC) || defined(__BORLANDC__)
  224. /* This compiler is believed to have an ISO compatible preprocessor */
  225. #define CURL_ISOCPP
  226. #else
  227. /* This compiler is believed NOT to have an ISO compatible preprocessor */
  228. #undef CURL_ISOCPP
  229. #endif
  230. #ifdef CURL_ISOCPP
  231. #define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number
  232. #else
  233. /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
  234. #define LONG CURLOPTTYPE_LONG
  235. #define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
  236. #define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
  237. #define CINIT(name,type,number) CURLOPT_/**/name = type + number
  238. #endif
  239. typedef enum {
  240. CINIT(NOTHING, LONG, 0), /********* the first one is unused ************/
  241. /* This is the FILE * or void * the regular output should be written to. */
  242. CINIT(FILE, OBJECTPOINT, 1),
  243. /* The full URL to get/put */
  244. CINIT(URL, OBJECTPOINT, 2),
  245. /* Port number to connect to, if other than default. Specify the CONF_PORT
  246. flag in the CURLOPT_FLAGS to activate this */
  247. CINIT(PORT, LONG, 3),
  248. /* Name of proxy to use. Specify the CONF_PROXY flag in the CURLOPT_FLAGS to
  249. activate this */
  250. CINIT(PROXY, OBJECTPOINT, 4),
  251. /* Name and password to use when fetching. Specify the CONF_USERPWD flag in
  252. the CURLOPT_FLAGS to activate this */
  253. CINIT(USERPWD, OBJECTPOINT, 5),
  254. /* Name and password to use with Proxy. Specify the CONF_PROXYUSERPWD
  255. flag in the CURLOPT_FLAGS to activate this */
  256. CINIT(PROXYUSERPWD, OBJECTPOINT, 6),
  257. /* Range to get, specified as an ASCII string. Specify the CONF_RANGE flag
  258. in the CURLOPT_FLAGS to activate this */
  259. CINIT(RANGE, OBJECTPOINT, 7),
  260. /* not used */
  261. /* Specified file stream to upload from (use as input): */
  262. CINIT(INFILE, OBJECTPOINT, 9),
  263. /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE
  264. * bytes big. If this is not used, error messages go to stderr instead: */
  265. CINIT(ERRORBUFFER, OBJECTPOINT, 10),
  266. /* Function that will be called to store the output (instead of fwrite). The
  267. * parameters will use fwrite() syntax, make sure to follow them. */
  268. CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11),
  269. /* Function that will be called to read the input (instead of fread). The
  270. * parameters will use fread() syntax, make sure to follow them. */
  271. CINIT(READFUNCTION, FUNCTIONPOINT, 12),
  272. /* Time-out the read operation after this amount of seconds */
  273. CINIT(TIMEOUT, LONG, 13),
  274. /* If the CURLOPT_INFILE is used, this can be used to inform libcurl about
  275. * how large the file being sent really is. That allows better error
  276. * checking and better verifies that the upload was succcessful. -1 means
  277. * unknown size. */
  278. CINIT(INFILESIZE, LONG, 14),
  279. /* POST input fields. */
  280. CINIT(POSTFIELDS, OBJECTPOINT, 15),
  281. /* Set the referer page (needed by some CGIs) */
  282. CINIT(REFERER, OBJECTPOINT, 16),
  283. /* Set the FTP PORT string (interface name, named or numerical IP address)
  284. Use i.e '-' to use default address. */
  285. CINIT(FTPPORT, OBJECTPOINT, 17),
  286. /* Set the User-Agent string (examined by some CGIs) */
  287. CINIT(USERAGENT, OBJECTPOINT, 18),
  288. /* If the download receives less than "low speed limit" bytes/second
  289. * during "low speed time" seconds, the operations is aborted.
  290. * You could i.e if you have a pretty high speed connection, abort if
  291. * it is less than 2000 bytes/sec during 20 seconds.
  292. */
  293. /* Set the "low speed limit" */
  294. CINIT(LOW_SPEED_LIMIT, LONG , 19),
  295. /* Set the "low speed time" */
  296. CINIT(LOW_SPEED_TIME, LONG, 20),
  297. /* Set the continuation offset */
  298. CINIT(RESUME_FROM, LONG, 21),
  299. /* Set cookie in request: */
  300. CINIT(COOKIE, OBJECTPOINT, 22),
  301. /* This points to a linked list of headers, struct curl_slist kind */
  302. CINIT(HTTPHEADER, OBJECTPOINT, 23),
  303. /* This points to a linked list of post entries, struct HttpPost */
  304. CINIT(HTTPPOST, OBJECTPOINT, 24),
  305. /* name of the file keeping your private SSL-certificate */
  306. CINIT(SSLCERT, OBJECTPOINT, 25),
  307. /* password for the SSL-private key, keep this for compatibility */
  308. CINIT(SSLCERTPASSWD, OBJECTPOINT, 26),
  309. /* password for the SSL private key */
  310. CINIT(SSLKEYPASSWD, OBJECTPOINT, 26),
  311. /* send TYPE parameter? */
  312. CINIT(CRLF, LONG, 27),
  313. /* send linked-list of QUOTE commands */
  314. CINIT(QUOTE, OBJECTPOINT, 28),
  315. /* send FILE * or void * to store headers to, if you use a callback it
  316. is simply passed to the callback unmodified */
  317. CINIT(WRITEHEADER, OBJECTPOINT, 29),
  318. /* point to a file to read the initial cookies from, also enables
  319. "cookie awareness" */
  320. CINIT(COOKIEFILE, OBJECTPOINT, 31),
  321. /* What version to specifly try to use.
  322. See CURL_SSLVERSION defines below. */
  323. CINIT(SSLVERSION, LONG, 32),
  324. /* What kind of HTTP time condition to use, see defines */
  325. CINIT(TIMECONDITION, LONG, 33),
  326. /* Time to use with the above condition. Specified in number of seconds
  327. since 1 Jan 1970 */
  328. CINIT(TIMEVALUE, LONG, 34),
  329. /* HTTP request, for odd commands like DELETE, TRACE and others */
  330. /* OBSOLETE DEFINE, left for tradition only */
  331. CINIT(HTTPREQUEST, OBJECTPOINT, 35),
  332. /* Custom request, for customizing the get command like
  333. HTTP: DELETE, TRACE and others
  334. FTP: to use a different list command
  335. */
  336. CINIT(CUSTOMREQUEST, OBJECTPOINT, 36),
  337. /* HTTP request, for odd commands like DELETE, TRACE and others */
  338. CINIT(STDERR, OBJECTPOINT, 37),
  339. /* 38 is not used */
  340. /* send linked-list of post-transfer QUOTE commands */
  341. CINIT(POSTQUOTE, OBJECTPOINT, 39),
  342. /* Pass a pointer to string of the output using full variable-replacement
  343. as described elsewhere. */
  344. CINIT(WRITEINFO, OBJECTPOINT, 40),
  345. /* Previous FLAG bits */
  346. CINIT(VERBOSE, LONG, 41), /* talk a lot */
  347. CINIT(HEADER, LONG, 42), /* throw the header out too */
  348. CINIT(NOPROGRESS, LONG, 43), /* shut off the progress meter */
  349. CINIT(NOBODY, LONG, 44), /* use HEAD to get http document */
  350. CINIT(FAILONERROR, LONG, 45), /* no output on http error codes >= 300 */
  351. CINIT(UPLOAD, LONG, 46), /* this is an upload */
  352. CINIT(POST, LONG, 47), /* HTTP POST method */
  353. CINIT(FTPLISTONLY, LONG, 48), /* Use NLST when listing ftp dir */
  354. CINIT(FTPAPPEND, LONG, 50), /* Append instead of overwrite on upload! */
  355. /* Specify whether to read the user+password from the .netrc or the URL.
  356. * This must be one of the CURL_NETRC_* enums below. */
  357. CINIT(NETRC, LONG, 51),
  358. CINIT(FOLLOWLOCATION, LONG, 52), /* use Location: Luke! */
  359. /* This FTPASCII name is now obsolete, to be removed, use the TRANSFERTEXT
  360. instead. It goes for more protocols than just ftp... */
  361. CINIT(FTPASCII, LONG, 53), /* use TYPE A for transfer */
  362. CINIT(TRANSFERTEXT, LONG, 53), /* transfer data in text/ASCII format */
  363. CINIT(PUT, LONG, 54), /* PUT the input file */
  364. CINIT(MUTE, LONG, 55), /* OBSOLETE OPTION, removed in 7.8 */
  365. /* Function that will be called instead of the internal progress display
  366. * function. This function should be defined as the curl_progress_callback
  367. * prototype defines. */
  368. CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56),
  369. /* Data passed to the progress callback */
  370. CINIT(PROGRESSDATA, OBJECTPOINT, 57),
  371. /* We want the referer field set automatically when following locations */
  372. CINIT(AUTOREFERER, LONG, 58),
  373. /* Port of the proxy, can be set in the proxy string as well with:
  374. "[host]:[port]" */
  375. CINIT(PROXYPORT, LONG, 59),
  376. /* size of the POST input data, if strlen() is not good to use */
  377. CINIT(POSTFIELDSIZE, LONG, 60),
  378. /* tunnel non-http operations through a HTTP proxy */
  379. CINIT(HTTPPROXYTUNNEL, LONG, 61),
  380. /* Set the interface string to use as outgoing network interface */
  381. CINIT(INTERFACE, OBJECTPOINT, 62),
  382. /* Set the krb4 security level, this also enables krb4 awareness. This is a
  383. * string, 'clear', 'safe', 'confidential' or 'private'. If the string is
  384. * set but doesn't match one of these, 'private' will be used. */
  385. CINIT(KRB4LEVEL, OBJECTPOINT, 63),
  386. /* Set if we should verify the peer in ssl handshake, set 1 to verify. */
  387. CINIT(SSL_VERIFYPEER, LONG, 64),
  388. /* The CApath or CAfile used to validate the peer certificate
  389. this option is used only if SSL_VERIFYPEER is true */
  390. CINIT(CAINFO, OBJECTPOINT, 65),
  391. /* Function pointer to replace the internal password prompt */
  392. CINIT(PASSWDFUNCTION, FUNCTIONPOINT, 66),
  393. /* Custom pointer that gets passed as first argument to the password
  394. function */
  395. CINIT(PASSWDDATA, OBJECTPOINT, 67),
  396. /* Maximum number of http redirects to follow */
  397. CINIT(MAXREDIRS, LONG, 68),
  398. /* Pass a pointer to a time_t to get a possible date of the requested
  399. document! Pass a NULL to shut it off. */
  400. CINIT(FILETIME, OBJECTPOINT, 69),
  401. /* This points to a linked list of telnet options */
  402. CINIT(TELNETOPTIONS, OBJECTPOINT, 70),
  403. /* Max amount of cached alive connections */
  404. CINIT(MAXCONNECTS, LONG, 71),
  405. /* What policy to use when closing connections when the cache is filled
  406. up */
  407. CINIT(CLOSEPOLICY, LONG, 72),
  408. /* Callback to use when CURLCLOSEPOLICY_CALLBACK is set */
  409. CINIT(CLOSEFUNCTION, FUNCTIONPOINT, 73),
  410. /* Set to explicitly use a new connection for the upcoming transfer.
  411. Do not use this unless you're absolutely sure of this, as it makes the
  412. operation slower and is less friendly for the network. */
  413. CINIT(FRESH_CONNECT, LONG, 74),
  414. /* Set to explicitly forbid the upcoming transfer's connection to be re-used
  415. when done. Do not use this unless you're absolutely sure of this, as it
  416. makes the operation slower and is less friendly for the network. */
  417. CINIT(FORBID_REUSE, LONG, 75),
  418. /* Set to a file name that contains random data for libcurl to use to
  419. seed the random engine when doing SSL connects. */
  420. CINIT(RANDOM_FILE, OBJECTPOINT, 76),
  421. /* Set to the Entropy Gathering Daemon socket pathname */
  422. CINIT(EGDSOCKET, OBJECTPOINT, 77),
  423. /* Time-out connect operations after this amount of seconds, if connects
  424. are OK within this time, then fine... This only aborts the connect
  425. phase. [Only works on unix-style/SIGALRM operating systems] */
  426. CINIT(CONNECTTIMEOUT, LONG, 78),
  427. /* Function that will be called to store headers (instead of fwrite). The
  428. * parameters will use fwrite() syntax, make sure to follow them. */
  429. CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79),
  430. /* Set this to force the HTTP request to get back to GET. Only really usable
  431. if POST, PUT or a custom request have been used first.
  432. */
  433. CINIT(HTTPGET, LONG, 80),
  434. /* Set if we should verify the Common name from the peer certificate in ssl
  435. * handshake, set 1 to check existence, 2 to ensure that it matches the
  436. * provided hostname. */
  437. CINIT(SSL_VERIFYHOST, LONG, 81),
  438. /* Specify which file name to write all known cookies in after completed
  439. operation. Set file name to "-" (dash) to make it go to stdout. */
  440. CINIT(COOKIEJAR, OBJECTPOINT, 82),
  441. /* Specify which SSL ciphers to use */
  442. CINIT(SSL_CIPHER_LIST, OBJECTPOINT, 83),
  443. /* Specify which HTTP version to use! This must be set to one of the
  444. CURL_HTTP_VERSION* enums set below. */
  445. CINIT(HTTP_VERSION, LONG, 84),
  446. /* Specificly switch on or off the FTP engine's use of the EPSV command. By
  447. default, that one will always be attempted before the more traditional
  448. PASV command. */
  449. CINIT(FTP_USE_EPSV, LONG, 85),
  450. /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */
  451. CINIT(SSLCERTTYPE, OBJECTPOINT, 86),
  452. /* name of the file keeping your private SSL-key */
  453. CINIT(SSLKEY, OBJECTPOINT, 87),
  454. /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */
  455. CINIT(SSLKEYTYPE, OBJECTPOINT, 88),
  456. /* crypto engine for the SSL-sub system */
  457. CINIT(SSLENGINE, OBJECTPOINT, 89),
  458. /* set the crypto engine for the SSL-sub system as default
  459. the param has no meaning...
  460. */
  461. CINIT(SSLENGINE_DEFAULT, LONG, 90),
  462. /* Non-zero value means to use the global dns cache */
  463. CINIT(DNS_USE_GLOBAL_CACHE, LONG, 91),
  464. /* DNS cache timeout */
  465. CINIT(DNS_CACHE_TIMEOUT, LONG, 92),
  466. /* send linked-list of pre-transfer QUOTE commands (Wesley Laxton)*/
  467. CINIT(PREQUOTE, OBJECTPOINT, 93),
  468. /* set the debug function */
  469. CINIT(DEBUGFUNCTION, FUNCTIONPOINT, 94),
  470. /* set the data for the debug function */
  471. CINIT(DEBUGDATA, OBJECTPOINT, 95),
  472. /* mark this as start of a cookie session */
  473. CINIT(COOKIESESSION, LONG, 96),
  474. /* The CApath directory used to validate the peer certificate
  475. this option is used only if SSL_VERIFYPEER is true */
  476. CINIT(CAPATH, OBJECTPOINT, 97),
  477. /* Instruct libcurl to use a smaller receive buffer */
  478. CINIT(BUFFERSIZE, LONG, 98),
  479. /* Instruct libcurl to not use any signal/alarm handlers, even when using
  480. timeouts. This option is useful for multi-threaded applications.
  481. See libcurl-the-guide for more background information. */
  482. CINIT(NOSIGNAL, LONG, 99),
  483. /* Provide a CURLShare for mutexing non-ts data */
  484. CINIT(SHARE, OBJECTPOINT, 100),
  485. /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default),
  486. CURLPROXY_SOCKS4 and CURLPROXY_SOCKS5. */
  487. CINIT(PROXYTYPE, LONG, 101),
  488. /* Set the Accept-Encoding string. Use this to tell a server you would like
  489. the response to be compressed. */
  490. CINIT(ENCODING, OBJECTPOINT, 102),
  491. /* Set pointer to private data */
  492. CINIT(PRIVATE, OBJECTPOINT, 103),
  493. /* Set aliases for HTTP 200 in the HTTP Response header */
  494. CINIT(HTTP200ALIASES, OBJECTPOINT, 104),
  495. CURLOPT_LASTENTRY /* the last unused */
  496. } CURLoption;
  497. /* two convenient "aliases" that follow the name scheme better */
  498. #define CURLOPT_WRITEDATA CURLOPT_FILE
  499. #define CURLOPT_READDATA CURLOPT_INFILE
  500. #define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER
  501. /* These enums are for use with the CURLOPT_HTTP_VERSION option. */
  502. enum {
  503. CURL_HTTP_VERSION_NONE, /* setting this means we don't care, and that we'd
  504. like the library to choose the best possible
  505. for us! */
  506. CURL_HTTP_VERSION_1_0, /* please use HTTP 1.0 in the request */
  507. CURL_HTTP_VERSION_1_1, /* please use HTTP 1.1 in the request */
  508. CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */
  509. };
  510. /* These enums are for use with the CURLOPT_NETRC option. */
  511. enum CURL_NETRC_OPTION {
  512. CURL_NETRC_IGNORED, /* The .netrc will never be read.
  513. * This is the default. */
  514. CURL_NETRC_OPTIONAL, /* A user:password in the URL will be preferred
  515. * to one in the .netrc. */
  516. CURL_NETRC_REQUIRED, /* A user:password in the URL will be ignored.
  517. * Unless one is set programmatically, the .netrc
  518. * will be queried. */
  519. CURL_NETRC_LAST
  520. };
  521. enum {
  522. CURL_SSLVERSION_DEFAULT,
  523. CURL_SSLVERSION_TLSv1,
  524. CURL_SSLVERSION_SSLv2,
  525. CURL_SSLVERSION_SSLv3,
  526. CURL_SSLVERSION_LAST /* never use, keep last */
  527. };
  528. typedef enum {
  529. CURL_TIMECOND_NONE,
  530. CURL_TIMECOND_IFMODSINCE,
  531. CURL_TIMECOND_IFUNMODSINCE,
  532. CURL_TIMECOND_LASTMOD,
  533. CURL_TIMECOND_LAST
  534. } curl_TimeCond;
  535. /* for backwards compatibility */
  536. #ifndef TIMECOND_IFMODSINCE
  537. #define TIMECOND_IFMODSINCE CURL_TIMECOND_IFMODSINCE
  538. #endif
  539. #ifndef TIMECOND_IFUNMODSINCE
  540. #define TIMECOND_IFUNMODSINCE CURL_TIMECOND_IFUNMODSINCE
  541. #endif
  542. #ifndef TIMECOND_LASTMOD
  543. #define TIMECOND_LASTMOD CURL_TIMECOND_LASTMOD
  544. #endif
  545. #ifdef __BEOS__
  546. #include <support/SupportDefs.h>
  547. #endif
  548. /* These functions are in the libcurl, they're here for portable reasons and
  549. they are used by the 'curl' client. They really should be moved to some kind
  550. of "portability library" since it has nothing to do with file transfers and
  551. might be usable to other programs...
  552. NOTE: they return TRUE if the strings match *case insensitively*.
  553. */
  554. extern int (curl_strequal)(const char *s1, const char *s2);
  555. extern int (curl_strnequal)(const char *s1, const char *s2, size_t n);
  556. #define strequal(a,b) curl_strequal(a,b)
  557. #define strnequal(a,b,c) curl_strnequal(a,b,c)
  558. /* DEPRECATED function to build formdata */
  559. int curl_formparse(char *, struct curl_httppost **,
  560. struct curl_httppost **_post);
  561. /* name is uppercase CURLFORM_<name> */
  562. #ifdef CFINIT
  563. #undef CFINIT
  564. #endif
  565. #ifdef CURL_ISOCPP
  566. #define CFINIT(name) CURLFORM_ ## name
  567. #else
  568. /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
  569. #define CFINIT(name) CURLFORM_/**/name
  570. #endif
  571. typedef enum {
  572. CFINIT(NOTHING), /********* the first one is unused ************/
  573. /* */
  574. CFINIT(COPYNAME),
  575. CFINIT(PTRNAME),
  576. CFINIT(NAMELENGTH),
  577. CFINIT(COPYCONTENTS),
  578. CFINIT(PTRCONTENTS),
  579. CFINIT(CONTENTSLENGTH),
  580. CFINIT(FILECONTENT),
  581. CFINIT(ARRAY),
  582. CFINIT(OBSOLETE),
  583. CFINIT(FILE),
  584. CFINIT(BUFFER),
  585. CFINIT(BUFFERPTR),
  586. CFINIT(BUFFERLENGTH),
  587. CFINIT(CONTENTTYPE),
  588. CFINIT(CONTENTHEADER),
  589. CFINIT(FILENAME),
  590. CFINIT(END),
  591. CFINIT(OBSOLETE2),
  592. CURLFORM_LASTENTRY /* the last unusued */
  593. } CURLformoption;
  594. #undef CFINIT /* done */
  595. /* structure to be used as parameter for CURLFORM_ARRAY */
  596. struct curl_forms {
  597. CURLformoption option;
  598. const char *value;
  599. };
  600. /* use this for multipart formpost building */
  601. /* Returns code for curl_formadd()
  602. *
  603. * Returns:
  604. * CURL_FORMADD_OK on success
  605. * CURL_FORMADD_MEMORY if the FormInfo allocation fails
  606. * CURL_FORMADD_OPTION_TWICE if one option is given twice for one Form
  607. * CURL_FORMADD_NULL if a null pointer was given for a char
  608. * CURL_FORMADD_MEMORY if the allocation of a FormInfo struct failed
  609. * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used
  610. * CURL_FORMADD_INCOMPLETE if the some FormInfo is not complete (or error)
  611. * CURL_FORMADD_MEMORY if a HttpPost struct cannot be allocated
  612. * CURL_FORMADD_MEMORY if some allocation for string copying failed.
  613. * CURL_FORMADD_ILLEGAL_ARRAY if an illegal option is used in an array
  614. *
  615. ***************************************************************************/
  616. typedef enum {
  617. CURL_FORMADD_OK, /* first, no error */
  618. CURL_FORMADD_MEMORY,
  619. CURL_FORMADD_OPTION_TWICE,
  620. CURL_FORMADD_NULL,
  621. CURL_FORMADD_UNKNOWN_OPTION,
  622. CURL_FORMADD_INCOMPLETE,
  623. CURL_FORMADD_ILLEGAL_ARRAY,
  624. CURL_FORMADD_LAST /* last */
  625. } CURLFORMcode;
  626. CURLFORMcode curl_formadd(struct curl_httppost **httppost,
  627. struct curl_httppost **last_post,
  628. ...);
  629. /* cleanup a form: */
  630. void curl_formfree(struct curl_httppost *form);
  631. /* Unix and Win32 getenv function call, this returns a malloc()'ed string that
  632. MUST be free()ed after usage is complete. */
  633. char *curl_getenv(const char *variable);
  634. /* Returns a static ascii string of the libcurl version. */
  635. char *curl_version(void);
  636. /* Escape and unescape URL encoding in strings. The functions return a new
  637. * allocated string or NULL if an error occurred. */
  638. char *curl_escape(const char *string, int length);
  639. char *curl_unescape(const char *string, int length);
  640. /* 20020912 WJM. Provide for a de-allocation in the same translation unit
  641. that did the allocation. Added in libcurl 7.10 */
  642. void curl_free(void *p);
  643. /* curl_global_init() should be invoked exactly once for each application that
  644. uses libcurl */
  645. CURLcode curl_global_init(long flags);
  646. /* curl_global_cleanup() should be invoked exactly once for each application
  647. that uses libcurl */
  648. void curl_global_cleanup(void);
  649. /* This is the version number */
  650. #define LIBCURL_VERSION "7.10.3"
  651. #define LIBCURL_VERSION_NUM 0x070a03
  652. /* linked-list structure for the CURLOPT_QUOTE option (and other) */
  653. struct curl_slist {
  654. char *data;
  655. struct curl_slist *next;
  656. };
  657. struct curl_slist *curl_slist_append(struct curl_slist *, const char *);
  658. void curl_slist_free_all(struct curl_slist *);
  659. /*
  660. * NAME curl_getdate()
  661. *
  662. * DESCRIPTION
  663. *
  664. * Returns the time, in seconds since 1 Jan 1970 of the time string given in
  665. * the first argument. The time argument in the second parameter is for cases
  666. * where the specified time is relative now, like 'two weeks' or 'tomorrow'
  667. * etc.
  668. */
  669. time_t curl_getdate(const char *p, const time_t *now);
  670. #define CURLINFO_STRING 0x100000
  671. #define CURLINFO_LONG 0x200000
  672. #define CURLINFO_DOUBLE 0x300000
  673. #define CURLINFO_MASK 0x0fffff
  674. #define CURLINFO_TYPEMASK 0xf00000
  675. typedef enum {
  676. CURLINFO_NONE, /* first, never use this */
  677. CURLINFO_EFFECTIVE_URL = CURLINFO_STRING + 1,
  678. CURLINFO_HTTP_CODE = CURLINFO_LONG + 2,
  679. CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE + 3,
  680. CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE + 4,
  681. CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5,
  682. CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6,
  683. CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE + 7,
  684. CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE + 8,
  685. CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE + 9,
  686. CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE + 10,
  687. CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11,
  688. CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12,
  689. CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13,
  690. CURLINFO_FILETIME = CURLINFO_LONG + 14,
  691. CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE + 15,
  692. CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE + 16,
  693. CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17,
  694. CURLINFO_CONTENT_TYPE = CURLINFO_STRING + 18,
  695. CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19,
  696. CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20,
  697. CURLINFO_PRIVATE = CURLINFO_STRING + 21,
  698. /* Fill in new entries here! */
  699. CURLINFO_LASTONE = 22
  700. } CURLINFO;
  701. typedef enum {
  702. CURLCLOSEPOLICY_NONE, /* first, never use this */
  703. CURLCLOSEPOLICY_OLDEST,
  704. CURLCLOSEPOLICY_LEAST_RECENTLY_USED,
  705. CURLCLOSEPOLICY_LEAST_TRAFFIC,
  706. CURLCLOSEPOLICY_SLOWEST,
  707. CURLCLOSEPOLICY_CALLBACK,
  708. CURLCLOSEPOLICY_LAST /* last, never use this */
  709. } curl_closepolicy;
  710. #define CURL_GLOBAL_SSL (1<<0)
  711. #define CURL_GLOBAL_WIN32 (1<<1)
  712. #define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)
  713. #define CURL_GLOBAL_NOTHING 0
  714. #define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL
  715. /*****************************************************************************
  716. * Setup defines, protos etc for the sharing stuff.
  717. */
  718. /* Different data locks for a single share */
  719. typedef enum {
  720. CURL_LOCK_DATA_NONE = 0,
  721. CURL_LOCK_DATA_COOKIE = 1,
  722. CURL_LOCK_DATA_DNS = 2,
  723. CURL_LOCK_DATA_SSL_SESSION = 3,
  724. CURL_LOCK_DATA_CONNECT = 4,
  725. CURL_LOCK_DATA_LAST
  726. } curl_lock_data;
  727. /* Different lock access types */
  728. typedef enum {
  729. CURL_LOCK_ACCESS_NONE = 0, /* unspecified action */
  730. CURL_LOCK_ACCESS_SHARED = 1, /* for read perhaps */
  731. CURL_LOCK_ACCESS_SINGLE = 2, /* for write perhaps */
  732. CURL_LOCK_ACCESS_LAST /* never use */
  733. } curl_lock_access;
  734. typedef void (*curl_lock_function)(CURL *handle,
  735. curl_lock_data data,
  736. curl_lock_access access,
  737. void *userptr);
  738. typedef void (*curl_unlock_function)(CURL *handle,
  739. curl_lock_data data,
  740. void *userptr);
  741. typedef void CURLSH;
  742. typedef enum {
  743. CURLSHE_OK, /* all is fine */
  744. CURLSHE_BAD_OPTION, /* 1 */
  745. CURLSHE_IN_USE, /* 2 */
  746. CURLSHE_INVALID, /* 3 */
  747. CURLSHE_LAST /* never use */
  748. } CURLSHcode;
  749. typedef enum {
  750. CURLSHOPT_NONE, /* don't use */
  751. CURLSHOPT_SHARE, /* specify a data type to share */
  752. CURLSHOPT_UNSHARE, /* specify shich data type to stop sharing */
  753. CURLSHOPT_LOCKFUNC, /* pass in a 'curl_lock_function' pointer */
  754. CURLSHOPT_UNLOCKFUNC, /* pass in a 'curl_unlock_function' pointer */
  755. CURLSHOPT_USERDATA, /* pass in a user data pointer used in the lock/unlock
  756. callback functions */
  757. CURLSHOPT_LAST /* never use */
  758. } CURLSHoption;
  759. CURLSH *curl_share_init(void);
  760. CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...);
  761. CURLSHcode curl_share_cleanup(CURLSH *);
  762. /****************************************************************************
  763. * Structures for querying information about the curl library at runtime.
  764. */
  765. typedef enum {
  766. CURLVERSION_FIRST,
  767. CURLVERSION_LAST /* never actually use this */
  768. } CURLversion;
  769. /* The 'CURLVERSION_NOW' is the symbolic name meant to be used by
  770. basicly all programs ever, that want to get version information. It is
  771. meant to be a built-in version number for what kind of struct the caller
  772. expects. If the struct ever changes, we redfine the NOW to another enum
  773. from above. */
  774. #define CURLVERSION_NOW CURLVERSION_FIRST
  775. typedef struct {
  776. CURLversion age; /* age of the returned struct */
  777. const char *version; /* LIBCURL_VERSION */
  778. unsigned int version_num; /* LIBCURL_VERSION_NUM */
  779. const char *host; /* OS/host/cpu/machine when configured */
  780. int features; /* bitmask, see defines below */
  781. char *ssl_version; /* human readable string */
  782. long ssl_version_num; /* number */
  783. const char *libz_version; /* human readable string */
  784. /* protocols is terminated by an entry with a NULL protoname */
  785. const char **protocols;
  786. } curl_version_info_data;
  787. #define CURL_VERSION_IPV6 (1<<0)
  788. #define CURL_VERSION_KERBEROS4 (1<<1)
  789. #define CURL_VERSION_SSL (1<<2)
  790. #define CURL_VERSION_LIBZ (1<<3)
  791. /* returns a pointer to a static copy of the version info struct */
  792. curl_version_info_data *curl_version_info(CURLversion);
  793. #ifdef __cplusplus
  794. }
  795. #endif
  796. /* unfortunately, the easy.h and multi.h include files need options and info
  797. stuff before they can be included! */
  798. #include "easy.h" /* nothing in curl is fun without the easy stuff */
  799. #include "multi.h"
  800. #endif /* __CURL_CURL_H */