1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
3*0Sstevel@tonic-gate  * Use is subject to license terms.
4*0Sstevel@tonic-gate  */
5*0Sstevel@tonic-gate 
6*0Sstevel@tonic-gate #ifndef	_DEFINES_H
7*0Sstevel@tonic-gate #define	_DEFINES_H
8*0Sstevel@tonic-gate 
9*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
10*0Sstevel@tonic-gate 
11*0Sstevel@tonic-gate #ifdef __cplusplus
12*0Sstevel@tonic-gate extern "C" {
13*0Sstevel@tonic-gate #endif
14*0Sstevel@tonic-gate 
15*0Sstevel@tonic-gate /* $Id: defines.h,v 1.96 2002/09/26 00:38:48 tim Exp $ */
16*0Sstevel@tonic-gate 
17*0Sstevel@tonic-gate 
18*0Sstevel@tonic-gate /* Constants */
19*0Sstevel@tonic-gate 
20*0Sstevel@tonic-gate #ifndef SHUT_RDWR
21*0Sstevel@tonic-gate enum
22*0Sstevel@tonic-gate {
23*0Sstevel@tonic-gate   SHUT_RD = 0,		/* No more receptions.  */
24*0Sstevel@tonic-gate   SHUT_WR,			/* No more transmissions.  */
25*0Sstevel@tonic-gate   SHUT_RDWR			/* No more receptions or transmissions.  */
26*0Sstevel@tonic-gate };
27*0Sstevel@tonic-gate # define SHUT_RD   SHUT_RD
28*0Sstevel@tonic-gate # define SHUT_WR   SHUT_WR
29*0Sstevel@tonic-gate # define SHUT_RDWR SHUT_RDWR
30*0Sstevel@tonic-gate #endif
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifndef IPTOS_LOWDELAY
33*0Sstevel@tonic-gate # define IPTOS_LOWDELAY          0x10
34*0Sstevel@tonic-gate # define IPTOS_THROUGHPUT        0x08
35*0Sstevel@tonic-gate # define IPTOS_RELIABILITY       0x04
36*0Sstevel@tonic-gate # define IPTOS_LOWCOST           0x02
37*0Sstevel@tonic-gate # define IPTOS_MINCOST           IPTOS_LOWCOST
38*0Sstevel@tonic-gate #endif /* IPTOS_LOWDELAY */
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #ifndef MAXPATHLEN
41*0Sstevel@tonic-gate # ifdef PATH_MAX
42*0Sstevel@tonic-gate #  define MAXPATHLEN PATH_MAX
43*0Sstevel@tonic-gate # else /* PATH_MAX */
44*0Sstevel@tonic-gate #  define MAXPATHLEN 64 /* Should be safe */
45*0Sstevel@tonic-gate # endif /* PATH_MAX */
46*0Sstevel@tonic-gate #endif /* MAXPATHLEN */
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate #ifndef STDIN_FILENO
49*0Sstevel@tonic-gate # define STDIN_FILENO    0
50*0Sstevel@tonic-gate #endif
51*0Sstevel@tonic-gate #ifndef STDOUT_FILENO
52*0Sstevel@tonic-gate # define STDOUT_FILENO   1
53*0Sstevel@tonic-gate #endif
54*0Sstevel@tonic-gate #ifndef STDERR_FILENO
55*0Sstevel@tonic-gate # define STDERR_FILENO   2
56*0Sstevel@tonic-gate #endif
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate #ifndef NGROUPS_MAX	/* Disable groupaccess if NGROUP_MAX is not set */
59*0Sstevel@tonic-gate #ifdef NGROUPS
60*0Sstevel@tonic-gate #define NGROUPS_MAX NGROUPS
61*0Sstevel@tonic-gate #else
62*0Sstevel@tonic-gate #define NGROUPS_MAX 0
63*0Sstevel@tonic-gate #endif
64*0Sstevel@tonic-gate #endif
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate #ifndef O_NONBLOCK	/* Non Blocking Open */
67*0Sstevel@tonic-gate # define O_NONBLOCK      00004
68*0Sstevel@tonic-gate #endif
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate #ifndef S_ISDIR
71*0Sstevel@tonic-gate # define S_ISDIR(mode)	(((mode) & (_S_IFMT)) == (_S_IFDIR))
72*0Sstevel@tonic-gate #endif /* S_ISDIR */
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate #ifndef S_ISREG
75*0Sstevel@tonic-gate # define S_ISREG(mode)	(((mode) & (_S_IFMT)) == (_S_IFREG))
76*0Sstevel@tonic-gate #endif /* S_ISREG */
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate #ifndef S_ISLNK
79*0Sstevel@tonic-gate # define S_ISLNK(mode)	(((mode) & S_IFMT) == S_IFLNK)
80*0Sstevel@tonic-gate #endif /* S_ISLNK */
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate #ifndef S_IXUSR
83*0Sstevel@tonic-gate # define S_IXUSR			0000100	/* execute/search permission, */
84*0Sstevel@tonic-gate # define S_IXGRP			0000010	/* execute/search permission, */
85*0Sstevel@tonic-gate # define S_IXOTH			0000001	/* execute/search permission, */
86*0Sstevel@tonic-gate # define _S_IWUSR			0000200	/* write permission, */
87*0Sstevel@tonic-gate # define S_IWUSR			_S_IWUSR	/* write permission, owner */
88*0Sstevel@tonic-gate # define S_IWGRP			0000020	/* write permission, group */
89*0Sstevel@tonic-gate # define S_IWOTH			0000002	/* write permission, other */
90*0Sstevel@tonic-gate # define S_IRUSR			0000400	/* read permission, owner */
91*0Sstevel@tonic-gate # define S_IRGRP			0000040	/* read permission, group */
92*0Sstevel@tonic-gate # define S_IROTH			0000004	/* read permission, other */
93*0Sstevel@tonic-gate # define S_IRWXU			0000700	/* read, write, execute */
94*0Sstevel@tonic-gate # define S_IRWXG			0000070	/* read, write, execute */
95*0Sstevel@tonic-gate # define S_IRWXO			0000007	/* read, write, execute */
96*0Sstevel@tonic-gate #endif /* S_IXUSR */
97*0Sstevel@tonic-gate 
98*0Sstevel@tonic-gate #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
99*0Sstevel@tonic-gate #define MAP_ANON MAP_ANONYMOUS
100*0Sstevel@tonic-gate #endif
101*0Sstevel@tonic-gate 
102*0Sstevel@tonic-gate #ifndef MAP_FAILED
103*0Sstevel@tonic-gate # define MAP_FAILED ((void *)-1)
104*0Sstevel@tonic-gate #endif
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate /* *-*-nto-qnx doesn't define this constant in the system headers */
107*0Sstevel@tonic-gate #ifdef MISSING_NFDBITS
108*0Sstevel@tonic-gate # define	NFDBITS (8 * sizeof(unsigned long))
109*0Sstevel@tonic-gate #endif
110*0Sstevel@tonic-gate 
111*0Sstevel@tonic-gate /*
112*0Sstevel@tonic-gate SCO Open Server 3 has INADDR_LOOPBACK defined in rpc/rpc.h but
113*0Sstevel@tonic-gate including rpc/rpc.h breaks Solaris 6
114*0Sstevel@tonic-gate */
115*0Sstevel@tonic-gate #ifndef INADDR_LOOPBACK
116*0Sstevel@tonic-gate #define INADDR_LOOPBACK ((u_long)0x7f000001)
117*0Sstevel@tonic-gate #endif
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate /* Types */
120*0Sstevel@tonic-gate 
121*0Sstevel@tonic-gate /* If sys/types.h does not supply intXX_t, supply them ourselves */
122*0Sstevel@tonic-gate /* (or die trying) */
123*0Sstevel@tonic-gate 
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate #ifndef HAVE_U_INT
126*0Sstevel@tonic-gate typedef unsigned int u_int;
127*0Sstevel@tonic-gate #endif
128*0Sstevel@tonic-gate 
129*0Sstevel@tonic-gate #ifndef HAVE_INTXX_T
130*0Sstevel@tonic-gate # if (SIZEOF_CHAR == 1)
131*0Sstevel@tonic-gate typedef char int8_t;
132*0Sstevel@tonic-gate # else
133*0Sstevel@tonic-gate #  error "8 bit int type not found."
134*0Sstevel@tonic-gate # endif
135*0Sstevel@tonic-gate # if (SIZEOF_SHORT_INT == 2)
136*0Sstevel@tonic-gate typedef short int int16_t;
137*0Sstevel@tonic-gate # else
138*0Sstevel@tonic-gate #  ifdef _UNICOS
139*0Sstevel@tonic-gate #   if (SIZEOF_SHORT_INT == 4)
140*0Sstevel@tonic-gate typedef short int16_t;
141*0Sstevel@tonic-gate #   else
142*0Sstevel@tonic-gate typedef long  int16_t;
143*0Sstevel@tonic-gate #   endif
144*0Sstevel@tonic-gate #  else
145*0Sstevel@tonic-gate #   error "16 bit int type not found."
146*0Sstevel@tonic-gate #  endif /* _UNICOS */
147*0Sstevel@tonic-gate # endif
148*0Sstevel@tonic-gate # if (SIZEOF_INT == 4)
149*0Sstevel@tonic-gate typedef int int32_t;
150*0Sstevel@tonic-gate # else
151*0Sstevel@tonic-gate #  ifdef _UNICOS
152*0Sstevel@tonic-gate typedef long  int32_t;
153*0Sstevel@tonic-gate #  else
154*0Sstevel@tonic-gate #   error "32 bit int type not found."
155*0Sstevel@tonic-gate #  endif /* _UNICOS */
156*0Sstevel@tonic-gate # endif
157*0Sstevel@tonic-gate #endif
158*0Sstevel@tonic-gate 
159*0Sstevel@tonic-gate /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
160*0Sstevel@tonic-gate #ifndef HAVE_U_INTXX_T
161*0Sstevel@tonic-gate # ifdef HAVE_UINTXX_T
162*0Sstevel@tonic-gate typedef uint8_t u_int8_t;
163*0Sstevel@tonic-gate typedef uint16_t u_int16_t;
164*0Sstevel@tonic-gate typedef uint32_t u_int32_t;
165*0Sstevel@tonic-gate # define HAVE_U_INTXX_T 1
166*0Sstevel@tonic-gate # else
167*0Sstevel@tonic-gate #  if (SIZEOF_CHAR == 1)
168*0Sstevel@tonic-gate typedef unsigned char u_int8_t;
169*0Sstevel@tonic-gate #  else
170*0Sstevel@tonic-gate #   error "8 bit int type not found."
171*0Sstevel@tonic-gate #  endif
172*0Sstevel@tonic-gate #  if (SIZEOF_SHORT_INT == 2)
173*0Sstevel@tonic-gate typedef unsigned short int u_int16_t;
174*0Sstevel@tonic-gate #  else
175*0Sstevel@tonic-gate #   ifdef _UNICOS
176*0Sstevel@tonic-gate #    if (SIZEOF_SHORT_INT == 4)
177*0Sstevel@tonic-gate typedef unsigned short u_int16_t;
178*0Sstevel@tonic-gate #    else
179*0Sstevel@tonic-gate typedef unsigned long  u_int16_t;
180*0Sstevel@tonic-gate #    endif
181*0Sstevel@tonic-gate #   else
182*0Sstevel@tonic-gate #    error "16 bit int type not found."
183*0Sstevel@tonic-gate #   endif
184*0Sstevel@tonic-gate #  endif
185*0Sstevel@tonic-gate #  if (SIZEOF_INT == 4)
186*0Sstevel@tonic-gate typedef unsigned int u_int32_t;
187*0Sstevel@tonic-gate #  else
188*0Sstevel@tonic-gate #   ifdef _UNICOS
189*0Sstevel@tonic-gate typedef unsigned long  u_int32_t;
190*0Sstevel@tonic-gate #   else
191*0Sstevel@tonic-gate #    error "32 bit int type not found."
192*0Sstevel@tonic-gate #   endif
193*0Sstevel@tonic-gate #  endif
194*0Sstevel@tonic-gate # endif
195*0Sstevel@tonic-gate #define __BIT_TYPES_DEFINED__
196*0Sstevel@tonic-gate #endif
197*0Sstevel@tonic-gate 
198*0Sstevel@tonic-gate /* 64-bit types */
199*0Sstevel@tonic-gate #ifndef HAVE_INT64_T
200*0Sstevel@tonic-gate # if (SIZEOF_LONG_INT == 8)
201*0Sstevel@tonic-gate typedef long int int64_t;
202*0Sstevel@tonic-gate #   define HAVE_INT64_T 1
203*0Sstevel@tonic-gate # else
204*0Sstevel@tonic-gate #  if (SIZEOF_LONG_LONG_INT == 8)
205*0Sstevel@tonic-gate typedef long long int int64_t;
206*0Sstevel@tonic-gate #   define HAVE_INT64_T 1
207*0Sstevel@tonic-gate #  endif
208*0Sstevel@tonic-gate # endif
209*0Sstevel@tonic-gate #endif
210*0Sstevel@tonic-gate #ifndef HAVE_U_INT64_T
211*0Sstevel@tonic-gate # if (SIZEOF_LONG_INT == 8)
212*0Sstevel@tonic-gate typedef unsigned long int u_int64_t;
213*0Sstevel@tonic-gate #   define HAVE_U_INT64_T 1
214*0Sstevel@tonic-gate # else
215*0Sstevel@tonic-gate #  if (SIZEOF_LONG_LONG_INT == 8)
216*0Sstevel@tonic-gate typedef unsigned long long int u_int64_t;
217*0Sstevel@tonic-gate #   define HAVE_U_INT64_T 1
218*0Sstevel@tonic-gate #  endif
219*0Sstevel@tonic-gate # endif
220*0Sstevel@tonic-gate #endif
221*0Sstevel@tonic-gate #if !defined(HAVE_LONG_LONG_INT) && (SIZEOF_LONG_LONG_INT == 8)
222*0Sstevel@tonic-gate # define HAVE_LONG_LONG_INT 1
223*0Sstevel@tonic-gate #endif
224*0Sstevel@tonic-gate 
225*0Sstevel@tonic-gate #ifndef HAVE_U_CHAR
226*0Sstevel@tonic-gate typedef unsigned char u_char;
227*0Sstevel@tonic-gate # define HAVE_U_CHAR
228*0Sstevel@tonic-gate #endif /* HAVE_U_CHAR */
229*0Sstevel@tonic-gate 
230*0Sstevel@tonic-gate #ifndef SIZE_T_MAX
231*0Sstevel@tonic-gate #define SIZE_T_MAX ULONG_MAX
232*0Sstevel@tonic-gate #endif /* SIZE_T_MAX */
233*0Sstevel@tonic-gate 
234*0Sstevel@tonic-gate #ifndef HAVE_SIZE_T
235*0Sstevel@tonic-gate typedef unsigned int size_t;
236*0Sstevel@tonic-gate # define HAVE_SIZE_T
237*0Sstevel@tonic-gate #endif /* HAVE_SIZE_T */
238*0Sstevel@tonic-gate 
239*0Sstevel@tonic-gate #ifndef HAVE_SSIZE_T
240*0Sstevel@tonic-gate typedef int ssize_t;
241*0Sstevel@tonic-gate # define HAVE_SSIZE_T
242*0Sstevel@tonic-gate #endif /* HAVE_SSIZE_T */
243*0Sstevel@tonic-gate 
244*0Sstevel@tonic-gate #ifndef HAVE_CLOCK_T
245*0Sstevel@tonic-gate typedef long clock_t;
246*0Sstevel@tonic-gate # define HAVE_CLOCK_T
247*0Sstevel@tonic-gate #endif /* HAVE_CLOCK_T */
248*0Sstevel@tonic-gate 
249*0Sstevel@tonic-gate #ifndef HAVE_SA_FAMILY_T
250*0Sstevel@tonic-gate typedef int sa_family_t;
251*0Sstevel@tonic-gate # define HAVE_SA_FAMILY_T
252*0Sstevel@tonic-gate #endif /* HAVE_SA_FAMILY_T */
253*0Sstevel@tonic-gate 
254*0Sstevel@tonic-gate #ifndef HAVE_PID_T
255*0Sstevel@tonic-gate typedef int pid_t;
256*0Sstevel@tonic-gate # define HAVE_PID_T
257*0Sstevel@tonic-gate #endif /* HAVE_PID_T */
258*0Sstevel@tonic-gate 
259*0Sstevel@tonic-gate #ifndef HAVE_SIG_ATOMIC_T
260*0Sstevel@tonic-gate typedef int sig_atomic_t;
261*0Sstevel@tonic-gate # define HAVE_SIG_ATOMIC_T
262*0Sstevel@tonic-gate #endif /* HAVE_SIG_ATOMIC_T */
263*0Sstevel@tonic-gate 
264*0Sstevel@tonic-gate #ifndef HAVE_MODE_T
265*0Sstevel@tonic-gate typedef int mode_t;
266*0Sstevel@tonic-gate # define HAVE_MODE_T
267*0Sstevel@tonic-gate #endif /* HAVE_MODE_T */
268*0Sstevel@tonic-gate 
269*0Sstevel@tonic-gate #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS)
270*0Sstevel@tonic-gate # define ss_family __ss_family
271*0Sstevel@tonic-gate #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */
272*0Sstevel@tonic-gate 
273*0Sstevel@tonic-gate #ifndef HAVE_SYS_UN_H
274*0Sstevel@tonic-gate struct	sockaddr_un {
275*0Sstevel@tonic-gate 	short	sun_family;		/* AF_UNIX */
276*0Sstevel@tonic-gate 	char	sun_path[108];		/* path name (gag) */
277*0Sstevel@tonic-gate };
278*0Sstevel@tonic-gate #endif /* HAVE_SYS_UN_H */
279*0Sstevel@tonic-gate 
280*0Sstevel@tonic-gate #if defined(BROKEN_SYS_TERMIO_H) && !defined(_STRUCT_WINSIZE)
281*0Sstevel@tonic-gate #define _STRUCT_WINSIZE
282*0Sstevel@tonic-gate struct winsize {
283*0Sstevel@tonic-gate       unsigned short ws_row;          /* rows, in characters */
284*0Sstevel@tonic-gate       unsigned short ws_col;          /* columns, in character */
285*0Sstevel@tonic-gate       unsigned short ws_xpixel;       /* horizontal size, pixels */
286*0Sstevel@tonic-gate       unsigned short ws_ypixel;       /* vertical size, pixels */
287*0Sstevel@tonic-gate };
288*0Sstevel@tonic-gate #endif
289*0Sstevel@tonic-gate 
290*0Sstevel@tonic-gate /* *-*-nto-qnx does not define this type in the system headers */
291*0Sstevel@tonic-gate #ifdef MISSING_FD_MASK
292*0Sstevel@tonic-gate  typedef unsigned long int	fd_mask;
293*0Sstevel@tonic-gate #endif
294*0Sstevel@tonic-gate 
295*0Sstevel@tonic-gate /* Paths */
296*0Sstevel@tonic-gate 
297*0Sstevel@tonic-gate #ifndef _PATH_BSHELL
298*0Sstevel@tonic-gate # define _PATH_BSHELL "/bin/sh"
299*0Sstevel@tonic-gate #endif
300*0Sstevel@tonic-gate #ifndef _PATH_CSHELL
301*0Sstevel@tonic-gate # define _PATH_CSHELL "/bin/csh"
302*0Sstevel@tonic-gate #endif
303*0Sstevel@tonic-gate #ifndef _PATH_SHELLS
304*0Sstevel@tonic-gate # define _PATH_SHELLS "/etc/shells"
305*0Sstevel@tonic-gate #endif
306*0Sstevel@tonic-gate 
307*0Sstevel@tonic-gate #ifdef USER_PATH
308*0Sstevel@tonic-gate # ifdef _PATH_STDPATH
309*0Sstevel@tonic-gate #  undef _PATH_STDPATH
310*0Sstevel@tonic-gate # endif
311*0Sstevel@tonic-gate # define _PATH_STDPATH USER_PATH
312*0Sstevel@tonic-gate #endif
313*0Sstevel@tonic-gate 
314*0Sstevel@tonic-gate #ifndef _PATH_STDPATH
315*0Sstevel@tonic-gate # define _PATH_STDPATH "/usr/bin"
316*0Sstevel@tonic-gate #endif
317*0Sstevel@tonic-gate 
318*0Sstevel@tonic-gate #ifndef _PATH_DEVNULL
319*0Sstevel@tonic-gate # define _PATH_DEVNULL "/dev/null"
320*0Sstevel@tonic-gate #endif
321*0Sstevel@tonic-gate 
322*0Sstevel@tonic-gate #ifndef MAIL_DIRECTORY
323*0Sstevel@tonic-gate # define MAIL_DIRECTORY "/var/spool/mail"
324*0Sstevel@tonic-gate #endif
325*0Sstevel@tonic-gate 
326*0Sstevel@tonic-gate #ifndef MAILDIR
327*0Sstevel@tonic-gate # define MAILDIR MAIL_DIRECTORY
328*0Sstevel@tonic-gate #endif
329*0Sstevel@tonic-gate 
330*0Sstevel@tonic-gate #if !defined(_PATH_MAILDIR) && defined(MAILDIR)
331*0Sstevel@tonic-gate # define _PATH_MAILDIR MAILDIR
332*0Sstevel@tonic-gate #endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */
333*0Sstevel@tonic-gate 
334*0Sstevel@tonic-gate #ifndef _PATH_RSH
335*0Sstevel@tonic-gate # ifdef RSH_PATH
336*0Sstevel@tonic-gate #  define _PATH_RSH RSH_PATH
337*0Sstevel@tonic-gate # else /* RSH_PATH */
338*0Sstevel@tonic-gate #  define _PATH_RSH "/usr/bin/rsh"
339*0Sstevel@tonic-gate # endif /* RSH_PATH */
340*0Sstevel@tonic-gate #endif /* _PATH_RSH */
341*0Sstevel@tonic-gate 
342*0Sstevel@tonic-gate #ifndef _PATH_NOLOGIN
343*0Sstevel@tonic-gate # define _PATH_NOLOGIN "/etc/nologin"
344*0Sstevel@tonic-gate #endif
345*0Sstevel@tonic-gate 
346*0Sstevel@tonic-gate /* Define this to be the path of the xauth program. */
347*0Sstevel@tonic-gate #ifdef XAUTH_PATH
348*0Sstevel@tonic-gate #define _PATH_XAUTH XAUTH_PATH
349*0Sstevel@tonic-gate #endif /* XAUTH_PATH */
350*0Sstevel@tonic-gate 
351*0Sstevel@tonic-gate /* derived from XF4/xc/lib/dps/Xlibnet.h */
352*0Sstevel@tonic-gate #ifndef X_UNIX_PATH
353*0Sstevel@tonic-gate #  ifdef __hpux
354*0Sstevel@tonic-gate #    define X_UNIX_PATH "/var/spool/sockets/X11/%u"
355*0Sstevel@tonic-gate #  else
356*0Sstevel@tonic-gate #    define X_UNIX_PATH "/tmp/.X11-unix/X%u"
357*0Sstevel@tonic-gate #  endif
358*0Sstevel@tonic-gate #endif /* X_UNIX_PATH */
359*0Sstevel@tonic-gate #define _PATH_UNIX_X X_UNIX_PATH
360*0Sstevel@tonic-gate 
361*0Sstevel@tonic-gate #ifndef _PATH_TTY
362*0Sstevel@tonic-gate # define _PATH_TTY "/dev/tty"
363*0Sstevel@tonic-gate #endif
364*0Sstevel@tonic-gate 
365*0Sstevel@tonic-gate /* Macros */
366*0Sstevel@tonic-gate 
367*0Sstevel@tonic-gate #if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H)
368*0Sstevel@tonic-gate # define HAVE_LOGIN_CAP
369*0Sstevel@tonic-gate #endif
370*0Sstevel@tonic-gate 
371*0Sstevel@tonic-gate #ifndef MAX
372*0Sstevel@tonic-gate # define MAX(a,b) (((a)>(b))?(a):(b))
373*0Sstevel@tonic-gate # define MIN(a,b) (((a)<(b))?(a):(b))
374*0Sstevel@tonic-gate #endif
375*0Sstevel@tonic-gate 
376*0Sstevel@tonic-gate #ifndef roundup
377*0Sstevel@tonic-gate # define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
378*0Sstevel@tonic-gate #endif
379*0Sstevel@tonic-gate 
380*0Sstevel@tonic-gate #ifndef timersub
381*0Sstevel@tonic-gate #define timersub(a, b, result)					\
382*0Sstevel@tonic-gate    do {								\
383*0Sstevel@tonic-gate       (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;		\
384*0Sstevel@tonic-gate       (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;		\
385*0Sstevel@tonic-gate       if ((result)->tv_usec < 0) {				\
386*0Sstevel@tonic-gate 	 --(result)->tv_sec;					\
387*0Sstevel@tonic-gate 	 (result)->tv_usec += 1000000;				\
388*0Sstevel@tonic-gate       }								\
389*0Sstevel@tonic-gate    } while (0)
390*0Sstevel@tonic-gate #endif
391*0Sstevel@tonic-gate 
392*0Sstevel@tonic-gate #ifndef __P
393*0Sstevel@tonic-gate # define __P(x) x
394*0Sstevel@tonic-gate #endif
395*0Sstevel@tonic-gate 
396*0Sstevel@tonic-gate #if !defined(IN6_IS_ADDR_V4MAPPED)
397*0Sstevel@tonic-gate # define IN6_IS_ADDR_V4MAPPED(a) \
398*0Sstevel@tonic-gate 	((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \
399*0Sstevel@tonic-gate 	 (((u_int32_t *) (a))[2] == htonl (0xffff)))
400*0Sstevel@tonic-gate #endif /* !defined(IN6_IS_ADDR_V4MAPPED) */
401*0Sstevel@tonic-gate 
402*0Sstevel@tonic-gate #if !defined(__GNUC__) || (__GNUC__ < 2)
403*0Sstevel@tonic-gate # define __attribute__(x)
404*0Sstevel@tonic-gate #endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
405*0Sstevel@tonic-gate 
406*0Sstevel@tonic-gate /* *-*-nto-qnx doesn't define this macro in the system headers */
407*0Sstevel@tonic-gate #ifdef MISSING_HOWMANY
408*0Sstevel@tonic-gate # define howmany(x,y)	(((x)+((y)-1))/(y))
409*0Sstevel@tonic-gate #endif
410*0Sstevel@tonic-gate 
411*0Sstevel@tonic-gate #ifndef OSSH_ALIGNBYTES
412*0Sstevel@tonic-gate #define OSSH_ALIGNBYTES	(sizeof(int) - 1)
413*0Sstevel@tonic-gate #endif
414*0Sstevel@tonic-gate #ifndef __CMSG_ALIGN
415*0Sstevel@tonic-gate #define	__CMSG_ALIGN(p) (((u_int)(p) + OSSH_ALIGNBYTES) &~ OSSH_ALIGNBYTES)
416*0Sstevel@tonic-gate #endif
417*0Sstevel@tonic-gate 
418*0Sstevel@tonic-gate /* Length of the contents of a control message of length len */
419*0Sstevel@tonic-gate #ifndef CMSG_LEN
420*0Sstevel@tonic-gate #define	CMSG_LEN(len)	(__CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
421*0Sstevel@tonic-gate #endif
422*0Sstevel@tonic-gate 
423*0Sstevel@tonic-gate /* Length of the space taken up by a padded control message of length len */
424*0Sstevel@tonic-gate #ifndef CMSG_SPACE
425*0Sstevel@tonic-gate #define	CMSG_SPACE(len)	(__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(len))
426*0Sstevel@tonic-gate #endif
427*0Sstevel@tonic-gate 
428*0Sstevel@tonic-gate /* Function replacement / compatibility hacks */
429*0Sstevel@tonic-gate 
430*0Sstevel@tonic-gate #if !defined(HAVE_GETADDRINFO) && (defined(HAVE_OGETADDRINFO) || defined(HAVE_NGETADDRINFO))
431*0Sstevel@tonic-gate # define HAVE_GETADDRINFO
432*0Sstevel@tonic-gate #endif
433*0Sstevel@tonic-gate 
434*0Sstevel@tonic-gate #ifndef HAVE_GETOPT_OPTRESET
435*0Sstevel@tonic-gate # undef getopt
436*0Sstevel@tonic-gate # undef opterr
437*0Sstevel@tonic-gate # undef optind
438*0Sstevel@tonic-gate # undef optopt
439*0Sstevel@tonic-gate # undef optreset
440*0Sstevel@tonic-gate # undef optarg
441*0Sstevel@tonic-gate # define getopt(ac, av, o)  BSDgetopt(ac, av, o)
442*0Sstevel@tonic-gate # define opterr             BSDopterr
443*0Sstevel@tonic-gate # define optind             BSDoptind
444*0Sstevel@tonic-gate # define optopt             BSDoptopt
445*0Sstevel@tonic-gate # define optreset           BSDoptreset
446*0Sstevel@tonic-gate # define optarg             BSDoptarg
447*0Sstevel@tonic-gate #endif
448*0Sstevel@tonic-gate 
449*0Sstevel@tonic-gate /* In older versions of libpam, pam_strerror takes a single argument */
450*0Sstevel@tonic-gate #ifdef HAVE_OLD_PAM
451*0Sstevel@tonic-gate # define PAM_STRERROR(a,b) pam_strerror((b))
452*0Sstevel@tonic-gate #else
453*0Sstevel@tonic-gate # define PAM_STRERROR(a,b) pam_strerror((a),(b))
454*0Sstevel@tonic-gate #endif
455*0Sstevel@tonic-gate 
456*0Sstevel@tonic-gate #ifdef PAM_SUN_CODEBASE
457*0Sstevel@tonic-gate # define PAM_MSG_MEMBER(msg, n, member) ((*(msg))[(n)].member)
458*0Sstevel@tonic-gate #else
459*0Sstevel@tonic-gate # define PAM_MSG_MEMBER(msg, n, member) ((msg)[(n)]->member)
460*0Sstevel@tonic-gate #endif
461*0Sstevel@tonic-gate 
462*0Sstevel@tonic-gate #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO)
463*0Sstevel@tonic-gate # undef HAVE_GETADDRINFO
464*0Sstevel@tonic-gate #endif
465*0Sstevel@tonic-gate #if defined(BROKEN_GETADDRINFO) && defined(HAVE_FREEADDRINFO)
466*0Sstevel@tonic-gate # undef HAVE_FREEADDRINFO
467*0Sstevel@tonic-gate #endif
468*0Sstevel@tonic-gate #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GAI_STRERROR)
469*0Sstevel@tonic-gate # undef HAVE_GAI_STRERROR
470*0Sstevel@tonic-gate #endif
471*0Sstevel@tonic-gate 
472*0Sstevel@tonic-gate #if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY)
473*0Sstevel@tonic-gate # define memmove(s1, s2, n) bcopy((s2), (s1), (n))
474*0Sstevel@tonic-gate #endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */
475*0Sstevel@tonic-gate 
476*0Sstevel@tonic-gate #if defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX)
477*0Sstevel@tonic-gate #  define USE_VHANGUP
478*0Sstevel@tonic-gate #endif /* defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) */
479*0Sstevel@tonic-gate 
480*0Sstevel@tonic-gate #ifndef GETPGRP_VOID
481*0Sstevel@tonic-gate # define getpgrp() getpgrp(0)
482*0Sstevel@tonic-gate #endif
483*0Sstevel@tonic-gate 
484*0Sstevel@tonic-gate /* OPENSSL_free() is Free() in versions before OpenSSL 0.9.6 */
485*0Sstevel@tonic-gate #if !defined(OPENSSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER < 0x0090600f)
486*0Sstevel@tonic-gate # define OPENSSL_free(x) Free(x)
487*0Sstevel@tonic-gate #endif
488*0Sstevel@tonic-gate 
489*0Sstevel@tonic-gate #if !defined(HAVE___func__) && defined(HAVE___FUNCTION__)
490*0Sstevel@tonic-gate #  define __func__ __FUNCTION__
491*0Sstevel@tonic-gate #elif !defined(HAVE___func__)
492*0Sstevel@tonic-gate #  define __func__ ""
493*0Sstevel@tonic-gate #endif
494*0Sstevel@tonic-gate 
495*0Sstevel@tonic-gate /*
496*0Sstevel@tonic-gate  * Define this to use pipes instead of socketpairs for communicating with the
497*0Sstevel@tonic-gate  * client program.  Socketpairs do not seem to work on all systems.
498*0Sstevel@tonic-gate  *
499*0Sstevel@tonic-gate  * configure.ac sets this for a few OS's which are known to have problems
500*0Sstevel@tonic-gate  * but you may need to set it yourself
501*0Sstevel@tonic-gate  */
502*0Sstevel@tonic-gate /* #define USE_PIPES 1 */
503*0Sstevel@tonic-gate 
504*0Sstevel@tonic-gate /**
505*0Sstevel@tonic-gate  ** login recorder definitions
506*0Sstevel@tonic-gate  **/
507*0Sstevel@tonic-gate 
508*0Sstevel@tonic-gate /* FIXME: put default paths back in */
509*0Sstevel@tonic-gate #ifndef UTMP_FILE
510*0Sstevel@tonic-gate #  ifdef _PATH_UTMP
511*0Sstevel@tonic-gate #    define UTMP_FILE _PATH_UTMP
512*0Sstevel@tonic-gate #  else
513*0Sstevel@tonic-gate #    ifdef CONF_UTMP_FILE
514*0Sstevel@tonic-gate #      define UTMP_FILE CONF_UTMP_FILE
515*0Sstevel@tonic-gate #    endif
516*0Sstevel@tonic-gate #  endif
517*0Sstevel@tonic-gate #endif
518*0Sstevel@tonic-gate #ifndef WTMP_FILE
519*0Sstevel@tonic-gate #  ifdef _PATH_WTMP
520*0Sstevel@tonic-gate #    define WTMP_FILE _PATH_WTMP
521*0Sstevel@tonic-gate #  else
522*0Sstevel@tonic-gate #    ifdef CONF_WTMP_FILE
523*0Sstevel@tonic-gate #      define WTMP_FILE CONF_WTMP_FILE
524*0Sstevel@tonic-gate #    endif
525*0Sstevel@tonic-gate #  endif
526*0Sstevel@tonic-gate #endif
527*0Sstevel@tonic-gate /* pick up the user's location for lastlog if given */
528*0Sstevel@tonic-gate #ifndef LASTLOG_FILE
529*0Sstevel@tonic-gate #  ifdef _PATH_LASTLOG
530*0Sstevel@tonic-gate #    define LASTLOG_FILE _PATH_LASTLOG
531*0Sstevel@tonic-gate #  else
532*0Sstevel@tonic-gate #    ifdef CONF_LASTLOG_FILE
533*0Sstevel@tonic-gate #      define LASTLOG_FILE CONF_LASTLOG_FILE
534*0Sstevel@tonic-gate #    endif
535*0Sstevel@tonic-gate #  endif
536*0Sstevel@tonic-gate #endif
537*0Sstevel@tonic-gate 
538*0Sstevel@tonic-gate 
539*0Sstevel@tonic-gate /* The login() library function in libutil is first choice */
540*0Sstevel@tonic-gate #if defined(HAVE_LOGIN) && !defined(DISABLE_LOGIN)
541*0Sstevel@tonic-gate #  define USE_LOGIN
542*0Sstevel@tonic-gate 
543*0Sstevel@tonic-gate #else
544*0Sstevel@tonic-gate /* Simply select your favourite login types. */
545*0Sstevel@tonic-gate /* Can't do if-else because some systems use several... <sigh> */
546*0Sstevel@tonic-gate #  if defined(UTMPX_FILE) && !defined(DISABLE_UTMPX)
547*0Sstevel@tonic-gate #    define USE_UTMPX
548*0Sstevel@tonic-gate #  endif
549*0Sstevel@tonic-gate #  if defined(UTMP_FILE) && !defined(DISABLE_UTMP)
550*0Sstevel@tonic-gate #    define USE_UTMP
551*0Sstevel@tonic-gate #  endif
552*0Sstevel@tonic-gate #  if defined(WTMPX_FILE) && !defined(DISABLE_WTMPX)
553*0Sstevel@tonic-gate #    define USE_WTMPX
554*0Sstevel@tonic-gate #  endif
555*0Sstevel@tonic-gate #  if defined(WTMP_FILE) && !defined(DISABLE_WTMP)
556*0Sstevel@tonic-gate #    define USE_WTMP
557*0Sstevel@tonic-gate #  endif
558*0Sstevel@tonic-gate 
559*0Sstevel@tonic-gate #endif
560*0Sstevel@tonic-gate 
561*0Sstevel@tonic-gate /* I hope that the presence of LASTLOG_FILE is enough to detect this */
562*0Sstevel@tonic-gate #if defined(LASTLOG_FILE) && !defined(DISABLE_LASTLOG)
563*0Sstevel@tonic-gate #  define USE_LASTLOG
564*0Sstevel@tonic-gate #endif
565*0Sstevel@tonic-gate 
566*0Sstevel@tonic-gate /** end of login recorder definitions */
567*0Sstevel@tonic-gate 
568*0Sstevel@tonic-gate #ifdef __cplusplus
569*0Sstevel@tonic-gate }
570*0Sstevel@tonic-gate #endif
571*0Sstevel@tonic-gate 
572*0Sstevel@tonic-gate #endif /* _DEFINES_H */
573