#ifndef __CURL_CURL_H #define __CURL_CURL_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2009, Daniel Stenberg, <[email protected]>, 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.396 2009-10-16 13:30:31 yangtse Exp $ ***************************************************************************/ /* * If you have libcurl problems, all docs and details are found here: * http://curl.haxx.se/libcurl/ * * curl-library mailing list subscription and unsubscription web interface: * http://cool.haxx.se/mailman/listinfo/curl-library/ */ /* * Leading 'curl' path on the 'curlbuild.h' include statement is * required to properly allow building outside of the source tree, * due to the fact that in this case 'curlbuild.h' is generated in * a subdirectory of the build tree while 'curl.h actually remains * in a subdirectory of the source tree. */ #include "third_party/curl/curlver.h" /* libcurl version defines */ #include "third_party/curl/curlbuild.h" /* libcurl build definitions */ #include "third_party/curl/curlrules.h" /* libcurl rules enforcement */ /* * Define WIN32 when build target is Win32 API */ #if (defined(_WIN32) || defined(__WIN32__)) && \ !defined(WIN32) && !defined(__SYMBIAN32__) #define WIN32 #endif #include <stdio.h> #include <limits.h> /* The include stuff here below is mainly for time_t! */ #include <sys/types.h> #include <time.h> #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) && \ !defined(__CYGWIN__) || defined(__MINGW32__) #if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H)) /* The check above prevents the winsock2 inclusion if winsock.h already was included, since they can't co-exist without problems */ #include <winsock2.h> #include <ws2tcpip.h> #endif #else /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish libc5-based Linux systems. Only include it on system that are known to require it! */ #if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \ defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \ defined(__ANDROID__) #include <sys/select.h> #endif #ifndef _WIN32_WCE #include <sys/socket.h> #endif #if !defined(WIN32) && !defined(__WATCOMC__) && !defined(__VXWORKS__) #include <sys/time.h> #endif #include <sys/types.h> #endif #ifdef __BEOS__ #include <support/SupportDefs.h> #endif #ifdef __cplusplus extern "C" { #endif CURL; /* * Decorate exportable functions for Win32 and Symbian OS DLL linking. * This avoids using a .def file for building libcurl.dll. */ #if (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)) && \ !defined(CURL_STATICLIB) #if defined(BUILDING_LIBCURL) #define CURL_EXTERN … #else #define CURL_EXTERN … #endif #else #ifdef CURL_HIDDEN_SYMBOLS /* * This definition is used to make external definitions visible in the * shared library when symbols are hidden by default. It makes no * difference when compiling applications whether this is set or not, * only when compiling the library. */ #define CURL_EXTERN … #else #define CURL_EXTERN #endif #endif #ifndef curl_socket_typedef /* socket typedef */ #ifdef WIN32 typedef SOCKET curl_socket_t; #define CURL_SOCKET_BAD … #else curl_socket_t; #define CURL_SOCKET_BAD … #endif #define curl_socket_typedef #endif /* curl_socket_typedef */ struct curl_httppost { … }; curl_progress_callback; #ifndef CURL_MAX_WRITE_SIZE /* 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. We do the ifndef check to allow this value to easier be changed at build time for those who feel adventurous. */ #define CURL_MAX_WRITE_SIZE … #endif #ifndef CURL_MAX_HTTP_HEADER /* The only reason to have a max limit for this is to avoid the risk of a bad server feeding libcurl with a never-ending header that will cause reallocs infinitely */ #define CURL_MAX_HTTP_HEADER … #endif /* This is a magic return code for the write callback that, when returned, will signal libcurl to pause receiving on the current transfer. */ #define CURL_WRITEFUNC_PAUSE … curl_write_callback; /* These are the return codes for the seek callbacks */ #define CURL_SEEKFUNC_OK … #define CURL_SEEKFUNC_FAIL … #define CURL_SEEKFUNC_CANTSEEK … curl_seek_callback; /* 'whence' */ /* This is a return code for the read callback that, when returned, will signal libcurl to immediately abort the current transfer. */ #define CURL_READFUNC_ABORT … /* This is a return code for the read callback that, when returned, will signal libcurl to pause sending data on the current transfer. */ #define CURL_READFUNC_PAUSE … curl_read_callback; curlsocktype; curl_sockopt_callback; struct curl_sockaddr { … }; curl_opensocket_callback; #ifndef CURL_NO_OLDIES /* not used since 7.10.8, will be removed in a future release */ curl_passwd_callback; #endif curlioerr; curliocmd; curl_ioctl_callback; /* * The following typedef's are signatures of malloc, free, realloc, strdup and * calloc respectively. Function pointers of these types can be passed to the * curl_global_init_mem() function to set user defined memory management * callback routines. */ curl_malloc_callback; curl_free_callback; curl_realloc_callback; curl_strdup_callback; curl_calloc_callback; /* the kind of data that is passed to information_callback*/ curl_infotype; curl_debug_callback; /* 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! */ CURLcode; #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all the obsolete stuff removed! */ /* Backwards compatibility with older names */ /* The following were added in 7.17.1 */ /* These are scheduled to disappear by 2009 */ #define CURLE_SSL_PEER_CERTIFICATE … /* The following were added in 7.17.0 */ /* These are scheduled to disappear by 2009 */ #define CURLE_OBSOLETE … #define CURLE_BAD_PASSWORD_ENTERED … #define CURLE_BAD_CALLING_ORDER … #define CURLE_FTP_USER_PASSWORD_INCORRECT … #define CURLE_FTP_CANT_RECONNECT … #define CURLE_FTP_COULDNT_GET_SIZE … #define CURLE_FTP_COULDNT_SET_ASCII … #define CURLE_FTP_WEIRD_USER_REPLY … #define CURLE_FTP_WRITE_ERROR … #define CURLE_LIBRARY_NOT_FOUND … #define CURLE_MALFORMAT_USER … #define CURLE_SHARE_IN_USE … #define CURLE_URL_MALFORMAT_USER … #define CURLE_FTP_ACCESS_DENIED … #define CURLE_FTP_COULDNT_SET_BINARY … #define CURLE_FTP_QUOTE_ERROR … #define CURLE_TFTP_DISKFULL … #define CURLE_TFTP_EXISTS … #define CURLE_HTTP_RANGE_ERROR … #define CURLE_FTP_SSL_FAILED … /* The following were added earlier */ #define CURLE_OPERATION_TIMEOUTED … #define CURLE_HTTP_NOT_FOUND … #define CURLE_HTTP_PORT_FAILED … #define CURLE_FTP_COULDNT_STOR_FILE … #define CURLE_FTP_PARTIAL_FILE … #define CURLE_FTP_BAD_DOWNLOAD_RESUME … /* 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 … #endif /*!CURL_NO_OLDIES*/ /* This prototype applies to all conversion callbacks */ curl_conv_callback; curl_ssl_ctx_callback; curl_proxytype; /* this enum was added in 7.10 */ #define CURLAUTH_NONE … #define CURLAUTH_BASIC … #define CURLAUTH_DIGEST … #define CURLAUTH_GSSNEGOTIATE … #define CURLAUTH_NTLM … #define CURLAUTH_DIGEST_IE … #define CURLAUTH_ANY … #define CURLAUTH_ANYSAFE … #define CURLSSH_AUTH_ANY … #define CURLSSH_AUTH_NONE … #define CURLSSH_AUTH_PUBLICKEY … #define CURLSSH_AUTH_PASSWORD … #define CURLSSH_AUTH_HOST … #define CURLSSH_AUTH_KEYBOARD … #define CURLSSH_AUTH_DEFAULT … #define CURL_ERROR_SIZE … struct curl_khkey { … }; /* this is the set of return values expected from the curl_sshkeycallback callback */ enum curl_khstat { … }; /* this is the set of status codes pass in to the callback */ enum curl_khmatch { … }; curl_sshkeycallback; /* custom pointer passed from app */ /* parameter for the CURLOPT_USE_SSL option */ curl_usessl; #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all the obsolete stuff removed! */ /* Backwards compatibility with older names */ /* These are scheduled to disappear by 2009 */ #define CURLFTPSSL_NONE … #define CURLFTPSSL_TRY … #define CURLFTPSSL_CONTROL … #define CURLFTPSSL_ALL … #define CURLFTPSSL_LAST … #define curl_ftpssl … #endif /*!CURL_NO_OLDIES*/ /* parameter for the CURLOPT_FTP_SSL_CCC option */ curl_ftpccc; /* parameter for the CURLOPT_FTPSSLAUTH option */ curl_ftpauth; /* parameter for the CURLOPT_FTP_CREATE_MISSING_DIRS option */ curl_ftpcreatedir; /* parameter for the CURLOPT_FTP_FILEMETHOD option */ curl_ftpmethod; /* CURLPROTO_ defines are for the CURLOPT_*PROTOCOLS options */ #define CURLPROTO_HTTP … #define CURLPROTO_HTTPS … #define CURLPROTO_FTP … #define CURLPROTO_FTPS … #define CURLPROTO_SCP … #define CURLPROTO_SFTP … #define CURLPROTO_TELNET … #define CURLPROTO_LDAP … #define CURLPROTO_LDAPS … #define CURLPROTO_DICT … #define CURLPROTO_FILE … #define CURLPROTO_TFTP … #define CURLPROTO_ALL … /* long may be 32 or 64 bits, but we should never depend on anything else but 32 */ #define CURLOPTTYPE_LONG … #define CURLOPTTYPE_OBJECTPOINT … #define CURLOPTTYPE_FUNCTIONPOINT … #define CURLOPTTYPE_OFF_T … /* name is uppercase CURLOPT_<name>, type is one of the defined CURLOPTTYPE_<type> number is unique identifier */ #ifdef CINIT #undef CINIT #endif #ifdef CURL_ISOCPP #define CINIT(name,type,number) … #else /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ #define LONG … #define OBJECTPOINT … #define FUNCTIONPOINT … #define OFF_T … #define CINIT … #endif /* * This macro-mania below setups the CURLOPT_[what] enum, to be used with * curl_easy_setopt(). The first argument in the CINIT() macro is the [what] * word. */ CURLoption; #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all the obsolete stuff removed! */ /* Backwards compatibility with older names */ /* These are scheduled to disappear by 2011 */ /* This was added in version 7.19.1 */ #define CURLOPT_POST301 … /* These are scheduled to disappear by 2009 */ /* The following were added in 7.17.0 */ #define CURLOPT_SSLKEYPASSWD … #define CURLOPT_FTPAPPEND … #define CURLOPT_FTPLISTONLY … #define CURLOPT_FTP_SSL … /* The following were added earlier */ #define CURLOPT_SSLCERTPASSWD … #define CURLOPT_KRB4LEVEL … #else /* This is set if CURL_NO_OLDIES is defined at compile-time */ #undef CURLOPT_DNS_USE_GLOBAL_CACHE /* soon obsolete */ #endif /* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host name resolves addresses using more than one IP protocol version, this option might be handy to force libcurl to use a specific IP version. */ #define CURL_IPRESOLVE_WHATEVER … #define CURL_IPRESOLVE_V4 … #define CURL_IPRESOLVE_V6 … /* three convenient "aliases" that follow the name scheme better */ #define CURLOPT_WRITEDATA … #define CURLOPT_READDATA … #define CURLOPT_HEADERDATA … /* These enums are for use with the CURLOPT_HTTP_VERSION option. */ enum { … }; /* These enums are for use with the CURLOPT_NETRC option. */ enum CURL_NETRC_OPTION { … }; enum { … }; /* symbols to use with CURLOPT_POSTREDIR. CURL_REDIR_POST_301 and CURL_REDIR_POST_302 can be bitwise ORed so that CURL_REDIR_POST_301 | CURL_REDIR_POST_302 == CURL_REDIR_POST_ALL */ #define CURL_REDIR_GET_ALL … #define CURL_REDIR_POST_301 … #define CURL_REDIR_POST_302 … #define CURL_REDIR_POST_ALL … curl_TimeCond; /* curl_strequal() and curl_strnequal() are subject for removal in a future libcurl, see lib/README.curlx for details */ CURL_EXTERN int (curl_strequal)(const char *s1, const char *s2); CURL_EXTERN int (curl_strnequal)(const char *s1, const char *s2, size_t n); /* name is uppercase CURLFORM_<name> */ #ifdef CFINIT #undef CFINIT #endif #ifdef CURL_ISOCPP #define CFINIT … #else /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ #define CFINIT … #endif CURLformoption; #undef CFINIT /* done */ /* structure to be used as parameter for CURLFORM_ARRAY */ struct curl_forms { … }; /* use this for multipart formpost building */ /* Returns code for curl_formadd() * * Returns: * CURL_FORMADD_OK on success * CURL_FORMADD_MEMORY if the FormInfo allocation fails * CURL_FORMADD_OPTION_TWICE if one option is given twice for one Form * CURL_FORMADD_NULL if a null pointer was given for a char * CURL_FORMADD_MEMORY if the allocation of a FormInfo struct failed * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used * CURL_FORMADD_INCOMPLETE if the some FormInfo is not complete (or error) * CURL_FORMADD_MEMORY if a curl_httppost struct cannot be allocated * CURL_FORMADD_MEMORY if some allocation for string copying failed. * CURL_FORMADD_ILLEGAL_ARRAY if an illegal option is used in an array * ***************************************************************************/ CURLFORMcode; /* * NAME curl_formadd() * * DESCRIPTION * * Pretty advanced function for building multi-part formposts. Each invoke * adds one part that together construct a full post. Then use * CURLOPT_HTTPPOST to send it off to libcurl. */ CURL_EXTERN CURLFORMcode curl_formadd(struct curl_httppost **httppost, struct curl_httppost **last_post, ...); /* * callback function for curl_formget() * The void *arg pointer will be the one passed as second argument to * curl_formget(). * The character buffer passed to it must not be freed. * Should return the buffer length passed to it as the argument "len" on * success. */ curl_formget_callback; /* * NAME curl_formget() * * DESCRIPTION * * Serialize a curl_httppost struct built with curl_formadd(). * Accepts a void pointer as second argument which will be passed to * the curl_formget_callback function. * Returns 0 on success. */ CURL_EXTERN int curl_formget(struct curl_httppost *form, void *arg, curl_formget_callback append); /* * NAME curl_formfree() * * DESCRIPTION * * Free a multipart formpost previously built with curl_formadd(). */ CURL_EXTERN void curl_formfree(struct curl_httppost *form); /* * NAME curl_getenv() * * DESCRIPTION * * Returns a malloc()'ed string that MUST be curl_free()ed after usage is * complete. DEPRECATED - see lib/README.curlx */ CURL_EXTERN char *curl_getenv(const char *variable); /* * NAME curl_version() * * DESCRIPTION * * Returns a static ascii string of the libcurl version. */ CURL_EXTERN char *curl_version(void); /* * NAME curl_easy_escape() * * DESCRIPTION * * Escapes URL strings (converts all letters consider illegal in URLs to their * %XX versions). This function returns a new allocated string or NULL if an * error occurred. */ CURL_EXTERN char *curl_easy_escape(CURL *handle, const char *string, int length); /* the previous version: */ CURL_EXTERN char *curl_escape(const char *string, int length); /* * NAME curl_easy_unescape() * * DESCRIPTION * * Unescapes URL encoding in strings (converts all %XX codes to their 8bit * versions). This function returns a new allocated string or NULL if an error * occurred. * Conversion Note: On non-ASCII platforms the ASCII %XX codes are * converted into the host encoding. */ CURL_EXTERN char *curl_easy_unescape(CURL *handle, const char *string, int length, int *outlength); /* the previous version */ CURL_EXTERN char *curl_unescape(const char *string, int length); /* * NAME curl_free() * * DESCRIPTION * * Provided for de-allocation in the same translation unit that did the * allocation. Added in libcurl 7.10 */ CURL_EXTERN void curl_free(void *p); /* * NAME curl_global_init() * * DESCRIPTION * * curl_global_init() should be invoked exactly once for each application that * uses libcurl and before any call of other libcurl functions. * * This function is not thread-safe! */ CURL_EXTERN CURLcode curl_global_init(long flags); /* * NAME curl_global_init_mem() * * DESCRIPTION * * curl_global_init() or curl_global_init_mem() should be invoked exactly once * for each application that uses libcurl. This function can be used to * initialize libcurl and set user defined memory management callback * functions. Users can implement memory management routines to check for * memory leaks, check for mis-use of the curl library etc. User registered * callback routines with be invoked by this library instead of the system * memory management routines like malloc, free etc. */ CURL_EXTERN CURLcode curl_global_init_mem(long flags, curl_malloc_callback m, curl_free_callback f, curl_realloc_callback r, curl_strdup_callback s, curl_calloc_callback c); /* * NAME curl_global_cleanup() * * DESCRIPTION * * curl_global_cleanup() should be invoked exactly once for each application * that uses libcurl */ CURL_EXTERN void curl_global_cleanup(void); /* linked-list structure for the CURLOPT_QUOTE option (and other) */ struct curl_slist { … }; /* * NAME curl_slist_append() * * DESCRIPTION * * Appends a string to a linked list. If no list exists, it will be created * first. Returns the new list, after appending. */ CURL_EXTERN struct curl_slist *curl_slist_append(struct curl_slist *, const char *); /* * NAME curl_slist_free_all() * * DESCRIPTION * * free a previously built curl_slist. */ CURL_EXTERN void curl_slist_free_all(struct curl_slist *); /* * NAME curl_getdate() * * DESCRIPTION * * Returns the time, in seconds since 1 Jan 1970 of the time string given in * the first argument. The time argument in the second parameter is unused * and should be set to NULL. */ CURL_EXTERN time_t curl_getdate(const char *p, const time_t *unused); /* info about the certificate chain, only for OpenSSL builds. Asked for with CURLOPT_CERTINFO / CURLINFO_CERTINFO */ struct curl_certinfo { … }; #define CURLINFO_STRING … #define CURLINFO_LONG … #define CURLINFO_DOUBLE … #define CURLINFO_SLIST … #define CURLINFO_MASK … #define CURLINFO_TYPEMASK … CURLINFO; /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as CURLINFO_HTTP_CODE */ #define CURLINFO_HTTP_CODE … curl_closepolicy; #define CURL_GLOBAL_SSL … #define CURL_GLOBAL_WIN32 … #define CURL_GLOBAL_ALL … #define CURL_GLOBAL_NOTHING … #define CURL_GLOBAL_DEFAULT … /***************************************************************************** * Setup defines, protos etc for the sharing stuff. */ /* Different data locks for a single share */ curl_lock_data; /* Different lock access types */ curl_lock_access; curl_lock_function; curl_unlock_function; CURLSH; CURLSHcode; CURLSHoption; CURL_EXTERN CURLSH *curl_share_init(void); CURL_EXTERN CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...); CURL_EXTERN CURLSHcode curl_share_cleanup(CURLSH *); /**************************************************************************** * Structures for querying information about the curl library at runtime. */ CURLversion; /* The 'CURLVERSION_NOW' is the symbolic name meant to be used by basically all programs ever that want to get version information. It is meant to be a built-in version number for what kind of struct the caller expects. If the struct ever changes, we redefine the NOW to another enum from above. */ #define CURLVERSION_NOW … curl_version_info_data; #define CURL_VERSION_IPV6 … #define CURL_VERSION_KERBEROS4 … #define CURL_VERSION_SSL … #define CURL_VERSION_LIBZ … #define CURL_VERSION_NTLM … #define CURL_VERSION_GSSNEGOTIATE … #define CURL_VERSION_DEBUG … #define CURL_VERSION_ASYNCHDNS … #define CURL_VERSION_SPNEGO … #define CURL_VERSION_LARGEFILE … #define CURL_VERSION_IDN … #define CURL_VERSION_SSPI … #define CURL_VERSION_CONV … #define CURL_VERSION_CURLDEBUG … /* * NAME curl_version_info() * * DESCRIPTION * * This function returns a pointer to a static copy of the version info * struct. See above. */ CURL_EXTERN curl_version_info_data *curl_version_info(CURLversion); /* * NAME curl_easy_strerror() * * DESCRIPTION * * The curl_easy_strerror function may be used to turn a CURLcode value * into the equivalent human readable error string. This is useful * for printing meaningful error messages. */ CURL_EXTERN const char *curl_easy_strerror(CURLcode); /* * NAME curl_share_strerror() * * DESCRIPTION * * The curl_share_strerror function may be used to turn a CURLSHcode value * into the equivalent human readable error string. This is useful * for printing meaningful error messages. */ CURL_EXTERN const char *curl_share_strerror(CURLSHcode); /* * NAME curl_easy_pause() * * DESCRIPTION * * The curl_easy_pause function pauses or unpauses transfers. Select the new * state by setting the bitmask, use the convenience defines below. * */ CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask); #define CURLPAUSE_RECV … #define CURLPAUSE_RECV_CONT … #define CURLPAUSE_SEND … #define CURLPAUSE_SEND_CONT … #define CURLPAUSE_ALL … #define CURLPAUSE_CONT … #ifdef __cplusplus } #endif /* unfortunately, the easy.h and multi.h include files need options and info stuff before they can be included! */ #include "easy.h" /* nothing in curl is fun without the easy stuff */ #include "multi.h" /* the typechecker doesn't work in C++ (yet) */ #if defined(__GNUC__) && defined(__GNUC_MINOR__) && \ ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && \ !defined(__cplusplus) && !defined(CURL_DISABLE_TYPECHECK) #include "typecheck-gcc.h" #else #if defined(__STDC__) && (__STDC__ >= 1) /* This preprocessor magic that replaces a call with the exact same call is only done to make sure application authors pass exactly three arguments to these functions. */ #define curl_easy_setopt(handle,opt,param) … #define curl_easy_getinfo(handle,info,arg) … #define curl_share_setopt(share,opt,param) … #define curl_multi_setopt(handle,opt,param) … #endif /* __STDC__ >= 1 */ #endif /* gcc >= 4.3 && !__cplusplus */ #endif /* __CURL_CURL_H */