• 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) 1998 - 2021, 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  ***************************************************************************/
24 
25 #if defined(BUILDING_LIBCURL) && !defined(CURL_NO_OLDIES)
26 #define CURL_NO_OLDIES
27 #endif
28 
29 /*
30  * Disable Visual Studio warnings:
31  * 4127 "conditional expression is constant"
32  */
33 #ifdef _MSC_VER
34 #pragma warning(disable:4127)
35 #endif
36 
37 /*
38  * Define WIN32 when build target is Win32 API
39  */
40 
41 #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
42 #define WIN32
43 #endif
44 
45 #ifdef WIN32
46 /*
47  * Don't include unneeded stuff in Windows headers to avoid compiler
48  * warnings and macro clashes.
49  * Make sure to define this macro before including any Windows headers.
50  */
51 #  ifndef WIN32_LEAN_AND_MEAN
52 #    define WIN32_LEAN_AND_MEAN
53 #  endif
54 #  ifndef NOGDI
55 #    define NOGDI
56 #  endif
57 /* Detect Windows App environment which has a restricted access
58  * to the Win32 APIs. */
59 # if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \
60   defined(WINAPI_FAMILY)
61 #  include <winapifamily.h>
62 #  if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) &&  \
63      !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
64 #    define CURL_WINDOWS_APP
65 #  endif
66 # endif
67 #endif
68 
69 /*
70  * Include configuration script results or hand-crafted
71  * configuration file for platforms which lack config tool.
72  */
73 
74 #ifdef HAVE_CONFIG_H
75 
76 #include "curl_config.h"
77 
78 #else /* HAVE_CONFIG_H */
79 
80 #ifdef _WIN32_WCE
81 #  include "config-win32ce.h"
82 #else
83 #  ifdef WIN32
84 #    include "config-win32.h"
85 #  endif
86 #endif
87 
88 #if defined(macintosh) && defined(__MRC__)
89 #  include "config-mac.h"
90 #endif
91 
92 #ifdef __riscos__
93 #  include "config-riscos.h"
94 #endif
95 
96 #ifdef __AMIGA__
97 #  include "config-amigaos.h"
98 #endif
99 
100 #ifdef __OS400__
101 #  include "config-os400.h"
102 #endif
103 
104 #ifdef TPF
105 #  include "config-tpf.h"
106 #endif
107 
108 #ifdef __VXWORKS__
109 #  include "config-vxworks.h"
110 #endif
111 
112 #ifdef __PLAN9__
113 #  include "config-plan9.h"
114 #endif
115 
116 #endif /* HAVE_CONFIG_H */
117 
118 /* ================================================================ */
119 /* Definition of preprocessor macros/symbols which modify compiler  */
120 /* behavior or generated code characteristics must be done here,   */
121 /* as appropriate, before any system header file is included. It is */
122 /* also possible to have them defined in the config file included   */
123 /* before this point. As a result of all this we frown inclusion of */
124 /* system header files in our config files, avoid this at any cost. */
125 /* ================================================================ */
126 
127 /*
128  * AIX 4.3 and newer needs _THREAD_SAFE defined to build
129  * proper reentrant code. Others may also need it.
130  */
131 
132 #ifdef NEED_THREAD_SAFE
133 #  ifndef _THREAD_SAFE
134 #    define _THREAD_SAFE
135 #  endif
136 #endif
137 
138 /*
139  * Tru64 needs _REENTRANT set for a few function prototypes and
140  * things to appear in the system header files. Unixware needs it
141  * to build proper reentrant code. Others may also need it.
142  */
143 
144 #ifdef NEED_REENTRANT
145 #  ifndef _REENTRANT
146 #    define _REENTRANT
147 #  endif
148 #endif
149 
150 /* Solaris needs this to get a POSIX-conformant getpwuid_r */
151 #if defined(sun) || defined(__sun)
152 #  ifndef _POSIX_PTHREAD_SEMANTICS
153 #    define _POSIX_PTHREAD_SEMANTICS 1
154 #  endif
155 #endif
156 
157 /* ================================================================ */
158 /*  If you need to include a system header file for your platform,  */
159 /*  please, do it beyond the point further indicated in this file.  */
160 /* ================================================================ */
161 
162 #include <curl/curl.h>
163 
164 /*
165  * Disable other protocols when http is the only one desired.
166  */
167 
168 #ifdef HTTP_ONLY
169 #  ifndef CURL_DISABLE_TFTP
170 #    define CURL_DISABLE_TFTP
171 #  endif
172 #  ifndef CURL_DISABLE_FTP
173 #    define CURL_DISABLE_FTP
174 #  endif
175 #  ifndef CURL_DISABLE_LDAP
176 #    define CURL_DISABLE_LDAP
177 #  endif
178 #  ifndef CURL_DISABLE_TELNET
179 #    define CURL_DISABLE_TELNET
180 #  endif
181 #  ifndef CURL_DISABLE_DICT
182 #    define CURL_DISABLE_DICT
183 #  endif
184 #  ifndef CURL_DISABLE_FILE
185 #    define CURL_DISABLE_FILE
186 #  endif
187 #  ifndef CURL_DISABLE_RTSP
188 #    define CURL_DISABLE_RTSP
189 #  endif
190 #  ifndef CURL_DISABLE_POP3
191 #    define CURL_DISABLE_POP3
192 #  endif
193 #  ifndef CURL_DISABLE_IMAP
194 #    define CURL_DISABLE_IMAP
195 #  endif
196 #  ifndef CURL_DISABLE_SMTP
197 #    define CURL_DISABLE_SMTP
198 #  endif
199 #  ifndef CURL_DISABLE_GOPHER
200 #    define CURL_DISABLE_GOPHER
201 #  endif
202 #  ifndef CURL_DISABLE_SMB
203 #    define CURL_DISABLE_SMB
204 #  endif
205 #endif
206 
207 /*
208  * When http is disabled rtsp is not supported.
209  */
210 
211 #if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP)
212 #  define CURL_DISABLE_RTSP
213 #endif
214 
215 /* ================================================================ */
216 /* No system header file shall be included in this file before this */
217 /* point. The only allowed ones are those included from curl/system.h */
218 /* ================================================================ */
219 
220 /*
221  * OS/400 setup file includes some system headers.
222  */
223 
224 #ifdef __OS400__
225 #  include "setup-os400.h"
226 #endif
227 
228 /*
229  * VMS setup file includes some system headers.
230  */
231 
232 #ifdef __VMS
233 #  include "setup-vms.h"
234 #endif
235 
236 /*
237  * Windows setup file includes some system headers.
238  */
239 
240 #ifdef HAVE_WINDOWS_H
241 #  include "setup-win32.h"
242 #endif
243 
244 /*
245  * Use getaddrinfo to resolve the IPv4 address literal. If the current network
246  * interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64,
247  * performing this task will result in a synthesized IPv6 address.
248  */
249 #if defined(__APPLE__) && !defined(USE_ARES)
250 #include <TargetConditionals.h>
251 #define USE_RESOLVE_ON_IPS 1
252 #  if defined(TARGET_OS_OSX) && TARGET_OS_OSX
253 #    define CURL_OSX_CALL_COPYPROXIES 1
254 #  endif
255 #endif
256 
257 #ifdef USE_LWIPSOCK
258 #  include <lwip/init.h>
259 #  include <lwip/sockets.h>
260 #  include <lwip/netdb.h>
261 #endif
262 
263 #ifdef HAVE_EXTRA_STRICMP_H
264 #  include <extra/stricmp.h>
265 #endif
266 
267 #ifdef HAVE_EXTRA_STRDUP_H
268 #  include <extra/strdup.h>
269 #endif
270 
271 #ifdef TPF
272 #  include <strings.h>    /* for bzero, strcasecmp, and strncasecmp */
273 #  include <string.h>     /* for strcpy and strlen */
274 #  include <stdlib.h>     /* for rand and srand */
275 #  include <sys/socket.h> /* for select and ioctl*/
276 #  include <netdb.h>      /* for in_addr_t definition */
277 #  include <tpf/sysapi.h> /* for tpf_process_signals */
278    /* change which select is used for libcurl */
279 #  define select(a,b,c,d,e) tpf_select_libcurl(a,b,c,d,e)
280 #endif
281 
282 #ifdef __VXWORKS__
283 #  include <sockLib.h>    /* for generic BSD socket functions */
284 #  include <ioLib.h>      /* for basic I/O interface functions */
285 #endif
286 
287 #ifdef __AMIGA__
288 #  include <exec/types.h>
289 #  include <exec/execbase.h>
290 #  include <proto/exec.h>
291 #  include <proto/dos.h>
292 #  include <unistd.h>
293 #  ifdef HAVE_PROTO_BSDSOCKET_H
294 #    include <proto/bsdsocket.h> /* ensure bsdsocket.library use */
295 #    define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
296 #  endif
297 /*
298  * In clib2 arpa/inet.h warns that some prototypes may clash
299  * with bsdsocket.library. This avoids the definition of those.
300  */
301 #  define __NO_NET_API
302 #endif
303 
304 #include <stdio.h>
305 #ifdef HAVE_ASSERT_H
306 #include <assert.h>
307 #endif
308 
309 #ifdef __TANDEM /* for nsr-tandem-nsk systems */
310 #include <floss.h>
311 #endif
312 
313 #ifndef STDC_HEADERS /* no standard C headers! */
314 #include <curl/stdcheaders.h>
315 #endif
316 
317 #ifdef __POCC__
318 #  include <sys/types.h>
319 #  include <unistd.h>
320 #  define sys_nerr EILSEQ
321 #endif
322 
323 /*
324  * Salford-C kludge section (mostly borrowed from wxWidgets).
325  */
326 #ifdef __SALFORDC__
327   #pragma suppress 353             /* Possible nested comments */
328   #pragma suppress 593             /* Define not used */
329   #pragma suppress 61              /* enum has no name */
330   #pragma suppress 106             /* unnamed, unused parameter */
331   #include <clib.h>
332 #endif
333 
334 /*
335  * Large file (>2Gb) support using WIN32 functions.
336  */
337 
338 #ifdef USE_WIN32_LARGE_FILES
339 #  include <io.h>
340 #  include <sys/types.h>
341 #  include <sys/stat.h>
342 #  undef  lseek
343 #  define lseek(fdes,offset,whence)  _lseeki64(fdes, offset, whence)
344 #  undef  fstat
345 #  define fstat(fdes,stp)            _fstati64(fdes, stp)
346 #  undef  stat
347 #  define stat(fname,stp)            curlx_win32_stat(fname, stp)
348 #  define struct_stat                struct _stati64
349 #  define LSEEK_ERROR                (__int64)-1
350 #  define open                       curlx_win32_open
351 #  define fopen(fname,mode)          curlx_win32_fopen(fname, mode)
352 #  define access(fname,mode)         curlx_win32_access(fname, mode)
353    int curlx_win32_open(const char *filename, int oflag, ...);
354    int curlx_win32_stat(const char *path, struct_stat *buffer);
355    FILE *curlx_win32_fopen(const char *filename, const char *mode);
356    int curlx_win32_access(const char *path, int mode);
357 #endif
358 
359 /*
360  * Small file (<2Gb) support using WIN32 functions.
361  */
362 
363 #ifdef USE_WIN32_SMALL_FILES
364 #  include <io.h>
365 #  include <sys/types.h>
366 #  include <sys/stat.h>
367 #  ifndef _WIN32_WCE
368 #    undef  lseek
369 #    define lseek(fdes,offset,whence)  _lseek(fdes, (long)offset, whence)
370 #    define fstat(fdes,stp)            _fstat(fdes, stp)
371 #    define stat(fname,stp)            curlx_win32_stat(fname, stp)
372 #    define struct_stat                struct _stat
373 #    define open                       curlx_win32_open
374 #    define fopen(fname,mode)          curlx_win32_fopen(fname, mode)
375 #    define access(fname,mode)         curlx_win32_access(fname, mode)
376      int curlx_win32_stat(const char *path, struct_stat *buffer);
377      int curlx_win32_open(const char *filename, int oflag, ...);
378      FILE *curlx_win32_fopen(const char *filename, const char *mode);
379      int curlx_win32_access(const char *path, int mode);
380 #  endif
381 #  define LSEEK_ERROR                (long)-1
382 #endif
383 
384 #ifndef struct_stat
385 #  define struct_stat struct stat
386 #endif
387 
388 #ifndef LSEEK_ERROR
389 #  define LSEEK_ERROR (off_t)-1
390 #endif
391 
392 #ifndef SIZEOF_TIME_T
393 /* assume default size of time_t to be 32 bit */
394 #define SIZEOF_TIME_T 4
395 #endif
396 
397 /*
398  * Default sizeof(off_t) in case it hasn't been defined in config file.
399  */
400 
401 #ifndef SIZEOF_OFF_T
402 #  if defined(__VMS) && !defined(__VAX)
403 #    if defined(_LARGEFILE)
404 #      define SIZEOF_OFF_T 8
405 #    endif
406 #  elif defined(__OS400__) && defined(__ILEC400__)
407 #    if defined(_LARGE_FILES)
408 #      define SIZEOF_OFF_T 8
409 #    endif
410 #  elif defined(__MVS__) && defined(__IBMC__)
411 #    if defined(_LP64) || defined(_LARGE_FILES)
412 #      define SIZEOF_OFF_T 8
413 #    endif
414 #  elif defined(__370__) && defined(__IBMC__)
415 #    if defined(_LP64) || defined(_LARGE_FILES)
416 #      define SIZEOF_OFF_T 8
417 #    endif
418 #  endif
419 #  ifndef SIZEOF_OFF_T
420 #    define SIZEOF_OFF_T 4
421 #  endif
422 #endif
423 
424 #if (SIZEOF_CURL_OFF_T == 4)
425 #  define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFF)
426 #else
427    /* assume SIZEOF_CURL_OFF_T == 8 */
428 #  define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
429 #endif
430 #define CURL_OFF_T_MIN (-CURL_OFF_T_MAX - CURL_OFF_T_C(1))
431 
432 #if (SIZEOF_TIME_T == 4)
433 #  ifdef HAVE_TIME_T_UNSIGNED
434 #  define TIME_T_MAX UINT_MAX
435 #  define TIME_T_MIN 0
436 #  else
437 #  define TIME_T_MAX INT_MAX
438 #  define TIME_T_MIN INT_MIN
439 #  endif
440 #else
441 #  ifdef HAVE_TIME_T_UNSIGNED
442 #  define TIME_T_MAX 0xFFFFFFFFFFFFFFFF
443 #  define TIME_T_MIN 0
444 #  else
445 #  define TIME_T_MAX 0x7FFFFFFFFFFFFFFF
446 #  define TIME_T_MIN (-TIME_T_MAX - 1)
447 #  endif
448 #endif
449 
450 #ifndef SIZE_T_MAX
451 /* some limits.h headers have this defined, some don't */
452 #if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
453 #define SIZE_T_MAX 18446744073709551615U
454 #else
455 #define SIZE_T_MAX 4294967295U
456 #endif
457 #endif
458 
459 #ifndef SSIZE_T_MAX
460 /* some limits.h headers have this defined, some don't */
461 #if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
462 #define SSIZE_T_MAX 9223372036854775807
463 #else
464 #define SSIZE_T_MAX 2147483647
465 #endif
466 #endif
467 
468 /*
469  * Arg 2 type for gethostname in case it hasn't been defined in config file.
470  */
471 
472 #ifndef GETHOSTNAME_TYPE_ARG2
473 #  ifdef USE_WINSOCK
474 #    define GETHOSTNAME_TYPE_ARG2 int
475 #  else
476 #    define GETHOSTNAME_TYPE_ARG2 size_t
477 #  endif
478 #endif
479 
480 /* Below we define some functions. They should
481 
482    4. set the SIGALRM signal timeout
483    5. set dir/file naming defines
484    */
485 
486 #ifdef WIN32
487 
488 #  define DIR_CHAR      "\\"
489 
490 #else /* WIN32 */
491 
492 #  ifdef MSDOS  /* Watt-32 */
493 
494 #    include <sys/ioctl.h>
495 #    define select(n,r,w,x,t) select_s(n,r,w,x,t)
496 #    define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
497 #    include <tcp.h>
498 #    ifdef word
499 #      undef word
500 #    endif
501 #    ifdef byte
502 #      undef byte
503 #    endif
504 
505 #  endif /* MSDOS */
506 
507 #  ifdef __minix
508      /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
509      extern char *strtok_r(char *s, const char *delim, char **last);
510      extern struct tm *gmtime_r(const time_t * const timep, struct tm *tmp);
511 #  endif
512 
513 #  define DIR_CHAR      "/"
514 
515 #  ifndef fileno /* sunos 4 have this as a macro! */
516      int fileno(FILE *stream);
517 #  endif
518 
519 #endif /* WIN32 */
520 
521 /*
522  * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
523  * defined in ws2tcpip.h as well as to provide IPv6 support.
524  * Does not apply if lwIP is used.
525  */
526 
527 #if defined(_MSC_VER) && !defined(__POCC__) && !defined(USE_LWIPSOCK)
528 #  if !defined(HAVE_WS2TCPIP_H) || \
529      ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN))
530 #    undef HAVE_GETADDRINFO_THREADSAFE
531 #    undef HAVE_FREEADDRINFO
532 #    undef HAVE_GETADDRINFO
533 #    undef ENABLE_IPV6
534 #  endif
535 #endif
536 
537 /* ---------------------------------------------------------------- */
538 /*             resolver specialty compile-time defines              */
539 /*         CURLRES_* defines to use in the host*.c sources          */
540 /* ---------------------------------------------------------------- */
541 
542 /*
543  * lcc-win32 doesn't have _beginthreadex(), lacks threads support.
544  */
545 
546 #if defined(__LCC__) && defined(WIN32)
547 #  undef USE_THREADS_POSIX
548 #  undef USE_THREADS_WIN32
549 #endif
550 
551 /*
552  * MSVC threads support requires a multi-threaded runtime library.
553  * _beginthreadex() is not available in single-threaded ones.
554  */
555 
556 #if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT)
557 #  undef USE_THREADS_POSIX
558 #  undef USE_THREADS_WIN32
559 #endif
560 
561 /*
562  * Mutually exclusive CURLRES_* definitions.
563  */
564 
565 #if defined(ENABLE_IPV6) && defined(HAVE_GETADDRINFO)
566 #  define CURLRES_IPV6
567 #else
568 #  define CURLRES_IPV4
569 #endif
570 
571 #ifdef USE_ARES
572 #  define CURLRES_ASYNCH
573 #  define CURLRES_ARES
574 /* now undef the stock libc functions just to avoid them being used */
575 #  undef HAVE_GETADDRINFO
576 #  undef HAVE_FREEADDRINFO
577 #  undef HAVE_GETHOSTBYNAME
578 #elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
579 #  define CURLRES_ASYNCH
580 #  define CURLRES_THREADED
581 #else
582 #  define CURLRES_SYNCH
583 #endif
584 
585 /* ---------------------------------------------------------------- */
586 
587 /*
588  * msvc 6.0 does not have struct sockaddr_storage and
589  * does not define IPPROTO_ESP in winsock2.h. But both
590  * are available if PSDK is properly installed.
591  */
592 
593 #if defined(_MSC_VER) && !defined(__POCC__)
594 #  if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP))
595 #    undef HAVE_STRUCT_SOCKADDR_STORAGE
596 #  endif
597 #endif
598 
599 /*
600  * Intentionally fail to build when using msvc 6.0 without PSDK installed.
601  * The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK
602  * in lib/config-win32.h although absolutely discouraged and unsupported.
603  */
604 
605 #if defined(_MSC_VER) && !defined(__POCC__)
606 #  if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_))
607 #    if !defined(ALLOW_MSVC6_WITHOUT_PSDK)
608 #      error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. \
609              "Windows Server 2003 PSDK"
610 #    else
611 #      define CURL_DISABLE_LDAP 1
612 #    endif
613 #  endif
614 #endif
615 
616 #ifdef NETWARE
617 int netware_init(void);
618 #ifndef __NOVELL_LIBC__
619 #include <sys/bsdskt.h>
620 #include <sys/timeval.h>
621 #endif
622 #endif
623 
624 #if defined(HAVE_LIBIDN2) && defined(HAVE_IDN2_H) && !defined(USE_WIN32_IDN)
625 /* The lib and header are present */
626 #define USE_LIBIDN2
627 #endif
628 
629 #if defined(USE_LIBIDN2) && defined(USE_WIN32_IDN)
630 #error "Both libidn2 and WinIDN are enabled, choose one."
631 #endif
632 
633 #define LIBIDN_REQUIRED_VERSION "0.4.1"
634 
635 #if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_NSS) || \
636     defined(USE_MBEDTLS) || \
637     defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || \
638     defined(USE_SECTRANSP) || defined(USE_GSKIT) || defined(USE_MESALINK) || \
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_CRYPTO_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_CRYPTO_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_CRYPTO_AUTH) && !defined(CURL_DISABLE_NTLM)
657 #  if defined(USE_OPENSSL) || defined(USE_MBEDTLS) ||                       \
658       defined(USE_GNUTLS) || defined(USE_NSS) || 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 /*
692  * Include macros and defines that should only be processed once.
693  */
694 
695 #ifndef HEADER_CURL_SETUP_ONCE_H
696 #include "curl_setup_once.h"
697 #endif
698 
699 /*
700  * Definition of our NOP statement Object-like macro
701  */
702 
703 #ifndef Curl_nop_stmt
704 #  define Curl_nop_stmt do { } while(0)
705 #endif
706 
707 /*
708  * Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
709  */
710 
711 #if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H)
712 #  if defined(SOCKET) || \
713      defined(USE_WINSOCK) || \
714      defined(HAVE_WINSOCK_H) || \
715      defined(HAVE_WINSOCK2_H) || \
716      defined(HAVE_WS2TCPIP_H)
717 #    error "WinSock and lwIP TCP/IP stack definitions shall not coexist!"
718 #  endif
719 #endif
720 
721 /*
722  * shutdown() flags for systems that don't define them
723  */
724 
725 #ifndef SHUT_RD
726 #define SHUT_RD 0x00
727 #endif
728 
729 #ifndef SHUT_WR
730 #define SHUT_WR 0x01
731 #endif
732 
733 #ifndef SHUT_RDWR
734 #define SHUT_RDWR 0x02
735 #endif
736 
737 /* Define S_ISREG if not defined by system headers, f.e. MSVC */
738 #if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
739 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
740 #endif
741 
742 /* Define S_ISDIR if not defined by system headers, f.e. MSVC */
743 #if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
744 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
745 #endif
746 
747 /* In Windows the default file mode is text but an application can override it.
748 Therefore we specify it explicitly. https://github.com/curl/curl/pull/258
749 */
750 #if defined(WIN32) || defined(MSDOS)
751 #define FOPEN_READTEXT "rt"
752 #define FOPEN_WRITETEXT "wt"
753 #define FOPEN_APPENDTEXT "at"
754 #elif defined(__CYGWIN__)
755 /* Cygwin has specific behavior we need to address when WIN32 is not defined.
756 https://cygwin.com/cygwin-ug-net/using-textbinary.html
757 For write we want our output to have line endings of LF and be compatible with
758 other Cygwin utilities. For read we want to handle input that may have line
759 endings either CRLF or LF so 't' is appropriate.
760 */
761 #define FOPEN_READTEXT "rt"
762 #define FOPEN_WRITETEXT "w"
763 #define FOPEN_APPENDTEXT "a"
764 #else
765 #define FOPEN_READTEXT "r"
766 #define FOPEN_WRITETEXT "w"
767 #define FOPEN_APPENDTEXT "a"
768 #endif
769 
770 /* WinSock destroys recv() buffer when send() failed.
771  * Enabled automatically for Windows and for Cygwin as Cygwin sockets are
772  * wrappers for WinSock sockets. https://github.com/curl/curl/issues/657
773  * Define DONT_USE_RECV_BEFORE_SEND_WORKAROUND to force disable workaround.
774  */
775 #if !defined(DONT_USE_RECV_BEFORE_SEND_WORKAROUND)
776 #  if defined(WIN32) || defined(__CYGWIN__)
777 #    define USE_RECV_BEFORE_SEND_WORKAROUND
778 #  endif
779 #else  /* DONT_USE_RECV_BEFORE_SEND_WORKAROUND */
780 #  ifdef USE_RECV_BEFORE_SEND_WORKAROUND
781 #    undef USE_RECV_BEFORE_SEND_WORKAROUND
782 #  endif
783 #endif /* DONT_USE_RECV_BEFORE_SEND_WORKAROUND */
784 
785 /* for systems that don't detect this in configure */
786 #ifndef CURL_SA_FAMILY_T
787 #  if defined(HAVE_SA_FAMILY_T)
788 #    define CURL_SA_FAMILY_T sa_family_t
789 #  elif defined(HAVE_ADDRESS_FAMILY)
790 #    define CURL_SA_FAMILY_T ADDRESS_FAMILY
791 #  else
792 /* use a sensible default */
793 #    define CURL_SA_FAMILY_T unsigned short
794 #  endif
795 #endif
796 
797 /* Some convenience macros to get the larger/smaller value out of two given.
798    We prefix with CURL to prevent name collisions. */
799 #define CURLMAX(x,y) ((x)>(y)?(x):(y))
800 #define CURLMIN(x,y) ((x)<(y)?(x):(y))
801 
802 /* Some versions of the Android SDK is missing the declaration */
803 #if defined(HAVE_GETPWUID_R) && defined(HAVE_DECL_GETPWUID_R_MISSING)
804 struct passwd;
805 int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
806                size_t buflen, struct passwd **result);
807 #endif
808 
809 #ifdef DEBUGBUILD
810 #define UNITTEST
811 #else
812 #define UNITTEST static
813 #endif
814 
815 #if defined(USE_NGHTTP2) || defined(USE_HYPER)
816 #define USE_HTTP2
817 #endif
818 
819 #if defined(USE_NGTCP2) || defined(USE_QUICHE)
820 #define ENABLE_QUIC
821 #endif
822 
823 #if defined(USE_UNIX_SOCKETS) && defined(WIN32)
824 #  if defined(__MINGW32__) && !defined(LUP_SECURE)
825      typedef u_short ADDRESS_FAMILY; /* Classic mingw, 11y+ old mingw-w64 */
826 #  endif
827 #  if !defined(UNIX_PATH_MAX)
828      /* Replicating logic present in afunix.h
829         (distributed with newer Windows 10 SDK versions only) */
830 #    define UNIX_PATH_MAX 108
831      /* !checksrc! disable TYPEDEFSTRUCT 1 */
832      typedef struct sockaddr_un {
833        ADDRESS_FAMILY sun_family;
834        char sun_path[UNIX_PATH_MAX];
835      } SOCKADDR_UN, *PSOCKADDR_UN;
836 #  endif
837 #endif
838 
839 #endif /* HEADER_CURL_SETUP_H */
840