defines.h revision 192595
1124208Sdes/* 2124208Sdes * Copyright (c) 1999-2003 Damien Miller. All rights reserved. 3124208Sdes * 4124208Sdes * Redistribution and use in source and binary forms, with or without 5124208Sdes * modification, are permitted provided that the following conditions 6124208Sdes * are met: 7124208Sdes * 1. Redistributions of source code must retain the above copyright 8124208Sdes * notice, this list of conditions and the following disclaimer. 9124208Sdes * 2. Redistributions in binary form must reproduce the above copyright 10124208Sdes * notice, this list of conditions and the following disclaimer in the 11124208Sdes * documentation and/or other materials provided with the distribution. 12124208Sdes * 13124208Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14124208Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15124208Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16124208Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17124208Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18124208Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19124208Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20124208Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21124208Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22124208Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23124208Sdes */ 24124208Sdes 2598937Sdes#ifndef _DEFINES_H 2698937Sdes#define _DEFINES_H 2798937Sdes 28192595Sdes/* $Id: defines.h,v 1.153 2009/02/01 11:19:54 dtucker Exp $ */ 2998937Sdes 3098937Sdes 3198937Sdes/* Constants */ 3298937Sdes 33162852Sdes#if defined(HAVE_DECL_SHUT_RD) && HAVE_DECL_SHUT_RD == 0 3498937Sdesenum 3598937Sdes{ 3698937Sdes SHUT_RD = 0, /* No more receptions. */ 3798937Sdes SHUT_WR, /* No more transmissions. */ 3898937Sdes SHUT_RDWR /* No more receptions or transmissions. */ 3998937Sdes}; 4098937Sdes# define SHUT_RD SHUT_RD 4198937Sdes# define SHUT_WR SHUT_WR 4298937Sdes# define SHUT_RDWR SHUT_RDWR 4398937Sdes#endif 4498937Sdes 4598937Sdes#ifndef IPTOS_LOWDELAY 4698937Sdes# define IPTOS_LOWDELAY 0x10 4798937Sdes# define IPTOS_THROUGHPUT 0x08 4898937Sdes# define IPTOS_RELIABILITY 0x04 4998937Sdes# define IPTOS_LOWCOST 0x02 5098937Sdes# define IPTOS_MINCOST IPTOS_LOWCOST 5198937Sdes#endif /* IPTOS_LOWDELAY */ 5298937Sdes 5398937Sdes#ifndef MAXPATHLEN 5498937Sdes# ifdef PATH_MAX 5598937Sdes# define MAXPATHLEN PATH_MAX 5698937Sdes# else /* PATH_MAX */ 57149749Sdes# define MAXPATHLEN 64 58149749Sdes/* realpath uses a fixed buffer of size MAXPATHLEN, so force use of ours */ 59149749Sdes# ifndef BROKEN_REALPATH 60149749Sdes# define BROKEN_REALPATH 1 61149749Sdes# endif /* BROKEN_REALPATH */ 6298937Sdes# endif /* PATH_MAX */ 6398937Sdes#endif /* MAXPATHLEN */ 6498937Sdes 65149749Sdes#ifndef PATH_MAX 66149749Sdes# ifdef _POSIX_PATH_MAX 67149749Sdes# define PATH_MAX _POSIX_PATH_MAX 68149749Sdes# endif 69149749Sdes#endif 70149749Sdes 71181111Sdes#if defined(HAVE_DECL_MAXSYMLINKS) && HAVE_DECL_MAXSYMLINKS == 0 72149749Sdes# define MAXSYMLINKS 5 73149749Sdes#endif 74149749Sdes 7598937Sdes#ifndef STDIN_FILENO 7698937Sdes# define STDIN_FILENO 0 7798937Sdes#endif 7898937Sdes#ifndef STDOUT_FILENO 7998937Sdes# define STDOUT_FILENO 1 8098937Sdes#endif 8198937Sdes#ifndef STDERR_FILENO 8298937Sdes# define STDERR_FILENO 2 8398937Sdes#endif 8498937Sdes 8598937Sdes#ifndef NGROUPS_MAX /* Disable groupaccess if NGROUP_MAX is not set */ 8698937Sdes#ifdef NGROUPS 8798937Sdes#define NGROUPS_MAX NGROUPS 8898937Sdes#else 8998937Sdes#define NGROUPS_MAX 0 9098937Sdes#endif 9198937Sdes#endif 9298937Sdes 93162852Sdes#if defined(HAVE_DECL_O_NONBLOCK) && HAVE_DECL_O_NONBLOCK == 0 94162852Sdes# define O_NONBLOCK 00004 /* Non Blocking Open */ 9598937Sdes#endif 9698937Sdes 9798937Sdes#ifndef S_ISDIR 9898937Sdes# define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR)) 9998937Sdes#endif /* S_ISDIR */ 10098937Sdes 101126274Sdes#ifndef S_ISREG 10298937Sdes# define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG)) 10398937Sdes#endif /* S_ISREG */ 10498937Sdes 10598937Sdes#ifndef S_ISLNK 10698937Sdes# define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) 10798937Sdes#endif /* S_ISLNK */ 10898937Sdes 10998937Sdes#ifndef S_IXUSR 11098937Sdes# define S_IXUSR 0000100 /* execute/search permission, */ 11198937Sdes# define S_IXGRP 0000010 /* execute/search permission, */ 11298937Sdes# define S_IXOTH 0000001 /* execute/search permission, */ 11398937Sdes# define _S_IWUSR 0000200 /* write permission, */ 11498937Sdes# define S_IWUSR _S_IWUSR /* write permission, owner */ 11598937Sdes# define S_IWGRP 0000020 /* write permission, group */ 11698937Sdes# define S_IWOTH 0000002 /* write permission, other */ 11798937Sdes# define S_IRUSR 0000400 /* read permission, owner */ 11898937Sdes# define S_IRGRP 0000040 /* read permission, group */ 11998937Sdes# define S_IROTH 0000004 /* read permission, other */ 12098937Sdes# define S_IRWXU 0000700 /* read, write, execute */ 12198937Sdes# define S_IRWXG 0000070 /* read, write, execute */ 12298937Sdes# define S_IRWXO 0000007 /* read, write, execute */ 12398937Sdes#endif /* S_IXUSR */ 12498937Sdes 12598937Sdes#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS) 12698937Sdes#define MAP_ANON MAP_ANONYMOUS 12798937Sdes#endif 12898937Sdes 12998937Sdes#ifndef MAP_FAILED 13098937Sdes# define MAP_FAILED ((void *)-1) 13198937Sdes#endif 13298937Sdes 13398937Sdes/* *-*-nto-qnx doesn't define this constant in the system headers */ 13498937Sdes#ifdef MISSING_NFDBITS 13598937Sdes# define NFDBITS (8 * sizeof(unsigned long)) 13698937Sdes#endif 13798937Sdes 13898937Sdes/* 13998937SdesSCO Open Server 3 has INADDR_LOOPBACK defined in rpc/rpc.h but 14098937Sdesincluding rpc/rpc.h breaks Solaris 6 14198937Sdes*/ 14298937Sdes#ifndef INADDR_LOOPBACK 143106121Sdes#define INADDR_LOOPBACK ((u_long)0x7f000001) 14498937Sdes#endif 14598937Sdes 14698937Sdes/* Types */ 14798937Sdes 14898937Sdes/* If sys/types.h does not supply intXX_t, supply them ourselves */ 14998937Sdes/* (or die trying) */ 15098937Sdes 15198937Sdes#ifndef HAVE_U_INT 15298937Sdestypedef unsigned int u_int; 15398937Sdes#endif 15498937Sdes 15598937Sdes#ifndef HAVE_INTXX_T 15698937Sdes# if (SIZEOF_CHAR == 1) 15798937Sdestypedef char int8_t; 15898937Sdes# else 15998937Sdes# error "8 bit int type not found." 16098937Sdes# endif 16198937Sdes# if (SIZEOF_SHORT_INT == 2) 16298937Sdestypedef short int int16_t; 16398937Sdes# else 164106121Sdes# ifdef _UNICOS 16598937Sdes# if (SIZEOF_SHORT_INT == 4) 16698937Sdestypedef short int16_t; 16798937Sdes# else 16898937Sdestypedef long int16_t; 16998937Sdes# endif 17098937Sdes# else 17198937Sdes# error "16 bit int type not found." 172106121Sdes# endif /* _UNICOS */ 17398937Sdes# endif 17498937Sdes# if (SIZEOF_INT == 4) 17598937Sdestypedef int int32_t; 17698937Sdes# else 177106121Sdes# ifdef _UNICOS 17898937Sdestypedef long int32_t; 17998937Sdes# else 18098937Sdes# error "32 bit int type not found." 181106121Sdes# endif /* _UNICOS */ 18298937Sdes# endif 18398937Sdes#endif 18498937Sdes 18598937Sdes/* If sys/types.h does not supply u_intXX_t, supply them ourselves */ 18698937Sdes#ifndef HAVE_U_INTXX_T 18798937Sdes# ifdef HAVE_UINTXX_T 18898937Sdestypedef uint8_t u_int8_t; 18998937Sdestypedef uint16_t u_int16_t; 19098937Sdestypedef uint32_t u_int32_t; 19198937Sdes# define HAVE_U_INTXX_T 1 19298937Sdes# else 19398937Sdes# if (SIZEOF_CHAR == 1) 19498937Sdestypedef unsigned char u_int8_t; 19598937Sdes# else 19698937Sdes# error "8 bit int type not found." 19798937Sdes# endif 19898937Sdes# if (SIZEOF_SHORT_INT == 2) 19998937Sdestypedef unsigned short int u_int16_t; 20098937Sdes# else 201106121Sdes# ifdef _UNICOS 20298937Sdes# if (SIZEOF_SHORT_INT == 4) 20398937Sdestypedef unsigned short u_int16_t; 20498937Sdes# else 20598937Sdestypedef unsigned long u_int16_t; 20698937Sdes# endif 20798937Sdes# else 20898937Sdes# error "16 bit int type not found." 20998937Sdes# endif 21098937Sdes# endif 21198937Sdes# if (SIZEOF_INT == 4) 21298937Sdestypedef unsigned int u_int32_t; 21398937Sdes# else 214106121Sdes# ifdef _UNICOS 21598937Sdestypedef unsigned long u_int32_t; 21698937Sdes# else 21798937Sdes# error "32 bit int type not found." 21898937Sdes# endif 21998937Sdes# endif 22098937Sdes# endif 22198937Sdes#define __BIT_TYPES_DEFINED__ 22298937Sdes#endif 22398937Sdes 22498937Sdes/* 64-bit types */ 22598937Sdes#ifndef HAVE_INT64_T 22698937Sdes# if (SIZEOF_LONG_INT == 8) 22798937Sdestypedef long int int64_t; 22898937Sdes# else 22998937Sdes# if (SIZEOF_LONG_LONG_INT == 8) 23098937Sdestypedef long long int int64_t; 23198937Sdes# endif 23298937Sdes# endif 23398937Sdes#endif 23498937Sdes#ifndef HAVE_U_INT64_T 23598937Sdes# if (SIZEOF_LONG_INT == 8) 23698937Sdestypedef unsigned long int u_int64_t; 23798937Sdes# else 23898937Sdes# if (SIZEOF_LONG_LONG_INT == 8) 23998937Sdestypedef unsigned long long int u_int64_t; 24098937Sdes# endif 24198937Sdes# endif 24298937Sdes#endif 24398937Sdes 24498937Sdes#ifndef HAVE_U_CHAR 24598937Sdestypedef unsigned char u_char; 24698937Sdes# define HAVE_U_CHAR 24798937Sdes#endif /* HAVE_U_CHAR */ 24898937Sdes 249106121Sdes#ifndef SIZE_T_MAX 250106121Sdes#define SIZE_T_MAX ULONG_MAX 251106121Sdes#endif /* SIZE_T_MAX */ 252106121Sdes 25398937Sdes#ifndef HAVE_SIZE_T 25498937Sdestypedef unsigned int size_t; 25598937Sdes# define HAVE_SIZE_T 256126274Sdes# define SIZE_T_MAX UINT_MAX 25798937Sdes#endif /* HAVE_SIZE_T */ 25898937Sdes 25998937Sdes#ifndef HAVE_SSIZE_T 26098937Sdestypedef int ssize_t; 26198937Sdes# define HAVE_SSIZE_T 26298937Sdes#endif /* HAVE_SSIZE_T */ 26398937Sdes 26498937Sdes#ifndef HAVE_CLOCK_T 26598937Sdestypedef long clock_t; 26698937Sdes# define HAVE_CLOCK_T 26798937Sdes#endif /* HAVE_CLOCK_T */ 26898937Sdes 26998937Sdes#ifndef HAVE_SA_FAMILY_T 27098937Sdestypedef int sa_family_t; 27198937Sdes# define HAVE_SA_FAMILY_T 27298937Sdes#endif /* HAVE_SA_FAMILY_T */ 27398937Sdes 27498937Sdes#ifndef HAVE_PID_T 27598937Sdestypedef int pid_t; 27698937Sdes# define HAVE_PID_T 27798937Sdes#endif /* HAVE_PID_T */ 27898937Sdes 27998937Sdes#ifndef HAVE_SIG_ATOMIC_T 28098937Sdestypedef int sig_atomic_t; 28198937Sdes# define HAVE_SIG_ATOMIC_T 28298937Sdes#endif /* HAVE_SIG_ATOMIC_T */ 28398937Sdes 28498937Sdes#ifndef HAVE_MODE_T 28598937Sdestypedef int mode_t; 28698937Sdes# define HAVE_MODE_T 28798937Sdes#endif /* HAVE_MODE_T */ 28898937Sdes 28998937Sdes#if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS) 29098937Sdes# define ss_family __ss_family 29198937Sdes#endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */ 29298937Sdes 29398937Sdes#ifndef HAVE_SYS_UN_H 29498937Sdesstruct sockaddr_un { 29598937Sdes short sun_family; /* AF_UNIX */ 29698937Sdes char sun_path[108]; /* path name (gag) */ 29798937Sdes}; 29898937Sdes#endif /* HAVE_SYS_UN_H */ 29998937Sdes 300146998Sdes#ifndef HAVE_IN_ADDR_T 301146998Sdestypedef u_int32_t in_addr_t; 302146998Sdes#endif 303146998Sdes 30498937Sdes#if defined(BROKEN_SYS_TERMIO_H) && !defined(_STRUCT_WINSIZE) 30598937Sdes#define _STRUCT_WINSIZE 30698937Sdesstruct winsize { 30798937Sdes unsigned short ws_row; /* rows, in characters */ 30898937Sdes unsigned short ws_col; /* columns, in character */ 30998937Sdes unsigned short ws_xpixel; /* horizontal size, pixels */ 31098937Sdes unsigned short ws_ypixel; /* vertical size, pixels */ 31198937Sdes}; 31298937Sdes#endif 31398937Sdes 31498937Sdes/* *-*-nto-qnx does not define this type in the system headers */ 31598937Sdes#ifdef MISSING_FD_MASK 31698937Sdes typedef unsigned long int fd_mask; 31798937Sdes#endif 31898937Sdes 31998937Sdes/* Paths */ 32098937Sdes 32198937Sdes#ifndef _PATH_BSHELL 32298937Sdes# define _PATH_BSHELL "/bin/sh" 32398937Sdes#endif 32498937Sdes 32598937Sdes#ifdef USER_PATH 32698937Sdes# ifdef _PATH_STDPATH 32798937Sdes# undef _PATH_STDPATH 32898937Sdes# endif 32998937Sdes# define _PATH_STDPATH USER_PATH 33098937Sdes#endif 33198937Sdes 33298937Sdes#ifndef _PATH_STDPATH 33398937Sdes# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" 33498937Sdes#endif 33598937Sdes 336124208Sdes#ifndef SUPERUSER_PATH 337124208Sdes# define SUPERUSER_PATH _PATH_STDPATH 338124208Sdes#endif 339124208Sdes 34098937Sdes#ifndef _PATH_DEVNULL 34198937Sdes# define _PATH_DEVNULL "/dev/null" 34298937Sdes#endif 34398937Sdes 34498937Sdes#ifndef MAIL_DIRECTORY 34598937Sdes# define MAIL_DIRECTORY "/var/spool/mail" 34698937Sdes#endif 34798937Sdes 34898937Sdes#ifndef MAILDIR 34998937Sdes# define MAILDIR MAIL_DIRECTORY 35098937Sdes#endif 35198937Sdes 35298937Sdes#if !defined(_PATH_MAILDIR) && defined(MAILDIR) 35398937Sdes# define _PATH_MAILDIR MAILDIR 35498937Sdes#endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */ 35598937Sdes 35698937Sdes#ifndef _PATH_NOLOGIN 35798937Sdes# define _PATH_NOLOGIN "/etc/nologin" 35898937Sdes#endif 35998937Sdes 36098937Sdes/* Define this to be the path of the xauth program. */ 36198937Sdes#ifdef XAUTH_PATH 36298937Sdes#define _PATH_XAUTH XAUTH_PATH 36398937Sdes#endif /* XAUTH_PATH */ 36498937Sdes 36598937Sdes/* derived from XF4/xc/lib/dps/Xlibnet.h */ 36698937Sdes#ifndef X_UNIX_PATH 36798937Sdes# ifdef __hpux 36898937Sdes# define X_UNIX_PATH "/var/spool/sockets/X11/%u" 36998937Sdes# else 37098937Sdes# define X_UNIX_PATH "/tmp/.X11-unix/X%u" 37198937Sdes# endif 37298937Sdes#endif /* X_UNIX_PATH */ 37398937Sdes#define _PATH_UNIX_X X_UNIX_PATH 37498937Sdes 37598937Sdes#ifndef _PATH_TTY 37698937Sdes# define _PATH_TTY "/dev/tty" 37798937Sdes#endif 37898937Sdes 37998937Sdes/* Macros */ 38098937Sdes 38198937Sdes#if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H) 38298937Sdes# define HAVE_LOGIN_CAP 38398937Sdes#endif 38498937Sdes 38598937Sdes#ifndef MAX 38698937Sdes# define MAX(a,b) (((a)>(b))?(a):(b)) 38798937Sdes# define MIN(a,b) (((a)<(b))?(a):(b)) 38898937Sdes#endif 38998937Sdes 39098937Sdes#ifndef roundup 39198937Sdes# define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 39298937Sdes#endif 39398937Sdes 39498937Sdes#ifndef timersub 39598937Sdes#define timersub(a, b, result) \ 39698937Sdes do { \ 39798937Sdes (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ 39898937Sdes (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ 39998937Sdes if ((result)->tv_usec < 0) { \ 40098937Sdes --(result)->tv_sec; \ 40198937Sdes (result)->tv_usec += 1000000; \ 40298937Sdes } \ 40398937Sdes } while (0) 40498937Sdes#endif 40598937Sdes 406113908Sdes#ifndef TIMEVAL_TO_TIMESPEC 407113908Sdes#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ 408113908Sdes (ts)->tv_sec = (tv)->tv_sec; \ 409113908Sdes (ts)->tv_nsec = (tv)->tv_usec * 1000; \ 410113908Sdes} 411113908Sdes#endif 412113908Sdes 413113908Sdes#ifndef TIMESPEC_TO_TIMEVAL 414113908Sdes#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ 415113908Sdes (tv)->tv_sec = (ts)->tv_sec; \ 416113908Sdes (tv)->tv_usec = (ts)->tv_nsec / 1000; \ 417113908Sdes} 418113908Sdes#endif 419113908Sdes 42098937Sdes#ifndef __P 42198937Sdes# define __P(x) x 42298937Sdes#endif 42398937Sdes 42498937Sdes#if !defined(IN6_IS_ADDR_V4MAPPED) 42598937Sdes# define IN6_IS_ADDR_V4MAPPED(a) \ 42698937Sdes ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \ 42798937Sdes (((u_int32_t *) (a))[2] == htonl (0xffff))) 42898937Sdes#endif /* !defined(IN6_IS_ADDR_V4MAPPED) */ 42998937Sdes 43098937Sdes#if !defined(__GNUC__) || (__GNUC__ < 2) 43198937Sdes# define __attribute__(x) 43298937Sdes#endif /* !defined(__GNUC__) || (__GNUC__ < 2) */ 43398937Sdes 434149749Sdes#if !defined(HAVE_ATTRIBUTE__SENTINEL__) && !defined(__sentinel__) 435149749Sdes# define __sentinel__ 436149749Sdes#endif 437149749Sdes 438157016Sdes#if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__) 439157016Sdes# define __bounded__(x, y, z) 440157016Sdes#endif 441157016Sdes 442181111Sdes#if !defined(HAVE_ATTRIBUTE__NONNULL__) && !defined(__nonnull__) 443181111Sdes# define __nonnull__(x) 444181111Sdes#endif 445181111Sdes 44698937Sdes/* *-*-nto-qnx doesn't define this macro in the system headers */ 44798937Sdes#ifdef MISSING_HOWMANY 44898937Sdes# define howmany(x,y) (((x)+((y)-1))/(y)) 44998937Sdes#endif 45098937Sdes 45198937Sdes#ifndef OSSH_ALIGNBYTES 45298937Sdes#define OSSH_ALIGNBYTES (sizeof(int) - 1) 45398937Sdes#endif 45498937Sdes#ifndef __CMSG_ALIGN 45598937Sdes#define __CMSG_ALIGN(p) (((u_int)(p) + OSSH_ALIGNBYTES) &~ OSSH_ALIGNBYTES) 45698937Sdes#endif 45798937Sdes 45898937Sdes/* Length of the contents of a control message of length len */ 45998937Sdes#ifndef CMSG_LEN 46098937Sdes#define CMSG_LEN(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) 46198937Sdes#endif 46298937Sdes 46398937Sdes/* Length of the space taken up by a padded control message of length len */ 46498937Sdes#ifndef CMSG_SPACE 46598937Sdes#define CMSG_SPACE(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(len)) 46698937Sdes#endif 46798937Sdes 468124208Sdes/* given pointer to struct cmsghdr, return pointer to data */ 469124208Sdes#ifndef CMSG_DATA 470124208Sdes#define CMSG_DATA(cmsg) ((u_char *)(cmsg) + __CMSG_ALIGN(sizeof(struct cmsghdr))) 471124208Sdes#endif /* CMSG_DATA */ 472124208Sdes 473124208Sdes/* 474124208Sdes * RFC 2292 requires to check msg_controllen, in case that the kernel returns 475124208Sdes * an empty list for some reasons. 476124208Sdes */ 477124208Sdes#ifndef CMSG_FIRSTHDR 478124208Sdes#define CMSG_FIRSTHDR(mhdr) \ 479124208Sdes ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ 480124208Sdes (struct cmsghdr *)(mhdr)->msg_control : \ 481124208Sdes (struct cmsghdr *)NULL) 482124208Sdes#endif /* CMSG_FIRSTHDR */ 483124208Sdes 484181111Sdes#if defined(HAVE_DECL_OFFSETOF) && HAVE_DECL_OFFSETOF == 0 485137015Sdes# define offsetof(type, member) ((size_t) &((type *)0)->member) 486137015Sdes#endif 487124208Sdes 488162852Sdes/* Set up BSD-style BYTE_ORDER definition if it isn't there already */ 489162852Sdes/* XXX: doesn't try to cope with strange byte orders (PDP_ENDIAN) */ 490162852Sdes#ifndef BYTE_ORDER 491162852Sdes# ifndef LITTLE_ENDIAN 492162852Sdes# define LITTLE_ENDIAN 1234 493162852Sdes# endif /* LITTLE_ENDIAN */ 494162852Sdes# ifndef BIG_ENDIAN 495162852Sdes# define BIG_ENDIAN 4321 496162852Sdes# endif /* BIG_ENDIAN */ 497162852Sdes# ifdef WORDS_BIGENDIAN 498162852Sdes# define BYTE_ORDER BIG_ENDIAN 499162852Sdes# else /* WORDS_BIGENDIAN */ 500162852Sdes# define BYTE_ORDER LITTLE_ENDIAN 501162852Sdes# endif /* WORDS_BIGENDIAN */ 502162852Sdes#endif /* BYTE_ORDER */ 503162852Sdes 50498937Sdes/* Function replacement / compatibility hacks */ 50598937Sdes 50698937Sdes#if !defined(HAVE_GETADDRINFO) && (defined(HAVE_OGETADDRINFO) || defined(HAVE_NGETADDRINFO)) 50798937Sdes# define HAVE_GETADDRINFO 50898937Sdes#endif 50998937Sdes 51098937Sdes#ifndef HAVE_GETOPT_OPTRESET 51199060Sdes# undef getopt 51299060Sdes# undef opterr 51399060Sdes# undef optind 51499060Sdes# undef optopt 51599060Sdes# undef optreset 51699060Sdes# undef optarg 51799060Sdes# define getopt(ac, av, o) BSDgetopt(ac, av, o) 51899060Sdes# define opterr BSDopterr 51999060Sdes# define optind BSDoptind 52099060Sdes# define optopt BSDoptopt 52199060Sdes# define optreset BSDoptreset 52299060Sdes# define optarg BSDoptarg 52398937Sdes#endif 52498937Sdes 52598937Sdes#if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) 52698937Sdes# undef HAVE_GETADDRINFO 52798937Sdes#endif 52898937Sdes#if defined(BROKEN_GETADDRINFO) && defined(HAVE_FREEADDRINFO) 52998937Sdes# undef HAVE_FREEADDRINFO 53098937Sdes#endif 53198937Sdes#if defined(BROKEN_GETADDRINFO) && defined(HAVE_GAI_STRERROR) 53298937Sdes# undef HAVE_GAI_STRERROR 53398937Sdes#endif 53498937Sdes 535128456Sdes#if defined(BROKEN_UPDWTMPX) && defined(HAVE_UPDWTMPX) 536128456Sdes# undef HAVE_UPDWTMPX 537128456Sdes#endif 538128456Sdes 539181111Sdes#if defined(BROKEN_SHADOW_EXPIRE) && defined(HAS_SHADOW_EXPIRE) 540181111Sdes# undef HAS_SHADOW_EXPIRE 541181111Sdes#endif 542181111Sdes 543162852Sdes#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT) && \ 544162852Sdes defined(SYSLOG_R_SAFE_IN_SIGHAND) 545162852Sdes# define DO_LOG_SAFE_IN_SIGHAND 546162852Sdes#endif 547162852Sdes 54898937Sdes#if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) 54998937Sdes# define memmove(s1, s2, n) bcopy((s2), (s1), (n)) 55098937Sdes#endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */ 55198937Sdes 55298937Sdes#if defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) 55398937Sdes# define USE_VHANGUP 55498937Sdes#endif /* defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) */ 55598937Sdes 55698937Sdes#ifndef GETPGRP_VOID 557162852Sdes# include <unistd.h> 55898937Sdes# define getpgrp() getpgrp(0) 55998937Sdes#endif 56098937Sdes 561146998Sdes#ifdef USE_BSM_AUDIT 562146998Sdes# define SSH_AUDIT_EVENTS 563146998Sdes# define CUSTOM_SSH_AUDIT_EVENTS 564146998Sdes#endif 565146998Sdes 56698937Sdes#if !defined(HAVE___func__) && defined(HAVE___FUNCTION__) 56798937Sdes# define __func__ __FUNCTION__ 56898937Sdes#elif !defined(HAVE___func__) 56998937Sdes# define __func__ "" 57098937Sdes#endif 57198937Sdes 572124208Sdes#if defined(KRB5) && !defined(HEIMDAL) 573124208Sdes# define krb5_get_err_text(context,code) error_message(code) 574124208Sdes#endif 575124208Sdes 576128456Sdes#if defined(SKEYCHALLENGE_4ARG) 577128456Sdes# define _compat_skeychallenge(a,b,c,d) skeychallenge(a,b,c,d) 578128456Sdes#else 579128456Sdes# define _compat_skeychallenge(a,b,c,d) skeychallenge(a,b,c) 580128456Sdes#endif 581128456Sdes 582126274Sdes/* Maximum number of file descriptors available */ 583126274Sdes#ifdef HAVE_SYSCONF 584126274Sdes# define SSH_SYSFDMAX sysconf(_SC_OPEN_MAX) 585126274Sdes#else 586126274Sdes# define SSH_SYSFDMAX 10000 587126274Sdes#endif 588126274Sdes 589181111Sdes#ifdef FSID_HAS_VAL 590181111Sdes/* encode f_fsid into a 64 bit value */ 591181111Sdes#define FSID_TO_ULONG(f) \ 592181111Sdes ((((u_int64_t)(f).val[0] & 0xffffffffUL) << 32) | \ 593181111Sdes ((f).val[1] & 0xffffffffUL)) 594181111Sdes#else 595181111Sdes# define FSID_TO_ULONG(f) ((f)) 596181111Sdes#endif 597181111Sdes 598149749Sdes#if defined(__Lynx__) 599149749Sdes /* 600149749Sdes * LynxOS defines these in param.h which we do not want to include since 601149749Sdes * it will also pull in a bunch of kernel definitions. 602149749Sdes */ 603149749Sdes# define ALIGNBYTES (sizeof(int) - 1) 604149749Sdes# define ALIGN(p) (((unsigned)p + ALIGNBYTES) & ~ALIGNBYTES) 605149749Sdes /* Missing prototypes on LynxOS */ 606149749Sdes int snprintf (char *, size_t, const char *, ...); 607149749Sdes int mkstemp (char *); 608149749Sdes char *crypt (const char *, const char *); 609149749Sdes int seteuid (uid_t); 610149749Sdes int setegid (gid_t); 611149749Sdes char *mkdtemp (char *); 612149749Sdes int rresvport_af (int *, sa_family_t); 613149749Sdes int innetgr (const char *, const char *, const char *, const char *); 614149749Sdes#endif 615126274Sdes 61698937Sdes/* 61798937Sdes * Define this to use pipes instead of socketpairs for communicating with the 61898937Sdes * client program. Socketpairs do not seem to work on all systems. 61998937Sdes * 62098937Sdes * configure.ac sets this for a few OS's which are known to have problems 62198937Sdes * but you may need to set it yourself 62298937Sdes */ 62398937Sdes/* #define USE_PIPES 1 */ 62498937Sdes 62598937Sdes/** 62698937Sdes ** login recorder definitions 62798937Sdes **/ 62898937Sdes 62998937Sdes/* FIXME: put default paths back in */ 63098937Sdes#ifndef UTMP_FILE 63198937Sdes# ifdef _PATH_UTMP 63298937Sdes# define UTMP_FILE _PATH_UTMP 63398937Sdes# else 63498937Sdes# ifdef CONF_UTMP_FILE 63598937Sdes# define UTMP_FILE CONF_UTMP_FILE 63698937Sdes# endif 63798937Sdes# endif 63898937Sdes#endif 63998937Sdes#ifndef WTMP_FILE 64098937Sdes# ifdef _PATH_WTMP 64198937Sdes# define WTMP_FILE _PATH_WTMP 64298937Sdes# else 64398937Sdes# ifdef CONF_WTMP_FILE 64498937Sdes# define WTMP_FILE CONF_WTMP_FILE 64598937Sdes# endif 64698937Sdes# endif 64798937Sdes#endif 64898937Sdes/* pick up the user's location for lastlog if given */ 64998937Sdes#ifndef LASTLOG_FILE 65098937Sdes# ifdef _PATH_LASTLOG 65198937Sdes# define LASTLOG_FILE _PATH_LASTLOG 65298937Sdes# else 65398937Sdes# ifdef CONF_LASTLOG_FILE 65498937Sdes# define LASTLOG_FILE CONF_LASTLOG_FILE 65598937Sdes# endif 65698937Sdes# endif 65798937Sdes#endif 65898937Sdes 659126274Sdes#if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) 660126274Sdes# define USE_SHADOW 661126274Sdes#endif 66298937Sdes 66398937Sdes/* The login() library function in libutil is first choice */ 66498937Sdes#if defined(HAVE_LOGIN) && !defined(DISABLE_LOGIN) 66598937Sdes# define USE_LOGIN 66698937Sdes 66798937Sdes#else 66898937Sdes/* Simply select your favourite login types. */ 66998937Sdes/* Can't do if-else because some systems use several... <sigh> */ 67098937Sdes# if defined(UTMPX_FILE) && !defined(DISABLE_UTMPX) 67198937Sdes# define USE_UTMPX 67298937Sdes# endif 67398937Sdes# if defined(UTMP_FILE) && !defined(DISABLE_UTMP) 67498937Sdes# define USE_UTMP 67598937Sdes# endif 67698937Sdes# if defined(WTMPX_FILE) && !defined(DISABLE_WTMPX) 67798937Sdes# define USE_WTMPX 67898937Sdes# endif 67998937Sdes# if defined(WTMP_FILE) && !defined(DISABLE_WTMP) 68098937Sdes# define USE_WTMP 68198937Sdes# endif 68298937Sdes 68398937Sdes#endif 68498937Sdes 685128456Sdes#ifndef UT_LINESIZE 686128456Sdes# define UT_LINESIZE 8 687128456Sdes#endif 688128456Sdes 68998937Sdes/* I hope that the presence of LASTLOG_FILE is enough to detect this */ 69098937Sdes#if defined(LASTLOG_FILE) && !defined(DISABLE_LASTLOG) 69198937Sdes# define USE_LASTLOG 69298937Sdes#endif 69398937Sdes 694128456Sdes#ifdef HAVE_OSF_SIA 695128456Sdes# ifdef USE_SHADOW 696128456Sdes# undef USE_SHADOW 697128456Sdes# endif 698128456Sdes# define CUSTOM_SYS_AUTH_PASSWD 1 699128456Sdes#endif 700128456Sdes 701192595Sdes#if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(HAVE_SECUREWARE) 702149749Sdes# define CUSTOM_SYS_AUTH_PASSWD 1 703149749Sdes#endif 704181111Sdes#if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(BROKEN_LIBIAF) 705181111Sdes# define USE_LIBIAF 706181111Sdes#endif 707149749Sdes 708146998Sdes/* HP-UX 11.11 */ 709146998Sdes#ifdef BTMP_FILE 710146998Sdes# define _PATH_BTMP BTMP_FILE 711146998Sdes#endif 712146998Sdes 713146998Sdes#if defined(USE_BTMP) && defined(_PATH_BTMP) 714146998Sdes# define CUSTOM_FAILED_LOGIN 715146998Sdes#endif 716146998Sdes 71798937Sdes/** end of login recorder definitions */ 71898937Sdes 719149749Sdes#ifdef BROKEN_GETGROUPS 720149749Sdes# define getgroups(a,b) ((a)==0 && (b)==NULL ? NGROUPS_MAX : getgroups((a),(b))) 721149749Sdes#endif 722149749Sdes 723149749Sdes#if defined(HAVE_MMAP) && defined(BROKEN_MMAP) 724149749Sdes# undef HAVE_MMAP 725149749Sdes#endif 726149749Sdes 727162852Sdes#ifndef IOV_MAX 728162852Sdes# if defined(_XOPEN_IOV_MAX) 729162852Sdes# define IOV_MAX _XOPEN_IOV_MAX 730162852Sdes# elif defined(DEF_IOV_MAX) 731162852Sdes# define IOV_MAX DEF_IOV_MAX 732162852Sdes# else 733162852Sdes# define IOV_MAX 16 734162852Sdes# endif 735157016Sdes#endif 736157016Sdes 737181111Sdes#ifndef EWOULDBLOCK 738181111Sdes# define EWOULDBLOCK EAGAIN 739181111Sdes#endif 740181111Sdes 741192595Sdes#ifndef INET6_ADDRSTRLEN /* for non IPv6 machines */ 742192595Sdes#define INET6_ADDRSTRLEN 46 743192595Sdes#endif 744192595Sdes 74598937Sdes#endif /* _DEFINES_H */ 746