Fixed ftp support with uClibc due to differing inet_ntoa_r() behaviour.
[platform/upstream/curl.git] / lib / setup.h
1 #ifndef __SETUP_H
2 #define __SETUP_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 1998 - 2004, 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 #ifdef HTTP_ONLY
27 #define CURL_DISABLE_FTP
28 #define CURL_DISABLE_LDAP
29 #define CURL_DISABLE_TELNET
30 #define CURL_DISABLE_DICT
31 #define CURL_DISABLE_FILE
32 #define CURL_DISABLE_GOPHER
33 #endif
34
35 #if !defined(WIN32) && defined(__WIN32__)
36 /* This should be a good Borland fix. Alexander J. Oss told us! */
37 #define WIN32
38 #endif
39
40 #ifdef HAVE_CONFIG_H
41 #include "config.h" /* the configure script results */
42 #else
43 #ifdef _WIN32_WCE
44 #include "config-win32ce.h"
45 #else
46 #ifdef WIN32
47 /* hand-modified win32 config.h! */
48 #include "config-win32.h"
49 #endif
50 #endif
51 #endif
52
53 #ifdef macintosh
54 /* hand-modified MacOS config.h! */
55 #include "config-mac.h"
56 #endif
57 #ifdef AMIGA
58 /* hand-modified AmigaOS config.h! */
59 #include "amigaos.h"
60 #endif
61
62 #ifndef TRUE
63 #define TRUE 1
64 #endif
65 #ifndef FALSE
66 #define FALSE 0
67 #endif
68
69 #if !defined(__cplusplus) && !defined(__BEOS__) && !defined(typedef_bool)
70 typedef unsigned char bool;
71 #define typedef_bool
72 #endif
73
74 #ifdef HAVE_LONGLONG
75 #define LONG_LONG long long
76 #define ENABLE_64BIT
77 #else
78 #ifdef _MSC_VER
79 #define LONG_LONG __int64
80 #define ENABLE_64BIT
81 #endif
82 #endif /* HAVE_LONGLONG */
83
84 #ifndef SIZEOF_CURL_OFF_T
85 /* If we don't know the size here, we assume a conservative size: 4. When
86    building libcurl, the actual size of this variable should be define in the
87    config*.h file. */
88 #define SIZEOF_CURL_OFF_T 4
89 #endif
90
91 /* We set up our internal prefered (CURL_)FORMAT_OFF_T here */
92 #if SIZEOF_CURL_OFF_T > 4
93 #define FORMAT_OFF_T "lld"
94 #else
95 #define FORMAT_OFF_T "ld"
96 #endif
97
98 /*#ifdef NEED_REENTRANT*/
99 /* Solaris needs _REENTRANT set for a few function prototypes and things to
100    appear in the #include files. We need to #define it before all #include
101    files. Unixware needs it to build proper reentrant code. Others may also
102    need it. */
103 #define _REENTRANT
104 /*#endif */
105
106 #include <stdio.h>
107 #ifdef HAVE_ASSERT_H
108 #include <assert.h>
109 #endif
110 #include <errno.h>
111
112 #ifdef __TANDEM /* for nsr-tandem-nsk systems */
113 #include <floss.h>
114 #endif
115
116 #ifndef STDC_HEADERS /* no standard C headers! */
117 #include <curl/stdcheaders.h>
118 #endif
119
120 #if defined(CURLDEBUG) && defined(HAVE_ASSERT_H)
121 #define curlassert(x) assert(x)
122 #else
123 /* does nothing without CURLDEBUG defined */
124 #define curlassert(x)
125 #endif
126
127 #ifdef MSG_NOSIGNAL
128 /* If we have the MSG_NOSIGNAL define, we make sure to use that in the forth
129    argument to send() and recv() */
130 #define SEND_4TH_ARG MSG_NOSIGNAL
131 #define HAVE_MSG_NOSIGNAL 1 /* we have MSG_NOSIGNAL */
132 #else
133 #define SEND_4TH_ARG 0
134 #endif
135
136 /* To make large file support transparent even on Windows */
137 #if defined(WIN32) && (SIZEOF_CURL_OFF_T > 4)
138 #include <sys/stat.h>   /* must come first before we redefine stat() */
139 #include <io.h>
140 #define lseek(x,y,z) _lseeki64(x, y, z)
141 #define struct_stat struct _stati64
142 #define stat(file,st) _stati64(file,st)
143 #define fstat(fd,st) _fstati64(fd,st)
144 #else
145 #define struct_stat struct stat
146 #endif
147
148 /* Below we define four functions. They should
149    1. close a socket
150    2. read from a socket
151    3. write to a socket
152
153    4. set the SIGALRM signal timeout
154    5. set dir/file naming defines
155    */
156
157 #ifdef WIN32
158
159 #ifndef WIN32_LEAN_AND_MEAN
160 #define WIN32_LEAN_AND_MEAN  /* Prevent including <winsock*.h> in <windows.h> */
161 #endif
162
163 #if HAVE_WINSOCK2_H
164 #include <winsock2.h>        /* required by telnet.c */
165 #endif
166
167 #if defined(ENABLE_IPV6) || defined(USE_SSLEAY)
168 #include <ws2tcpip.h>
169 #endif
170
171 #if !defined(__GNUC__) || defined(__MINGW32__)
172 #define sclose(x) closesocket(x)
173 #define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG)
174 #define swrite(x,y,z) (size_t)send(x,y,z, SEND_4TH_ARG)
175 #undef HAVE_ALARM
176 #else
177      /* gcc-for-win is still good :) */
178 #define sclose(x) close(x)
179 #define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG)
180 #define swrite(x,y,z) send(x,y,z, SEND_4TH_ARG)
181 #define HAVE_ALARM
182 #endif
183
184 #define DIR_CHAR      "\\"
185 #define DOT_CHAR      "_"
186
187 #else
188
189 #ifdef DJGPP
190 #define sclose(x)         close_s(x)
191 #define sread(x,y,z)      read_s(x,y,z)
192 #define swrite(x,y,z)     write_s(x,y,z)
193 #define select(n,r,w,x,t) select_s(n,r,w,x,t)
194 #define IOCTL_3_ARGS
195 #include <tcp.h>
196 #ifdef word
197 #undef word
198 #endif
199
200 #else
201
202 #ifdef __BEOS__
203 #define sclose(x) closesocket(x)
204 #define sread(x,y,z) (ssize_t)recv(x,y,z, SEND_4TH_ARG)
205 #define swrite(x,y,z) (ssize_t)send(x,y,z, SEND_4TH_ARG)
206 #else
207 #define sclose(x) close(x)
208 #define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG)
209 #define swrite(x,y,z) send(x,y,z, SEND_4TH_ARG)
210 #endif
211
212 #define HAVE_ALARM
213
214 #endif
215
216 #ifdef _AMIGASF
217 #undef HAVE_ALARM
218 #undef sclose
219 #define sclose(x) CloseSocket(x)
220 #endif
221
222 #define DIR_CHAR      "/"
223 #define DOT_CHAR      "."
224
225 #ifdef DJGPP
226 #undef DOT_CHAR
227 #define DOT_CHAR      "_"
228 #endif
229
230 #ifndef fileno /* sunos 4 have this as a macro! */
231 int fileno( FILE *stream);
232 #endif
233
234 #endif
235
236 /* now typedef our socket type */
237 #ifdef WIN32
238 typedef SOCKET curl_socket_t;
239 #define CURL_SOCKET_BAD INVALID_SOCKET
240 #else
241 typedef int curl_socket_t;
242 #define CURL_SOCKET_BAD -1
243 #endif
244
245 #if defined(ENABLE_IPV6) && defined(USE_ARES)
246 #error "ares does not yet support IPv6. Disable IPv6 or ares and rebuild"
247 #endif
248
249 #if defined(WIN32) && !defined(__CYGWIN__) && !defined(USE_ARES) && \
250     !defined(__LCC__)  /* lcc-win32 doesn't have _beginthreadex() */
251 #ifdef ENABLE_IPV6
252 #define USE_THREADING_GETADDRINFO
253 #else
254 #define USE_THREADING_GETHOSTBYNAME  /* Cygwin uses alarm() function */
255 #endif
256 #endif
257
258 #ifdef mpeix
259 #define IOCTL_3_ARGS
260 #endif
261
262 #ifdef NETWARE
263 #undef HAVE_ALARM
264 #endif
265
266 #if defined(HAVE_LIBIDN) && defined(HAVE_TLD_H)
267 /* The lib was present and the tld.h header (which is missing in libidn 0.3.X
268    but we only work with libidn 0.4.1 or later) */
269 #define USE_LIBIDN
270 #endif
271
272 #ifndef SIZEOF_TIME_T
273 /* assume default size of time_t to be 32 bit */
274 #define SIZEOF_TIME_T 4
275 #endif
276
277 #define LIBIDN_REQUIRED_VERSION "0.4.1"
278
279 #ifdef __UCLIBC_MAJOR__
280 #define HAVE_INET_NTOA_R_2_ARGS 1
281 #endif
282
283 #endif /* __CONFIG_H */