4 /* Necessary headers */
6 #include <sys/types.h> /* For [u]intxx_t */
8 #include <sys/socket.h> /* For SHUT_XXXX */
10 #include <netinet/in.h> /* For IPv6 macros */
12 #ifdef HAVE_SYS_BITYPES_H
13 # include <sys/bitypes.h> /* For u_intXX_t */
17 # include <paths.h> /* For _PATH_XXX */
21 # include <utmp.h> /* For _PATH_XXX */
24 #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
25 # include <utmpx.h> /* For _PATH_XXX */
28 #ifdef HAVE_SYS_TIME_H
29 # include <sys/time.h> /* For timersub */
32 #ifdef HAVE_MAILLOCK_H
33 # include <maillock.h> /* For _PATH_MAILDIR */
36 #ifdef HAVE_SYS_CDEFS_H
37 # include <sys/cdefs.h> /* For __P() */
40 #ifdef HAVE_SYS_SYSMACROS_H
41 # include <sys/sysmacros.h> /* For MIN, MAX, etc */
49 SHUT_RD = 0, /* No more receptions. */
50 SHUT_WR, /* No more transmissions. */
51 SHUT_RDWR /* No more receptions or transmissions. */
53 # define SHUT_RD SHUT_RD
54 # define SHUT_WR SHUT_WR
55 # define SHUT_RDWR SHUT_RDWR
60 /* If sys/types.h does not supply intXX_t, supply them ourselves */
63 # if (SIZEOF_CHAR == 1)
66 # error "8 bit int type not found."
68 # if (SIZEOF_SHORT_INT == 2)
69 typedef short int int16_t;
71 # error "16 bit int type not found."
73 # if (SIZEOF_INT == 4)
76 # error "32 bit int type not found."
78 # if (SIZEOF_LONG_INT == 8)
79 typedef long int int64_t;
81 # if (SIZEOF_LONG_LONG_INT == 8)
82 typedef long long int int64_t;
83 # define HAVE_INTXX_T 1
85 # error "64 bit int type not found."
90 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
91 #ifndef HAVE_U_INTXX_T
93 typedef uint8_t u_int8_t;
94 typedef uint16_t u_int16_t;
95 typedef uint32_t u_int32_t;
96 typedef uint64_t u_int64_t;
97 # define HAVE_U_INTXX_T 1
99 # if (SIZEOF_CHAR == 1)
100 typedef unsigned char u_int8_t;
102 # error "8 bit int type not found."
104 # if (SIZEOF_SHORT_INT == 2)
105 typedef unsigned short int u_int16_t;
107 # error "16 bit int type not found."
109 # if (SIZEOF_INT == 4)
110 typedef unsigned int u_int32_t;
112 # error "32 bit int type not found."
114 # if (SIZEOF_LONG_INT == 8)
115 typedef unsigned long int u_int64_t;
117 # if (SIZEOF_LONG_LONG_INT == 8)
118 typedef unsigned long long int u_int64_t;
119 # define HAVE_U_INTXX_T 1
121 # error "64 bit int type not found."
127 #ifndef HAVE_SOCKLEN_T
128 typedef unsigned int socklen_t;
129 # define HAVE_SOCKLEN_T
130 #endif /* HAVE_SOCKLEN_T */
133 typedef unsigned int size_t;
135 #endif /* HAVE_SIZE_T */
137 #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS)
138 # define ss_family __ss_family
139 #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */
143 /* If _PATH_LASTLOG is not defined by system headers, set it to the */
144 /* lastlog file detected by autoconf */
145 #ifndef _PATH_LASTLOG
146 # ifdef LASTLOG_LOCATION
147 # define _PATH_LASTLOG LASTLOG_LOCATION
153 # define _PATH_UTMP UTMP_FILE
155 # define _PATH_UTMP "/var/adm/utmp"
161 # define _PATH_WTMP WTMP_FILE
163 # define _PATH_WTMP "/var/adm/wtmp"
167 #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
170 # define _PATH_UTMPX UTMPX_FILE
172 # define _PATH_UTMPX "/var/adm/utmpx"
177 # define _PATH_WTMPX WTMPX_FILE
179 # define _PATH_WTMPX "/var/adm/wtmp"
185 # define _PATH_BSHELL "/bin/sh"
189 # ifdef _PATH_STDPATH
190 # undef _PATH_STDPATH
192 # define _PATH_STDPATH USER_PATH
195 #ifndef _PATH_STDPATH
196 # define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
199 #ifndef _PATH_DEVNULL
200 # define _PATH_DEVNULL "/dev/null"
204 # define MAILDIR MAIL_DIRECTORY
207 #if !defined(_PATH_MAILDIR) && defined(MAILDIR)
208 # define _PATH_MAILDIR MAILDIR
209 #endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */
213 # define _PATH_RSH RSH_PATH
214 # endif /* RSH_PATH */
215 #endif /* _PATH_RSH */
220 # define MAX(a,b) (((a)>(b))?(a):(b))
221 # define MIN(a,b) (((a)<(b))?(a):(b))
225 #define timersub(a, b, result) \
227 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
228 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
229 if ((result)->tv_usec < 0) { \
230 --(result)->tv_sec; \
231 (result)->tv_usec += 1000000; \
240 #if !defined(IN6_IS_ADDR_V4MAPPED)
241 # define IN6_IS_ADDR_V4MAPPED(a) \
242 ((((uint32_t *) (a))[0] == 0) && (((uint32_t *) (a))[1] == 0) && \
243 (((uint32_t *) (a))[2] == htonl (0xffff)))
244 #endif /* !defined(IN6_IS_ADDR_V4MAPPED) */
246 #if !defined(__GNUC__) || (__GNUC__ < 2)
247 # define __attribute__(x)
248 #endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
250 #if defined(HAVE_SECURITY_PAM_APPL_H) && !defined(DISABLE_PAM)
252 #endif /* defined(HAVE_SECURITY_PAM_APPL_H) && !defined(DISABLE_PAM) */
254 /* Function replacement / compatibility hacks */
256 /* In older versions of libpam, pam_strerror takes a single argument */
258 # define PAM_STRERROR(a,b) pam_strerror((b))
260 # define PAM_STRERROR(a,b) pam_strerror((a),(b))
263 #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO)
264 # undef HAVE_GETADDRINFO
265 #endif /* defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) */
267 #endif /* _DEFINES_H */