| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* GATE PROJECT LICENSE: | ||
| 2 | +----------------------------------------------------------------------------+ | ||
| 3 | | Copyright(c) 2018-2025, Stefan Meislinger <sm@opengate.at> | | ||
| 4 | | All rights reserved. | | ||
| 5 | | | | ||
| 6 | | Redistribution and use in source and binary forms, with or without | | ||
| 7 | | modification, are permitted provided that the following conditions are met:| | ||
| 8 | | | | ||
| 9 | | 1. Redistributions of source code must retain the above copyright notice, | | ||
| 10 | | this list of conditions and the following disclaimer. | | ||
| 11 | | 2. Redistributions in binary form must reproduce the above copyright | | ||
| 12 | | notice, this list of conditions and the following disclaimer in the | | ||
| 13 | | documentation and/or other materials provided with the distribution. | | ||
| 14 | | | | ||
| 15 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"| | ||
| 16 | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | ||
| 17 | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | ||
| 18 | | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | | ||
| 19 | | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | ||
| 20 | | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | ||
| 21 | | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | ||
| 22 | | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | ||
| 23 | | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | ||
| 24 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | | ||
| 25 | | THE POSSIBILITY OF SUCH DAMAGE. | | ||
| 26 | +----------------------------------------------------------------------------+ | ||
| 27 | */ | ||
| 28 | |||
| 29 | #ifndef GATE_NET_LIBCURL_API_H_INCLUDED | ||
| 30 | #define GATE_NET_LIBCURL_API_H_INCLUDED | ||
| 31 | |||
| 32 | typedef enum | ||
| 33 | { | ||
| 34 | CURLE_OK = 0, | ||
| 35 | CURLE_UNSUPPORTED_PROTOCOL, /* 1 */ | ||
| 36 | CURLE_FAILED_INIT, /* 2 */ | ||
| 37 | CURLE_URL_MALFORMAT, /* 3 */ | ||
| 38 | CURLE_NOT_BUILT_IN, /* 4 - [was obsoleted in August 2007 for | ||
| 39 | 7.17.0, reused in April 2011 for 7.21.5] */ | ||
| 40 | CURLE_COULDNT_RESOLVE_PROXY, /* 5 */ | ||
| 41 | CURLE_COULDNT_RESOLVE_HOST, /* 6 */ | ||
| 42 | CURLE_COULDNT_CONNECT, /* 7 */ | ||
| 43 | CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */ | ||
| 44 | CURLE_REMOTE_ACCESS_DENIED, /* 9 a service was denied by the server | ||
| 45 | due to lack of access - when login fails | ||
| 46 | this is not returned. */ | ||
| 47 | CURLE_FTP_ACCEPT_FAILED, /* 10 - [was obsoleted in April 2006 for | ||
| 48 | 7.15.4, reused in Dec 2011 for 7.24.0]*/ | ||
| 49 | CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */ | ||
| 50 | CURLE_FTP_ACCEPT_TIMEOUT, /* 12 - timeout occurred accepting server | ||
| 51 | [was obsoleted in August 2007 for 7.17.0, | ||
| 52 | reused in Dec 2011 for 7.24.0]*/ | ||
| 53 | CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */ | ||
| 54 | CURLE_FTP_WEIRD_227_FORMAT, /* 14 */ | ||
| 55 | CURLE_FTP_CANT_GET_HOST, /* 15 */ | ||
| 56 | CURLE_OBSOLETE16, /* 16 - NOT USED */ | ||
| 57 | CURLE_FTP_COULDNT_SET_TYPE, /* 17 */ | ||
| 58 | CURLE_PARTIAL_FILE, /* 18 */ | ||
| 59 | CURLE_FTP_COULDNT_RETR_FILE, /* 19 */ | ||
| 60 | CURLE_OBSOLETE20, /* 20 - NOT USED */ | ||
| 61 | CURLE_QUOTE_ERROR, /* 21 - quote command failure */ | ||
| 62 | CURLE_HTTP_RETURNED_ERROR, /* 22 */ | ||
| 63 | CURLE_WRITE_ERROR, /* 23 */ | ||
| 64 | CURLE_OBSOLETE24, /* 24 - NOT USED */ | ||
| 65 | CURLE_UPLOAD_FAILED, /* 25 - failed upload "command" */ | ||
| 66 | CURLE_READ_ERROR, /* 26 - couldn't open/read from file */ | ||
| 67 | CURLE_OUT_OF_MEMORY, /* 27 */ | ||
| 68 | /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error | ||
| 69 | instead of a memory allocation error if CURL_DOES_CONVERSIONS | ||
| 70 | is defined | ||
| 71 | */ | ||
| 72 | CURLE_OPERATION_TIMEDOUT, /* 28 - the timeout time was reached */ | ||
| 73 | CURLE_OBSOLETE29, /* 29 - NOT USED */ | ||
| 74 | CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */ | ||
| 75 | CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */ | ||
| 76 | CURLE_OBSOLETE32, /* 32 - NOT USED */ | ||
| 77 | CURLE_RANGE_ERROR, /* 33 - RANGE "command" didn't work */ | ||
| 78 | CURLE_HTTP_POST_ERROR, /* 34 */ | ||
| 79 | CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */ | ||
| 80 | CURLE_BAD_DOWNLOAD_RESUME, /* 36 - couldn't resume download */ | ||
| 81 | CURLE_FILE_COULDNT_READ_FILE, /* 37 */ | ||
| 82 | CURLE_LDAP_CANNOT_BIND, /* 38 */ | ||
| 83 | CURLE_LDAP_SEARCH_FAILED, /* 39 */ | ||
| 84 | CURLE_OBSOLETE40, /* 40 - NOT USED */ | ||
| 85 | CURLE_FUNCTION_NOT_FOUND, /* 41 */ | ||
| 86 | CURLE_ABORTED_BY_CALLBACK, /* 42 */ | ||
| 87 | CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */ | ||
| 88 | CURLE_OBSOLETE44, /* 44 - NOT USED */ | ||
| 89 | CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */ | ||
| 90 | CURLE_OBSOLETE46, /* 46 - NOT USED */ | ||
| 91 | CURLE_TOO_MANY_REDIRECTS, /* 47 - catch endless re-direct loops */ | ||
| 92 | CURLE_UNKNOWN_OPTION, /* 48 - User specified an unknown option */ | ||
| 93 | CURLE_TELNET_OPTION_SYNTAX, /* 49 - Malformed telnet option */ | ||
| 94 | CURLE_OBSOLETE50, /* 50 - NOT USED */ | ||
| 95 | CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint | ||
| 96 | wasn't verified fine */ | ||
| 97 | CURLE_GOT_NOTHING, /* 52 - when this is a specific error */ | ||
| 98 | CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */ | ||
| 99 | CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as | ||
| 100 | default */ | ||
| 101 | CURLE_SEND_ERROR, /* 55 - failed sending network data */ | ||
| 102 | CURLE_RECV_ERROR, /* 56 - failure in receiving network data */ | ||
| 103 | CURLE_OBSOLETE57, /* 57 - NOT IN USE */ | ||
| 104 | CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */ | ||
| 105 | CURLE_SSL_CIPHER, /* 59 - couldn't use specified cipher */ | ||
| 106 | CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */ | ||
| 107 | CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized/bad encoding */ | ||
| 108 | CURLE_LDAP_INVALID_URL, /* 62 - Invalid LDAP URL */ | ||
| 109 | CURLE_FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */ | ||
| 110 | CURLE_USE_SSL_FAILED, /* 64 - Requested FTP SSL level failed */ | ||
| 111 | CURLE_SEND_FAIL_REWIND, /* 65 - Sending the data requires a rewind | ||
| 112 | that failed */ | ||
| 113 | CURLE_SSL_ENGINE_INITFAILED, /* 66 - failed to initialise ENGINE */ | ||
| 114 | CURLE_LOGIN_DENIED, /* 67 - user, password or similar was not | ||
| 115 | accepted and we failed to login */ | ||
| 116 | CURLE_TFTP_NOTFOUND, /* 68 - file not found on server */ | ||
| 117 | CURLE_TFTP_PERM, /* 69 - permission problem on server */ | ||
| 118 | CURLE_REMOTE_DISK_FULL, /* 70 - out of disk space on server */ | ||
| 119 | CURLE_TFTP_ILLEGAL, /* 71 - Illegal TFTP operation */ | ||
| 120 | CURLE_TFTP_UNKNOWNID, /* 72 - Unknown transfer ID */ | ||
| 121 | CURLE_REMOTE_FILE_EXISTS, /* 73 - File already exists */ | ||
| 122 | CURLE_TFTP_NOSUCHUSER, /* 74 - No such user */ | ||
| 123 | CURLE_CONV_FAILED, /* 75 - conversion failed */ | ||
| 124 | CURLE_CONV_REQD, /* 76 - caller must register conversion | ||
| 125 | callbacks using curl_easy_setopt options | ||
| 126 | CURLOPT_CONV_FROM_NETWORK_FUNCTION, | ||
| 127 | CURLOPT_CONV_TO_NETWORK_FUNCTION, and | ||
| 128 | CURLOPT_CONV_FROM_UTF8_FUNCTION */ | ||
| 129 | CURLE_SSL_CACERT_BADFILE, /* 77 - could not load CACERT file, missing | ||
| 130 | or wrong format */ | ||
| 131 | CURLE_REMOTE_FILE_NOT_FOUND, /* 78 - remote file not found */ | ||
| 132 | CURLE_SSH, /* 79 - error from the SSH layer, somewhat | ||
| 133 | generic so the error message will be of | ||
| 134 | interest when this has happened */ | ||
| 135 | |||
| 136 | CURLE_SSL_SHUTDOWN_FAILED, /* 80 - Failed to shut down the SSL | ||
| 137 | connection */ | ||
| 138 | CURLE_AGAIN, /* 81 - socket is not ready for send/recv, | ||
| 139 | wait till it's ready and try again (Added | ||
| 140 | in 7.18.2) */ | ||
| 141 | CURLE_SSL_CRL_BADFILE, /* 82 - could not load CRL file, missing or | ||
| 142 | wrong format (Added in 7.19.0) */ | ||
| 143 | CURLE_SSL_ISSUER_ERROR, /* 83 - Issuer check failed. (Added in | ||
| 144 | 7.19.0) */ | ||
| 145 | CURLE_FTP_PRET_FAILED, /* 84 - a PRET command failed */ | ||
| 146 | CURLE_RTSP_CSEQ_ERROR, /* 85 - mismatch of RTSP CSeq numbers */ | ||
| 147 | CURLE_RTSP_SESSION_ERROR, /* 86 - mismatch of RTSP Session Ids */ | ||
| 148 | CURLE_FTP_BAD_FILE_LIST, /* 87 - unable to parse FTP file list */ | ||
| 149 | CURLE_CHUNK_FAILED, /* 88 - chunk callback reported error */ | ||
| 150 | CURL_LAST /* never use! */ | ||
| 151 | } CURLcode; | ||
| 152 | |||
| 153 | |||
| 154 | typedef enum { | ||
| 155 | CURLVERSION_FIRST, | ||
| 156 | CURLVERSION_SECOND, | ||
| 157 | CURLVERSION_THIRD, | ||
| 158 | CURLVERSION_FOURTH, | ||
| 159 | CURLVERSION_FIFTH, | ||
| 160 | CURLVERSION_SIXTH, | ||
| 161 | CURLVERSION_SEVENTH, | ||
| 162 | CURLVERSION_EIGHTH, | ||
| 163 | CURLVERSION_NINTH, | ||
| 164 | CURLVERSION_TENTH, | ||
| 165 | CURLVERSION_ELEVENTH | ||
| 166 | } CURLversion; | ||
| 167 | |||
| 168 | #define CURLVERSION_NOW CURLVERSION_ELEVENTH | ||
| 169 | |||
| 170 | struct curl_version_info_data { | ||
| 171 | CURLversion age; /* age of the returned struct */ | ||
| 172 | const char *version; /* LIBCURL_VERSION */ | ||
| 173 | unsigned int version_num; /* LIBCURL_VERSION_NUM */ | ||
| 174 | const char *host; /* OS/host/cpu/machine when configured */ | ||
| 175 | int features; /* bitmask, see defines below */ | ||
| 176 | const char *ssl_version; /* human readable string */ | ||
| 177 | long ssl_version_num; /* not used anymore, always 0 */ | ||
| 178 | const char *libz_version; /* human readable string */ | ||
| 179 | /* protocols is terminated by an entry with a NULL protoname */ | ||
| 180 | const char * const *protocols; | ||
| 181 | |||
| 182 | /* The fields below this were added in CURLVERSION_SECOND */ | ||
| 183 | const char *ares; | ||
| 184 | int ares_num; | ||
| 185 | |||
| 186 | /* This field was added in CURLVERSION_THIRD */ | ||
| 187 | const char *libidn; | ||
| 188 | |||
| 189 | /* These field were added in CURLVERSION_FOURTH */ | ||
| 190 | |||
| 191 | /* Same as '_libiconv_version' if built with HAVE_ICONV */ | ||
| 192 | int iconv_ver_num; | ||
| 193 | |||
| 194 | const char *libssh_version; /* human readable string */ | ||
| 195 | |||
| 196 | /* These fields were added in CURLVERSION_FIFTH */ | ||
| 197 | unsigned int brotli_ver_num; /* Numeric Brotli version | ||
| 198 | (MAJOR << 24) | (MINOR << 12) | PATCH */ | ||
| 199 | const char *brotli_version; /* human readable string. */ | ||
| 200 | |||
| 201 | /* These fields were added in CURLVERSION_SIXTH */ | ||
| 202 | unsigned int nghttp2_ver_num; /* Numeric nghttp2 version | ||
| 203 | (MAJOR << 16) | (MINOR << 8) | PATCH */ | ||
| 204 | const char *nghttp2_version; /* human readable string. */ | ||
| 205 | const char *quic_version; /* human readable quic (+ HTTP/3) library + | ||
| 206 | version or NULL */ | ||
| 207 | |||
| 208 | /* These fields were added in CURLVERSION_SEVENTH */ | ||
| 209 | const char *cainfo; /* the built-in default CURLOPT_CAINFO, might | ||
| 210 | be NULL */ | ||
| 211 | const char *capath; /* the built-in default CURLOPT_CAPATH, might | ||
| 212 | be NULL */ | ||
| 213 | |||
| 214 | /* These fields were added in CURLVERSION_EIGHTH */ | ||
| 215 | unsigned int zstd_ver_num; /* Numeric Zstd version | ||
| 216 | (MAJOR << 24) | (MINOR << 12) | PATCH */ | ||
| 217 | const char *zstd_version; /* human readable string. */ | ||
| 218 | |||
| 219 | /* These fields were added in CURLVERSION_NINTH */ | ||
| 220 | const char *hyper_version; /* human readable string. */ | ||
| 221 | |||
| 222 | /* These fields were added in CURLVERSION_TENTH */ | ||
| 223 | const char *gsasl_version; /* human readable string. */ | ||
| 224 | |||
| 225 | /* These fields were added in CURLVERSION_ELEVENTH */ | ||
| 226 | /* feature_names is terminated by an entry with a NULL feature name */ | ||
| 227 | const char * const *feature_names; | ||
| 228 | }; | ||
| 229 | |||
| 230 | |||
| 231 | #define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */ | ||
| 232 | #define CURL_VERSION_KERBEROS4 (1<<1) /* Kerberos V4 auth is supported | ||
| 233 | (deprecated) */ | ||
| 234 | #define CURL_VERSION_SSL (1<<2) /* SSL options are present */ | ||
| 235 | #define CURL_VERSION_LIBZ (1<<3) /* libz features are present */ | ||
| 236 | #define CURL_VERSION_NTLM (1<<4) /* NTLM auth is supported */ | ||
| 237 | #define CURL_VERSION_GSSNEGOTIATE (1<<5) /* Negotiate auth is supported | ||
| 238 | (deprecated) */ | ||
| 239 | #define CURL_VERSION_DEBUG (1<<6) /* Built with debug capabilities */ | ||
| 240 | #define CURL_VERSION_ASYNCHDNS (1<<7) /* Asynchronous DNS resolves */ | ||
| 241 | #define CURL_VERSION_SPNEGO (1<<8) /* SPNEGO auth is supported */ | ||
| 242 | #define CURL_VERSION_LARGEFILE (1<<9) /* Supports files larger than 2GB */ | ||
| 243 | #define CURL_VERSION_IDN (1<<10) /* Internationized Domain Names are | ||
| 244 | supported */ | ||
| 245 | #define CURL_VERSION_SSPI (1<<11) /* Built against Windows SSPI */ | ||
| 246 | #define CURL_VERSION_CONV (1<<12) /* Character conversions supported */ | ||
| 247 | #define CURL_VERSION_CURLDEBUG (1<<13) /* Debug memory tracking supported */ | ||
| 248 | #define CURL_VERSION_TLSAUTH_SRP (1<<14) /* TLS-SRP auth is supported */ | ||
| 249 | #define CURL_VERSION_NTLM_WB (1<<15) /* NTLM delegation to winbind helper | ||
| 250 | is supported */ | ||
| 251 | #define CURL_VERSION_HTTP2 (1<<16) /* HTTP2 support built-in */ | ||
| 252 | #define CURL_VERSION_GSSAPI (1<<17) /* Built against a GSS-API library */ | ||
| 253 | #define CURL_VERSION_KERBEROS5 (1<<18) /* Kerberos V5 auth is supported */ | ||
| 254 | #define CURL_VERSION_UNIX_SOCKETS (1<<19) /* Unix domain sockets support */ | ||
| 255 | #define CURL_VERSION_PSL (1<<20) /* Mozilla's Public Suffix List, used | ||
| 256 | for cookie domain verification */ | ||
| 257 | #define CURL_VERSION_HTTPS_PROXY (1<<21) /* HTTPS-proxy support built-in */ | ||
| 258 | #define CURL_VERSION_MULTI_SSL (1<<22) /* Multiple SSL backends available */ | ||
| 259 | #define CURL_VERSION_BROTLI (1<<23) /* Brotli features are present. */ | ||
| 260 | #define CURL_VERSION_ALTSVC (1<<24) /* Alt-Svc handling built-in */ | ||
| 261 | #define CURL_VERSION_HTTP3 (1<<25) /* HTTP3 support built-in */ | ||
| 262 | #define CURL_VERSION_ZSTD (1<<26) /* zstd features are present */ | ||
| 263 | #define CURL_VERSION_UNICODE (1<<27) /* Unicode support on Windows */ | ||
| 264 | #define CURL_VERSION_HSTS (1<<28) /* HSTS is supported */ | ||
| 265 | #define CURL_VERSION_GSASL (1<<29) /* libgsasl is supported */ | ||
| 266 | #define CURL_VERSION_THREADSAFE (1<<30) /* libcurl API is thread-safe */ | ||
| 267 | |||
| 268 | |||
| 269 | |||
| 270 | /* CURLPROTO_ defines are for the CURLOPT_*PROTOCOLS options */ | ||
| 271 | #define CURLPROTO_HTTP (1<<0) | ||
| 272 | #define CURLPROTO_HTTPS (1<<1) | ||
| 273 | #define CURLPROTO_FTP (1<<2) | ||
| 274 | #define CURLPROTO_FTPS (1<<3) | ||
| 275 | #define CURLPROTO_SCP (1<<4) | ||
| 276 | #define CURLPROTO_SFTP (1<<5) | ||
| 277 | #define CURLPROTO_TELNET (1<<6) | ||
| 278 | #define CURLPROTO_LDAP (1<<7) | ||
| 279 | #define CURLPROTO_LDAPS (1<<8) | ||
| 280 | #define CURLPROTO_DICT (1<<9) | ||
| 281 | #define CURLPROTO_FILE (1<<10) | ||
| 282 | #define CURLPROTO_TFTP (1<<11) | ||
| 283 | #define CURLPROTO_IMAP (1<<12) | ||
| 284 | #define CURLPROTO_IMAPS (1<<13) | ||
| 285 | #define CURLPROTO_POP3 (1<<14) | ||
| 286 | #define CURLPROTO_POP3S (1<<15) | ||
| 287 | #define CURLPROTO_SMTP (1<<16) | ||
| 288 | #define CURLPROTO_SMTPS (1<<17) | ||
| 289 | #define CURLPROTO_RTSP (1<<18) | ||
| 290 | #define CURLPROTO_RTMP (1<<19) | ||
| 291 | #define CURLPROTO_RTMPT (1<<20) | ||
| 292 | #define CURLPROTO_RTMPE (1<<21) | ||
| 293 | #define CURLPROTO_RTMPTE (1<<22) | ||
| 294 | #define CURLPROTO_RTMPS (1<<23) | ||
| 295 | #define CURLPROTO_RTMPTS (1<<24) | ||
| 296 | #define CURLPROTO_GOPHER (1<<25) | ||
| 297 | #define CURLPROTO_ALL (~0) /* enable everything */ | ||
| 298 | |||
| 299 | |||
| 300 | #define CURLOPTTYPE_LONG 0 | ||
| 301 | #define CURLOPTTYPE_OBJECTPOINT 10000 | ||
| 302 | #define CURLOPTTYPE_FUNCTIONPOINT 20000 | ||
| 303 | #define CURLOPTTYPE_OFF_T 30000 | ||
| 304 | |||
| 305 | |||
| 306 | #define CINIT(name,type,number) CURLOPT_ ## name = type + number | ||
| 307 | |||
| 308 | typedef enum | ||
| 309 | { | ||
| 310 | CINIT(FILE, CURLOPTTYPE_OBJECTPOINT, 1), | ||
| 311 | CINIT(URL, CURLOPTTYPE_OBJECTPOINT, 2), | ||
| 312 | CINIT(PORT, CURLOPTTYPE_LONG, 3), | ||
| 313 | CINIT(PROXY, CURLOPTTYPE_OBJECTPOINT, 4), | ||
| 314 | CINIT(USERPWD, CURLOPTTYPE_OBJECTPOINT, 5), | ||
| 315 | CINIT(PROXYUSERPWD, CURLOPTTYPE_OBJECTPOINT, 6), | ||
| 316 | CINIT(RANGE, CURLOPTTYPE_OBJECTPOINT, 7), | ||
| 317 | CINIT(INFILE, CURLOPTTYPE_OBJECTPOINT, 9), | ||
| 318 | CINIT(ERRORBUFFER, CURLOPTTYPE_OBJECTPOINT, 10), | ||
| 319 | CINIT(WRITEFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 11), | ||
| 320 | CINIT(READFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 12), | ||
| 321 | CINIT(TIMEOUT, CURLOPTTYPE_LONG, 13), | ||
| 322 | CINIT(INFILESIZE, CURLOPTTYPE_LONG, 14), | ||
| 323 | CINIT(POSTFIELDS, CURLOPTTYPE_OBJECTPOINT, 15), | ||
| 324 | CINIT(REFERER, CURLOPTTYPE_OBJECTPOINT, 16), | ||
| 325 | CINIT(FTPPORT, CURLOPTTYPE_OBJECTPOINT, 17), | ||
| 326 | CINIT(USERAGENT, CURLOPTTYPE_OBJECTPOINT, 18), | ||
| 327 | CINIT(LOW_SPEED_LIMIT, CURLOPTTYPE_LONG, 19), | ||
| 328 | CINIT(LOW_SPEED_TIME, CURLOPTTYPE_LONG, 20), | ||
| 329 | CINIT(RESUME_FROM, CURLOPTTYPE_LONG, 21), | ||
| 330 | CINIT(COOKIE, CURLOPTTYPE_OBJECTPOINT, 22), | ||
| 331 | CINIT(HTTPHEADER, CURLOPTTYPE_OBJECTPOINT, 23), | ||
| 332 | CINIT(HTTPPOST, CURLOPTTYPE_OBJECTPOINT, 24), | ||
| 333 | CINIT(SSLCERT, CURLOPTTYPE_OBJECTPOINT, 25), | ||
| 334 | CINIT(KEYPASSWD, CURLOPTTYPE_OBJECTPOINT, 26), | ||
| 335 | CINIT(CRLF, CURLOPTTYPE_LONG, 27), | ||
| 336 | CINIT(QUOTE, CURLOPTTYPE_OBJECTPOINT, 28), | ||
| 337 | CINIT(WRITEHEADER, CURLOPTTYPE_OBJECTPOINT, 29), | ||
| 338 | CINIT(COOKIEFILE, CURLOPTTYPE_OBJECTPOINT, 31), | ||
| 339 | CINIT(SSLVERSION, CURLOPTTYPE_LONG, 32), | ||
| 340 | CINIT(TIMECONDITION, CURLOPTTYPE_LONG, 33), | ||
| 341 | CINIT(TIMEVALUE, CURLOPTTYPE_LONG, 34), | ||
| 342 | CINIT(CUSTOMREQUEST, CURLOPTTYPE_OBJECTPOINT, 36), | ||
| 343 | CINIT(STDERR, CURLOPTTYPE_OBJECTPOINT, 37), | ||
| 344 | CINIT(POSTQUOTE, CURLOPTTYPE_OBJECTPOINT, 39), | ||
| 345 | CINIT(WRITEINFO, CURLOPTTYPE_OBJECTPOINT, 40), | ||
| 346 | CINIT(VERBOSE, CURLOPTTYPE_LONG, 41), | ||
| 347 | CINIT(HEADER, CURLOPTTYPE_LONG, 42), | ||
| 348 | CINIT(NOPROGRESS, CURLOPTTYPE_LONG, 43), | ||
| 349 | CINIT(NOBODY, CURLOPTTYPE_LONG, 44), | ||
| 350 | CINIT(FAILONERROR, CURLOPTTYPE_LONG, 45), | ||
| 351 | CINIT(UPLOAD, CURLOPTTYPE_LONG, 46), | ||
| 352 | CINIT(POST, CURLOPTTYPE_LONG, 47), | ||
| 353 | CINIT(DIRLISTONLY, CURLOPTTYPE_LONG, 48), | ||
| 354 | CINIT(APPEND, CURLOPTTYPE_LONG, 50), | ||
| 355 | CINIT(NETRC, CURLOPTTYPE_LONG, 51), | ||
| 356 | CINIT(FOLLOWLOCATION, CURLOPTTYPE_LONG, 52), | ||
| 357 | CINIT(TRANSFERTEXT, CURLOPTTYPE_LONG, 53), | ||
| 358 | CINIT(PUT, CURLOPTTYPE_LONG, 54), | ||
| 359 | CINIT(PROGRESSFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 56), | ||
| 360 | CINIT(PROGRESSDATA, CURLOPTTYPE_OBJECTPOINT, 57), | ||
| 361 | CINIT(AUTOREFERER, CURLOPTTYPE_LONG, 58), | ||
| 362 | CINIT(PROXYPORT, CURLOPTTYPE_LONG, 59), | ||
| 363 | CINIT(POSTFIELDSIZE, CURLOPTTYPE_LONG, 60), | ||
| 364 | CINIT(HTTPPROXYTUNNEL, CURLOPTTYPE_LONG, 61), | ||
| 365 | CINIT(INTERFACE, CURLOPTTYPE_OBJECTPOINT, 62), | ||
| 366 | CINIT(KRBLEVEL, CURLOPTTYPE_OBJECTPOINT, 63), | ||
| 367 | CINIT(SSL_VERIFYPEER, CURLOPTTYPE_LONG, 64), | ||
| 368 | CINIT(CAINFO, CURLOPTTYPE_OBJECTPOINT, 65), | ||
| 369 | CINIT(MAXREDIRS, CURLOPTTYPE_LONG, 68), | ||
| 370 | CINIT(FILETIME, CURLOPTTYPE_LONG, 69), | ||
| 371 | CINIT(TELNETOPTIONS, CURLOPTTYPE_OBJECTPOINT, 70), | ||
| 372 | CINIT(MAXCONNECTS, CURLOPTTYPE_LONG, 71), | ||
| 373 | CINIT(CLOSEPOLICY, CURLOPTTYPE_LONG, 72), | ||
| 374 | CINIT(FRESH_CONNECT, CURLOPTTYPE_LONG, 74), | ||
| 375 | CINIT(FORBID_REUSE, CURLOPTTYPE_LONG, 75), | ||
| 376 | CINIT(RANDOM_FILE, CURLOPTTYPE_OBJECTPOINT, 76), | ||
| 377 | CINIT(EGDSOCKET, CURLOPTTYPE_OBJECTPOINT, 77), | ||
| 378 | CINIT(CONNECTTIMEOUT, CURLOPTTYPE_LONG, 78), | ||
| 379 | CINIT(HEADERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 79), | ||
| 380 | CINIT(HTTPGET, CURLOPTTYPE_LONG, 80), | ||
| 381 | CINIT(SSL_VERIFYHOST, CURLOPTTYPE_LONG, 81), | ||
| 382 | CINIT(COOKIEJAR, CURLOPTTYPE_OBJECTPOINT, 82), | ||
| 383 | CINIT(SSL_CIPHER_LIST, CURLOPTTYPE_OBJECTPOINT, 83), | ||
| 384 | CINIT(HTTP_VERSION, CURLOPTTYPE_LONG, 84), | ||
| 385 | CINIT(FTP_USE_EPSV, CURLOPTTYPE_LONG, 85), | ||
| 386 | CINIT(SSLCERTTYPE, CURLOPTTYPE_OBJECTPOINT, 86), | ||
| 387 | CINIT(SSLKEY, CURLOPTTYPE_OBJECTPOINT, 87), | ||
| 388 | CINIT(SSLKEYTYPE, CURLOPTTYPE_OBJECTPOINT, 88), | ||
| 389 | CINIT(SSLENGINE, CURLOPTTYPE_OBJECTPOINT, 89), | ||
| 390 | CINIT(SSLENGINE_DEFAULT, CURLOPTTYPE_LONG, 90), | ||
| 391 | CINIT(DNS_USE_GLOBAL_CACHE, CURLOPTTYPE_LONG, 91), | ||
| 392 | CINIT(DNS_CACHE_TIMEOUT, CURLOPTTYPE_LONG, 92), | ||
| 393 | CINIT(PREQUOTE, CURLOPTTYPE_OBJECTPOINT, 93), | ||
| 394 | CINIT(DEBUGFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 94), | ||
| 395 | CINIT(DEBUGDATA, CURLOPTTYPE_OBJECTPOINT, 95), | ||
| 396 | CINIT(COOKIESESSION, CURLOPTTYPE_LONG, 96), | ||
| 397 | CINIT(CAPATH, CURLOPTTYPE_OBJECTPOINT, 97), | ||
| 398 | CINIT(BUFFERSIZE, CURLOPTTYPE_LONG, 98), | ||
| 399 | CINIT(NOSIGNAL, CURLOPTTYPE_LONG, 99), | ||
| 400 | CINIT(SHARE, CURLOPTTYPE_OBJECTPOINT, 100), | ||
| 401 | CINIT(PROXYTYPE, CURLOPTTYPE_LONG, 101), | ||
| 402 | CINIT(ACCEPT_ENCODING, CURLOPTTYPE_OBJECTPOINT, 102), | ||
| 403 | CINIT(PRIVATE, CURLOPTTYPE_OBJECTPOINT, 103), | ||
| 404 | CINIT(HTTP200ALIASES, CURLOPTTYPE_OBJECTPOINT, 104), | ||
| 405 | CINIT(UNRESTRICTED_AUTH, CURLOPTTYPE_LONG, 105), | ||
| 406 | CINIT(FTP_USE_EPRT, CURLOPTTYPE_LONG, 106), | ||
| 407 | CINIT(HTTPAUTH, CURLOPTTYPE_LONG, 107), | ||
| 408 | CINIT(SSL_CTX_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 108), | ||
| 409 | CINIT(SSL_CTX_DATA, CURLOPTTYPE_OBJECTPOINT, 109), | ||
| 410 | CINIT(FTP_CREATE_MISSING_DIRS, CURLOPTTYPE_LONG, 110), | ||
| 411 | CINIT(PROXYAUTH, CURLOPTTYPE_LONG, 111), | ||
| 412 | CINIT(FTP_RESPONSE_TIMEOUT, CURLOPTTYPE_LONG, 112), | ||
| 413 | #define CURLOPT_SERVER_RESPONSE_TIMEOUT CURLOPT_FTP_RESPONSE_TIMEOUT | ||
| 414 | CINIT(IPRESOLVE, CURLOPTTYPE_LONG, 113), | ||
| 415 | CINIT(MAXFILESIZE, CURLOPTTYPE_LONG, 114), | ||
| 416 | CINIT(INFILESIZE_LARGE, CURLOPTTYPE_OFF_T, 115), | ||
| 417 | CINIT(RESUME_FROM_LARGE, CURLOPTTYPE_OFF_T, 116), | ||
| 418 | CINIT(MAXFILESIZE_LARGE, CURLOPTTYPE_OFF_T, 117), | ||
| 419 | CINIT(NETRC_FILE, CURLOPTTYPE_OBJECTPOINT, 118), | ||
| 420 | CINIT(USE_SSL, CURLOPTTYPE_LONG, 119), | ||
| 421 | CINIT(POSTFIELDSIZE_LARGE, CURLOPTTYPE_OFF_T, 120), | ||
| 422 | CINIT(TCP_NODELAY, CURLOPTTYPE_LONG, 121), | ||
| 423 | CINIT(FTPSSLAUTH, CURLOPTTYPE_LONG, 129), | ||
| 424 | CINIT(IOCTLFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 130), | ||
| 425 | CINIT(IOCTLDATA, CURLOPTTYPE_OBJECTPOINT, 131), | ||
| 426 | CINIT(FTP_ACCOUNT, CURLOPTTYPE_OBJECTPOINT, 134), | ||
| 427 | CINIT(COOKIELIST, CURLOPTTYPE_OBJECTPOINT, 135), | ||
| 428 | CINIT(IGNORE_CONTENT_LENGTH, CURLOPTTYPE_LONG, 136), | ||
| 429 | CINIT(FTP_SKIP_PASV_IP, CURLOPTTYPE_LONG, 137), | ||
| 430 | CINIT(FTP_FILEMETHOD, CURLOPTTYPE_LONG, 138), | ||
| 431 | CINIT(LOCALPORT, CURLOPTTYPE_LONG, 139), | ||
| 432 | CINIT(LOCALPORTRANGE, CURLOPTTYPE_LONG, 140), | ||
| 433 | CINIT(CONNECT_ONLY, CURLOPTTYPE_LONG, 141), | ||
| 434 | CINIT(CONV_FROM_NETWORK_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 142), | ||
| 435 | CINIT(CONV_TO_NETWORK_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 143), | ||
| 436 | CINIT(CONV_FROM_UTF8_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 144), | ||
| 437 | CINIT(MAX_SEND_SPEED_LARGE, CURLOPTTYPE_OFF_T, 145), | ||
| 438 | CINIT(MAX_RECV_SPEED_LARGE, CURLOPTTYPE_OFF_T, 146), | ||
| 439 | CINIT(FTP_ALTERNATIVE_TO_USER, CURLOPTTYPE_OBJECTPOINT, 147), | ||
| 440 | CINIT(SOCKOPTFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 148), | ||
| 441 | CINIT(SOCKOPTDATA, CURLOPTTYPE_OBJECTPOINT, 149), | ||
| 442 | CINIT(SSL_SESSIONID_CACHE, CURLOPTTYPE_LONG, 150), | ||
| 443 | CINIT(SSH_AUTH_TYPES, CURLOPTTYPE_LONG, 151), | ||
| 444 | CINIT(SSH_PUBLIC_KEYFILE, CURLOPTTYPE_OBJECTPOINT, 152), | ||
| 445 | CINIT(SSH_PRIVATE_KEYFILE, CURLOPTTYPE_OBJECTPOINT, 153), | ||
| 446 | CINIT(FTP_SSL_CCC, CURLOPTTYPE_LONG, 154), | ||
| 447 | CINIT(TIMEOUT_MS, CURLOPTTYPE_LONG, 155), | ||
| 448 | CINIT(CONNECTTIMEOUT_MS, CURLOPTTYPE_LONG, 156), | ||
| 449 | CINIT(HTTP_TRANSFER_DECODING, CURLOPTTYPE_LONG, 157), | ||
| 450 | CINIT(HTTP_CONTENT_DECODING, CURLOPTTYPE_LONG, 158), | ||
| 451 | CINIT(NEW_FILE_PERMS, CURLOPTTYPE_LONG, 159), | ||
| 452 | CINIT(NEW_DIRECTORY_PERMS, CURLOPTTYPE_LONG, 160), | ||
| 453 | CINIT(POSTREDIR, CURLOPTTYPE_LONG, 161), | ||
| 454 | CINIT(SSH_HOST_PUBLIC_KEY_MD5, CURLOPTTYPE_OBJECTPOINT, 162), | ||
| 455 | CINIT(OPENSOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 163), | ||
| 456 | CINIT(OPENSOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 164), | ||
| 457 | CINIT(COPYPOSTFIELDS, CURLOPTTYPE_OBJECTPOINT, 165), | ||
| 458 | CINIT(PROXY_TRANSFER_MODE, CURLOPTTYPE_LONG, 166), | ||
| 459 | CINIT(SEEKFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 167), | ||
| 460 | CINIT(SEEKDATA, CURLOPTTYPE_OBJECTPOINT, 168), | ||
| 461 | CINIT(CRLFILE, CURLOPTTYPE_OBJECTPOINT, 169), | ||
| 462 | CINIT(ISSUERCERT, CURLOPTTYPE_OBJECTPOINT, 170), | ||
| 463 | CINIT(ADDRESS_SCOPE, CURLOPTTYPE_LONG, 171), | ||
| 464 | CINIT(CERTINFO, CURLOPTTYPE_LONG, 172), | ||
| 465 | CINIT(USERNAME, CURLOPTTYPE_OBJECTPOINT, 173), | ||
| 466 | CINIT(PASSWORD, CURLOPTTYPE_OBJECTPOINT, 174), | ||
| 467 | CINIT(PROXYUSERNAME, CURLOPTTYPE_OBJECTPOINT, 175), | ||
| 468 | CINIT(PROXYPASSWORD, CURLOPTTYPE_OBJECTPOINT, 176), | ||
| 469 | CINIT(NOPROXY, CURLOPTTYPE_OBJECTPOINT, 177), | ||
| 470 | CINIT(TFTP_BLKSIZE, CURLOPTTYPE_LONG, 178), | ||
| 471 | CINIT(SOCKS5_GSSAPI_SERVICE, CURLOPTTYPE_OBJECTPOINT, 179), | ||
| 472 | CINIT(SOCKS5_GSSAPI_NEC, CURLOPTTYPE_LONG, 180), | ||
| 473 | CINIT(PROTOCOLS, CURLOPTTYPE_LONG, 181), | ||
| 474 | CINIT(REDIR_PROTOCOLS, CURLOPTTYPE_LONG, 182), | ||
| 475 | CINIT(SSH_KNOWNHOSTS, CURLOPTTYPE_OBJECTPOINT, 183), | ||
| 476 | CINIT(SSH_KEYFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 184), | ||
| 477 | CINIT(SSH_KEYDATA, CURLOPTTYPE_OBJECTPOINT, 185), | ||
| 478 | CINIT(MAIL_FROM, CURLOPTTYPE_OBJECTPOINT, 186), | ||
| 479 | CINIT(MAIL_RCPT, CURLOPTTYPE_OBJECTPOINT, 187), | ||
| 480 | CINIT(FTP_USE_PRET, CURLOPTTYPE_LONG, 188), | ||
| 481 | CINIT(RTSP_REQUEST, CURLOPTTYPE_LONG, 189), | ||
| 482 | CINIT(RTSP_SESSION_ID, CURLOPTTYPE_OBJECTPOINT, 190), | ||
| 483 | CINIT(RTSP_STREAM_URI, CURLOPTTYPE_OBJECTPOINT, 191), | ||
| 484 | CINIT(RTSP_TRANSPORT, CURLOPTTYPE_OBJECTPOINT, 192), | ||
| 485 | CINIT(RTSP_CLIENT_CSEQ, CURLOPTTYPE_LONG, 193), | ||
| 486 | CINIT(RTSP_SERVER_CSEQ, CURLOPTTYPE_LONG, 194), | ||
| 487 | CINIT(INTERLEAVEDATA, CURLOPTTYPE_OBJECTPOINT, 195), | ||
| 488 | CINIT(INTERLEAVEFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 196), | ||
| 489 | CINIT(WILDCARDMATCH, CURLOPTTYPE_LONG, 197), | ||
| 490 | CINIT(CHUNK_BGN_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 198), | ||
| 491 | CINIT(CHUNK_END_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 199), | ||
| 492 | CINIT(FNMATCH_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 200), | ||
| 493 | CINIT(CHUNK_DATA, CURLOPTTYPE_OBJECTPOINT, 201), | ||
| 494 | CINIT(FNMATCH_DATA, CURLOPTTYPE_OBJECTPOINT, 202), | ||
| 495 | CINIT(RESOLVE, CURLOPTTYPE_OBJECTPOINT, 203), | ||
| 496 | CINIT(TLSAUTH_USERNAME, CURLOPTTYPE_OBJECTPOINT, 204), | ||
| 497 | CINIT(TLSAUTH_PASSWORD, CURLOPTTYPE_OBJECTPOINT, 205), | ||
| 498 | CINIT(TLSAUTH_TYPE, CURLOPTTYPE_OBJECTPOINT, 206), | ||
| 499 | CINIT(TRANSFER_ENCODING, CURLOPTTYPE_LONG, 207), | ||
| 500 | CINIT(CLOSESOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 208), | ||
| 501 | CINIT(CLOSESOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 209), | ||
| 502 | CINIT(GSSAPI_DELEGATION, CURLOPTTYPE_LONG, 210), | ||
| 503 | CINIT(DNS_SERVERS, CURLOPTTYPE_OBJECTPOINT, 211), | ||
| 504 | CINIT(ACCEPTTIMEOUT_MS, CURLOPTTYPE_LONG, 212), | ||
| 505 | CINIT(TCP_KEEPALIVE, CURLOPTTYPE_LONG, 213), | ||
| 506 | CINIT(TCP_KEEPIDLE, CURLOPTTYPE_LONG, 214), | ||
| 507 | CINIT(TCP_KEEPINTVL, CURLOPTTYPE_LONG, 215), | ||
| 508 | CINIT(SSL_OPTIONS, CURLOPTTYPE_LONG, 216), | ||
| 509 | CINIT(MAIL_AUTH, CURLOPTTYPE_OBJECTPOINT, 217), | ||
| 510 | |||
| 511 | CURLOPT_LASTENTRY | ||
| 512 | } CURLoption; | ||
| 513 | |||
| 514 | #define CURLAUTH_BASIC (((unsigned long)1) << 0) | ||
| 515 | #define CURLAUTH_DIGEST (((unsigned long)1) << 1) | ||
| 516 | #define CURLAUTH_NEGOTIATE (((unsigned long)1) << 2) | ||
| 517 | #define CURLAUTH_NTLM (((unsigned long)1) << 3) | ||
| 518 | #define CURLAUTH_DIGEST_IE (((unsigned long)1) << 4) | ||
| 519 | #define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE) | ||
| 520 | |||
| 521 | #define CURLOPT_WRITEDATA CURLOPT_FILE | ||
| 522 | #define CURLOPT_READDATA CURLOPT_INFILE | ||
| 523 | |||
| 524 | #define CURLINFO_STRING 0x100000 | ||
| 525 | #define CURLINFO_LONG 0x200000 | ||
| 526 | #define CURLINFO_DOUBLE 0x300000 | ||
| 527 | #define CURLINFO_SLIST 0x400000 | ||
| 528 | #define CURLINFO_MASK 0x0fffff | ||
| 529 | #define CURLINFO_TYPEMASK 0xf00000 | ||
| 530 | |||
| 531 | #define CURL_HTTP_VERSION_NONE 0 | ||
| 532 | #define CURL_HTTP_VERSION_1_0 1 | ||
| 533 | #define CURL_HTTP_VERSION_1_1 2 | ||
| 534 | #define CURL_HTTP_VERSION_2_0 3 | ||
| 535 | #define CURL_HTTP_VERSION_2TLS 4 | ||
| 536 | #define CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE 5 | ||
| 537 | #define CURL_HTTP_VERSION_3 30 | ||
| 538 | #define CURL_HTTP_VERSION_3ONLY 31 | ||
| 539 | |||
| 540 | typedef enum | ||
| 541 | { | ||
| 542 | CURLINFO_NONE, | ||
| 543 | CURLINFO_EFFECTIVE_URL = CURLINFO_STRING + 1, | ||
| 544 | CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2, | ||
| 545 | CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE + 3, | ||
| 546 | CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE + 4, | ||
| 547 | CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5, | ||
| 548 | CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6, | ||
| 549 | CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE + 7, | ||
| 550 | CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE + 8, | ||
| 551 | CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE + 9, | ||
| 552 | CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE + 10, | ||
| 553 | CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11, | ||
| 554 | CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12, | ||
| 555 | CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13, | ||
| 556 | CURLINFO_FILETIME = CURLINFO_LONG + 14, | ||
| 557 | CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE + 15, | ||
| 558 | CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE + 16, | ||
| 559 | CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17, | ||
| 560 | CURLINFO_CONTENT_TYPE = CURLINFO_STRING + 18, | ||
| 561 | CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19, | ||
| 562 | CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20, | ||
| 563 | CURLINFO_PRIVATE = CURLINFO_STRING + 21, | ||
| 564 | CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG + 22, | ||
| 565 | CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23, | ||
| 566 | CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24, | ||
| 567 | CURLINFO_OS_ERRNO = CURLINFO_LONG + 25, | ||
| 568 | CURLINFO_NUM_CONNECTS = CURLINFO_LONG + 26, | ||
| 569 | CURLINFO_SSL_ENGINES = CURLINFO_SLIST + 27, | ||
| 570 | CURLINFO_COOKIELIST = CURLINFO_SLIST + 28, | ||
| 571 | CURLINFO_LASTSOCKET = CURLINFO_LONG + 29, | ||
| 572 | CURLINFO_FTP_ENTRY_PATH = CURLINFO_STRING + 30, | ||
| 573 | CURLINFO_REDIRECT_URL = CURLINFO_STRING + 31, | ||
| 574 | CURLINFO_PRIMARY_IP = CURLINFO_STRING + 32, | ||
| 575 | CURLINFO_APPCONNECT_TIME = CURLINFO_DOUBLE + 33, | ||
| 576 | CURLINFO_CERTINFO = CURLINFO_SLIST + 34, | ||
| 577 | CURLINFO_CONDITION_UNMET = CURLINFO_LONG + 35, | ||
| 578 | CURLINFO_RTSP_SESSION_ID = CURLINFO_STRING + 36, | ||
| 579 | CURLINFO_RTSP_CLIENT_CSEQ = CURLINFO_LONG + 37, | ||
| 580 | CURLINFO_RTSP_SERVER_CSEQ = CURLINFO_LONG + 38, | ||
| 581 | CURLINFO_RTSP_CSEQ_RECV = CURLINFO_LONG + 39, | ||
| 582 | CURLINFO_PRIMARY_PORT = CURLINFO_LONG + 40, | ||
| 583 | CURLINFO_LOCAL_IP = CURLINFO_STRING + 41, | ||
| 584 | CURLINFO_LOCAL_PORT = CURLINFO_LONG + 42, | ||
| 585 | |||
| 586 | CURLINFO_LASTONE = 42 | ||
| 587 | } CURLINFO; | ||
| 588 | |||
| 589 | typedef void CURL; | ||
| 590 | |||
| 591 | struct curl_slist | ||
| 592 | { | ||
| 593 | char* data; | ||
| 594 | struct curl_slist* next; | ||
| 595 | }; | ||
| 596 | |||
| 597 | struct curl_httppost { | ||
| 598 | struct curl_httppost* next; | ||
| 599 | char* name; | ||
| 600 | long namelength; | ||
| 601 | char* contents; | ||
| 602 | long contentslength; | ||
| 603 | char* buffer; | ||
| 604 | long bufferlength; | ||
| 605 | char* contenttype; | ||
| 606 | struct curl_slist* contentheader; | ||
| 607 | struct curl_httppost* more; | ||
| 608 | long flags; | ||
| 609 | #define HTTPPOST_FILENAME (1<<0) | ||
| 610 | #define HTTPPOST_READFILE (1<<1) | ||
| 611 | #define HTTPPOST_PTRNAME (1<<2) | ||
| 612 | #define HTTPPOST_PTRCONTENTS (1<<3) | ||
| 613 | #define HTTPPOST_BUFFER (1<<4) | ||
| 614 | #define HTTPPOST_PTRBUFFER (1<<5) | ||
| 615 | #define HTTPPOST_CALLBACK (1<<6) | ||
| 616 | |||
| 617 | char* showfilename; | ||
| 618 | void* userp; | ||
| 619 | }; | ||
| 620 | |||
| 621 | |||
| 622 | typedef enum { | ||
| 623 | CURL_FORMADD_OK, | ||
| 624 | |||
| 625 | CURL_FORMADD_MEMORY, | ||
| 626 | CURL_FORMADD_OPTION_TWICE, | ||
| 627 | CURL_FORMADD_NULL, | ||
| 628 | CURL_FORMADD_UNKNOWN_OPTION, | ||
| 629 | CURL_FORMADD_INCOMPLETE, | ||
| 630 | CURL_FORMADD_ILLEGAL_ARRAY, | ||
| 631 | CURL_FORMADD_DISABLED, | ||
| 632 | |||
| 633 | CURL_FORMADD_LAST | ||
| 634 | } CURLFORMcode; | ||
| 635 | |||
| 636 | |||
| 637 | #include "gate/gatetypes.h" | ||
| 638 | #include "gate/libraries.h" | ||
| 639 | #include "gate/results.h" | ||
| 640 | #include "gate/debugging.h" | ||
| 641 | #include "gate/streams.h" | ||
| 642 | #include "gate/platforms.h" | ||
| 643 | |||
| 644 | |||
| 645 | typedef struct gate_curl_functions_class | ||
| 646 | { | ||
| 647 | struct curl_version_info_data* (*version_info) (CURLversion age); | ||
| 648 | CURLcode (*easy_setopt) (CURL* handle, CURLoption option, ...); | ||
| 649 | void (*easy_cleanup) (CURL* handle); | ||
| 650 | CURLcode (*global_init) (long flags); | ||
| 651 | void (*global_cleanup) (void); | ||
| 652 | CURL* (*easy_init) (void); | ||
| 653 | CURLcode (*easy_perform) (CURL* handle); | ||
| 654 | CURLcode (*easy_getinfo) (CURL* handle, CURLINFO info, ...); | ||
| 655 | struct curl_slist* (*slist_append) (struct curl_slist* list, const char* str); | ||
| 656 | void (*slist_free_all) (struct curl_slist* list); | ||
| 657 | CURLFORMcode (*formadd) (struct curl_httppost** firstitem, struct curl_httppost** lastitem, ...); | ||
| 658 | void (*formfree) (struct curl_httppost* form); | ||
| 659 | } gate_curl_functions_t; | ||
| 660 | |||
| 661 | static gate_curl_functions_t curl; | ||
| 662 | |||
| 663 | |||
| 664 | static gate_library_t libcurl_library = NULL; | ||
| 665 | static gate_bool_t volatile libcurl_library_loaded = false; | ||
| 666 | |||
| 667 | |||
| 668 | 2 | static void libcurl_atexit_cleanup(void) | |
| 669 | { | ||
| 670 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (libcurl_library != NULL) |
| 671 | { | ||
| 672 | 2 | gate_library_close(libcurl_library); | |
| 673 | 2 | libcurl_library = NULL; | |
| 674 | } | ||
| 675 | 2 | } | |
| 676 | |||
| 677 | 9 | static gate_result_t load_libcurl_functions(void) | |
| 678 | { | ||
| 679 | #if defined(GATE_SYS_WIN) | ||
| 680 | static gate_string_t const lib_curl_file = GATE_STRING_INIT_STATIC("libcurl.dll"); | ||
| 681 | static gate_string_t const lib_curl_file2 = GATE_STRING_INIT_STATIC("libcurl-4.dll"); | ||
| 682 | #elif defined(GATE_SYS_DARWIN) | ||
| 683 | static gate_string_t const lib_curl_file = GATE_STRING_INIT_STATIC("libcurl.dylib"); | ||
| 684 | static gate_string_t const lib_curl_file2 = GATE_STRING_INIT_STATIC("libcurl.dylib"); | ||
| 685 | #else | ||
| 686 | static gate_string_t const lib_curl_file = GATE_STRING_INIT_STATIC("libcurl.so"); | ||
| 687 | static gate_string_t const lib_curl_file2 = GATE_STRING_INIT_STATIC("libcurl.so.4"); | ||
| 688 | #endif | ||
| 689 | |||
| 690 | 9 | gate_result_t ret = GATE_RESULT_NOTSUPPORTED; | |
| 691 | |||
| 692 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
|
9 | if (!libcurl_library_loaded) |
| 693 | { | ||
| 694 | do | ||
| 695 | { | ||
| 696 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (libcurl_library == NULL) |
| 697 | { | ||
| 698 | 2 | ret = gate_library_open(&lib_curl_file, &libcurl_library, GATE_LIBRARY_FLAG_DEFAULT); | |
| 699 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (GATE_FAILED(ret)) |
| 700 | { | ||
| 701 | 2 | ret = gate_library_open(&lib_curl_file2, &libcurl_library, GATE_LIBRARY_FLAG_DEFAULT); | |
| 702 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (GATE_FAILED(ret)) |
| 703 | { | ||
| 704 | ✗ | libcurl_library = NULL; | |
| 705 | ✗ | break; | |
| 706 | } | ||
| 707 | } | ||
| 708 | 2 | gate_platform_atexit(&libcurl_atexit_cleanup); | |
| 709 | } | ||
| 710 | |||
| 711 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_version_info", &curl.version_info)); |
| 712 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_easy_setopt", &curl.easy_setopt)); |
| 713 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_easy_cleanup", &curl.easy_cleanup)); |
| 714 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_global_init", &curl.global_init)); |
| 715 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_global_cleanup", &curl.global_cleanup)); |
| 716 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_easy_init", &curl.easy_init)); |
| 717 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_easy_perform", &curl.easy_perform)); |
| 718 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_easy_getinfo", &curl.easy_getinfo)); |
| 719 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_slist_append", &curl.slist_append)); |
| 720 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_slist_free_all", &curl.slist_free_all)); |
| 721 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_formadd", &curl.formadd)); |
| 722 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_formfree", &curl.formfree)); |
| 723 | |||
| 724 | 2 | libcurl_library_loaded = true; | |
| 725 | } while (0); | ||
| 726 | } | ||
| 727 | |||
| 728 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if (libcurl_library_loaded) |
| 729 | { | ||
| 730 | 9 | ret = GATE_RESULT_OK; | |
| 731 | } | ||
| 732 | 9 | return ret; | |
| 733 | } | ||
| 734 | |||
| 735 | 43 | static gate_result_t gate_curl_map_result(CURLcode code, char const** ptr_msg) | |
| 736 | { | ||
| 737 | 43 | gate_result_t ret = GATE_RESULT_FAILED; | |
| 738 | 43 | char const* msg = NULL; | |
| 739 | |||
| 740 |
1/80✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
|
43 | switch (code) |
| 741 | { | ||
| 742 | 43 | case CURLE_OK: ret = GATE_RESULT_OK; break; | |
| 743 | ✗ | case CURLE_UNSUPPORTED_PROTOCOL: ret = GATE_RESULT_NOTSUPPORTED; msg = "Unsupported Protocol"; break; | |
| 744 | ✗ | case CURLE_FAILED_INIT: ret = GATE_RESULT_FAILED; msg = "Initialization failed"; break; | |
| 745 | ✗ | case CURLE_URL_MALFORMAT: ret = GATE_RESULT_FAILED; msg = "Invalid URL"; break; | |
| 746 | ✗ | case CURLE_NOT_BUILT_IN: ret = GATE_RESULT_NOTSUPPORTED; msg = "Feature not built in"; break; | |
| 747 | ✗ | case CURLE_COULDNT_RESOLVE_PROXY: ret = GATE_RESULT_NOTAVAILABLE; msg = "Failed to resolve proxy"; break; | |
| 748 | ✗ | case CURLE_COULDNT_RESOLVE_HOST: ret = GATE_RESULT_NOTAVAILABLE; msg = "Failed to resolve host"; break; | |
| 749 | ✗ | case CURLE_COULDNT_CONNECT: ret = GATE_RESULT_NOTAVAILABLE; msg = "Connect failed"; break; | |
| 750 | ✗ | case CURLE_FTP_WEIRD_SERVER_REPLY: ret = GATE_RESULT_FAILED; msg = "Invalid FTP server reply"; break; | |
| 751 | ✗ | case CURLE_REMOTE_ACCESS_DENIED: ret = GATE_RESULT_ACCESSDENIED; msg = "Remote access denied"; break; | |
| 752 | ✗ | case CURLE_FTP_ACCEPT_FAILED: ret = GATE_RESULT_FAILED; msg = "FTP accept failed"; break; | |
| 753 | ✗ | case CURLE_FTP_WEIRD_PASS_REPLY: ret = GATE_RESULT_FAILED; msg = "Invalid FTP PASS reply"; break; | |
| 754 | ✗ | case CURLE_FTP_ACCEPT_TIMEOUT: ret = GATE_RESULT_TIMEOUT; msg = "FTP accept timeout"; break; | |
| 755 | ✗ | case CURLE_FTP_WEIRD_PASV_REPLY: ret = GATE_RESULT_FAILED; msg = "Invalid FTP PASV reply"; break; | |
| 756 | ✗ | case CURLE_FTP_WEIRD_227_FORMAT: ret = GATE_RESULT_FAILED; msg = "Invalid FTP 227 format"; break; | |
| 757 | ✗ | case CURLE_FTP_CANT_GET_HOST: ret = GATE_RESULT_FAILED; msg = "Cant get FTP host"; break; | |
| 758 | #ifdef CURLE_HTTP2 | ||
| 759 | case CURLE_HTTP2: ret = GATE_RESULT_FAILED; msg = "HTTP2"; break; | ||
| 760 | #endif | ||
| 761 | ✗ | case CURLE_FTP_COULDNT_SET_TYPE: ret = GATE_RESULT_FAILED; msg = "Failed to set FTP type"; break; | |
| 762 | ✗ | case CURLE_PARTIAL_FILE: ret = GATE_RESULT_FAILED; msg = "Partial file"; break; | |
| 763 | ✗ | case CURLE_FTP_COULDNT_RETR_FILE: ret = GATE_RESULT_FAILED; msg = "Failed to retrieve FTP file"; break; | |
| 764 | ✗ | case CURLE_QUOTE_ERROR: ret = GATE_RESULT_FAILED; msg = "QUOTE error"; break; | |
| 765 | ✗ | case CURLE_HTTP_RETURNED_ERROR: ret = GATE_RESULT_FAILED; msg = "HTTP error"; break; | |
| 766 | ✗ | case CURLE_WRITE_ERROR: ret = GATE_RESULT_FAILED; msg = "Write failed"; break; | |
| 767 | ✗ | case CURLE_UPLOAD_FAILED: ret = GATE_RESULT_FAILED; msg = "Upload failed"; break; | |
| 768 | ✗ | case CURLE_READ_ERROR: ret = GATE_RESULT_FAILED; msg = "Read failed"; break; | |
| 769 | ✗ | case CURLE_OUT_OF_MEMORY: ret = GATE_RESULT_OUTOFMEMORY; msg = "Out of memory"; break; | |
| 770 | ✗ | case CURLE_OPERATION_TIMEDOUT: ret = GATE_RESULT_TIMEOUT; msg = "Operation timeout"; break; | |
| 771 | ✗ | case CURLE_FTP_PORT_FAILED: ret = GATE_RESULT_FAILED; msg = "FTP PORT command failed"; break; | |
| 772 | ✗ | case CURLE_FTP_COULDNT_USE_REST: ret = GATE_RESULT_FAILED; msg = "FTP REST command failed"; break; | |
| 773 | ✗ | case CURLE_RANGE_ERROR: ret = GATE_RESULT_FAILED; msg = "Range request failed"; break; | |
| 774 | ✗ | case CURLE_HTTP_POST_ERROR: ret = GATE_RESULT_FAILED; msg = "HTTP POST failed"; break; | |
| 775 | ✗ | case CURLE_SSL_CONNECT_ERROR: ret = GATE_RESULT_FAILED; msg = "SSL connect error"; break; | |
| 776 | ✗ | case CURLE_BAD_DOWNLOAD_RESUME: ret = GATE_RESULT_FAILED; msg = "Failed to resume download"; break; | |
| 777 | ✗ | case CURLE_FILE_COULDNT_READ_FILE: ret = GATE_RESULT_FAILED; msg = "Failed to read file"; break; | |
| 778 | ✗ | case CURLE_LDAP_CANNOT_BIND: ret = GATE_RESULT_FAILED; msg = "Cannot bind LDAP"; break; | |
| 779 | ✗ | case CURLE_LDAP_SEARCH_FAILED: ret = GATE_RESULT_FAILED; msg = "LDAP search failed"; break; | |
| 780 | ✗ | case CURLE_FUNCTION_NOT_FOUND: ret = GATE_RESULT_NOTAVAILABLE; msg = "Function not found"; break; | |
| 781 | ✗ | case CURLE_ABORTED_BY_CALLBACK: ret = GATE_RESULT_CANCELED; msg = "Canceled by callback"; break; | |
| 782 | ✗ | case CURLE_BAD_FUNCTION_ARGUMENT: ret = GATE_RESULT_INVALIDARG; msg = "Bad function argument"; break; | |
| 783 | ✗ | case CURLE_INTERFACE_FAILED: ret = GATE_RESULT_FAILED; msg = "Interface failed"; break; | |
| 784 | ✗ | case CURLE_TOO_MANY_REDIRECTS: ret = GATE_RESULT_FAILED; msg = "Too many redirects"; break; | |
| 785 | ✗ | case CURLE_UNKNOWN_OPTION: ret = GATE_RESULT_FAILED; msg = "Unknown option"; break; | |
| 786 | ✗ | case CURLE_TELNET_OPTION_SYNTAX: ret = GATE_RESULT_FAILED; msg = "Telnet option illegally formated"; break; | |
| 787 | ✗ | case CURLE_PEER_FAILED_VERIFICATION: ret = GATE_RESULT_FAILED; msg = "Peer verification failed"; break; | |
| 788 | ✗ | case CURLE_GOT_NOTHING: ret = GATE_RESULT_INVALIDDATA; msg = "No data returned"; break; | |
| 789 | ✗ | case CURLE_SSL_ENGINE_NOTFOUND: ret = GATE_RESULT_NOTAVAILABLE; msg = "SSL engine not found"; break; | |
| 790 | ✗ | case CURLE_SSL_ENGINE_SETFAILED: ret = GATE_RESULT_NOTAVAILABLE; msg = "SSL engine error"; break; | |
| 791 | ✗ | case CURLE_SEND_ERROR: ret = GATE_RESULT_FAILED; msg = "Send error"; break; | |
| 792 | ✗ | case CURLE_RECV_ERROR: ret = GATE_RESULT_FAILED; msg = "Receive error"; break; | |
| 793 | ✗ | case CURLE_SSL_CERTPROBLEM: ret = GATE_RESULT_FAILED; msg = "SSL Certificate problem"; break; | |
| 794 | ✗ | case CURLE_SSL_CIPHER: ret = GATE_RESULT_FAILED; msg = "SSL cipher error"; break; | |
| 795 | ✗ | case CURLE_SSL_CACERT: ret = GATE_RESULT_FAILED; msg = "SSL certificate authentication failed"; break; | |
| 796 | ✗ | case CURLE_BAD_CONTENT_ENCODING: ret = GATE_RESULT_INVALIDDATA; msg = "Bad content encoding"; break; | |
| 797 | ✗ | case CURLE_LDAP_INVALID_URL: ret = GATE_RESULT_FAILED; msg = "LDAP invalid URL"; break; | |
| 798 | ✗ | case CURLE_FILESIZE_EXCEEDED: ret = GATE_RESULT_INCORRECTSIZE;msg = "Filesize exceeded"; break; | |
| 799 | ✗ | case CURLE_USE_SSL_FAILED: ret = GATE_RESULT_FAILED; msg = "Requested SSL level failed"; break; | |
| 800 | ✗ | case CURLE_SEND_FAIL_REWIND: ret = GATE_RESULT_FAILED; msg = "Send-Rewind failed"; break; | |
| 801 | ✗ | case CURLE_SSL_ENGINE_INITFAILED: ret = GATE_RESULT_FAILED; msg = "SSL initialization failed"; break; | |
| 802 | ✗ | case CURLE_LOGIN_DENIED: ret = GATE_RESULT_ACCESSDENIED; msg = "Login denied"; break; | |
| 803 | ✗ | case CURLE_TFTP_NOTFOUND: ret = GATE_RESULT_NOTAVAILABLE; msg = "TFTP not found"; break; | |
| 804 | ✗ | case CURLE_TFTP_PERM: ret = GATE_RESULT_ACCESSDENIED; msg = "TFTP permission failed"; break; | |
| 805 | ✗ | case CURLE_REMOTE_DISK_FULL: ret = GATE_RESULT_FAILED; msg = "Remote disk full"; break; | |
| 806 | ✗ | case CURLE_TFTP_ILLEGAL: ret = GATE_RESULT_FAILED; msg = "Illegal TFTP operation"; break; | |
| 807 | ✗ | case CURLE_TFTP_UNKNOWNID: ret = GATE_RESULT_FAILED; msg = "Unknown TFTP transfer ID"; break; | |
| 808 | ✗ | case CURLE_REMOTE_FILE_EXISTS: ret = GATE_RESULT_ALREADYEXISTS;msg = "Remote file exists"; break; | |
| 809 | ✗ | case CURLE_TFTP_NOSUCHUSER: ret = GATE_RESULT_FAILED; msg = "TFTP: No such user"; break; | |
| 810 | ✗ | case CURLE_CONV_FAILED: ret = GATE_RESULT_INVALIDDATA; msg = "Character conversion failed"; break; | |
| 811 | ✗ | case CURLE_CONV_REQD: ret = GATE_RESULT_FAILED; msg = "Conversion callback missing"; break; | |
| 812 | ✗ | case CURLE_SSL_CACERT_BADFILE: ret = GATE_RESULT_FAILED; msg = "SSL CA cert file problem"; break; | |
| 813 | ✗ | case CURLE_REMOTE_FILE_NOT_FOUND: ret = GATE_RESULT_FAILED; msg = "Remote file not found"; break; | |
| 814 | ✗ | case CURLE_SSH: ret = GATE_RESULT_FAILED; msg = "SSH error"; break; | |
| 815 | ✗ | case CURLE_SSL_SHUTDOWN_FAILED: ret = GATE_RESULT_FAILED; msg = "SSL shutdown failed"; break; | |
| 816 | ✗ | case CURLE_AGAIN: ret = GATE_RESULT_NOTREADY; msg = "Socket not ready for send/recv"; break; | |
| 817 | ✗ | case CURLE_SSL_CRL_BADFILE: ret = GATE_RESULT_FAILED; msg = "Failed to load SSL CRL file"; break; | |
| 818 | ✗ | case CURLE_SSL_ISSUER_ERROR: ret = GATE_RESULT_FAILED; msg = "SSL issuer check failed"; break; | |
| 819 | ✗ | case CURLE_FTP_PRET_FAILED: ret = GATE_RESULT_FAILED; msg = "FTP PRET command failed"; break; | |
| 820 | ✗ | case CURLE_RTSP_CSEQ_ERROR: ret = GATE_RESULT_FAILED; msg = "Mismatch of RTSP CSeq numbers"; break; | |
| 821 | ✗ | case CURLE_RTSP_SESSION_ERROR: ret = GATE_RESULT_FAILED; msg = "Mismatch of RTSP session identifiers"; break; | |
| 822 | ✗ | case CURLE_FTP_BAD_FILE_LIST: ret = GATE_RESULT_FAILED; msg = "Unable to parse FTP file list"; break; | |
| 823 | ✗ | case CURLE_CHUNK_FAILED: ret = GATE_RESULT_FAILED; msg = "Chunk callback error"; break; | |
| 824 | #ifdef CURLE_NO_CONNECTION_AVAILABLE | ||
| 825 | case CURLE_NO_CONNECTION_AVAILABLE: ret = GATE_RESULT_FAILED; msg = "No connection available"; break; | ||
| 826 | #endif | ||
| 827 | #ifdef CURLE_SSL_PINNEDPUBKEYNOTMATCH | ||
| 828 | case CURLE_SSL_PINNEDPUBKEYNOTMATCH: ret = GATE_RESULT_FAILED; msg = "Failed to match pinned key"; break; | ||
| 829 | #endif | ||
| 830 | #ifdef CURLE_SSL_INVALIDCERTSTATUS | ||
| 831 | case CURLE_SSL_INVALIDCERTSTATUS: ret = GATE_RESULT_FAILED; msg = "Invalid SSL cert status"; break; | ||
| 832 | #endif | ||
| 833 | #ifdef CURLE_HTTP2_STREAM | ||
| 834 | case CURLE_HTTP2_STREAM: ret = GATE_RESULT_FAILED; msg = "HTTP2 stream error"; break; | ||
| 835 | #endif | ||
| 836 | ✗ | default: ret = GATE_RESULT_UNKNOWNERROR; msg = "Unknown error"; break; | |
| 837 | } | ||
| 838 | |||
| 839 |
1/2✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
|
43 | if (ptr_msg) |
| 840 | { | ||
| 841 | 43 | *ptr_msg = msg; | |
| 842 | } | ||
| 843 | 43 | return ret; | |
| 844 | } | ||
| 845 | |||
| 846 | |||
| 847 | ✗ | static size_t gate_curl_read_stream_cb(void* ptr, size_t size, size_t nmemb, void* data) | |
| 848 | { | ||
| 849 | ✗ | gate_stream_t* stream = (gate_stream_t*)data; | |
| 850 | ✗ | size_t len = size * nmemb; | |
| 851 | ✗ | gate_size_t lenread = 0; | |
| 852 | gate_result_t result; | ||
| 853 | |||
| 854 | ✗ | if (!stream || (len == 0)) | |
| 855 | { | ||
| 856 | ✗ | return 0; | |
| 857 | } | ||
| 858 | |||
| 859 | ✗ | result = gate_stream_read_block(stream, (char*)ptr, len, &lenread); | |
| 860 | ✗ | if (GATE_SUCCEEDED(result)) | |
| 861 | { | ||
| 862 | /* success case */ | ||
| 863 | ✗ | GATE_DEBUG_ASSERT((lenread % size) == 0); | |
| 864 | ✗ | return lenread / size; | |
| 865 | } | ||
| 866 | else | ||
| 867 | { | ||
| 868 | /* error case */ | ||
| 869 | ✗ | return 0; | |
| 870 | } | ||
| 871 | } | ||
| 872 | |||
| 873 | ✗ | static size_t gate_curl_noread_cb(void* ptr, size_t size, size_t nmemb, void* data) | |
| 874 | { | ||
| 875 | GATE_UNUSED_ARG(ptr); | ||
| 876 | GATE_UNUSED_ARG(size); | ||
| 877 | GATE_UNUSED_ARG(nmemb); | ||
| 878 | GATE_UNUSED_ARG(data); | ||
| 879 | ✗ | return 0; | |
| 880 | } | ||
| 881 | |||
| 882 | |||
| 883 | 86 | static size_t gate_curl_write_stream_cb(void* ptr, size_t size, size_t nmemb, void* data) | |
| 884 | { | ||
| 885 | 86 | gate_stream_t* const stream = (gate_stream_t*)data; | |
| 886 | 86 | size_t const len = size * nmemb; | |
| 887 | 86 | char* const str = (char*)ptr; | |
| 888 | 86 | gate_size_t written = 0; | |
| 889 | gate_result_t result; | ||
| 890 | |||
| 891 |
3/6✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 86 times.
|
86 | if (len == 0 || !stream || !ptr) |
| 892 | { | ||
| 893 | /* invalid arg error */ | ||
| 894 | ✗ | return 0; | |
| 895 | } | ||
| 896 | |||
| 897 | 86 | result = gate_stream_write_block(stream, str, len, &written); | |
| 898 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
|
86 | if (GATE_FAILED(result)) |
| 899 | { | ||
| 900 | /* write failed */ | ||
| 901 | ✗ | return 0; | |
| 902 | } | ||
| 903 | else | ||
| 904 | { | ||
| 905 | /* write succeeded */ | ||
| 906 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
|
86 | GATE_DEBUG_ASSERT(written == len); |
| 907 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
|
86 | GATE_DEBUG_ASSERT((written % size) == 0); |
| 908 | 86 | return written / size; | |
| 909 | } | ||
| 910 | |||
| 911 | } | ||
| 912 | |||
| 913 | 1 | static size_t gate_curl_nowrite_cb(void* ptr, size_t size, size_t nmemb, void* data) | |
| 914 | { | ||
| 915 | GATE_UNUSED_ARG(ptr); | ||
| 916 | GATE_UNUSED_ARG(size); | ||
| 917 | GATE_UNUSED_ARG(nmemb); | ||
| 918 | GATE_UNUSED_ARG(data); | ||
| 919 | 1 | return nmemb; | |
| 920 | } | ||
| 921 | |||
| 922 | |||
| 923 | #ifndef CURL_BREAK_IF_FAILED | ||
| 924 | #define CURL_BREAK_IF_FAILED(curl_result) if(CURLE_OK != (curl_result)) { break; } | ||
| 925 | #endif | ||
| 926 | |||
| 927 | 3 | static gate_result_t gate_curl_setup(CURL* ptr_curl, gate_string_t const* url, gate_stream_t* input_stream, gate_stream_t* output_stream) | |
| 928 | { | ||
| 929 | 3 | gate_result_t ret = GATE_RESULT_FAILED; | |
| 930 | do | ||
| 931 | { | ||
| 932 | 3 | curl.easy_setopt(ptr_curl, CURLOPT_NOSIGNAL, 1L); | |
| 933 | |||
| 934 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | if (!gate_string_is_empty(url)) |
| 935 | { | ||
| 936 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
3 | CURL_BREAK_IF_FAILED(curl.easy_setopt(ptr_curl, CURLOPT_URL, gate_string_ptr(url, 0))); |
| 937 | } | ||
| 938 | |||
| 939 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | CURL_BREAK_IF_FAILED(curl.easy_setopt(ptr_curl, CURLOPT_READDATA, (void*)input_stream)); |
| 940 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
|
3 | CURL_BREAK_IF_FAILED(curl.easy_setopt(ptr_curl, CURLOPT_READFUNCTION, |
| 941 | (input_stream != NULL) ? &gate_curl_read_stream_cb : &gate_curl_noread_cb)); | ||
| 942 | |||
| 943 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | CURL_BREAK_IF_FAILED(curl.easy_setopt(ptr_curl, CURLOPT_WRITEDATA, (void*)output_stream)); |
| 944 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
|
3 | CURL_BREAK_IF_FAILED(curl.easy_setopt(ptr_curl, CURLOPT_WRITEFUNCTION, |
| 945 | (output_stream != NULL) ? &gate_curl_write_stream_cb : &gate_curl_nowrite_cb)); | ||
| 946 | |||
| 947 | 3 | ret = GATE_RESULT_OK; | |
| 948 | } while (0); | ||
| 949 | |||
| 950 | 3 | return ret; | |
| 951 | } | ||
| 952 | |||
| 953 | 3 | static gate_result_t gate_curl_reset(CURL* ptr_curl) | |
| 954 | { | ||
| 955 | 3 | gate_result_t ret = GATE_RESULT_FAILED; | |
| 956 | |||
| 957 | do | ||
| 958 | { | ||
| 959 | /* ensure we don't have pointers and functions that are not valid anymore */ | ||
| 960 | 3 | curl.easy_setopt(ptr_curl, CURLOPT_READDATA, NULL); | |
| 961 | 3 | curl.easy_setopt(ptr_curl, CURLOPT_READFUNCTION, &gate_curl_noread_cb); | |
| 962 | |||
| 963 | 3 | curl.easy_setopt(ptr_curl, CURLOPT_WRITEDATA, NULL); | |
| 964 | 3 | curl.easy_setopt(ptr_curl, CURLOPT_WRITEFUNCTION, &gate_curl_nowrite_cb); | |
| 965 | |||
| 966 | 3 | ret = GATE_RESULT_OK; | |
| 967 | } while (0); | ||
| 968 | |||
| 969 | 3 | return ret; | |
| 970 | } | ||
| 971 | |||
| 972 | #endif | ||
| 973 |