1 #ifndef __LIB_CURL_SETUP_H 2 #define __LIB_CURL_SETUP_H 3 /*************************************************************************** 4 * _ _ ____ _ 5 * Project ___| | | | _ \| | 6 * / __| | | | |_) | | 7 * | (__| |_| | _ <| |___ 8 * \___|\___/|_| \_\_____| 9 * 10 * Copyright (C) 1998 - 2008, 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 * $Id: setup.h,v 1.163 2009-02-12 20:48:44 danf Exp $ 24 ***************************************************************************/ 25 26 /* 27 * Define WIN32 when build target is Win32 API 28 */ 29 30 #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && !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 #include "config.h" 41 #else 42 43 #ifdef _WIN32_WCE 44 #include "config-win32ce.h" 45 #else 46 #ifdef WIN32 47 #include "config-win32.h" 48 #endif 49 #endif 50 51 #if defined(macintosh) && defined(__MRC__) 52 # include "config-mac.h" 53 #endif 54 55 #ifdef __AMIGA__ 56 #include "amigaos.h" 57 #endif 58 59 #ifdef __SYMBIAN32__ 60 #include "config-symbian.h" 61 #endif 62 63 #ifdef __OS400__ 64 # include "config-os400.h" 65 #endif 66 67 #ifdef TPF 68 #include "config-tpf.h" /* hand-modified TPF config.h */ 69 /* change which select is used for libcurl */ 70 #define select(a,b,c,d,e) tpf_select_libcurl(a,b,c,d,e) 71 #endif 72 73 #endif /* HAVE_CONFIG_H */ 74 75 /* ================================================================ */ 76 /* Definition of preprocessor macros/symbols which modify compiler */ 77 /* behaviour or generated code characteristics must be done here, */ 78 /* as appropriate, before any system header file is included. It is */ 79 /* also possible to have them defined in the config file included */ 80 /* before this point. As a result of all this we frown inclusion of */ 81 /* system header files in our config files, avoid this at any cost. */ 82 /* ================================================================ */ 83 84 /* 85 * Tru64 needs _REENTRANT set for a few function prototypes and 86 * things to appear in the system header files. Unixware needs it 87 * to build proper reentrant code. Others may also need it. 88 */ 89 90 #ifdef NEED_REENTRANT 91 # ifndef _REENTRANT 92 # define _REENTRANT 93 # endif 94 #endif 95 96 /* ================================================================ */ 97 /* If you need to include a system header file for your platform, */ 98 /* please, do it beyond the point further indicated in this file. */ 99 /* ================================================================ */ 100 101 /* 102 * libcurl's external interface definitions are also used internally, 103 * and might also include required system header files to define them. 104 */ 105 106 #include <curl/curlbuild.h> 107 108 /* 109 * Compile time sanity checks must also be done when building the library. 110 */ 111 112 #include <curl/curlrules.h> 113 114 /* 115 * Ensure that no one is using the old SIZEOF_CURL_OFF_T macro 116 */ 117 118 #ifdef SIZEOF_CURL_OFF_T 119 # error "SIZEOF_CURL_OFF_T shall not be defined!" 120 Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined 121 #endif 122 123 /* 124 * Set up internal curl_off_t formatting string directives for 125 * exclusive use with libcurl's internal *printf functions. 126 */ 127 128 #ifdef FORMAT_OFF_T 129 # error "FORMAT_OFF_T shall not be defined before this point!" 130 Error Compilation_aborted_FORMAT_OFF_T_already_defined 131 #endif 132 133 #ifdef FORMAT_OFF_TU 134 # error "FORMAT_OFF_TU shall not be defined before this point!" 135 Error Compilation_aborted_FORMAT_OFF_TU_already_defined 136 #endif 137 138 #if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG) 139 # define FORMAT_OFF_T "lld" 140 # define FORMAT_OFF_TU "llu" 141 #else 142 # define FORMAT_OFF_T "ld" 143 # define FORMAT_OFF_TU "lu" 144 #endif 145 146 /* 147 * Disable other protocols when http is the only one desired. 148 */ 149 150 #ifdef HTTP_ONLY 151 # define CURL_DISABLE_TFTP 152 # define CURL_DISABLE_FTP 153 # define CURL_DISABLE_LDAP 154 # define CURL_DISABLE_TELNET 155 # define CURL_DISABLE_DICT 156 # define CURL_DISABLE_FILE 157 #endif 158 159 /* ================================================================ */ 160 /* No system header file shall be included in this file before this */ 161 /* point. The only allowed ones are those included from curlbuild.h */ 162 /* ================================================================ */ 163 164 /* 165 * OS/400 setup file includes some system headers. 166 */ 167 168 #ifdef __OS400__ 169 # include "setup-os400.h" 170 #endif 171 172 /* 173 * Include header files for windows builds before redefining anything. 174 * Use this preproessor block only to include or exclude windows.h, 175 * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs 176 * to any other further and independant block. Under Cygwin things work 177 * just as under linux (e.g. <sys/socket.h>) and the winsock headers should 178 * never be included when __CYGWIN__ is defined. configure script takes 179 * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H, 180 * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined. 181 */ 182 183 #ifdef HAVE_WINDOWS_H 184 # ifndef WIN32_LEAN_AND_MEAN 185 # define WIN32_LEAN_AND_MEAN 186 # endif 187 # include <windows.h> 188 # ifdef HAVE_WINSOCK2_H 189 # include <winsock2.h> 190 # ifdef HAVE_WS2TCPIP_H 191 # include <ws2tcpip.h> 192 # endif 193 # else 194 # ifdef HAVE_WINSOCK_H 195 # include <winsock.h> 196 # endif 197 # endif 198 #endif 199 200 /* 201 * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else 202 * define USE_WINSOCK to 1 if we have and use WINSOCK API, else 203 * undefine USE_WINSOCK. 204 */ 205 206 #undef USE_WINSOCK 207 208 #ifdef HAVE_WINSOCK2_H 209 # define USE_WINSOCK 2 210 #else 211 # ifdef HAVE_WINSOCK_H 212 # define USE_WINSOCK 1 213 # endif 214 #endif 215 216 #ifdef HAVE_EXTRA_STRICMP_H 217 # include <extra/stricmp.h> 218 #endif 219 220 #ifdef HAVE_EXTRA_STRDUP_H 221 # include <extra/strdup.h> 222 #endif 223 224 #ifdef TPF 225 # include <strings.h> /* for bzero, strcasecmp, and strncasecmp */ 226 # include <string.h> /* for strcpy and strlen */ 227 # include <stdlib.h> /* for rand and srand */ 228 # include <sys/socket.h> /* for select and ioctl*/ 229 # include <netdb.h> /* for in_addr_t definition */ 230 # include <tpf/sysapi.h> /* for tpf_process_signals */ 231 #endif 232 233 #include <stdio.h> 234 #ifdef HAVE_ASSERT_H 235 #include <assert.h> 236 #endif 237 #include <errno.h> 238 239 #ifdef __TANDEM /* for nsr-tandem-nsk systems */ 240 #include <floss.h> 241 #endif 242 243 #ifndef STDC_HEADERS /* no standard C headers! */ 244 #include <curl/stdcheaders.h> 245 #endif 246 247 /* 248 * PellesC kludge section (yikes); 249 * - It has 'ssize_t', but it is in <unistd.h>. The way the headers 250 * on Win32 are included, forces me to include this header here. 251 * - sys_nerr, EINTR is missing in v4.0 or older. 252 */ 253 #ifdef __POCC__ 254 #include <sys/types.h> 255 #include <unistd.h> 256 #if (__POCC__ <= 400) 257 #define sys_nerr EILSEQ /* for strerror.c */ 258 #define EINTR -1 /* for select.c */ 259 #endif 260 #endif 261 262 /* 263 * Salford-C kludge section (mostly borrowed from wxWidgets). 264 */ 265 #ifdef __SALFORDC__ 266 #pragma suppress 353 /* Possible nested comments */ 267 #pragma suppress 593 /* Define not used */ 268 #pragma suppress 61 /* enum has no name */ 269 #pragma suppress 106 /* unnamed, unused parameter */ 270 #include <clib.h> 271 #endif 272 273 /* 274 * Large file (>2Gb) support using WIN32 functions. 275 */ 276 277 #ifdef USE_WIN32_LARGE_FILES 278 # include <io.h> 279 # include <sys/types.h> 280 # include <sys/stat.h> 281 # define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence) 282 # define fstat(fdes,stp) _fstati64(fdes, stp) 283 # define stat(fname,stp) _stati64(fname, stp) 284 # define struct_stat struct _stati64 285 #endif 286 287 /* 288 * Small file (<2Gb) support using WIN32 functions. 289 */ 290 291 #ifdef USE_WIN32_SMALL_FILES 292 # include <io.h> 293 # include <sys/types.h> 294 # include <sys/stat.h> 295 # define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence) 296 # define fstat(fdes,stp) _fstat(fdes, stp) 297 # define stat(fname,stp) _stat(fname, stp) 298 # define struct_stat struct _stat 299 #endif 300 301 #ifndef struct_stat 302 # define struct_stat struct stat 303 #endif 304 305 /* 306 * Default sizeof(off_t) in case it hasn't been defined in config file. 307 */ 308 309 #ifndef SIZEOF_OFF_T 310 # if defined(__VMS) && (defined(__alpha) || defined(__ia64)) 311 # if defined(_LARGEFILE) 312 # define SIZEOF_OFF_T 8 313 # endif 314 # elif defined(__OS400__) && defined(__ILEC400__) 315 # if defined(_LARGE_FILES) 316 # define SIZEOF_OFF_T 8 317 # endif 318 # elif defined(__MVS__) && defined(__IBMC__) 319 # if defined(_LP64) || defined(_LARGE_FILES) 320 # define SIZEOF_OFF_T 8 321 # endif 322 # elif defined(__370__) && defined(__IBMC__) 323 # if defined(_LP64) || defined(_LARGE_FILES) 324 # define SIZEOF_OFF_T 8 325 # endif 326 # endif 327 # ifndef SIZEOF_OFF_T 328 # define SIZEOF_OFF_T 4 329 # endif 330 #endif 331 332 /* Below we define some functions. They should 333 1. close a socket 334 335 4. set the SIGALRM signal timeout 336 5. set dir/file naming defines 337 */ 338 339 #ifdef WIN32 340 341 # if !defined(__CYGWIN__) 342 # define sclose(x) closesocket(x) 343 # else 344 # define sclose(x) close(x) 345 # endif 346 347 # define DIR_CHAR "\\" 348 # define DOT_CHAR "_" 349 350 #else /* WIN32 */ 351 352 # ifdef MSDOS /* Watt-32 */ 353 354 # include <sys/ioctl.h> 355 # define sclose(x) close_s(x) 356 # define select(n,r,w,x,t) select_s(n,r,w,x,t) 357 # define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z)) 358 # include <tcp.h> 359 # ifdef word 360 # undef word 361 # endif 362 # ifdef byte 363 # undef byte 364 # endif 365 366 # else /* MSDOS */ 367 368 # ifdef __BEOS__ 369 # define sclose(x) closesocket(x) 370 # else /* __BEOS__ */ 371 # define sclose(x) close(x) 372 # endif /* __BEOS__ */ 373 374 # endif /* MSDOS */ 375 376 # ifdef _AMIGASF 377 # undef sclose 378 # define sclose(x) CloseSocket(x) 379 # endif 380 381 # ifdef __minix 382 /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */ 383 extern char * strtok_r(char *s, const char *delim, char **last); 384 extern struct tm * gmtime_r(const time_t * const timep, struct tm *tmp); 385 # endif 386 387 # define DIR_CHAR "/" 388 # ifndef DOT_CHAR 389 # define DOT_CHAR "." 390 # endif 391 392 # ifdef MSDOS 393 # undef DOT_CHAR 394 # define DOT_CHAR "_" 395 # endif 396 397 # ifndef fileno /* sunos 4 have this as a macro! */ 398 int fileno( FILE *stream); 399 # endif 400 401 #endif /* WIN32 */ 402 403 #if defined(WIN32) && !defined(__CYGWIN__) && !defined(USE_ARES) && \ 404 !defined(__LCC__) /* lcc-win32 doesn't have _beginthreadex() */ 405 #ifdef ENABLE_IPV6 406 #define USE_THREADING_GETADDRINFO 407 #else 408 #define USE_THREADING_GETHOSTBYNAME /* Cygwin uses alarm() function */ 409 #endif 410 #endif 411 412 /* "cl -ML" or "cl -MLd" implies a single-threaded runtime library where 413 _beginthreadex() is not available */ 414 #if (defined(_MSC_VER) && !defined(__POCC__)) && !defined(_MT) && !defined(USE_ARES) 415 #undef USE_THREADING_GETADDRINFO 416 #undef USE_THREADING_GETHOSTBYNAME 417 #define CURL_NO__BEGINTHREADEX 418 #endif 419 420 /* 421 * msvc 6.0 does not have struct sockaddr_storage and 422 * does not define IPPROTO_ESP in winsock2.h. But both 423 * are available if PSDK is properly installed. 424 */ 425 426 #ifdef _MSC_VER 427 #if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP)) 428 #undef HAVE_STRUCT_SOCKADDR_STORAGE 429 #endif 430 #endif 431 432 #ifdef NETWARE 433 int netware_init(void); 434 #ifndef __NOVELL_LIBC__ 435 #include <sys/bsdskt.h> 436 #include <sys/timeval.h> 437 #endif 438 #endif 439 440 #if defined(HAVE_LIBIDN) && defined(HAVE_TLD_H) 441 /* The lib was present and the tld.h header (which is missing in libidn 0.3.X 442 but we only work with libidn 0.4.1 or later) */ 443 #define USE_LIBIDN 444 #endif 445 446 #ifndef SIZEOF_TIME_T 447 /* assume default size of time_t to be 32 bit */ 448 #define SIZEOF_TIME_T 4 449 #endif 450 451 #define LIBIDN_REQUIRED_VERSION "0.4.1" 452 453 #if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || defined(USE_QSOSSL) 454 #define USE_SSL /* SSL support has been enabled */ 455 #endif 456 457 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM) 458 #if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI) || defined(USE_GNUTLS) 459 #define USE_NTLM 460 #endif 461 #endif 462 463 /* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */ 464 #if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE) 465 #define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE") 466 #endif 467 468 /* 469 * Include macros and defines that should only be processed once. 470 */ 471 472 #ifndef __SETUP_ONCE_H 473 #include "setup_once.h" 474 #endif 475 476 #ifdef __SYMBIAN32__ 477 #ifndef bool 478 typedef int bool; 479 #endif 480 #endif 481 482 #endif /* __LIB_CURL_SETUP_H */ 483