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