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