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