defines.h revision 202213
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 28197679Sdes/* $Id: defines.h,v 1.156 2009/08/28 01:21:07 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 303197679Sdes#ifndef HAVE_IN_PORT_T 304197679Sdestypedef u_int16_t in_port_t; 305197679Sdes#endif 306146998Sdes 30798937Sdes#if defined(BROKEN_SYS_TERMIO_H) && !defined(_STRUCT_WINSIZE) 30898937Sdes#define _STRUCT_WINSIZE 30998937Sdesstruct winsize { 31098937Sdes unsigned short ws_row; /* rows, in characters */ 31198937Sdes unsigned short ws_col; /* columns, in character */ 31298937Sdes unsigned short ws_xpixel; /* horizontal size, pixels */ 31398937Sdes unsigned short ws_ypixel; /* vertical size, pixels */ 31498937Sdes}; 31598937Sdes#endif 31698937Sdes 31798937Sdes/* *-*-nto-qnx does not define this type in the system headers */ 31898937Sdes#ifdef MISSING_FD_MASK 31998937Sdes typedef unsigned long int fd_mask; 32098937Sdes#endif 32198937Sdes 32298937Sdes/* Paths */ 32398937Sdes 32498937Sdes#ifndef _PATH_BSHELL 32598937Sdes# define _PATH_BSHELL "/bin/sh" 32698937Sdes#endif 32798937Sdes 32898937Sdes#ifdef USER_PATH 32998937Sdes# ifdef _PATH_STDPATH 33098937Sdes# undef _PATH_STDPATH 33198937Sdes# endif 33298937Sdes# define _PATH_STDPATH USER_PATH 33398937Sdes#endif 33498937Sdes 33598937Sdes#ifndef _PATH_STDPATH 33698937Sdes# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" 33798937Sdes#endif 33898937Sdes 339124208Sdes#ifndef SUPERUSER_PATH 340124208Sdes# define SUPERUSER_PATH _PATH_STDPATH 341124208Sdes#endif 342124208Sdes 34398937Sdes#ifndef _PATH_DEVNULL 34498937Sdes# define _PATH_DEVNULL "/dev/null" 34598937Sdes#endif 34698937Sdes 34798937Sdes#ifndef MAIL_DIRECTORY 34898937Sdes# define MAIL_DIRECTORY "/var/spool/mail" 34998937Sdes#endif 35098937Sdes 35198937Sdes#ifndef MAILDIR 35298937Sdes# define MAILDIR MAIL_DIRECTORY 35398937Sdes#endif 35498937Sdes 35598937Sdes#if !defined(_PATH_MAILDIR) && defined(MAILDIR) 35698937Sdes# define _PATH_MAILDIR MAILDIR 35798937Sdes#endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */ 35898937Sdes 35998937Sdes#ifndef _PATH_NOLOGIN 36098937Sdes# define _PATH_NOLOGIN "/etc/nologin" 36198937Sdes#endif 36298937Sdes 36398937Sdes/* Define this to be the path of the xauth program. */ 36498937Sdes#ifdef XAUTH_PATH 36598937Sdes#define _PATH_XAUTH XAUTH_PATH 36698937Sdes#endif /* XAUTH_PATH */ 36798937Sdes 36898937Sdes/* derived from XF4/xc/lib/dps/Xlibnet.h */ 36998937Sdes#ifndef X_UNIX_PATH 37098937Sdes# ifdef __hpux 37198937Sdes# define X_UNIX_PATH "/var/spool/sockets/X11/%u" 37298937Sdes# else 37398937Sdes# define X_UNIX_PATH "/tmp/.X11-unix/X%u" 37498937Sdes# endif 37598937Sdes#endif /* X_UNIX_PATH */ 37698937Sdes#define _PATH_UNIX_X X_UNIX_PATH 37798937Sdes 37898937Sdes#ifndef _PATH_TTY 37998937Sdes# define _PATH_TTY "/dev/tty" 38098937Sdes#endif 38198937Sdes 38298937Sdes/* Macros */ 38398937Sdes 38498937Sdes#if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H) 38598937Sdes# define HAVE_LOGIN_CAP 38698937Sdes#endif 38798937Sdes 38898937Sdes#ifndef MAX 38998937Sdes# define MAX(a,b) (((a)>(b))?(a):(b)) 39098937Sdes# define MIN(a,b) (((a)<(b))?(a):(b)) 39198937Sdes#endif 39298937Sdes 39398937Sdes#ifndef roundup 39498937Sdes# define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 39598937Sdes#endif 39698937Sdes 39798937Sdes#ifndef timersub 39898937Sdes#define timersub(a, b, result) \ 39998937Sdes do { \ 40098937Sdes (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ 40198937Sdes (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ 40298937Sdes if ((result)->tv_usec < 0) { \ 40398937Sdes --(result)->tv_sec; \ 40498937Sdes (result)->tv_usec += 1000000; \ 40598937Sdes } \ 40698937Sdes } while (0) 40798937Sdes#endif 40898937Sdes 409113908Sdes#ifndef TIMEVAL_TO_TIMESPEC 410113908Sdes#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ 411113908Sdes (ts)->tv_sec = (tv)->tv_sec; \ 412113908Sdes (ts)->tv_nsec = (tv)->tv_usec * 1000; \ 413113908Sdes} 414113908Sdes#endif 415113908Sdes 416113908Sdes#ifndef TIMESPEC_TO_TIMEVAL 417113908Sdes#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ 418113908Sdes (tv)->tv_sec = (ts)->tv_sec; \ 419113908Sdes (tv)->tv_usec = (ts)->tv_nsec / 1000; \ 420113908Sdes} 421113908Sdes#endif 422113908Sdes 42398937Sdes#ifndef __P 42498937Sdes# define __P(x) x 42598937Sdes#endif 42698937Sdes 42798937Sdes#if !defined(IN6_IS_ADDR_V4MAPPED) 42898937Sdes# define IN6_IS_ADDR_V4MAPPED(a) \ 42998937Sdes ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \ 43098937Sdes (((u_int32_t *) (a))[2] == htonl (0xffff))) 43198937Sdes#endif /* !defined(IN6_IS_ADDR_V4MAPPED) */ 43298937Sdes 43398937Sdes#if !defined(__GNUC__) || (__GNUC__ < 2) 43498937Sdes# define __attribute__(x) 43598937Sdes#endif /* !defined(__GNUC__) || (__GNUC__ < 2) */ 43698937Sdes 437149749Sdes#if !defined(HAVE_ATTRIBUTE__SENTINEL__) && !defined(__sentinel__) 438149749Sdes# define __sentinel__ 439149749Sdes#endif 440149749Sdes 441157016Sdes#if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__) 442157016Sdes# define __bounded__(x, y, z) 443157016Sdes#endif 444157016Sdes 445181111Sdes#if !defined(HAVE_ATTRIBUTE__NONNULL__) && !defined(__nonnull__) 446181111Sdes# define __nonnull__(x) 447181111Sdes#endif 448181111Sdes 44998937Sdes/* *-*-nto-qnx doesn't define this macro in the system headers */ 45098937Sdes#ifdef MISSING_HOWMANY 45198937Sdes# define howmany(x,y) (((x)+((y)-1))/(y)) 45298937Sdes#endif 45398937Sdes 45498937Sdes#ifndef OSSH_ALIGNBYTES 45598937Sdes#define OSSH_ALIGNBYTES (sizeof(int) - 1) 45698937Sdes#endif 45798937Sdes#ifndef __CMSG_ALIGN 45898937Sdes#define __CMSG_ALIGN(p) (((u_int)(p) + OSSH_ALIGNBYTES) &~ OSSH_ALIGNBYTES) 45998937Sdes#endif 46098937Sdes 46198937Sdes/* Length of the contents of a control message of length len */ 46298937Sdes#ifndef CMSG_LEN 46398937Sdes#define CMSG_LEN(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) 46498937Sdes#endif 46598937Sdes 46698937Sdes/* Length of the space taken up by a padded control message of length len */ 46798937Sdes#ifndef CMSG_SPACE 46898937Sdes#define CMSG_SPACE(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(len)) 46998937Sdes#endif 47098937Sdes 471124208Sdes/* given pointer to struct cmsghdr, return pointer to data */ 472124208Sdes#ifndef CMSG_DATA 473124208Sdes#define CMSG_DATA(cmsg) ((u_char *)(cmsg) + __CMSG_ALIGN(sizeof(struct cmsghdr))) 474124208Sdes#endif /* CMSG_DATA */ 475124208Sdes 476124208Sdes/* 477124208Sdes * RFC 2292 requires to check msg_controllen, in case that the kernel returns 478124208Sdes * an empty list for some reasons. 479124208Sdes */ 480124208Sdes#ifndef CMSG_FIRSTHDR 481124208Sdes#define CMSG_FIRSTHDR(mhdr) \ 482124208Sdes ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ 483124208Sdes (struct cmsghdr *)(mhdr)->msg_control : \ 484124208Sdes (struct cmsghdr *)NULL) 485124208Sdes#endif /* CMSG_FIRSTHDR */ 486124208Sdes 487181111Sdes#if defined(HAVE_DECL_OFFSETOF) && HAVE_DECL_OFFSETOF == 0 488137015Sdes# define offsetof(type, member) ((size_t) &((type *)0)->member) 489137015Sdes#endif 490124208Sdes 491162852Sdes/* Set up BSD-style BYTE_ORDER definition if it isn't there already */ 492162852Sdes/* XXX: doesn't try to cope with strange byte orders (PDP_ENDIAN) */ 493162852Sdes#ifndef BYTE_ORDER 494162852Sdes# ifndef LITTLE_ENDIAN 495162852Sdes# define LITTLE_ENDIAN 1234 496162852Sdes# endif /* LITTLE_ENDIAN */ 497162852Sdes# ifndef BIG_ENDIAN 498162852Sdes# define BIG_ENDIAN 4321 499162852Sdes# endif /* BIG_ENDIAN */ 500162852Sdes# ifdef WORDS_BIGENDIAN 501162852Sdes# define BYTE_ORDER BIG_ENDIAN 502162852Sdes# else /* WORDS_BIGENDIAN */ 503162852Sdes# define BYTE_ORDER LITTLE_ENDIAN 504162852Sdes# endif /* WORDS_BIGENDIAN */ 505162852Sdes#endif /* BYTE_ORDER */ 506162852Sdes 50798937Sdes/* Function replacement / compatibility hacks */ 50898937Sdes 50998937Sdes#if !defined(HAVE_GETADDRINFO) && (defined(HAVE_OGETADDRINFO) || defined(HAVE_NGETADDRINFO)) 51098937Sdes# define HAVE_GETADDRINFO 51198937Sdes#endif 51298937Sdes 51398937Sdes#ifndef HAVE_GETOPT_OPTRESET 51499060Sdes# undef getopt 51599060Sdes# undef opterr 51699060Sdes# undef optind 51799060Sdes# undef optopt 51899060Sdes# undef optreset 51999060Sdes# undef optarg 52099060Sdes# define getopt(ac, av, o) BSDgetopt(ac, av, o) 52199060Sdes# define opterr BSDopterr 52299060Sdes# define optind BSDoptind 52399060Sdes# define optopt BSDoptopt 52499060Sdes# define optreset BSDoptreset 52599060Sdes# define optarg BSDoptarg 52698937Sdes#endif 52798937Sdes 52898937Sdes#if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) 52998937Sdes# undef HAVE_GETADDRINFO 53098937Sdes#endif 53198937Sdes#if defined(BROKEN_GETADDRINFO) && defined(HAVE_FREEADDRINFO) 53298937Sdes# undef HAVE_FREEADDRINFO 53398937Sdes#endif 53498937Sdes#if defined(BROKEN_GETADDRINFO) && defined(HAVE_GAI_STRERROR) 53598937Sdes# undef HAVE_GAI_STRERROR 53698937Sdes#endif 53798937Sdes 538128456Sdes#if defined(BROKEN_UPDWTMPX) && defined(HAVE_UPDWTMPX) 539128456Sdes# undef HAVE_UPDWTMPX 540128456Sdes#endif 541128456Sdes 542181111Sdes#if defined(BROKEN_SHADOW_EXPIRE) && defined(HAS_SHADOW_EXPIRE) 543181111Sdes# undef HAS_SHADOW_EXPIRE 544181111Sdes#endif 545181111Sdes 546162852Sdes#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT) && \ 547162852Sdes defined(SYSLOG_R_SAFE_IN_SIGHAND) 548162852Sdes# define DO_LOG_SAFE_IN_SIGHAND 549162852Sdes#endif 550162852Sdes 55198937Sdes#if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) 55298937Sdes# define memmove(s1, s2, n) bcopy((s2), (s1), (n)) 55398937Sdes#endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */ 55498937Sdes 55598937Sdes#if defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) 55698937Sdes# define USE_VHANGUP 55798937Sdes#endif /* defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) */ 55898937Sdes 55998937Sdes#ifndef GETPGRP_VOID 560162852Sdes# include <unistd.h> 56198937Sdes# define getpgrp() getpgrp(0) 56298937Sdes#endif 56398937Sdes 564146998Sdes#ifdef USE_BSM_AUDIT 565146998Sdes# define SSH_AUDIT_EVENTS 566146998Sdes# define CUSTOM_SSH_AUDIT_EVENTS 567146998Sdes#endif 568146998Sdes 56998937Sdes#if !defined(HAVE___func__) && defined(HAVE___FUNCTION__) 57098937Sdes# define __func__ __FUNCTION__ 57198937Sdes#elif !defined(HAVE___func__) 57298937Sdes# define __func__ "" 57398937Sdes#endif 57498937Sdes 575124208Sdes#if defined(KRB5) && !defined(HEIMDAL) 576124208Sdes# define krb5_get_err_text(context,code) error_message(code) 577124208Sdes#endif 578124208Sdes 579128456Sdes#if defined(SKEYCHALLENGE_4ARG) 580128456Sdes# define _compat_skeychallenge(a,b,c,d) skeychallenge(a,b,c,d) 581128456Sdes#else 582128456Sdes# define _compat_skeychallenge(a,b,c,d) skeychallenge(a,b,c) 583128456Sdes#endif 584128456Sdes 585126274Sdes/* Maximum number of file descriptors available */ 586126274Sdes#ifdef HAVE_SYSCONF 587126274Sdes# define SSH_SYSFDMAX sysconf(_SC_OPEN_MAX) 588126274Sdes#else 589126274Sdes# define SSH_SYSFDMAX 10000 590126274Sdes#endif 591126274Sdes 592181111Sdes#ifdef FSID_HAS_VAL 593181111Sdes/* encode f_fsid into a 64 bit value */ 594181111Sdes#define FSID_TO_ULONG(f) \ 595181111Sdes ((((u_int64_t)(f).val[0] & 0xffffffffUL) << 32) | \ 596181111Sdes ((f).val[1] & 0xffffffffUL)) 597197679Sdes#elif defined(FSID_HAS___VAL) 598197679Sdes#define FSID_TO_ULONG(f) \ 599197679Sdes ((((u_int64_t)(f).__val[0] & 0xffffffffUL) << 32) | \ 600197679Sdes ((f).__val[1] & 0xffffffffUL)) 601181111Sdes#else 602181111Sdes# define FSID_TO_ULONG(f) ((f)) 603181111Sdes#endif 604181111Sdes 605149749Sdes#if defined(__Lynx__) 606149749Sdes /* 607149749Sdes * LynxOS defines these in param.h which we do not want to include since 608149749Sdes * it will also pull in a bunch of kernel definitions. 609149749Sdes */ 610149749Sdes# define ALIGNBYTES (sizeof(int) - 1) 611149749Sdes# define ALIGN(p) (((unsigned)p + ALIGNBYTES) & ~ALIGNBYTES) 612149749Sdes /* Missing prototypes on LynxOS */ 613149749Sdes int snprintf (char *, size_t, const char *, ...); 614149749Sdes int mkstemp (char *); 615149749Sdes char *crypt (const char *, const char *); 616149749Sdes int seteuid (uid_t); 617149749Sdes int setegid (gid_t); 618149749Sdes char *mkdtemp (char *); 619149749Sdes int rresvport_af (int *, sa_family_t); 620149749Sdes int innetgr (const char *, const char *, const char *, const char *); 621149749Sdes#endif 622126274Sdes 62398937Sdes/* 62498937Sdes * Define this to use pipes instead of socketpairs for communicating with the 62598937Sdes * client program. Socketpairs do not seem to work on all systems. 62698937Sdes * 62798937Sdes * configure.ac sets this for a few OS's which are known to have problems 62898937Sdes * but you may need to set it yourself 62998937Sdes */ 63098937Sdes/* #define USE_PIPES 1 */ 63198937Sdes 63298937Sdes/** 63398937Sdes ** login recorder definitions 63498937Sdes **/ 63598937Sdes 63698937Sdes/* FIXME: put default paths back in */ 63798937Sdes#ifndef UTMP_FILE 63898937Sdes# ifdef _PATH_UTMP 63998937Sdes# define UTMP_FILE _PATH_UTMP 64098937Sdes# else 64198937Sdes# ifdef CONF_UTMP_FILE 64298937Sdes# define UTMP_FILE CONF_UTMP_FILE 64398937Sdes# endif 64498937Sdes# endif 64598937Sdes#endif 64698937Sdes#ifndef WTMP_FILE 64798937Sdes# ifdef _PATH_WTMP 64898937Sdes# define WTMP_FILE _PATH_WTMP 64998937Sdes# else 65098937Sdes# ifdef CONF_WTMP_FILE 65198937Sdes# define WTMP_FILE CONF_WTMP_FILE 65298937Sdes# endif 65398937Sdes# endif 65498937Sdes#endif 65598937Sdes/* pick up the user's location for lastlog if given */ 65698937Sdes#ifndef LASTLOG_FILE 65798937Sdes# ifdef _PATH_LASTLOG 65898937Sdes# define LASTLOG_FILE _PATH_LASTLOG 65998937Sdes# else 66098937Sdes# ifdef CONF_LASTLOG_FILE 66198937Sdes# define LASTLOG_FILE CONF_LASTLOG_FILE 66298937Sdes# endif 66398937Sdes# endif 66498937Sdes#endif 66598937Sdes 666126274Sdes#if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) 667126274Sdes# define USE_SHADOW 668126274Sdes#endif 66998937Sdes 67098937Sdes/* The login() library function in libutil is first choice */ 67198937Sdes#if defined(HAVE_LOGIN) && !defined(DISABLE_LOGIN) 67298937Sdes# define USE_LOGIN 67398937Sdes 67498937Sdes#else 67598937Sdes/* Simply select your favourite login types. */ 67698937Sdes/* Can't do if-else because some systems use several... <sigh> */ 677202213Sed# if !defined(DISABLE_UTMPX) 67898937Sdes# define USE_UTMPX 67998937Sdes# endif 68098937Sdes# if defined(UTMP_FILE) && !defined(DISABLE_UTMP) 68198937Sdes# define USE_UTMP 68298937Sdes# endif 68398937Sdes# if defined(WTMPX_FILE) && !defined(DISABLE_WTMPX) 68498937Sdes# define USE_WTMPX 68598937Sdes# endif 68698937Sdes# if defined(WTMP_FILE) && !defined(DISABLE_WTMP) 68798937Sdes# define USE_WTMP 68898937Sdes# endif 68998937Sdes 69098937Sdes#endif 69198937Sdes 692128456Sdes#ifndef UT_LINESIZE 693128456Sdes# define UT_LINESIZE 8 694128456Sdes#endif 695128456Sdes 69698937Sdes/* I hope that the presence of LASTLOG_FILE is enough to detect this */ 69798937Sdes#if defined(LASTLOG_FILE) && !defined(DISABLE_LASTLOG) 69898937Sdes# define USE_LASTLOG 69998937Sdes#endif 70098937Sdes 701128456Sdes#ifdef HAVE_OSF_SIA 702128456Sdes# ifdef USE_SHADOW 703128456Sdes# undef USE_SHADOW 704128456Sdes# endif 705128456Sdes# define CUSTOM_SYS_AUTH_PASSWD 1 706128456Sdes#endif 707128456Sdes 708192595Sdes#if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(HAVE_SECUREWARE) 709149749Sdes# define CUSTOM_SYS_AUTH_PASSWD 1 710149749Sdes#endif 711181111Sdes#if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(BROKEN_LIBIAF) 712181111Sdes# define USE_LIBIAF 713181111Sdes#endif 714149749Sdes 715146998Sdes/* HP-UX 11.11 */ 716146998Sdes#ifdef BTMP_FILE 717146998Sdes# define _PATH_BTMP BTMP_FILE 718146998Sdes#endif 719146998Sdes 720146998Sdes#if defined(USE_BTMP) && defined(_PATH_BTMP) 721146998Sdes# define CUSTOM_FAILED_LOGIN 722146998Sdes#endif 723146998Sdes 72498937Sdes/** end of login recorder definitions */ 72598937Sdes 726149749Sdes#ifdef BROKEN_GETGROUPS 727149749Sdes# define getgroups(a,b) ((a)==0 && (b)==NULL ? NGROUPS_MAX : getgroups((a),(b))) 728149749Sdes#endif 729149749Sdes 730149749Sdes#if defined(HAVE_MMAP) && defined(BROKEN_MMAP) 731149749Sdes# undef HAVE_MMAP 732149749Sdes#endif 733149749Sdes 734162852Sdes#ifndef IOV_MAX 735162852Sdes# if defined(_XOPEN_IOV_MAX) 736162852Sdes# define IOV_MAX _XOPEN_IOV_MAX 737162852Sdes# elif defined(DEF_IOV_MAX) 738162852Sdes# define IOV_MAX DEF_IOV_MAX 739162852Sdes# else 740162852Sdes# define IOV_MAX 16 741162852Sdes# endif 742157016Sdes#endif 743157016Sdes 744181111Sdes#ifndef EWOULDBLOCK 745181111Sdes# define EWOULDBLOCK EAGAIN 746181111Sdes#endif 747181111Sdes 748192595Sdes#ifndef INET6_ADDRSTRLEN /* for non IPv6 machines */ 749192595Sdes#define INET6_ADDRSTRLEN 46 750192595Sdes#endif 751192595Sdes 752197679Sdes#ifndef SSH_IOBUFSZ 753197679Sdes# define SSH_IOBUFSZ 8192 754197679Sdes#endif 755197679Sdes 75698937Sdes#endif /* _DEFINES_H */ 757