1 | #ifndef HEADER_CURL_SETUP_H
|
---|
2 | #define HEADER_CURL_SETUP_H
|
---|
3 | /***************************************************************************
|
---|
4 | * _ _ ____ _
|
---|
5 | * Project ___| | | | _ \| |
|
---|
6 | * / __| | | | |_) | |
|
---|
7 | * | (__| |_| | _ <| |___
|
---|
8 | * \___|\___/|_| \_\_____|
|
---|
9 | *
|
---|
10 | * Copyright (C) Daniel Stenberg, <[email protected]>, et al.
|
---|
11 | *
|
---|
12 | * This software is licensed as described in the file COPYING, which
|
---|
13 | * you should have received as part of this distribution. The terms
|
---|
14 | * are also available at https://curl.se/docs/copyright.html.
|
---|
15 | *
|
---|
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
---|
17 | * copies of the Software, and permit persons to whom the Software is
|
---|
18 | * furnished to do so, under the terms of the COPYING file.
|
---|
19 | *
|
---|
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
---|
21 | * KIND, either express or implied.
|
---|
22 | *
|
---|
23 | * SPDX-License-Identifier: curl
|
---|
24 | *
|
---|
25 | ***************************************************************************/
|
---|
26 |
|
---|
27 | #if defined(BUILDING_LIBCURL) && !defined(CURL_NO_OLDIES)
|
---|
28 | #define CURL_NO_OLDIES
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | /* FIXME: Delete this once the warnings have been fixed. */
|
---|
32 | #if !defined(CURL_WARN_SIGN_CONVERSION)
|
---|
33 | #ifdef __GNUC__
|
---|
34 | #pragma GCC diagnostic ignored "-Wsign-conversion"
|
---|
35 | #endif
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | /* Set default _WIN32_WINNT */
|
---|
39 | #ifdef __MINGW32__
|
---|
40 | #include <_mingw.h>
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | /*
|
---|
44 | * Disable Visual Studio warnings:
|
---|
45 | * 4127 "conditional expression is constant"
|
---|
46 | */
|
---|
47 | #ifdef _MSC_VER
|
---|
48 | #pragma warning(disable:4127)
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | /*
|
---|
52 | * VBOX
|
---|
53 | * Define WIN32 when build target is Win32 API
|
---|
54 | */
|
---|
55 |
|
---|
56 | #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
---|
57 | #define WIN32
|
---|
58 | #endif
|
---|
59 |
|
---|
60 |
|
---|
61 | #ifdef _WIN32
|
---|
62 | /*
|
---|
63 | * Don't include unneeded stuff in Windows headers to avoid compiler
|
---|
64 | * warnings and macro clashes.
|
---|
65 | * Make sure to define this macro before including any Windows headers.
|
---|
66 | */
|
---|
67 | # ifndef WIN32_LEAN_AND_MEAN
|
---|
68 | # define WIN32_LEAN_AND_MEAN
|
---|
69 | # endif
|
---|
70 | # ifndef NOGDI
|
---|
71 | # define NOGDI
|
---|
72 | # endif
|
---|
73 | /* Detect Windows App environment which has a restricted access
|
---|
74 | * to the Win32 APIs. */
|
---|
75 | # if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \
|
---|
76 | defined(WINAPI_FAMILY)
|
---|
77 | # include <winapifamily.h>
|
---|
78 | # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
|
---|
79 | !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
---|
80 | # define CURL_WINDOWS_APP
|
---|
81 | # endif
|
---|
82 | # endif
|
---|
83 | #endif
|
---|
84 |
|
---|
85 | /*
|
---|
86 | * Include configuration script results or hand-crafted
|
---|
87 | * configuration file for platforms which lack config tool.
|
---|
88 | */
|
---|
89 |
|
---|
90 | #ifdef HAVE_CONFIG_H
|
---|
91 |
|
---|
92 | #include "curl_config.h"
|
---|
93 |
|
---|
94 | # ifdef VBOX
|
---|
95 | # ifdef WIN32
|
---|
96 | /* Fixing an issue with following #if (SIZEOF_CURL_OFF_T < 8) */
|
---|
97 | /* Define to the size of `curl_off_t', as computed by sizeof. */
|
---|
98 | # undef SIZEOF_CURL_OFF_T
|
---|
99 | # define SIZEOF_CURL_OFF_T 8
|
---|
100 | # endif
|
---|
101 | # endif
|
---|
102 |
|
---|
103 | #else /* HAVE_CONFIG_H */
|
---|
104 |
|
---|
105 | #ifdef _WIN32_WCE
|
---|
106 | # include "config-win32ce.h"
|
---|
107 | #else
|
---|
108 | # ifdef _WIN32
|
---|
109 | # include "config-win32.h"
|
---|
110 | # endif
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | #ifdef macintosh
|
---|
114 | # include "config-mac.h"
|
---|
115 | #endif
|
---|
116 |
|
---|
117 | #ifdef __riscos__
|
---|
118 | # include "config-riscos.h"
|
---|
119 | #endif
|
---|
120 |
|
---|
121 | #ifdef __AMIGA__
|
---|
122 | # include "config-amigaos.h"
|
---|
123 | #endif
|
---|
124 |
|
---|
125 | #ifdef __OS400__
|
---|
126 | # include "config-os400.h"
|
---|
127 | #endif
|
---|
128 |
|
---|
129 | #ifdef __PLAN9__
|
---|
130 | # include "config-plan9.h"
|
---|
131 | #endif
|
---|
132 |
|
---|
133 | #ifdef MSDOS
|
---|
134 | # include "config-dos.h"
|
---|
135 | #endif
|
---|
136 |
|
---|
137 | #endif /* HAVE_CONFIG_H */
|
---|
138 |
|
---|
139 | /* ================================================================ */
|
---|
140 | /* Definition of preprocessor macros/symbols which modify compiler */
|
---|
141 | /* behavior or generated code characteristics must be done here, */
|
---|
142 | /* as appropriate, before any system header file is included. It is */
|
---|
143 | /* also possible to have them defined in the config file included */
|
---|
144 | /* before this point. As a result of all this we frown inclusion of */
|
---|
145 | /* system header files in our config files, avoid this at any cost. */
|
---|
146 | /* ================================================================ */
|
---|
147 |
|
---|
148 | /*
|
---|
149 | * AIX 4.3 and newer needs _THREAD_SAFE defined to build
|
---|
150 | * proper reentrant code. Others may also need it.
|
---|
151 | */
|
---|
152 |
|
---|
153 | #ifdef NEED_THREAD_SAFE
|
---|
154 | # ifndef _THREAD_SAFE
|
---|
155 | # define _THREAD_SAFE
|
---|
156 | # endif
|
---|
157 | #endif
|
---|
158 |
|
---|
159 | /*
|
---|
160 | * Tru64 needs _REENTRANT set for a few function prototypes and
|
---|
161 | * things to appear in the system header files. Unixware needs it
|
---|
162 | * to build proper reentrant code. Others may also need it.
|
---|
163 | */
|
---|
164 |
|
---|
165 | #ifdef NEED_REENTRANT
|
---|
166 | # ifndef _REENTRANT
|
---|
167 | # define _REENTRANT
|
---|
168 | # endif
|
---|
169 | #endif
|
---|
170 |
|
---|
171 | /* Solaris needs this to get a POSIX-conformant getpwuid_r */
|
---|
172 | #if defined(sun) || defined(__sun)
|
---|
173 | # ifndef _POSIX_PTHREAD_SEMANTICS
|
---|
174 | # define _POSIX_PTHREAD_SEMANTICS 1
|
---|
175 | # endif
|
---|
176 | #endif
|
---|
177 |
|
---|
178 | /* ================================================================ */
|
---|
179 | /* If you need to include a system header file for your platform, */
|
---|
180 | /* please, do it beyond the point further indicated in this file. */
|
---|
181 | /* ================================================================ */
|
---|
182 |
|
---|
183 | /*
|
---|
184 | * Disable other protocols when http is the only one desired.
|
---|
185 | */
|
---|
186 |
|
---|
187 | #ifdef HTTP_ONLY
|
---|
188 | # ifndef CURL_DISABLE_DICT
|
---|
189 | # define CURL_DISABLE_DICT
|
---|
190 | # endif
|
---|
191 | # ifndef CURL_DISABLE_FILE
|
---|
192 | # define CURL_DISABLE_FILE
|
---|
193 | # endif
|
---|
194 | # ifndef CURL_DISABLE_FTP
|
---|
195 | # define CURL_DISABLE_FTP
|
---|
196 | # endif
|
---|
197 | # ifndef CURL_DISABLE_GOPHER
|
---|
198 | # define CURL_DISABLE_GOPHER
|
---|
199 | # endif
|
---|
200 | # ifndef CURL_DISABLE_IMAP
|
---|
201 | # define CURL_DISABLE_IMAP
|
---|
202 | # endif
|
---|
203 | # ifndef CURL_DISABLE_LDAP
|
---|
204 | # define CURL_DISABLE_LDAP
|
---|
205 | # endif
|
---|
206 | # ifndef CURL_DISABLE_LDAPS
|
---|
207 | # define CURL_DISABLE_LDAPS
|
---|
208 | # endif
|
---|
209 | # ifndef CURL_DISABLE_MQTT
|
---|
210 | # define CURL_DISABLE_MQTT
|
---|
211 | # endif
|
---|
212 | # ifndef CURL_DISABLE_POP3
|
---|
213 | # define CURL_DISABLE_POP3
|
---|
214 | # endif
|
---|
215 | # ifndef CURL_DISABLE_RTSP
|
---|
216 | # define CURL_DISABLE_RTSP
|
---|
217 | # endif
|
---|
218 | # ifndef CURL_DISABLE_SMB
|
---|
219 | # define CURL_DISABLE_SMB
|
---|
220 | # endif
|
---|
221 | # ifndef CURL_DISABLE_SMTP
|
---|
222 | # define CURL_DISABLE_SMTP
|
---|
223 | # endif
|
---|
224 | # ifndef CURL_DISABLE_TELNET
|
---|
225 | # define CURL_DISABLE_TELNET
|
---|
226 | # endif
|
---|
227 | # ifndef CURL_DISABLE_TFTP
|
---|
228 | # define CURL_DISABLE_TFTP
|
---|
229 | # endif
|
---|
230 | #endif
|
---|
231 |
|
---|
232 | /*
|
---|
233 | * When http is disabled rtsp is not supported.
|
---|
234 | */
|
---|
235 |
|
---|
236 | #if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP)
|
---|
237 | # define CURL_DISABLE_RTSP
|
---|
238 | #endif
|
---|
239 |
|
---|
240 | /*
|
---|
241 | * When HTTP is disabled, disable HTTP-only features
|
---|
242 | */
|
---|
243 |
|
---|
244 | #if defined(CURL_DISABLE_HTTP)
|
---|
245 | # define CURL_DISABLE_ALTSVC 1
|
---|
246 | # define CURL_DISABLE_COOKIES 1
|
---|
247 | # define CURL_DISABLE_BASIC_AUTH 1
|
---|
248 | # define CURL_DISABLE_BEARER_AUTH 1
|
---|
249 | # define CURL_DISABLE_AWS 1
|
---|
250 | # define CURL_DISABLE_DOH 1
|
---|
251 | # define CURL_DISABLE_FORM_API 1
|
---|
252 | # define CURL_DISABLE_HEADERS_API 1
|
---|
253 | # define CURL_DISABLE_HSTS 1
|
---|
254 | # define CURL_DISABLE_HTTP_AUTH 1
|
---|
255 | #endif
|
---|
256 |
|
---|
257 | /* ================================================================ */
|
---|
258 | /* No system header file shall be included in this file before this */
|
---|
259 | /* point. */
|
---|
260 | /* ================================================================ */
|
---|
261 |
|
---|
262 | /*
|
---|
263 | * OS/400 setup file includes some system headers.
|
---|
264 | */
|
---|
265 |
|
---|
266 | #ifdef __OS400__
|
---|
267 | # include "setup-os400.h"
|
---|
268 | #endif
|
---|
269 |
|
---|
270 | /*
|
---|
271 | * VMS setup file includes some system headers.
|
---|
272 | */
|
---|
273 |
|
---|
274 | #ifdef __VMS
|
---|
275 | # include "setup-vms.h"
|
---|
276 | #endif
|
---|
277 |
|
---|
278 | /*
|
---|
279 | * Windows setup file includes some system headers.
|
---|
280 | */
|
---|
281 |
|
---|
282 | #ifdef _WIN32
|
---|
283 | # include "setup-win32.h"
|
---|
284 | #endif
|
---|
285 |
|
---|
286 | #include <curl/system.h>
|
---|
287 |
|
---|
288 | /* Helper macro to expand and concatenate two macros.
|
---|
289 | * Direct macros concatenation does not work because macros
|
---|
290 | * are not expanded before direct concatenation.
|
---|
291 | */
|
---|
292 | #define CURL_CONC_MACROS_(A,B) A ## B
|
---|
293 | #define CURL_CONC_MACROS(A,B) CURL_CONC_MACROS_(A,B)
|
---|
294 |
|
---|
295 | /* curl uses its own printf() function internally. It understands the GNU
|
---|
296 | * format. Use this format, so that is matches the GNU format attribute we
|
---|
297 | * use with the mingw compiler, allowing it to verify them at compile-time.
|
---|
298 | */
|
---|
299 | #ifdef __MINGW32__
|
---|
300 | # undef CURL_FORMAT_CURL_OFF_T
|
---|
301 | # undef CURL_FORMAT_CURL_OFF_TU
|
---|
302 | # define CURL_FORMAT_CURL_OFF_T "lld"
|
---|
303 | # define CURL_FORMAT_CURL_OFF_TU "llu"
|
---|
304 | #endif
|
---|
305 |
|
---|
306 | /* based on logic in "curl/mprintf.h" */
|
---|
307 |
|
---|
308 | #if (defined(__GNUC__) || defined(__clang__)) && \
|
---|
309 | defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
|
---|
310 | !defined(CURL_NO_FMT_CHECKS)
|
---|
311 | #if defined(__MINGW32__) && !defined(__clang__)
|
---|
312 | #define CURL_PRINTF(fmt, arg) \
|
---|
313 | __attribute__((format(gnu_printf, fmt, arg)))
|
---|
314 | #else
|
---|
315 | #define CURL_PRINTF(fmt, arg) \
|
---|
316 | __attribute__((format(__printf__, fmt, arg)))
|
---|
317 | #endif
|
---|
318 | #else
|
---|
319 | #define CURL_PRINTF(fmt, arg)
|
---|
320 | #endif
|
---|
321 |
|
---|
322 | /*
|
---|
323 | * Use getaddrinfo to resolve the IPv4 address literal. If the current network
|
---|
324 | * interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64,
|
---|
325 | * performing this task will result in a synthesized IPv6 address.
|
---|
326 | */
|
---|
327 | #if defined(__APPLE__) && !defined(USE_ARES)
|
---|
328 | #include <TargetConditionals.h>
|
---|
329 | #define USE_RESOLVE_ON_IPS 1
|
---|
330 | # if TARGET_OS_MAC && !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && \
|
---|
331 | defined(ENABLE_IPV6)
|
---|
332 | # define CURL_MACOS_CALL_COPYPROXIES 1
|
---|
333 | # endif
|
---|
334 | #endif
|
---|
335 |
|
---|
336 | #ifdef USE_LWIPSOCK
|
---|
337 | # include <lwip/init.h>
|
---|
338 | # include <lwip/sockets.h>
|
---|
339 | # include <lwip/netdb.h>
|
---|
340 | #endif
|
---|
341 |
|
---|
342 | #ifdef HAVE_EXTRA_STRICMP_H
|
---|
343 | # include <extra/stricmp.h>
|
---|
344 | #endif
|
---|
345 |
|
---|
346 | #ifdef HAVE_EXTRA_STRDUP_H
|
---|
347 | # include <extra/strdup.h>
|
---|
348 | #endif
|
---|
349 |
|
---|
350 | #ifdef __AMIGA__
|
---|
351 | # ifdef __amigaos4__
|
---|
352 | # define __USE_INLINE__
|
---|
353 | /* use our own resolver which uses runtime feature detection */
|
---|
354 | # define CURLRES_AMIGA
|
---|
355 | /* getaddrinfo() currently crashes bsdsocket.library, so disable */
|
---|
356 | # undef HAVE_GETADDRINFO
|
---|
357 | # if !(defined(__NEWLIB__) || \
|
---|
358 | (defined(__CLIB2__) && defined(__THREAD_SAFE)))
|
---|
359 | /* disable threaded resolver with clib2 - requires newlib or clib-ts */
|
---|
360 | # undef USE_THREADS_POSIX
|
---|
361 | # endif
|
---|
362 | # endif
|
---|
363 | # include <exec/types.h>
|
---|
364 | # include <exec/execbase.h>
|
---|
365 | # include <proto/exec.h>
|
---|
366 | # include <proto/dos.h>
|
---|
367 | # include <unistd.h>
|
---|
368 | # if defined(HAVE_PROTO_BSDSOCKET_H) && \
|
---|
369 | (!defined(__amigaos4__) || defined(USE_AMISSL))
|
---|
370 | /* use bsdsocket.library directly, instead of libc networking functions */
|
---|
371 | # define _SYS_MBUF_H /* m_len define clashes with curl */
|
---|
372 | # include <proto/bsdsocket.h>
|
---|
373 | # ifdef __amigaos4__
|
---|
374 | int Curl_amiga_select(int nfds, fd_set *readfds, fd_set *writefds,
|
---|
375 | fd_set *errorfds, struct timeval *timeout);
|
---|
376 | # define select(a,b,c,d,e) Curl_amiga_select(a,b,c,d,e)
|
---|
377 | # else
|
---|
378 | # define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
|
---|
379 | # endif
|
---|
380 | /* must not use libc's fcntl() on bsdsocket.library sockfds! */
|
---|
381 | # undef HAVE_FCNTL
|
---|
382 | # undef HAVE_FCNTL_O_NONBLOCK
|
---|
383 | # else
|
---|
384 | /* use libc networking and hence close() and fnctl() */
|
---|
385 | # undef HAVE_CLOSESOCKET_CAMEL
|
---|
386 | # undef HAVE_IOCTLSOCKET_CAMEL
|
---|
387 | # endif
|
---|
388 | /*
|
---|
389 | * In clib2 arpa/inet.h warns that some prototypes may clash
|
---|
390 | * with bsdsocket.library. This avoids the definition of those.
|
---|
391 | */
|
---|
392 | # define __NO_NET_API
|
---|
393 | #endif
|
---|
394 |
|
---|
395 | #include <stdio.h>
|
---|
396 | #include <assert.h>
|
---|
397 |
|
---|
398 | #ifdef __TANDEM /* for ns*-tandem-nsk systems */
|
---|
399 | # if ! defined __LP64
|
---|
400 | # include <floss.h> /* FLOSS is only used for 32-bit builds. */
|
---|
401 | # endif
|
---|
402 | #endif
|
---|
403 |
|
---|
404 | #ifndef STDC_HEADERS /* no standard C headers! */
|
---|
405 | #include <curl/stdcheaders.h>
|
---|
406 | #endif
|
---|
407 |
|
---|
408 | /*
|
---|
409 | * Large file (>2Gb) support using WIN32 functions.
|
---|
410 | */
|
---|
411 |
|
---|
412 | #ifdef USE_WIN32_LARGE_FILES
|
---|
413 | # include <io.h>
|
---|
414 | # include <sys/types.h>
|
---|
415 | # include <sys/stat.h>
|
---|
416 | # undef lseek
|
---|
417 | # define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence)
|
---|
418 | # undef fstat
|
---|
419 | # define fstat(fdes,stp) _fstati64(fdes, stp)
|
---|
420 | # undef stat
|
---|
421 | # define stat(fname,stp) curlx_win32_stat(fname, stp)
|
---|
422 | # define struct_stat struct _stati64
|
---|
423 | # define LSEEK_ERROR (__int64)-1
|
---|
424 | # define open curlx_win32_open
|
---|
425 | # define fopen(fname,mode) curlx_win32_fopen(fname, mode)
|
---|
426 | # define access(fname,mode) curlx_win32_access(fname, mode)
|
---|
427 | int curlx_win32_open(const char *filename, int oflag, ...);
|
---|
428 | int curlx_win32_stat(const char *path, struct_stat *buffer);
|
---|
429 | FILE *curlx_win32_fopen(const char *filename, const char *mode);
|
---|
430 | int curlx_win32_access(const char *path, int mode);
|
---|
431 | #endif
|
---|
432 |
|
---|
433 | /*
|
---|
434 | * Small file (<2Gb) support using WIN32 functions.
|
---|
435 | */
|
---|
436 |
|
---|
437 | #ifdef USE_WIN32_SMALL_FILES
|
---|
438 | # include <io.h>
|
---|
439 | # include <sys/types.h>
|
---|
440 | # include <sys/stat.h>
|
---|
441 | # ifndef _WIN32_WCE
|
---|
442 | # undef lseek
|
---|
443 | # define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence)
|
---|
444 | # define fstat(fdes,stp) _fstat(fdes, stp)
|
---|
445 | # define stat(fname,stp) curlx_win32_stat(fname, stp)
|
---|
446 | # define struct_stat struct _stat
|
---|
447 | # define open curlx_win32_open
|
---|
448 | # define fopen(fname,mode) curlx_win32_fopen(fname, mode)
|
---|
449 | # define access(fname,mode) curlx_win32_access(fname, mode)
|
---|
450 | int curlx_win32_stat(const char *path, struct_stat *buffer);
|
---|
451 | int curlx_win32_open(const char *filename, int oflag, ...);
|
---|
452 | FILE *curlx_win32_fopen(const char *filename, const char *mode);
|
---|
453 | int curlx_win32_access(const char *path, int mode);
|
---|
454 | # endif
|
---|
455 | # define LSEEK_ERROR (long)-1
|
---|
456 | #endif
|
---|
457 |
|
---|
458 | #ifndef struct_stat
|
---|
459 | # define struct_stat struct stat
|
---|
460 | #endif
|
---|
461 |
|
---|
462 | #ifndef LSEEK_ERROR
|
---|
463 | # define LSEEK_ERROR (off_t)-1
|
---|
464 | #endif
|
---|
465 |
|
---|
466 | #ifndef SIZEOF_TIME_T
|
---|
467 | /* assume default size of time_t to be 32 bit */
|
---|
468 | #define SIZEOF_TIME_T 4
|
---|
469 | #endif
|
---|
470 |
|
---|
471 | #ifndef SIZEOF_CURL_SOCKET_T
|
---|
472 | /* configure and cmake check and set the define */
|
---|
473 | # ifdef _WIN64
|
---|
474 | # define SIZEOF_CURL_SOCKET_T 8
|
---|
475 | # else
|
---|
476 | /* default guess */
|
---|
477 | # define SIZEOF_CURL_SOCKET_T 4
|
---|
478 | # endif
|
---|
479 | #endif
|
---|
480 |
|
---|
481 | #if SIZEOF_CURL_SOCKET_T < 8
|
---|
482 | # define CURL_FORMAT_SOCKET_T "d"
|
---|
483 | #elif defined(__MINGW32__)
|
---|
484 | # define CURL_FORMAT_SOCKET_T "zd"
|
---|
485 | #else
|
---|
486 | # define CURL_FORMAT_SOCKET_T "qd"
|
---|
487 | #endif
|
---|
488 |
|
---|
489 | /*
|
---|
490 | * Default sizeof(off_t) in case it hasn't been defined in config file.
|
---|
491 | */
|
---|
492 |
|
---|
493 | #ifndef SIZEOF_OFF_T
|
---|
494 | # if defined(__VMS) && !defined(__VAX)
|
---|
495 | # if defined(_LARGEFILE)
|
---|
496 | # define SIZEOF_OFF_T 8
|
---|
497 | # endif
|
---|
498 | # elif defined(__OS400__) && defined(__ILEC400__)
|
---|
499 | # if defined(_LARGE_FILES)
|
---|
500 | # define SIZEOF_OFF_T 8
|
---|
501 | # endif
|
---|
502 | # elif defined(__MVS__) && defined(__IBMC__)
|
---|
503 | # if defined(_LP64) || defined(_LARGE_FILES)
|
---|
504 | # define SIZEOF_OFF_T 8
|
---|
505 | # endif
|
---|
506 | # elif defined(__370__) && defined(__IBMC__)
|
---|
507 | # if defined(_LP64) || defined(_LARGE_FILES)
|
---|
508 | # define SIZEOF_OFF_T 8
|
---|
509 | # endif
|
---|
510 | # endif
|
---|
511 | # ifndef SIZEOF_OFF_T
|
---|
512 | # define SIZEOF_OFF_T 4
|
---|
513 | # endif
|
---|
514 | #endif
|
---|
515 |
|
---|
516 | #if (SIZEOF_CURL_OFF_T < 8)
|
---|
517 | #error "too small curl_off_t"
|
---|
518 | #else
|
---|
519 | /* assume SIZEOF_CURL_OFF_T == 8 */
|
---|
520 | # define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
|
---|
521 | #endif
|
---|
522 | #define CURL_OFF_T_MIN (-CURL_OFF_T_MAX - CURL_OFF_T_C(1))
|
---|
523 |
|
---|
524 | #if (SIZEOF_CURL_OFF_T != 8)
|
---|
525 | # error "curl_off_t must be exactly 64 bits"
|
---|
526 | #else
|
---|
527 | typedef unsigned CURL_TYPEOF_CURL_OFF_T curl_uint64_t;
|
---|
528 | # ifndef CURL_SUFFIX_CURL_OFF_TU
|
---|
529 | # error "CURL_SUFFIX_CURL_OFF_TU must be defined"
|
---|
530 | # endif
|
---|
531 | # define CURL_UINT64_SUFFIX CURL_SUFFIX_CURL_OFF_TU
|
---|
532 | # define CURL_UINT64_C(val) CURL_CONC_MACROS(val,CURL_UINT64_SUFFIX)
|
---|
533 | #endif
|
---|
534 |
|
---|
535 | #if (SIZEOF_TIME_T == 4)
|
---|
536 | # ifdef HAVE_TIME_T_UNSIGNED
|
---|
537 | # define TIME_T_MAX UINT_MAX
|
---|
538 | # define TIME_T_MIN 0
|
---|
539 | # else
|
---|
540 | # define TIME_T_MAX INT_MAX
|
---|
541 | # define TIME_T_MIN INT_MIN
|
---|
542 | # endif
|
---|
543 | #else
|
---|
544 | # ifdef HAVE_TIME_T_UNSIGNED
|
---|
545 | # define TIME_T_MAX 0xFFFFFFFFFFFFFFFF
|
---|
546 | # define TIME_T_MIN 0
|
---|
547 | # else
|
---|
548 | # define TIME_T_MAX 0x7FFFFFFFFFFFFFFF
|
---|
549 | # define TIME_T_MIN (-TIME_T_MAX - 1)
|
---|
550 | # endif
|
---|
551 | #endif
|
---|
552 |
|
---|
553 | #ifndef SIZE_T_MAX
|
---|
554 | /* some limits.h headers have this defined, some don't */
|
---|
555 | #if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
|
---|
556 | #define SIZE_T_MAX 18446744073709551615U
|
---|
557 | #else
|
---|
558 | #define SIZE_T_MAX 4294967295U
|
---|
559 | #endif
|
---|
560 | #endif
|
---|
561 |
|
---|
562 | #ifndef SSIZE_T_MAX
|
---|
563 | /* some limits.h headers have this defined, some don't */
|
---|
564 | #if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
|
---|
565 | #define SSIZE_T_MAX 9223372036854775807
|
---|
566 | #else
|
---|
567 | #define SSIZE_T_MAX 2147483647
|
---|
568 | #endif
|
---|
569 | #endif
|
---|
570 |
|
---|
571 | /*
|
---|
572 | * Arg 2 type for gethostname in case it hasn't been defined in config file.
|
---|
573 | */
|
---|
574 |
|
---|
575 | #ifndef GETHOSTNAME_TYPE_ARG2
|
---|
576 | # ifdef USE_WINSOCK
|
---|
577 | # define GETHOSTNAME_TYPE_ARG2 int
|
---|
578 | # else
|
---|
579 | # define GETHOSTNAME_TYPE_ARG2 size_t
|
---|
580 | # endif
|
---|
581 | #endif
|
---|
582 |
|
---|
583 | /* Below we define some functions. They should
|
---|
584 |
|
---|
585 | 4. set the SIGALRM signal timeout
|
---|
586 | 5. set dir/file naming defines
|
---|
587 | */
|
---|
588 |
|
---|
589 | #ifdef _WIN32
|
---|
590 |
|
---|
591 | # define DIR_CHAR "\\"
|
---|
592 |
|
---|
593 | #else /* _WIN32 */
|
---|
594 |
|
---|
595 | # ifdef MSDOS /* Watt-32 */
|
---|
596 |
|
---|
597 | # include <sys/ioctl.h>
|
---|
598 | # define select(n,r,w,x,t) select_s(n,r,w,x,t)
|
---|
599 | # define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
|
---|
600 | # include <tcp.h>
|
---|
601 | # ifdef word
|
---|
602 | # undef word
|
---|
603 | # endif
|
---|
604 | # ifdef byte
|
---|
605 | # undef byte
|
---|
606 | # endif
|
---|
607 |
|
---|
608 | # endif /* MSDOS */
|
---|
609 |
|
---|
610 | # ifdef __minix
|
---|
611 | /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
|
---|
612 | extern char *strtok_r(char *s, const char *delim, char **last);
|
---|
613 | extern struct tm *gmtime_r(const time_t * const timep, struct tm *tmp);
|
---|
614 | # endif
|
---|
615 |
|
---|
616 | # define DIR_CHAR "/"
|
---|
617 |
|
---|
618 | #endif /* _WIN32 */
|
---|
619 |
|
---|
620 | /* ---------------------------------------------------------------- */
|
---|
621 | /* resolver specialty compile-time defines */
|
---|
622 | /* CURLRES_* defines to use in the host*.c sources */
|
---|
623 | /* ---------------------------------------------------------------- */
|
---|
624 |
|
---|
625 | /*
|
---|
626 | * MSVC threads support requires a multi-threaded runtime library.
|
---|
627 | * _beginthreadex() is not available in single-threaded ones.
|
---|
628 | */
|
---|
629 |
|
---|
630 | #if defined(_MSC_VER) && !defined(_MT)
|
---|
631 | # undef USE_THREADS_POSIX
|
---|
632 | # undef USE_THREADS_WIN32
|
---|
633 | #endif
|
---|
634 |
|
---|
635 | /*
|
---|
636 | * Mutually exclusive CURLRES_* definitions.
|
---|
637 | */
|
---|
638 |
|
---|
639 | #if defined(ENABLE_IPV6) && defined(HAVE_GETADDRINFO)
|
---|
640 | # define CURLRES_IPV6
|
---|
641 | #elif defined(ENABLE_IPV6) && (defined(_WIN32) || defined(__CYGWIN__))
|
---|
642 | /* assume on Windows that IPv6 without getaddrinfo is a broken build */
|
---|
643 | # error "Unexpected build: IPv6 is enabled but getaddrinfo was not found."
|
---|
644 | #else
|
---|
645 | # define CURLRES_IPV4
|
---|
646 | #endif
|
---|
647 |
|
---|
648 | #ifdef USE_ARES
|
---|
649 | # define CURLRES_ASYNCH
|
---|
650 | # define CURLRES_ARES
|
---|
651 | /* now undef the stock libc functions just to avoid them being used */
|
---|
652 | # undef HAVE_GETADDRINFO
|
---|
653 | # undef HAVE_FREEADDRINFO
|
---|
654 | #elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
|
---|
655 | # define CURLRES_ASYNCH
|
---|
656 | # define CURLRES_THREADED
|
---|
657 | #else
|
---|
658 | # define CURLRES_SYNCH
|
---|
659 | #endif
|
---|
660 |
|
---|
661 | /* ---------------------------------------------------------------- */
|
---|
662 |
|
---|
663 | #if defined(HAVE_LIBIDN2) && defined(HAVE_IDN2_H) && !defined(USE_WIN32_IDN)
|
---|
664 | /* The lib and header are present */
|
---|
665 | #define USE_LIBIDN2
|
---|
666 | #endif
|
---|
667 |
|
---|
668 | #if defined(USE_LIBIDN2) && defined(USE_WIN32_IDN)
|
---|
669 | #error "Both libidn2 and WinIDN are enabled, choose one."
|
---|
670 | #endif
|
---|
671 |
|
---|
672 | #define LIBIDN_REQUIRED_VERSION "0.4.1"
|
---|
673 |
|
---|
674 | #if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_MBEDTLS) || \
|
---|
675 | defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || defined(USE_SECTRANSP) || \
|
---|
676 | defined(USE_BEARSSL) || defined(USE_RUSTLS)
|
---|
677 | #define USE_SSL /* SSL support has been enabled */
|
---|
678 | #endif
|
---|
679 |
|
---|
680 | /* Single point where USE_SPNEGO definition might be defined */
|
---|
681 | #if !defined(CURL_DISABLE_NEGOTIATE_AUTH) && \
|
---|
682 | (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI))
|
---|
683 | #define USE_SPNEGO
|
---|
684 | #endif
|
---|
685 |
|
---|
686 | /* Single point where USE_KERBEROS5 definition might be defined */
|
---|
687 | #if !defined(CURL_DISABLE_KERBEROS_AUTH) && \
|
---|
688 | (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI))
|
---|
689 | #define USE_KERBEROS5
|
---|
690 | #endif
|
---|
691 |
|
---|
692 | /* Single point where USE_NTLM definition might be defined */
|
---|
693 | #if !defined(CURL_DISABLE_NTLM)
|
---|
694 | # if defined(USE_OPENSSL) || defined(USE_MBEDTLS) || \
|
---|
695 | defined(USE_GNUTLS) || defined(USE_SECTRANSP) || \
|
---|
696 | defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \
|
---|
697 | (defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT))
|
---|
698 | # define USE_CURL_NTLM_CORE
|
---|
699 | # endif
|
---|
700 | # if defined(USE_CURL_NTLM_CORE) || defined(USE_WINDOWS_SSPI)
|
---|
701 | # define USE_NTLM
|
---|
702 | # endif
|
---|
703 | #endif
|
---|
704 |
|
---|
705 | #ifdef CURL_WANTS_CA_BUNDLE_ENV
|
---|
706 | #error "No longer supported. Set CURLOPT_CAINFO at runtime instead."
|
---|
707 | #endif
|
---|
708 |
|
---|
709 | #if defined(USE_LIBSSH2) || defined(USE_LIBSSH) || defined(USE_WOLFSSH)
|
---|
710 | #define USE_SSH
|
---|
711 | #endif
|
---|
712 |
|
---|
713 | /*
|
---|
714 | * Provide a mechanism to silence picky compilers, such as gcc 4.6+.
|
---|
715 | * Parameters should of course normally not be unused, but for example when
|
---|
716 | * we have multiple implementations of the same interface it may happen.
|
---|
717 | */
|
---|
718 |
|
---|
719 | #if defined(__GNUC__) && ((__GNUC__ >= 3) || \
|
---|
720 | ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7)))
|
---|
721 | # define UNUSED_PARAM __attribute__((__unused__))
|
---|
722 | # define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
---|
723 | #else
|
---|
724 | # define UNUSED_PARAM /* NOTHING */
|
---|
725 | # define WARN_UNUSED_RESULT
|
---|
726 | #endif
|
---|
727 |
|
---|
728 | /* noreturn attribute */
|
---|
729 |
|
---|
730 | #if !defined(CURL_NORETURN)
|
---|
731 | #if (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__clang__)
|
---|
732 | # define CURL_NORETURN __attribute__((__noreturn__))
|
---|
733 | #elif defined(_MSC_VER) && (_MSC_VER >= 1200)
|
---|
734 | # define CURL_NORETURN __declspec(noreturn)
|
---|
735 | #else
|
---|
736 | # define CURL_NORETURN
|
---|
737 | #endif
|
---|
738 | #endif
|
---|
739 |
|
---|
740 | /* fallthrough attribute */
|
---|
741 |
|
---|
742 | #if !defined(FALLTHROUGH)
|
---|
743 | #if (defined(__GNUC__) && __GNUC__ >= 7) || \
|
---|
744 | (defined(__clang__) && __clang_major__ >= 10)
|
---|
745 | # define FALLTHROUGH() __attribute__((fallthrough))
|
---|
746 | #else
|
---|
747 | # define FALLTHROUGH() do {} while (0)
|
---|
748 | #endif
|
---|
749 | #endif
|
---|
750 |
|
---|
751 | /*
|
---|
752 | * Include macros and defines that should only be processed once.
|
---|
753 | */
|
---|
754 |
|
---|
755 | #ifndef HEADER_CURL_SETUP_ONCE_H
|
---|
756 | #include "curl_setup_once.h"
|
---|
757 | #endif
|
---|
758 |
|
---|
759 | /*
|
---|
760 | * Definition of our NOP statement Object-like macro
|
---|
761 | */
|
---|
762 |
|
---|
763 | #ifndef Curl_nop_stmt
|
---|
764 | # define Curl_nop_stmt do { } while(0)
|
---|
765 | #endif
|
---|
766 |
|
---|
767 | /*
|
---|
768 | * Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
|
---|
769 | */
|
---|
770 |
|
---|
771 | #if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H)
|
---|
772 | # if defined(SOCKET) || defined(USE_WINSOCK)
|
---|
773 | # error "WinSock and lwIP TCP/IP stack definitions shall not coexist!"
|
---|
774 | # endif
|
---|
775 | #endif
|
---|
776 |
|
---|
777 | /*
|
---|
778 | * shutdown() flags for systems that don't define them
|
---|
779 | */
|
---|
780 |
|
---|
781 | #ifndef SHUT_RD
|
---|
782 | #define SHUT_RD 0x00
|
---|
783 | #endif
|
---|
784 |
|
---|
785 | #ifndef SHUT_WR
|
---|
786 | #define SHUT_WR 0x01
|
---|
787 | #endif
|
---|
788 |
|
---|
789 | #ifndef SHUT_RDWR
|
---|
790 | #define SHUT_RDWR 0x02
|
---|
791 | #endif
|
---|
792 |
|
---|
793 | /* Define S_ISREG if not defined by system headers, e.g. MSVC */
|
---|
794 | #if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
|
---|
795 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
---|
796 | #endif
|
---|
797 |
|
---|
798 | /* Define S_ISDIR if not defined by system headers, e.g. MSVC */
|
---|
799 | #if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
|
---|
800 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
---|
801 | #endif
|
---|
802 |
|
---|
803 | /* In Windows the default file mode is text but an application can override it.
|
---|
804 | Therefore we specify it explicitly. https://github.com/curl/curl/pull/258
|
---|
805 | */
|
---|
806 | #if defined(_WIN32) || defined(MSDOS)
|
---|
807 | #define FOPEN_READTEXT "rt"
|
---|
808 | #define FOPEN_WRITETEXT "wt"
|
---|
809 | #define FOPEN_APPENDTEXT "at"
|
---|
810 | #elif defined(__CYGWIN__)
|
---|
811 | /* Cygwin has specific behavior we need to address when WIN32 is not defined.
|
---|
812 | https://cygwin.com/cygwin-ug-net/using-textbinary.html
|
---|
813 | For write we want our output to have line endings of LF and be compatible with
|
---|
814 | other Cygwin utilities. For read we want to handle input that may have line
|
---|
815 | endings either CRLF or LF so 't' is appropriate.
|
---|
816 | */
|
---|
817 | #define FOPEN_READTEXT "rt"
|
---|
818 | #define FOPEN_WRITETEXT "w"
|
---|
819 | #define FOPEN_APPENDTEXT "a"
|
---|
820 | #else
|
---|
821 | #define FOPEN_READTEXT "r"
|
---|
822 | #define FOPEN_WRITETEXT "w"
|
---|
823 | #define FOPEN_APPENDTEXT "a"
|
---|
824 | #endif
|
---|
825 |
|
---|
826 | /* for systems that don't detect this in configure */
|
---|
827 | #ifndef CURL_SA_FAMILY_T
|
---|
828 | # if defined(HAVE_SA_FAMILY_T)
|
---|
829 | # define CURL_SA_FAMILY_T sa_family_t
|
---|
830 | # elif defined(HAVE_ADDRESS_FAMILY)
|
---|
831 | # define CURL_SA_FAMILY_T ADDRESS_FAMILY
|
---|
832 | # else
|
---|
833 | /* use a sensible default */
|
---|
834 | # define CURL_SA_FAMILY_T unsigned short
|
---|
835 | # endif
|
---|
836 | #endif
|
---|
837 |
|
---|
838 | /* Some convenience macros to get the larger/smaller value out of two given.
|
---|
839 | We prefix with CURL to prevent name collisions. */
|
---|
840 | #define CURLMAX(x,y) ((x)>(y)?(x):(y))
|
---|
841 | #define CURLMIN(x,y) ((x)<(y)?(x):(y))
|
---|
842 |
|
---|
843 | /* A convenience macro to provide both the string literal and the length of
|
---|
844 | the string literal in one go, useful for functions that take "string,len"
|
---|
845 | as their argument */
|
---|
846 | #define STRCONST(x) x,sizeof(x)-1
|
---|
847 |
|
---|
848 | /* Some versions of the Android SDK is missing the declaration */
|
---|
849 | #if defined(HAVE_GETPWUID_R) && defined(HAVE_DECL_GETPWUID_R_MISSING)
|
---|
850 | struct passwd;
|
---|
851 | int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
|
---|
852 | size_t buflen, struct passwd **result);
|
---|
853 | #endif
|
---|
854 |
|
---|
855 | #ifdef DEBUGBUILD
|
---|
856 | #define UNITTEST
|
---|
857 | #else
|
---|
858 | #define UNITTEST static
|
---|
859 | #endif
|
---|
860 |
|
---|
861 | /* Hyper supports HTTP2 also, but Curl's integration with Hyper does not */
|
---|
862 | #if defined(USE_NGHTTP2)
|
---|
863 | #define USE_HTTP2
|
---|
864 | #endif
|
---|
865 |
|
---|
866 | #if (defined(USE_NGTCP2) && defined(USE_NGHTTP3)) || \
|
---|
867 | (defined(USE_OPENSSL_QUIC) && defined(USE_NGHTTP3)) || \
|
---|
868 | defined(USE_QUICHE) || defined(USE_MSH3)
|
---|
869 |
|
---|
870 | #ifdef CURL_WITH_MULTI_SSL
|
---|
871 | #error "Multi-SSL combined with QUIC is not supported"
|
---|
872 | #endif
|
---|
873 |
|
---|
874 | #define ENABLE_QUIC
|
---|
875 | #define USE_HTTP3
|
---|
876 | #endif
|
---|
877 |
|
---|
878 | /* Certain Windows implementations are not aligned with what curl expects,
|
---|
879 | so always use the local one on this platform. E.g. the mingw-w64
|
---|
880 | implementation can return wrong results for non-ASCII inputs. */
|
---|
881 | #if defined(HAVE_BASENAME) && defined(_WIN32)
|
---|
882 | #undef HAVE_BASENAME
|
---|
883 | #endif
|
---|
884 |
|
---|
885 | #if defined(USE_UNIX_SOCKETS) && defined(_WIN32)
|
---|
886 | # if !defined(UNIX_PATH_MAX)
|
---|
887 | /* Replicating logic present in afunix.h
|
---|
888 | (distributed with newer Windows 10 SDK versions only) */
|
---|
889 | # define UNIX_PATH_MAX 108
|
---|
890 | /* !checksrc! disable TYPEDEFSTRUCT 1 */
|
---|
891 | typedef struct sockaddr_un {
|
---|
892 | ADDRESS_FAMILY sun_family;
|
---|
893 | char sun_path[UNIX_PATH_MAX];
|
---|
894 | } SOCKADDR_UN, *PSOCKADDR_UN;
|
---|
895 | # define WIN32_SOCKADDR_UN
|
---|
896 | # endif
|
---|
897 | #endif
|
---|
898 |
|
---|
899 | /* OpenSSLv3 marks DES, MD5 and ENGINE functions deprecated but we have no
|
---|
900 | replacements (yet) so tell the compiler to not warn for them. */
|
---|
901 | #ifdef USE_OPENSSL
|
---|
902 | #define OPENSSL_SUPPRESS_DEPRECATED
|
---|
903 | #endif
|
---|
904 |
|
---|
905 | #endif /* HEADER_CURL_SETUP_H */
|
---|