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