For congruency sake with the naming of other CURL_XXXXXX_CURL_OFF_T macros,
[platform/upstream/curl.git] / lib / setup.h
1 #ifndef __LIB_CURL_SETUP_H
2 #define __LIB_CURL_SETUP_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 1998 - 2008, 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  * $Id$
24  ***************************************************************************/
25
26 /*
27  * Define WIN32 when build target is Win32 API
28  */
29
30 #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && !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 #include "config.h"
41 #else
42
43 #ifdef _WIN32_WCE
44 #include "config-win32ce.h"
45 #else
46 #ifdef WIN32
47 #include "config-win32.h"
48 #endif
49 #endif
50
51 #ifdef macintosh
52 #include "config-mac.h"
53 #endif
54
55 #ifdef __AMIGA__
56 #include "amigaos.h"
57 #endif
58
59 #ifdef __SYMBIAN32__
60 #include "config-symbian.h"
61 #endif
62
63 #ifdef __OS400__
64 #  include "config-os400.h"
65 #endif
66
67 #ifdef TPF
68 #include "config-tpf.h" /* hand-modified TPF config.h */
69 /* change which select is used for libcurl */
70 #define select(a,b,c,d,e) tpf_select_libcurl(a,b,c,d,e)
71 #endif
72
73 #endif /* HAVE_CONFIG_H */
74
75 /* ================================================================ */
76 /* Definition of preprocessor macros/symbols which modify compiler  */
77 /* behaviour or generated code characteristics must be done here,   */
78 /* as appropriate, before any system header file is included. It is */
79 /* also possible to have them defined in the config file included   */
80 /* before this point. As a result of all this we frown inclusion of */
81 /* system header files in our config files, avoid this at any cost. */
82 /* ================================================================ */
83
84 /*
85  * Tru64 needs _REENTRANT set for a few function prototypes and
86  * things to appear in the system header files. Unixware needs it
87  * to build proper reentrant code. Others may also need it.
88  */
89
90 #ifdef NEED_REENTRANT
91 #  ifndef _REENTRANT
92 #    define _REENTRANT
93 #  endif
94 #endif
95
96 /* ================================================================ */
97 /*  If you need to include a system header file for your platform,  */
98 /*  please, do it beyond the point further indicated in this file.  */
99 /* ================================================================ */
100
101 /*
102  * libcurl's external interface definitions are also used internally,
103  * and might also include required system header files to define them.
104  */
105
106 #include <curl/curlbuild.h>
107
108 /*
109  * Compile time sanity checks must also be done when building the library.
110  */
111
112 #include <curl/curlrules.h>
113
114 /*
115  * Ensure that no one is using the old SIZEOF_CURL_OFF_T macro
116  */
117
118 #ifdef SIZEOF_CURL_OFF_T
119 #  error "SIZEOF_CURL_OFF_T shall not be defined!"
120    Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined
121 #endif
122
123 /*
124  * Ensure that no one is using the old internal FORMAT_OFF_T macro
125  */
126
127 #ifdef FORMAT_OFF_T
128 #  error "FORMAT_OFF_T shall not be defined!"
129    Error Compilation_aborted_FORMAT_OFF_T_shall_not_be_defined
130 #endif
131
132 /*
133  * Ensure that no one is using the old internal FORMAT_OFF_TU macro
134  */
135
136 #ifdef FORMAT_OFF_TU
137 #  error "FORMAT_OFF_TU shall not be defined!"
138    Error Compilation_aborted_FORMAT_OFF_TU_shall_not_be_defined
139 #endif
140
141 /*
142  * Disable other protocols when http is the only one desired.
143  */
144
145 #ifdef HTTP_ONLY
146 #  define CURL_DISABLE_TFTP
147 #  define CURL_DISABLE_FTP
148 #  define CURL_DISABLE_LDAP
149 #  define CURL_DISABLE_TELNET
150 #  define CURL_DISABLE_DICT
151 #  define CURL_DISABLE_FILE
152 #endif
153
154 /* ================================================================ */
155 /* No system header file shall be included in this file before this */
156 /* point. The only allowed ones are those included from curlbuild.h */
157 /* ================================================================ */
158
159 /*
160  * OS/400 setup file includes some system headers.
161  */
162
163 #ifdef __OS400__
164 #  include "setup-os400.h"
165 #endif
166
167 /*
168  * Include header files for windows builds before redefining anything.
169  * Use this preproessor block only to include or exclude windows.h,
170  * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
171  * to any other further and independant block.  Under Cygwin things work
172  * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
173  * never be included when __CYGWIN__ is defined.  configure script takes
174  * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
175  * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
176  */
177
178 #ifdef HAVE_WINDOWS_H
179 #  ifndef WIN32_LEAN_AND_MEAN
180 #    define WIN32_LEAN_AND_MEAN
181 #  endif
182 #  include <windows.h>
183 #  ifdef HAVE_WINSOCK2_H
184 #    include <winsock2.h>
185 #    ifdef HAVE_WS2TCPIP_H
186 #       include <ws2tcpip.h>
187 #    endif
188 #  else
189 #    ifdef HAVE_WINSOCK_H
190 #      include <winsock.h>
191 #    endif
192 #  endif
193 #endif
194
195 /*
196  * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
197  * define USE_WINSOCK to 1 if we have and use WINSOCK  API, else
198  * undefine USE_WINSOCK.
199  */
200
201 #undef USE_WINSOCK
202
203 #ifdef HAVE_WINSOCK2_H
204 #  define USE_WINSOCK 2
205 #else
206 #  ifdef HAVE_WINSOCK_H
207 #    define USE_WINSOCK 1
208 #  endif
209 #endif
210
211
212 #ifdef HAVE_LONGLONG
213 #define LONG_LONG long long
214 #define ENABLE_64BIT
215 #else
216 #ifdef _MSC_VER
217 #define LONG_LONG __int64
218 #define ENABLE_64BIT
219 #endif /* _MSC_VER */
220 #endif /* HAVE_LONGLONG */
221
222 #ifdef HAVE_EXTRA_STRICMP_H
223 #  include <extra/stricmp.h>
224 #endif
225
226 #ifdef HAVE_EXTRA_STRDUP_H
227 #  include <extra/strdup.h>
228 #endif
229
230 #ifdef TPF
231 #  include <strings.h>    /* for bzero, strcasecmp, and strncasecmp */
232 #  include <string.h>     /* for strcpy and strlen */
233 #  include <stdlib.h>     /* for rand and srand */
234 #  include <sys/socket.h> /* for select and ioctl*/
235 #  include <netdb.h>      /* for in_addr_t definition */
236 #  include <tpf/sysapi.h> /* for tpf_process_signals */
237 #endif
238
239 #include <stdio.h>
240 #ifdef HAVE_ASSERT_H
241 #include <assert.h>
242 #endif
243 #include <errno.h>
244
245 #ifdef __TANDEM /* for nsr-tandem-nsk systems */
246 #include <floss.h>
247 #endif
248
249 #ifndef STDC_HEADERS /* no standard C headers! */
250 #include <curl/stdcheaders.h>
251 #endif
252
253 /*
254  * PellesC kludge section (yikes);
255  *  - It has 'ssize_t', but it is in <unistd.h>. The way the headers
256  *    on Win32 are included, forces me to include this header here.
257  *  - sys_nerr, EINTR is missing in v4.0 or older.
258  */
259 #ifdef __POCC__
260   #include <sys/types.h>
261   #include <unistd.h>
262   #if (__POCC__ <= 400)
263   #define sys_nerr EILSEQ  /* for strerror.c */
264   #define EINTR    -1      /* for select.c */
265   #endif
266 #endif
267
268 /*
269  * Salford-C kludge section (mostly borrowed from wxWidgets).
270  */
271 #ifdef __SALFORDC__
272   #pragma suppress 353             /* Possible nested comments */
273   #pragma suppress 593             /* Define not used */
274   #pragma suppress 61              /* enum has no name */
275   #pragma suppress 106             /* unnamed, unused parameter */
276   #include <clib.h>
277 #endif
278
279
280 /* To make large file support transparent even on Windows */
281 #if defined(WIN32) && (CURL_SIZEOF_CURL_OFF_T > 4)
282 #include <sys/stat.h>   /* must come first before we redefine stat() */
283 #include <io.h>
284 #define lseek(x,y,z) _lseeki64(x, y, z)
285 #define struct_stat struct _stati64
286 #define stat(file,st) _stati64(file,st)
287 #define fstat(fd,st) _fstati64(fd,st)
288 #else
289 #define struct_stat struct stat
290 #endif /* Win32 with large file support */
291
292
293 /* Below we define some functions. They should
294    1. close a socket
295
296    4. set the SIGALRM signal timeout
297    5. set dir/file naming defines
298    */
299
300 #ifdef WIN32
301
302 #if !defined(__CYGWIN__)
303 #define sclose(x) closesocket(x)
304
305 #undef HAVE_ALARM
306 #else
307      /* gcc-for-win is still good :) */
308 #define sclose(x) close(x)
309 #define HAVE_ALARM
310 #endif /* !GNU or mingw */
311
312 #define DIR_CHAR      "\\"
313 #define DOT_CHAR      "_"
314
315 #else /* WIN32 */
316
317 #ifdef MSDOS  /* Watt-32 */
318 #include <sys/ioctl.h>
319 #define sclose(x)         close_s(x)
320 #define select(n,r,w,x,t) select_s(n,r,w,x,t)
321 #define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
322 #define IOCTL_3_ARGS
323 #include <tcp.h>
324 #ifdef word
325 #undef word
326 #endif
327 #ifdef byte
328 #undef byte
329 #endif
330
331 #else /* MSDOS */
332
333 #ifdef __BEOS__
334 #define sclose(x) closesocket(x)
335 #else /* __BEOS__ */
336 #define sclose(x) close(x)
337 #endif /* __BEOS__ */
338
339 #define HAVE_ALARM
340
341 #endif /* MSDOS */
342
343 #ifdef _AMIGASF
344 #undef HAVE_ALARM
345 #undef sclose
346 #define sclose(x) CloseSocket(x)
347 #endif
348
349 #ifdef __minix
350 /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
351 extern char * strtok_r(char *s, const char *delim, char **last);
352 extern struct tm * gmtime_r(const time_t * const timep, struct tm *tmp);
353 #endif
354
355 #ifdef __SYMBIAN32__
356 #undef HAVE_ALARM
357 #endif
358
359 #define DIR_CHAR      "/"
360 #ifndef DOT_CHAR
361 #define DOT_CHAR      "."
362 #endif
363
364 #ifdef MSDOS
365 #undef DOT_CHAR
366 #define DOT_CHAR      "_"
367 #endif
368
369 #ifndef fileno /* sunos 4 have this as a macro! */
370 int fileno( FILE *stream);
371 #endif
372
373 #endif /* WIN32 */
374
375 #if defined(WIN32) && !defined(__CYGWIN__) && !defined(USE_ARES) && \
376     !defined(__LCC__)  /* lcc-win32 doesn't have _beginthreadex() */
377 #ifdef ENABLE_IPV6
378 #define USE_THREADING_GETADDRINFO
379 #else
380 #define USE_THREADING_GETHOSTBYNAME  /* Cygwin uses alarm() function */
381 #endif
382 #endif
383
384 /* "cl -ML" or "cl -MLd" implies a single-threaded runtime library where
385    _beginthreadex() is not available */
386 #if (defined(_MSC_VER) && !defined(__POCC__)) && !defined(_MT) && !defined(USE_ARES)
387 #undef USE_THREADING_GETADDRINFO
388 #undef USE_THREADING_GETHOSTBYNAME
389 #define CURL_NO__BEGINTHREADEX
390 #endif
391
392 /*
393  * msvc 6.0 does not have struct sockaddr_storage and
394  * does not define IPPROTO_ESP in winsock2.h. But both
395  * are available if PSDK is properly installed.
396  */
397
398 #ifdef _MSC_VER
399 #if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP))
400 #undef HAVE_STRUCT_SOCKADDR_STORAGE
401 #endif
402 #endif
403
404 #ifdef mpeix
405 #define IOCTL_3_ARGS
406 #endif
407
408 #ifdef NETWARE
409 int netware_init(void);
410 #ifndef __NOVELL_LIBC__
411 #include <sys/bsdskt.h>
412 #include <sys/timeval.h>
413 #endif
414 #undef HAVE_ALARM
415 #endif
416
417 #if defined(HAVE_LIBIDN) && defined(HAVE_TLD_H)
418 /* The lib was present and the tld.h header (which is missing in libidn 0.3.X
419    but we only work with libidn 0.4.1 or later) */
420 #define USE_LIBIDN
421 #endif
422
423 #ifndef SIZEOF_TIME_T
424 /* assume default size of time_t to be 32 bit */
425 #define SIZEOF_TIME_T 4
426 #endif
427
428 #define LIBIDN_REQUIRED_VERSION "0.4.1"
429
430 #ifdef __UCLIBC__
431 #define HAVE_INET_NTOA_R_2_ARGS 1
432 #endif
433
434 #if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || defined(USE_QSOSSL)
435 #define USE_SSL    /* SSL support has been enabled */
436 #endif
437
438 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM)
439 #if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI)
440 #define USE_NTLM
441 #endif
442 #endif
443
444 /* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */
445 #if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE)
446 #define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE")
447 #endif
448
449 /*
450  * Include macros and defines that should only be processed once.
451  */
452
453 #ifndef __SETUP_ONCE_H
454 #include "setup_once.h"
455 #endif
456
457 #endif /* __LIB_CURL_SETUP_H */