1 #ifndef HEADER_CURL_LIB_SETUP_H
2 #define HEADER_CURL_LIB_SETUP_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
26 * Define WIN32 when build target is Win32 API
29 #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && !defined(__SYMBIAN32__)
34 * Include configuration script results or hand-crafted
35 * configuration file for platforms which lack config tool.
40 #include "curl_config.h"
42 #else /* HAVE_CONFIG_H */
45 # include "config-win32ce.h"
48 # include "config-win32.h"
52 #if defined(macintosh) && defined(__MRC__)
53 # include "config-mac.h"
61 # include "config-symbian.h"
65 # include "config-os400.h"
69 # include "config-tpf.h"
73 # include "config-vxworks.h"
76 #endif /* HAVE_CONFIG_H */
78 /* ================================================================ */
79 /* Definition of preprocessor macros/symbols which modify compiler */
80 /* behavior or generated code characteristics must be done here, */
81 /* as appropriate, before any system header file is included. It is */
82 /* also possible to have them defined in the config file included */
83 /* before this point. As a result of all this we frown inclusion of */
84 /* system header files in our config files, avoid this at any cost. */
85 /* ================================================================ */
88 * AIX 4.3 and newer needs _THREAD_SAFE defined to build
89 * proper reentrant code. Others may also need it.
92 #ifdef NEED_THREAD_SAFE
99 * Tru64 needs _REENTRANT set for a few function prototypes and
100 * things to appear in the system header files. Unixware needs it
101 * to build proper reentrant code. Others may also need it.
104 #ifdef NEED_REENTRANT
110 /* ================================================================ */
111 /* If you need to include a system header file for your platform, */
112 /* please, do it beyond the point further indicated in this file. */
113 /* ================================================================ */
116 * libcurl's external interface definitions are also used internally,
117 * and might also include required system header files to define them.
120 #include <curl/curlbuild.h>
123 * Compile time sanity checks must also be done when building the library.
126 #include <curl/curlrules.h>
129 * Ensure that no one is using the old SIZEOF_CURL_OFF_T macro
132 #ifdef SIZEOF_CURL_OFF_T
133 # error "SIZEOF_CURL_OFF_T shall not be defined!"
134 Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined
138 * Set up internal curl_off_t formatting string directives for
139 * exclusive use with libcurl's internal *printf functions.
143 # error "FORMAT_OFF_T shall not be defined before this point!"
144 Error Compilation_aborted_FORMAT_OFF_T_already_defined
148 # error "FORMAT_OFF_TU shall not be defined before this point!"
149 Error Compilation_aborted_FORMAT_OFF_TU_already_defined
152 #if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
153 # define FORMAT_OFF_T "lld"
154 # define FORMAT_OFF_TU "llu"
156 # define FORMAT_OFF_T "ld"
157 # define FORMAT_OFF_TU "lu"
161 * Disable other protocols when http is the only one desired.
165 # define CURL_DISABLE_TFTP
166 # define CURL_DISABLE_FTP
167 # define CURL_DISABLE_LDAP
168 # define CURL_DISABLE_TELNET
169 # define CURL_DISABLE_DICT
170 # define CURL_DISABLE_FILE
171 # define CURL_DISABLE_RTSP
175 * When http is disabled rtsp is not supported.
178 #if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP)
179 # define CURL_DISABLE_RTSP
182 /* ================================================================ */
183 /* No system header file shall be included in this file before this */
184 /* point. The only allowed ones are those included from curlbuild.h */
185 /* ================================================================ */
188 * OS/400 setup file includes some system headers.
192 # include "setup-os400.h"
196 * Include header files for windows builds before redefining anything.
197 * Use this preprocessor block only to include or exclude windows.h,
198 * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
199 * to any other further and independent block. Under Cygwin things work
200 * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
201 * never be included when __CYGWIN__ is defined. configure script takes
202 * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
203 * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
206 #ifdef HAVE_WINDOWS_H
207 # ifndef WIN32_LEAN_AND_MEAN
208 # define WIN32_LEAN_AND_MEAN
210 # include <windows.h>
211 # ifdef HAVE_WINSOCK2_H
212 # include <winsock2.h>
213 # ifdef HAVE_WS2TCPIP_H
214 # include <ws2tcpip.h>
217 # ifdef HAVE_WINSOCK_H
218 # include <winsock.h>
224 * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
225 * define USE_WINSOCK to 1 if we have and use WINSOCK API, else
226 * undefine USE_WINSOCK.
231 #ifdef HAVE_WINSOCK2_H
232 # define USE_WINSOCK 2
234 # ifdef HAVE_WINSOCK_H
235 # define USE_WINSOCK 1
239 #ifdef HAVE_EXTRA_STRICMP_H
240 # include <extra/stricmp.h>
243 #ifdef HAVE_EXTRA_STRDUP_H
244 # include <extra/strdup.h>
248 # include <strings.h> /* for bzero, strcasecmp, and strncasecmp */
249 # include <string.h> /* for strcpy and strlen */
250 # include <stdlib.h> /* for rand and srand */
251 # include <sys/socket.h> /* for select and ioctl*/
252 # include <netdb.h> /* for in_addr_t definition */
253 # include <tpf/sysapi.h> /* for tpf_process_signals */
254 /* change which select is used for libcurl */
255 # define select(a,b,c,d,e) tpf_select_libcurl(a,b,c,d,e)
259 # include <sockLib.h> /* for generic BSD socket functions */
260 # include <ioLib.h> /* for basic I/O interface functions */
269 #ifdef __TANDEM /* for nsr-tandem-nsk systems */
273 #ifndef STDC_HEADERS /* no standard C headers! */
274 #include <curl/stdcheaders.h>
278 # include <sys/types.h>
280 # define sys_nerr EILSEQ
284 * Salford-C kludge section (mostly borrowed from wxWidgets).
287 #pragma suppress 353 /* Possible nested comments */
288 #pragma suppress 593 /* Define not used */
289 #pragma suppress 61 /* enum has no name */
290 #pragma suppress 106 /* unnamed, unused parameter */
295 * Large file (>2Gb) support using WIN32 functions.
298 #ifdef USE_WIN32_LARGE_FILES
300 # include <sys/types.h>
301 # include <sys/stat.h>
302 # define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence)
303 # define fstat(fdes,stp) _fstati64(fdes, stp)
304 # define stat(fname,stp) _stati64(fname, stp)
305 # define struct_stat struct _stati64
306 # define LSEEK_ERROR (__int64)-1
310 * Small file (<2Gb) support using WIN32 functions.
313 #ifdef USE_WIN32_SMALL_FILES
315 # include <sys/types.h>
316 # include <sys/stat.h>
317 # define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence)
318 # define fstat(fdes,stp) _fstat(fdes, stp)
319 # define stat(fname,stp) _stat(fname, stp)
320 # define struct_stat struct _stat
321 # define LSEEK_ERROR (long)-1
325 # define struct_stat struct stat
329 # define LSEEK_ERROR (off_t)-1
333 * Default sizeof(off_t) in case it hasn't been defined in config file.
337 # if defined(__VMS) && !defined(__VAX)
338 # if defined(_LARGEFILE)
339 # define SIZEOF_OFF_T 8
341 # elif defined(__OS400__) && defined(__ILEC400__)
342 # if defined(_LARGE_FILES)
343 # define SIZEOF_OFF_T 8
345 # elif defined(__MVS__) && defined(__IBMC__)
346 # if defined(_LP64) || defined(_LARGE_FILES)
347 # define SIZEOF_OFF_T 8
349 # elif defined(__370__) && defined(__IBMC__)
350 # if defined(_LP64) || defined(_LARGE_FILES)
351 # define SIZEOF_OFF_T 8
354 # ifndef SIZEOF_OFF_T
355 # define SIZEOF_OFF_T 4
360 * Arg 2 type for gethostname in case it hasn't been defined in config file.
363 #ifndef GETHOSTNAME_TYPE_ARG2
365 # define GETHOSTNAME_TYPE_ARG2 int
367 # define GETHOSTNAME_TYPE_ARG2 size_t
371 /* Below we define some functions. They should
373 4. set the SIGALRM signal timeout
374 5. set dir/file naming defines
379 # define DIR_CHAR "\\"
380 # define DOT_CHAR "_"
384 # ifdef MSDOS /* Watt-32 */
386 # include <sys/ioctl.h>
387 # define select(n,r,w,x,t) select_s(n,r,w,x,t)
388 # define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
400 /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
401 extern char * strtok_r(char *s, const char *delim, char **last);
402 extern struct tm * gmtime_r(const time_t * const timep, struct tm *tmp);
405 # define DIR_CHAR "/"
407 # define DOT_CHAR "."
412 # define DOT_CHAR "_"
415 # ifndef fileno /* sunos 4 have this as a macro! */
416 int fileno( FILE *stream);
422 * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
423 * defined in ws2tcpip.h as well as to provide IPv6 support.
426 #if defined(_MSC_VER) && !defined(__POCC__)
427 # if !defined(HAVE_WS2TCPIP_H) || \
428 ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN))
429 # undef HAVE_GETADDRINFO_THREADSAFE
430 # undef HAVE_FREEADDRINFO
431 # undef HAVE_GETADDRINFO
432 # undef HAVE_GETNAMEINFO
437 /* ---------------------------------------------------------------- */
438 /* resolver specialty compile-time defines */
439 /* CURLRES_* defines to use in the host*.c sources */
440 /* ---------------------------------------------------------------- */
443 * lcc-win32 doesn't have _beginthreadex(), lacks threads support.
446 #if defined(__LCC__) && defined(WIN32)
447 # undef USE_THREADS_POSIX
448 # undef USE_THREADS_WIN32
452 * MSVC threads support requires a multi-threaded runtime library.
453 * _beginthreadex() is not available in single-threaded ones.
456 #if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT)
457 # undef USE_THREADS_POSIX
458 # undef USE_THREADS_WIN32
462 * Mutually exclusive CURLRES_* definitions.
466 # define CURLRES_ASYNCH
467 # define CURLRES_ARES
468 #elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
469 # define CURLRES_ASYNCH
470 # define CURLRES_THREADED
472 # define CURLRES_SYNCH
476 # define CURLRES_IPV6
478 # define CURLRES_IPV4
481 /* ---------------------------------------------------------------- */
484 * When using WINSOCK, TELNET protocol requires WINSOCK2 API.
487 #if defined(USE_WINSOCK) && (USE_WINSOCK != 2)
488 # define CURL_DISABLE_TELNET 1
492 * msvc 6.0 does not have struct sockaddr_storage and
493 * does not define IPPROTO_ESP in winsock2.h. But both
494 * are available if PSDK is properly installed.
497 #if defined(_MSC_VER) && !defined(__POCC__)
498 # if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP))
499 # undef HAVE_STRUCT_SOCKADDR_STORAGE
504 * Intentionally fail to build when using msvc 6.0 without PSDK installed.
505 * The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK
506 * in lib/config-win32.h although absolutely discouraged and unsupported.
509 #if defined(_MSC_VER) && !defined(__POCC__)
510 # if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_))
511 # if !defined(ALLOW_MSVC6_WITHOUT_PSDK)
512 # error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. "Windows Server 2003 PSDK"
514 # define CURL_DISABLE_LDAP 1
520 int netware_init(void);
521 #ifndef __NOVELL_LIBC__
522 #include <sys/bsdskt.h>
523 #include <sys/timeval.h>
527 #if defined(HAVE_LIBIDN) && defined(HAVE_TLD_H)
528 /* The lib was present and the tld.h header (which is missing in libidn 0.3.X
529 but we only work with libidn 0.4.1 or later) */
533 #ifndef SIZEOF_TIME_T
534 /* assume default size of time_t to be 32 bit */
535 #define SIZEOF_TIME_T 4
538 #define LIBIDN_REQUIRED_VERSION "0.4.1"
540 #if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || defined(USE_QSOSSL) || defined(USE_POLARSSL)
541 #define USE_SSL /* SSL support has been enabled */
544 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM)
545 #if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI) || defined(USE_GNUTLS) || defined(USE_NSS)
550 /* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */
551 #if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE)
552 #define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE")
555 /* Define S_ISREG if not defined by system headers, f.e. MSVC */
556 #if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
557 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
561 * Include macros and defines that should only be processed once.
564 #ifndef __SETUP_ONCE_H
565 #include "setup_once.h"
568 #endif /* HEADER_CURL_LIB_SETUP_H */