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