Add the -p option for using regular Unix permissions.
[tftp-hpa.git] / config.h
blobedd6781789761102713314ec6d83d81d2ac2f194
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 #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 #include <errno.h>
93 #include <signal.h>
95 #include <sys/socket.h>
97 /* If we don't have intmax_t, try creating it */
99 #ifndef HAVE_INTMAX_T
100 #ifdef HAVE_LONG_LONG
101 typedef long long intmax_t;
102 typedef unsigned long long uintmax_t;
103 #define PRIdMAX "Ld"
104 #define PRIuMAX "Lu"
105 #define PRIxMAX "Lx"
106 #define INTMAX_C(x) (x##LL)
107 #define UINTMAX_C(x) (x##ULL)
108 #else
109 typedef long intmax_t;
110 typedef unsigned long uintmax_t;
111 #define PRIdMAX "ld"
112 #define PRIuMAX "lu"
113 #define PRIxMAX "lx"
114 #define INTMAX_C(x) (x##L)
115 #define UINTMAX_C(x) (x##UL)
116 #endif
117 #endif
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
123 #undef PRIdMAX
124 #undef PRIuMAX
125 #undef PRIxMAX
126 #undef INTMAX_C
127 #undef UINTMAX_C
128 #undef HAVE_STRTOUMAX
130 #ifdef HAVE_LONG_LONG
131 #define intmax_t long long
132 #define uintmax_t unsigned long long
133 #define PRIdMAX "Ld"
134 #define PRIuMAX "Lu"
135 #define PRIxMAX "Lx"
136 #define INTMAX_C(x) (x##LL)
137 #define UINTMAX_C(x) (x##ULL)
138 #else
139 #define intmax_t long
140 #define uintmax_t unsigned long
141 #define PRIdMAX "ld"
142 #define PRIuMAX "lu"
143 #define PRIxMAX "lx"
144 #define INTMAX_C(x) (x##L)
145 #define UINTMAX_C(x) (x##UL)
146 #endif
147 #endif
148 #endif
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))
154 #else
155 #define strtoumax(p,e,b) ((uintmax_t)strtoul(p,e,b))
156 #endif
157 #endif
159 /* A lot of this is old BSD code. Some newer systems don't approve. */
161 /* The type used by htons(), ntohs() */
162 #ifndef HAVE_U_SHORT
163 #ifdef HAVE_UINT16_T
164 typedef uint16_t u_short;
165 #else
166 typedef unsigned short u_short;
167 #endif
168 #endif
170 /* The type used to htonl(), ntohl() */
171 #ifndef HAVE_U_LONG
172 #ifdef HAVE_UINT32_T
173 typedef uint32_t u_long;
174 #else
175 typedef unsigned long u_long;
176 #endif
177 #endif
179 /* sysexits.h */
181 #ifdef HAVE_SYSEXITS_H
182 #include <sysexits.h>
183 #else
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 */
199 #endif
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
207 #endif
209 /* How do we annotate unused data items? */
211 #ifndef UNUSED
212 #ifdef __GNUC__
213 #define UNUSED __attribute__((unused))
214 #else
215 #define UNUSED
216 #endif
217 #endif
219 /* netinet/in.h, and possible missing pieces */
221 #include <netinet/in.h>
223 #ifndef HAVE_IPPORT_TFTP_DEFINITION
224 #ifndef IPPORT_TFTP
225 #define IPPORT_TFTP 69
226 #endif
227 #endif
229 /* arpa/{inet,tftp}.h, and possible missing pieces */
231 #ifdef HAVE_ARPA_INET_H
232 #include <arpa/inet.h>
233 #endif
234 /* If we don't have arpa/tftp.h we have problems... */
235 #include <arpa/tftp.h>
237 #ifndef OACK
238 #define OACK 6
239 #endif
240 #ifndef EOPTNEG
241 #define EOPTNEG 8
242 #endif
244 /* tftp-hpa version and configuration strings */
246 #include "version.h"
248 #ifdef WITH_READLINE
249 #define WITH_READLINE_STR ", with readline"
250 #else
251 #define WITH_READLINE_STR ", without readline"
252 #endif
254 #ifdef WITH_REGEX
255 #define WITH_REGEX_STR ", with remap"
256 #else
257 #define WITH_REGEX_STR ", without remap"
258 #endif
260 #ifdef HAVE_LIBWRAP
261 #define HAVE_LIBWRAP_STR ", with tcpwrappers"
262 #else
263 #define HAVE_LIBWRAP_STR ", without tcpwrappers"
264 #endif
266 #define TFTP_CONFIG_STR VERSION WITH_READLINE_STR
267 #define TFTPD_CONFIG_STR VERSION WITH_REGEX_STR HAVE_LIBWRAP_STR
269 #endif