1 #ifndef __CURL_CURL_INIT_H 2 #define __CURL_CURL_INIT_H 3 /*************************************************************************** 4 * _ _ ____ _ 5 * Project ___| | | | _ \| | 6 * / __| | | | |_) | | 7 * | (__| |_| | _ <| |___ 8 * \___|\___/|_| \_\_____| 9 * 10 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, 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 * licensed versions 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 ***************************************************************************/ 24 25 /* 26 * If you have libcurl problems, all docs and details are found here: 27 * http://curl.haxx.se/libcurl/ 28 * 29 * curl-library mailing list subscription and unsubscription web interface: 30 * http://cool.haxx.se/mailman/listinfo/curl-library/ 31 */ 32 33 34 #ifdef __ghs__ 35 #include <stdio.h> 36 #endif /* __ghs__ */ 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #ifdef CURL_HIDDEN_SYMBOLS 43 /* 44 * This definition is used to make external definitions visible in the 45 * shared library when symbols are hidden by default. It makes no 46 * difference when compiling applications whether this is set or not, 47 * only when compiling the library. 48 */ 49 #define CURL_EXTERN CURL_EXTERN_SYMBOL 50 #else 51 #define CURL_EXTERN 52 #endif 53 54 /* All possible error codes from all sorts of curl functions. Future versions 55 may return other values, stay prepared. 56 57 Always add new return codes last. Never *EVER* remove any. The return 58 codes must remain the same! 59 */ 60 61 typedef enum { 62 CURLE_OK = 0, 63 CURLE_UNSUPPORTED_PROTOCOL, /* 1 */ 64 CURLE_FAILED_INIT, /* 2 */ 65 CURLE_URL_MALFORMAT, /* 3 */ 66 CURLE_NOT_BUILT_IN, /* 4 - [was obsoleted in August 2007 for 67 7.17.0, reused in April 2011 for 7.21.5] */ 68 CURLE_COULDNT_RESOLVE_PROXY, /* 5 */ 69 CURLE_COULDNT_RESOLVE_HOST, /* 6 */ 70 CURLE_COULDNT_CONNECT, /* 7 */ 71 CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */ 72 CURLE_REMOTE_ACCESS_DENIED, /* 9 a service was denied by the server 73 due to lack of access - when login fails 74 this is not returned. */ 75 CURLE_OBSOLETE10, /* 10 - NOT USED */ 76 CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */ 77 CURLE_OBSOLETE12, /* 12 - NOT USED */ 78 CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */ 79 CURLE_FTP_WEIRD_227_FORMAT, /* 14 */ 80 CURLE_FTP_CANT_GET_HOST, /* 15 */ 81 CURLE_OBSOLETE16, /* 16 - NOT USED */ 82 CURLE_FTP_COULDNT_SET_TYPE, /* 17 */ 83 CURLE_PARTIAL_FILE, /* 18 */ 84 CURLE_FTP_COULDNT_RETR_FILE, /* 19 */ 85 CURLE_OBSOLETE20, /* 20 - NOT USED */ 86 CURLE_QUOTE_ERROR, /* 21 - quote command failure */ 87 CURLE_HTTP_RETURNED_ERROR, /* 22 */ 88 CURLE_WRITE_ERROR, /* 23 */ 89 CURLE_OBSOLETE24, /* 24 - NOT USED */ 90 CURLE_UPLOAD_FAILED, /* 25 - failed upload "command" */ 91 CURLE_READ_ERROR, /* 26 - could not open/read from file */ 92 CURLE_OUT_OF_MEMORY, /* 27 */ 93 /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error 94 instead of a memory allocation error if CURL_DOES_CONVERSIONS 95 is defined 96 */ 97 CURLE_OPERATION_TIMEDOUT, /* 28 - the timeout time was reached */ 98 CURLE_OBSOLETE29, /* 29 - NOT USED */ 99 CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */ 100 CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */ 101 CURLE_OBSOLETE32, /* 32 - NOT USED */ 102 CURLE_RANGE_ERROR, /* 33 - RANGE "command" did not work */ 103 CURLE_HTTP_POST_ERROR, /* 34 */ 104 CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */ 105 CURLE_BAD_DOWNLOAD_RESUME, /* 36 - could not resume download */ 106 CURLE_FILE_COULDNT_READ_FILE, /* 37 */ 107 CURLE_LDAP_CANNOT_BIND, /* 38 */ 108 CURLE_LDAP_SEARCH_FAILED, /* 39 */ 109 CURLE_OBSOLETE40, /* 40 - NOT USED */ 110 CURLE_FUNCTION_NOT_FOUND, /* 41 */ 111 CURLE_ABORTED_BY_CALLBACK, /* 42 */ 112 CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */ 113 CURLE_OBSOLETE44, /* 44 - NOT USED */ 114 CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */ 115 CURLE_OBSOLETE46, /* 46 - NOT USED */ 116 CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */ 117 CURLE_UNKNOWN_OPTION, /* 48 - User specified an unknown option */ 118 CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */ 119 CURLE_OBSOLETE50, /* 50 - NOT USED */ 120 CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint 121 was not verified fine */ 122 CURLE_GOT_NOTHING, /* 52 - when this is a specific error */ 123 CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */ 124 CURLE_SSL_ENGINE_SETFAILED, /* 54 - cannot set SSL crypto engine as 125 default */ 126 CURLE_SEND_ERROR, /* 55 - failed sending network data */ 127 CURLE_RECV_ERROR, /* 56 - failure in receiving network data */ 128 CURLE_OBSOLETE57, /* 57 - NOT IN USE */ 129 CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */ 130 CURLE_SSL_CIPHER, /* 59 - could not use specified cipher */ 131 CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */ 132 CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized/bad encoding */ 133 CURLE_LDAP_INVALID_URL, /* 62 - Invalid LDAP URL */ 134 CURLE_FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */ 135 CURLE_USE_SSL_FAILED, /* 64 - Requested FTP SSL level failed */ 136 CURLE_SEND_FAIL_REWIND, /* 65 - Sending the data requires a rewind 137 that failed */ 138 CURLE_SSL_ENGINE_INITFAILED, /* 66 - failed to initialise ENGINE */ 139 CURLE_LOGIN_DENIED, /* 67 - user, password or similar was not 140 accepted and we failed to login */ 141 CURLE_TFTP_NOTFOUND, /* 68 - file not found on server */ 142 CURLE_TFTP_PERM, /* 69 - permission problem on server */ 143 CURLE_REMOTE_DISK_FULL, /* 70 - out of disk space on server */ 144 CURLE_TFTP_ILLEGAL, /* 71 - Illegal TFTP operation */ 145 CURLE_TFTP_UNKNOWNID, /* 72 - Unknown transfer ID */ 146 CURLE_REMOTE_FILE_EXISTS, /* 73 - File already exists */ 147 CURLE_TFTP_NOSUCHUSER, /* 74 - No such user */ 148 CURLE_CONV_FAILED, /* 75 - conversion failed */ 149 CURLE_CONV_REQD, /* 76 - caller must register conversion 150 callbacks using curl_easy_setopt options 151 CURLOPT_CONV_FROM_NETWORK_FUNCTION, 152 CURLOPT_CONV_TO_NETWORK_FUNCTION, and 153 CURLOPT_CONV_FROM_UTF8_FUNCTION */ 154 CURLE_SSL_CACERT_BADFILE, /* 77 - could not load CACERT file, missing 155 or wrong format */ 156 CURLE_REMOTE_FILE_NOT_FOUND, /* 78 - remote file not found */ 157 CURLE_SSH, /* 79 - error from the SSH layer, somewhat 158 generic so the error message will be of 159 interest when this has happened */ 160 161 CURLE_SSL_SHUTDOWN_FAILED, /* 80 - Failed to shut down the SSL 162 connection */ 163 CURLE_AGAIN, /* 81 - socket is not ready for send/recv, 164 wait till it is ready and try again (Added 165 in 7.18.2) */ 166 CURLE_SSL_CRL_BADFILE, /* 82 - could not load CRL file, missing or 167 wrong format (Added in 7.19.0) */ 168 CURLE_SSL_ISSUER_ERROR, /* 83 - Issuer check failed. (Added in 169 7.19.0) */ 170 CURLE_FTP_PRET_FAILED, /* 84 - a PRET command failed */ 171 CURLE_RTSP_CSEQ_ERROR, /* 85 - mismatch of RTSP CSeq numbers */ 172 CURLE_RTSP_SESSION_ERROR, /* 86 - mismatch of RTSP Session Ids */ 173 CURLE_FTP_BAD_FILE_LIST, /* 87 - unable to parse FTP file list */ 174 CURLE_CHUNK_FAILED, /* 88 - chunk callback reported error */ 175 CURLE_NSSL_NO_CTX, /* 89 - no NSSL context was set for handle 176 with https url */ 177 CURLE_READ_DEFAULT_PROXY, /* 90 - failed to read default proxy */ 178 CURLE_DEFAULT_PROXY_NOT_READY, /* 91 - default proxy is not loaded */ 179 180 CURL_LAST /* never use! */ 181 } CURLcode; 182 183 /* 184 * The following typedef's are signatures of malloc, free, realloc, strdup and 185 * calloc respectively. Function pointers of these types can be passed to the 186 * curl_global_init_mem() function to set user defined memory management 187 * callback routines. 188 */ 189 typedef void *(*curl_malloc_callback)(size_t size); 190 typedef void (*curl_free_callback)(void *ptr); 191 typedef void *(*curl_realloc_callback)(void *ptr, size_t size); 192 typedef char *(*curl_strdup_callback)(const char *str); 193 typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size); 194 195 /* 196 * NAME curl_global_init() 197 * 198 * DESCRIPTION 199 * 200 * curl_global_init() should be invoked exactly once for each application that 201 * uses libcurl and before any call of other libcurl functions. 202 * 203 * This function is not thread-safe! 204 */ 205 CURL_EXTERN CURLcode curl_global_init(long flags); 206 207 /* 208 * NAME curl_global_init_mem() 209 * 210 * DESCRIPTION 211 * 212 * curl_global_init() or curl_global_init_mem() should be invoked exactly once 213 * for each application that uses libcurl. This function can be used to 214 * initialize libcurl and set user defined memory management callback 215 * functions. Users can implement memory management routines to check for 216 * memory leaks, check for mis-use of the curl library etc. User registered 217 * callback routines will be invoked by this library instead of the system 218 * memory management routines like malloc, free etc. 219 */ 220 CURL_EXTERN CURLcode curl_global_init_mem(long flags, 221 curl_malloc_callback m, 222 curl_free_callback f, 223 curl_realloc_callback r, 224 curl_strdup_callback s, 225 curl_calloc_callback c); 226 227 /* 228 * NAME curl_global_cleanup() 229 * 230 * DESCRIPTION 231 * 232 * curl_global_cleanup() should be invoked exactly once for each application 233 * that uses libcurl 234 */ 235 CURL_EXTERN void curl_global_cleanup(void); 236 237 #define CURL_GLOBAL_SSL (1<<0) 238 #define CURL_GLOBAL_WIN32 (1<<1) 239 #define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32) 240 #define CURL_GLOBAL_NOTHING 0 241 #define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL 242 243 #ifdef __cplusplus 244 } 245 #endif 246 247 #endif /* __CURL_CURL_H */ 248