curl.h 34 KB

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