blob: cc016c9cd37457b9dc2a1be823f4103a79823e3c [file] [log] [blame]
Kristian Monsen5ab50182010-05-14 18:53:44 +01001#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 - 2010, 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) && !defined(__SYMBIAN32__)
30#define WIN32
31#endif
32
33/*
34 * Include configuration script results or hand-crafted
35 * configuration file for platforms which lack config tool.
36 */
37
38#ifdef HAVE_CONFIG_H
39
40#include "curl_config.h"
41
42#else /* HAVE_CONFIG_H */
43
44#ifdef _WIN32_WCE
45# include "config-win32ce.h"
46#else
47# ifdef WIN32
48# include "config-win32.h"
49# endif
50#endif
51
52#if defined(macintosh) && defined(__MRC__)
53# include "config-mac.h"
54#endif
55
56#ifdef __AMIGA__
57# include "amigaos.h"
58#endif
59
60#ifdef __SYMBIAN32__
61# include "config-symbian.h"
62#endif
63
64#ifdef __OS400__
65# include "config-os400.h"
66#endif
67
68#ifdef TPF
69# include "config-tpf.h"
70#endif
71
72#ifdef __VXWORKS__
73# include "config-vxworks.h"
74#endif
75
76#endif /* HAVE_CONFIG_H */
77
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/* ================================================================ */
86
87/*
88 * AIX 4.3 and newer needs _THREAD_SAFE defined to build
89 * proper reentrant code. Others may also need it.
90 */
91
92#ifdef NEED_THREAD_SAFE
93# ifndef _THREAD_SAFE
94# define _THREAD_SAFE
95# endif
96#endif
97
98/*
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.
102 */
103
104#ifdef NEED_REENTRANT
105# ifndef _REENTRANT
106# define _REENTRANT
107# endif
108#endif
109
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/* ================================================================ */
114
115/*
116 * libcurl's external interface definitions are also used internally,
117 * and might also include required system header files to define them.
118 */
119
120#include <curl/curlbuild.h>
121
122/*
123 * Compile time sanity checks must also be done when building the library.
124 */
125
126#include <curl/curlrules.h>
127
128/*
129 * Ensure that no one is using the old SIZEOF_CURL_OFF_T macro
130 */
131
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
135#endif
136
137/*
138 * Set up internal curl_off_t formatting string directives for
139 * exclusive use with libcurl's internal *printf functions.
140 */
141
142#ifdef FORMAT_OFF_T
143# error "FORMAT_OFF_T shall not be defined before this point!"
144 Error Compilation_aborted_FORMAT_OFF_T_already_defined
145#endif
146
147#ifdef FORMAT_OFF_TU
148# error "FORMAT_OFF_TU shall not be defined before this point!"
149 Error Compilation_aborted_FORMAT_OFF_TU_already_defined
150#endif
151
152#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
153# define FORMAT_OFF_T "lld"
154# define FORMAT_OFF_TU "llu"
155#else
156# define FORMAT_OFF_T "ld"
157# define FORMAT_OFF_TU "lu"
158#endif
159
160/*
161 * Disable other protocols when http is the only one desired.
162 */
163
164#ifdef HTTP_ONLY
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
172#endif
173
174/*
175 * When http is disabled rtsp is not supported.
176 */
177
178#if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP)
179# define CURL_DISABLE_RTSP
180#endif
181
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/* ================================================================ */
186
187/*
188 * OS/400 setup file includes some system headers.
189 */
190
191#ifdef __OS400__
192# include "setup-os400.h"
193#endif
194
195/*
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.
204 */
205
206#ifdef HAVE_WINDOWS_H
207# ifndef WIN32_LEAN_AND_MEAN
208# define WIN32_LEAN_AND_MEAN
209# endif
210# include <windows.h>
211# ifdef HAVE_WINSOCK2_H
212# include <winsock2.h>
213# ifdef HAVE_WS2TCPIP_H
214# include <ws2tcpip.h>
215# endif
216# else
217# ifdef HAVE_WINSOCK_H
218# include <winsock.h>
219# endif
220# endif
221#endif
222
223/*
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.
227 */
228
229#undef USE_WINSOCK
230
231#ifdef HAVE_WINSOCK2_H
232# define USE_WINSOCK 2
233#else
234# ifdef HAVE_WINSOCK_H
235# define USE_WINSOCK 1
236# endif
237#endif
238
239#ifdef HAVE_EXTRA_STRICMP_H
240# include <extra/stricmp.h>
241#endif
242
243#ifdef HAVE_EXTRA_STRDUP_H
244# include <extra/strdup.h>
245#endif
246
247#ifdef TPF
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)
256#endif
257
258#ifdef __VXWORKS__
259# include <sockLib.h> /* for generic BSD socket functions */
260# include <ioLib.h> /* for basic I/O interface functions */
261#endif
262
263#include <stdio.h>
264#ifdef HAVE_ASSERT_H
265#include <assert.h>
266#endif
267#include <errno.h>
268
269#ifdef __TANDEM /* for nsr-tandem-nsk systems */
270#include <floss.h>
271#endif
272
273#ifndef STDC_HEADERS /* no standard C headers! */
274#include <curl/stdcheaders.h>
275#endif
276
277#ifdef __POCC__
278# include <sys/types.h>
279# include <unistd.h>
280# define sys_nerr EILSEQ
281#endif
282
283/*
284 * Salford-C kludge section (mostly borrowed from wxWidgets).
285 */
286#ifdef __SALFORDC__
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 */
291 #include <clib.h>
292#endif
293
294/*
295 * Large file (>2Gb) support using WIN32 functions.
296 */
297
298#ifdef USE_WIN32_LARGE_FILES
299# include <io.h>
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
307#endif
308
309/*
310 * Small file (<2Gb) support using WIN32 functions.
311 */
312
313#ifdef USE_WIN32_SMALL_FILES
314# include <io.h>
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
322#endif
323
324#ifndef struct_stat
325# define struct_stat struct stat
326#endif
327
328#ifndef LSEEK_ERROR
329# define LSEEK_ERROR (off_t)-1
330#endif
331
332/*
333 * Default sizeof(off_t) in case it hasn't been defined in config file.
334 */
335
336#ifndef SIZEOF_OFF_T
337# if defined(__VMS) && !defined(__VAX)
338# if defined(_LARGEFILE)
339# define SIZEOF_OFF_T 8
340# endif
341# elif defined(__OS400__) && defined(__ILEC400__)
342# if defined(_LARGE_FILES)
343# define SIZEOF_OFF_T 8
344# endif
345# elif defined(__MVS__) && defined(__IBMC__)
346# if defined(_LP64) || defined(_LARGE_FILES)
347# define SIZEOF_OFF_T 8
348# endif
349# elif defined(__370__) && defined(__IBMC__)
350# if defined(_LP64) || defined(_LARGE_FILES)
351# define SIZEOF_OFF_T 8
352# endif
353# endif
354# ifndef SIZEOF_OFF_T
355# define SIZEOF_OFF_T 4
356# endif
357#endif
358
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700359/*
360 * Arg 2 type for gethostname in case it hasn't been defined in config file.
361 */
362
363#ifndef GETHOSTNAME_TYPE_ARG2
364# ifdef USE_WINSOCK
365# define GETHOSTNAME_TYPE_ARG2 int
366# else
367# define GETHOSTNAME_TYPE_ARG2 size_t
368# endif
369#endif
370
Kristian Monsen5ab50182010-05-14 18:53:44 +0100371/* Below we define some functions. They should
372
373 4. set the SIGALRM signal timeout
374 5. set dir/file naming defines
375 */
376
377#ifdef WIN32
378
379# define DIR_CHAR "\\"
380# define DOT_CHAR "_"
381
382#else /* WIN32 */
383
384# ifdef MSDOS /* Watt-32 */
385
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))
389# include <tcp.h>
390# ifdef word
391# undef word
392# endif
393# ifdef byte
394# undef byte
395# endif
396
397# endif /* MSDOS */
398
399# ifdef __minix
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);
403# endif
404
405# define DIR_CHAR "/"
406# ifndef DOT_CHAR
407# define DOT_CHAR "."
408# endif
409
410# ifdef MSDOS
411# undef DOT_CHAR
412# define DOT_CHAR "_"
413# endif
414
415# ifndef fileno /* sunos 4 have this as a macro! */
416 int fileno( FILE *stream);
417# endif
418
419#endif /* WIN32 */
420
421/*
422 * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
423 * defined in ws2tcpip.h as well as to provide IPv6 support.
424 */
425
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
433# undef ENABLE_IPV6
434# endif
435#endif
436
437/* ---------------------------------------------------------------- */
438/* resolver specialty compile-time defines */
439/* CURLRES_* defines to use in the host*.c sources */
440/* ---------------------------------------------------------------- */
441
442/*
443 * lcc-win32 doesn't have _beginthreadex(), lacks threads support.
444 */
445
446#if defined(__LCC__) && defined(WIN32)
447# undef USE_THREADS_POSIX
448# undef USE_THREADS_WIN32
449#endif
450
451/*
452 * MSVC threads support requires a multi-threaded runtime library.
453 * _beginthreadex() is not available in single-threaded ones.
454 */
455
456#if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT)
457# undef USE_THREADS_POSIX
458# undef USE_THREADS_WIN32
459#endif
460
461/*
462 * Mutually exclusive CURLRES_* definitions.
463 */
464
465#ifdef USE_ARES
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
471#else
472# define CURLRES_SYNCH
473#endif
474
475#ifdef ENABLE_IPV6
476# define CURLRES_IPV6
477#else
478# define CURLRES_IPV4
479#endif
480
481/* ---------------------------------------------------------------- */
482
483/*
484 * When using WINSOCK, TELNET protocol requires WINSOCK2 API.
485 */
486
487#if defined(USE_WINSOCK) && (USE_WINSOCK != 2)
488# define CURL_DISABLE_TELNET 1
489#endif
490
491/*
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.
495 */
496
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
500# endif
501#endif
502
503/*
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.
507 */
508
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)
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700512# error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. "Windows Server 2003 PSDK"
Kristian Monsen5ab50182010-05-14 18:53:44 +0100513# else
514# define CURL_DISABLE_LDAP 1
515# endif
516# endif
517#endif
518
519#ifdef NETWARE
520int netware_init(void);
521#ifndef __NOVELL_LIBC__
522#include <sys/bsdskt.h>
523#include <sys/timeval.h>
524#endif
525#endif
526
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) */
530#define USE_LIBIDN
531#endif
532
533#ifndef SIZEOF_TIME_T
534/* assume default size of time_t to be 32 bit */
535#define SIZEOF_TIME_T 4
536#endif
537
538#define LIBIDN_REQUIRED_VERSION "0.4.1"
539
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700540#if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || defined(USE_QSOSSL) || defined(USE_POLARSSL)
Kristian Monsen5ab50182010-05-14 18:53:44 +0100541#define USE_SSL /* SSL support has been enabled */
542#endif
543
544#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM)
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700545#if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI) || defined(USE_GNUTLS) || defined(USE_NSS)
Kristian Monsen5ab50182010-05-14 18:53:44 +0100546#define USE_NTLM
547#endif
548#endif
549
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")
553#endif
554
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700555/* 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)
558#endif
559
Kristian Monsen5ab50182010-05-14 18:53:44 +0100560/*
561 * Include macros and defines that should only be processed once.
562 */
563
564#ifndef __SETUP_ONCE_H
565#include "setup_once.h"
566#endif
567
568#endif /* HEADER_CURL_LIB_SETUP_H */