Update version for release
[tftp-hpa.git] / config.h
blob8869134e2ab193eaa659611ccced82a32df477d3
1 /* -*- c -*- ------------------------------------------------------------- *
2 *
3 * Copyright 2001-2006 H. Peter Anvin - All Rights Reserved
5 * This program is free software available under the same license
6 * as the "OpenBSD" operating system, distributed at
7 * http://www.openbsd.org/.
9 * ----------------------------------------------------------------------- */
10 /* $Id$ */
13 * config.h
15 * Sets up a common baseline environment, based on "autoconf" findings...
18 #ifndef CONFIG_H
19 #define CONFIG_H 1
21 /* Must be included before we include any system headers! */
22 #include "aconfig.h" /* autogenerated configuration header */
24 /* Standard includes */
26 #include <stdio.h>
28 #ifdef HAVE_SYS_TYPES_H
29 #include <sys/types.h>
30 #endif
32 #ifdef HAVE_SYS_STAT_H
33 #include <sys/stat.h>
34 #endif
36 #ifdef STDC_HEADERS
37 #include <stdlib.h>
38 #include <stddef.h>
39 #else
40 #ifdef HAVE_STDLIB_H
41 #include <stdlib.h>
42 #endif
43 #endif
45 #ifdef HAVE_MEMORY_H
46 #ifndef STDC_HEADERS
47 #include <memory.h>
48 #endif
49 #endif
51 #ifdef HAVE_STRING_H
52 #include <string.h>
53 #endif
55 #ifdef HAVE_STRINGS_H
56 #include <strings.h>
57 #endif
59 #ifdef HAVE_INTTYPES_H
60 #ifdef INTTYPES_H_IS_SANE
61 #include <inttypes.h>
62 #endif
63 #else
64 #ifdef HAVE_STDINT_H
65 #include <stdint.h>
66 #endif
67 #endif
69 #ifdef HAVE_UNISTD_H
70 #include <unistd.h>
71 #endif
73 #ifdef HAVE_SETJMP_H
74 #include <setjmp.h>
75 #endif
77 #ifdef TIME_WITH_SYS_TIME
78 #include <sys/time.h>
79 #include <time.h>
80 #else
81 #if HAVE_SYS_TIME_H
82 #include <sys/time.h>
83 #else
84 #include <time.h>
85 #endif
86 #endif
88 #ifdef HAVE_GRP_H
89 #include <grp.h>
90 #endif
92 #ifdef HAVE_FCNTL_H
93 #include <fcntl.h>
94 #endif
96 #include <errno.h>
97 #include <signal.h>
99 #ifdef HAVE_SYS_SOCKET_H
100 #include <sys/socket.h>
101 #else
102 #ifdef HAVE_WINSOCK2_H
103 #include <winsock2.h>
104 #else
105 #ifdef HAVE_WINSOCK_H
106 #include <winsock.h>
107 #endif
108 #endif
109 #endif
111 #ifdef HAVE_GETOPT_H
112 #include <getopt.h>
113 #else
114 extern char *optarg;
115 extern int optind, opterr, optopt;
116 #endif
118 /* Test for EAGAIN/EWOULDBLOCK */
119 #ifdef EAGAIN
120 #if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
121 #define E_WOULD_BLOCK(x) ((x) == EAGAIN || (x) == EWOULDBLOCK)
122 #else
123 #define E_WOULD_BLOCK(x) ((x) == EAGAIN)
124 #endif
125 #else
126 #define E_WOULD_BLOCK(x) ((x) == EWOULDBLOCK)
127 #endif
129 /* Some broken systems care about text versus binary, but
130 real Unix systems don't... */
131 #ifndef HAVE_O_TEXT_DEFINITION
132 #define O_TEXT 0
133 #endif
134 #ifndef HAVE_O_BINARY_DEFINITION
135 #define O_BINARY 0
136 #endif
138 /* If we don't have intmax_t, try creating it */
140 #ifndef HAVE_INTMAX_T
141 #ifdef HAVE_LONG_LONG
142 typedef long long intmax_t;
143 typedef unsigned long long uintmax_t;
144 #define PRIdMAX "lld"
145 #define PRIuMAX "llu"
146 #define PRIxMAX "llx"
147 #define INTMAX_C(x) (x##LL)
148 #define UINTMAX_C(x) (x##ULL)
149 #else
150 typedef long intmax_t;
151 typedef unsigned long uintmax_t;
152 #define PRIdMAX "ld"
153 #define PRIuMAX "lu"
154 #define PRIxMAX "lx"
155 #define INTMAX_C(x) (x##L)
156 #define UINTMAX_C(x) (x##UL)
157 #endif
158 #endif
160 /* On some version of AIX, <inttypes.h> is buggy to the point of
161 unusability. We have to use macros here, not typedefs, to override. */
162 #ifdef HAVE_INTTYPES_H
163 #ifndef INTTYPES_H_IS_SANE
164 #undef PRIdMAX
165 #undef PRIuMAX
166 #undef PRIxMAX
167 #undef INTMAX_C
168 #undef UINTMAX_C
169 #undef HAVE_STRTOUMAX
171 #ifdef HAVE_LONG_LONG
172 #define intmax_t long long
173 #define uintmax_t unsigned long long
174 #define PRIdMAX "Ld"
175 #define PRIuMAX "Lu"
176 #define PRIxMAX "Lx"
177 #define INTMAX_C(x) (x##LL)
178 #define UINTMAX_C(x) (x##ULL)
179 #else
180 #define intmax_t long
181 #define uintmax_t unsigned long
182 #define PRIdMAX "ld"
183 #define PRIuMAX "lu"
184 #define PRIxMAX "lx"
185 #define INTMAX_C(x) (x##L)
186 #define UINTMAX_C(x) (x##UL)
187 #endif
188 #endif
189 #endif
191 /* Even if intmax_t is defined, we may need this (Solaris 8 braindamage) */
192 #ifndef HAVE_STRTOUMAX
193 #if defined(HAVE_LONG_LONG) && defined(HAVE_STRTOULL)
194 #define strtoumax(p,e,b) ((uintmax_t)strtoull(p,e,b))
195 #else
196 #define strtoumax(p,e,b) ((uintmax_t)strtoul(p,e,b))
197 #endif
198 #endif
200 /* A lot of this is old BSD code. Some newer systems don't approve. */
202 /* The type used by htons(), ntohs() */
203 #ifndef HAVE_U_SHORT
204 #ifdef HAVE_UINT16_T
205 typedef uint16_t u_short;
206 #else
207 typedef unsigned short u_short;
208 #endif
209 #endif
211 /* The type used to htonl(), ntohl() */
212 #ifndef HAVE_U_LONG
213 #ifdef HAVE_UINT32_T
214 typedef uint32_t u_long;
215 #else
216 typedef unsigned long u_long;
217 #endif
218 #endif
220 /* socklen_t */
221 #ifndef HAVE_SOCKLEN_T
222 typedef int socklen_t;
223 #endif
225 /* sysexits.h */
227 #ifdef HAVE_SYSEXITS_H
228 #include <sysexits.h>
229 #else
230 #define EX_USAGE 64 /* command line usage error */
231 #define EX_DATAERR 65 /* data format error */
232 #define EX_NOINPUT 66 /* cannot open input */
233 #define EX_NOUSER 67 /* addressee unknown */
234 #define EX_NOHOST 68 /* host name unknown */
235 #define EX_UNAVAILABLE 69 /* service unavailable */
236 #define EX_SOFTWARE 70 /* internal software error */
237 #define EX_OSERR 71 /* system error (e.g., can't fork) */
238 #define EX_OSFILE 72 /* critical OS file missing */
239 #define EX_CANTCREAT 73 /* can't create (user) output file */
240 #define EX_IOERR 74 /* input/output error */
241 #define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
242 #define EX_PROTOCOL 76 /* remote error in protocol */
243 #define EX_NOPERM 77 /* permission denied */
244 #define EX_CONFIG 78 /* configuration error */
245 #endif
247 /* If we don't have sigsetjmp() et all, setjmp() will have to do */
249 #ifndef HAVE_SIGSETJMP
250 #define sigsetjmp(x,y) setjmp(x)
251 #define siglongjmp(x,y) longjmp(x,y)
252 #define sigjmp_buf jmp_buf
253 #endif
255 /* How do we annotate unused data items? */
257 #ifndef UNUSED
258 #ifdef __GNUC__
259 #define UNUSED __attribute__((unused))
260 #else
261 #define UNUSED
262 #endif
263 #endif
265 /* netinet/in.h, and possible missing pieces */
267 #include <netinet/in.h>
269 #ifndef HAVE_IPPORT_TFTP_DEFINITION
270 #ifndef IPPORT_TFTP
271 #define IPPORT_TFTP 69
272 #endif
273 #endif
275 /* arpa/{inet,tftp}.h, and possible missing pieces */
277 #ifdef HAVE_ARPA_INET_H
278 #include <arpa/inet.h>
279 #endif
280 /* If we don't have arpa/tftp.h we have problems... */
281 #include <arpa/tftp.h>
283 #ifndef OACK
284 #define OACK 6
285 #endif
286 #ifndef EOPTNEG
287 #define EOPTNEG 8
288 #endif
290 /* tftp-hpa version and configuration strings */
292 #include "version.h"
294 #ifdef WITH_READLINE
295 #define WITH_READLINE_STR ", with readline"
296 #else
297 #define WITH_READLINE_STR ", without readline"
298 #endif
300 #ifdef WITH_REGEX
301 #define WITH_REGEX_STR ", with remap"
302 #else
303 #define WITH_REGEX_STR ", without remap"
304 #endif
306 #ifdef HAVE_LIBWRAP
307 #define HAVE_LIBWRAP_STR ", with tcpwrappers"
308 #else
309 #define HAVE_LIBWRAP_STR ", without tcpwrappers"
310 #endif
312 #define TFTP_CONFIG_STR VERSION WITH_READLINE_STR
313 #define TFTPD_CONFIG_STR VERSION WITH_REGEX_STR HAVE_LIBWRAP_STR
315 #endif