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