VirtualBox

source: vbox/trunk/src/libs/curl-8.11.1/lib/curl_setup.h@ 108333

最後變更 在這個檔案從108333是 108048,由 vboxsync 提交於 7 週 前

curl-8.11.1: Applied and adjusted our curl changes to 8.7.1. jiraref:VBP-1535

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette