]>
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 */ |
7 | ||
cb807f40 | 8 | #include <sys/socket.h> /* For SHUT_XXXX */ |
9 | ||
a8ed9fd9 | 10 | #include <netinet/in.h> /* For IPv6 macros */ |
11 | ||
b7a87eea | 12 | #ifdef NEED_IN_SYSTM_H |
13 | # include <netinet/in_systm.h> | |
14 | #endif | |
18e92801 | 15 | #include <netinet/ip.h> /* For IPTOS macros */ |
16 | ||
5cdfe03f | 17 | #ifdef HAVE_SYS_BITYPES_H |
18 | # include <sys/bitypes.h> /* For u_intXX_t */ | |
19 | #endif | |
20 | ||
cb807f40 | 21 | #ifdef HAVE_PATHS_H |
22 | # include <paths.h> /* For _PATH_XXX */ | |
23 | #endif | |
24 | ||
25 | #ifdef HAVE_UTMP_H | |
26 | # include <utmp.h> /* For _PATH_XXX */ | |
27 | #endif | |
28 | ||
29 | #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) | |
30 | # include <utmpx.h> /* For _PATH_XXX */ | |
31 | #endif | |
32 | ||
33 | #ifdef HAVE_SYS_TIME_H | |
34 | # include <sys/time.h> /* For timersub */ | |
35 | #endif | |
36 | ||
37 | #ifdef HAVE_MAILLOCK_H | |
d94aa2ae | 38 | # include <maillock.h> /* For _PATH_MAILDIR */ |
cb807f40 | 39 | #endif |
40 | ||
d94aa2ae | 41 | #ifdef HAVE_SYS_CDEFS_H |
42 | # include <sys/cdefs.h> /* For __P() */ | |
43 | #endif | |
44 | ||
d468fc76 | 45 | #ifdef HAVE_SYS_SYSMACROS_H |
46 | # include <sys/sysmacros.h> /* For MIN, MAX, etc */ | |
47 | #endif | |
48 | ||
ea1970a3 | 49 | /* Constants */ |
50 | ||
cb807f40 | 51 | #ifndef SHUT_RDWR |
52 | enum | |
53 | { | |
54 | SHUT_RD = 0, /* No more receptions. */ | |
55 | SHUT_WR, /* No more transmissions. */ | |
56 | SHUT_RDWR /* No more receptions or transmissions. */ | |
57 | }; | |
58 | # define SHUT_RD SHUT_RD | |
59 | # define SHUT_WR SHUT_WR | |
60 | # define SHUT_RDWR SHUT_RDWR | |
61 | #endif | |
62 | ||
18e92801 | 63 | #ifndef IPTOS_LOWDELAY |
64 | # define IPTOS_LOWDELAY 0x10 | |
65 | # define IPTOS_THROUGHPUT 0x08 | |
66 | # define IPTOS_RELIABILITY 0x04 | |
67 | # define IPTOS_LOWCOST 0x02 | |
68 | # define IPTOS_MINCOST IPTOS_LOWCOST | |
69 | #endif /* IPTOS_LOWDELAY */ | |
70 | ||
ea1970a3 | 71 | /* Types */ |
72 | ||
cb807f40 | 73 | /* If sys/types.h does not supply intXX_t, supply them ourselves */ |
74 | /* (or die trying) */ | |
75 | #ifndef HAVE_INTXX_T | |
976f7e19 | 76 | # if (SIZEOF_CHAR == 1) |
77 | typedef char int8_t; | |
78 | # else | |
79 | # error "8 bit int type not found." | |
80 | # endif | |
cb807f40 | 81 | # if (SIZEOF_SHORT_INT == 2) |
ea1970a3 | 82 | typedef short int int16_t; |
cb807f40 | 83 | # else |
84 | # error "16 bit int type not found." | |
85 | # endif | |
86 | # if (SIZEOF_INT == 4) | |
ea1970a3 | 87 | typedef int int32_t; |
cb807f40 | 88 | # else |
89 | # error "32 bit int type not found." | |
90 | # endif | |
837c30b8 | 91 | /* |
cb807f40 | 92 | # if (SIZEOF_LONG_INT == 8) |
ea1970a3 | 93 | typedef long int int64_t; |
cb807f40 | 94 | # else |
95 | # if (SIZEOF_LONG_LONG_INT == 8) | |
ea1970a3 | 96 | typedef long long int int64_t; |
76a8e733 | 97 | # define HAVE_INTXX_T 1 |
cb807f40 | 98 | # else |
99 | # error "64 bit int type not found." | |
100 | # endif | |
101 | # endif | |
837c30b8 | 102 | */ |
cb807f40 | 103 | #endif |
104 | ||
105 | /* If sys/types.h does not supply u_intXX_t, supply them ourselves */ | |
106 | #ifndef HAVE_U_INTXX_T | |
107 | # ifdef HAVE_UINTXX_T | |
976f7e19 | 108 | typedef uint8_t u_int8_t; |
ea1970a3 | 109 | typedef uint16_t u_int16_t; |
110 | typedef uint32_t u_int32_t; | |
837c30b8 | 111 | /* |
ea1970a3 | 112 | typedef uint64_t u_int64_t; |
837c30b8 | 113 | */ |
76a8e733 | 114 | # define HAVE_U_INTXX_T 1 |
cb807f40 | 115 | # else |
976f7e19 | 116 | # if (SIZEOF_CHAR == 1) |
117 | typedef unsigned char u_int8_t; | |
118 | # else | |
119 | # error "8 bit int type not found." | |
120 | # endif | |
cb807f40 | 121 | # if (SIZEOF_SHORT_INT == 2) |
ea1970a3 | 122 | typedef unsigned short int u_int16_t; |
cb807f40 | 123 | # else |
124 | # error "16 bit int type not found." | |
125 | # endif | |
126 | # if (SIZEOF_INT == 4) | |
ea1970a3 | 127 | typedef unsigned int u_int32_t; |
cb807f40 | 128 | # else |
129 | # error "32 bit int type not found." | |
130 | # endif | |
837c30b8 | 131 | /* |
cb807f40 | 132 | # if (SIZEOF_LONG_INT == 8) |
ea1970a3 | 133 | typedef unsigned long int u_int64_t; |
cb807f40 | 134 | # else |
135 | # if (SIZEOF_LONG_LONG_INT == 8) | |
ea1970a3 | 136 | typedef unsigned long long int u_int64_t; |
76a8e733 | 137 | # define HAVE_U_INTXX_T 1 |
cb807f40 | 138 | # else |
139 | # error "64 bit int type not found." | |
140 | # endif | |
141 | # endif | |
837c30b8 | 142 | */ |
cb807f40 | 143 | # endif |
144 | #endif | |
145 | ||
ea1970a3 | 146 | #ifndef HAVE_SOCKLEN_T |
147 | typedef unsigned int socklen_t; | |
a6ddc88b | 148 | # define HAVE_SOCKLEN_T |
ea1970a3 | 149 | #endif /* HAVE_SOCKLEN_T */ |
150 | ||
e3a93db0 | 151 | #ifndef HAVE_SIZE_T |
152 | typedef unsigned int size_t; | |
a6ddc88b | 153 | # define HAVE_SIZE_T |
e3a93db0 | 154 | #endif /* HAVE_SIZE_T */ |
155 | ||
48e671d5 | 156 | #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS) |
157 | # define ss_family __ss_family | |
158 | #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */ | |
159 | ||
ea1970a3 | 160 | /* Paths */ |
161 | ||
cb807f40 | 162 | /* If _PATH_LASTLOG is not defined by system headers, set it to the */ |
163 | /* lastlog file detected by autoconf */ | |
164 | #ifndef _PATH_LASTLOG | |
165 | # ifdef LASTLOG_LOCATION | |
166 | # define _PATH_LASTLOG LASTLOG_LOCATION | |
167 | # endif | |
168 | #endif | |
169 | ||
170 | #ifndef _PATH_UTMP | |
171 | # ifdef UTMP_FILE | |
172 | # define _PATH_UTMP UTMP_FILE | |
173 | # else | |
174 | # define _PATH_UTMP "/var/adm/utmp" | |
175 | # endif | |
176 | #endif | |
177 | ||
178 | #ifndef _PATH_WTMP | |
179 | # ifdef WTMP_FILE | |
180 | # define _PATH_WTMP WTMP_FILE | |
181 | # else | |
182 | # define _PATH_WTMP "/var/adm/wtmp" | |
183 | # endif | |
184 | #endif | |
185 | ||
186 | #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) | |
187 | # ifndef _PATH_UTMPX | |
188 | # ifdef UTMPX_FILE | |
189 | # define _PATH_UTMPX UTMPX_FILE | |
190 | # else | |
191 | # define _PATH_UTMPX "/var/adm/utmpx" | |
192 | # endif | |
193 | # endif | |
194 | # ifndef _PATH_WTMPX | |
195 | # ifdef WTMPX_FILE | |
196 | # define _PATH_WTMPX WTMPX_FILE | |
197 | # else | |
198 | # define _PATH_WTMPX "/var/adm/wtmp" | |
199 | # endif | |
200 | # endif | |
201 | #endif | |
202 | ||
203 | #ifndef _PATH_BSHELL | |
204 | # define _PATH_BSHELL "/bin/sh" | |
205 | #endif | |
206 | ||
207 | #ifdef USER_PATH | |
208 | # ifdef _PATH_STDPATH | |
209 | # undef _PATH_STDPATH | |
210 | # endif | |
211 | # define _PATH_STDPATH USER_PATH | |
212 | #endif | |
213 | ||
214 | #ifndef _PATH_STDPATH | |
215 | # define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" | |
216 | #endif | |
217 | ||
218 | #ifndef _PATH_DEVNULL | |
219 | # define _PATH_DEVNULL "/dev/null" | |
220 | #endif | |
221 | ||
222 | #ifndef MAILDIR | |
223 | # define MAILDIR MAIL_DIRECTORY | |
224 | #endif | |
225 | ||
226 | #if !defined(_PATH_MAILDIR) && defined(MAILDIR) | |
227 | # define _PATH_MAILDIR MAILDIR | |
228 | #endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */ | |
229 | ||
ea1970a3 | 230 | #ifndef _PATH_RSH |
231 | # ifdef RSH_PATH | |
232 | # define _PATH_RSH RSH_PATH | |
233 | # endif /* RSH_PATH */ | |
234 | #endif /* _PATH_RSH */ | |
235 | ||
236 | /* Macros */ | |
237 | ||
cb807f40 | 238 | #ifndef MAX |
239 | # define MAX(a,b) (((a)>(b))?(a):(b)) | |
240 | # define MIN(a,b) (((a)<(b))?(a):(b)) | |
241 | #endif | |
242 | ||
243 | #ifndef timersub | |
244 | #define timersub(a, b, result) \ | |
245 | do { \ | |
246 | (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ | |
247 | (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ | |
248 | if ((result)->tv_usec < 0) { \ | |
249 | --(result)->tv_sec; \ | |
250 | (result)->tv_usec += 1000000; \ | |
251 | } \ | |
252 | } while (0) | |
253 | #endif | |
254 | ||
cb807f40 | 255 | #ifndef __P |
256 | # define __P(x) x | |
257 | #endif | |
258 | ||
a8ed9fd9 | 259 | #if !defined(IN6_IS_ADDR_V4MAPPED) |
260 | # define IN6_IS_ADDR_V4MAPPED(a) \ | |
84afc958 | 261 | ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \ |
262 | (((u_int32_t *) (a))[2] == htonl (0xffff))) | |
a8ed9fd9 | 263 | #endif /* !defined(IN6_IS_ADDR_V4MAPPED) */ |
264 | ||
cb807f40 | 265 | #if !defined(__GNUC__) || (__GNUC__ < 2) |
976f7e19 | 266 | # define __attribute__(x) |
cb807f40 | 267 | #endif /* !defined(__GNUC__) || (__GNUC__ < 2) */ |
268 | ||
ea1970a3 | 269 | #if defined(HAVE_SECURITY_PAM_APPL_H) && !defined(DISABLE_PAM) |
270 | # define USE_PAM | |
271 | #endif /* defined(HAVE_SECURITY_PAM_APPL_H) && !defined(DISABLE_PAM) */ | |
272 | ||
273 | /* Function replacement / compatibility hacks */ | |
274 | ||
275 | /* In older versions of libpam, pam_strerror takes a single argument */ | |
276 | #ifdef HAVE_OLD_PAM | |
277 | # define PAM_STRERROR(a,b) pam_strerror((b)) | |
278 | #else | |
279 | # define PAM_STRERROR(a,b) pam_strerror((a),(b)) | |
280 | #endif | |
281 | ||
4c8ef3fb | 282 | #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) |
283 | # undef HAVE_GETADDRINFO | |
284 | #endif /* defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) */ | |
285 | ||
76a8e733 | 286 | #endif /* _DEFINES_H */ |