1 /* -*- c -*- ------------------------------------------------------------- *
3 * Copyright 2001 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 * ----------------------------------------------------------------------- */
15 * Sets up a common baseline environment, based on "autoconf" findings...
21 /* Must be included before we include any system headers! */
24 /* Standard includes */
28 #ifdef HAVE_SYS_TYPES_H
29 #include <sys/types.h>
32 #ifdef HAVE_SYS_STAT_H
59 #ifdef HAVE_INTTYPES_H
60 #ifdef INTTYPES_H_IS_SANE
77 #ifdef TIME_WITH_SYS_TIME
95 #include <sys/socket.h>
97 /* If we don't have intmax_t, try creating it */
100 #ifdef HAVE_LONG_LONG
101 typedef long long intmax_t;
102 typedef unsigned long long uintmax_t;
106 #define INTMAX_C(x) (x##LL)
107 #define UINTMAX_C(x) (x##ULL)
109 typedef long intmax_t;
110 typedef unsigned long uintmax_t;
114 #define INTMAX_C(x) (x##L)
115 #define UINTMAX_C(x) (x##UL)
119 /* On some version of AIX, <inttypes.h> is buggy to the point of
120 unusability. We have to use macros here, not typedefs, to override. */
121 #ifdef HAVE_INTTYPES_H
122 #ifndef INTTYPES_H_IS_SANE
128 #undef HAVE_STRTOUMAX
130 #ifdef HAVE_LONG_LONG
131 #define intmax_t long long
132 #define uintmax_t unsigned long long
136 #define INTMAX_C(x) (x##LL)
137 #define UINTMAX_C(x) (x##ULL)
139 #define intmax_t long
140 #define uintmax_t unsigned long
144 #define INTMAX_C(x) (x##L)
145 #define UINTMAX_C(x) (x##UL)
150 /* Even if intmax_t is defined, we may need this (Solaris 8 braindamage) */
151 #ifndef HAVE_STRTOUMAX
152 #if defined(HAVE_LONG_LONG) && defined(HAVE_STRTOULL)
153 #define strtoumax(p,e,b) ((uintmax_t)strtoull(p,e,b))
155 #define strtoumax(p,e,b) ((uintmax_t)strtoul(p,e,b))
159 /* A lot of this is old BSD code. Some newer systems don't approve. */
161 /* The type used by htons(), ntohs() */
164 typedef uint16_t u_short
;
166 typedef unsigned short u_short
;
170 /* The type used to htonl(), ntohl() */
173 typedef uint32_t u_long
;
175 typedef unsigned long u_long
;
181 #ifdef HAVE_SYSEXITS_H
182 #include <sysexits.h>
184 #define EX_USAGE 64 /* command line usage error */
185 #define EX_DATAERR 65 /* data format error */
186 #define EX_NOINPUT 66 /* cannot open input */
187 #define EX_NOUSER 67 /* addressee unknown */
188 #define EX_NOHOST 68 /* host name unknown */
189 #define EX_UNAVAILABLE 69 /* service unavailable */
190 #define EX_SOFTWARE 70 /* internal software error */
191 #define EX_OSERR 71 /* system error (e.g., can't fork) */
192 #define EX_OSFILE 72 /* critical OS file missing */
193 #define EX_CANTCREAT 73 /* can't create (user) output file */
194 #define EX_IOERR 74 /* input/output error */
195 #define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
196 #define EX_PROTOCOL 76 /* remote error in protocol */
197 #define EX_NOPERM 77 /* permission denied */
198 #define EX_CONFIG 78 /* configuration error */
201 /* If we don't have sigsetjmp() et all, setjmp() will have to do */
203 #ifndef HAVE_SIGSETJMP
204 #define sigsetjmp(x,y) setjmp(x)
205 #define siglongjmp(x,y) longjmp(x,y)
206 #define sigjmp_buf jmp_buf
209 /* How do we annotate unused data items? */
213 #define UNUSED __attribute__((unused))
219 /* netinet/in.h, and possible missing pieces */
221 #include <netinet/in.h>
223 #ifndef HAVE_IPPORT_TFTP_DEFINITION
225 #define IPPORT_TFTP 69
229 /* arpa/{inet,tftp}.h, and possible missing pieces */
231 #ifdef HAVE_ARPA_INET_H
232 #include <arpa/inet.h>
234 /* If we don't have arpa/tftp.h we have problems... */
235 #include <arpa/tftp.h>
244 /* tftp-hpa version and configuration strings */
249 #define WITH_READLINE_STR ", with readline"
251 #define WITH_READLINE_STR ", without readline"
255 #define WITH_REGEX_STR ", with remap"
257 #define WITH_REGEX_STR ", without remap"
261 #define HAVE_LIBWRAP_STR ", with tcpwrappers"
263 #define HAVE_LIBWRAP_STR ", without tcpwrappers"
266 #define TFTP_CONFIG_STR VERSION WITH_READLINE_STR
267 #define TFTPD_CONFIG_STR VERSION WITH_REGEX_STR HAVE_LIBWRAP_STR