当前位置:   article > 正文

转一个lua封装libcurl的代码

libcurl lua
  1. --curl.h from libcurl 7.46.0
  2. local ffi = require'ffi'
  3. if ffi.abi'win' then
  4. if ffi.abi'64bit' then
  5. ffi.cdef'typedef uint64_t UINT_PTR;'
  6. else
  7. ffi.cdef'typedef uint32_t UINT_PTR;'
  8. end
  9. ffi.cdef[[
  10. typedef UINT_PTR SOCKET;
  11. typedef SOCKET curl_socket_t;
  12. ]]
  13. else
  14. ffi.cdef'typedef int curl_socket_t;'
  15. end
  16. ffi.cdef[[
  17. // curl.h --------------------------------------------------------------------
  18. typedef struct CURL CURL;
  19. typedef void curl_fd_set;
  20. typedef long long curl_off_t;
  21. typedef long time_t;
  22. typedef enum {
  23. CURLOPT_WRITEDATA = 10000 + 1,
  24. CURLOPT_URL = 10000 + 2,
  25. CURLOPT_PORT = 0 + 3,
  26. CURLOPT_PROXY = 10000 + 4,
  27. CURLOPT_USERPWD = 10000 + 5,
  28. CURLOPT_PROXYUSERPWD = 10000 + 6,
  29. CURLOPT_RANGE = 10000 + 7,
  30. CURLOPT_READDATA = 10000 + 9,
  31. CURLOPT_ERRORBUFFER = 10000 + 10,
  32. CURLOPT_WRITEFUNCTION = 20000 + 11,
  33. CURLOPT_READFUNCTION = 20000 + 12,
  34. CURLOPT_TIMEOUT = 0 + 13,
  35. // CURLOPT_INFILESIZE = 0 + 14,
  36. CURLOPT_POSTFIELDS = 10000 + 15,
  37. CURLOPT_REFERER = 10000 + 16,
  38. CURLOPT_FTPPORT = 10000 + 17,
  39. CURLOPT_USERAGENT = 10000 + 18,
  40. CURLOPT_LOW_SPEED_LIMIT = 0 + 19,
  41. CURLOPT_LOW_SPEED_TIME = 0 + 20,
  42. // CURLOPT_RESUME_FROM = 0 + 21,
  43. CURLOPT_COOKIE = 10000 + 22,
  44. CURLOPT_HTTPHEADER = 10000 + 23,
  45. CURLOPT_HTTPPOST = 10000 + 24,
  46. CURLOPT_SSLCERT = 10000 + 25,
  47. CURLOPT_KEYPASSWD = 10000 + 26,
  48. CURLOPT_CRLF = 0 + 27,
  49. CURLOPT_QUOTE = 10000 + 28,
  50. CURLOPT_HEADERDATA = 10000 + 29,
  51. CURLOPT_COOKIEFILE = 10000 + 31,
  52. CURLOPT_SSLVERSION = 0 + 32,
  53. CURLOPT_TIMECONDITION = 0 + 33,
  54. CURLOPT_TIMEVALUE = 0 + 34,
  55. CURLOPT_CUSTOMREQUEST = 10000 + 36,
  56. CURLOPT_STDERR = 10000 + 37,
  57. CURLOPT_POSTQUOTE = 10000 + 39,
  58. CURLOPT_OBSOLETE40 = 10000 + 40,
  59. CURLOPT_VERBOSE = 0 + 41,
  60. CURLOPT_HEADER = 0 + 42,
  61. CURLOPT_NOPROGRESS = 0 + 43,
  62. CURLOPT_NOBODY = 0 + 44,
  63. CURLOPT_FAILONERROR = 0 + 45,
  64. CURLOPT_UPLOAD = 0 + 46,
  65. CURLOPT_POST = 0 + 47,
  66. CURLOPT_DIRLISTONLY = 0 + 48,
  67. CURLOPT_APPEND = 0 + 50,
  68. CURLOPT_NETRC = 0 + 51,
  69. CURLOPT_FOLLOWLOCATION = 0 + 52,
  70. CURLOPT_TRANSFERTEXT = 0 + 53,
  71. CURLOPT_PUT = 0 + 54,
  72. CURLOPT_PROGRESSFUNCTION = 20000 + 56,
  73. CURLOPT_PROGRESSDATA = 10000 + 57,
  74. CURLOPT_XFERINFODATA = CURLOPT_PROGRESSDATA,
  75. CURLOPT_AUTOREFERER = 0 + 58,
  76. CURLOPT_PROXYPORT = 0 + 59,
  77. // CURLOPT_POSTFIELDSIZE = 0 + 60,
  78. CURLOPT_HTTPPROXYTUNNEL = 0 + 61,
  79. CURLOPT_INTERFACE = 10000 + 62,
  80. CURLOPT_KRBLEVEL = 10000 + 63,
  81. CURLOPT_SSL_VERIFYPEER = 0 + 64,
  82. CURLOPT_CAINFO = 10000 + 65,
  83. CURLOPT_MAXREDIRS = 0 + 68,
  84. CURLOPT_FILETIME = 0 + 69,
  85. CURLOPT_TELNETOPTIONS = 10000 + 70,
  86. CURLOPT_MAXCONNECTS = 0 + 71,
  87. CURLOPT_OBSOLETE72 = 0 + 72,
  88. CURLOPT_FRESH_CONNECT = 0 + 74,
  89. CURLOPT_FORBID_REUSE = 0 + 75,
  90. CURLOPT_RANDOM_FILE = 10000 + 76,
  91. CURLOPT_EGDSOCKET = 10000 + 77,
  92. CURLOPT_CONNECTTIMEOUT = 0 + 78,
  93. CURLOPT_HEADERFUNCTION = 20000 + 79,
  94. CURLOPT_HTTPGET = 0 + 80,
  95. CURLOPT_SSL_VERIFYHOST = 0 + 81,
  96. CURLOPT_COOKIEJAR = 10000 + 82,
  97. CURLOPT_SSL_CIPHER_LIST = 10000 + 83,
  98. CURLOPT_HTTP_VERSION = 0 + 84,
  99. CURLOPT_FTP_USE_EPSV = 0 + 85,
  100. CURLOPT_SSLCERTTYPE = 10000 + 86,
  101. CURLOPT_SSLKEY = 10000 + 87,
  102. CURLOPT_SSLKEYTYPE = 10000 + 88,
  103. CURLOPT_SSLENGINE = 10000 + 89,
  104. CURLOPT_SSLENGINE_DEFAULT = 0 + 90,
  105. CURLOPT_DNS_USE_GLOBAL_CACHE = 0 + 91,
  106. CURLOPT_DNS_CACHE_TIMEOUT = 0 + 92,
  107. CURLOPT_PREQUOTE = 10000 + 93,
  108. CURLOPT_DEBUGFUNCTION = 20000 + 94,
  109. CURLOPT_DEBUGDATA = 10000 + 95,
  110. CURLOPT_COOKIESESSION = 0 + 96,
  111. CURLOPT_CAPATH = 10000 + 97,
  112. CURLOPT_BUFFERSIZE = 0 + 98,
  113. CURLOPT_NOSIGNAL = 0 + 99,
  114. CURLOPT_SHARE = 10000 + 100,
  115. CURLOPT_PROXYTYPE = 0 + 101,
  116. CURLOPT_ACCEPT_ENCODING = 10000 + 102,
  117. CURLOPT_PRIVATE = 10000 + 103,
  118. CURLOPT_HTTP200ALIASES = 10000 + 104,
  119. CURLOPT_UNRESTRICTED_AUTH = 0 + 105,
  120. CURLOPT_FTP_USE_EPRT = 0 + 106,
  121. CURLOPT_HTTPAUTH = 0 + 107,
  122. CURLOPT_SSL_CTX_FUNCTION = 20000 + 108,
  123. CURLOPT_SSL_CTX_DATA = 10000 + 109,
  124. CURLOPT_FTP_CREATE_MISSING_DIRS = 0 + 110,
  125. CURLOPT_PROXYAUTH = 0 + 111,
  126. CURLOPT_FTP_RESPONSE_TIMEOUT = 0 + 112,
  127. CURLOPT_SERVER_RESPONSE_TIMEOUT = CURLOPT_FTP_RESPONSE_TIMEOUT,
  128. CURLOPT_IPRESOLVE = 0 + 113,
  129. // CURLOPT_MAXFILESIZE = 0 + 114,
  130. CURLOPT_INFILESIZE = 30000 + 115, // was *_LARGE
  131. CURLOPT_RESUME_FROM = 30000 + 116, // was *_LARGE
  132. CURLOPT_MAXFILESIZE = 30000 + 117, // was *_LARGE
  133. CURLOPT_NETRC_FILE = 10000 + 118,
  134. CURLOPT_USE_SSL = 0 + 119,
  135. CURLOPT_POSTFIELDSIZE = 30000 + 120, // was *_LARGE
  136. CURLOPT_TCP_NODELAY = 0 + 121,
  137. CURLOPT_FTPSSLAUTH = 0 + 129,
  138. CURLOPT_IOCTLFUNCTION = 20000 + 130,
  139. CURLOPT_IOCTLDATA = 10000 + 131,
  140. CURLOPT_FTP_ACCOUNT = 10000 + 134,
  141. CURLOPT_COOKIELIST = 10000 + 135,
  142. CURLOPT_IGNORE_CONTENT_LENGTH = 0 + 136,
  143. CURLOPT_FTP_SKIP_PASV_IP = 0 + 137,
  144. CURLOPT_FTP_FILEMETHOD = 0 + 138,
  145. CURLOPT_LOCALPORT = 0 + 139,
  146. CURLOPT_LOCALPORTRANGE = 0 + 140,
  147. CURLOPT_CONNECT_ONLY = 0 + 141,
  148. CURLOPT_CONV_FROM_NETWORK_FUNCTION = 20000 + 142,
  149. CURLOPT_CONV_TO_NETWORK_FUNCTION = 20000 + 143,
  150. CURLOPT_CONV_FROM_UTF8_FUNCTION = 20000 + 144,
  151. CURLOPT_MAX_SEND_SPEED = 30000 + 145, // was *_LARGE
  152. CURLOPT_MAX_RECV_SPEED = 30000 + 146, // was *_LARGE
  153. CURLOPT_FTP_ALTERNATIVE_TO_USER = 10000 + 147,
  154. CURLOPT_SOCKOPTFUNCTION = 20000 + 148,
  155. CURLOPT_SOCKOPTDATA = 10000 + 149,
  156. CURLOPT_SSL_SESSIONID_CACHE = 0 + 150,
  157. CURLOPT_SSH_AUTH_TYPES = 0 + 151,
  158. CURLOPT_SSH_PUBLIC_KEYFILE = 10000 + 152,
  159. CURLOPT_SSH_PRIVATE_KEYFILE = 10000 + 153,
  160. CURLOPT_FTP_SSL_CCC = 0 + 154,
  161. CURLOPT_TIMEOUT_MS = 0 + 155,
  162. CURLOPT_CONNECTTIMEOUT_MS = 0 + 156,
  163. CURLOPT_HTTP_TRANSFER_DECODING = 0 + 157,
  164. CURLOPT_HTTP_CONTENT_DECODING = 0 + 158,
  165. CURLOPT_NEW_FILE_PERMS = 0 + 159,
  166. CURLOPT_NEW_DIRECTORY_PERMS = 0 + 160,
  167. CURLOPT_POSTREDIR = 0 + 161,
  168. CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 = 10000 + 162,
  169. CURLOPT_OPENSOCKETFUNCTION = 20000 + 163,
  170. CURLOPT_OPENSOCKETDATA = 10000 + 164,
  171. CURLOPT_COPYPOSTFIELDS = 10000 + 165,
  172. CURLOPT_PROXY_TRANSFER_MODE = 0 + 166,
  173. CURLOPT_SEEKFUNCTION = 20000 + 167,
  174. CURLOPT_SEEKDATA = 10000 + 168,
  175. CURLOPT_CRLFILE = 10000 + 169,
  176. CURLOPT_ISSUERCERT = 10000 + 170,
  177. CURLOPT_ADDRESS_SCOPE = 0 + 171,
  178. CURLOPT_CERTINFO = 0 + 172,
  179. CURLOPT_USERNAME = 10000 + 173,
  180. CURLOPT_PASSWORD = 10000 + 174,
  181. CURLOPT_PROXYUSERNAME = 10000 + 175,
  182. CURLOPT_PROXYPASSWORD = 10000 + 176,
  183. CURLOPT_NOPROXY = 10000 + 177,
  184. CURLOPT_TFTP_BLKSIZE = 0 + 178,
  185. CURLOPT_SOCKS5_GSSAPI_SERVICE = 10000 + 179,
  186. CURLOPT_SOCKS5_GSSAPI_NEC = 0 + 180,
  187. CURLOPT_PROTOCOLS = 0 + 181,
  188. CURLOPT_REDIR_PROTOCOLS = 0 + 182,
  189. CURLOPT_SSH_KNOWNHOSTS = 10000 + 183,
  190. CURLOPT_SSH_KEYFUNCTION = 20000 + 184,
  191. CURLOPT_SSH_KEYDATA = 10000 + 185,
  192. CURLOPT_MAIL_FROM = 10000 + 186,
  193. CURLOPT_MAIL_RCPT = 10000 + 187,
  194. CURLOPT_FTP_USE_PRET = 0 + 188,
  195. CURLOPT_RTSP_REQUEST = 0 + 189,
  196. CURLOPT_RTSP_SESSION_ID = 10000 + 190,
  197. CURLOPT_RTSP_STREAM_URI = 10000 + 191,
  198. CURLOPT_RTSP_TRANSPORT = 10000 + 192,
  199. CURLOPT_RTSP_CLIENT_CSEQ = 0 + 193,
  200. CURLOPT_RTSP_SERVER_CSEQ = 0 + 194,
  201. CURLOPT_INTERLEAVEDATA = 10000 + 195,
  202. CURLOPT_INTERLEAVEFUNCTION = 20000 + 196,
  203. CURLOPT_WILDCARDMATCH = 0 + 197,
  204. CURLOPT_CHUNK_BGN_FUNCTION = 20000 + 198,
  205. CURLOPT_CHUNK_END_FUNCTION = 20000 + 199,
  206. CURLOPT_FNMATCH_FUNCTION = 20000 + 200,
  207. CURLOPT_CHUNK_DATA = 10000 + 201,
  208. CURLOPT_FNMATCH_DATA = 10000 + 202,
  209. CURLOPT_RESOLVE = 10000 + 203,
  210. CURLOPT_TLSAUTH_USERNAME = 10000 + 204,
  211. CURLOPT_TLSAUTH_PASSWORD = 10000 + 205,
  212. CURLOPT_TLSAUTH_TYPE = 10000 + 206,
  213. CURLOPT_TRANSFER_ENCODING = 0 + 207,
  214. CURLOPT_CLOSESOCKETFUNCTION = 20000 + 208,
  215. CURLOPT_CLOSESOCKETDATA = 10000 + 209,
  216. CURLOPT_GSSAPI_DELEGATION = 0 + 210,
  217. CURLOPT_DNS_SERVERS = 10000 + 211,
  218. CURLOPT_ACCEPTTIMEOUT_MS = 0 + 212,
  219. CURLOPT_TCP_KEEPALIVE = 0 + 213,
  220. CURLOPT_TCP_KEEPIDLE = 0 + 214,
  221. CURLOPT_TCP_KEEPINTVL = 0 + 215,
  222. CURLOPT_SSL_OPTIONS = 0 + 216,
  223. CURLOPT_MAIL_AUTH = 10000 + 217,
  224. CURLOPT_SASL_IR = 0 + 218,
  225. CURLOPT_XFERINFOFUNCTION = 20000 + 219,
  226. CURLOPT_XOAUTH2_BEARER = 10000 + 220,
  227. CURLOPT_DNS_INTERFACE = 10000 + 221,
  228. CURLOPT_DNS_LOCAL_IP4 = 10000 + 222,
  229. CURLOPT_DNS_LOCAL_IP6 = 10000 + 223,
  230. CURLOPT_LOGIN_OPTIONS = 10000 + 224,
  231. CURLOPT_SSL_ENABLE_NPN = 0 + 225,
  232. CURLOPT_SSL_ENABLE_ALPN = 0 + 226,
  233. CURLOPT_EXPECT_100_TIMEOUT_MS = 0 + 227,
  234. CURLOPT_PROXYHEADER = 10000 + 228,
  235. CURLOPT_HEADEROPT = 0 + 229,
  236. CURLOPT_PINNEDPUBLICKEY = 10000 + 230,
  237. CURLOPT_UNIX_SOCKET_PATH = 10000 + 231,
  238. CURLOPT_SSL_VERIFYSTATUS = 0 + 232,
  239. CURLOPT_SSL_FALSESTART = 0 + 233,
  240. CURLOPT_PATH_AS_IS = 0 + 234,
  241. CURLOPT_PROXY_SERVICE_NAME = 10000 + 235,
  242. CURLOPT_SERVICE_NAME = 10000 + 236,
  243. CURLOPT_PIPEWAIT = 0 + 237,
  244. CURLOPT_DEFAULT_PROTOCOL = 10000 + 238,
  245. CURLOPT_LASTENTRY
  246. } CURLoption;
  247. enum {
  248. CURLOPT_POST301 = CURLOPT_POSTREDIR,
  249. CURLOPT_SSLKEYPASSWD = CURLOPT_KEYPASSWD,
  250. CURLOPT_FTPAPPEND = CURLOPT_APPEND,
  251. CURLOPT_FTPLISTONLY = CURLOPT_DIRLISTONLY,
  252. CURLOPT_FTP_SSL = CURLOPT_USE_SSL,
  253. CURLOPT_SSLCERTPASSWD = CURLOPT_KEYPASSWD,
  254. CURLOPT_KRB4LEVEL = CURLOPT_KRBLEVEL,
  255. CURL_IPRESOLVE_WHATEVER = 0,
  256. CURL_IPRESOLVE_V4 = 1,
  257. CURL_IPRESOLVE_V6 = 2,
  258. CURLOPT_RTSPHEADER = CURLOPT_HTTPHEADER,
  259. };
  260. enum {
  261. CURL_HTTPPOST_FILENAME = (1<<0),
  262. CURL_HTTPPOST_READFILE = (1<<1),
  263. CURL_HTTPPOST_PTRNAME = (1<<2),
  264. CURL_HTTPPOST_PTRCONTENTS = (1<<3),
  265. CURL_HTTPPOST_BUFFER = (1<<4),
  266. CURL_HTTPPOST_PTRBUFFER = (1<<5),
  267. CURL_HTTPPOST_CALLBACK = (1<<6),
  268. CURL_HTTPPOST_LARGE = (1<<7),
  269. };
  270. struct curl_httppost {
  271. struct curl_httppost *next;
  272. char *name;
  273. long namelength;
  274. char *contents;
  275. long contentslength;
  276. char *buffer;
  277. long bufferlength;
  278. char *contenttype;
  279. struct curl_slist* contentheader;
  280. struct curl_httppost *more;
  281. long flags;
  282. char *showfilename;
  283. void *userp;
  284. curl_off_t contentlen;
  285. };
  286. typedef int (*curl_progress_callback)(void *clientp,
  287. double dltotal,
  288. double dlnow,
  289. double ultotal,
  290. double ulnow);
  291. typedef int (*curl_xferinfo_callback)(void *clientp,
  292. curl_off_t dltotal,
  293. curl_off_t dlnow,
  294. curl_off_t ultotal,
  295. curl_off_t ulnow);
  296. enum {
  297. CURL_MAX_WRITE_SIZE = 16384,
  298. CURL_MAX_HTTP_HEADER = (100*1024),
  299. CURL_WRITEFUNC_PAUSE = 0x10000001,
  300. };
  301. typedef size_t (*curl_write_callback)(char *buffer,
  302. size_t size,
  303. size_t nitems,
  304. void *outstream);
  305. typedef enum {
  306. CURLFILETYPE_FILE = 0,
  307. CURLFILETYPE_DIRECTORY,
  308. CURLFILETYPE_SYMLINK,
  309. CURLFILETYPE_DEVICE_BLOCK,
  310. CURLFILETYPE_DEVICE_CHAR,
  311. CURLFILETYPE_NAMEDPIPE,
  312. CURLFILETYPE_SOCKET,
  313. CURLFILETYPE_DOOR,
  314. CURLFILETYPE_UNKNOWN
  315. } curlfiletype;
  316. enum {
  317. CURLFINFOFLAG_KNOWN_FILENAME = (1<<0),
  318. CURLFINFOFLAG_KNOWN_FILETYPE = (1<<1),
  319. CURLFINFOFLAG_KNOWN_TIME = (1<<2),
  320. CURLFINFOFLAG_KNOWN_PERM = (1<<3),
  321. CURLFINFOFLAG_KNOWN_UID = (1<<4),
  322. CURLFINFOFLAG_KNOWN_GID = (1<<5),
  323. CURLFINFOFLAG_KNOWN_SIZE = (1<<6),
  324. CURLFINFOFLAG_KNOWN_HLINKCOUNT = (1<<7),
  325. };
  326. struct curl_fileinfo {
  327. char *filename;
  328. curlfiletype filetype;
  329. time_t time;
  330. unsigned int perm;
  331. int uid;
  332. int gid;
  333. curl_off_t size;
  334. long int hardlinks;
  335. struct {
  336. char *time;
  337. char *perm;
  338. char *user;
  339. char *group;
  340. char *target;
  341. } strings;
  342. unsigned int flags;
  343. char * b_data;
  344. size_t b_size;
  345. size_t b_used;
  346. };
  347. enum {
  348. CURL_CHUNK_BGN_FUNC_OK = 0,
  349. CURL_CHUNK_BGN_FUNC_FAIL = 1,
  350. CURL_CHUNK_BGN_FUNC_SKIP = 2,
  351. };
  352. typedef long (*curl_chunk_bgn_callback)(const void *transfer_info,
  353. void *ptr,
  354. int remains);
  355. enum {
  356. CURL_CHUNK_END_FUNC_OK = 0,
  357. CURL_CHUNK_END_FUNC_FAIL = 1,
  358. };
  359. typedef long (*curl_chunk_end_callback)(void *ptr);
  360. enum {
  361. CURL_FNMATCHFUNC_MATCH = 0,
  362. CURL_FNMATCHFUNC_NOMATCH = 1,
  363. CURL_FNMATCHFUNC_FAIL = 2,
  364. };
  365. typedef int (*curl_fnmatch_callback)(void *ptr,
  366. const char *pattern,
  367. const char *string);
  368. enum {
  369. CURL_SEEKFUNC_OK = 0,
  370. CURL_SEEKFUNC_FAIL = 1,
  371. CURL_SEEKFUNC_CANTSEEK = 2,
  372. };
  373. typedef int (*curl_seek_callback)(void *instream,
  374. curl_off_t offset,
  375. int origin);
  376. enum {
  377. CURL_READFUNC_ABORT = 0x10000000,
  378. CURL_READFUNC_PAUSE = 0x10000001,
  379. };
  380. typedef size_t (*curl_read_callback)(char *buffer,
  381. size_t size,
  382. size_t nitems,
  383. void *instream);
  384. typedef enum {
  385. CURLSOCKTYPE_IPCXN,
  386. CURLSOCKTYPE_ACCEPT,
  387. CURLSOCKTYPE_LAST
  388. } curlsocktype;
  389. enum {
  390. CURL_SOCKOPT_OK = 0,
  391. CURL_SOCKOPT_ERROR = 1,
  392. CURL_SOCKOPT_ALREADY_CONNECTED = 2,
  393. };
  394. typedef int (*curl_sockopt_callback)(void *clientp,
  395. curl_socket_t curlfd,
  396. curlsocktype purpose);
  397. struct curl_sockaddr {
  398. int family;
  399. int socktype;
  400. int protocol;
  401. unsigned int addrlen;
  402. };
  403. typedef curl_socket_t
  404. (*curl_opensocket_callback)(void *clientp,
  405. curlsocktype purpose,
  406. struct curl_sockaddr *address);
  407. typedef int
  408. (*curl_closesocket_callback)(void *clientp, curl_socket_t item);
  409. typedef enum {
  410. CURLIOE_OK,
  411. CURLIOE_UNKNOWNCMD,
  412. CURLIOE_FAILRESTART,
  413. CURLIOE_LAST
  414. } curlioerr;
  415. typedef enum {
  416. CURLIOCMD_NOP,
  417. CURLIOCMD_RESTARTREAD,
  418. CURLIOCMD_LAST
  419. } curliocmd;
  420. typedef curlioerr (*curl_ioctl_callback)(CURL *handle,
  421. int cmd,
  422. void *clientp);
  423. typedef void *(*curl_malloc_callback)(size_t size);
  424. typedef void (*curl_free_callback)(void *ptr);
  425. typedef void *(*curl_realloc_callback)(void *ptr, size_t size);
  426. typedef char *(*curl_strdup_callback)(const char *str);
  427. typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size);
  428. typedef enum {
  429. CURLINFO_TEXT = 0,
  430. CURLINFO_HEADER_IN,
  431. CURLINFO_HEADER_OUT,
  432. CURLINFO_DATA_IN,
  433. CURLINFO_DATA_OUT,
  434. CURLINFO_SSL_DATA_IN,
  435. CURLINFO_SSL_DATA_OUT,
  436. CURLINFO_END
  437. } curl_infotype;
  438. typedef int (*curl_debug_callback)
  439. (CURL *handle,
  440. curl_infotype type,
  441. char *data,
  442. size_t size,
  443. void *userptr);
  444. typedef enum {
  445. CURLE_OK = 0,
  446. CURLE_UNSUPPORTED_PROTOCOL,
  447. CURLE_FAILED_INIT,
  448. CURLE_URL_MALFORMAT,
  449. CURLE_NOT_BUILT_IN,
  450. CURLE_COULDNT_RESOLVE_PROXY,
  451. CURLE_COULDNT_RESOLVE_HOST,
  452. CURLE_COULDNT_CONNECT,
  453. CURLE_FTP_WEIRD_SERVER_REPLY,
  454. CURLE_REMOTE_ACCESS_DENIED,
  455. CURLE_FTP_ACCEPT_FAILED,
  456. CURLE_FTP_WEIRD_PASS_REPLY,
  457. CURLE_FTP_ACCEPT_TIMEOUT,
  458. CURLE_FTP_WEIRD_PASV_REPLY,
  459. CURLE_FTP_WEIRD_227_FORMAT,
  460. CURLE_FTP_CANT_GET_HOST,
  461. CURLE_HTTP2,
  462. CURLE_FTP_COULDNT_SET_TYPE,
  463. CURLE_PARTIAL_FILE,
  464. CURLE_FTP_COULDNT_RETR_FILE,
  465. CURLE_OBSOLETE20,
  466. CURLE_QUOTE_ERROR,
  467. CURLE_HTTP_RETURNED_ERROR,
  468. CURLE_WRITE_ERROR,
  469. CURLE_OBSOLETE24,
  470. CURLE_UPLOAD_FAILED,
  471. CURLE_READ_ERROR,
  472. CURLE_OUT_OF_MEMORY,
  473. CURLE_OPERATION_TIMEDOUT,
  474. CURLE_OBSOLETE29,
  475. CURLE_FTP_PORT_FAILED,
  476. CURLE_FTP_COULDNT_USE_REST,
  477. CURLE_OBSOLETE32,
  478. CURLE_RANGE_ERROR,
  479. CURLE_HTTP_POST_ERROR,
  480. CURLE_SSL_CONNECT_ERROR,
  481. CURLE_BAD_DOWNLOAD_RESUME,
  482. CURLE_FILE_COULDNT_READ_FILE,
  483. CURLE_LDAP_CANNOT_BIND,
  484. CURLE_LDAP_SEARCH_FAILED,
  485. CURLE_OBSOLETE40,
  486. CURLE_FUNCTION_NOT_FOUND,
  487. CURLE_ABORTED_BY_CALLBACK,
  488. CURLE_BAD_FUNCTION_ARGUMENT,
  489. CURLE_OBSOLETE44,
  490. CURLE_INTERFACE_FAILED,
  491. CURLE_OBSOLETE46,
  492. CURLE_TOO_MANY_REDIRECTS ,
  493. CURLE_UNKNOWN_OPTION,
  494. CURLE_TELNET_OPTION_SYNTAX ,
  495. CURLE_OBSOLETE50,
  496. CURLE_PEER_FAILED_VERIFICATION,
  497. CURLE_GOT_NOTHING,
  498. CURLE_SSL_ENGINE_NOTFOUND,
  499. CURLE_SSL_ENGINE_SETFAILED,
  500. CURLE_SEND_ERROR,
  501. CURLE_RECV_ERROR,
  502. CURLE_OBSOLETE57,
  503. CURLE_SSL_CERTPROBLEM,
  504. CURLE_SSL_CIPHER,
  505. CURLE_SSL_CACERT,
  506. CURLE_BAD_CONTENT_ENCODING,
  507. CURLE_LDAP_INVALID_URL,
  508. CURLE_FILESIZE_EXCEEDED,
  509. CURLE_USE_SSL_FAILED,
  510. CURLE_SEND_FAIL_REWIND,
  511. CURLE_SSL_ENGINE_INITFAILED,
  512. CURLE_LOGIN_DENIED,
  513. CURLE_TFTP_NOTFOUND,
  514. CURLE_TFTP_PERM,
  515. CURLE_REMOTE_DISK_FULL,
  516. CURLE_TFTP_ILLEGAL,
  517. CURLE_TFTP_UNKNOWNID,
  518. CURLE_REMOTE_FILE_EXISTS,
  519. CURLE_TFTP_NOSUCHUSER,
  520. CURLE_CONV_FAILED,
  521. CURLE_CONV_REQD,
  522. CURLE_SSL_CACERT_BADFILE,
  523. CURLE_REMOTE_FILE_NOT_FOUND,
  524. CURLE_SSH,
  525. CURLE_SSL_SHUTDOWN_FAILED,
  526. CURLE_AGAIN,
  527. CURLE_SSL_CRL_BADFILE,
  528. CURLE_SSL_ISSUER_ERROR,
  529. CURLE_FTP_PRET_FAILED,
  530. CURLE_RTSP_CSEQ_ERROR,
  531. CURLE_RTSP_SESSION_ERROR,
  532. CURLE_FTP_BAD_FILE_LIST,
  533. CURLE_CHUNK_FAILED,
  534. CURLE_NO_CONNECTION_AVAILABLE,
  535. CURLE_SSL_PINNEDPUBKEYNOTMATCH,
  536. CURLE_SSL_INVALIDCERTSTATUS,
  537. CURL_LAST
  538. } CURLcode;
  539. enum {
  540. CURLE_OBSOLETE16 = CURLE_HTTP2,
  541. CURLE_OBSOLETE10 = CURLE_FTP_ACCEPT_FAILED,
  542. CURLE_OBSOLETE12 = CURLE_FTP_ACCEPT_TIMEOUT,
  543. CURLOPT_ENCODING = CURLOPT_ACCEPT_ENCODING,
  544. CURLE_UNKNOWN_TELNET_OPTION = CURLE_UNKNOWN_OPTION,
  545. CURLE_SSL_PEER_CERTIFICATE = CURLE_PEER_FAILED_VERIFICATION,
  546. CURLE_OBSOLETE = CURLE_OBSOLETE50,
  547. CURLE_BAD_PASSWORD_ENTERED = CURLE_OBSOLETE46,
  548. CURLE_BAD_CALLING_ORDER = CURLE_OBSOLETE44,
  549. CURLE_FTP_USER_PASSWORD_INCORRECT = CURLE_OBSOLETE10,
  550. CURLE_FTP_CANT_RECONNECT = CURLE_OBSOLETE16,
  551. CURLE_FTP_COULDNT_GET_SIZE = CURLE_OBSOLETE32,
  552. CURLE_FTP_COULDNT_SET_ASCII = CURLE_OBSOLETE29,
  553. CURLE_FTP_WEIRD_USER_REPLY = CURLE_OBSOLETE12,
  554. CURLE_FTP_WRITE_ERROR = CURLE_OBSOLETE20,
  555. CURLE_LIBRARY_NOT_FOUND = CURLE_OBSOLETE40,
  556. CURLE_MALFORMAT_USER = CURLE_OBSOLETE24,
  557. CURLE_SHARE_IN_USE = CURLE_OBSOLETE57,
  558. CURLE_URL_MALFORMAT_USER = CURLE_NOT_BUILT_IN,
  559. CURLE_FTP_ACCESS_DENIED = CURLE_REMOTE_ACCESS_DENIED,
  560. CURLE_FTP_COULDNT_SET_BINARY = CURLE_FTP_COULDNT_SET_TYPE,
  561. CURLE_FTP_QUOTE_ERROR = CURLE_QUOTE_ERROR,
  562. CURLE_TFTP_DISKFULL = CURLE_REMOTE_DISK_FULL,
  563. CURLE_TFTP_EXISTS = CURLE_REMOTE_FILE_EXISTS,
  564. CURLE_HTTP_RANGE_ERROR = CURLE_RANGE_ERROR,
  565. CURLE_FTP_SSL_FAILED = CURLE_USE_SSL_FAILED,
  566. CURLE_OPERATION_TIMEOUTED = CURLE_OPERATION_TIMEDOUT,
  567. CURLE_HTTP_NOT_FOUND = CURLE_HTTP_RETURNED_ERROR,
  568. CURLE_HTTP_PORT_FAILED = CURLE_INTERFACE_FAILED,
  569. CURLE_FTP_COULDNT_STOR_FILE = CURLE_UPLOAD_FAILED,
  570. CURLE_FTP_PARTIAL_FILE = CURLE_PARTIAL_FILE,
  571. CURLE_FTP_BAD_DOWNLOAD_RESUME = CURLE_BAD_DOWNLOAD_RESUME,
  572. CURLE_ALREADY_COMPLETE = 99999,
  573. CURLOPT_FILE = CURLOPT_WRITEDATA,
  574. CURLOPT_INFILE = CURLOPT_READDATA,
  575. CURLOPT_WRITEHEADER = CURLOPT_HEADERDATA,
  576. CURLOPT_WRITEINFO = CURLOPT_OBSOLETE40,
  577. CURLOPT_CLOSEPOLICY = CURLOPT_OBSOLETE72,
  578. };
  579. typedef CURLcode (*curl_conv_callback)(char *buffer, size_t length);
  580. typedef CURLcode (*curl_ssl_ctx_callback)(CURL *curl,
  581. void *ssl_ctx,
  582. void *userptr);
  583. typedef enum {
  584. CURLPROXY_HTTP = 0,
  585. CURLPROXY_HTTP_1_0 = 1,
  586. CURLPROXY_SOCKS4 = 4,
  587. CURLPROXY_SOCKS5 = 5,
  588. CURLPROXY_SOCKS4A = 6,
  589. CURLPROXY_SOCKS5_HOSTNAME = 7
  590. } curl_proxytype;
  591. enum {
  592. CURLAUTH_NONE = ((unsigned long)0),
  593. CURLAUTH_BASIC = (((unsigned long)1)<<0),
  594. CURLAUTH_DIGEST = (((unsigned long)1)<<1),
  595. CURLAUTH_NEGOTIATE = (((unsigned long)1)<<2),
  596. CURLAUTH_GSSNEGOTIATE = CURLAUTH_NEGOTIATE,
  597. CURLAUTH_NTLM = (((unsigned long)1)<<3),
  598. CURLAUTH_DIGEST_IE = (((unsigned long)1)<<4),
  599. CURLAUTH_NTLM_WB = (((unsigned long)1)<<5),
  600. CURLAUTH_ONLY = (((unsigned long)1)<<31),
  601. CURLAUTH_ANY = (~CURLAUTH_DIGEST_IE),
  602. CURLAUTH_ANYSAFE = (~(CURLAUTH_BASIC|CURLAUTH_DIGEST_IE)),
  603. };
  604. enum {
  605. CURLSSH_AUTH_ANY = ~0,
  606. CURLSSH_AUTH_NONE = 0,
  607. CURLSSH_AUTH_PUBLICKEY = (1<<0),
  608. CURLSSH_AUTH_PASSWORD = (1<<1),
  609. CURLSSH_AUTH_HOST = (1<<2),
  610. CURLSSH_AUTH_KEYBOARD = (1<<3),
  611. CURLSSH_AUTH_AGENT = (1<<4),
  612. CURLSSH_AUTH_DEFAULT = CURLSSH_AUTH_ANY,
  613. };
  614. enum {
  615. CURLGSSAPI_DELEGATION_NONE = 0,
  616. CURLGSSAPI_DELEGATION_POLICY_FLAG = (1<<0),
  617. CURLGSSAPI_DELEGATION_FLAG = (1<<1),
  618. CURL_ERROR_SIZE = 256,
  619. };
  620. enum curl_khtype {
  621. CURLKHTYPE_UNKNOWN,
  622. CURLKHTYPE_RSA1,
  623. CURLKHTYPE_RSA,
  624. CURLKHTYPE_DSS
  625. };
  626. struct curl_khkey {
  627. const char *key;
  628. size_t len;
  629. enum curl_khtype keytype;
  630. };
  631. enum curl_khstat {
  632. CURLKHSTAT_FINE_ADD_TO_FILE,
  633. CURLKHSTAT_FINE,
  634. CURLKHSTAT_REJECT,
  635. CURLKHSTAT_DEFER,
  636. CURLKHSTAT_LAST
  637. };
  638. enum curl_khmatch {
  639. CURLKHMATCH_OK,
  640. CURLKHMATCH_MISMATCH,
  641. CURLKHMATCH_MISSING,
  642. CURLKHMATCH_LAST
  643. };
  644. typedef int
  645. (*curl_sshkeycallback) (CURL *easy,
  646. const struct curl_khkey *knownkey,
  647. const struct curl_khkey *foundkey,
  648. enum curl_khmatch,
  649. void *clientp);
  650. typedef enum {
  651. CURLUSESSL_NONE,
  652. CURLUSESSL_TRY,
  653. CURLUSESSL_CONTROL,
  654. CURLUSESSL_ALL,
  655. CURLUSESSL_LAST
  656. } curl_usessl;
  657. enum {
  658. CURLSSLOPT_ALLOW_BEAST = (1<<0),
  659. CURLSSLOPT_NO_REVOKE = (1<<1),
  660. CURLFTPSSL_NONE = CURLUSESSL_NONE,
  661. CURLFTPSSL_TRY = CURLUSESSL_TRY,
  662. CURLFTPSSL_CONTROL = CURLUSESSL_CONTROL,
  663. CURLFTPSSL_ALL = CURLUSESSL_ALL,
  664. CURLFTPSSL_LAST = CURLUSESSL_LAST,
  665. };
  666. typedef enum {
  667. CURLFTPSSL_CCC_NONE,
  668. CURLFTPSSL_CCC_PASSIVE,
  669. CURLFTPSSL_CCC_ACTIVE,
  670. CURLFTPSSL_CCC_LAST
  671. } curl_ftpccc;
  672. typedef enum {
  673. CURLFTPAUTH_DEFAULT,
  674. CURLFTPAUTH_SSL,
  675. CURLFTPAUTH_TLS,
  676. CURLFTPAUTH_LAST
  677. } curl_ftpauth;
  678. typedef enum {
  679. CURLFTP_CREATE_DIR_NONE,
  680. CURLFTP_CREATE_DIR,
  681. CURLFTP_CREATE_DIR_RETRY,
  682. CURLFTP_CREATE_DIR_LAST
  683. } curl_ftpcreatedir;
  684. typedef enum {
  685. CURLFTPMETHOD_DEFAULT,
  686. CURLFTPMETHOD_MULTICWD,
  687. CURLFTPMETHOD_NOCWD,
  688. CURLFTPMETHOD_SINGLECWD,
  689. CURLFTPMETHOD_LAST
  690. } curl_ftpmethod;
  691. enum {
  692. CURLHEADER_UNIFIED = 0,
  693. CURLHEADER_SEPARATE = (1<<0),
  694. };
  695. enum {
  696. CURLPROTO_HTTP = (1<<0),
  697. CURLPROTO_HTTPS = (1<<1),
  698. CURLPROTO_FTP = (1<<2),
  699. CURLPROTO_FTPS = (1<<3),
  700. CURLPROTO_SCP = (1<<4),
  701. CURLPROTO_SFTP = (1<<5),
  702. CURLPROTO_TELNET = (1<<6),
  703. CURLPROTO_LDAP = (1<<7),
  704. CURLPROTO_LDAPS = (1<<8),
  705. CURLPROTO_DICT = (1<<9),
  706. CURLPROTO_FILE = (1<<10),
  707. CURLPROTO_TFTP = (1<<11),
  708. CURLPROTO_IMAP = (1<<12),
  709. CURLPROTO_IMAPS = (1<<13),
  710. CURLPROTO_POP3 = (1<<14),
  711. CURLPROTO_POP3S = (1<<15),
  712. CURLPROTO_SMTP = (1<<16),
  713. CURLPROTO_SMTPS = (1<<17),
  714. CURLPROTO_RTSP = (1<<18),
  715. CURLPROTO_RTMP = (1<<19),
  716. CURLPROTO_RTMPT = (1<<20),
  717. CURLPROTO_RTMPE = (1<<21),
  718. CURLPROTO_RTMPTE = (1<<22),
  719. CURLPROTO_RTMPS = (1<<23),
  720. CURLPROTO_RTMPTS = (1<<24),
  721. CURLPROTO_GOPHER = (1<<25),
  722. CURLPROTO_SMB = (1<<26),
  723. CURLPROTO_SMBS = (1<<27),
  724. CURLPROTO_ALL = (~0),
  725. CURLOPTTYPE_LONG = 0,
  726. CURLOPTTYPE_OBJECTPOINT = 10000,
  727. CURLOPTTYPE_STRINGPOINT = 10000,
  728. CURLOPTTYPE_FUNCTIONPOINT = 20000,
  729. CURLOPTTYPE_OFF_T = 30000,
  730. };
  731. enum {
  732. CURL_HTTP_VERSION_NONE,
  733. CURL_HTTP_VERSION_1_0,
  734. CURL_HTTP_VERSION_1_1,
  735. CURL_HTTP_VERSION_2_0,
  736. CURL_HTTP_VERSION_LAST
  737. };
  738. enum {
  739. CURL_RTSPREQ_NONE,
  740. CURL_RTSPREQ_OPTIONS,
  741. CURL_RTSPREQ_DESCRIBE,
  742. CURL_RTSPREQ_ANNOUNCE,
  743. CURL_RTSPREQ_SETUP,
  744. CURL_RTSPREQ_PLAY,
  745. CURL_RTSPREQ_PAUSE,
  746. CURL_RTSPREQ_TEARDOWN,
  747. CURL_RTSPREQ_GET_PARAMETER,
  748. CURL_RTSPREQ_SET_PARAMETER,
  749. CURL_RTSPREQ_RECORD,
  750. CURL_RTSPREQ_RECEIVE,
  751. CURL_RTSPREQ_LAST
  752. };
  753. enum CURL_NETRC_OPTION {
  754. CURL_NETRC_IGNORED,
  755. CURL_NETRC_OPTIONAL,
  756. CURL_NETRC_REQUIRED,
  757. CURL_NETRC_LAST
  758. };
  759. enum {
  760. CURL_SSLVERSION_DEFAULT,
  761. CURL_SSLVERSION_TLSv1,
  762. CURL_SSLVERSION_SSLv2,
  763. CURL_SSLVERSION_SSLv3,
  764. CURL_SSLVERSION_TLSv1_0,
  765. CURL_SSLVERSION_TLSv1_1,
  766. CURL_SSLVERSION_TLSv1_2,
  767. CURL_SSLVERSION_LAST
  768. };
  769. enum CURL_TLSAUTH {
  770. CURL_TLSAUTH_NONE,
  771. CURL_TLSAUTH_SRP,
  772. CURL_TLSAUTH_LAST
  773. };
  774. enum {
  775. CURL_REDIR_GET_ALL = 0,
  776. CURL_REDIR_POST_301 = 1,
  777. CURL_REDIR_POST_302 = 2,
  778. CURL_REDIR_POST_303 = 4,
  779. CURL_REDIR_POST_ALL = (CURL_REDIR_POST_301|CURL_REDIR_POST_302|CURL_REDIR_POST_303),
  780. };
  781. typedef enum {
  782. CURL_TIMECOND_NONE,
  783. CURL_TIMECOND_IFMODSINCE,
  784. CURL_TIMECOND_IFUNMODSINCE,
  785. CURL_TIMECOND_LASTMOD,
  786. CURL_TIMECOND_LAST
  787. } curl_TimeCond;
  788. int (curl_strequal)(const char *s1, const char *s2);
  789. int (curl_strnequal)(const char *s1, const char *s2, size_t n);
  790. typedef enum {
  791. CURLFORM_NOTHING,
  792. CURLFORM_COPYNAME,
  793. CURLFORM_PTRNAME,
  794. CURLFORM_NAMELENGTH,
  795. CURLFORM_COPYCONTENTS,
  796. CURLFORM_PTRCONTENTS,
  797. CURLFORM_CONTENTSLENGTH,
  798. CURLFORM_FILECONTENT,
  799. CURLFORM_ARRAY,
  800. CURLFORM_OBSOLETE,
  801. CURLFORM_FILE,
  802. CURLFORM_BUFFER,
  803. CURLFORM_BUFFERPTR,
  804. CURLFORM_BUFFERLENGTH,
  805. CURLFORM_CONTENTTYPE,
  806. CURLFORM_CONTENTHEADER,
  807. CURLFORM_FILENAME,
  808. CURLFORM_END,
  809. CURLFORM_OBSOLETE2,
  810. CURLFORM_STREAM,
  811. CURLFORM_CONTENTLEN,
  812. CURLFORM_LASTENTRY
  813. } CURLformoption;
  814. struct curl_forms {
  815. CURLformoption option;
  816. const char *value;
  817. };
  818. typedef enum {
  819. CURL_FORMADD_OK,
  820. CURL_FORMADD_MEMORY,
  821. CURL_FORMADD_OPTION_TWICE,
  822. CURL_FORMADD_NULL,
  823. CURL_FORMADD_UNKNOWN_OPTION,
  824. CURL_FORMADD_INCOMPLETE,
  825. CURL_FORMADD_ILLEGAL_ARRAY,
  826. CURL_FORMADD_DISABLED,
  827. CURL_FORMADD_LAST
  828. } CURLFORMcode;
  829. CURLFORMcode curl_formadd(struct curl_httppost **httppost, struct curl_httppost **last_post, ...);
  830. typedef size_t (*curl_formget_callback)(void *arg, const char *buf, size_t len);
  831. int curl_formget(struct curl_httppost *form, void *arg, curl_formget_callback append);
  832. void curl_formfree(struct curl_httppost *form);
  833. char *curl_version(void);
  834. char *curl_easy_escape(CURL *handle, const char *string, int length);
  835. char *curl_escape(const char *string, int length);
  836. char *curl_easy_unescape(CURL *handle, const char *string, int length, int *outlength);
  837. char *curl_unescape(const char *string, int length);
  838. void curl_free(void *p);
  839. CURLcode curl_global_init(long flags);
  840. CURLcode curl_global_init_mem(long flags,
  841. curl_malloc_callback m,
  842. curl_free_callback f,
  843. curl_realloc_callback r,
  844. curl_strdup_callback s,
  845. curl_calloc_callback c);
  846. void curl_global_cleanup(void);
  847. struct curl_slist {
  848. char *data;
  849. struct curl_slist *next;
  850. };
  851. struct curl_slist *curl_slist_append(struct curl_slist *, const char *);
  852. void curl_slist_free_all(struct curl_slist *);
  853. time_t curl_getdate(const char *p, const time_t *unused);
  854. struct curl_certinfo {
  855. int num_of_certs;
  856. struct curl_slist **certinfo;
  857. };
  858. typedef enum {
  859. CURLSSLBACKEND_NONE = 0,
  860. CURLSSLBACKEND_OPENSSL = 1,
  861. CURLSSLBACKEND_GNUTLS = 2,
  862. CURLSSLBACKEND_NSS = 3,
  863. CURLSSLBACKEND_OBSOLETE4 = 4,
  864. CURLSSLBACKEND_GSKIT = 5,
  865. CURLSSLBACKEND_POLARSSL = 6,
  866. CURLSSLBACKEND_CYASSL = 7,
  867. CURLSSLBACKEND_SCHANNEL = 8,
  868. CURLSSLBACKEND_DARWINSSL = 9,
  869. CURLSSLBACKEND_AXTLS = 10,
  870. CURLSSLBACKEND_MBEDTLS = 11
  871. } curl_sslbackend;
  872. struct curl_tlssessioninfo {
  873. curl_sslbackend backend;
  874. void *internals;
  875. };
  876. enum {
  877. CURLINFO_STRING = 0x100000,
  878. CURLINFO_LONG = 0x200000,
  879. CURLINFO_DOUBLE = 0x300000,
  880. CURLINFO_SLIST = 0x400000,
  881. CURLINFO_SOCKET = 0x500000,
  882. CURLINFO_MASK = 0x0fffff,
  883. CURLINFO_TYPEMASK = 0xf00000,
  884. };
  885. typedef enum {
  886. CURLINFO_NONE,
  887. CURLINFO_EFFECTIVE_URL = 0x100000 + 1,
  888. CURLINFO_RESPONSE_CODE = 0x200000 + 2,
  889. CURLINFO_TOTAL_TIME = 0x300000 + 3,
  890. CURLINFO_NAMELOOKUP_TIME = 0x300000 + 4,
  891. CURLINFO_CONNECT_TIME = 0x300000 + 5,
  892. CURLINFO_PRETRANSFER_TIME = 0x300000 + 6,
  893. CURLINFO_SIZE_UPLOAD = 0x300000 + 7,
  894. CURLINFO_SIZE_DOWNLOAD = 0x300000 + 8,
  895. CURLINFO_SPEED_DOWNLOAD = 0x300000 + 9,
  896. CURLINFO_SPEED_UPLOAD = 0x300000 + 10,
  897. CURLINFO_HEADER_SIZE = 0x200000 + 11,
  898. CURLINFO_REQUEST_SIZE = 0x200000 + 12,
  899. CURLINFO_SSL_VERIFYRESULT = 0x200000 + 13,
  900. CURLINFO_FILETIME = 0x200000 + 14,
  901. CURLINFO_CONTENT_LENGTH_DOWNLOAD = 0x300000 + 15,
  902. CURLINFO_CONTENT_LENGTH_UPLOAD = 0x300000 + 16,
  903. CURLINFO_STARTTRANSFER_TIME = 0x300000 + 17,
  904. CURLINFO_CONTENT_TYPE = 0x100000 + 18,
  905. CURLINFO_REDIRECT_TIME = 0x300000 + 19,
  906. CURLINFO_REDIRECT_COUNT = 0x200000 + 20,
  907. CURLINFO_PRIVATE = 0x100000 + 21,
  908. CURLINFO_HTTP_CONNECTCODE = 0x200000 + 22,
  909. CURLINFO_HTTPAUTH_AVAIL = 0x200000 + 23,
  910. CURLINFO_PROXYAUTH_AVAIL = 0x200000 + 24,
  911. CURLINFO_OS_ERRNO = 0x200000 + 25,
  912. CURLINFO_NUM_CONNECTS = 0x200000 + 26,
  913. CURLINFO_SSL_ENGINES = 0x400000 + 27,
  914. CURLINFO_COOKIELIST = 0x400000 + 28,
  915. CURLINFO_LASTSOCKET = 0x200000 + 29,
  916. CURLINFO_FTP_ENTRY_PATH = 0x100000 + 30,
  917. CURLINFO_REDIRECT_URL = 0x100000 + 31,
  918. CURLINFO_PRIMARY_IP = 0x100000 + 32,
  919. CURLINFO_APPCONNECT_TIME = 0x300000 + 33,
  920. CURLINFO_CERTINFO = 0x400000 + 34,
  921. CURLINFO_CONDITION_UNMET = 0x200000 + 35,
  922. CURLINFO_RTSP_SESSION_ID = 0x100000 + 36,
  923. CURLINFO_RTSP_CLIENT_CSEQ = 0x200000 + 37,
  924. CURLINFO_RTSP_SERVER_CSEQ = 0x200000 + 38,
  925. CURLINFO_RTSP_CSEQ_RECV = 0x200000 + 39,
  926. CURLINFO_PRIMARY_PORT = 0x200000 + 40,
  927. CURLINFO_LOCAL_IP = 0x100000 + 41,
  928. CURLINFO_LOCAL_PORT = 0x200000 + 42,
  929. CURLINFO_TLS_SESSION = 0x400000 + 43,
  930. CURLINFO_ACTIVESOCKET = 0x500000 + 44,
  931. CURLINFO_LASTONE = 44
  932. } CURLINFO;
  933. enum {
  934. CURLINFO_HTTP_CODE = CURLINFO_RESPONSE_CODE,
  935. };
  936. typedef enum {
  937. CURLCLOSEPOLICY_NONE,
  938. CURLCLOSEPOLICY_OLDEST,
  939. CURLCLOSEPOLICY_LEAST_RECENTLY_USED,
  940. CURLCLOSEPOLICY_LEAST_TRAFFIC,
  941. CURLCLOSEPOLICY_SLOWEST,
  942. CURLCLOSEPOLICY_CALLBACK,
  943. CURLCLOSEPOLICY_LAST
  944. } curl_closepolicy;
  945. enum {
  946. CURL_GLOBAL_SSL = (1<<0),
  947. CURL_GLOBAL_WIN32 = (1<<1),
  948. CURL_GLOBAL_ALL = (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32),
  949. CURL_GLOBAL_NOTHING = 0,
  950. CURL_GLOBAL_DEFAULT = CURL_GLOBAL_ALL,
  951. CURL_GLOBAL_ACK_EINTR = (1<<2),
  952. };
  953. typedef enum {
  954. CURL_LOCK_DATA_NONE = 0,
  955. CURL_LOCK_DATA_SHARE,
  956. CURL_LOCK_DATA_COOKIE,
  957. CURL_LOCK_DATA_DNS,
  958. CURL_LOCK_DATA_SSL_SESSION,
  959. CURL_LOCK_DATA_CONNECT,
  960. CURL_LOCK_DATA_LAST
  961. } curl_lock_data;
  962. typedef enum {
  963. CURL_LOCK_ACCESS_NONE = 0,
  964. CURL_LOCK_ACCESS_SHARED = 1,
  965. CURL_LOCK_ACCESS_SINGLE = 2,
  966. CURL_LOCK_ACCESS_LAST
  967. } curl_lock_access;
  968. typedef void (*curl_lock_function)(CURL *handle,
  969. curl_lock_data data,
  970. curl_lock_access locktype,
  971. void *userptr);
  972. typedef void (*curl_unlock_function)(CURL *handle,
  973. curl_lock_data data,
  974. void *userptr);
  975. typedef struct CURLSH CURLSH;
  976. typedef enum {
  977. CURLSHE_OK,
  978. CURLSHE_BAD_OPTION,
  979. CURLSHE_IN_USE,
  980. CURLSHE_INVALID,
  981. CURLSHE_NOMEM,
  982. CURLSHE_NOT_BUILT_IN,
  983. CURLSHE_LAST
  984. } CURLSHcode;
  985. typedef enum {
  986. CURLSHOPT_NONE,
  987. CURLSHOPT_SHARE,
  988. CURLSHOPT_UNSHARE,
  989. CURLSHOPT_LOCKFUNC,
  990. CURLSHOPT_UNLOCKFUNC,
  991. CURLSHOPT_USERDATA,
  992. CURLSHOPT_LAST
  993. } CURLSHoption;
  994. CURLSH *curl_share_init(void);
  995. CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...);
  996. CURLSHcode curl_share_cleanup(CURLSH *);
  997. typedef enum {
  998. CURLVERSION_FIRST,
  999. CURLVERSION_SECOND,
  1000. CURLVERSION_THIRD,
  1001. CURLVERSION_FOURTH,
  1002. CURLVERSION_LAST
  1003. } CURLversion;
  1004. enum {
  1005. CURLVERSION_NOW = CURLVERSION_FOURTH,
  1006. };
  1007. typedef struct {
  1008. CURLversion age;
  1009. const char *version;
  1010. unsigned int version_num;
  1011. const char *host;
  1012. int features;
  1013. const char *ssl_version;
  1014. long ssl_version_num;
  1015. const char *libz_version;
  1016. const char * const *protocols;
  1017. const char *ares;
  1018. int ares_num;
  1019. const char *libidn;
  1020. int iconv_ver_num;
  1021. const char *libssh_version;
  1022. } curl_version_info_data;
  1023. enum {
  1024. CURL_VERSION_IPV6 = (1<<0),
  1025. CURL_VERSION_KERBEROS4 = (1<<1),
  1026. CURL_VERSION_SSL = (1<<2),
  1027. CURL_VERSION_LIBZ = (1<<3),
  1028. CURL_VERSION_NTLM = (1<<4),
  1029. CURL_VERSION_GSSNEGOTIATE = (1<<5),
  1030. CURL_VERSION_DEBUG = (1<<6),
  1031. CURL_VERSION_ASYNCHDNS = (1<<7),
  1032. CURL_VERSION_SPNEGO = (1<<8),
  1033. CURL_VERSION_LARGEFILE = (1<<9),
  1034. CURL_VERSION_IDN = (1<<10),
  1035. CURL_VERSION_SSPI = (1<<11),
  1036. CURL_VERSION_CONV = (1<<12),
  1037. CURL_VERSION_CURLDEBUG = (1<<13),
  1038. CURL_VERSION_TLSAUTH_SRP = (1<<14),
  1039. CURL_VERSION_NTLM_WB = (1<<15),
  1040. CURL_VERSION_HTTP2 = (1<<16),
  1041. CURL_VERSION_GSSAPI = (1<<17),
  1042. CURL_VERSION_KERBEROS5 = (1<<18),
  1043. CURL_VERSION_UNIX_SOCKETS = (1<<19),
  1044. };
  1045. curl_version_info_data *curl_version_info(CURLversion);
  1046. // easy.h --------------------------------------------------------------------
  1047. const char *curl_easy_strerror(CURLcode);
  1048. const char *curl_share_strerror(CURLSHcode);
  1049. CURLcode curl_easy_pause(CURL *handle, int bitmask);
  1050. enum {
  1051. CURLPAUSE_RECV = (1<<0),
  1052. CURLPAUSE_RECV_CONT = (0),
  1053. CURLPAUSE_SEND = (1<<2),
  1054. CURLPAUSE_SEND_CONT = (0),
  1055. CURLPAUSE_ALL = (CURLPAUSE_RECV|CURLPAUSE_SEND),
  1056. CURLPAUSE_CONT = (CURLPAUSE_RECV_CONT|CURLPAUSE_SEND_CONT),
  1057. };
  1058. CURL *curl_easy_init(void);
  1059. CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
  1060. CURLcode curl_easy_perform(CURL *curl);
  1061. void curl_easy_cleanup(CURL *curl);
  1062. CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
  1063. CURL* curl_easy_duphandle(CURL *curl);
  1064. void curl_easy_reset(CURL *curl);
  1065. CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
  1066. size_t *n);
  1067. CURLcode curl_easy_send(CURL *curl, const void *buffer,
  1068. size_t buflen, size_t *n);
  1069. // multi.h -------------------------------------------------------------------
  1070. typedef struct CURLM CURLM;
  1071. typedef enum {
  1072. CURLM_CALL_MULTI_PERFORM = -1,
  1073. CURLM_OK,
  1074. CURLM_BAD_HANDLE,
  1075. CURLM_BAD_EASY_HANDLE,
  1076. CURLM_OUT_OF_MEMORY,
  1077. CURLM_INTERNAL_ERROR,
  1078. CURLM_BAD_SOCKET,
  1079. CURLM_UNKNOWN_OPTION,
  1080. CURLM_ADDED_ALREADY,
  1081. CURLM_LAST
  1082. } CURLMcode;
  1083. enum {
  1084. CURLM_CALL_MULTI_SOCKET = CURLM_CALL_MULTI_PERFORM,
  1085. CURLPIPE_NOTHING = 0,
  1086. CURLPIPE_HTTP1 = 1,
  1087. CURLPIPE_MULTIPLEX = 2,
  1088. };
  1089. typedef enum {
  1090. CURLMSG_NONE,
  1091. CURLMSG_DONE,
  1092. CURLMSG_LAST
  1093. } CURLMSG;
  1094. struct CURLMsg {
  1095. CURLMSG msg;
  1096. CURL *easy_handle;
  1097. union {
  1098. void *whatever;
  1099. CURLcode result;
  1100. } data;
  1101. };
  1102. typedef struct CURLMsg CURLMsg;
  1103. enum {
  1104. CURL_WAIT_POLLIN = 0x0001,
  1105. CURL_WAIT_POLLPRI = 0x0002,
  1106. CURL_WAIT_POLLOUT = 0x0004,
  1107. };
  1108. struct curl_waitfd {
  1109. curl_socket_t fd;
  1110. short events;
  1111. short revents;
  1112. };
  1113. CURLM *curl_multi_init(void);
  1114. CURLMcode curl_multi_add_handle(CURLM *multi_handle, CURL *curl_handle);
  1115. CURLMcode curl_multi_remove_handle(CURLM *multi_handle, CURL *curl_handle);
  1116. CURLMcode curl_multi_fdset(CURLM *multi_handle,
  1117. curl_fd_set *read_fd_set,
  1118. curl_fd_set *write_fd_set,
  1119. curl_fd_set *exc_fd_set,
  1120. int *max_fd);
  1121. CURLMcode curl_multi_wait(CURLM *multi_handle,
  1122. struct curl_waitfd extra_fds[],
  1123. unsigned int extra_nfds,
  1124. int timeout_ms,
  1125. int *ret);
  1126. CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles);
  1127. CURLMcode curl_multi_cleanup(CURLM *multi_handle);
  1128. CURLMsg *curl_multi_info_read(CURLM *multi_handle, int *msgs_in_queue);
  1129. const char *curl_multi_strerror(CURLMcode);
  1130. enum {
  1131. CURL_POLL_NONE = 0,
  1132. CURL_POLL_IN = 1,
  1133. CURL_POLL_OUT = 2,
  1134. CURL_POLL_INOUT = 3,
  1135. CURL_POLL_REMOVE = 4,
  1136. CURL_CSELECT_IN = 0x01,
  1137. CURL_CSELECT_OUT = 0x02,
  1138. CURL_CSELECT_ERR = 0x04,
  1139. };
  1140. typedef int (*curl_socket_callback)(CURL *easy, curl_socket_t s, int what, void *userp, void *socketp);
  1141. typedef int (*curl_multi_timer_callback)(CURLM *multi, long timeout_ms, void *userp);
  1142. CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s, int *running_handles);
  1143. CURLMcode curl_multi_socket_action(CURLM *multi_handle, curl_socket_t s, int ev_bitmask, int *running_handles);
  1144. CURLMcode curl_multi_socket_all(CURLM *multi_handle, int *running_handles);
  1145. CURLMcode curl_multi_timeout(CURLM *multi_handle, long *milliseconds);
  1146. typedef enum {
  1147. CURLMOPT_SOCKETFUNCTION = 20000 + 1,
  1148. CURLMOPT_SOCKETDATA = 10000 + 2,
  1149. CURLMOPT_PIPELINING = 0 + 3,
  1150. CURLMOPT_TIMERFUNCTION = 20000 + 4,
  1151. CURLMOPT_TIMERDATA = 10000 + 5,
  1152. CURLMOPT_MAXCONNECTS = 0 + 6,
  1153. CURLMOPT_MAX_HOST_CONNECTIONS = 0 + 7,
  1154. CURLMOPT_MAX_PIPELINE_LENGTH = 0 + 8,
  1155. CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE = 30000 + 9,
  1156. CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE = 30000 + 10,
  1157. CURLMOPT_PIPELINING_SITE_BL = 10000 + 11,
  1158. CURLMOPT_PIPELINING_SERVER_BL = 10000 + 12,
  1159. CURLMOPT_MAX_TOTAL_CONNECTIONS = 0 + 13,
  1160. CURLMOPT_PUSHFUNCTION = 20000 + 14,
  1161. CURLMOPT_PUSHDATA = 10000 + 15,
  1162. CURLMOPT_LASTENTRY
  1163. } CURLMoption;
  1164. CURLMcode curl_multi_setopt(CURLM *multi_handle, CURLMoption option, ...);
  1165. CURLMcode curl_multi_assign(CURLM *multi_handle, curl_socket_t sockfd, void *sockp);
  1166. enum {
  1167. CURL_PUSH_OK = 0,
  1168. CURL_PUSH_DENY = 1,
  1169. };
  1170. struct curl_pushheaders;
  1171. char *curl_pushheader_bynum(struct curl_pushheaders *h, size_t num);
  1172. char *curl_pushheader_byname(struct curl_pushheaders *h, const char *name);
  1173. typedef int (*curl_push_callback)(CURL *parent,
  1174. CURL *easy,
  1175. size_t num_headers,
  1176. struct curl_pushheaders *headers,
  1177. void *userp);
  1178. ]]

 

转载于:https://my.oschina.net/u/2385183/blog/689534

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/636007
推荐阅读
相关标签
  

闽ICP备14008679号