1#ifndef HEADER_CURL_LIB_SETUP_H 2#define HEADER_CURL_LIB_SETUP_H 3/*************************************************************************** 4 * _ _ ____ _ 5 * Project ___| | | | _ \| | 6 * / __| | | | |_) | | 7 * | (__| |_| | _ <| |___ 8 * \___|\___/|_| \_\_____| 9 * 10 * Copyright (C) 1998 - 2011, 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 http://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/* 26 * Define WIN32 when build target is Win32 API 27 */ 28 29#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && \ 30 !defined(__SYMBIAN32__) 31#define WIN32 32#endif 33 34/* 35 * Include configuration script results or hand-crafted 36 * configuration file for platforms which lack config tool. 37 */ 38 39#ifdef HAVE_CONFIG_H 40 41#include "curl_config.h" 42 43#else /* HAVE_CONFIG_H */ 44 45#ifdef _WIN32_WCE 46# include "config-win32ce.h" 47#else 48# ifdef WIN32 49# include "config-win32.h" 50# endif 51#endif 52 53#if defined(macintosh) && defined(__MRC__) 54# include "config-mac.h" 55#endif 56 57#ifdef __AMIGA__ 58# include "amigaos.h" 59#endif 60 61#ifdef __SYMBIAN32__ 62# include "config-symbian.h" 63#endif 64 65#ifdef __OS400__ 66# include "config-os400.h" 67#endif 68 69#ifdef TPF 70# include "config-tpf.h" 71#endif 72 73#ifdef __VXWORKS__ 74# include "config-vxworks.h" 75#endif 76 77#endif /* HAVE_CONFIG_H */ 78 79/* ================================================================ */ 80/* Definition of preprocessor macros/symbols which modify compiler */ 81/* behavior or generated code characteristics must be done here, */ 82/* as appropriate, before any system header file is included. It is */ 83/* also possible to have them defined in the config file included */ 84/* before this point. As a result of all this we frown inclusion of */ 85/* system header files in our config files, avoid this at any cost. */ 86/* ================================================================ */ 87 88/* 89 * AIX 4.3 and newer needs _THREAD_SAFE defined to build 90 * proper reentrant code. Others may also need it. 91 */ 92 93#ifdef NEED_THREAD_SAFE 94# ifndef _THREAD_SAFE 95# define _THREAD_SAFE 96# endif 97#endif 98 99/* 100 * Tru64 needs _REENTRANT set for a few function prototypes and 101 * things to appear in the system header files. Unixware needs it 102 * to build proper reentrant code. Others may also need it. 103 */ 104 105#ifdef NEED_REENTRANT 106# ifndef _REENTRANT 107# define _REENTRANT 108# endif 109#endif 110 111/* ================================================================ */ 112/* If you need to include a system header file for your platform, */ 113/* please, do it beyond the point further indicated in this file. */ 114/* ================================================================ */ 115 116/* 117 * libcurl's external interface definitions are also used internally, 118 * and might also include required system header files to define them. 119 */ 120 121#include <curl/curlbuild.h> 122 123/* 124 * Compile time sanity checks must also be done when building the library. 125 */ 126 127#include <curl/curlrules.h> 128 129/* 130 * Ensure that no one is using the old SIZEOF_CURL_OFF_T macro 131 */ 132 133#ifdef SIZEOF_CURL_OFF_T 134# error "SIZEOF_CURL_OFF_T shall not be defined!" 135 Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined 136#endif 137 138/* 139 * Set up internal curl_off_t formatting string directives for 140 * exclusive use with libcurl's internal *printf functions. 141 */ 142 143#ifdef FORMAT_OFF_T 144# error "FORMAT_OFF_T shall not be defined before this point!" 145 Error Compilation_aborted_FORMAT_OFF_T_already_defined 146#endif 147 148#ifdef FORMAT_OFF_TU 149# error "FORMAT_OFF_TU shall not be defined before this point!" 150 Error Compilation_aborted_FORMAT_OFF_TU_already_defined 151#endif 152 153#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG) 154# define FORMAT_OFF_T "lld" 155# define FORMAT_OFF_TU "llu" 156#else 157# define FORMAT_OFF_T "ld" 158# define FORMAT_OFF_TU "lu" 159#endif 160 161/* 162 * Disable other protocols when http is the only one desired. 163 */ 164 165#ifdef HTTP_ONLY 166# ifndef CURL_DISABLE_TFTP 167# define CURL_DISABLE_TFTP 168# endif 169# ifndef CURL_DISABLE_FTP 170# define CURL_DISABLE_FTP 171# endif 172# ifndef CURL_DISABLE_LDAP 173# define CURL_DISABLE_LDAP 174# endif 175# ifndef CURL_DISABLE_TELNET 176# define CURL_DISABLE_TELNET 177# endif 178# ifndef CURL_DISABLE_DICT 179# define CURL_DISABLE_DICT 180# endif 181# ifndef CURL_DISABLE_FILE 182# define CURL_DISABLE_FILE 183# endif 184# ifndef CURL_DISABLE_RTSP 185# define CURL_DISABLE_RTSP 186# endif 187#endif 188 189/* 190 * When http is disabled rtsp is not supported. 191 */ 192 193#if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP) 194# define CURL_DISABLE_RTSP 195#endif 196 197/* ================================================================ */ 198/* No system header file shall be included in this file before this */ 199/* point. The only allowed ones are those included from curlbuild.h */ 200/* ================================================================ */ 201 202/* 203 * OS/400 setup file includes some system headers. 204 */ 205 206#ifdef __OS400__ 207# include "setup-os400.h" 208#endif 209 210/* 211 * Include header files for windows builds before redefining anything. 212 * Use this preprocessor block only to include or exclude windows.h, 213 * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs 214 * to any other further and independent block. Under Cygwin things work 215 * just as under linux (e.g. <sys/socket.h>) and the winsock headers should 216 * never be included when __CYGWIN__ is defined. configure script takes 217 * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H, 218 * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined. 219 */ 220 221#ifdef HAVE_WINDOWS_H 222# ifndef WIN32_LEAN_AND_MEAN 223# define WIN32_LEAN_AND_MEAN 224# endif 225# include <windows.h> 226# ifdef HAVE_WINSOCK2_H 227# include <winsock2.h> 228# ifdef HAVE_WS2TCPIP_H 229# include <ws2tcpip.h> 230# endif 231# else 232# ifdef HAVE_WINSOCK_H 233# include <winsock.h> 234# endif 235# endif 236#endif 237 238/* 239 * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else 240 * define USE_WINSOCK to 1 if we have and use WINSOCK API, else 241 * undefine USE_WINSOCK. 242 */ 243 244#undef USE_WINSOCK 245 246#ifdef HAVE_WINSOCK2_H 247# define USE_WINSOCK 2 248#else 249# ifdef HAVE_WINSOCK_H 250# define USE_WINSOCK 1 251# endif 252#endif 253 254#ifdef USE_LWIPSOCK 255# include <lwip/init.h> 256# include <lwip/sockets.h> 257# include <lwip/netdb.h> 258#endif 259 260#ifdef HAVE_EXTRA_STRICMP_H 261# include <extra/stricmp.h> 262#endif 263 264#ifdef HAVE_EXTRA_STRDUP_H 265# include <extra/strdup.h> 266#endif 267 268#ifdef TPF 269# include <strings.h> /* for bzero, strcasecmp, and strncasecmp */ 270# include <string.h> /* for strcpy and strlen */ 271# include <stdlib.h> /* for rand and srand */ 272# include <sys/socket.h> /* for select and ioctl*/ 273# include <netdb.h> /* for in_addr_t definition */ 274# include <tpf/sysapi.h> /* for tpf_process_signals */ 275 /* change which select is used for libcurl */ 276# define select(a,b,c,d,e) tpf_select_libcurl(a,b,c,d,e) 277#endif 278 279#ifdef __VXWORKS__ 280# include <sockLib.h> /* for generic BSD socket functions */ 281# include <ioLib.h> /* for basic I/O interface functions */ 282#endif 283 284#include <stdio.h> 285#ifdef HAVE_ASSERT_H 286#include <assert.h> 287#endif 288 289#ifdef __TANDEM /* for nsr-tandem-nsk systems */ 290#include <floss.h> 291#endif 292 293#ifndef STDC_HEADERS /* no standard C headers! */ 294#include <curl/stdcheaders.h> 295#endif 296 297#ifdef __POCC__ 298# include <sys/types.h> 299# include <unistd.h> 300# define sys_nerr EILSEQ 301#endif 302 303/* 304 * Salford-C kludge section (mostly borrowed from wxWidgets). 305 */ 306#ifdef __SALFORDC__ 307 #pragma suppress 353 /* Possible nested comments */ 308 #pragma suppress 593 /* Define not used */ 309 #pragma suppress 61 /* enum has no name */ 310 #pragma suppress 106 /* unnamed, unused parameter */ 311 #include <clib.h> 312#endif 313 314/* 315 * Large file (>2Gb) support using WIN32 functions. 316 */ 317 318#ifdef USE_WIN32_LARGE_FILES 319# include <io.h> 320# include <sys/types.h> 321# include <sys/stat.h> 322# undef lseek 323# define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence) 324# define fstat(fdes,stp) _fstati64(fdes, stp) 325# define stat(fname,stp) _stati64(fname, stp) 326# define struct_stat struct _stati64 327# define LSEEK_ERROR (__int64)-1 328#endif 329 330/* 331 * Small file (<2Gb) support using WIN32 functions. 332 */ 333 334#ifdef USE_WIN32_SMALL_FILES 335# include <io.h> 336# include <sys/types.h> 337# include <sys/stat.h> 338# undef lseek 339# define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence) 340# define fstat(fdes,stp) _fstat(fdes, stp) 341# define stat(fname,stp) _stat(fname, stp) 342# define struct_stat struct _stat 343# define LSEEK_ERROR (long)-1 344#endif 345 346#ifndef struct_stat 347# define struct_stat struct stat 348#endif 349 350#ifndef LSEEK_ERROR 351# define LSEEK_ERROR (off_t)-1 352#endif 353 354/* 355 * Default sizeof(off_t) in case it hasn't been defined in config file. 356 */ 357 358#ifndef SIZEOF_OFF_T 359# if defined(__VMS) && !defined(__VAX) 360# if defined(_LARGEFILE) 361# define SIZEOF_OFF_T 8 362# endif 363# elif defined(__OS400__) && defined(__ILEC400__) 364# if defined(_LARGE_FILES) 365# define SIZEOF_OFF_T 8 366# endif 367# elif defined(__MVS__) && defined(__IBMC__) 368# if defined(_LP64) || defined(_LARGE_FILES) 369# define SIZEOF_OFF_T 8 370# endif 371# elif defined(__370__) && defined(__IBMC__) 372# if defined(_LP64) || defined(_LARGE_FILES) 373# define SIZEOF_OFF_T 8 374# endif 375# endif 376# ifndef SIZEOF_OFF_T 377# define SIZEOF_OFF_T 4 378# endif 379#endif 380 381/* 382 * Arg 2 type for gethostname in case it hasn't been defined in config file. 383 */ 384 385#ifndef GETHOSTNAME_TYPE_ARG2 386# ifdef USE_WINSOCK 387# define GETHOSTNAME_TYPE_ARG2 int 388# else 389# define GETHOSTNAME_TYPE_ARG2 size_t 390# endif 391#endif 392 393/* Below we define some functions. They should 394 395 4. set the SIGALRM signal timeout 396 5. set dir/file naming defines 397 */ 398 399#ifdef WIN32 400 401# define DIR_CHAR "\\" 402# define DOT_CHAR "_" 403 404#else /* WIN32 */ 405 406# ifdef MSDOS /* Watt-32 */ 407 408# include <sys/ioctl.h> 409# define select(n,r,w,x,t) select_s(n,r,w,x,t) 410# define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z)) 411# include <tcp.h> 412# ifdef word 413# undef word 414# endif 415# ifdef byte 416# undef byte 417# endif 418 419# endif /* MSDOS */ 420 421# ifdef __minix 422 /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */ 423 extern char * strtok_r(char *s, const char *delim, char **last); 424 extern struct tm * gmtime_r(const time_t * const timep, struct tm *tmp); 425# endif 426 427# define DIR_CHAR "/" 428# ifndef DOT_CHAR 429# define DOT_CHAR "." 430# endif 431 432# ifdef MSDOS 433# undef DOT_CHAR 434# define DOT_CHAR "_" 435# endif 436 437# ifndef fileno /* sunos 4 have this as a macro! */ 438 int fileno( FILE *stream); 439# endif 440 441#endif /* WIN32 */ 442 443/* 444 * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN 445 * defined in ws2tcpip.h as well as to provide IPv6 support. 446 */ 447 448#if defined(_MSC_VER) && !defined(__POCC__) 449# if !defined(HAVE_WS2TCPIP_H) || \ 450 ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN)) 451# undef HAVE_GETADDRINFO_THREADSAFE 452# undef HAVE_FREEADDRINFO 453# undef HAVE_GETADDRINFO 454# undef HAVE_GETNAMEINFO 455# undef ENABLE_IPV6 456# endif 457#endif 458 459/* ---------------------------------------------------------------- */ 460/* resolver specialty compile-time defines */ 461/* CURLRES_* defines to use in the host*.c sources */ 462/* ---------------------------------------------------------------- */ 463 464/* 465 * lcc-win32 doesn't have _beginthreadex(), lacks threads support. 466 */ 467 468#if defined(__LCC__) && defined(WIN32) 469# undef USE_THREADS_POSIX 470# undef USE_THREADS_WIN32 471#endif 472 473/* 474 * MSVC threads support requires a multi-threaded runtime library. 475 * _beginthreadex() is not available in single-threaded ones. 476 */ 477 478#if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT) 479# undef USE_THREADS_POSIX 480# undef USE_THREADS_WIN32 481#endif 482 483/* 484 * Mutually exclusive CURLRES_* definitions. 485 */ 486 487#ifdef USE_ARES 488# define CURLRES_ASYNCH 489# define CURLRES_ARES 490#elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) 491# define CURLRES_ASYNCH 492# define CURLRES_THREADED 493#else 494# define CURLRES_SYNCH 495#endif 496 497#ifdef ENABLE_IPV6 498# define CURLRES_IPV6 499#else 500# define CURLRES_IPV4 501#endif 502 503/* ---------------------------------------------------------------- */ 504 505/* 506 * When using WINSOCK, TELNET protocol requires WINSOCK2 API. 507 */ 508 509#if defined(USE_WINSOCK) && (USE_WINSOCK != 2) 510# define CURL_DISABLE_TELNET 1 511#endif 512 513/* 514 * msvc 6.0 does not have struct sockaddr_storage and 515 * does not define IPPROTO_ESP in winsock2.h. But both 516 * are available if PSDK is properly installed. 517 */ 518 519#if defined(_MSC_VER) && !defined(__POCC__) 520# if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP)) 521# undef HAVE_STRUCT_SOCKADDR_STORAGE 522# endif 523#endif 524 525/* 526 * Intentionally fail to build when using msvc 6.0 without PSDK installed. 527 * The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK 528 * in lib/config-win32.h although absolutely discouraged and unsupported. 529 */ 530 531#if defined(_MSC_VER) && !defined(__POCC__) 532# if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_)) 533# if !defined(ALLOW_MSVC6_WITHOUT_PSDK) 534# error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. \ 535 "Windows Server 2003 PSDK" 536# else 537# define CURL_DISABLE_LDAP 1 538# endif 539# endif 540#endif 541 542#ifdef NETWARE 543int netware_init(void); 544#ifndef __NOVELL_LIBC__ 545#include <sys/bsdskt.h> 546#include <sys/timeval.h> 547#endif 548#endif 549 550#if defined(HAVE_LIBIDN) && defined(HAVE_TLD_H) 551/* The lib was present and the tld.h header (which is missing in libidn 0.3.X 552 but we only work with libidn 0.4.1 or later) */ 553#define USE_LIBIDN 554#endif 555 556#ifndef SIZEOF_TIME_T 557/* assume default size of time_t to be 32 bit */ 558#define SIZEOF_TIME_T 4 559#endif 560 561#define LIBIDN_REQUIRED_VERSION "0.4.1" 562 563#if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || \ 564 defined(USE_QSOSSL) || defined(USE_POLARSSL) || defined(USE_AXTLS) || \ 565 defined(USE_CYASSL) 566#define USE_SSL /* SSL support has been enabled */ 567#endif 568 569#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) 570#define USE_HTTP_NEGOTIATE 571#endif 572 573/* Single point where USE_NTLM definition might be done */ 574#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM) 575#if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI) || \ 576 defined(USE_GNUTLS) || defined(USE_NSS) 577#define USE_NTLM 578#endif 579#endif 580 581/* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */ 582#if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE) 583#define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE") 584#endif 585 586/* Define S_ISREG if not defined by system headers, f.e. MSVC */ 587#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG) 588#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 589#endif 590 591/* Provide a mechanism to silence picky compilers, such as gcc 4.6+. 592 Parameters should of course normally not be unused, but for example when we 593 have multiple implementations of the same interface it may happen. */ 594#ifndef __GNUC__ 595#define UNUSED_PARAM /*NOTHING*/ 596#else 597#define UNUSED_PARAM __attribute__((unused)) 598#endif 599 600/* 601 * Include macros and defines that should only be processed once. 602 */ 603 604#ifndef __SETUP_ONCE_H 605#include "setup_once.h" 606#endif 607 608/* 609 * Definition of our NOP statement Object-like macro 610 */ 611 612#ifndef Curl_nop_stmt 613# define Curl_nop_stmt do { } WHILE_FALSE 614#endif 615 616/* 617 * Ensure that Winsock and lwIP TCP/IP stacks are not mixed. 618 */ 619 620#if defined(__LWIP_OPT_H__) 621# if defined(SOCKET) || \ 622 defined(USE_WINSOCK) || \ 623 defined(HAVE_ERRNO_H) || \ 624 defined(HAVE_WINSOCK_H) || \ 625 defined(HAVE_WINSOCK2_H) || \ 626 defined(HAVE_WS2TCPIP_H) 627# error "Winsock and lwIP TCP/IP stack definitions shall not coexist!" 628# endif 629#endif 630 631#endif /* HEADER_CURL_LIB_SETUP_H */ 632