blob: ca98ad7e0d4d66db8e48152a853949cae36020ab [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
359/* Below we define some functions. They should
360
361 4. set the SIGALRM signal timeout
362 5. set dir/file naming defines
363 */
364
365#ifdef WIN32
366
367# define DIR_CHAR "\\"
368# define DOT_CHAR "_"
369
370#else /* WIN32 */
371
372# ifdef MSDOS /* Watt-32 */
373
374# include <sys/ioctl.h>
375# define select(n,r,w,x,t) select_s(n,r,w,x,t)
376# define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
377# include <tcp.h>
378# ifdef word
379# undef word
380# endif
381# ifdef byte
382# undef byte
383# endif
384
385# endif /* MSDOS */
386
387# ifdef __minix
388 /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
389 extern char * strtok_r(char *s, const char *delim, char **last);
390 extern struct tm * gmtime_r(const time_t * const timep, struct tm *tmp);
391# endif
392
393# define DIR_CHAR "/"
394# ifndef DOT_CHAR
395# define DOT_CHAR "."
396# endif
397
398# ifdef MSDOS
399# undef DOT_CHAR
400# define DOT_CHAR "_"
401# endif
402
403# ifndef fileno /* sunos 4 have this as a macro! */
404 int fileno( FILE *stream);
405# endif
406
407#endif /* WIN32 */
408
409/*
410 * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
411 * defined in ws2tcpip.h as well as to provide IPv6 support.
412 */
413
414#if defined(_MSC_VER) && !defined(__POCC__)
415# if !defined(HAVE_WS2TCPIP_H) || \
416 ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN))
417# undef HAVE_GETADDRINFO_THREADSAFE
418# undef HAVE_FREEADDRINFO
419# undef HAVE_GETADDRINFO
420# undef HAVE_GETNAMEINFO
421# undef ENABLE_IPV6
422# endif
423#endif
424
425/* ---------------------------------------------------------------- */
426/* resolver specialty compile-time defines */
427/* CURLRES_* defines to use in the host*.c sources */
428/* ---------------------------------------------------------------- */
429
430/*
431 * lcc-win32 doesn't have _beginthreadex(), lacks threads support.
432 */
433
434#if defined(__LCC__) && defined(WIN32)
435# undef USE_THREADS_POSIX
436# undef USE_THREADS_WIN32
437#endif
438
439/*
440 * MSVC threads support requires a multi-threaded runtime library.
441 * _beginthreadex() is not available in single-threaded ones.
442 */
443
444#if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT)
445# undef USE_THREADS_POSIX
446# undef USE_THREADS_WIN32
447#endif
448
449/*
450 * Mutually exclusive CURLRES_* definitions.
451 */
452
453#ifdef USE_ARES
454# define CURLRES_ASYNCH
455# define CURLRES_ARES
456#elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
457# define CURLRES_ASYNCH
458# define CURLRES_THREADED
459#else
460# define CURLRES_SYNCH
461#endif
462
463#ifdef ENABLE_IPV6
464# define CURLRES_IPV6
465#else
466# define CURLRES_IPV4
467#endif
468
469/* ---------------------------------------------------------------- */
470
471/*
472 * When using WINSOCK, TELNET protocol requires WINSOCK2 API.
473 */
474
475#if defined(USE_WINSOCK) && (USE_WINSOCK != 2)
476# define CURL_DISABLE_TELNET 1
477#endif
478
479/*
480 * msvc 6.0 does not have struct sockaddr_storage and
481 * does not define IPPROTO_ESP in winsock2.h. But both
482 * are available if PSDK is properly installed.
483 */
484
485#if defined(_MSC_VER) && !defined(__POCC__)
486# if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP))
487# undef HAVE_STRUCT_SOCKADDR_STORAGE
488# endif
489#endif
490
491/*
492 * Intentionally fail to build when using msvc 6.0 without PSDK installed.
493 * The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK
494 * in lib/config-win32.h although absolutely discouraged and unsupported.
495 */
496
497#if defined(_MSC_VER) && !defined(__POCC__)
498# if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_))
499# if !defined(ALLOW_MSVC6_WITHOUT_PSDK)
500# error MSVC 6.0 requires 'February 2003 Platform SDK' a.k.a. 'Windows Server 2003 PSDK'
501# else
502# define CURL_DISABLE_LDAP 1
503# endif
504# endif
505#endif
506
507#ifdef NETWARE
508int netware_init(void);
509#ifndef __NOVELL_LIBC__
510#include <sys/bsdskt.h>
511#include <sys/timeval.h>
512#endif
513#endif
514
515#if defined(HAVE_LIBIDN) && defined(HAVE_TLD_H)
516/* The lib was present and the tld.h header (which is missing in libidn 0.3.X
517 but we only work with libidn 0.4.1 or later) */
518#define USE_LIBIDN
519#endif
520
521#ifndef SIZEOF_TIME_T
522/* assume default size of time_t to be 32 bit */
523#define SIZEOF_TIME_T 4
524#endif
525
526#define LIBIDN_REQUIRED_VERSION "0.4.1"
527
528#if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || defined(USE_QSOSSL)
529#define USE_SSL /* SSL support has been enabled */
530#endif
531
532#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM)
533#if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI) || defined(USE_GNUTLS)
534#define USE_NTLM
535#endif
536#endif
537
538/* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */
539#if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE)
540#define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE")
541#endif
542
543/*
544 * Include macros and defines that should only be processed once.
545 */
546
547#ifndef __SETUP_ONCE_H
548#include "setup_once.h"
549#endif
550
551#endif /* HEADER_CURL_LIB_SETUP_H */