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
72 #include <sys/socket.h>
74 /* If we don't have intmax_t, try creating it */
78 typedef long long intmax_t;
79 typedef unsigned long long uintmax_t;
83 #define INTMAX_C(x) (x##LL)
84 #define UINTMAX_C(x) (x##ULL)
86 typedef long intmax_t;
87 typedef unsigned long uintmax_t;
91 #define INTMAX_C(x) (x##L)
92 #define UINTMAX_C(x) (x##UL)
96 /* Even if intmax_t is defined, we may need this (Solaris 8 braindamage) */
97 #ifndef HAVE_STRTOUMAX
98 #if defined(HAVE_LONG_LONG) && defined(HAVE_STRTOULL)
99 #define strtoumax(p,e,b) ((uintmax_t)strtoull(p,e,b))
101 #define strtoumax(p,e,b) ((uintmax_t)strtoul(p,e,b))
105 /* A lot of this is old BSD code. Some newer systems don't approve. */
107 /* The type used by htons(), ntohs() */
110 typedef uint16_t u_short
;
112 typedef unsigned short u_short
;
116 /* The type used to htonl(), ntohl() */
119 typedef uint32_t u_long
;
121 typedef unsigned long u_long
;
127 #ifdef HAVE_SYSEXITS_H
128 #include <sysexits.h>
130 #define EX_USAGE 64 /* command line usage error */
131 #define EX_DATAERR 65 /* data format error */
132 #define EX_NOINPUT 66 /* cannot open input */
133 #define EX_NOUSER 67 /* addressee unknown */
134 #define EX_NOHOST 68 /* host name unknown */
135 #define EX_UNAVAILABLE 69 /* service unavailable */
136 #define EX_SOFTWARE 70 /* internal software error */
137 #define EX_OSERR 71 /* system error (e.g., can't fork) */
138 #define EX_OSFILE 72 /* critical OS file missing */
139 #define EX_CANTCREAT 73 /* can't create (user) output file */
140 #define EX_IOERR 74 /* input/output error */
141 #define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
142 #define EX_PROTOCOL 76 /* remote error in protocol */
143 #define EX_NOPERM 77 /* permission denied */
144 #define EX_CONFIG 78 /* configuration error */
147 /* If we don't have sigsetjmp() et all, setjmp() will have to do */
149 #ifndef HAVE_SIGSETJMP
150 #define sigsetjmp(x,y) setjmp(x)
151 #define siglongjmp(x,y) longjmp(x,y)
152 #define sigjmp_buf jmp_buf
155 /* How do we annotate unused data items? */
159 #define UNUSED __attribute__((unused))
165 /* netinet/in.h, and possible missing pieces */
167 #include <netinet/in.h>
169 #ifndef HAVE_IPPORT_TFTP_DEFINITION
171 #define IPPORT_TFTP 69
175 /* arpa/{inet,tftp}.h, and possible missing pieces */
177 #ifdef HAVE_ARPA_INET_H
178 #include <arpa/inet.h>
180 /* If we don't have arpa/tftp.h we have problems... */
181 #include <arpa/tftp.h>
190 /* tftp-hpa version and configuration strings */
195 #define WITH_READLINE_STR ", with readline"
197 #define WITH_READLINE_STR ", without readline"
201 #define WITH_REGEX_STR ", with remap"
203 #define WITH_REGEX_STR ", without remap"
207 #define HAVE_LIBWRAP_STR ", with tcpwrappers"
209 #define HAVE_LIBWRAP_STR ", without tcpwrappers"
212 #define TFTP_CONFIG_STR VERSION WITH_READLINE_STR
213 #define TFTPD_CONFIG_STR VERSION WITH_REGEX_STR HAVE_LIBWRAP_STR