[BACK]Return to compat.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / sudo

Annotation of src/usr.bin/sudo/compat.h, Revision 1.1.1.1

1.1       millert     1: /*
                      2:  * Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com>
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms, with or without
                      6:  * modification, are permitted provided that the following conditions
                      7:  * are met:
                      8:  *
                      9:  * 1. Redistributions of source code must retain the above copyright
                     10:  *    notice, this list of conditions and the following disclaimer.
                     11:  *
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
                     15:  *
                     16:  * 3. The name of the author may not be used to endorse or promote products
                     17:  *    derived from this software without specific prior written permission.
                     18:  *
                     19:  * 4. Products derived from this software may not be called "Sudo" nor
                     20:  *    may "Sudo" appear in their names without specific prior written
                     21:  *    permission from the author.
                     22:  *
                     23:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
                     24:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
                     25:  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
                     26:  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
                     27:  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
                     28:  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
                     29:  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
                     30:  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
                     31:  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
                     32:  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     33:  *
                     34:  * $Sudo: compat.h,v 1.54 1999/10/08 01:12:49 millert Exp $
                     35:  */
                     36:
                     37: #ifndef _SUDO_COMPAT_H
                     38: #define _SUDO_COMPAT_H
                     39:
                     40: /*
                     41:  * Macros that may be missing on some Operating Systems
                     42:  */
                     43:
                     44: /* Deal with ANSI stuff reasonably.  */
                     45: #ifndef  __P
                     46: # if defined (__cplusplus) || defined (__STDC__)
                     47: #  define __P(args)            args
                     48: # else
                     49: #  define __P(args)            ()
                     50: # endif
                     51: #endif /* __P */
                     52:
                     53: /*
                     54:  * Some systems (ie ISC V/386) do not define MAXPATHLEN even in param.h
                     55:  */
                     56: #ifndef MAXPATHLEN
                     57: # define MAXPATHLEN            1024
                     58: #endif
                     59:
                     60: /*
                     61:  * Some systems do not define MAXHOSTNAMELEN.
                     62:  */
                     63: #ifndef MAXHOSTNAMELEN
                     64: # define MAXHOSTNAMELEN                64
                     65: #endif
                     66:
                     67: /*
                     68:  * 4.2BSD lacks FD_* macros (we only use FD_SET and FD_ZERO)
                     69:  */
                     70: #ifndef FD_SETSIZE
                     71: # define FD_SET(fd, fds)       ((fds) -> fds_bits[0] |= (1 << (fd)))
                     72: # define FD_ZERO(fds)          ((fds) -> fds_bits[0] = 0)
                     73: #endif /* !FD_SETSIZE */
                     74:
                     75: /*
                     76:  * Posix versions for those without...
                     77:  */
                     78: #ifndef _S_IFMT
                     79: # define _S_IFMT               S_IFMT
                     80: #endif /* _S_IFMT */
                     81: #ifndef _S_IFREG
                     82: # define _S_IFREG              S_IFREG
                     83: #endif /* _S_IFREG */
                     84: #ifndef _S_IFDIR
                     85: # define _S_IFDIR              S_IFDIR
                     86: #endif /* _S_IFDIR */
                     87: #ifndef _S_IFLNK
                     88: # define _S_IFLNK              S_IFLNK
                     89: #endif /* _S_IFLNK */
                     90: #ifndef S_ISREG
                     91: # define S_ISREG(m)            (((m) & _S_IFMT) == _S_IFREG)
                     92: #endif /* S_ISREG */
                     93: #ifndef S_ISDIR
                     94: # define S_ISDIR(m)            (((m) & _S_IFMT) == _S_IFDIR)
                     95: #endif /* S_ISDIR */
                     96:
                     97: /*
                     98:  * Some OS's may not have this.
                     99:  */
                    100: #ifndef S_IRWXU
                    101: # define S_IRWXU               0000700         /* rwx for owner */
                    102: #endif /* S_IRWXU */
                    103:
                    104: /*
                    105:  * In case this is not defined in <sys/types.h> or <sys/select.h>
                    106:  */
                    107: #ifndef howmany
                    108: # define howmany(x, y) (((x) + ((y) - 1)) / (y))
                    109: #endif
                    110:
                    111: /*
                    112:  * These should be defined in <unistd.h> but not everyone has them.
                    113:  */
                    114: #ifndef STDIN_FILENO
                    115: # define       STDIN_FILENO    0
                    116: #endif
                    117: #ifndef STDOUT_FILENO
                    118: # define       STDOUT_FILENO   1
                    119: #endif
                    120: #ifndef STDERR_FILENO
                    121: # define       STDERR_FILENO   2
                    122: #endif
                    123:
                    124: /*
                    125:  * These should be defined in <unistd.h> but not everyone has them.
                    126:  */
                    127: #ifndef SEEK_SET
                    128: # define       SEEK_SET        0
                    129: #endif
                    130: #ifndef SEEK_CUR
                    131: # define       SEEK_CUR        1
                    132: #endif
                    133: #ifndef SEEK_END
                    134: # define       SEEK_END        2
                    135: #endif
                    136:
                    137: /*
                    138:  * BSD defines these in <sys/param.h> but others may not.
                    139:  */
                    140: #ifndef MIN
                    141: # define MIN(a,b) (((a)<(b))?(a):(b))
                    142: #endif
                    143: #ifndef MAX
                    144: # define MAX(a,b) (((a)>(b))?(a):(b))
                    145: #endif
                    146:
                    147: /*
                    148:  * Emulate seteuid() for HP-UX via setresuid(2) and seteuid(2) for others.
                    149:  */
                    150: #ifndef HAVE_SETEUID
                    151: # ifdef __hpux
                    152: #  define seteuid(_EUID)       (setresuid((uid_t) -1, _EUID, (uid_t) -1))
                    153: # else
                    154: #  define seteuid(_EUID)       (setreuid((uid_t) -1, _EUID))
                    155: # endif /* __hpux */
                    156: #endif /* HAVE_SETEUID */
                    157:
                    158: /*
                    159:  * On POSIX systems, O_NOCTTY is the default so some OS's may lack this define.
                    160:  */
                    161: #ifndef O_NOCTTY
                    162: # define O_NOCTTY      0
                    163: #endif /* O_NOCTTY */
                    164:
                    165: #endif /* _SUDO_COMPAT_H */