GCC Code Coverage Report


Directory: src/gate/
File: src/gate/net/platform/libcurl_api.h
Date: 2026-10-19 17:06:30
Exec Total Coverage
Lines: 80 103 77.7%
Functions: 7 9 77.8%
Branches: 48 108 44.4%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright (c) 2018-2026, 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 CURLOPTTYPE_OBJECTPOINT 10000
515 #define CURLOPT_MIMEPOST (CURLOPTTYPE_OBJECTPOINT + 269)
516
517 #define CURLAUTH_BASIC (((unsigned long)1) << 0)
518 #define CURLAUTH_DIGEST (((unsigned long)1) << 1)
519 #define CURLAUTH_NEGOTIATE (((unsigned long)1) << 2)
520 #define CURLAUTH_NTLM (((unsigned long)1) << 3)
521 #define CURLAUTH_DIGEST_IE (((unsigned long)1) << 4)
522 #define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE)
523
524 #define CURLOPT_WRITEDATA CURLOPT_FILE
525 #define CURLOPT_READDATA CURLOPT_INFILE
526
527 #define CURLINFO_STRING 0x100000
528 #define CURLINFO_LONG 0x200000
529 #define CURLINFO_DOUBLE 0x300000
530 #define CURLINFO_SLIST 0x400000
531 #define CURLINFO_MASK 0x0fffff
532 #define CURLINFO_TYPEMASK 0xf00000
533
534 #define CURL_HTTP_VERSION_NONE 0
535 #define CURL_HTTP_VERSION_1_0 1
536 #define CURL_HTTP_VERSION_1_1 2
537 #define CURL_HTTP_VERSION_2_0 3
538 #define CURL_HTTP_VERSION_2TLS 4
539 #define CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE 5
540 #define CURL_HTTP_VERSION_3 30
541 #define CURL_HTTP_VERSION_3ONLY 31
542
543 typedef enum
544 {
545 CURLINFO_NONE,
546 CURLINFO_EFFECTIVE_URL = CURLINFO_STRING + 1,
547 CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2,
548 CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE + 3,
549 CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE + 4,
550 CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5,
551 CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6,
552 CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE + 7,
553 CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE + 8,
554 CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE + 9,
555 CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE + 10,
556 CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11,
557 CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12,
558 CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13,
559 CURLINFO_FILETIME = CURLINFO_LONG + 14,
560 CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE + 15,
561 CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE + 16,
562 CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17,
563 CURLINFO_CONTENT_TYPE = CURLINFO_STRING + 18,
564 CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19,
565 CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20,
566 CURLINFO_PRIVATE = CURLINFO_STRING + 21,
567 CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG + 22,
568 CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23,
569 CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24,
570 CURLINFO_OS_ERRNO = CURLINFO_LONG + 25,
571 CURLINFO_NUM_CONNECTS = CURLINFO_LONG + 26,
572 CURLINFO_SSL_ENGINES = CURLINFO_SLIST + 27,
573 CURLINFO_COOKIELIST = CURLINFO_SLIST + 28,
574 CURLINFO_LASTSOCKET = CURLINFO_LONG + 29,
575 CURLINFO_FTP_ENTRY_PATH = CURLINFO_STRING + 30,
576 CURLINFO_REDIRECT_URL = CURLINFO_STRING + 31,
577 CURLINFO_PRIMARY_IP = CURLINFO_STRING + 32,
578 CURLINFO_APPCONNECT_TIME = CURLINFO_DOUBLE + 33,
579 CURLINFO_CERTINFO = CURLINFO_SLIST + 34,
580 CURLINFO_CONDITION_UNMET = CURLINFO_LONG + 35,
581 CURLINFO_RTSP_SESSION_ID = CURLINFO_STRING + 36,
582 CURLINFO_RTSP_CLIENT_CSEQ = CURLINFO_LONG + 37,
583 CURLINFO_RTSP_SERVER_CSEQ = CURLINFO_LONG + 38,
584 CURLINFO_RTSP_CSEQ_RECV = CURLINFO_LONG + 39,
585 CURLINFO_PRIMARY_PORT = CURLINFO_LONG + 40,
586 CURLINFO_LOCAL_IP = CURLINFO_STRING + 41,
587 CURLINFO_LOCAL_PORT = CURLINFO_LONG + 42,
588
589 CURLINFO_LASTONE = 42
590 } CURLINFO;
591
592 typedef void CURL;
593
594 struct curl_slist
595 {
596 char* data;
597 struct curl_slist* next;
598 };
599
600 struct curl_httppost {
601 struct curl_httppost* next;
602 char* name;
603 long namelength;
604 char* contents;
605 long contentslength;
606 char* buffer;
607 long bufferlength;
608 char* contenttype;
609 struct curl_slist* contentheader;
610 struct curl_httppost* more;
611 long flags;
612 #define HTTPPOST_FILENAME (1<<0)
613 #define HTTPPOST_READFILE (1<<1)
614 #define HTTPPOST_PTRNAME (1<<2)
615 #define HTTPPOST_PTRCONTENTS (1<<3)
616 #define HTTPPOST_BUFFER (1<<4)
617 #define HTTPPOST_PTRBUFFER (1<<5)
618 #define HTTPPOST_CALLBACK (1<<6)
619
620 char* showfilename;
621 void* userp;
622 };
623
624
625 typedef enum {
626 CURL_FORMADD_OK,
627
628 CURL_FORMADD_MEMORY,
629 CURL_FORMADD_OPTION_TWICE,
630 CURL_FORMADD_NULL,
631 CURL_FORMADD_UNKNOWN_OPTION,
632 CURL_FORMADD_INCOMPLETE,
633 CURL_FORMADD_ILLEGAL_ARRAY,
634 CURL_FORMADD_DISABLED,
635
636 CURL_FORMADD_LAST
637 } CURLFORMcode;
638
639 typedef enum {
640 CURLUSESSL_NONE, /* do not attempt to use SSL */
641 CURLUSESSL_TRY, /* try using SSL, proceed anyway otherwise */
642 CURLUSESSL_CONTROL, /* SSL for the control connection or fail */
643 CURLUSESSL_ALL, /* SSL for all communication or fail */
644 CURLUSESSL_LAST /* not an option, never use */
645 } curl_usessl;
646
647 #define CURL_GLOBAL_SSL (1<<0) /* no purpose since 7.57.0 */
648 #define CURL_GLOBAL_WIN32 (1<<1)
649 #define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)
650 #define CURL_GLOBAL_NOTHING 0
651 #define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL
652 #define CURL_GLOBAL_ACK_EINTR (1<<2)
653
654 #define CURL_ZERO_TERMINATED ((size_t) -1)
655
656 typedef struct curl_mime curl_mime; /* Mime context. */
657 typedef struct curl_mimepart curl_mimepart; /* Mime part context. */
658
659 #include "gate/gatetypes.h"
660 #include "gate/libraries.h"
661 #include "gate/results.h"
662 #include "gate/debugging.h"
663 #include "gate/streams.h"
664 #include "gate/platforms.h"
665
666 typedef gate_int64_t curl_off_t;
667
668 typedef size_t (*curl_read_callback)(char *buffer,
669 size_t size,
670 size_t nitems,
671 void *instream);
672
673 typedef int (*curl_seek_callback)(void *instream,
674 curl_off_t offset,
675 int origin);
676
677 typedef void (*curl_free_callback)(void *ptr);
678
679 typedef struct gate_curl_functions_class
680 {
681 struct curl_version_info_data* (*version_info) (CURLversion age);
682 CURLcode (*easy_setopt) (CURL* handle, CURLoption option, ...);
683 void (*easy_cleanup) (CURL* handle);
684 CURLcode (*global_init) (long flags);
685 void (*global_cleanup) (void);
686 CURL* (*easy_init) (void);
687 CURLcode (*easy_perform) (CURL* handle);
688 CURLcode (*easy_getinfo) (CURL* handle, CURLINFO info, ...);
689 struct curl_slist* (*slist_append) (struct curl_slist* list, const char* str);
690 void (*slist_free_all) (struct curl_slist* list);
691 CURLFORMcode (*formadd) (struct curl_httppost** firstitem, struct curl_httppost** lastitem, ...);
692 void (*formfree) (struct curl_httppost* form);
693 curl_mime* (*mime_init) (CURL* handle);
694 void (*mime_free) (curl_mime* mime);
695 curl_mimepart* (*mime_addpart) (curl_mime* mime);
696 CURLcode (*mime_name) (curl_mimepart* part, const char* name);
697 CURLcode (*mime_filename) (curl_mimepart* part, const char* filename);
698 CURLcode (*mime_type) (curl_mimepart* part, const char* mimetype);
699 CURLcode (*mime_encoder) (curl_mimepart* part, const char* encoding);
700 CURLcode (*mime_data) (curl_mimepart* part, const char* data, size_t datasize);
701 CURLcode (*mime_filedata) (curl_mimepart* part, const char* filename);
702 CURLcode (*mime_data_cb) (curl_mimepart* part, curl_off_t datasize, curl_read_callback readfunc, curl_seek_callback seekfunc, curl_free_callback freefunc, void *arg);
703 CURLcode (*mime_subparts) (curl_mimepart* part, curl_mime* subparts);
704 CURLcode (*mime_headers) (curl_mimepart* part, struct curl_slist* headers, int take_ownership);
705 } gate_curl_functions_t;
706
707 static gate_curl_functions_t curl;
708
709
710 static gate_library_t libcurl_library = NULL;
711 static gate_bool_t volatile libcurl_library_loaded = false;
712
713
714 4 static void libcurl_atexit_cleanup(void)
715 {
716
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (libcurl_library != NULL)
717 {
718 4 curl.global_cleanup();
719 4 gate_library_close(libcurl_library);
720 4 libcurl_library = NULL;
721 }
722 4 }
723
724 #define CURL_ERROR_SIZE 256
725
726 40 static gate_result_t load_libcurl_functions(void)
727 {
728 #if defined(GATE_SYS_WIN)
729 static gate_string_t const lib_curl_file = GATE_STRING_INIT_STATIC("libcurl.dll");
730 static gate_string_t const lib_curl_file2 = GATE_STRING_INIT_STATIC("libcurl-4.dll");
731 #elif defined(GATE_SYS_DARWIN)
732 static gate_string_t const lib_curl_file = GATE_STRING_INIT_STATIC("libcurl.dylib");
733 static gate_string_t const lib_curl_file2 = GATE_STRING_INIT_STATIC("libcurl.dylib");
734 #else
735 static gate_string_t const lib_curl_file = GATE_STRING_INIT_STATIC("libcurl.so");
736 static gate_string_t const lib_curl_file2 = GATE_STRING_INIT_STATIC("libcurl.so.4");
737 #endif
738
739 40 gate_result_t ret = GATE_RESULT_NOTSUPPORTED;
740
741
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 36 times.
40 if (!libcurl_library_loaded)
742 {
743 do
744 {
745
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (libcurl_library == NULL)
746 {
747 4 ret = gate_library_open(&lib_curl_file, &libcurl_library, GATE_LIBRARY_FLAG_DEFAULT);
748
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (GATE_FAILED(ret))
749 {
750 4 ret = gate_library_open(&lib_curl_file2, &libcurl_library, GATE_LIBRARY_FLAG_DEFAULT);
751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (GATE_FAILED(ret))
752 {
753 ✗ libcurl_library = NULL;
754 ✗ break;
755 }
756 }
757 4 gate_platform_atexit(&libcurl_atexit_cleanup);
758 }
759
760
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_version_info", &curl.version_info));
761
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_easy_setopt", &curl.easy_setopt));
762
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_easy_cleanup", &curl.easy_cleanup));
763
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_global_init", &curl.global_init));
764
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_global_cleanup", &curl.global_cleanup));
765
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_easy_init", &curl.easy_init));
766
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_easy_perform", &curl.easy_perform));
767
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_easy_getinfo", &curl.easy_getinfo));
768
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_slist_append", &curl.slist_append));
769
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_slist_free_all", &curl.slist_free_all));
770
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_formadd", &curl.formadd));
771
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_formfree", &curl.formfree));
772
773
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_mime_init", &curl.mime_init));
774
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_mime_free", &curl.mime_free));
775
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_mime_addpart", &curl.mime_addpart));
776
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_mime_name", &curl.mime_name));
777
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_mime_filename", &curl.mime_filename));
778
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_mime_type", &curl.mime_type));
779
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_mime_encoder", &curl.mime_encoder));
780
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_mime_data", &curl.mime_data));
781
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_mime_filedata", &curl.mime_filedata));
782
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_mime_data_cb", &curl.mime_data_cb));
783
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_mime_subparts", &curl.mime_subparts));
784
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 GATE_BREAK_IF_FAILED(ret = gate_library_get_data_name(libcurl_library, "curl_mime_headers", &curl.mime_headers));
785
786 4 curl.global_init(CURL_GLOBAL_ALL);
787
788 4 libcurl_library_loaded = true;
789 } while (0);
790 }
791
792
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if (libcurl_library_loaded)
793 {
794 40 ret = GATE_RESULT_OK;
795 }
796 40 return ret;
797 }
798
799 typedef struct gate_curl_error_mapping
800 {
801 CURLcode code;
802 gate_result_t result;
803 char const* msg;
804 } gate_curl_error_mapping_t;
805
806 214 static gate_result_t gate_curl_map_result(CURLcode code, char const** ptr_msg)
807 {
808 static gate_curl_error_mapping_t const errors[] =
809 {
810 { CURLE_UNSUPPORTED_PROTOCOL, GATE_RESULT_NOTSUPPORTED, "Unsupported Protocol" },
811 { CURLE_FAILED_INIT, GATE_RESULT_FAILED, "Initialization failed" },
812 { CURLE_URL_MALFORMAT, GATE_RESULT_FAILED, "Invalid URL" },
813 { CURLE_NOT_BUILT_IN, GATE_RESULT_NOTSUPPORTED, "Feature not built in" },
814 { CURLE_COULDNT_RESOLVE_PROXY, GATE_RESULT_NOTAVAILABLE, "Failed to resolve proxy" },
815 { CURLE_COULDNT_RESOLVE_HOST, GATE_RESULT_NOTAVAILABLE, "Failed to resolve host" },
816 { CURLE_COULDNT_CONNECT, GATE_RESULT_NOTAVAILABLE, "Connect failed" },
817 { CURLE_FTP_WEIRD_SERVER_REPLY, GATE_RESULT_FAILED, "Invalid FTP server reply" },
818 { CURLE_REMOTE_ACCESS_DENIED, GATE_RESULT_ACCESSDENIED, "Remote access denied" },
819 { CURLE_FTP_ACCEPT_FAILED, GATE_RESULT_FAILED, "FTP accept failed" },
820 { CURLE_FTP_WEIRD_PASS_REPLY, GATE_RESULT_FAILED, "Invalid FTP PASS reply" },
821 { CURLE_FTP_ACCEPT_TIMEOUT, GATE_RESULT_TIMEOUT, "FTP accept timeout" },
822 { CURLE_FTP_WEIRD_PASV_REPLY, GATE_RESULT_FAILED, "Invalid FTP PASV reply" },
823 { CURLE_FTP_WEIRD_227_FORMAT, GATE_RESULT_FAILED, "Invalid FTP 227 format" },
824 { CURLE_FTP_CANT_GET_HOST, GATE_RESULT_FAILED, "Cant get FTP host" },
825 #ifdef CURLE_HTTP2
826 { CURLE_HTTP2, GATE_RESULT_FAILED, "HTTP2" },
827 #endif
828 { CURLE_FTP_COULDNT_SET_TYPE, GATE_RESULT_FAILED, "Failed to set FTP type" },
829 { CURLE_PARTIAL_FILE, GATE_RESULT_FAILED, "Partial file" },
830 { CURLE_FTP_COULDNT_RETR_FILE, GATE_RESULT_FAILED, "Failed to retrieve FTP file" },
831 { CURLE_QUOTE_ERROR, GATE_RESULT_FAILED, "QUOTE error" },
832 { CURLE_HTTP_RETURNED_ERROR, GATE_RESULT_FAILED, "HTTP error" },
833 { CURLE_WRITE_ERROR, GATE_RESULT_FAILED, "Write failed" },
834 { CURLE_UPLOAD_FAILED, GATE_RESULT_FAILED, "Upload failed" },
835 { CURLE_READ_ERROR, GATE_RESULT_FAILED, "Read failed" },
836 { CURLE_OUT_OF_MEMORY, GATE_RESULT_OUTOFMEMORY, "Out of memory" },
837 { CURLE_OPERATION_TIMEDOUT, GATE_RESULT_TIMEOUT, "Operation timeout" },
838 { CURLE_FTP_PORT_FAILED, GATE_RESULT_FAILED, "FTP PORT command failed" },
839 { CURLE_FTP_COULDNT_USE_REST, GATE_RESULT_FAILED, "FTP REST command failed" },
840 { CURLE_RANGE_ERROR, GATE_RESULT_FAILED, "Range request failed" },
841 { CURLE_HTTP_POST_ERROR, GATE_RESULT_FAILED, "HTTP POST failed" },
842 { CURLE_SSL_CONNECT_ERROR, GATE_RESULT_FAILED, "SSL connect error" },
843 { CURLE_BAD_DOWNLOAD_RESUME, GATE_RESULT_FAILED, "Failed to resume download" },
844 { CURLE_FILE_COULDNT_READ_FILE, GATE_RESULT_FAILED, "Failed to read file" },
845 { CURLE_LDAP_CANNOT_BIND, GATE_RESULT_FAILED, "Cannot bind LDAP" },
846 { CURLE_LDAP_SEARCH_FAILED, GATE_RESULT_FAILED, "LDAP search failed" },
847 { CURLE_FUNCTION_NOT_FOUND, GATE_RESULT_NOTAVAILABLE, "Function not found" },
848 { CURLE_ABORTED_BY_CALLBACK, GATE_RESULT_CANCELED, "Canceled by callback" },
849 { CURLE_BAD_FUNCTION_ARGUMENT, GATE_RESULT_INVALIDARG, "Bad function argument" },
850 { CURLE_INTERFACE_FAILED, GATE_RESULT_FAILED, "Interface failed" },
851 { CURLE_TOO_MANY_REDIRECTS, GATE_RESULT_FAILED, "Too many redirects" },
852 { CURLE_UNKNOWN_OPTION, GATE_RESULT_FAILED, "Unknown option" },
853 { CURLE_TELNET_OPTION_SYNTAX, GATE_RESULT_FAILED, "Telnet option illegally formated" },
854 { CURLE_PEER_FAILED_VERIFICATION, GATE_RESULT_FAILED, "Peer verification failed" },
855 { CURLE_GOT_NOTHING, GATE_RESULT_INVALIDDATA, "No data returned" },
856 { CURLE_SSL_ENGINE_NOTFOUND, GATE_RESULT_NOTAVAILABLE, "SSL engine not found" },
857 { CURLE_SSL_ENGINE_SETFAILED, GATE_RESULT_NOTAVAILABLE, "SSL engine error" },
858 { CURLE_SEND_ERROR, GATE_RESULT_FAILED, "Send error" },
859 { CURLE_RECV_ERROR, GATE_RESULT_FAILED, "Receive error" },
860 { CURLE_SSL_CERTPROBLEM, GATE_RESULT_FAILED, "SSL Certificate problem" },
861 { CURLE_SSL_CIPHER, GATE_RESULT_FAILED, "SSL cipher error" },
862 { CURLE_SSL_CACERT, GATE_RESULT_FAILED, "SSL certificate authentication failed" },
863 { CURLE_BAD_CONTENT_ENCODING, GATE_RESULT_INVALIDDATA, "Bad content encoding" },
864 { CURLE_LDAP_INVALID_URL, GATE_RESULT_FAILED, "LDAP invalid URL" },
865 { CURLE_FILESIZE_EXCEEDED, GATE_RESULT_INCORRECTSIZE, "Filesize exceeded" },
866 { CURLE_USE_SSL_FAILED, GATE_RESULT_FAILED, "Requested SSL level failed" },
867 { CURLE_SEND_FAIL_REWIND, GATE_RESULT_FAILED, "Send-Rewind failed" },
868 { CURLE_SSL_ENGINE_INITFAILED, GATE_RESULT_FAILED, "SSL initialization failed" },
869 { CURLE_LOGIN_DENIED, GATE_RESULT_ACCESSDENIED, "Login denied" },
870 { CURLE_TFTP_NOTFOUND, GATE_RESULT_NOTAVAILABLE, "TFTP not found" },
871 { CURLE_TFTP_PERM, GATE_RESULT_ACCESSDENIED, "TFTP permission failed" },
872 { CURLE_REMOTE_DISK_FULL, GATE_RESULT_FAILED, "Remote disk full" },
873 { CURLE_TFTP_ILLEGAL, GATE_RESULT_FAILED, "Illegal TFTP operation" },
874 { CURLE_TFTP_UNKNOWNID, GATE_RESULT_FAILED, "Unknown TFTP transfer ID" },
875 { CURLE_REMOTE_FILE_EXISTS, GATE_RESULT_ALREADYEXISTS, "Remote file exists" },
876 { CURLE_TFTP_NOSUCHUSER, GATE_RESULT_FAILED, "TFTP: No such user" },
877 { CURLE_CONV_FAILED, GATE_RESULT_INVALIDDATA, "Character conversion failed" },
878 { CURLE_CONV_REQD, GATE_RESULT_FAILED, "Conversion callback missing" },
879 { CURLE_SSL_CACERT_BADFILE, GATE_RESULT_FAILED, "SSL CA cert file problem" },
880 { CURLE_REMOTE_FILE_NOT_FOUND, GATE_RESULT_FAILED, "Remote file not found" },
881 { CURLE_SSH, GATE_RESULT_FAILED, "SSH error" },
882 { CURLE_SSL_SHUTDOWN_FAILED, GATE_RESULT_FAILED, "SSL shutdown failed" },
883 { CURLE_AGAIN, GATE_RESULT_NOTREADY, "Socket not ready for send/recv" },
884 { CURLE_SSL_CRL_BADFILE, GATE_RESULT_FAILED, "Failed to load SSL CRL file" },
885 { CURLE_SSL_ISSUER_ERROR, GATE_RESULT_FAILED, "SSL issuer check failed" },
886 { CURLE_FTP_PRET_FAILED, GATE_RESULT_FAILED, "FTP PRET command failed" },
887 { CURLE_RTSP_CSEQ_ERROR, GATE_RESULT_FAILED, "Mismatch of RTSP CSeq numbers" },
888 { CURLE_RTSP_SESSION_ERROR, GATE_RESULT_FAILED, "Mismatch of RTSP session identifiers" },
889 { CURLE_FTP_BAD_FILE_LIST, GATE_RESULT_FAILED, "Unable to parse FTP file list" },
890 { CURLE_CHUNK_FAILED, GATE_RESULT_FAILED, "Chunk callback error" },
891 #ifdef CURLE_NO_CONNECTION_AVAILABLE
892 { CURLE_NO_CONNECTION_AVAILABLE, GATE_RESULT_FAILED, "No connection available" },
893 #endif
894 #ifdef CURLE_SSL_PINNEDPUBKEYNOTMATCH
895 { CURLE_SSL_PINNEDPUBKEYNOTMATCH, GATE_RESULT_FAILED, "Failed to match pinned key" },
896 #endif
897 #ifdef CURLE_SSL_INVALIDCERTSTATUS
898 { CURLE_SSL_INVALIDCERTSTATUS, GATE_RESULT_FAILED, "Invalid SSL cert status" },
899 #endif
900 #ifdef CURLE_HTTP2_STREAM
901 { CURLE_HTTP2_STREAM, GATE_RESULT_FAILED, "HTTP2 stream error" },
902 #endif
903 { CURLE_OK, GATE_RESULT_OK, "" }
904 };
905 static unsigned const errors_count = sizeof(errors) / sizeof(errors[0]);
906 unsigned ndx;
907
1/2
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
214 if (code == CURLE_OK)
908 {
909 /* No error */
910
1/2
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
214 if (ptr_msg != NULL) *ptr_msg = NULL;
911 214 return GATE_RESULT_OK;
912 }
913
914 ✗ for (ndx = 0; ndx != errors_count; ++ndx)
915 {
916 ✗ if (errors[ndx].code == code)
917 {
918 ✗ if (ptr_msg != NULL) *ptr_msg = errors[ndx].msg;
919 ✗ return errors[ndx].result;
920 }
921 }
922
923 /* unknown error */
924 ✗ if (ptr_msg != NULL) *ptr_msg = "Unknown error";
925 ✗ return GATE_RESULT_UNKNOWNERROR;
926 }
927
928 ✗ static size_t gate_curl_read_stream_cb(void* ptr, size_t size, size_t nmemb, void* data)
929 {
930 ✗ gate_stream_t* stream = (gate_stream_t*)data;
931 ✗ size_t len = size * nmemb;
932 ✗ gate_size_t lenread = 0;
933 gate_result_t result;
934
935 ✗ if (!stream || (len == 0))
936 {
937 ✗ return 0;
938 }
939
940 ✗ result = gate_stream_read_block(stream, (char*)ptr, len, &lenread);
941 ✗ if (GATE_SUCCEEDED(result))
942 {
943 /* success case */
944 ✗ GATE_DEBUG_ASSERT((lenread % size) == 0);
945 ✗ return lenread / size;
946 }
947 else
948 {
949 /* error case */
950 ✗ return 0;
951 }
952 }
953
954 ✗ static size_t gate_curl_noread_cb(void* ptr, size_t size, size_t nmemb, void* data)
955 {
956 GATE_UNUSED_ARG(ptr);
957 GATE_UNUSED_ARG(size);
958 GATE_UNUSED_ARG(nmemb);
959 GATE_UNUSED_ARG(data);
960 ✗ return 0;
961 }
962
963
964 486 static size_t gate_curl_write_stream_cb(void* ptr, size_t size, size_t nmemb, void* data)
965 {
966 486 gate_stream_t* const stream = (gate_stream_t*)data;
967 486 size_t const len = size * nmemb;
968 486 char* const str = (char*)ptr;
969 486 gate_size_t written = 0;
970 gate_result_t result;
971
972
3/6
✓ Branch 0 taken 486 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 486 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 486 times.
486 if (len == 0 || !stream || !ptr)
973 {
974 /* invalid arg error */
975 ✗ return 0;
976 }
977
978 486 result = gate_stream_write_block(stream, str, len, &written);
979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 486 times.
486 if (GATE_FAILED(result))
980 {
981 /* write failed */
982 ✗ return 0;
983 }
984 else
985 {
986 /* write succeeded */
987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 486 times.
486 GATE_DEBUG_ASSERT(written == len);
988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 486 times.
486 GATE_DEBUG_ASSERT((written % size) == 0);
989 486 return written / size;
990 }
991
992 }
993
994 1 static size_t gate_curl_nowrite_cb(void* ptr, size_t size, size_t nmemb, void* data)
995 {
996 GATE_UNUSED_ARG(ptr);
997 GATE_UNUSED_ARG(size);
998 GATE_UNUSED_ARG(nmemb);
999 GATE_UNUSED_ARG(data);
1000 1 return nmemb;
1001 }
1002
1003
1004 #ifndef CURL_BREAK_IF_FAILED
1005 #define CURL_BREAK_IF_FAILED(curl_result) if(CURLE_OK != (curl_result)) { break; }
1006 #endif
1007
1008 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)
1009 {
1010 3 gate_result_t ret = GATE_RESULT_FAILED;
1011 do
1012 {
1013 3 curl.easy_setopt(ptr_curl, CURLOPT_NOSIGNAL, 1L);
1014
1015
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (!gate_string_is_empty(url))
1016 {
1017
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)));
1018 }
1019
1020
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));
1021
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,
1022 (input_stream != NULL) ? &gate_curl_read_stream_cb : &gate_curl_noread_cb));
1023
1024
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));
1025
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,
1026 (output_stream != NULL) ? &gate_curl_write_stream_cb : &gate_curl_nowrite_cb));
1027
1028 3 ret = GATE_RESULT_OK;
1029 } while (0);
1030
1031 3 return ret;
1032 }
1033
1034 3 static gate_result_t gate_curl_reset(CURL* ptr_curl)
1035 {
1036 3 gate_result_t ret = GATE_RESULT_FAILED;
1037
1038 do
1039 {
1040 /* ensure we don't have pointers and functions that are not valid anymore */
1041 3 curl.easy_setopt(ptr_curl, CURLOPT_READDATA, NULL);
1042 3 curl.easy_setopt(ptr_curl, CURLOPT_READFUNCTION, &gate_curl_noread_cb);
1043
1044 3 curl.easy_setopt(ptr_curl, CURLOPT_WRITEDATA, NULL);
1045 3 curl.easy_setopt(ptr_curl, CURLOPT_WRITEFUNCTION, &gate_curl_nowrite_cb);
1046
1047 3 ret = GATE_RESULT_OK;
1048 } while (0);
1049
1050 3 return ret;
1051 }
1052
1053 #endif
1054