📄 curl.h
字号:
#ifndef __CURL_CURL_H#define __CURL_CURL_H/**************************************************************************** _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____|** Copyright (C) 1998 - 2003, Daniel Stenberg, <daniel@haxx.se>, et al.** This software is licensed as described in the file COPYING, which* you should have received as part of this distribution. The terms* are also available at http://curl.haxx.se/docs/copyright.html.* * You may opt to use, copy, modify, merge, publish, distribute and/or sell* copies of the Software, and permit persons to whom the Software is* furnished to do so, under the terms of the COPYING file.** This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY* KIND, either express or implied.** $Id: curl.h,v 1.192 2003/03/31 14:02:45 bagder Exp $***************************************************************************/#include <stdio.h>/* The include stuff here is mainly for time_t! */#ifdef vms# include <types.h># include <time.h>#else# include <sys/types.h># ifdef TIME_WITH_SYS_TIME# include <sys/time.h># include <time.h># else# ifdef HAVE_SYS_TIME_H# include <sys/time.h># else# include <time.h># endif# endif#endif /* defined (vms) */#ifndef TRUE#define TRUE 1#endif#ifndef FALSE#define FALSE 0#endif#include "types.h"#ifdef __cplusplusextern "C" {#endif /* stupid #define trick to preserve functionality with older code, but making it use our name space for the future */#define HttpPost curl_httppost struct curl_httppost { struct curl_httppost *next; /* next entry in the list */ char *name; /* pointer to allocated name */ long namelength; /* length of name length */ char *contents; /* pointer to allocated data contents */ long contentslength; /* length of contents field */ /* CMC: Added support for buffer uploads */ char *buffer; /* pointer to allocated buffer contents */ long bufferlength; /* length of buffer field */ char *contenttype; /* Content-Type */ struct curl_slist* contentheader; /* list of extra headers for this form */ struct curl_httppost *more; /* if one field name has more than one file, this link should link to following files */ long flags; /* as defined below */#define HTTPPOST_FILENAME (1<<0) /* specified content is a file name */#define HTTPPOST_READFILE (1<<1) /* specified content is a file name */#define HTTPPOST_PTRNAME (1<<2) /* name is only stored pointer do not free in formfree */#define HTTPPOST_PTRCONTENTS (1<<3) /* contents is only stored pointer do not free in formfree */ /* CMC: Added support for buffer uploads */#define HTTPPOST_BUFFER (1<<4) /* upload file from buffer */#define HTTPPOST_PTRBUFFER (1<<5) /* upload file from pointer contents */ char *showfilename; /* The file name to show. If not set, the actual file name will be used (if this is a file part) */ }; typedef int (*curl_progress_callback)(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); /* Tests have proven that 20K is a very bad buffer size for uploads on Windows, while 16K for some odd reason performed a lot better. */#define CURL_MAX_WRITE_SIZE 16384 typedef size_t (*curl_write_callback)(char *buffer, size_t size, size_t nitems, void *outstream); typedef size_t (*curl_read_callback)(char *buffer, size_t size, size_t nitems, void *instream); typedef int (*curl_passwd_callback)(void *clientp, const char *prompt, char *buffer, int buflen); /* the kind of data that is passed to information_callback*/ typedef enum { CURLINFO_TEXT = 0, CURLINFO_HEADER_IN, /* 1 */ CURLINFO_HEADER_OUT, /* 2 */ CURLINFO_DATA_IN, /* 3 */ CURLINFO_DATA_OUT, /* 4 */ CURLINFO_END } curl_infotype; typedef int (*curl_debug_callback) (CURL *handle, /* the handle/transfer this concerns */ curl_infotype type, /* what kind of data */ char *data, /* points to the data */ size_t size, /* size of the data pointed to */ void *userp); /* whatever the user please */ /* All possible error codes from all sorts of curl functions. Future versions may return other values, stay prepared. Always add new return codes last. Never *EVER* remove any. The return codes must remain the same! */ typedef enum { CURLE_OK = 0, CURLE_UNSUPPORTED_PROTOCOL, /* 1 */ CURLE_FAILED_INIT, /* 2 */ CURLE_URL_MALFORMAT, /* 3 */ CURLE_URL_MALFORMAT_USER, /* 4 */ CURLE_COULDNT_RESOLVE_PROXY, /* 5 */ CURLE_COULDNT_RESOLVE_HOST, /* 6 */ CURLE_COULDNT_CONNECT, /* 7 */ CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */ CURLE_FTP_ACCESS_DENIED, /* 9 */ CURLE_FTP_USER_PASSWORD_INCORRECT, /* 10 */ CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */ CURLE_FTP_WEIRD_USER_REPLY, /* 12 */ CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */ CURLE_FTP_WEIRD_227_FORMAT, /* 14 */ CURLE_FTP_CANT_GET_HOST, /* 15 */ CURLE_FTP_CANT_RECONNECT, /* 16 */ CURLE_FTP_COULDNT_SET_BINARY, /* 17 */ CURLE_PARTIAL_FILE, /* 18 */ CURLE_FTP_COULDNT_RETR_FILE, /* 19 */ CURLE_FTP_WRITE_ERROR, /* 20 */ CURLE_FTP_QUOTE_ERROR, /* 21 */ CURLE_HTTP_RETURNED_ERROR, /* 22 */ CURLE_WRITE_ERROR, /* 23 */ CURLE_MALFORMAT_USER, /* 24 - user name is illegally specified */ CURLE_FTP_COULDNT_STOR_FILE, /* 25 - failed FTP upload */ CURLE_READ_ERROR, /* 26 - could open/read from file */ CURLE_OUT_OF_MEMORY, /* 27 */ CURLE_OPERATION_TIMEOUTED, /* 28 - the timeout time was reached */ CURLE_FTP_COULDNT_SET_ASCII, /* 29 - TYPE A failed */ CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */ CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */ CURLE_FTP_COULDNT_GET_SIZE, /* 32 - the SIZE command failed */ CURLE_HTTP_RANGE_ERROR, /* 33 - RANGE "command" didn't work */ CURLE_HTTP_POST_ERROR, /* 34 */ CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */ CURLE_BAD_DOWNLOAD_RESUME, /* 36 - couldn't resume download */ CURLE_FILE_COULDNT_READ_FILE, /* 37 */ CURLE_LDAP_CANNOT_BIND, /* 38 */ CURLE_LDAP_SEARCH_FAILED, /* 39 */ CURLE_LIBRARY_NOT_FOUND, /* 40 */ CURLE_FUNCTION_NOT_FOUND, /* 41 */ CURLE_ABORTED_BY_CALLBACK, /* 42 */ CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */ CURLE_BAD_CALLING_ORDER, /* 44 */ CURLE_HTTP_PORT_FAILED, /* 45 - HTTP Interface operation failed */ CURLE_BAD_PASSWORD_ENTERED, /* 46 - my_getpass() returns fail */ CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */ CURLE_UNKNOWN_TELNET_OPTION, /* 48 - User specified an unknown option */ CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */ CURLE_OBSOLETE, /* 50 - removed after 7.7.3 */ CURLE_SSL_PEER_CERTIFICATE, /* 51 - peer's certificate wasn't ok */ CURLE_GOT_NOTHING, /* 52 - when this is a specific error */ CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */ CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as default */ CURLE_SEND_ERROR, /* 55 - failed sending network data */ CURLE_RECV_ERROR, /* 56 - failure in receiving network data */ CURLE_SHARE_IN_USE, /* 57 - share is in use */ CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */ CURLE_SSL_CIPHER, /* 59 - couldn't use specified cipher */ CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */ CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized transfer encoding */ CURL_LAST /* never use! */ } CURLcode; /* Make a spelling correction for the operation timed-out define */#define CURLE_OPERATION_TIMEDOUT CURLE_OPERATION_TIMEOUTED#define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR typedef enum { CURLPROXY_HTTP = 0, CURLPROXY_SOCKS4 = 4, CURLPROXY_SOCKS5 = 5 } curl_proxytype; /* this was the error code 50 in 7.7.3 and a few earlier versions, this is no longer used by libcurl but is instead #defined here only to not make programs break */#define CURLE_ALREADY_COMPLETE 99999 /* This is just to make older programs not break: */#define CURLE_FTP_PARTIAL_FILE CURLE_PARTIAL_FILE#define CURLE_FTP_BAD_DOWNLOAD_RESUME CURLE_BAD_DOWNLOAD_RESUME#define CURL_ERROR_SIZE 256 /* long may be 32 or 64 bits, but we should never depend on anything else but 32 */#define CURLOPTTYPE_LONG 0#define CURLOPTTYPE_OBJECTPOINT 10000#define CURLOPTTYPE_FUNCTIONPOINT 20000 /* name is uppercase CURLOPT_<name>, type is one of the defined CURLOPTTYPE_<type> number is unique identifier */#ifdef CINIT#undef CINIT#endif /* * Figure out if we can use the ## operator, which is supported by ISO/ANSI C * and C++. Some compilers support it without setting __STDC__ or __cplusplus * so we need to carefully check for them too. We don't use configure-checks * for these since we want these headers to remain generic and working for all * platforms. */#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \ defined(__HP_aCC) || defined(__BORLANDC__) /* This compiler is believed to have an ISO compatible preprocessor */#define CURL_ISOCPP#else /* This compiler is believed NOT to have an ISO compatible preprocessor */#undef CURL_ISOCPP#endif#ifdef CURL_ISOCPP#define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number#else /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */#define LONG CURLOPTTYPE_LONG#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT#define CINIT(name,type,number) CURLOPT_/**/name = type + number#endif typedef enum { CINIT(NOTHING, LONG, 0), /********* the first one is unused ************/ /* This is the FILE * or void * the regular output should be written to. */ CINIT(FILE, OBJECTPOINT, 1), /* The full URL to get/put */ CINIT(URL, OBJECTPOINT, 2), /* Port number to connect to, if other than default. Specify the CONF_PORT flag in the CURLOPT_FLAGS to activate this */ CINIT(PORT, LONG, 3), /* Name of proxy to use. Specify the CONF_PROXY flag in the CURLOPT_FLAGS to activate this */ CINIT(PROXY, OBJECTPOINT, 4), /* Name and password to use when fetching. Specify the CONF_USERPWD flag in the CURLOPT_FLAGS to activate this */ CINIT(USERPWD, OBJECTPOINT, 5), /* Name and password to use with Proxy. Specify the CONF_PROXYUSERPWD flag in the CURLOPT_FLAGS to activate this */ CINIT(PROXYUSERPWD, OBJECTPOINT, 6), /* Range to get, specified as an ASCII string. Specify the CONF_RANGE flag in the CURLOPT_FLAGS to activate this */ CINIT(RANGE, OBJECTPOINT, 7), /* not used */ /* Specified file stream to upload from (use as input): */ CINIT(INFILE, OBJECTPOINT, 9), /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE * bytes big. If this is not used, error messages go to stderr instead: */ CINIT(ERRORBUFFER, OBJECTPOINT, 10), /* Function that will be called to store the output (instead of fwrite). The * parameters will use fwrite() syntax, make sure to follow them. */ CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11), /* Function that will be called to read the input (instead of fread). The * parameters will use fread() syntax, make sure to follow them. */ CINIT(READFUNCTION, FUNCTIONPOINT, 12), /* Time-out the read operation after this amount of seconds */ CINIT(TIMEOUT, LONG, 13), /* If the CURLOPT_INFILE is used, this can be used to inform libcurl about * how large the file being sent really is. That allows better error * checking and better verifies that the upload was succcessful. -1 means * unknown size. */ CINIT(INFILESIZE, LONG, 14), /* POST input fields. */ CINIT(POSTFIELDS, OBJECTPOINT, 15), /* Set the referer page (needed by some CGIs) */ CINIT(REFERER, OBJECTPOINT, 16), /* Set the FTP PORT string (interface name, named or numerical IP address) Use i.e '-' to use default address. */ CINIT(FTPPORT, OBJECTPOINT, 17), /* Set the User-Agent string (examined by some CGIs) */ CINIT(USERAGENT, OBJECTPOINT, 18),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -