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