defines.h revision 192595
155682Smarkm/* 2178825Sdfr * Copyright (c) 1999-2003 Damien Miller. All rights reserved. 355682Smarkm * 455682Smarkm * Redistribution and use in source and binary forms, with or without 555682Smarkm * modification, are permitted provided that the following conditions 655682Smarkm * are met: 755682Smarkm * 1. Redistributions of source code must retain the above copyright 855682Smarkm * notice, this list of conditions and the following disclaimer. 955682Smarkm * 2. Redistributions in binary form must reproduce the above copyright 1055682Smarkm * notice, this list of conditions and the following disclaimer in the 1155682Smarkm * documentation and/or other materials provided with the distribution. 1255682Smarkm * 1355682Smarkm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1455682Smarkm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1555682Smarkm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1655682Smarkm * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1755682Smarkm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1855682Smarkm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1955682Smarkm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2055682Smarkm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2155682Smarkm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2255682Smarkm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2355682Smarkm */ 2455682Smarkm 2555682Smarkm#ifndef _DEFINES_H 2655682Smarkm#define _DEFINES_H 2755682Smarkm 2855682Smarkm/* $Id: defines.h,v 1.153 2009/02/01 11:19:54 dtucker Exp $ */ 2955682Smarkm 3055682Smarkm 3155682Smarkm/* Constants */ 3255682Smarkm 3355682Smarkm#if defined(HAVE_DECL_SHUT_RD) && HAVE_DECL_SHUT_RD == 0 3455682Smarkmenum 3555682Smarkm{ 36178825Sdfr SHUT_RD = 0, /* No more receptions. */ 3755682Smarkm SHUT_WR, /* No more transmissions. */ 3855682Smarkm SHUT_RDWR /* No more receptions or transmissions. */ 3955682Smarkm}; 4055682Smarkm# define SHUT_RD SHUT_RD 4155682Smarkm# define SHUT_WR SHUT_WR 4255682Smarkm# define SHUT_RDWR SHUT_RDWR 4355682Smarkm#endif 4455682Smarkm 4555682Smarkm#ifndef IPTOS_LOWDELAY 4655682Smarkm# define IPTOS_LOWDELAY 0x10 4755682Smarkm# define IPTOS_THROUGHPUT 0x08 48120945Snectar# define IPTOS_RELIABILITY 0x04 49120945Snectar# define IPTOS_LOWCOST 0x02 50120945Snectar# define IPTOS_MINCOST IPTOS_LOWCOST 51120945Snectar#endif /* IPTOS_LOWDELAY */ 52120945Snectar 5355682Smarkm#ifndef MAXPATHLEN 5455682Smarkm# ifdef PATH_MAX 5555682Smarkm# define MAXPATHLEN PATH_MAX 5655682Smarkm# else /* PATH_MAX */ 5755682Smarkm# define MAXPATHLEN 64 5855682Smarkm/* realpath uses a fixed buffer of size MAXPATHLEN, so force use of ours */ 5955682Smarkm# ifndef BROKEN_REALPATH 6055682Smarkm# define BROKEN_REALPATH 1 6155682Smarkm# endif /* BROKEN_REALPATH */ 62120945Snectar# endif /* PATH_MAX */ 63120945Snectar#endif /* MAXPATHLEN */ 64120945Snectar 65120945Snectar#ifndef PATH_MAX 66120945Snectar# ifdef _POSIX_PATH_MAX 67120945Snectar# define PATH_MAX _POSIX_PATH_MAX 68120945Snectar# endif 69120945Snectar#endif 70120945Snectar 7155682Smarkm#if defined(HAVE_DECL_MAXSYMLINKS) && HAVE_DECL_MAXSYMLINKS == 0 72120945Snectar# define MAXSYMLINKS 5 73120945Snectar#endif 7455682Smarkm 7555682Smarkm#ifndef STDIN_FILENO 76120945Snectar# define STDIN_FILENO 0 7755682Smarkm#endif 7855682Smarkm#ifndef STDOUT_FILENO 7955682Smarkm# define STDOUT_FILENO 1 8055682Smarkm#endif 8155682Smarkm#ifndef STDERR_FILENO 8255682Smarkm# define STDERR_FILENO 2 83120945Snectar#endif 8455682Smarkm 8555682Smarkm#ifndef NGROUPS_MAX /* Disable groupaccess if NGROUP_MAX is not set */ 86120945Snectar#ifdef NGROUPS 8755682Smarkm#define NGROUPS_MAX NGROUPS 8855682Smarkm#else 8955682Smarkm#define NGROUPS_MAX 0 9055682Smarkm#endif 91120945Snectar#endif 9255682Smarkm 9355682Smarkm#if defined(HAVE_DECL_O_NONBLOCK) && HAVE_DECL_O_NONBLOCK == 0 94120945Snectar# define O_NONBLOCK 00004 /* Non Blocking Open */ 9555682Smarkm#endif 9655682Smarkm 9755682Smarkm#ifndef S_ISDIR 9855682Smarkm# define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR)) 9955682Smarkm#endif /* S_ISDIR */ 10055682Smarkm 10155682Smarkm#ifndef S_ISREG 10255682Smarkm# define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG)) 10355682Smarkm#endif /* S_ISREG */ 10455682Smarkm 10555682Smarkm#ifndef S_ISLNK 10655682Smarkm# define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) 10755682Smarkm#endif /* S_ISLNK */ 10855682Smarkm 10955682Smarkm#ifndef S_IXUSR 11055682Smarkm# define S_IXUSR 0000100 /* execute/search permission, */ 11155682Smarkm# define S_IXGRP 0000010 /* execute/search permission, */ 11255682Smarkm# define S_IXOTH 0000001 /* execute/search permission, */ 11355682Smarkm# define _S_IWUSR 0000200 /* write permission, */ 11455682Smarkm# define S_IWUSR _S_IWUSR /* write permission, owner */ 11555682Smarkm# define S_IWGRP 0000020 /* write permission, group */ 11655682Smarkm# define S_IWOTH 0000002 /* write permission, other */ 117120945Snectar# define S_IRUSR 0000400 /* read permission, owner */ 118120945Snectar# define S_IRGRP 0000040 /* read permission, group */ 11955682Smarkm# define S_IROTH 0000004 /* read permission, other */ 12055682Smarkm# define S_IRWXU 0000700 /* read, write, execute */ 121120945Snectar# define S_IRWXG 0000070 /* read, write, execute */ 122120945Snectar# define S_IRWXO 0000007 /* read, write, execute */ 123120945Snectar#endif /* S_IXUSR */ 124120945Snectar 125120945Snectar#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS) 126120945Snectar#define MAP_ANON MAP_ANONYMOUS 127120945Snectar#endif 128120945Snectar 129120945Snectar#ifndef MAP_FAILED 130120945Snectar# define MAP_FAILED ((void *)-1) 131120945Snectar#endif 132120945Snectar 133120945Snectar/* *-*-nto-qnx doesn't define this constant in the system headers */ 134120945Snectar#ifdef MISSING_NFDBITS 135120945Snectar# define NFDBITS (8 * sizeof(unsigned long)) 136120945Snectar#endif 137120945Snectar 138120945Snectar/* 139120945SnectarSCO Open Server 3 has INADDR_LOOPBACK defined in rpc/rpc.h but 140120945Snectarincluding rpc/rpc.h breaks Solaris 6 141120945Snectar*/ 142120945Snectar#ifndef INADDR_LOOPBACK 143120945Snectar#define INADDR_LOOPBACK ((u_long)0x7f000001) 144120945Snectar#endif 145120945Snectar 146120945Snectar/* Types */ 147120945Snectar 148120945Snectar/* If sys/types.h does not supply intXX_t, supply them ourselves */ 149120945Snectar/* (or die trying) */ 150120945Snectar 151120945Snectar#ifndef HAVE_U_INT 152120945Snectartypedef unsigned int u_int; 153120945Snectar#endif 154120945Snectar 155120945Snectar#ifndef HAVE_INTXX_T 156120945Snectar# if (SIZEOF_CHAR == 1) 157120945Snectartypedef char int8_t; 158120945Snectar# else 159120945Snectar# error "8 bit int type not found." 160120945Snectar# endif 161120945Snectar# if (SIZEOF_SHORT_INT == 2) 162120945Snectartypedef short int int16_t; 163120945Snectar# else 164120945Snectar# ifdef _UNICOS 165120945Snectar# if (SIZEOF_SHORT_INT == 4) 166120945Snectartypedef short int16_t; 167120945Snectar# else 168120945Snectartypedef long int16_t; 169120945Snectar# endif 170120945Snectar# else 171120945Snectar# error "16 bit int type not found." 172120945Snectar# endif /* _UNICOS */ 17355682Smarkm# endif 17455682Smarkm# if (SIZEOF_INT == 4) 17555682Smarkmtypedef int int32_t; 17655682Smarkm# else 17755682Smarkm# ifdef _UNICOS 17855682Smarkmtypedef long int32_t; 17955682Smarkm# else 18055682Smarkm# error "32 bit int type not found." 18155682Smarkm# endif /* _UNICOS */ 18255682Smarkm# endif 18355682Smarkm#endif 18455682Smarkm 18555682Smarkm/* If sys/types.h does not supply u_intXX_t, supply them ourselves */ 18655682Smarkm#ifndef HAVE_U_INTXX_T 18755682Smarkm# ifdef HAVE_UINTXX_T 18855682Smarkmtypedef uint8_t u_int8_t; 18955682Smarkmtypedef uint16_t u_int16_t; 19055682Smarkmtypedef uint32_t u_int32_t; 19155682Smarkm# define HAVE_U_INTXX_T 1 19255682Smarkm# else 19355682Smarkm# if (SIZEOF_CHAR == 1) 19455682Smarkmtypedef unsigned char u_int8_t; 19555682Smarkm# else 19655682Smarkm# error "8 bit int type not found." 19755682Smarkm# endif 19855682Smarkm# if (SIZEOF_SHORT_INT == 2) 19955682Smarkmtypedef unsigned short int u_int16_t; 20055682Smarkm# else 20155682Smarkm# ifdef _UNICOS 20255682Smarkm# if (SIZEOF_SHORT_INT == 4) 203178825Sdfrtypedef unsigned short u_int16_t; 20455682Smarkm# else 20555682Smarkmtypedef unsigned long u_int16_t; 20655682Smarkm# endif 20755682Smarkm# else 208178825Sdfr# error "16 bit int type not found." 20955682Smarkm# endif 21055682Smarkm# endif 21155682Smarkm# if (SIZEOF_INT == 4) 21255682Smarkmtypedef unsigned int u_int32_t; 21355682Smarkm# else 21455682Smarkm# ifdef _UNICOS 21555682Smarkmtypedef unsigned long u_int32_t; 21655682Smarkm# else 21755682Smarkm# error "32 bit int type not found." 21855682Smarkm# endif 21955682Smarkm# endif 22055682Smarkm# endif 22155682Smarkm#define __BIT_TYPES_DEFINED__ 22255682Smarkm#endif 22355682Smarkm 22455682Smarkm/* 64-bit types */ 22555682Smarkm#ifndef HAVE_INT64_T 22655682Smarkm# if (SIZEOF_LONG_INT == 8) 22755682Smarkmtypedef long int int64_t; 22855682Smarkm# else 22955682Smarkm# if (SIZEOF_LONG_LONG_INT == 8) 23055682Smarkmtypedef long long int int64_t; 23155682Smarkm# endif 23255682Smarkm# endif 23355682Smarkm#endif 23455682Smarkm#ifndef HAVE_U_INT64_T 23555682Smarkm# if (SIZEOF_LONG_INT == 8) 23655682Smarkmtypedef unsigned long int u_int64_t; 23755682Smarkm# else 238178825Sdfr# if (SIZEOF_LONG_LONG_INT == 8) 23955682Smarkmtypedef unsigned long long int u_int64_t; 24055682Smarkm# endif 24155682Smarkm# endif 24255682Smarkm#endif 24355682Smarkm 24455682Smarkm#ifndef HAVE_U_CHAR 245178825Sdfrtypedef unsigned char u_char; 24655682Smarkm# define HAVE_U_CHAR 24755682Smarkm#endif /* HAVE_U_CHAR */ 24855682Smarkm 24955682Smarkm#ifndef SIZE_T_MAX 25055682Smarkm#define SIZE_T_MAX ULONG_MAX 25155682Smarkm#endif /* SIZE_T_MAX */ 25255682Smarkm 25355682Smarkm#ifndef HAVE_SIZE_T 25455682Smarkmtypedef unsigned int size_t; 25555682Smarkm# define HAVE_SIZE_T 25655682Smarkm# define SIZE_T_MAX UINT_MAX 25755682Smarkm#endif /* HAVE_SIZE_T */ 25855682Smarkm 259178825Sdfr#ifndef HAVE_SSIZE_T 260178825Sdfrtypedef int ssize_t; 26155682Smarkm# define HAVE_SSIZE_T 26255682Smarkm#endif /* HAVE_SSIZE_T */ 26355682Smarkm 264178825Sdfr#ifndef HAVE_CLOCK_T 26555682Smarkmtypedef long clock_t; 26655682Smarkm# define HAVE_CLOCK_T 26755682Smarkm#endif /* HAVE_CLOCK_T */ 26855682Smarkm 26955682Smarkm#ifndef HAVE_SA_FAMILY_T 27055682Smarkmtypedef int sa_family_t; 271178825Sdfr# define HAVE_SA_FAMILY_T 27255682Smarkm#endif /* HAVE_SA_FAMILY_T */ 273178825Sdfr 274178825Sdfr#ifndef HAVE_PID_T 275178825Sdfrtypedef int pid_t; 276178825Sdfr# define HAVE_PID_T 277178825Sdfr#endif /* HAVE_PID_T */ 278178825Sdfr 279178825Sdfr#ifndef HAVE_SIG_ATOMIC_T 280178825Sdfrtypedef int sig_atomic_t; 281178825Sdfr# define HAVE_SIG_ATOMIC_T 282178825Sdfr#endif /* HAVE_SIG_ATOMIC_T */ 283178825Sdfr 284178825Sdfr#ifndef HAVE_MODE_T 28555682Smarkmtypedef int mode_t; 286178825Sdfr# define HAVE_MODE_T 287178825Sdfr#endif /* HAVE_MODE_T */ 288178825Sdfr 28955682Smarkm#if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS) 29055682Smarkm# define ss_family __ss_family 29155682Smarkm#endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */ 29255682Smarkm 29355682Smarkm#ifndef HAVE_SYS_UN_H 29490926Snectarstruct sockaddr_un { 295178825Sdfr short sun_family; /* AF_UNIX */ 296178825Sdfr char sun_path[108]; /* path name (gag) */ 29755682Smarkm}; 29855682Smarkm#endif /* HAVE_SYS_UN_H */ 29955682Smarkm 30055682Smarkm#ifndef HAVE_IN_ADDR_T 30155682Smarkmtypedef u_int32_t in_addr_t; 30255682Smarkm#endif 30355682Smarkm 30490926Snectar#if defined(BROKEN_SYS_TERMIO_H) && !defined(_STRUCT_WINSIZE) 30590926Snectar#define _STRUCT_WINSIZE 306178825Sdfrstruct winsize { 30790926Snectar unsigned short ws_row; /* rows, in characters */ 30855682Smarkm unsigned short ws_col; /* columns, in character */ 30990926Snectar unsigned short ws_xpixel; /* horizontal size, pixels */ 31090926Snectar unsigned short ws_ypixel; /* vertical size, pixels */ 31155682Smarkm}; 31255682Smarkm#endif 31390926Snectar 31490926Snectar/* *-*-nto-qnx does not define this type in the system headers */ 31590926Snectar#ifdef MISSING_FD_MASK 31690926Snectar typedef unsigned long int fd_mask; 31790926Snectar#endif 31890926Snectar 31990926Snectar/* Paths */ 32090926Snectar 32190926Snectar#ifndef _PATH_BSHELL 32255682Smarkm# define _PATH_BSHELL "/bin/sh" 32355682Smarkm#endif 32455682Smarkm 32555682Smarkm#ifdef USER_PATH 32655682Smarkm# ifdef _PATH_STDPATH 32755682Smarkm# undef _PATH_STDPATH 32855682Smarkm# endif 32955682Smarkm# define _PATH_STDPATH USER_PATH 33055682Smarkm#endif 33155682Smarkm 33255682Smarkm#ifndef _PATH_STDPATH 33355682Smarkm# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" 33455682Smarkm#endif 33555682Smarkm 33655682Smarkm#ifndef SUPERUSER_PATH 33755682Smarkm# define SUPERUSER_PATH _PATH_STDPATH 33855682Smarkm#endif 33955682Smarkm 34055682Smarkm#ifndef _PATH_DEVNULL 34155682Smarkm# define _PATH_DEVNULL "/dev/null" 34290926Snectar#endif 34390926Snectar 34490926Snectar#ifndef MAIL_DIRECTORY 345178825Sdfr# define MAIL_DIRECTORY "/var/spool/mail" 346178825Sdfr#endif 347178825Sdfr 34890926Snectar#ifndef MAILDIR 34990926Snectar# define MAILDIR MAIL_DIRECTORY 35090926Snectar#endif 35190926Snectar 35290926Snectar#if !defined(_PATH_MAILDIR) && defined(MAILDIR) 35390926Snectar# define _PATH_MAILDIR MAILDIR 35490926Snectar#endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */ 35590926Snectar 356178825Sdfr#ifndef _PATH_NOLOGIN 357178825Sdfr# define _PATH_NOLOGIN "/etc/nologin" 35890926Snectar#endif 35990926Snectar 36090926Snectar/* Define this to be the path of the xauth program. */ 36190926Snectar#ifdef XAUTH_PATH 36290926Snectar#define _PATH_XAUTH XAUTH_PATH 36390926Snectar#endif /* XAUTH_PATH */ 36490926Snectar 36590926Snectar/* derived from XF4/xc/lib/dps/Xlibnet.h */ 36690926Snectar#ifndef X_UNIX_PATH 36755682Smarkm# ifdef __hpux 36890926Snectar# define X_UNIX_PATH "/var/spool/sockets/X11/%u" 36955682Smarkm# else 37090926Snectar# define X_UNIX_PATH "/tmp/.X11-unix/X%u" 37155682Smarkm# endif 37255682Smarkm#endif /* X_UNIX_PATH */ 373120945Snectar#define _PATH_UNIX_X X_UNIX_PATH 374178825Sdfr 375120945Snectar#ifndef _PATH_TTY 376120945Snectar# define _PATH_TTY "/dev/tty" 377120945Snectar#endif 378120945Snectar 379120945Snectar/* Macros */ 380120945Snectar 381120945Snectar#if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H) 382120945Snectar# define HAVE_LOGIN_CAP 383120945Snectar#endif 384120945Snectar 385120945Snectar#ifndef MAX 386120945Snectar# define MAX(a,b) (((a)>(b))?(a):(b)) 387120945Snectar# define MIN(a,b) (((a)<(b))?(a):(b)) 388120945Snectar#endif 389120945Snectar 390120945Snectar#ifndef roundup 391120945Snectar# define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 392120945Snectar#endif 39355682Smarkm 394178825Sdfr#ifndef timersub 395120945Snectar#define timersub(a, b, result) \ 396120945Snectar do { \ 397120945Snectar (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ 398120945Snectar (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ 399120945Snectar if ((result)->tv_usec < 0) { \ 40055682Smarkm --(result)->tv_sec; \ 40155682Smarkm (result)->tv_usec += 1000000; \ 40255682Smarkm } \ 40355682Smarkm } while (0) 40455682Smarkm#endif 405178825Sdfr 40655682Smarkm#ifndef TIMEVAL_TO_TIMESPEC 40755682Smarkm#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ 40855682Smarkm (ts)->tv_sec = (tv)->tv_sec; \ 40955682Smarkm (ts)->tv_nsec = (tv)->tv_usec * 1000; \ 41055682Smarkm} 41155682Smarkm#endif 41255682Smarkm 41355682Smarkm#ifndef TIMESPEC_TO_TIMEVAL 41455682Smarkm#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ 41555682Smarkm (tv)->tv_sec = (ts)->tv_sec; \ 41655682Smarkm (tv)->tv_usec = (ts)->tv_nsec / 1000; \ 41755682Smarkm} 41855682Smarkm#endif 41955682Smarkm 42055682Smarkm#ifndef __P 42155682Smarkm# define __P(x) x 42255682Smarkm#endif 42355682Smarkm 42455682Smarkm#if !defined(IN6_IS_ADDR_V4MAPPED) 42555682Smarkm# define IN6_IS_ADDR_V4MAPPED(a) \ 426102644Snectar ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \ 42755682Smarkm (((u_int32_t *) (a))[2] == htonl (0xffff))) 42855682Smarkm#endif /* !defined(IN6_IS_ADDR_V4MAPPED) */ 42955682Smarkm 430120945Snectar#if !defined(__GNUC__) || (__GNUC__ < 2) 431120945Snectar# define __attribute__(x) 43255682Smarkm#endif /* !defined(__GNUC__) || (__GNUC__ < 2) */ 433120945Snectar 434120945Snectar#if !defined(HAVE_ATTRIBUTE__SENTINEL__) && !defined(__sentinel__) 43555682Smarkm# define __sentinel__ 43655682Smarkm#endif 43755682Smarkm 438120945Snectar#if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__) 43955682Smarkm# define __bounded__(x, y, z) 44055682Smarkm#endif 44155682Smarkm 44255682Smarkm#if !defined(HAVE_ATTRIBUTE__NONNULL__) && !defined(__nonnull__) 44355682Smarkm# define __nonnull__(x) 44455682Smarkm#endif 445120945Snectar 446120945Snectar/* *-*-nto-qnx doesn't define this macro in the system headers */ 44755682Smarkm#ifdef MISSING_HOWMANY 44855682Smarkm# define howmany(x,y) (((x)+((y)-1))/(y)) 44955682Smarkm#endif 45055682Smarkm 45155682Smarkm#ifndef OSSH_ALIGNBYTES 45255682Smarkm#define OSSH_ALIGNBYTES (sizeof(int) - 1) 45355682Smarkm#endif 45455682Smarkm#ifndef __CMSG_ALIGN 45555682Smarkm#define __CMSG_ALIGN(p) (((u_int)(p) + OSSH_ALIGNBYTES) &~ OSSH_ALIGNBYTES) 456120945Snectar#endif 457120945Snectar 45855682Smarkm/* Length of the contents of a control message of length len */ 45955682Smarkm#ifndef CMSG_LEN 46055682Smarkm#define CMSG_LEN(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) 46155682Smarkm#endif 46255682Smarkm 46355682Smarkm/* Length of the space taken up by a padded control message of length len */ 46455682Smarkm#ifndef CMSG_SPACE 46555682Smarkm#define CMSG_SPACE(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(len)) 466120945Snectar#endif 467120945Snectar 46855682Smarkm/* given pointer to struct cmsghdr, return pointer to data */ 469120945Snectar#ifndef CMSG_DATA 470120945Snectar#define CMSG_DATA(cmsg) ((u_char *)(cmsg) + __CMSG_ALIGN(sizeof(struct cmsghdr))) 47155682Smarkm#endif /* CMSG_DATA */ 47255682Smarkm 47355682Smarkm/* 47455682Smarkm * RFC 2292 requires to check msg_controllen, in case that the kernel returns 47555682Smarkm * an empty list for some reasons. 47655682Smarkm */ 47755682Smarkm#ifndef CMSG_FIRSTHDR 47855682Smarkm#define CMSG_FIRSTHDR(mhdr) \ 47955682Smarkm ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ 48055682Smarkm (struct cmsghdr *)(mhdr)->msg_control : \ 48155682Smarkm (struct cmsghdr *)NULL) 482120945Snectar#endif /* CMSG_FIRSTHDR */ 483120945Snectar 48455682Smarkm#if defined(HAVE_DECL_OFFSETOF) && HAVE_DECL_OFFSETOF == 0 485120945Snectar# define offsetof(type, member) ((size_t) &((type *)0)->member) 486120945Snectar#endif 48755682Smarkm 48855682Smarkm/* Set up BSD-style BYTE_ORDER definition if it isn't there already */ 48955682Smarkm/* XXX: doesn't try to cope with strange byte orders (PDP_ENDIAN) */ 49055682Smarkm#ifndef BYTE_ORDER 49155682Smarkm# ifndef LITTLE_ENDIAN 49255682Smarkm# define LITTLE_ENDIAN 1234 493# endif /* LITTLE_ENDIAN */ 494# ifndef BIG_ENDIAN 495# define BIG_ENDIAN 4321 496# endif /* BIG_ENDIAN */ 497# ifdef WORDS_BIGENDIAN 498# define BYTE_ORDER BIG_ENDIAN 499# else /* WORDS_BIGENDIAN */ 500# define BYTE_ORDER LITTLE_ENDIAN 501# endif /* WORDS_BIGENDIAN */ 502#endif /* BYTE_ORDER */ 503 504/* Function replacement / compatibility hacks */ 505 506#if !defined(HAVE_GETADDRINFO) && (defined(HAVE_OGETADDRINFO) || defined(HAVE_NGETADDRINFO)) 507# define HAVE_GETADDRINFO 508#endif 509 510#ifndef HAVE_GETOPT_OPTRESET 511# undef getopt 512# undef opterr 513# undef optind 514# undef optopt 515# undef optreset 516# undef optarg 517# define getopt(ac, av, o) BSDgetopt(ac, av, o) 518# define opterr BSDopterr 519# define optind BSDoptind 520# define optopt BSDoptopt 521# define optreset BSDoptreset 522# define optarg BSDoptarg 523#endif 524 525#if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) 526# undef HAVE_GETADDRINFO 527#endif 528#if defined(BROKEN_GETADDRINFO) && defined(HAVE_FREEADDRINFO) 529# undef HAVE_FREEADDRINFO 530#endif 531#if defined(BROKEN_GETADDRINFO) && defined(HAVE_GAI_STRERROR) 532# undef HAVE_GAI_STRERROR 533#endif 534 535#if defined(BROKEN_UPDWTMPX) && defined(HAVE_UPDWTMPX) 536# undef HAVE_UPDWTMPX 537#endif 538 539#if defined(BROKEN_SHADOW_EXPIRE) && defined(HAS_SHADOW_EXPIRE) 540# undef HAS_SHADOW_EXPIRE 541#endif 542 543#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT) && \ 544 defined(SYSLOG_R_SAFE_IN_SIGHAND) 545# define DO_LOG_SAFE_IN_SIGHAND 546#endif 547 548#if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) 549# define memmove(s1, s2, n) bcopy((s2), (s1), (n)) 550#endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */ 551 552#if defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) 553# define USE_VHANGUP 554#endif /* defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) */ 555 556#ifndef GETPGRP_VOID 557# include <unistd.h> 558# define getpgrp() getpgrp(0) 559#endif 560 561#ifdef USE_BSM_AUDIT 562# define SSH_AUDIT_EVENTS 563# define CUSTOM_SSH_AUDIT_EVENTS 564#endif 565 566#if !defined(HAVE___func__) && defined(HAVE___FUNCTION__) 567# define __func__ __FUNCTION__ 568#elif !defined(HAVE___func__) 569# define __func__ "" 570#endif 571 572#if defined(KRB5) && !defined(HEIMDAL) 573# define krb5_get_err_text(context,code) error_message(code) 574#endif 575 576#if defined(SKEYCHALLENGE_4ARG) 577# define _compat_skeychallenge(a,b,c,d) skeychallenge(a,b,c,d) 578#else 579# define _compat_skeychallenge(a,b,c,d) skeychallenge(a,b,c) 580#endif 581 582/* Maximum number of file descriptors available */ 583#ifdef HAVE_SYSCONF 584# define SSH_SYSFDMAX sysconf(_SC_OPEN_MAX) 585#else 586# define SSH_SYSFDMAX 10000 587#endif 588 589#ifdef FSID_HAS_VAL 590/* encode f_fsid into a 64 bit value */ 591#define FSID_TO_ULONG(f) \ 592 ((((u_int64_t)(f).val[0] & 0xffffffffUL) << 32) | \ 593 ((f).val[1] & 0xffffffffUL)) 594#else 595# define FSID_TO_ULONG(f) ((f)) 596#endif 597 598#if defined(__Lynx__) 599 /* 600 * LynxOS defines these in param.h which we do not want to include since 601 * it will also pull in a bunch of kernel definitions. 602 */ 603# define ALIGNBYTES (sizeof(int) - 1) 604# define ALIGN(p) (((unsigned)p + ALIGNBYTES) & ~ALIGNBYTES) 605 /* Missing prototypes on LynxOS */ 606 int snprintf (char *, size_t, const char *, ...); 607 int mkstemp (char *); 608 char *crypt (const char *, const char *); 609 int seteuid (uid_t); 610 int setegid (gid_t); 611 char *mkdtemp (char *); 612 int rresvport_af (int *, sa_family_t); 613 int innetgr (const char *, const char *, const char *, const char *); 614#endif 615 616/* 617 * Define this to use pipes instead of socketpairs for communicating with the 618 * client program. Socketpairs do not seem to work on all systems. 619 * 620 * configure.ac sets this for a few OS's which are known to have problems 621 * but you may need to set it yourself 622 */ 623/* #define USE_PIPES 1 */ 624 625/** 626 ** login recorder definitions 627 **/ 628 629/* FIXME: put default paths back in */ 630#ifndef UTMP_FILE 631# ifdef _PATH_UTMP 632# define UTMP_FILE _PATH_UTMP 633# else 634# ifdef CONF_UTMP_FILE 635# define UTMP_FILE CONF_UTMP_FILE 636# endif 637# endif 638#endif 639#ifndef WTMP_FILE 640# ifdef _PATH_WTMP 641# define WTMP_FILE _PATH_WTMP 642# else 643# ifdef CONF_WTMP_FILE 644# define WTMP_FILE CONF_WTMP_FILE 645# endif 646# endif 647#endif 648/* pick up the user's location for lastlog if given */ 649#ifndef LASTLOG_FILE 650# ifdef _PATH_LASTLOG 651# define LASTLOG_FILE _PATH_LASTLOG 652# else 653# ifdef CONF_LASTLOG_FILE 654# define LASTLOG_FILE CONF_LASTLOG_FILE 655# endif 656# endif 657#endif 658 659#if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) 660# define USE_SHADOW 661#endif 662 663/* The login() library function in libutil is first choice */ 664#if defined(HAVE_LOGIN) && !defined(DISABLE_LOGIN) 665# define USE_LOGIN 666 667#else 668/* Simply select your favourite login types. */ 669/* Can't do if-else because some systems use several... <sigh> */ 670# if defined(UTMPX_FILE) && !defined(DISABLE_UTMPX) 671# define USE_UTMPX 672# endif 673# if defined(UTMP_FILE) && !defined(DISABLE_UTMP) 674# define USE_UTMP 675# endif 676# if defined(WTMPX_FILE) && !defined(DISABLE_WTMPX) 677# define USE_WTMPX 678# endif 679# if defined(WTMP_FILE) && !defined(DISABLE_WTMP) 680# define USE_WTMP 681# endif 682 683#endif 684 685#ifndef UT_LINESIZE 686# define UT_LINESIZE 8 687#endif 688 689/* I hope that the presence of LASTLOG_FILE is enough to detect this */ 690#if defined(LASTLOG_FILE) && !defined(DISABLE_LASTLOG) 691# define USE_LASTLOG 692#endif 693 694#ifdef HAVE_OSF_SIA 695# ifdef USE_SHADOW 696# undef USE_SHADOW 697# endif 698# define CUSTOM_SYS_AUTH_PASSWD 1 699#endif 700 701#if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(HAVE_SECUREWARE) 702# define CUSTOM_SYS_AUTH_PASSWD 1 703#endif 704#if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(BROKEN_LIBIAF) 705# define USE_LIBIAF 706#endif 707 708/* HP-UX 11.11 */ 709#ifdef BTMP_FILE 710# define _PATH_BTMP BTMP_FILE 711#endif 712 713#if defined(USE_BTMP) && defined(_PATH_BTMP) 714# define CUSTOM_FAILED_LOGIN 715#endif 716 717/** end of login recorder definitions */ 718 719#ifdef BROKEN_GETGROUPS 720# define getgroups(a,b) ((a)==0 && (b)==NULL ? NGROUPS_MAX : getgroups((a),(b))) 721#endif 722 723#if defined(HAVE_MMAP) && defined(BROKEN_MMAP) 724# undef HAVE_MMAP 725#endif 726 727#ifndef IOV_MAX 728# if defined(_XOPEN_IOV_MAX) 729# define IOV_MAX _XOPEN_IOV_MAX 730# elif defined(DEF_IOV_MAX) 731# define IOV_MAX DEF_IOV_MAX 732# else 733# define IOV_MAX 16 734# endif 735#endif 736 737#ifndef EWOULDBLOCK 738# define EWOULDBLOCK EAGAIN 739#endif 740 741#ifndef INET6_ADDRSTRLEN /* for non IPv6 machines */ 742#define INET6_ADDRSTRLEN 46 743#endif 744 745#endif /* _DEFINES_H */ 746