curl.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. #ifndef __CURL_CURL_H
  2. #define __CURL_CURL_H
  3. /*****************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2002, Daniel Stenberg, <[email protected]>, et al.
  11. *
  12. * In order to be useful for every potential user, curl and libcurl are
  13. * dual-licensed under the MPL and the MIT/X-derivate licenses.
  14. *
  15. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  16. * copies of the Software, and permit persons to whom the Software is
  17. * furnished to do so, under the terms of the MPL or the MIT/X-derivate
  18. * licenses. You may pick one of these licenses.
  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 <curl/types.h>
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53. struct HttpPost {
  54. struct HttpPost *next; /* next entry in the list */
  55. char *name; /* pointer to allocated name */
  56. long namelength; /* length of name length */
  57. char *contents; /* pointer to allocated data contents */
  58. long contentslength; /* length of contents field */
  59. char *contenttype; /* Content-Type */
  60. struct curl_slist* contentheader; /* list of extra headers for this form */
  61. struct HttpPost *more; /* if one field name has more than one file, this
  62. link should link to following files */
  63. long flags; /* as defined below */
  64. #define HTTPPOST_FILENAME (1<<0) /* specified content is a file name */
  65. #define HTTPPOST_READFILE (1<<1) /* specified content is a file name */
  66. #define HTTPPOST_PTRNAME (1<<2) /* name is only stored pointer
  67. do not free in formfree */
  68. #define HTTPPOST_PTRCONTENTS (1<<3) /* contents is only stored pointer
  69. do not free in formfree */
  70. };
  71. typedef int (*curl_progress_callback)(void *clientp,
  72. double dltotal,
  73. double dlnow,
  74. double ultotal,
  75. double ulnow);
  76. typedef size_t (*curl_write_callback)(char *buffer,
  77. size_t size,
  78. size_t nitems,
  79. void *outstream);
  80. typedef size_t (*curl_read_callback)(char *buffer,
  81. size_t size,
  82. size_t nitems,
  83. void *instream);
  84. typedef int (*curl_passwd_callback)(void *clientp,
  85. const char *prompt,
  86. char *buffer,
  87. int buflen);
  88. /* All possible error codes from all sorts of curl functions. Future versions
  89. may return other values, stay prepared.
  90. Always add new return codes last. Never *EVER* remove any. The return
  91. codes must remain the same!
  92. */
  93. typedef enum {
  94. CURLE_OK = 0,
  95. CURLE_UNSUPPORTED_PROTOCOL, /* 1 */
  96. CURLE_FAILED_INIT, /* 2 */
  97. CURLE_URL_MALFORMAT, /* 3 */
  98. CURLE_URL_MALFORMAT_USER, /* 4 */
  99. CURLE_COULDNT_RESOLVE_PROXY, /* 5 */
  100. CURLE_COULDNT_RESOLVE_HOST, /* 6 */
  101. CURLE_COULDNT_CONNECT, /* 7 */
  102. CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */
  103. CURLE_FTP_ACCESS_DENIED, /* 9 */
  104. CURLE_FTP_USER_PASSWORD_INCORRECT, /* 10 */
  105. CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */
  106. CURLE_FTP_WEIRD_USER_REPLY, /* 12 */
  107. CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */
  108. CURLE_FTP_WEIRD_227_FORMAT, /* 14 */
  109. CURLE_FTP_CANT_GET_HOST, /* 15 */
  110. CURLE_FTP_CANT_RECONNECT, /* 16 */
  111. CURLE_FTP_COULDNT_SET_BINARY, /* 17 */
  112. CURLE_PARTIAL_FILE, /* 18 */
  113. CURLE_FTP_COULDNT_RETR_FILE, /* 19 */
  114. CURLE_FTP_WRITE_ERROR, /* 20 */
  115. CURLE_FTP_QUOTE_ERROR, /* 21 */
  116. CURLE_HTTP_NOT_FOUND, /* 22 */
  117. CURLE_WRITE_ERROR, /* 23 */
  118. CURLE_MALFORMAT_USER, /* 24 - user name is illegally specified */
  119. CURLE_FTP_COULDNT_STOR_FILE, /* 25 - failed FTP upload */
  120. CURLE_READ_ERROR, /* 26 - could open/read from file */
  121. CURLE_OUT_OF_MEMORY, /* 27 */
  122. CURLE_OPERATION_TIMEOUTED, /* 28 - the timeout time was reached */
  123. CURLE_FTP_COULDNT_SET_ASCII, /* 29 - TYPE A failed */
  124. CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */
  125. CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */
  126. CURLE_FTP_COULDNT_GET_SIZE, /* 32 - the SIZE command failed */
  127. CURLE_HTTP_RANGE_ERROR, /* 33 - RANGE "command" didn't work */
  128. CURLE_HTTP_POST_ERROR, /* 34 */
  129. CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */
  130. CURLE_FTP_BAD_DOWNLOAD_RESUME, /* 36 - couldn't resume download */
  131. CURLE_FILE_COULDNT_READ_FILE, /* 37 */
  132. CURLE_LDAP_CANNOT_BIND, /* 38 */
  133. CURLE_LDAP_SEARCH_FAILED, /* 39 */
  134. CURLE_LIBRARY_NOT_FOUND, /* 40 */
  135. CURLE_FUNCTION_NOT_FOUND, /* 41 */
  136. CURLE_ABORTED_BY_CALLBACK, /* 42 */
  137. CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */
  138. CURLE_BAD_CALLING_ORDER, /* 44 */
  139. CURLE_HTTP_PORT_FAILED, /* 45 - HTTP Interface operation failed */
  140. CURLE_BAD_PASSWORD_ENTERED, /* 46 - my_getpass() returns fail */
  141. CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */
  142. CURLE_UNKNOWN_TELNET_OPTION, /* 48 - User specified an unknown option */
  143. CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */
  144. CURLE_OBSOLETE, /* 50 - removed after 7.7.3 */
  145. CURLE_SSL_PEER_CERTIFICATE, /* 51 - peer's certificate wasn't ok */
  146. CURLE_GOT_NOTHING, /* 52 - when this is a specific error */
  147. CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */
  148. CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as default */
  149. CURL_LAST /* never use! */
  150. } CURLcode;
  151. /* this was the error code 50 in 7.7.3 and a few earlier versions, this
  152. is no longer used by libcurl but is instead #defined here only to not
  153. make programs break */
  154. #define CURLE_ALREADY_COMPLETE 99999
  155. /* This is just to make older programs not break: */
  156. #define CURLE_FTP_PARTIAL_FILE CURLE_PARTIAL_FILE
  157. #define CURL_ERROR_SIZE 256
  158. /* name is uppercase CURLOPT_<name>,
  159. type is one of the defined CURLOPTTYPE_<type>
  160. number is unique identifier */
  161. #ifdef CINIT
  162. #undef CINIT
  163. #endif
  164. #define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number
  165. /* long may be 32 or 64 bits, but we should never depend on anything else
  166. but 32 */
  167. #define CURLOPTTYPE_LONG 0
  168. #define CURLOPTTYPE_OBJECTPOINT 10000
  169. #define CURLOPTTYPE_FUNCTIONPOINT 20000
  170. typedef enum {
  171. CINIT(NOTHING, LONG, 0), /********* the first one is unused ************/
  172. /* This is the FILE * or void * the regular output should be written to. */
  173. CINIT(FILE, OBJECTPOINT, 1),
  174. /* The full URL to get/put */
  175. CINIT(URL, OBJECTPOINT, 2),
  176. /* Port number to connect to, if other than default. Specify the CONF_PORT
  177. flag in the CURLOPT_FLAGS to activate this */
  178. CINIT(PORT, LONG, 3),
  179. /* Name of proxy to use. Specify the CONF_PROXY flag in the CURLOPT_FLAGS to
  180. activate this */
  181. CINIT(PROXY, OBJECTPOINT, 4),
  182. /* Name and password to use when fetching. Specify the CONF_USERPWD flag in
  183. the CURLOPT_FLAGS to activate this */
  184. CINIT(USERPWD, OBJECTPOINT, 5),
  185. /* Name and password to use with Proxy. Specify the CONF_PROXYUSERPWD
  186. flag in the CURLOPT_FLAGS to activate this */
  187. CINIT(PROXYUSERPWD, OBJECTPOINT, 6),
  188. /* Range to get, specified as an ASCII string. Specify the CONF_RANGE flag
  189. in the CURLOPT_FLAGS to activate this */
  190. CINIT(RANGE, OBJECTPOINT, 7),
  191. /* not used */
  192. /* Specified file stream to upload from (use as input): */
  193. CINIT(INFILE, OBJECTPOINT, 9),
  194. /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE
  195. * bytes big. If this is not used, error messages go to stderr instead: */
  196. CINIT(ERRORBUFFER, OBJECTPOINT, 10),
  197. /* Function that will be called to store the output (instead of fwrite). The
  198. * parameters will use fwrite() syntax, make sure to follow them. */
  199. CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11),
  200. /* Function that will be called to read the input (instead of fread). The
  201. * parameters will use fread() syntax, make sure to follow them. */
  202. CINIT(READFUNCTION, FUNCTIONPOINT, 12),
  203. /* Time-out the read operation after this amount of seconds */
  204. CINIT(TIMEOUT, LONG, 13),
  205. /* If the CURLOPT_INFILE is used, this can be used to inform libcurl about
  206. * how large the file being sent really is. That allows better error
  207. * checking and better verifies that the upload was succcessful. -1 means
  208. * unknown size. */
  209. CINIT(INFILESIZE, LONG, 14),
  210. /* POST input fields. */
  211. CINIT(POSTFIELDS, OBJECTPOINT, 15),
  212. /* Set the referer page (needed by some CGIs) */
  213. CINIT(REFERER, OBJECTPOINT, 16),
  214. /* Set the FTP PORT string (interface name, named or numerical IP address)
  215. Use i.e '-' to use default address. */
  216. CINIT(FTPPORT, OBJECTPOINT, 17),
  217. /* Set the User-Agent string (examined by some CGIs) */
  218. CINIT(USERAGENT, OBJECTPOINT, 18),
  219. /* If the download receives less than "low speed limit" bytes/second
  220. * during "low speed time" seconds, the operations is aborted.
  221. * You could i.e if you have a pretty high speed connection, abort if
  222. * it is less than 2000 bytes/sec during 20 seconds.
  223. */
  224. /* Set the "low speed limit" */
  225. CINIT(LOW_SPEED_LIMIT, LONG , 19),
  226. /* Set the "low speed time" */
  227. CINIT(LOW_SPEED_TIME, LONG, 20),
  228. /* Set the continuation offset */
  229. CINIT(RESUME_FROM, LONG, 21),
  230. /* Set cookie in request: */
  231. CINIT(COOKIE, OBJECTPOINT, 22),
  232. /* This points to a linked list of headers, struct curl_slist kind */
  233. CINIT(HTTPHEADER, OBJECTPOINT, 23),
  234. /* This points to a linked list of post entries, struct HttpPost */
  235. CINIT(HTTPPOST, OBJECTPOINT, 24),
  236. /* name of the file keeping your private SSL-certificate */
  237. CINIT(SSLCERT, OBJECTPOINT, 25),
  238. /* password for the SSL-private key, keep this for compatibility */
  239. CINIT(SSLCERTPASSWD, OBJECTPOINT, 26),
  240. /* password for the SSL private key */
  241. CINIT(SSLKEYPASSWD, OBJECTPOINT, 26),
  242. /* send TYPE parameter? */
  243. CINIT(CRLF, LONG, 27),
  244. /* send linked-list of QUOTE commands */
  245. CINIT(QUOTE, OBJECTPOINT, 28),
  246. /* send FILE * or void * to store headers to, if you use a callback it
  247. is simply passed to the callback unmodified */
  248. CINIT(WRITEHEADER, OBJECTPOINT, 29),
  249. /* point to a file to read the initial cookies from, also enables
  250. "cookie awareness" */
  251. CINIT(COOKIEFILE, OBJECTPOINT, 31),
  252. /* What version to specifly try to use.
  253. See CURL_SSLVERSION defines below. */
  254. CINIT(SSLVERSION, LONG, 32),
  255. /* What kind of HTTP time condition to use, see defines */
  256. CINIT(TIMECONDITION, LONG, 33),
  257. /* Time to use with the above condition. Specified in number of seconds
  258. since 1 Jan 1970 */
  259. CINIT(TIMEVALUE, LONG, 34),
  260. /* HTTP request, for odd commands like DELETE, TRACE and others */
  261. /* OBSOLETE DEFINE, left for tradition only */
  262. CINIT(HTTPREQUEST, OBJECTPOINT, 35),
  263. /* Custom request, for customizing the get command like
  264. HTTP: DELETE, TRACE and others
  265. FTP: to use a different list command
  266. */
  267. CINIT(CUSTOMREQUEST, OBJECTPOINT, 36),
  268. /* HTTP request, for odd commands like DELETE, TRACE and others */
  269. CINIT(STDERR, OBJECTPOINT, 37),
  270. /* 38 is not used */
  271. /* send linked-list of post-transfer QUOTE commands */
  272. CINIT(POSTQUOTE, OBJECTPOINT, 39),
  273. /* Pass a pointer to string of the output using full variable-replacement
  274. as described elsewhere. */
  275. CINIT(WRITEINFO, OBJECTPOINT, 40),
  276. /* Previous FLAG bits */
  277. CINIT(VERBOSE, LONG, 41), /* talk a lot */
  278. CINIT(HEADER, LONG, 42), /* throw the header out too */
  279. CINIT(NOPROGRESS, LONG, 43), /* shut off the progress meter */
  280. CINIT(NOBODY, LONG, 44), /* use HEAD to get http document */
  281. CINIT(FAILONERROR, LONG, 45), /* no output on http error codes >= 300 */
  282. CINIT(UPLOAD, LONG, 46), /* this is an upload */
  283. CINIT(POST, LONG, 47), /* HTTP POST method */
  284. CINIT(FTPLISTONLY, LONG, 48), /* Use NLST when listing ftp dir */
  285. CINIT(FTPAPPEND, LONG, 50), /* Append instead of overwrite on upload! */
  286. CINIT(NETRC, LONG, 51), /* read user+password from .netrc */
  287. CINIT(FOLLOWLOCATION, LONG, 52), /* use Location: Luke! */
  288. /* This FTPASCII name is now obsolete, to be removed, use the TRANSFERTEXT
  289. instead. It goes for more protocols than just ftp... */
  290. CINIT(FTPASCII, LONG, 53), /* use TYPE A for transfer */
  291. CINIT(TRANSFERTEXT, LONG, 53), /* transfer data in text/ASCII format */
  292. CINIT(PUT, LONG, 54), /* PUT the input file */
  293. CINIT(MUTE, LONG, 55), /* OBSOLETE OPTION, removed in 7.8 */
  294. /* Function that will be called instead of the internal progress display
  295. * function. This function should be defined as the curl_progress_callback
  296. * prototype defines. */
  297. CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56),
  298. /* Data passed to the progress callback */
  299. CINIT(PROGRESSDATA, OBJECTPOINT, 57),
  300. /* We want the referer field set automatically when following locations */
  301. CINIT(AUTOREFERER, LONG, 58),
  302. /* Port of the proxy, can be set in the proxy string as well with:
  303. "[host]:[port]" */
  304. CINIT(PROXYPORT, LONG, 59),
  305. /* size of the POST input data, if strlen() is not good to use */
  306. CINIT(POSTFIELDSIZE, LONG, 60),
  307. /* tunnel non-http operations through a HTTP proxy */
  308. CINIT(HTTPPROXYTUNNEL, LONG, 61),
  309. /* Set the interface string to use as outgoing network interface */
  310. CINIT(INTERFACE, OBJECTPOINT, 62),
  311. /* Set the krb4 security level, this also enables krb4 awareness. This is a
  312. * string, 'clear', 'safe', 'confidential' or 'private'. If the string is
  313. * set but doesn't match one of these, 'private' will be used. */
  314. CINIT(KRB4LEVEL, OBJECTPOINT, 63),
  315. /* Set if we should verify the peer in ssl handshake, set 1 to verify. */
  316. CINIT(SSL_VERIFYPEER, LONG, 64),
  317. /* The CApath or CAfile used to validate the peer certificate
  318. this option is used only if SSL_VERIFYPEER is true */
  319. CINIT(CAINFO, OBJECTPOINT, 65),
  320. /* Function pointer to replace the internal password prompt */
  321. CINIT(PASSWDFUNCTION, FUNCTIONPOINT, 66),
  322. /* Custom pointer that gets passed as first argument to the password
  323. function */
  324. CINIT(PASSWDDATA, OBJECTPOINT, 67),
  325. /* Maximum number of http redirects to follow */
  326. CINIT(MAXREDIRS, LONG, 68),
  327. /* Pass a pointer to a time_t to get a possible date of the requested
  328. document! Pass a NULL to shut it off. */
  329. CINIT(FILETIME, OBJECTPOINT, 69),
  330. /* This points to a linked list of telnet options */
  331. CINIT(TELNETOPTIONS, OBJECTPOINT, 70),
  332. /* Max amount of cached alive connections */
  333. CINIT(MAXCONNECTS, LONG, 71),
  334. /* What policy to use when closing connections when the cache is filled
  335. up */
  336. CINIT(CLOSEPOLICY, LONG, 72),
  337. /* Callback to use when CURLCLOSEPOLICY_CALLBACK is set */
  338. CINIT(CLOSEFUNCTION, FUNCTIONPOINT, 73),
  339. /* Set to explicitly use a new connection for the upcoming transfer.
  340. Do not use this unless you're absolutely sure of this, as it makes the
  341. operation slower and is less friendly for the network. */
  342. CINIT(FRESH_CONNECT, LONG, 74),
  343. /* Set to explicitly forbid the upcoming transfer's connection to be re-used
  344. when done. Do not use this unless you're absolutely sure of this, as it
  345. makes the operation slower and is less friendly for the network. */
  346. CINIT(FORBID_REUSE, LONG, 75),
  347. /* Set to a file name that contains random data for libcurl to use to
  348. seed the random engine when doing SSL connects. */
  349. CINIT(RANDOM_FILE, OBJECTPOINT, 76),
  350. /* Set to the Entropy Gathering Daemon socket pathname */
  351. CINIT(EGDSOCKET, OBJECTPOINT, 77),
  352. /* Time-out connect operations after this amount of seconds, if connects
  353. are OK within this time, then fine... This only aborts the connect
  354. phase. [Only works on unix-style/SIGALRM operating systems] */
  355. CINIT(CONNECTTIMEOUT, LONG, 78),
  356. /* Function that will be called to store headers (instead of fwrite). The
  357. * parameters will use fwrite() syntax, make sure to follow them. */
  358. CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79),
  359. /* Set this to force the HTTP request to get back to GET. Only really usable
  360. if POST, PUT or a custom request have been used first.
  361. */
  362. CINIT(HTTPGET, LONG, 80),
  363. /* Set if we should verify the Common name from the peer certificate in ssl
  364. * handshake, set 1 to check existence, 2 to ensure that it matches the
  365. * provided hostname. */
  366. CINIT(SSL_VERIFYHOST, LONG, 81),
  367. /* Specify which file name to write all known cookies in after completed
  368. operation. Set file name to "-" (dash) to make it go to stdout. */
  369. CINIT(COOKIEJAR, OBJECTPOINT, 82),
  370. /* Specify which SSL ciphers to use */
  371. CINIT(SSL_CIPHER_LIST, OBJECTPOINT, 83),
  372. /* Specify which HTTP version to use! This must be set to one of the
  373. CURL_HTTP_VERSION* enums set below. */
  374. CINIT(HTTP_VERSION, LONG, 84),
  375. /* Specificly switch on or off the FTP engine's use of the EPSV command. By
  376. default, that one will always be attempted before the more traditional
  377. PASV command. */
  378. CINIT(FTP_USE_EPSV, LONG, 85),
  379. /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */
  380. CINIT(SSLCERTTYPE, OBJECTPOINT, 86),
  381. /* name of the file keeping your private SSL-key */
  382. CINIT(SSLKEY, OBJECTPOINT, 87),
  383. /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */
  384. CINIT(SSLKEYTYPE, OBJECTPOINT, 88),
  385. /* crypto engine for the SSL-sub system */
  386. CINIT(SSLENGINE, OBJECTPOINT, 89),
  387. /* set the crypto engine for the SSL-sub system as default
  388. the param has no meaning...
  389. */
  390. CINIT(SSLENGINE_DEFAULT, LONG, 90),
  391. /* Non-zero value means to use the global dns cache */
  392. CINIT(DNS_USE_GLOBAL_CACHE, LONG, 91),
  393. /* DNS cache timeout */
  394. CINIT(DNS_CACHE_TIMEOUT, LONG, 92),
  395. /* send linked-list of pre-transfer QUOTE commands (Wesley Laxton)*/
  396. CINIT(PREQUOTE, OBJECTPOINT, 93),
  397. CURLOPT_LASTENTRY /* the last unusued */
  398. } CURLoption;
  399. /* These enums are for use with the CURLOPT_HTTP_VERSION option. */
  400. enum {
  401. CURL_HTTP_VERSION_NONE, /* setting this means we don't care, and that we'd
  402. like the library to choose the best possible
  403. for us! */
  404. CURL_HTTP_VERSION_1_0, /* please use HTTP 1.0 in the request */
  405. CURL_HTTP_VERSION_1_1, /* please use HTTP 1.1 in the request */
  406. CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */
  407. };
  408. enum {
  409. CURL_SSLVERSION_DEFAULT,
  410. CURL_SSLVERSION_TLSv1,
  411. CURL_SSLVERSION_SSLv2,
  412. CURL_SSLVERSION_SSLv3,
  413. CURL_SSLVERSION_LAST /* never use, keep last */
  414. };
  415. typedef enum {
  416. TIMECOND_NONE,
  417. TIMECOND_IFMODSINCE,
  418. TIMECOND_IFUNMODSINCE,
  419. TIMECOND_LASTMOD,
  420. TIMECOND_LAST
  421. } curl_TimeCond;
  422. #ifdef __BEOS__
  423. #include <support/SupportDefs.h>
  424. #endif
  425. /* These functions are in the libcurl, they're here for portable reasons and
  426. they are used by the 'curl' client. They really should be moved to some kind
  427. of "portability library" since it has nothing to do with file transfers and
  428. might be usable to other programs...
  429. NOTE: they return TRUE if the strings match *case insensitively*.
  430. */
  431. extern int (curl_strequal)(const char *s1, const char *s2);
  432. extern int (curl_strnequal)(const char *s1, const char *s2, size_t n);
  433. #define strequal(a,b) curl_strequal(a,b)
  434. #define strnequal(a,b,c) curl_strnequal(a,b,c)
  435. /* external form function */
  436. int curl_formparse(char *string,
  437. struct HttpPost **httppost,
  438. struct HttpPost **last_post);
  439. /* name is uppercase CURLFORM_<name> */
  440. #ifdef CFINIT
  441. #undef CFINIT
  442. #endif
  443. #define CFINIT(name) CURLFORM_ ## name
  444. typedef enum {
  445. CFINIT(NOTHING), /********* the first one is unused ************/
  446. /* */
  447. CFINIT(COPYNAME),
  448. CFINIT(PTRNAME),
  449. CFINIT(NAMELENGTH),
  450. CFINIT(COPYCONTENTS),
  451. CFINIT(PTRCONTENTS),
  452. CFINIT(CONTENTSLENGTH),
  453. CFINIT(FILECONTENT),
  454. CFINIT(ARRAY),
  455. CFINIT(ARRAY_START), /* below are the options allowed within a array */
  456. CFINIT(FILE),
  457. CFINIT(CONTENTTYPE),
  458. CFINIT(CONTENTHEADER),
  459. CFINIT(END),
  460. CFINIT(ARRAY_END), /* up are the options allowed within a array */
  461. CURLFORM_LASTENTRY /* the last unusued */
  462. } CURLformoption;
  463. /* structure to be used as parameter for CURLFORM_ARRAY */
  464. struct curl_forms {
  465. CURLformoption option;
  466. const char *value;
  467. };
  468. /* new external form function */
  469. int curl_formadd(struct HttpPost **httppost,
  470. struct HttpPost **last_post,
  471. ...);
  472. /* cleanup a form: */
  473. void curl_formfree(struct HttpPost *form);
  474. /* Unix and Win32 getenv function call, this returns a malloc()'ed string that
  475. MUST be free()ed after usage is complete. */
  476. char *curl_getenv(const char *variable);
  477. /* Returns a static ascii string of the libcurl version. */
  478. char *curl_version(void);
  479. /* Escape and unescape URL encoding in strings. The functions return a new
  480. * allocated string or NULL if an error occurred. */
  481. char *curl_escape(const char *string, int length);
  482. char *curl_unescape(const char *string, int length);
  483. /* curl_global_init() should be invoked exactly once for each application that
  484. uses libcurl */
  485. CURLcode curl_global_init(long flags);
  486. /* curl_global_cleanup() should be invoked exactly once for each application
  487. that uses libcurl */
  488. void curl_global_cleanup(void);
  489. /* This is the version number */
  490. #define LIBCURL_VERSION "7.9.5"
  491. #define LIBCURL_VERSION_NUM 0x070905
  492. /* linked-list structure for the CURLOPT_QUOTE option (and other) */
  493. struct curl_slist {
  494. char *data;
  495. struct curl_slist *next;
  496. };
  497. struct curl_slist *curl_slist_append(struct curl_slist *, const char *);
  498. void curl_slist_free_all(struct curl_slist *);
  499. /*
  500. * NAME curl_getdate()
  501. *
  502. * DESCRIPTION
  503. *
  504. * Returns the time, in seconds since 1 Jan 1970 of the time string given in
  505. * the first argument. The time argument in the second parameter is for cases
  506. * where the specified time is relative now, like 'two weeks' or 'tomorrow'
  507. * etc.
  508. */
  509. time_t curl_getdate(const char *p, const time_t *now);
  510. #define CURLINFO_STRING 0x100000
  511. #define CURLINFO_LONG 0x200000
  512. #define CURLINFO_DOUBLE 0x300000
  513. #define CURLINFO_MASK 0x0fffff
  514. #define CURLINFO_TYPEMASK 0xf00000
  515. typedef enum {
  516. CURLINFO_NONE, /* first, never use this */
  517. CURLINFO_EFFECTIVE_URL = CURLINFO_STRING + 1,
  518. CURLINFO_HTTP_CODE = CURLINFO_LONG + 2,
  519. CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE + 3,
  520. CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE + 4,
  521. CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5,
  522. CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6,
  523. CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE + 7,
  524. CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE + 8,
  525. CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE + 9,
  526. CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE + 10,
  527. CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11,
  528. CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12,
  529. CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13,
  530. CURLINFO_FILETIME = CURLINFO_LONG + 14,
  531. CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE + 15,
  532. CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE + 16,
  533. CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17,
  534. CURLINFO_CONTENT_TYPE = CURLINFO_STRING + 18,
  535. /* Fill in new entries here! */
  536. CURLINFO_LASTONE = 19
  537. } CURLINFO;
  538. /* unfortunately, the easy.h include file needs the options and info stuff
  539. before it can be included! */
  540. #include <curl/easy.h> /* nothing in curl is fun without the easy stuff */
  541. typedef enum {
  542. CURLCLOSEPOLICY_NONE, /* first, never use this */
  543. CURLCLOSEPOLICY_OLDEST,
  544. CURLCLOSEPOLICY_LEAST_RECENTLY_USED,
  545. CURLCLOSEPOLICY_LEAST_TRAFFIC,
  546. CURLCLOSEPOLICY_SLOWEST,
  547. CURLCLOSEPOLICY_CALLBACK,
  548. CURLCLOSEPOLICY_LAST /* last, never use this */
  549. } curl_closepolicy;
  550. #define CURL_GLOBAL_SSL (1<<0)
  551. #define CURL_GLOBAL_WIN32 (1<<1)
  552. #define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)
  553. #define CURL_GLOBAL_NOTHING 0
  554. #define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL
  555. #ifdef __cplusplus
  556. }
  557. #endif
  558. #endif /* __CURL_CURL_H */