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