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 HAVE_EXTRA_STRICMP_H
255#  include <extra/stricmp.h>
256#endif
257
258#ifdef HAVE_EXTRA_STRDUP_H
259#  include <extra/strdup.h>
260#endif
261
262#ifdef TPF
263#  include <strings.h>    /* for bzero, strcasecmp, and strncasecmp */
264#  include <string.h>     /* for strcpy and strlen */
265#  include <stdlib.h>     /* for rand and srand */
266#  include <sys/socket.h> /* for select and ioctl*/
267#  include <netdb.h>      /* for in_addr_t definition */
268#  include <tpf/sysapi.h> /* for tpf_process_signals */
269   /* change which select is used for libcurl */
270#  define select(a,b,c,d,e) tpf_select_libcurl(a,b,c,d,e)
271#endif
272
273#ifdef __VXWORKS__
274#  include <sockLib.h>    /* for generic BSD socket functions */
275#  include <ioLib.h>      /* for basic I/O interface functions */
276#endif
277
278#include <stdio.h>
279#ifdef HAVE_ASSERT_H
280#include <assert.h>
281#endif
282#include <errno.h>
283
284#ifdef __TANDEM /* for nsr-tandem-nsk systems */
285#include <floss.h>
286#endif
287
288#ifndef STDC_HEADERS /* no standard C headers! */
289#include <curl/stdcheaders.h>
290#endif
291
292#ifdef __POCC__
293#  include <sys/types.h>
294#  include <unistd.h>
295#  define sys_nerr EILSEQ
296#endif
297
298/*
299 * Salford-C kludge section (mostly borrowed from wxWidgets).
300 */
301#ifdef __SALFORDC__
302  #pragma suppress 353             /* Possible nested comments */
303  #pragma suppress 593             /* Define not used */
304  #pragma suppress 61              /* enum has no name */
305  #pragma suppress 106             /* unnamed, unused parameter */
306  #include <clib.h>
307#endif
308
309/*
310 * Large file (>2Gb) support using WIN32 functions.
311 */
312
313#ifdef USE_WIN32_LARGE_FILES
314#  include <io.h>
315#  include <sys/types.h>
316#  include <sys/stat.h>
317#  define lseek(fdes,offset,whence)  _lseeki64(fdes, offset, whence)
318#  define fstat(fdes,stp)            _fstati64(fdes, stp)
319#  define stat(fname,stp)            _stati64(fname, stp)
320#  define struct_stat                struct _stati64
321#  define LSEEK_ERROR                (__int64)-1
322#endif
323
324/*
325 * Small file (<2Gb) support using WIN32 functions.
326 */
327
328#ifdef USE_WIN32_SMALL_FILES
329#  include <io.h>
330#  include <sys/types.h>
331#  include <sys/stat.h>
332#  define lseek(fdes,offset,whence)  _lseek(fdes, (long)offset, whence)
333#  define fstat(fdes,stp)            _fstat(fdes, stp)
334#  define stat(fname,stp)            _stat(fname, stp)
335#  define struct_stat                struct _stat
336#  define LSEEK_ERROR                (long)-1
337#endif
338
339#ifndef struct_stat
340#  define struct_stat struct stat
341#endif
342
343#ifndef LSEEK_ERROR
344#  define LSEEK_ERROR (off_t)-1
345#endif
346
347/*
348 * Default sizeof(off_t) in case it hasn't been defined in config file.
349 */
350
351#ifndef SIZEOF_OFF_T
352#  if defined(__VMS) && !defined(__VAX)
353#    if defined(_LARGEFILE)
354#      define SIZEOF_OFF_T 8
355#    endif
356#  elif defined(__OS400__) && defined(__ILEC400__)
357#    if defined(_LARGE_FILES)
358#      define SIZEOF_OFF_T 8
359#    endif
360#  elif defined(__MVS__) && defined(__IBMC__)
361#    if defined(_LP64) || defined(_LARGE_FILES)
362#      define SIZEOF_OFF_T 8
363#    endif
364#  elif defined(__370__) && defined(__IBMC__)
365#    if defined(_LP64) || defined(_LARGE_FILES)
366#      define SIZEOF_OFF_T 8
367#    endif
368#  endif
369#  ifndef SIZEOF_OFF_T
370#    define SIZEOF_OFF_T 4
371#  endif
372#endif
373
374/*
375 * Arg 2 type for gethostname in case it hasn't been defined in config file.
376 */
377
378#ifndef GETHOSTNAME_TYPE_ARG2
379#  ifdef USE_WINSOCK
380#    define GETHOSTNAME_TYPE_ARG2 int
381#  else
382#    define GETHOSTNAME_TYPE_ARG2 size_t
383#  endif
384#endif
385
386/* Below we define some functions. They should
387
388   4. set the SIGALRM signal timeout
389   5. set dir/file naming defines
390   */
391
392#ifdef WIN32
393
394#  define DIR_CHAR      "\\"
395#  define DOT_CHAR      "_"
396
397#else /* WIN32 */
398
399#  ifdef MSDOS  /* Watt-32 */
400
401#    include <sys/ioctl.h>
402#    define select(n,r,w,x,t) select_s(n,r,w,x,t)
403#    define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
404#    include <tcp.h>
405#    ifdef word
406#      undef word
407#    endif
408#    ifdef byte
409#      undef byte
410#    endif
411
412#  endif /* MSDOS */
413
414#  ifdef __minix
415     /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
416     extern char * strtok_r(char *s, const char *delim, char **last);
417     extern struct tm * gmtime_r(const time_t * const timep, struct tm *tmp);
418#  endif
419
420#  define DIR_CHAR      "/"
421#  ifndef DOT_CHAR
422#    define DOT_CHAR      "."
423#  endif
424
425#  ifdef MSDOS
426#    undef DOT_CHAR
427#    define DOT_CHAR      "_"
428#  endif
429
430#  ifndef fileno /* sunos 4 have this as a macro! */
431     int fileno( FILE *stream);
432#  endif
433
434#endif /* WIN32 */
435
436/*
437 * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
438 * defined in ws2tcpip.h as well as to provide IPv6 support.
439 */
440
441#if defined(_MSC_VER) && !defined(__POCC__)
442#  if !defined(HAVE_WS2TCPIP_H) || \
443     ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN))
444#    undef HAVE_GETADDRINFO_THREADSAFE
445#    undef HAVE_FREEADDRINFO
446#    undef HAVE_GETADDRINFO
447#    undef HAVE_GETNAMEINFO
448#    undef ENABLE_IPV6
449#  endif
450#endif
451
452/* ---------------------------------------------------------------- */
453/*             resolver specialty compile-time defines              */
454/*         CURLRES_* defines to use in the host*.c sources          */
455/* ---------------------------------------------------------------- */
456
457/*
458 * lcc-win32 doesn't have _beginthreadex(), lacks threads support.
459 */
460
461#if defined(__LCC__) && defined(WIN32)
462#  undef USE_THREADS_POSIX
463#  undef USE_THREADS_WIN32
464#endif
465
466/*
467 * MSVC threads support requires a multi-threaded runtime library.
468 * _beginthreadex() is not available in single-threaded ones.
469 */
470
471#if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT)
472#  undef USE_THREADS_POSIX
473#  undef USE_THREADS_WIN32
474#endif
475
476/*
477 * Mutually exclusive CURLRES_* definitions.
478 */
479
480#ifdef USE_ARES
481#  define CURLRES_ASYNCH
482#  define CURLRES_ARES
483#elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
484#  define CURLRES_ASYNCH
485#  define CURLRES_THREADED
486#else
487#  define CURLRES_SYNCH
488#endif
489
490#ifdef ENABLE_IPV6
491#  define CURLRES_IPV6
492#else
493#  define CURLRES_IPV4
494#endif
495
496/* ---------------------------------------------------------------- */
497
498/*
499 * When using WINSOCK, TELNET protocol requires WINSOCK2 API.
500 */
501
502#if defined(USE_WINSOCK) && (USE_WINSOCK != 2)
503#  define CURL_DISABLE_TELNET 1
504#endif
505
506/*
507 * msvc 6.0 does not have struct sockaddr_storage and
508 * does not define IPPROTO_ESP in winsock2.h. But both
509 * are available if PSDK is properly installed.
510 */
511
512#if defined(_MSC_VER) && !defined(__POCC__)
513#  if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP))
514#    undef HAVE_STRUCT_SOCKADDR_STORAGE
515#  endif
516#endif
517
518/*
519 * Intentionally fail to build when using msvc 6.0 without PSDK installed.
520 * The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK
521 * in lib/config-win32.h although absolutely discouraged and unsupported.
522 */
523
524#if defined(_MSC_VER) && !defined(__POCC__)
525#  if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_))
526#    if !defined(ALLOW_MSVC6_WITHOUT_PSDK)
527#      error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. \
528             "Windows Server 2003 PSDK"
529#    else
530#      define CURL_DISABLE_LDAP 1
531#    endif
532#  endif
533#endif
534
535#ifdef NETWARE
536int netware_init(void);
537#ifndef __NOVELL_LIBC__
538#include <sys/bsdskt.h>
539#include <sys/timeval.h>
540#endif
541#endif
542
543#if defined(HAVE_LIBIDN) && defined(HAVE_TLD_H)
544/* The lib was present and the tld.h header (which is missing in libidn 0.3.X
545   but we only work with libidn 0.4.1 or later) */
546#define USE_LIBIDN
547#endif
548
549#ifndef SIZEOF_TIME_T
550/* assume default size of time_t to be 32 bit */
551#define SIZEOF_TIME_T 4
552#endif
553
554#define LIBIDN_REQUIRED_VERSION "0.4.1"
555
556#if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || \
557    defined(USE_QSOSSL) || defined(USE_POLARSSL) || defined(USE_AXTLS) || \
558    defined(USE_CYASSL)
559#define USE_SSL    /* SSL support has been enabled */
560#endif
561
562#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
563#define USE_HTTP_NEGOTIATE
564#endif
565
566#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM)
567#if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI) || \
568   defined(USE_GNUTLS) || defined(USE_NSS)
569#define USE_NTLM
570#endif
571#endif
572
573/* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */
574#if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE)
575#define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE")
576#endif
577
578/* Define S_ISREG if not defined by system headers, f.e. MSVC */
579#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
580#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
581#endif
582
583/*
584 * Include macros and defines that should only be processed once.
585 */
586
587#ifndef __SETUP_ONCE_H
588#include "setup_once.h"
589#endif
590
591#endif /* HEADER_CURL_LIB_SETUP_H */
592