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