xref: /onnv-gate/usr/src/cmd/ssh/include/defines.h (revision 11802:78df4fbee1b2)
10Sstevel@tonic-gate /*
25087Sjp161948  * Copyright (c) 1999-2003 Damien Miller.  All rights reserved.
35087Sjp161948  *
45087Sjp161948  * Redistribution and use in source and binary forms, with or without
55087Sjp161948  * modification, are permitted provided that the following conditions
65087Sjp161948  * are met:
75087Sjp161948  * 1. Redistributions of source code must retain the above copyright
85087Sjp161948  *    notice, this list of conditions and the following disclaimer.
95087Sjp161948  * 2. Redistributions in binary form must reproduce the above copyright
105087Sjp161948  *    notice, this list of conditions and the following disclaimer in the
115087Sjp161948  *    documentation and/or other materials provided with the distribution.
125087Sjp161948  *
135087Sjp161948  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
145087Sjp161948  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
155087Sjp161948  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
165087Sjp161948  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
175087Sjp161948  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
185087Sjp161948  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
195087Sjp161948  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
205087Sjp161948  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
215087Sjp161948  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
225087Sjp161948  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
235087Sjp161948  */
245087Sjp161948 /*
25*11802SJan.Pechanec@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
260Sstevel@tonic-gate  * Use is subject to license terms.
270Sstevel@tonic-gate  */
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifndef	_DEFINES_H
300Sstevel@tonic-gate #define	_DEFINES_H
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifdef __cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
360Sstevel@tonic-gate /* $Id: defines.h,v 1.96 2002/09/26 00:38:48 tim Exp $ */
370Sstevel@tonic-gate 
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /* Constants */
400Sstevel@tonic-gate #ifndef SHUT_RDWR
410Sstevel@tonic-gate enum
420Sstevel@tonic-gate {
435685Sjp161948 	SHUT_RD = 0,	/* No more receptions.  */
445685Sjp161948 	SHUT_WR,	/* No more transmissions.  */
455685Sjp161948 	SHUT_RDWR	/* No more receptions or transmissions. */
460Sstevel@tonic-gate };
475685Sjp161948 #define	SHUT_RD   SHUT_RD
485685Sjp161948 #define	SHUT_WR   SHUT_WR
495685Sjp161948 #define	SHUT_RDWR SHUT_RDWR
500Sstevel@tonic-gate #endif
510Sstevel@tonic-gate 
520Sstevel@tonic-gate #ifndef IPTOS_LOWDELAY
535685Sjp161948 #define	IPTOS_LOWDELAY		0x10
545685Sjp161948 #define	IPTOS_THROUGHPUT	0x08
555685Sjp161948 #define	IPTOS_RELIABILITY	0x04
565685Sjp161948 #define	IPTOS_LOWCOST		0x02
575685Sjp161948 #define	IPTOS_MINCOST		IPTOS_LOWCOST
580Sstevel@tonic-gate #endif /* IPTOS_LOWDELAY */
590Sstevel@tonic-gate 
600Sstevel@tonic-gate #ifndef MAXPATHLEN
615685Sjp161948 #ifdef PATH_MAX
625685Sjp161948 #define	MAXPATHLEN PATH_MAX
635685Sjp161948 #else /* PATH_MAX */
645685Sjp161948 #define	MAXPATHLEN 64 /* Should be safe */
655685Sjp161948 #endif /* PATH_MAX */
660Sstevel@tonic-gate #endif /* MAXPATHLEN */
670Sstevel@tonic-gate 
680Sstevel@tonic-gate #ifndef STDIN_FILENO
695685Sjp161948 #define	STDIN_FILENO    0
700Sstevel@tonic-gate #endif
715685Sjp161948 
720Sstevel@tonic-gate #ifndef STDOUT_FILENO
735685Sjp161948 #define	STDOUT_FILENO   1
740Sstevel@tonic-gate #endif
755685Sjp161948 
760Sstevel@tonic-gate #ifndef STDERR_FILENO
775685Sjp161948 #define	STDERR_FILENO   2
780Sstevel@tonic-gate #endif
790Sstevel@tonic-gate 
805600Sjp161948 /* Disable groupaccess if NGROUPS_UMAX, NGROUPS_MAX and NGROUPS are not set */
815600Sjp161948 #ifndef NGROUPS_UMAX
825600Sjp161948 #ifdef NGROUPS_MAX
835685Sjp161948 #define	NGROUPS_UMAX NGROUPS_MAX
845600Sjp161948 #elif defined(NGROUPS)
855685Sjp161948 #define	NGROUPS_UMAX NGROUPS
860Sstevel@tonic-gate #else
875685Sjp161948 #define	NGROUPS_UMAX 0
880Sstevel@tonic-gate #endif
890Sstevel@tonic-gate #endif
900Sstevel@tonic-gate 
910Sstevel@tonic-gate #ifndef O_NONBLOCK	/* Non Blocking Open */
925685Sjp161948 #define	O_NONBLOCK	00004
930Sstevel@tonic-gate #endif
940Sstevel@tonic-gate 
950Sstevel@tonic-gate #ifndef S_ISDIR
965685Sjp161948 #define	S_ISDIR(mode)	(((mode) & (_S_IFMT)) == (_S_IFDIR))
970Sstevel@tonic-gate #endif /* S_ISDIR */
980Sstevel@tonic-gate 
995685Sjp161948 #ifndef S_ISREG
1005685Sjp161948 #define	S_ISREG(mode)	(((mode) & (_S_IFMT)) == (_S_IFREG))
1010Sstevel@tonic-gate #endif /* S_ISREG */
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate #ifndef S_ISLNK
1045685Sjp161948 #define	S_ISLNK(mode)	(((mode) & S_IFMT) == S_IFLNK)
1050Sstevel@tonic-gate #endif /* S_ISLNK */
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate #ifndef S_IXUSR
1085685Sjp161948 #define	S_IXUSR			0000100	/* execute/search permission, */
1095685Sjp161948 #define	S_IXGRP			0000010	/* execute/search permission, */
1105685Sjp161948 #define	S_IXOTH			0000001	/* execute/search permission, */
1115685Sjp161948 #define	_S_IWUSR		0000200	/* write permission, */
1125685Sjp161948 #define	S_IWUSR			_S_IWUSR /* write permission, owner */
1135685Sjp161948 #define	S_IWGRP			0000020	/* write permission, group */
1145685Sjp161948 #define	S_IWOTH			0000002	/* write permission, other */
1155685Sjp161948 #define	S_IRUSR			0000400	/* read permission, owner */
1165685Sjp161948 #define	S_IRGRP			0000040	/* read permission, group */
1175685Sjp161948 #define	S_IROTH			0000004	/* read permission, other */
1185685Sjp161948 #define	S_IRWXU			0000700	/* read, write, execute */
1195685Sjp161948 #define	S_IRWXG			0000070	/* read, write, execute */
1205685Sjp161948 #define	S_IRWXO			0000007	/* read, write, execute */
1210Sstevel@tonic-gate #endif /* S_IXUSR */
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
1245685Sjp161948 #define	MAP_ANON MAP_ANONYMOUS
1250Sstevel@tonic-gate #endif
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate #ifndef MAP_FAILED
1285685Sjp161948 #define	MAP_FAILED ((void *)-1)
1290Sstevel@tonic-gate #endif
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate /* *-*-nto-qnx doesn't define this constant in the system headers */
1320Sstevel@tonic-gate #ifdef MISSING_NFDBITS
1335685Sjp161948 #define	NFDBITS (8 * sizeof (unsigned long))
1340Sstevel@tonic-gate #endif
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate /*
1375685Sjp161948  * SCO Open Server 3 has INADDR_LOOPBACK defined in rpc/rpc.h but including
1385685Sjp161948  * rpc/rpc.h breaks Solaris 6
1395685Sjp161948  */
1400Sstevel@tonic-gate #ifndef INADDR_LOOPBACK
1415685Sjp161948 #define	INADDR_LOOPBACK ((ulong_t)0x7f000001)
1420Sstevel@tonic-gate #endif
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate /* Types */
1450Sstevel@tonic-gate 
1465685Sjp161948 /*
1475685Sjp161948  * If sys/types.h does not supply intXX_t, supply them ourselves (or die trying)
1485685Sjp161948  */
1490Sstevel@tonic-gate #ifndef HAVE_U_INT
1505685Sjp161948 /* for now, we can't remove u_int without changing almost all other files */
1515685Sjp161948 /* CSTYLED */
1520Sstevel@tonic-gate typedef unsigned int u_int;
1530Sstevel@tonic-gate #endif
1540Sstevel@tonic-gate 
1550Sstevel@tonic-gate #ifndef HAVE_INTXX_T
1565685Sjp161948 #if (SIZEOF_CHAR == 1)
1570Sstevel@tonic-gate typedef char int8_t;
1585685Sjp161948 #else
1595685Sjp161948 #error "8 bit int type not found."
1605685Sjp161948 #endif
1615685Sjp161948 #if (SIZEOF_SHORT_INT == 2)
1620Sstevel@tonic-gate typedef short int int16_t;
1635685Sjp161948 #else
1645685Sjp161948 #ifdef _UNICOS
1655685Sjp161948 #if (SIZEOF_SHORT_INT == 4)
1660Sstevel@tonic-gate typedef short int16_t;
1675685Sjp161948 #else
1680Sstevel@tonic-gate typedef long  int16_t;
1695685Sjp161948 #endif
1705685Sjp161948 #else
1715685Sjp161948 #error "16 bit int type not found."
1725685Sjp161948 #endif /* _UNICOS */
1735685Sjp161948 #endif
1745685Sjp161948 #if (SIZEOF_INT == 4)
1750Sstevel@tonic-gate typedef int int32_t;
1765685Sjp161948 #else
1775685Sjp161948 #ifdef _UNICOS
1780Sstevel@tonic-gate typedef long  int32_t;
1795685Sjp161948 #else
1805685Sjp161948 #error "32 bit int type not found."
1815685Sjp161948 #endif /* _UNICOS */
1825685Sjp161948 #endif
1830Sstevel@tonic-gate #endif
1840Sstevel@tonic-gate 
1850Sstevel@tonic-gate /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
1860Sstevel@tonic-gate #ifndef HAVE_U_INTXX_T
1875685Sjp161948 #ifdef HAVE_UINTXX_T
1880Sstevel@tonic-gate typedef uint8_t u_int8_t;
1890Sstevel@tonic-gate typedef uint16_t u_int16_t;
1900Sstevel@tonic-gate typedef uint32_t u_int32_t;
1915685Sjp161948 #define	HAVE_U_INTXX_T 1
1925685Sjp161948 #else
1935685Sjp161948 #if (SIZEOF_CHAR == 1)
1940Sstevel@tonic-gate typedef unsigned char u_int8_t;
1955685Sjp161948 #else
1965685Sjp161948 #error "8 bit int type not found."
1975685Sjp161948 #endif
1985685Sjp161948 #if (SIZEOF_SHORT_INT == 2)
1990Sstevel@tonic-gate typedef unsigned short int u_int16_t;
2005685Sjp161948 #else
2015685Sjp161948 #ifdef _UNICOS
2025685Sjp161948 #if (SIZEOF_SHORT_INT == 4)
2030Sstevel@tonic-gate typedef unsigned short u_int16_t;
2045685Sjp161948 #else
2050Sstevel@tonic-gate typedef unsigned long  u_int16_t;
2065685Sjp161948 #endif
2075685Sjp161948 #else
2085685Sjp161948 #error "16 bit int type not found."
2095685Sjp161948 #endif
2105685Sjp161948 #endif
2115685Sjp161948 #if (SIZEOF_INT == 4)
2120Sstevel@tonic-gate typedef unsigned int u_int32_t;
2135685Sjp161948 #else
2145685Sjp161948 #ifdef _UNICOS
2150Sstevel@tonic-gate typedef unsigned long  u_int32_t;
2165685Sjp161948 #else
2175685Sjp161948 #error "32 bit int type not found."
2185685Sjp161948 #endif
2195685Sjp161948 #endif
2205685Sjp161948 #endif
2215685Sjp161948 #define	__BIT_TYPES_DEFINED__
2220Sstevel@tonic-gate #endif
2230Sstevel@tonic-gate 
2240Sstevel@tonic-gate /* 64-bit types */
2250Sstevel@tonic-gate #ifndef HAVE_INT64_T
2265685Sjp161948 #if (SIZEOF_LONG_INT == 8)
2270Sstevel@tonic-gate typedef long int int64_t;
2285685Sjp161948 #define	HAVE_INT64_T 1
2295685Sjp161948 #else
2305685Sjp161948 #if (SIZEOF_LONG_LONG_INT == 8)
2310Sstevel@tonic-gate typedef long long int int64_t;
2325685Sjp161948 #define	HAVE_INT64_T 1
2335685Sjp161948 #endif
2340Sstevel@tonic-gate #endif
2355685Sjp161948 #endif
2365685Sjp161948 
2370Sstevel@tonic-gate #ifndef HAVE_U_INT64_T
2385685Sjp161948 #if (SIZEOF_LONG_INT == 8)
2390Sstevel@tonic-gate typedef unsigned long int u_int64_t;
2405685Sjp161948 #define	HAVE_U_INT64_T 1
2415685Sjp161948 #else
2425685Sjp161948 #if (SIZEOF_LONG_LONG_INT == 8)
2430Sstevel@tonic-gate typedef unsigned long long int u_int64_t;
2445685Sjp161948 #define	HAVE_U_INT64_T 1
2455685Sjp161948 #endif
2465685Sjp161948 #endif
2470Sstevel@tonic-gate #endif
2485685Sjp161948 
2490Sstevel@tonic-gate #if !defined(HAVE_LONG_LONG_INT) && (SIZEOF_LONG_LONG_INT == 8)
2505685Sjp161948 #define	HAVE_LONG_LONG_INT 1
2510Sstevel@tonic-gate #endif
2520Sstevel@tonic-gate 
2530Sstevel@tonic-gate #ifndef HAVE_U_CHAR
2545685Sjp161948 /* for now, we can't remove u_char without changing almost all other files */
2555685Sjp161948 /* CSTYLED */
2560Sstevel@tonic-gate typedef unsigned char u_char;
2575685Sjp161948 #define	HAVE_U_CHAR
2580Sstevel@tonic-gate #endif /* HAVE_U_CHAR */
2590Sstevel@tonic-gate 
2600Sstevel@tonic-gate #ifndef SIZE_T_MAX
2615685Sjp161948 #define	SIZE_T_MAX ULONG_MAX
2620Sstevel@tonic-gate #endif /* SIZE_T_MAX */
2630Sstevel@tonic-gate 
2640Sstevel@tonic-gate #ifndef HAVE_SIZE_T
2650Sstevel@tonic-gate typedef unsigned int size_t;
2665685Sjp161948 #define	HAVE_SIZE_T
2670Sstevel@tonic-gate #endif /* HAVE_SIZE_T */
2680Sstevel@tonic-gate 
2690Sstevel@tonic-gate #ifndef HAVE_SSIZE_T
2700Sstevel@tonic-gate typedef int ssize_t;
2715685Sjp161948 #define	HAVE_SSIZE_T
2720Sstevel@tonic-gate #endif /* HAVE_SSIZE_T */
2730Sstevel@tonic-gate 
2740Sstevel@tonic-gate #ifndef HAVE_CLOCK_T
2750Sstevel@tonic-gate typedef long clock_t;
2765685Sjp161948 #define	HAVE_CLOCK_T
2770Sstevel@tonic-gate #endif /* HAVE_CLOCK_T */
2780Sstevel@tonic-gate 
2790Sstevel@tonic-gate #ifndef HAVE_SA_FAMILY_T
2800Sstevel@tonic-gate typedef int sa_family_t;
2815685Sjp161948 #define	HAVE_SA_FAMILY_T
2820Sstevel@tonic-gate #endif /* HAVE_SA_FAMILY_T */
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate #ifndef HAVE_PID_T
2850Sstevel@tonic-gate typedef int pid_t;
2865685Sjp161948 #define	HAVE_PID_T
2870Sstevel@tonic-gate #endif /* HAVE_PID_T */
2880Sstevel@tonic-gate 
2890Sstevel@tonic-gate #ifndef HAVE_SIG_ATOMIC_T
2900Sstevel@tonic-gate typedef int sig_atomic_t;
2915685Sjp161948 #define	HAVE_SIG_ATOMIC_T
2920Sstevel@tonic-gate #endif /* HAVE_SIG_ATOMIC_T */
2930Sstevel@tonic-gate 
2940Sstevel@tonic-gate #ifndef HAVE_MODE_T
2950Sstevel@tonic-gate typedef int mode_t;
2965685Sjp161948 #define	HAVE_MODE_T
2970Sstevel@tonic-gate #endif /* HAVE_MODE_T */
2980Sstevel@tonic-gate 
2990Sstevel@tonic-gate #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS)
3005685Sjp161948 #define	ss_family __ss_family
3010Sstevel@tonic-gate #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */
3020Sstevel@tonic-gate 
3030Sstevel@tonic-gate #ifndef HAVE_SYS_UN_H
3040Sstevel@tonic-gate struct	sockaddr_un {
3050Sstevel@tonic-gate 	short	sun_family;		/* AF_UNIX */
3060Sstevel@tonic-gate 	char	sun_path[108];		/* path name (gag) */
3070Sstevel@tonic-gate };
3080Sstevel@tonic-gate #endif /* HAVE_SYS_UN_H */
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate #if defined(BROKEN_SYS_TERMIO_H) && !defined(_STRUCT_WINSIZE)
3115685Sjp161948 #define	_STRUCT_WINSIZE
3120Sstevel@tonic-gate struct winsize {
3135685Sjp161948 	unsigned short ws_row;		/* rows, in characters */
3145685Sjp161948 	unsigned short ws_col;		/* columns, in character */
3155685Sjp161948 	unsigned short ws_xpixel;	/* horizontal size, pixels */
3165685Sjp161948 	unsigned short ws_ypixel;	/* vertical size, pixels */
3170Sstevel@tonic-gate };
3180Sstevel@tonic-gate #endif
3190Sstevel@tonic-gate 
3200Sstevel@tonic-gate /* *-*-nto-qnx does not define this type in the system headers */
3210Sstevel@tonic-gate #ifdef MISSING_FD_MASK
3225685Sjp161948 typedef unsigned long int fd_mask;
3230Sstevel@tonic-gate #endif
3240Sstevel@tonic-gate 
3250Sstevel@tonic-gate /* Paths */
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate #ifndef _PATH_BSHELL
3285685Sjp161948 #define	_PATH_BSHELL "/bin/sh"
3290Sstevel@tonic-gate #endif
3305685Sjp161948 
3310Sstevel@tonic-gate #ifndef _PATH_CSHELL
3325685Sjp161948 #define	_PATH_CSHELL "/bin/csh"
3330Sstevel@tonic-gate #endif
3345685Sjp161948 
3350Sstevel@tonic-gate #ifndef _PATH_SHELLS
3365685Sjp161948 #define	_PATH_SHELLS "/etc/shells"
3370Sstevel@tonic-gate #endif
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate #ifdef USER_PATH
3405685Sjp161948 #ifdef _PATH_STDPATH
3415685Sjp161948 #undef _PATH_STDPATH
3425685Sjp161948 #endif
3435685Sjp161948 #define	_PATH_STDPATH USER_PATH
3440Sstevel@tonic-gate #endif
3450Sstevel@tonic-gate 
3460Sstevel@tonic-gate #ifndef _PATH_STDPATH
3475685Sjp161948 #define	_PATH_STDPATH "/usr/bin"
3480Sstevel@tonic-gate #endif
3490Sstevel@tonic-gate 
3500Sstevel@tonic-gate #ifndef _PATH_DEVNULL
3515685Sjp161948 #define	_PATH_DEVNULL "/dev/null"
3520Sstevel@tonic-gate #endif
3530Sstevel@tonic-gate 
3540Sstevel@tonic-gate #ifndef MAIL_DIRECTORY
3555685Sjp161948 #define	MAIL_DIRECTORY "/var/spool/mail"
3560Sstevel@tonic-gate #endif
3570Sstevel@tonic-gate 
3580Sstevel@tonic-gate #ifndef MAILDIR
3595685Sjp161948 #define	MAILDIR MAIL_DIRECTORY
3600Sstevel@tonic-gate #endif
3610Sstevel@tonic-gate 
3620Sstevel@tonic-gate #if !defined(_PATH_MAILDIR) && defined(MAILDIR)
3635685Sjp161948 #define	_PATH_MAILDIR MAILDIR
3640Sstevel@tonic-gate #endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */
3650Sstevel@tonic-gate 
3660Sstevel@tonic-gate #ifndef _PATH_RSH
3675685Sjp161948 #ifdef RSH_PATH
3685685Sjp161948 #define	_PATH_RSH RSH_PATH
3695685Sjp161948 #else /* RSH_PATH */
3705685Sjp161948 #define	_PATH_RSH "/usr/bin/rsh"
3715685Sjp161948 #endif /* RSH_PATH */
3720Sstevel@tonic-gate #endif /* _PATH_RSH */
3730Sstevel@tonic-gate 
3740Sstevel@tonic-gate #ifndef _PATH_NOLOGIN
3755685Sjp161948 #define	_PATH_NOLOGIN "/etc/nologin"
3760Sstevel@tonic-gate #endif
3770Sstevel@tonic-gate 
3780Sstevel@tonic-gate /* Define this to be the path of the xauth program. */
3790Sstevel@tonic-gate #ifdef XAUTH_PATH
3805685Sjp161948 #define	_PATH_XAUTH XAUTH_PATH
3810Sstevel@tonic-gate #endif /* XAUTH_PATH */
3820Sstevel@tonic-gate 
3830Sstevel@tonic-gate /* derived from XF4/xc/lib/dps/Xlibnet.h */
3840Sstevel@tonic-gate #ifndef X_UNIX_PATH
3855685Sjp161948 #ifdef __hpux
3865685Sjp161948 #define	X_UNIX_PATH "/var/spool/sockets/X11/%u"
3875685Sjp161948 #else
3885685Sjp161948 #define	X_UNIX_PATH "/tmp/.X11-unix/X%u"
3895685Sjp161948 #endif
3900Sstevel@tonic-gate #endif /* X_UNIX_PATH */
3915685Sjp161948 
3925685Sjp161948 #define	_PATH_UNIX_X X_UNIX_PATH
3930Sstevel@tonic-gate 
3940Sstevel@tonic-gate #ifndef _PATH_TTY
3955685Sjp161948 #define	_PATH_TTY "/dev/tty"
3960Sstevel@tonic-gate #endif
3970Sstevel@tonic-gate 
3980Sstevel@tonic-gate /* Macros */
3990Sstevel@tonic-gate 
4000Sstevel@tonic-gate #ifndef MAX
4015685Sjp161948 #define	MAX(a, b) (((a) > (b)) ? (a) : (b))
4025685Sjp161948 #define	MIN(a, b) (((a) < (b)) ? (a) : (b))
4030Sstevel@tonic-gate #endif
4040Sstevel@tonic-gate 
4050Sstevel@tonic-gate #ifndef roundup
4065685Sjp161948 #define	roundup(x, y)   ((((x) + ((y) - 1)) / (y)) * (y))
4070Sstevel@tonic-gate #endif
4080Sstevel@tonic-gate 
4090Sstevel@tonic-gate #ifndef timersub
4105685Sjp161948 #define	timersub(a, b, result)						\
4115685Sjp161948 	do {								\
4125685Sjp161948 		(result)->tv_sec = (a)->tv_sec - (b)->tv_sec;		\
4135685Sjp161948 		(result)->tv_usec = (a)->tv_usec - (b)->tv_usec;	\
4145685Sjp161948 		if ((result)->tv_usec < 0) {				\
4155685Sjp161948 			--(result)->tv_sec;				\
4165685Sjp161948 			(result)->tv_usec += 1000000;			\
4175685Sjp161948 		}							\
4185685Sjp161948 	} while (0)
4190Sstevel@tonic-gate #endif
4200Sstevel@tonic-gate 
4210Sstevel@tonic-gate #ifndef __P
4225685Sjp161948 #define	__P(x) x
4230Sstevel@tonic-gate #endif
4240Sstevel@tonic-gate 
4250Sstevel@tonic-gate #if !defined(IN6_IS_ADDR_V4MAPPED)
4265685Sjp161948 #define	IN6_IS_ADDR_V4MAPPED(a) \
4275685Sjp161948 	((((u_int32_t *)(a))[0] == 0) && (((u_int32_t *)(a))[1] == 0) && \
4285685Sjp161948 	(((u_int32_t *)(a))[2] == htonl(0xffff)))
4290Sstevel@tonic-gate #endif /* !defined(IN6_IS_ADDR_V4MAPPED) */
4300Sstevel@tonic-gate 
4310Sstevel@tonic-gate #if !defined(__GNUC__) || (__GNUC__ < 2)
4325685Sjp161948 #define	__attribute__(x)
4330Sstevel@tonic-gate #endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
4340Sstevel@tonic-gate 
4355087Sjp161948 #if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__)
4365685Sjp161948 #define	__bounded__(x, y, z)
4375087Sjp161948 #endif
4385087Sjp161948 
4390Sstevel@tonic-gate /* *-*-nto-qnx doesn't define this macro in the system headers */
4400Sstevel@tonic-gate #ifdef MISSING_HOWMANY
4415685Sjp161948 #define	howmany(x, y)	(((x) + ((y) - 1)) / (y))
4420Sstevel@tonic-gate #endif
4430Sstevel@tonic-gate 
4440Sstevel@tonic-gate #ifndef OSSH_ALIGNBYTES
4455685Sjp161948 #define	OSSH_ALIGNBYTES	(sizeof (int) - 1)
4460Sstevel@tonic-gate #endif
4475685Sjp161948 
4480Sstevel@tonic-gate #ifndef __CMSG_ALIGN
4495685Sjp161948 #define	__CMSG_ALIGN(p) (((uint_t)(p) + OSSH_ALIGNBYTES) &~ OSSH_ALIGNBYTES)
4500Sstevel@tonic-gate #endif
4510Sstevel@tonic-gate 
4520Sstevel@tonic-gate /* Length of the contents of a control message of length len */
4530Sstevel@tonic-gate #ifndef CMSG_LEN
4545685Sjp161948 #define	CMSG_LEN(len)	(__CMSG_ALIGN(sizeof (struct cmsghdr)) + (len))
4550Sstevel@tonic-gate #endif
4560Sstevel@tonic-gate 
4570Sstevel@tonic-gate /* Length of the space taken up by a padded control message of length len */
4580Sstevel@tonic-gate #ifndef CMSG_SPACE
4595685Sjp161948 #define	CMSG_SPACE(len)	\
4605685Sjp161948 	(__CMSG_ALIGN(sizeof (struct cmsghdr)) + __CMSG_ALIGN(len))
4610Sstevel@tonic-gate #endif
4620Sstevel@tonic-gate 
4630Sstevel@tonic-gate /* Function replacement / compatibility hacks */
4640Sstevel@tonic-gate 
4655685Sjp161948 #if !defined(HAVE_GETADDRINFO) && (defined(HAVE_OGETADDRINFO) || \
4665685Sjp161948 	defined(HAVE_NGETADDRINFO))
4675685Sjp161948 #define	HAVE_GETADDRINFO
4680Sstevel@tonic-gate #endif
4690Sstevel@tonic-gate 
4700Sstevel@tonic-gate #ifndef HAVE_GETOPT_OPTRESET
4715685Sjp161948 #undef getopt
4725685Sjp161948 #undef opterr
4735685Sjp161948 #undef optind
4745685Sjp161948 #undef optopt
4755685Sjp161948 #undef optreset
4765685Sjp161948 #undef optarg
4775685Sjp161948 #define	getopt(ac, av, o)	BSDgetopt(ac, av, o)
4785685Sjp161948 #define	opterr			BSDopterr
4795685Sjp161948 #define	optind			BSDoptind
4805685Sjp161948 #define	optopt			BSDoptopt
4815685Sjp161948 #define	optreset		BSDoptreset
4825685Sjp161948 #define	optarg			BSDoptarg
4830Sstevel@tonic-gate #endif
4840Sstevel@tonic-gate 
4850Sstevel@tonic-gate /* In older versions of libpam, pam_strerror takes a single argument */
4860Sstevel@tonic-gate #ifdef HAVE_OLD_PAM
4875685Sjp161948 #define	PAM_STRERROR(a, b) pam_strerror((b))
4880Sstevel@tonic-gate #else
4895685Sjp161948 #define	PAM_STRERROR(a, b) pam_strerror((a), (b))
4900Sstevel@tonic-gate #endif
4910Sstevel@tonic-gate 
4920Sstevel@tonic-gate #ifdef PAM_SUN_CODEBASE
4935685Sjp161948 #define	PAM_MSG_MEMBER(msg, n, member) ((*(msg))[(n)].member)
4940Sstevel@tonic-gate #else
4955685Sjp161948 #define	PAM_MSG_MEMBER(msg, n, member) ((msg)[(n)]->member)
4960Sstevel@tonic-gate #endif
4970Sstevel@tonic-gate 
4980Sstevel@tonic-gate #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO)
4995685Sjp161948 #undef HAVE_GETADDRINFO
5000Sstevel@tonic-gate #endif
5015685Sjp161948 
5020Sstevel@tonic-gate #if defined(BROKEN_GETADDRINFO) && defined(HAVE_FREEADDRINFO)
5035685Sjp161948 #undef HAVE_FREEADDRINFO
5040Sstevel@tonic-gate #endif
5055685Sjp161948 
5060Sstevel@tonic-gate #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GAI_STRERROR)
5075685Sjp161948 #undef HAVE_GAI_STRERROR
5080Sstevel@tonic-gate #endif
5090Sstevel@tonic-gate 
5100Sstevel@tonic-gate #if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY)
5115685Sjp161948 #define	memmove(s1, s2, n) bcopy((s2), (s1), (n))
5120Sstevel@tonic-gate #endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */
5130Sstevel@tonic-gate 
5140Sstevel@tonic-gate #if defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX)
5155685Sjp161948 #define	USE_VHANGUP
5160Sstevel@tonic-gate #endif /* defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) */
5170Sstevel@tonic-gate 
5180Sstevel@tonic-gate #ifndef GETPGRP_VOID
5195685Sjp161948 #define	getpgrp() getpgrp(0)
5200Sstevel@tonic-gate #endif
5210Sstevel@tonic-gate 
5220Sstevel@tonic-gate /* OPENSSL_free() is Free() in versions before OpenSSL 0.9.6 */
5230Sstevel@tonic-gate #if !defined(OPENSSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER < 0x0090600f)
5245685Sjp161948 #define	OPENSSL_free(x) Free(x)
5250Sstevel@tonic-gate #endif
5260Sstevel@tonic-gate 
5270Sstevel@tonic-gate #if !defined(HAVE___func__) && defined(HAVE___FUNCTION__)
5285685Sjp161948 #define	__func__ __FUNCTION__
5290Sstevel@tonic-gate #elif !defined(HAVE___func__)
5305685Sjp161948 #define	__func__ ""
5310Sstevel@tonic-gate #endif
5320Sstevel@tonic-gate 
5330Sstevel@tonic-gate /*
5345685Sjp161948  * login recorder definitions
5355685Sjp161948  */
5360Sstevel@tonic-gate 
5370Sstevel@tonic-gate /* FIXME: put default paths back in */
5380Sstevel@tonic-gate #ifndef UTMP_FILE
5395685Sjp161948 #ifdef _PATH_UTMP
5405685Sjp161948 #define	UTMP_FILE _PATH_UTMP
5415685Sjp161948 #else
5425685Sjp161948 #ifdef CONF_UTMP_FILE
5435685Sjp161948 #define	UTMP_FILE CONF_UTMP_FILE
5440Sstevel@tonic-gate #endif
5455685Sjp161948 #endif
5465685Sjp161948 #endif
5475685Sjp161948 
5480Sstevel@tonic-gate #ifndef WTMP_FILE
5495685Sjp161948 #ifdef _PATH_WTMP
5505685Sjp161948 #define	WTMP_FILE _PATH_WTMP
5515685Sjp161948 #else
5525685Sjp161948 #ifdef CONF_WTMP_FILE
5535685Sjp161948 #define	WTMP_FILE CONF_WTMP_FILE
5540Sstevel@tonic-gate #endif
5555685Sjp161948 #endif
5565685Sjp161948 #endif
5575685Sjp161948 
5580Sstevel@tonic-gate /* pick up the user's location for lastlog if given */
5590Sstevel@tonic-gate #ifndef LASTLOG_FILE
5605685Sjp161948 #ifdef _PATH_LASTLOG
5615685Sjp161948 #define	LASTLOG_FILE _PATH_LASTLOG
5625685Sjp161948 #else
5635685Sjp161948 #ifdef CONF_LASTLOG_FILE
5645685Sjp161948 #define	LASTLOG_FILE CONF_LASTLOG_FILE
5650Sstevel@tonic-gate #endif
5665685Sjp161948 #endif
5675685Sjp161948 #endif
5680Sstevel@tonic-gate 
5690Sstevel@tonic-gate /* The login() library function in libutil is first choice */
5700Sstevel@tonic-gate #if defined(HAVE_LOGIN) && !defined(DISABLE_LOGIN)
5715685Sjp161948 #define	USE_LOGIN
5720Sstevel@tonic-gate #else
5730Sstevel@tonic-gate /* Simply select your favourite login types. */
5740Sstevel@tonic-gate /* Can't do if-else because some systems use several... <sigh> */
5755685Sjp161948 #if defined(UTMPX_FILE) && !defined(DISABLE_UTMPX)
5765685Sjp161948 #define	USE_UTMPX
5775685Sjp161948 #endif
5785685Sjp161948 #if defined(UTMP_FILE) && !defined(DISABLE_UTMP)
5795685Sjp161948 #define	USE_UTMP
5805685Sjp161948 #endif
5815685Sjp161948 #if defined(WTMPX_FILE) && !defined(DISABLE_WTMPX)
5825685Sjp161948 #define	USE_WTMPX
5835685Sjp161948 #endif
5845685Sjp161948 #if defined(WTMP_FILE) && !defined(DISABLE_WTMP)
5855685Sjp161948 #define	USE_WTMP
5865685Sjp161948 #endif
5870Sstevel@tonic-gate #endif
5880Sstevel@tonic-gate 
5890Sstevel@tonic-gate /* I hope that the presence of LASTLOG_FILE is enough to detect this */
5900Sstevel@tonic-gate #if defined(LASTLOG_FILE) && !defined(DISABLE_LASTLOG)
5915685Sjp161948 #define	USE_LASTLOG
5920Sstevel@tonic-gate #endif
5930Sstevel@tonic-gate 
5945685Sjp161948 /* end of login recorder definitions */
5950Sstevel@tonic-gate 
5960Sstevel@tonic-gate #ifdef __cplusplus
5970Sstevel@tonic-gate }
5980Sstevel@tonic-gate #endif
5990Sstevel@tonic-gate 
6000Sstevel@tonic-gate #endif /* _DEFINES_H */
601