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