Add a few feature test macros to benefit Digital Unix
[tftp-hpa.git] / config.h
blob1bc483a831277210dd0e6255e1507b4c727667a9
1 /* -*- c -*- ------------------------------------------------------------- *
2 *
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 * ----------------------------------------------------------------------- */
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 "acconfig.h"
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 #include <inttypes.h>
61 #else
62 #ifdef HAVE_STDINT_H
63 #include <stdint.h>
64 #endif
65 #endif
67 #ifdef HAVE_UNISTD_H
68 #include <unistd.h>
69 #endif
71 #include <setjmp.h>
72 #include <sys/socket.h>
74 /* If we don't have intmax_t, try creating it */
76 #ifndef HAVE_INTMAX_T
77 #ifdef HAVE_LONG_LONG
78 typedef long long intmax_t;
79 typedef unsigned long long uintmax_t;
80 #define PRIdMAX "Ld"
81 #define PRIuMAX "Lu"
82 #define PRIxMAX "Lx"
83 #define INTMAX_C(x) (x##LL)
84 #define UINTMAX_C(x) (x##ULL)
85 #else
86 typedef long intmax_t;
87 typedef unsigned long uintmax_t;
88 #define PRIdMAX "ld"
89 #define PRIuMAX "lu"
90 #define PRIxMAX "lx"
91 #define INTMAX_C(x) (x##L)
92 #define UINTMAX_C(x) (x##UL)
93 #endif
94 #endif
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))
100 #else
101 #define strtoumax(p,e,b) ((uintmax_t)strtoul(p,e,b))
102 #endif
103 #endif
105 /* A lot of this is old BSD code. Some newer systems don't approve. */
107 /* The type used by htons(), ntohs() */
108 #ifndef HAVE_U_SHORT
109 #ifdef HAVE_UINT16_T
110 typedef uint16_t u_short;
111 #else
112 typedef unsigned short u_short;
113 #endif
114 #endif
116 /* The type used to htonl(), ntohl() */
117 #ifndef HAVE_U_LONG
118 #ifdef HAVE_UINT32_T
119 typedef uint32_t u_long;
120 #else
121 typedef unsigned long u_long;
122 #endif
123 #endif
125 /* sysexits.h */
127 #ifdef HAVE_SYSEXITS_H
128 #include <sysexits.h>
129 #else
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 */
145 #endif
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
153 #endif
155 /* How do we annotate unused data items? */
157 #ifndef UNUSED
158 #ifdef __GNUC__
159 #define UNUSED __attribute__((unused))
160 #else
161 #define UNUSED
162 #endif
163 #endif
165 /* netinet/in.h, and possible missing pieces */
167 #include <netinet/in.h>
169 #ifndef HAVE_IPPORT_TFTP_DEFINITION
170 #ifndef IPPORT_TFTP
171 #define IPPORT_TFTP 69
172 #endif
173 #endif
175 /* arpa/{inet,tftp}.h, and possible missing pieces */
177 #ifdef HAVE_ARPA_INET_H
178 #include <arpa/inet.h>
179 #endif
180 /* If we don't have arpa/tftp.h we have problems... */
181 #include <arpa/tftp.h>
183 #ifndef OACK
184 #define OACK 6
185 #endif
186 #ifndef EOPTNEG
187 #define EOPTNEG 8
188 #endif
190 /* tftp-hpa version and configuration strings */
192 #include "version.h"
194 #ifdef WITH_READLINE
195 #define WITH_READLINE_STR ", with readline"
196 #else
197 #define WITH_READLINE_STR ", without readline"
198 #endif
200 #ifdef WITH_REGEX
201 #define WITH_REGEX_STR ", with remap"
202 #else
203 #define WITH_REGEX_STR ", without remap"
204 #endif
206 #ifdef HAVE_LIBWRAP
207 #define HAVE_LIBWRAP_STR ", with tcpwrappers"
208 #else
209 #define HAVE_LIBWRAP_STR ", without tcpwrappers"
210 #endif
212 #define TFTP_CONFIG_STR VERSION WITH_READLINE_STR
213 #define TFTPD_CONFIG_STR VERSION WITH_REGEX_STR HAVE_LIBWRAP_STR
215 #endif