]>
Commit | Line | Data |
---|---|---|
76a8e733 | 1 | #ifndef _DEFINES_H |
2 | #define _DEFINES_H | |
3 | ||
ea1970a3 | 4 | /* Necessary headers */ |
5 | ||
a8ed9fd9 | 6 | #include <sys/types.h> /* For [u]intxx_t */ |
cb807f40 | 7 | #include <sys/socket.h> /* For SHUT_XXXX */ |
509b1f88 | 8 | #include <sys/param.h> /* For MAXPATHLEN */ |
9 | #include <netinet/in_systm.h> /* For typedefs */ | |
a8ed9fd9 | 10 | #include <netinet/in.h> /* For IPv6 macros */ |
18e92801 | 11 | #include <netinet/ip.h> /* For IPTOS macros */ |
5cdfe03f | 12 | #ifdef HAVE_SYS_BITYPES_H |
13 | # include <sys/bitypes.h> /* For u_intXX_t */ | |
14 | #endif | |
cb807f40 | 15 | #ifdef HAVE_PATHS_H |
16 | # include <paths.h> /* For _PATH_XXX */ | |
17 | #endif | |
509b1f88 | 18 | #ifdef HAVE_LIMITS_H |
19 | # include <limits.h> /* For PATH_MAX */ | |
20 | #endif | |
cb807f40 | 21 | #ifdef HAVE_SYS_TIME_H |
22 | # include <sys/time.h> /* For timersub */ | |
23 | #endif | |
cb807f40 | 24 | #ifdef HAVE_MAILLOCK_H |
d94aa2ae | 25 | # include <maillock.h> /* For _PATH_MAILDIR */ |
cb807f40 | 26 | #endif |
d94aa2ae | 27 | #ifdef HAVE_SYS_CDEFS_H |
28 | # include <sys/cdefs.h> /* For __P() */ | |
29 | #endif | |
d468fc76 | 30 | #ifdef HAVE_SYS_SYSMACROS_H |
31 | # include <sys/sysmacros.h> /* For MIN, MAX, etc */ | |
32 | #endif | |
33 | ||
ea1970a3 | 34 | /* Constants */ |
35 | ||
cb807f40 | 36 | #ifndef SHUT_RDWR |
37 | enum | |
38 | { | |
39 | SHUT_RD = 0, /* No more receptions. */ | |
40 | SHUT_WR, /* No more transmissions. */ | |
41 | SHUT_RDWR /* No more receptions or transmissions. */ | |
42 | }; | |
43 | # define SHUT_RD SHUT_RD | |
44 | # define SHUT_WR SHUT_WR | |
45 | # define SHUT_RDWR SHUT_RDWR | |
46 | #endif | |
47 | ||
18e92801 | 48 | #ifndef IPTOS_LOWDELAY |
49 | # define IPTOS_LOWDELAY 0x10 | |
50 | # define IPTOS_THROUGHPUT 0x08 | |
51 | # define IPTOS_RELIABILITY 0x04 | |
52 | # define IPTOS_LOWCOST 0x02 | |
53 | # define IPTOS_MINCOST IPTOS_LOWCOST | |
54 | #endif /* IPTOS_LOWDELAY */ | |
55 | ||
509b1f88 | 56 | #ifndef MAXPATHLEN |
57 | # ifdef PATH_MAX | |
58 | # define MAXPATHLEN PATH_MAX | |
59 | # else /* PATH_MAX */ | |
60 | # define MAXPATHLEN 64 /* Should be safe */ | |
61 | # endif /* PATH_MAX */ | |
62 | #endif /* MAXPATHLEN */ | |
63 | ||
ea1970a3 | 64 | /* Types */ |
65 | ||
cb807f40 | 66 | /* If sys/types.h does not supply intXX_t, supply them ourselves */ |
67 | /* (or die trying) */ | |
68 | #ifndef HAVE_INTXX_T | |
976f7e19 | 69 | # if (SIZEOF_CHAR == 1) |
70 | typedef char int8_t; | |
71 | # else | |
72 | # error "8 bit int type not found." | |
73 | # endif | |
cb807f40 | 74 | # if (SIZEOF_SHORT_INT == 2) |
ea1970a3 | 75 | typedef short int int16_t; |
cb807f40 | 76 | # else |
77 | # error "16 bit int type not found." | |
78 | # endif | |
79 | # if (SIZEOF_INT == 4) | |
ea1970a3 | 80 | typedef int int32_t; |
cb807f40 | 81 | # else |
82 | # error "32 bit int type not found." | |
83 | # endif | |
837c30b8 | 84 | /* |
cb807f40 | 85 | # if (SIZEOF_LONG_INT == 8) |
ea1970a3 | 86 | typedef long int int64_t; |
cb807f40 | 87 | # else |
88 | # if (SIZEOF_LONG_LONG_INT == 8) | |
ea1970a3 | 89 | typedef long long int int64_t; |
76a8e733 | 90 | # define HAVE_INTXX_T 1 |
cb807f40 | 91 | # else |
92 | # error "64 bit int type not found." | |
93 | # endif | |
94 | # endif | |
837c30b8 | 95 | */ |
cb807f40 | 96 | #endif |
97 | ||
98 | /* If sys/types.h does not supply u_intXX_t, supply them ourselves */ | |
99 | #ifndef HAVE_U_INTXX_T | |
100 | # ifdef HAVE_UINTXX_T | |
976f7e19 | 101 | typedef uint8_t u_int8_t; |
ea1970a3 | 102 | typedef uint16_t u_int16_t; |
103 | typedef uint32_t u_int32_t; | |
837c30b8 | 104 | /* |
ea1970a3 | 105 | typedef uint64_t u_int64_t; |
837c30b8 | 106 | */ |
76a8e733 | 107 | # define HAVE_U_INTXX_T 1 |
cb807f40 | 108 | # else |
976f7e19 | 109 | # if (SIZEOF_CHAR == 1) |
110 | typedef unsigned char u_int8_t; | |
111 | # else | |
112 | # error "8 bit int type not found." | |
113 | # endif | |
cb807f40 | 114 | # if (SIZEOF_SHORT_INT == 2) |
ea1970a3 | 115 | typedef unsigned short int u_int16_t; |
cb807f40 | 116 | # else |
117 | # error "16 bit int type not found." | |
118 | # endif | |
119 | # if (SIZEOF_INT == 4) | |
ea1970a3 | 120 | typedef unsigned int u_int32_t; |
cb807f40 | 121 | # else |
122 | # error "32 bit int type not found." | |
123 | # endif | |
837c30b8 | 124 | /* |
cb807f40 | 125 | # if (SIZEOF_LONG_INT == 8) |
ea1970a3 | 126 | typedef unsigned long int u_int64_t; |
cb807f40 | 127 | # else |
128 | # if (SIZEOF_LONG_LONG_INT == 8) | |
ea1970a3 | 129 | typedef unsigned long long int u_int64_t; |
76a8e733 | 130 | # define HAVE_U_INTXX_T 1 |
cb807f40 | 131 | # else |
132 | # error "64 bit int type not found." | |
133 | # endif | |
134 | # endif | |
837c30b8 | 135 | */ |
cb807f40 | 136 | # endif |
137 | #endif | |
138 | ||
ea1970a3 | 139 | #ifndef HAVE_SOCKLEN_T |
140 | typedef unsigned int socklen_t; | |
a6ddc88b | 141 | # define HAVE_SOCKLEN_T |
ea1970a3 | 142 | #endif /* HAVE_SOCKLEN_T */ |
143 | ||
e3a93db0 | 144 | #ifndef HAVE_SIZE_T |
145 | typedef unsigned int size_t; | |
a6ddc88b | 146 | # define HAVE_SIZE_T |
e3a93db0 | 147 | #endif /* HAVE_SIZE_T */ |
148 | ||
c04f75f1 | 149 | #ifndef HAVE_SSIZE_T |
150 | typedef int ssize_t; | |
151 | # define HAVE_SSIZE_T | |
152 | #endif /* HAVE_SSIZE_T */ | |
153 | ||
48e671d5 | 154 | #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS) |
155 | # define ss_family __ss_family | |
156 | #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */ | |
157 | ||
ea1970a3 | 158 | /* Paths */ |
159 | ||
cb807f40 | 160 | #ifndef _PATH_BSHELL |
161 | # define _PATH_BSHELL "/bin/sh" | |
162 | #endif | |
163 | ||
164 | #ifdef USER_PATH | |
165 | # ifdef _PATH_STDPATH | |
166 | # undef _PATH_STDPATH | |
167 | # endif | |
168 | # define _PATH_STDPATH USER_PATH | |
169 | #endif | |
170 | ||
171 | #ifndef _PATH_STDPATH | |
172 | # define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" | |
173 | #endif | |
174 | ||
175 | #ifndef _PATH_DEVNULL | |
176 | # define _PATH_DEVNULL "/dev/null" | |
177 | #endif | |
178 | ||
c04f75f1 | 179 | #ifndef MAIL_DIRECTORY |
180 | # define MAIL_DIRECTORY "/var/spool/mail" | |
181 | #endif | |
182 | ||
cb807f40 | 183 | #ifndef MAILDIR |
184 | # define MAILDIR MAIL_DIRECTORY | |
185 | #endif | |
186 | ||
187 | #if !defined(_PATH_MAILDIR) && defined(MAILDIR) | |
188 | # define _PATH_MAILDIR MAILDIR | |
189 | #endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */ | |
190 | ||
ea1970a3 | 191 | #ifndef _PATH_RSH |
192 | # ifdef RSH_PATH | |
193 | # define _PATH_RSH RSH_PATH | |
194 | # endif /* RSH_PATH */ | |
195 | #endif /* _PATH_RSH */ | |
196 | ||
197 | /* Macros */ | |
198 | ||
cb807f40 | 199 | #ifndef MAX |
200 | # define MAX(a,b) (((a)>(b))?(a):(b)) | |
201 | # define MIN(a,b) (((a)<(b))?(a):(b)) | |
202 | #endif | |
203 | ||
204 | #ifndef timersub | |
205 | #define timersub(a, b, result) \ | |
206 | do { \ | |
207 | (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ | |
208 | (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ | |
209 | if ((result)->tv_usec < 0) { \ | |
210 | --(result)->tv_sec; \ | |
211 | (result)->tv_usec += 1000000; \ | |
212 | } \ | |
213 | } while (0) | |
214 | #endif | |
215 | ||
cb807f40 | 216 | #ifndef __P |
217 | # define __P(x) x | |
218 | #endif | |
219 | ||
a8ed9fd9 | 220 | #if !defined(IN6_IS_ADDR_V4MAPPED) |
221 | # define IN6_IS_ADDR_V4MAPPED(a) \ | |
84afc958 | 222 | ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \ |
223 | (((u_int32_t *) (a))[2] == htonl (0xffff))) | |
a8ed9fd9 | 224 | #endif /* !defined(IN6_IS_ADDR_V4MAPPED) */ |
225 | ||
cb807f40 | 226 | #if !defined(__GNUC__) || (__GNUC__ < 2) |
976f7e19 | 227 | # define __attribute__(x) |
cb807f40 | 228 | #endif /* !defined(__GNUC__) || (__GNUC__ < 2) */ |
229 | ||
ea1970a3 | 230 | #if defined(HAVE_SECURITY_PAM_APPL_H) && !defined(DISABLE_PAM) |
231 | # define USE_PAM | |
232 | #endif /* defined(HAVE_SECURITY_PAM_APPL_H) && !defined(DISABLE_PAM) */ | |
233 | ||
234 | /* Function replacement / compatibility hacks */ | |
235 | ||
236 | /* In older versions of libpam, pam_strerror takes a single argument */ | |
237 | #ifdef HAVE_OLD_PAM | |
238 | # define PAM_STRERROR(a,b) pam_strerror((b)) | |
239 | #else | |
240 | # define PAM_STRERROR(a,b) pam_strerror((a),(b)) | |
241 | #endif | |
242 | ||
4c8ef3fb | 243 | #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) |
244 | # undef HAVE_GETADDRINFO | |
245 | #endif /* defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) */ | |
246 | ||
c04f75f1 | 247 | #if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) |
248 | # define memmove(s1, s2, n) bcopy((s2), (s1), (n)) | |
249 | #endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */ | |
250 | ||
b9f446d1 | 251 | #if !defined(HAVE_ATEXIT) && defined(HAVE_ON_EXIT) |
252 | # define atexit(a) on_exit(a) | |
253 | #endif /* !defined(HAVE_ATEXIT) && defined(HAVE_ON_EXIT) */ | |
254 | ||
1d7b9b20 | 255 | /** |
256 | ** login recorder definitions | |
257 | **/ | |
258 | ||
259 | /* preprocess */ | |
260 | ||
261 | #ifdef HAVE_UTMP_H | |
262 | # ifdef HAVE_TIME_IN_UTMP | |
263 | # include <time.h> | |
264 | # endif | |
265 | # include <utmp.h> | |
266 | #endif | |
267 | #ifdef HAVE_UTMPX_H | |
268 | # ifdef HAVE_TV_IN_UTMPX | |
269 | # include <sys/time.h> | |
270 | # endif | |
271 | # include <utmpx.h> | |
272 | #endif | |
273 | #ifdef HAVE_LASTLOG_H | |
274 | # include <lastlog.h> | |
275 | #endif | |
276 | #ifdef HAVE_PATHS_H | |
277 | # include <paths.h> | |
278 | #endif | |
279 | ||
280 | /* FIXME: put default paths back in */ | |
281 | #if !defined(UTMP_FILE) && defined(_PATH_UTMP) | |
282 | # define UTMP_FILE _PATH_UTMP | |
283 | #endif | |
284 | #if !defined(WTMP_FILE) && defined(_PATH_WTMP) | |
285 | # define WTMP_FILE _PATH_WTMP | |
286 | #endif | |
287 | /* pick up the user's location for lastlog if given */ | |
1d7b9b20 | 288 | #if !defined(LASTLOG_FILE) && defined(_PATH_LASTLOG) |
289 | # define LASTLOG_FILE _PATH_LASTLOG | |
290 | #endif | |
d7c0f3d5 | 291 | #if !defined(LASTLOG_FILE) && defined(CONF_LASTLOG_FILE) |
292 | # define LASTLOG_FILE CONF_LASTLOG_FILE | |
293 | #endif | |
1d7b9b20 | 294 | |
295 | ||
296 | /* The login() library function in libutil is first choice */ | |
297 | #if defined(HAVE_LOGIN) && !defined(DISABLE_LOGIN) | |
298 | # define USE_LOGIN | |
299 | ||
300 | #else | |
301 | /* Simply select your favourite login types. */ | |
302 | /* Can't do if-else because some systems use several... <sigh> */ | |
303 | # if defined(UTMPX_FILE) && !defined(DISABLE_UTMPX) | |
304 | # define USE_UTMPX | |
305 | # endif | |
306 | # if defined(UTMP_FILE) && !defined(DISABLE_UTMP) | |
307 | # define USE_UTMP | |
308 | # endif | |
309 | # if defined(WTMPX_FILE) && !defined(DISABLE_WTMPX) | |
310 | # define USE_WTMPX | |
311 | # endif | |
312 | # if defined(WTMP_FILE) && !defined(DISABLE_WTMP) | |
313 | # define USE_WTMP | |
314 | # endif | |
315 | ||
316 | #endif | |
317 | ||
318 | /* I hope that the presence of LASTLOG_FILE is enough to detect this */ | |
319 | #if defined(LASTLOG_FILE) && !defined(DISABLE_LASTLOG) | |
320 | # define USE_LASTLOG | |
321 | #endif | |
322 | ||
323 | /* which type of time to use? (api.c) */ | |
324 | #ifdef HAVE_SYS_TIME_H | |
325 | # define USE_TIMEVAL | |
326 | #endif | |
327 | ||
328 | /** end of login recorder definitions */ | |
329 | ||
330 | ||
76a8e733 | 331 | #endif /* _DEFINES_H */ |