1 #ifndef HEADER_CURL_SETUP_H
2 #define HEADER_CURL_SETUP_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 * SPDX-License-Identifier: curl
25 ***************************************************************************/
27 #if defined(BUILDING_LIBCURL) && !defined(CURL_NO_OLDIES)
28 #define CURL_NO_OLDIES
31 /* define mingw version macros, eg __MINGW{32,64}_{MINOR,MAJOR}_VERSION */
37 * Disable Visual Studio warnings:
38 * 4127 "conditional expression is constant"
41 #pragma warning(disable:4127)
45 * Define WIN32 when build target is Win32 API
48 #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
54 * Don't include unneeded stuff in Windows headers to avoid compiler
55 * warnings and macro clashes.
56 * Make sure to define this macro before including any Windows headers.
58 # ifndef WIN32_LEAN_AND_MEAN
59 # define WIN32_LEAN_AND_MEAN
64 /* Detect Windows App environment which has a restricted access
65 * to the Win32 APIs. */
66 # if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \
67 defined(WINAPI_FAMILY)
68 # include <winapifamily.h>
69 # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
70 !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
71 # define CURL_WINDOWS_APP
77 * Include configuration script results or hand-crafted
78 * configuration file for platforms which lack config tool.
83 #include "curl_config.h"
85 #else /* HAVE_CONFIG_H */
88 # include "config-win32ce.h"
91 # include "config-win32.h"
95 #if defined(macintosh) && defined(__MRC__)
96 # include "config-mac.h"
100 # include "config-riscos.h"
104 # include "config-amigaos.h"
108 # include "config-os400.h"
112 # include "config-plan9.h"
115 #endif /* HAVE_CONFIG_H */
117 #if defined(_MSC_VER)
118 # pragma warning(push,1)
121 /* ================================================================ */
122 /* Definition of preprocessor macros/symbols which modify compiler */
123 /* behavior or generated code characteristics must be done here, */
124 /* as appropriate, before any system header file is included. It is */
125 /* also possible to have them defined in the config file included */
126 /* before this point. As a result of all this we frown inclusion of */
127 /* system header files in our config files, avoid this at any cost. */
128 /* ================================================================ */
131 * AIX 4.3 and newer needs _THREAD_SAFE defined to build
132 * proper reentrant code. Others may also need it.
135 #ifdef NEED_THREAD_SAFE
136 # ifndef _THREAD_SAFE
137 # define _THREAD_SAFE
142 * Tru64 needs _REENTRANT set for a few function prototypes and
143 * things to appear in the system header files. Unixware needs it
144 * to build proper reentrant code. Others may also need it.
147 #ifdef NEED_REENTRANT
153 /* Solaris needs this to get a POSIX-conformant getpwuid_r */
154 #if defined(sun) || defined(__sun)
155 # ifndef _POSIX_PTHREAD_SEMANTICS
156 # define _POSIX_PTHREAD_SEMANTICS 1
160 /* ================================================================ */
161 /* If you need to include a system header file for your platform, */
162 /* please, do it beyond the point further indicated in this file. */
163 /* ================================================================ */
166 * Disable other protocols when http is the only one desired.
170 # ifndef CURL_DISABLE_DICT
171 # define CURL_DISABLE_DICT
173 # ifndef CURL_DISABLE_FILE
174 # define CURL_DISABLE_FILE
176 # ifndef CURL_DISABLE_FTP
177 # define CURL_DISABLE_FTP
179 # ifndef CURL_DISABLE_GOPHER
180 # define CURL_DISABLE_GOPHER
182 # ifndef CURL_DISABLE_IMAP
183 # define CURL_DISABLE_IMAP
185 # ifndef CURL_DISABLE_LDAP
186 # define CURL_DISABLE_LDAP
188 # ifndef CURL_DISABLE_LDAPS
189 # define CURL_DISABLE_LDAPS
191 # ifndef CURL_DISABLE_MQTT
192 # define CURL_DISABLE_MQTT
194 # ifndef CURL_DISABLE_POP3
195 # define CURL_DISABLE_POP3
197 # ifndef CURL_DISABLE_RTSP
198 # define CURL_DISABLE_RTSP
200 # ifndef CURL_DISABLE_SMB
201 # define CURL_DISABLE_SMB
203 # ifndef CURL_DISABLE_SMTP
204 # define CURL_DISABLE_SMTP
206 # ifndef CURL_DISABLE_TELNET
207 # define CURL_DISABLE_TELNET
209 # ifndef CURL_DISABLE_TFTP
210 # define CURL_DISABLE_TFTP
215 * When http is disabled rtsp is not supported.
218 #if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP)
219 # define CURL_DISABLE_RTSP
222 /* ================================================================ */
223 /* No system header file shall be included in this file before this */
225 /* ================================================================ */
228 * OS/400 setup file includes some system headers.
232 # include "setup-os400.h"
236 * VMS setup file includes some system headers.
240 # include "setup-vms.h"
244 * Windows setup file includes some system headers.
247 #ifdef HAVE_WINDOWS_H
248 # include "setup-win32.h"
251 #include <curl/system.h>
254 * Use getaddrinfo to resolve the IPv4 address literal. If the current network
255 * interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64,
256 * performing this task will result in a synthesized IPv6 address.
258 #if defined(__APPLE__) && !defined(USE_ARES)
259 #include <TargetConditionals.h>
260 #define USE_RESOLVE_ON_IPS 1
261 # if defined(TARGET_OS_OSX) && TARGET_OS_OSX
262 # define CURL_OSX_CALL_COPYPROXIES 1
267 # include <lwip/init.h>
268 # include <lwip/sockets.h>
269 # include <lwip/netdb.h>
272 #ifdef HAVE_EXTRA_STRICMP_H
273 # include <extra/stricmp.h>
276 #ifdef HAVE_EXTRA_STRDUP_H
277 # include <extra/strdup.h>
282 # define __USE_INLINE__
283 /* use our own resolver which uses runtime feature detection */
284 # define CURLRES_AMIGA
285 /* getaddrinfo() currently crashes bsdsocket.library, so disable */
286 # undef HAVE_GETADDRINFO
287 # if !(defined(__NEWLIB__) || \
288 (defined(__CLIB2__) && defined(__THREAD_SAFE)))
289 /* disable threaded resolver with clib2 - requires newlib or clib-ts */
290 # undef USE_THREADS_POSIX
293 # include <exec/types.h>
294 # include <exec/execbase.h>
295 # include <proto/exec.h>
296 # include <proto/dos.h>
298 # if defined(HAVE_PROTO_BSDSOCKET_H) && \
299 (!defined(__amigaos4__) || defined(USE_AMISSL))
300 /* use bsdsocket.library directly, instead of libc networking functions */
301 # include <proto/bsdsocket.h>
303 int Curl_amiga_select(int nfds, fd_set *readfds, fd_set *writefds,
304 fd_set *errorfds, struct timeval *timeout);
305 # define select(a,b,c,d,e) Curl_amiga_select(a,b,c,d,e)
307 # define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
309 /* must not use libc's fcntl() on bsdsocket.library sockfds! */
311 # undef HAVE_FCNTL_O_NONBLOCK
313 /* use libc networking and hence close() and fnctl() */
314 # undef HAVE_CLOSESOCKET_CAMEL
315 # undef HAVE_IOCTLSOCKET_CAMEL
318 * In clib2 arpa/inet.h warns that some prototypes may clash
319 * with bsdsocket.library. This avoids the definition of those.
321 # define __NO_NET_API
329 #ifdef __TANDEM /* for ns*-tandem-nsk systems */
330 # if ! defined __LP64
331 # include <floss.h> /* FLOSS is only used for 32-bit builds. */
335 #ifndef STDC_HEADERS /* no standard C headers! */
336 #include <curl/stdcheaders.h>
340 # include <sys/types.h>
342 # define sys_nerr EILSEQ
346 * Salford-C kludge section (mostly borrowed from wxWidgets).
349 #pragma suppress 353 /* Possible nested comments */
350 #pragma suppress 593 /* Define not used */
351 #pragma suppress 61 /* enum has no name */
352 #pragma suppress 106 /* unnamed, unused parameter */
356 /* Default Windows file API selection. */
358 # if defined(_MSC_VER) && (_INTEGRAL_MAX_BITS >= 64)
359 # define USE_WIN32_LARGE_FILES
360 # elif defined(__MINGW32__)
361 # define USE_WIN32_LARGE_FILES
363 # define USE_WIN32_SMALL_FILES
368 * Large file (>2Gb) support using WIN32 functions.
371 #ifdef USE_WIN32_LARGE_FILES
373 # include <sys/types.h>
374 # include <sys/stat.h>
376 # define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence)
378 # define fstat(fdes,stp) _fstati64(fdes, stp)
380 # define stat(fname,stp) curlx_win32_stat(fname, stp)
381 # define struct_stat struct _stati64
382 # define LSEEK_ERROR (__int64)-1
383 # define open curlx_win32_open
384 # define fopen(fname,mode) curlx_win32_fopen(fname, mode)
385 # define access(fname,mode) curlx_win32_access(fname, mode)
386 int curlx_win32_open(const char *filename, int oflag, ...);
387 int curlx_win32_stat(const char *path, struct_stat *buffer);
388 FILE *curlx_win32_fopen(const char *filename, const char *mode);
389 int curlx_win32_access(const char *path, int mode);
393 * Small file (<2Gb) support using WIN32 functions.
396 #ifdef USE_WIN32_SMALL_FILES
398 # include <sys/types.h>
399 # include <sys/stat.h>
402 # define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence)
403 # define fstat(fdes,stp) _fstat(fdes, stp)
404 # define stat(fname,stp) curlx_win32_stat(fname, stp)
405 # define struct_stat struct _stat
406 # define open curlx_win32_open
407 # define fopen(fname,mode) curlx_win32_fopen(fname, mode)
408 # define access(fname,mode) curlx_win32_access(fname, mode)
409 int curlx_win32_stat(const char *path, struct_stat *buffer);
410 int curlx_win32_open(const char *filename, int oflag, ...);
411 FILE *curlx_win32_fopen(const char *filename, const char *mode);
412 int curlx_win32_access(const char *path, int mode);
414 # define LSEEK_ERROR (long)-1
418 # define struct_stat struct stat
422 # define LSEEK_ERROR (off_t)-1
425 #ifndef SIZEOF_TIME_T
426 /* assume default size of time_t to be 32 bit */
427 #define SIZEOF_TIME_T 4
431 * Default sizeof(off_t) in case it hasn't been defined in config file.
435 # if defined(__VMS) && !defined(__VAX)
436 # if defined(_LARGEFILE)
437 # define SIZEOF_OFF_T 8
439 # elif defined(__OS400__) && defined(__ILEC400__)
440 # if defined(_LARGE_FILES)
441 # define SIZEOF_OFF_T 8
443 # elif defined(__MVS__) && defined(__IBMC__)
444 # if defined(_LP64) || defined(_LARGE_FILES)
445 # define SIZEOF_OFF_T 8
447 # elif defined(__370__) && defined(__IBMC__)
448 # if defined(_LP64) || defined(_LARGE_FILES)
449 # define SIZEOF_OFF_T 8
452 # ifndef SIZEOF_OFF_T
453 # define SIZEOF_OFF_T 4
457 #if (SIZEOF_CURL_OFF_T == 4)
458 # define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFF)
460 /* assume SIZEOF_CURL_OFF_T == 8 */
461 # define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
463 #define CURL_OFF_T_MIN (-CURL_OFF_T_MAX - CURL_OFF_T_C(1))
465 #if (SIZEOF_TIME_T == 4)
466 # ifdef HAVE_TIME_T_UNSIGNED
467 # define TIME_T_MAX UINT_MAX
468 # define TIME_T_MIN 0
470 # define TIME_T_MAX INT_MAX
471 # define TIME_T_MIN INT_MIN
474 # ifdef HAVE_TIME_T_UNSIGNED
475 # define TIME_T_MAX 0xFFFFFFFFFFFFFFFF
476 # define TIME_T_MIN 0
478 # define TIME_T_MAX 0x7FFFFFFFFFFFFFFF
479 # define TIME_T_MIN (-TIME_T_MAX - 1)
484 /* some limits.h headers have this defined, some don't */
485 #if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
486 #define SIZE_T_MAX 18446744073709551615U
488 #define SIZE_T_MAX 4294967295U
493 /* some limits.h headers have this defined, some don't */
494 #if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
495 #define SSIZE_T_MAX 9223372036854775807
497 #define SSIZE_T_MAX 2147483647
502 * Arg 2 type for gethostname in case it hasn't been defined in config file.
505 #ifndef GETHOSTNAME_TYPE_ARG2
507 # define GETHOSTNAME_TYPE_ARG2 int
509 # define GETHOSTNAME_TYPE_ARG2 size_t
513 /* Below we define some functions. They should
515 4. set the SIGALRM signal timeout
516 5. set dir/file naming defines
521 # define DIR_CHAR "\\"
525 # ifdef MSDOS /* Watt-32 */
527 # include <sys/ioctl.h>
528 # define select(n,r,w,x,t) select_s(n,r,w,x,t)
529 # define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
541 /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
542 extern char *strtok_r(char *s, const char *delim, char **last);
543 extern struct tm *gmtime_r(const time_t * const timep, struct tm *tmp);
546 # define DIR_CHAR "/"
548 # ifndef fileno /* sunos 4 have this as a macro! */
549 int fileno(FILE *stream);
555 * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
556 * defined in ws2tcpip.h as well as to provide IPv6 support.
557 * Does not apply if lwIP is used.
560 #if defined(_MSC_VER) && !defined(__POCC__) && !defined(USE_LWIPSOCK)
561 # if !defined(HAVE_WS2TCPIP_H) || \
562 ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN))
563 # undef HAVE_GETADDRINFO_THREADSAFE
564 # undef HAVE_FREEADDRINFO
565 # undef HAVE_GETADDRINFO
570 /* ---------------------------------------------------------------- */
571 /* resolver specialty compile-time defines */
572 /* CURLRES_* defines to use in the host*.c sources */
573 /* ---------------------------------------------------------------- */
576 * lcc-win32 doesn't have _beginthreadex(), lacks threads support.
579 #if defined(__LCC__) && defined(WIN32)
580 # undef USE_THREADS_POSIX
581 # undef USE_THREADS_WIN32
585 * MSVC threads support requires a multi-threaded runtime library.
586 * _beginthreadex() is not available in single-threaded ones.
589 #if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT)
590 # undef USE_THREADS_POSIX
591 # undef USE_THREADS_WIN32
595 * Mutually exclusive CURLRES_* definitions.
598 #if defined(ENABLE_IPV6) && defined(HAVE_GETADDRINFO)
599 # define CURLRES_IPV6
601 # define CURLRES_IPV4
605 # define CURLRES_ASYNCH
606 # define CURLRES_ARES
607 /* now undef the stock libc functions just to avoid them being used */
608 # undef HAVE_GETADDRINFO
609 # undef HAVE_FREEADDRINFO
610 #elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
611 # define CURLRES_ASYNCH
612 # define CURLRES_THREADED
614 # define CURLRES_SYNCH
617 /* ---------------------------------------------------------------- */
620 * msvc 6.0 does not have struct sockaddr_storage and
621 * does not define IPPROTO_ESP in winsock2.h. But both
622 * are available if PSDK is properly installed.
625 #if defined(_MSC_VER) && !defined(__POCC__)
626 # if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP))
627 # undef HAVE_STRUCT_SOCKADDR_STORAGE
632 * Intentionally fail to build when using msvc 6.0 without PSDK installed.
633 * The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK
634 * in lib/config-win32.h although absolutely discouraged and unsupported.
637 #if defined(_MSC_VER) && !defined(__POCC__)
638 # if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_))
639 # if !defined(ALLOW_MSVC6_WITHOUT_PSDK)
640 # error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. \
641 "Windows Server 2003 PSDK"
643 # define CURL_DISABLE_LDAP 1
648 #if defined(HAVE_LIBIDN2) && defined(HAVE_IDN2_H) && !defined(USE_WIN32_IDN)
649 /* The lib and header are present */
653 #if defined(USE_LIBIDN2) && defined(USE_WIN32_IDN)
654 #error "Both libidn2 and WinIDN are enabled, choose one."
657 #define LIBIDN_REQUIRED_VERSION "0.4.1"
659 #if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_NSS) || \
660 defined(USE_MBEDTLS) || \
661 defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || \
662 defined(USE_SECTRANSP) || defined(USE_GSKIT) || \
663 defined(USE_BEARSSL) || defined(USE_RUSTLS)
664 #define USE_SSL /* SSL support has been enabled */
667 /* Single point where USE_SPNEGO definition might be defined */
668 #if !defined(CURL_DISABLE_CRYPTO_AUTH) && \
669 (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI))
673 /* Single point where USE_KERBEROS5 definition might be defined */
674 #if !defined(CURL_DISABLE_CRYPTO_AUTH) && \
675 (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI))
676 #define USE_KERBEROS5
679 /* Single point where USE_NTLM definition might be defined */
680 #if !defined(CURL_DISABLE_CRYPTO_AUTH) && !defined(CURL_DISABLE_NTLM)
681 # if defined(USE_OPENSSL) || defined(USE_MBEDTLS) || \
682 defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_SECTRANSP) || \
683 defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \
684 (defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT))
685 # define USE_CURL_NTLM_CORE
687 # if defined(USE_CURL_NTLM_CORE) || defined(USE_WINDOWS_SSPI)
692 #ifdef CURL_WANTS_CA_BUNDLE_ENV
693 #error "No longer supported. Set CURLOPT_CAINFO at runtime instead."
696 #if defined(USE_LIBSSH2) || defined(USE_LIBSSH) || defined(USE_WOLFSSH)
701 * Provide a mechanism to silence picky compilers, such as gcc 4.6+.
702 * Parameters should of course normally not be unused, but for example when
703 * we have multiple implementations of the same interface it may happen.
706 #if defined(__GNUC__) && ((__GNUC__ >= 3) || \
707 ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7)))
708 # define UNUSED_PARAM __attribute__((__unused__))
709 # define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
711 # define UNUSED_PARAM /*NOTHING*/
712 # define WARN_UNUSED_RESULT
716 * Include macros and defines that should only be processed once.
719 #ifndef HEADER_CURL_SETUP_ONCE_H
720 #include "curl_setup_once.h"
724 * Definition of our NOP statement Object-like macro
727 #ifndef Curl_nop_stmt
728 # define Curl_nop_stmt do { } while(0)
732 * Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
735 #if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H)
736 # if defined(SOCKET) || \
737 defined(USE_WINSOCK) || \
738 defined(HAVE_WINSOCK2_H) || \
739 defined(HAVE_WS2TCPIP_H)
740 # error "WinSock and lwIP TCP/IP stack definitions shall not coexist!"
745 * shutdown() flags for systems that don't define them
757 #define SHUT_RDWR 0x02
760 /* Define S_ISREG if not defined by system headers, e.g. MSVC */
761 #if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
762 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
765 /* Define S_ISDIR if not defined by system headers, e.g. MSVC */
766 #if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
767 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
770 /* In Windows the default file mode is text but an application can override it.
771 Therefore we specify it explicitly. https://github.com/curl/curl/pull/258
773 #if defined(WIN32) || defined(MSDOS)
774 #define FOPEN_READTEXT "rt"
775 #define FOPEN_WRITETEXT "wt"
776 #define FOPEN_APPENDTEXT "at"
777 #elif defined(__CYGWIN__)
778 /* Cygwin has specific behavior we need to address when WIN32 is not defined.
779 https://cygwin.com/cygwin-ug-net/using-textbinary.html
780 For write we want our output to have line endings of LF and be compatible with
781 other Cygwin utilities. For read we want to handle input that may have line
782 endings either CRLF or LF so 't' is appropriate.
784 #define FOPEN_READTEXT "rt"
785 #define FOPEN_WRITETEXT "w"
786 #define FOPEN_APPENDTEXT "a"
788 #define FOPEN_READTEXT "r"
789 #define FOPEN_WRITETEXT "w"
790 #define FOPEN_APPENDTEXT "a"
793 /* WinSock destroys recv() buffer when send() failed.
794 * Enabled automatically for Windows and for Cygwin as Cygwin sockets are
795 * wrappers for WinSock sockets. https://github.com/curl/curl/issues/657
796 * Define DONT_USE_RECV_BEFORE_SEND_WORKAROUND to force disable workaround.
798 #if !defined(DONT_USE_RECV_BEFORE_SEND_WORKAROUND)
799 # if defined(WIN32) || defined(__CYGWIN__)
800 # define USE_RECV_BEFORE_SEND_WORKAROUND
802 #else /* DONT_USE_RECV_BEFORE_SEND_WORKAROUND */
803 # ifdef USE_RECV_BEFORE_SEND_WORKAROUND
804 # undef USE_RECV_BEFORE_SEND_WORKAROUND
806 #endif /* DONT_USE_RECV_BEFORE_SEND_WORKAROUND */
808 /* for systems that don't detect this in configure */
809 #ifndef CURL_SA_FAMILY_T
810 # if defined(HAVE_SA_FAMILY_T)
811 # define CURL_SA_FAMILY_T sa_family_t
812 # elif defined(HAVE_ADDRESS_FAMILY)
813 # define CURL_SA_FAMILY_T ADDRESS_FAMILY
815 /* use a sensible default */
816 # define CURL_SA_FAMILY_T unsigned short
820 /* Some convenience macros to get the larger/smaller value out of two given.
821 We prefix with CURL to prevent name collisions. */
822 #define CURLMAX(x,y) ((x)>(y)?(x):(y))
823 #define CURLMIN(x,y) ((x)<(y)?(x):(y))
825 /* A convenience macro to provide both the string literal and the length of
826 the string literal in one go, useful for functions that take "string,len"
828 #define STRCONST(x) x,sizeof(x)-1
830 /* Some versions of the Android SDK is missing the declaration */
831 #if defined(HAVE_GETPWUID_R) && defined(HAVE_DECL_GETPWUID_R_MISSING)
833 int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
834 size_t buflen, struct passwd **result);
840 #define UNITTEST static
843 #if defined(USE_NGHTTP2) || defined(USE_HYPER)
847 #if defined(USE_NGTCP2) || defined(USE_QUICHE) || defined(USE_MSH3)
852 #if defined(USE_UNIX_SOCKETS) && defined(WIN32)
853 # if defined(__MINGW32__) && !defined(LUP_SECURE)
854 typedef u_short ADDRESS_FAMILY; /* Classic mingw, 11y+ old mingw-w64 */
856 # if !defined(UNIX_PATH_MAX)
857 /* Replicating logic present in afunix.h
858 (distributed with newer Windows 10 SDK versions only) */
859 # define UNIX_PATH_MAX 108
860 /* !checksrc! disable TYPEDEFSTRUCT 1 */
861 typedef struct sockaddr_un {
862 ADDRESS_FAMILY sun_family;
863 char sun_path[UNIX_PATH_MAX];
864 } SOCKADDR_UN, *PSOCKADDR_UN;
865 # define WIN32_SOCKADDR_UN
869 #endif /* HEADER_CURL_SETUP_H */