1#ifndef HEADER_CURL_SRC_SETUP_H
2#define HEADER_CURL_SRC_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#define CURL_NO_OLDIES
26
27/*
28 * Define WIN32 when build target is Win32 API
29 */
30
31#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && \
32  !defined(__SYMBIAN32__)
33#define WIN32
34#endif
35
36/*
37 * Include configuration script results or hand-crafted
38 * configuration file for platforms which lack config tool.
39 */
40
41#ifdef HAVE_CONFIG_H
42#include "curl_config.h"
43#else
44
45#ifdef WIN32
46#include "config-win32.h"
47#endif
48
49#if defined(macintosh) && defined(__MRC__)
50#  include "config-mac.h"
51#endif
52
53#ifdef __riscos__
54#include "config-riscos.h"
55#endif
56
57#ifdef __AMIGA__
58#include "config-amigaos.h"
59#endif
60
61#ifdef __SYMBIAN32__
62#include "config-symbian.h"
63#endif
64
65#ifdef TPF
66#include "config-tpf.h"
67#endif
68
69#endif /* HAVE_CONFIG_H */
70
71/*
72 * AIX 4.3 and newer needs _THREAD_SAFE defined to build
73 * proper reentrant code. Others may also need it.
74 */
75
76#ifdef NEED_THREAD_SAFE
77#  ifndef _THREAD_SAFE
78#    define _THREAD_SAFE
79#  endif
80#endif
81
82/*
83 * Tru64 needs _REENTRANT set for a few function prototypes and
84 * things to appear in the system header files. Unixware needs it
85 * to build proper reentrant code. Others may also need it.
86 */
87
88#ifdef NEED_REENTRANT
89#  ifndef _REENTRANT
90#    define _REENTRANT
91#  endif
92#endif
93
94/*
95 * Include header files for windows builds before redefining anything.
96 * Use this preproessor block only to include or exclude windows.h,
97 * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
98 * to any other further and independent block.  Under Cygwin things work
99 * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
100 * never be included when __CYGWIN__ is defined.  configure script takes
101 * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
102 * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
103 */
104
105#ifdef HAVE_WINDOWS_H
106#  ifndef WIN32_LEAN_AND_MEAN
107#    define WIN32_LEAN_AND_MEAN
108#  endif
109#  include <windows.h>
110#  ifdef HAVE_WINSOCK2_H
111#    include <winsock2.h>
112#    ifdef HAVE_WS2TCPIP_H
113#       include <ws2tcpip.h>
114#    endif
115#  else
116#    ifdef HAVE_WINSOCK_H
117#      include <winsock.h>
118#    endif
119#  endif
120#endif
121
122/*
123 * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
124 * define USE_WINSOCK to 1 if we have and use WINSOCK  API, else
125 * undefine USE_WINSOCK.
126 */
127
128#undef USE_WINSOCK
129
130#ifdef HAVE_WINSOCK2_H
131#  define USE_WINSOCK 2
132#else
133#  ifdef HAVE_WINSOCK_H
134#    define USE_WINSOCK 1
135#  endif
136#endif
137
138#ifdef USE_LWIPSOCK
139#  include <lwip/sockets.h>
140#  include <lwip/netdb.h>
141#endif
142
143#ifdef TPF
144#  include <sys/socket.h>
145   /* change which select is used for the curl command line tool */
146#  define select(a,b,c,d,e) tpf_select_bsd(a,b,c,d,e)
147   /* and turn off the progress meter */
148#  define CONF_DEFAULT (0|CONF_NOPROGRESS)
149#endif
150
151#include <stdio.h>
152#ifdef HAVE_ASSERT_H
153#include <assert.h>
154#endif
155
156
157#ifdef __TANDEM
158#include <floss.h>
159#endif
160
161/*
162 * Large file (>2Gb) support using WIN32 functions.
163 */
164
165#ifdef USE_WIN32_LARGE_FILES
166#  include <io.h>
167#  include <sys/types.h>
168#  include <sys/stat.h>
169#  undef  lseek
170#  define lseek(fdes,offset,whence)  _lseeki64(fdes, offset, whence)
171#  define fstat(fdes,stp)            _fstati64(fdes, stp)
172#  define stat(fname,stp)            _stati64(fname, stp)
173#  define struct_stat                struct _stati64
174#  define LSEEK_ERROR                (__int64)-1
175#endif
176
177/*
178 * Small file (<2Gb) support using WIN32 functions.
179 */
180
181#ifdef USE_WIN32_SMALL_FILES
182#  include <io.h>
183#  include <sys/types.h>
184#  include <sys/stat.h>
185#  undef  lseek
186#  define lseek(fdes,offset,whence)  _lseek(fdes, (long)offset, whence)
187#  define fstat(fdes,stp)            _fstat(fdes, stp)
188#  define stat(fname,stp)            _stat(fname, stp)
189#  define struct_stat                struct _stat
190#  define LSEEK_ERROR                (long)-1
191#endif
192
193#ifndef struct_stat
194#  define struct_stat struct stat
195#endif
196
197#ifndef LSEEK_ERROR
198#  define LSEEK_ERROR (off_t)-1
199#endif
200
201#ifndef OS
202#define OS "unknown"
203#endif
204
205#if !defined(fileno) && !defined(WIN32) /* sunos 4 have this as a macro! */
206int fileno( FILE *stream);
207#endif
208
209#ifdef WIN32
210#define DIR_CHAR      "\\"
211#define DOT_CHAR      "_"
212#else
213#ifdef __EMX__
214/* 20000318 mgs
215 * OS/2 supports leading dots in filenames if the volume is formatted
216 * with JFS or HPFS. */
217#define DIR_CHAR      "\\"
218#define DOT_CHAR      "."
219#else
220
221#ifdef DJGPP
222#include <tcp.h>
223#ifdef word
224#undef word
225#endif
226#define DIR_CHAR      "/"
227#define DOT_CHAR      "_"
228#else
229
230#define DIR_CHAR      "/"
231#define DOT_CHAR      "."
232
233#endif /* !DJGPP */
234#endif /* !__EMX__ */
235#endif /* !WIN32 */
236
237#ifdef __riscos__
238#define USE_ENVIRONMENT
239#endif
240
241#ifdef __BEOS__
242#define typedef_bool
243#endif
244
245#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
246#include <sys/timeval.h>
247#endif
248
249#ifndef UNPRINTABLE_CHAR
250/* define what to use for unprintable characters */
251#define UNPRINTABLE_CHAR '.'
252#endif
253
254#ifndef HAVE_STRDUP
255#include "strdup.h"
256#define strdup(ptr) curlx_strdup(ptr)
257#endif
258
259/* Define S_ISREG if not defined by system headers, f.e. MSVC */
260#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
261#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
262#endif
263
264/*
265 * Include macros and defines that should only be processed once.
266 */
267
268#ifndef __SETUP_ONCE_H
269#include "setup_once.h"
270#endif
271
272/*
273 * Definition of our NOP statement Object-like macro
274 */
275
276#ifndef Curl_nop_stmt
277#  define Curl_nop_stmt do { } WHILE_FALSE
278#endif
279
280/*
281 * Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
282 */
283
284#if defined(__LWIP_OPT_H__)
285#  if defined(SOCKET) || \
286     defined(USE_WINSOCK) || \
287     defined(HAVE_ERRNO_H) || \
288     defined(HAVE_WINSOCK_H) || \
289     defined(HAVE_WINSOCK2_H) || \
290     defined(HAVE_WS2TCPIP_H)
291#    error "Winsock and lwIP TCP/IP stack definitions shall not coexist!"
292#  endif
293#endif
294
295#endif /* HEADER_CURL_SRC_SETUP_H */
296
297