11e72d8d2Sderaadt /* system-dependent definitions for CVS. 21e72d8d2Sderaadt Copyright (C) 1989-1992 Free Software Foundation, Inc. 31e72d8d2Sderaadt 41e72d8d2Sderaadt This program is free software; you can redistribute it and/or modify 51e72d8d2Sderaadt it under the terms of the GNU General Public License as published by 61e72d8d2Sderaadt the Free Software Foundation; either version 2, or (at your option) 71e72d8d2Sderaadt any later version. 81e72d8d2Sderaadt 91e72d8d2Sderaadt This program is distributed in the hope that it will be useful, 101e72d8d2Sderaadt but WITHOUT ANY WARRANTY; without even the implied warranty of 111e72d8d2Sderaadt MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12461cc63eStholo GNU General Public License for more details. */ 131e72d8d2Sderaadt 141e72d8d2Sderaadt #include <sys/types.h> 151e72d8d2Sderaadt #include <sys/stat.h> 161e72d8d2Sderaadt 171e72d8d2Sderaadt #ifdef STAT_MACROS_BROKEN 181e72d8d2Sderaadt #undef S_ISBLK 191e72d8d2Sderaadt #undef S_ISCHR 201e72d8d2Sderaadt #undef S_ISDIR 211e72d8d2Sderaadt #undef S_ISREG 221e72d8d2Sderaadt #undef S_ISFIFO 231e72d8d2Sderaadt #undef S_ISLNK 241e72d8d2Sderaadt #undef S_ISSOCK 251e72d8d2Sderaadt #undef S_ISMPB 261e72d8d2Sderaadt #undef S_ISMPC 271e72d8d2Sderaadt #undef S_ISNWK 281e72d8d2Sderaadt #endif 291e72d8d2Sderaadt 3013571821Stholo /* Not all systems have S_IFMT, but we probably want to use it if we 3113571821Stholo do. See ChangeLog for a more detailed discussion. */ 3213571821Stholo 331e72d8d2Sderaadt #if !defined(S_ISBLK) && defined(S_IFBLK) 3413571821Stholo # if defined(S_IFMT) 351e72d8d2Sderaadt # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) 3613571821Stholo # else 3713571821Stholo # define S_ISBLK(m) ((m) & S_IFBLK) 381e72d8d2Sderaadt # endif 3913571821Stholo #endif 4013571821Stholo 411e72d8d2Sderaadt #if !defined(S_ISCHR) && defined(S_IFCHR) 4213571821Stholo # if defined(S_IFMT) 431e72d8d2Sderaadt # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) 4413571821Stholo # else 4513571821Stholo # define S_ISCHR(m) ((m) & S_IFCHR) 461e72d8d2Sderaadt # endif 4713571821Stholo #endif 4813571821Stholo 491e72d8d2Sderaadt #if !defined(S_ISDIR) && defined(S_IFDIR) 5013571821Stholo # if defined(S_IFMT) 511e72d8d2Sderaadt # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 5213571821Stholo # else 5313571821Stholo # define S_ISDIR(m) ((m) & S_IFDIR) 541e72d8d2Sderaadt # endif 5513571821Stholo #endif 5613571821Stholo 571e72d8d2Sderaadt #if !defined(S_ISREG) && defined(S_IFREG) 5813571821Stholo # if defined(S_IFMT) 591e72d8d2Sderaadt # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 6013571821Stholo # else 6113571821Stholo # define S_ISREG(m) ((m) & S_IFREG) 621e72d8d2Sderaadt # endif 6313571821Stholo #endif 6413571821Stholo 651e72d8d2Sderaadt #if !defined(S_ISFIFO) && defined(S_IFIFO) 6613571821Stholo # if defined(S_IFMT) 671e72d8d2Sderaadt # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) 6813571821Stholo # else 6913571821Stholo # define S_ISFIFO(m) ((m) & S_IFIFO) 701e72d8d2Sderaadt # endif 7113571821Stholo #endif 7213571821Stholo 731e72d8d2Sderaadt #if !defined(S_ISLNK) && defined(S_IFLNK) 7413571821Stholo # if defined(S_IFMT) 751e72d8d2Sderaadt # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) 7613571821Stholo # else 7713571821Stholo # define S_ISLNK(m) ((m) & S_IFLNK) 781e72d8d2Sderaadt # endif 7913571821Stholo #endif 8013571821Stholo 811e72d8d2Sderaadt #if !defined(S_ISSOCK) && defined(S_IFSOCK) 8213571821Stholo # if defined(S_IFMT) 831e72d8d2Sderaadt # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) 8413571821Stholo # else 8513571821Stholo # define S_ISSOCK(m) ((m) & S_IFSOCK) 861e72d8d2Sderaadt # endif 8713571821Stholo #endif 8813571821Stholo 891e72d8d2Sderaadt #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */ 9013571821Stholo # if defined(S_IFMT) 911e72d8d2Sderaadt # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) 921e72d8d2Sderaadt # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) 9313571821Stholo # else 9413571821Stholo # define S_ISMPB(m) ((m) & S_IFMPB) 9513571821Stholo # define S_ISMPC(m) ((m) & S_IFMPC) 961e72d8d2Sderaadt # endif 9713571821Stholo #endif 9813571821Stholo 991e72d8d2Sderaadt #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */ 10013571821Stholo # if defined(S_IFMT) 1011e72d8d2Sderaadt # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) 10213571821Stholo # else 10313571821Stholo # define S_ISNWK(m) ((m) & S_IFNWK) 1041e72d8d2Sderaadt # endif 10513571821Stholo #endif 10613571821Stholo 10713571821Stholo #ifdef NEED_DECOY_PERMISSIONS /* OS/2, really */ 10813571821Stholo 10913571821Stholo #define S_IRUSR S_IREAD 11013571821Stholo #define S_IWUSR S_IWRITE 11113571821Stholo #define S_IXUSR S_IEXEC 11213571821Stholo #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) 11313571821Stholo #define S_IRGRP S_IREAD 11413571821Stholo #define S_IWGRP S_IWRITE 11513571821Stholo #define S_IXGRP S_IEXEC 11613571821Stholo #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) 11713571821Stholo #define S_IROTH S_IREAD 11813571821Stholo #define S_IWOTH S_IWRITE 11913571821Stholo #define S_IXOTH S_IEXEC 12013571821Stholo #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) 12113571821Stholo 12213571821Stholo #else /* ! NEED_DECOY_PERMISSIONS */ 12313571821Stholo 1241e72d8d2Sderaadt #ifndef S_IRUSR 1251e72d8d2Sderaadt #define S_IRUSR 0400 1261e72d8d2Sderaadt #define S_IWUSR 0200 1271e72d8d2Sderaadt #define S_IXUSR 0100 1281e72d8d2Sderaadt /* Read, write, and execute by owner. */ 1291e72d8d2Sderaadt #define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR) 1301e72d8d2Sderaadt 1311e72d8d2Sderaadt #define S_IRGRP (S_IRUSR >> 3) /* Read by group. */ 1321e72d8d2Sderaadt #define S_IWGRP (S_IWUSR >> 3) /* Write by group. */ 1331e72d8d2Sderaadt #define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */ 1341e72d8d2Sderaadt /* Read, write, and execute by group. */ 1351e72d8d2Sderaadt #define S_IRWXG (S_IRWXU >> 3) 1361e72d8d2Sderaadt 1371e72d8d2Sderaadt #define S_IROTH (S_IRGRP >> 3) /* Read by others. */ 1381e72d8d2Sderaadt #define S_IWOTH (S_IWGRP >> 3) /* Write by others. */ 1391e72d8d2Sderaadt #define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */ 1401e72d8d2Sderaadt /* Read, write, and execute by others. */ 1411e72d8d2Sderaadt #define S_IRWXO (S_IRWXG >> 3) 14213571821Stholo #endif /* !def S_IRUSR */ 14313571821Stholo #endif /* NEED_DECOY_PERMISSIONS */ 1441e72d8d2Sderaadt 1451e72d8d2Sderaadt #if defined(POSIX) || defined(HAVE_UNISTD_H) 1461e72d8d2Sderaadt #include <unistd.h> 1471e72d8d2Sderaadt #include <limits.h> 1481e72d8d2Sderaadt #else 1491e72d8d2Sderaadt off_t lseek (); 1501e72d8d2Sderaadt #endif 1511e72d8d2Sderaadt 1521e72d8d2Sderaadt #if TIME_WITH_SYS_TIME 1531e72d8d2Sderaadt # include <sys/time.h> 1541e72d8d2Sderaadt # include <time.h> 1551e72d8d2Sderaadt #else 1561e72d8d2Sderaadt # if HAVE_SYS_TIME_H 1571e72d8d2Sderaadt # include <sys/time.h> 1581e72d8d2Sderaadt # else 1591e72d8d2Sderaadt # include <time.h> 1601e72d8d2Sderaadt # endif 1611e72d8d2Sderaadt #endif 1621e72d8d2Sderaadt 1631e72d8d2Sderaadt #ifdef HAVE_IO_H 1641e72d8d2Sderaadt #include <io.h> 1651e72d8d2Sderaadt #endif 1661e72d8d2Sderaadt 1671e72d8d2Sderaadt #ifdef HAVE_DIRECT_H 1681e72d8d2Sderaadt #include <direct.h> 1691e72d8d2Sderaadt #endif 1701e72d8d2Sderaadt 1711e72d8d2Sderaadt #ifdef timezone 1721e72d8d2Sderaadt #undef timezone /* needed for sgi */ 1731e72d8d2Sderaadt #endif 1741e72d8d2Sderaadt 1751e72d8d2Sderaadt #ifdef HAVE_SYS_TIMEB_H 1761e72d8d2Sderaadt #include <sys/timeb.h> 1771e72d8d2Sderaadt #else 1781e72d8d2Sderaadt struct timeb { 1791e72d8d2Sderaadt time_t time; /* Seconds since the epoch */ 1801e72d8d2Sderaadt unsigned short millitm; /* Field not used */ 1811e72d8d2Sderaadt short timezone; 1821e72d8d2Sderaadt short dstflag; /* Field not used */ 1831e72d8d2Sderaadt }; 1841e72d8d2Sderaadt #endif 1851e72d8d2Sderaadt 1861e72d8d2Sderaadt #if !defined(HAVE_FTIME) && !defined(HAVE_TIMEZONE) 1871e72d8d2Sderaadt #if !defined(timezone) 1881e72d8d2Sderaadt extern long timezone; 1891e72d8d2Sderaadt #endif 1901e72d8d2Sderaadt #endif 1911e72d8d2Sderaadt 1921e72d8d2Sderaadt 1931e72d8d2Sderaadt /* 1941e72d8d2Sderaadt ** MAXPATHLEN and PATH_MAX 1951e72d8d2Sderaadt ** 1961e72d8d2Sderaadt ** On most systems MAXPATHLEN is defined in sys/param.h to be 1024. Of 1971e72d8d2Sderaadt ** those that this is not true, again most define PATH_MAX in limits.h 1981e72d8d2Sderaadt ** or sys/limits.h which usually gets included by limits.h. On the few 1991e72d8d2Sderaadt ** remaining systems that neither statement is true, _POSIX_PATH_MAX 2001e72d8d2Sderaadt ** is defined. 2011e72d8d2Sderaadt ** 2021e72d8d2Sderaadt ** So: 2031e72d8d2Sderaadt ** 1. If PATH_MAX is defined just use it. 2041e72d8d2Sderaadt ** 2. If MAXPATHLEN is defined but not PATH_MAX, then define 2051e72d8d2Sderaadt ** PATH_MAX in terms of MAXPATHLEN. 2061e72d8d2Sderaadt ** 3. If neither is defined, include limits.h and check for 2071e72d8d2Sderaadt ** PATH_MAX again. 2081e72d8d2Sderaadt ** 3.1 If we now have PATHSIZE, define PATH_MAX in terms of that. 2091e72d8d2Sderaadt ** and ignore the rest. Since _POSIX_PATH_MAX (checked for 2101e72d8d2Sderaadt ** next) is the *most* restrictive (smallest) value, if we 2111e72d8d2Sderaadt ** trust _POSIX_PATH_MAX, several of our buffers are too small. 2121e72d8d2Sderaadt ** 4. If PATH_MAX is still not defined but _POSIX_PATH_MAX is, 2131e72d8d2Sderaadt ** then define PATH_MAX in terms of _POSIX_PATH_MAX. 2141e72d8d2Sderaadt ** 5. And if even _POSIX_PATH_MAX doesn't exist just put in 2151e72d8d2Sderaadt ** a reasonable value. 2161e72d8d2Sderaadt ** *. All in all, this is an excellent argument for using pathconf() 2171e72d8d2Sderaadt ** when at all possible. Or better yet, dynamically allocate 2181e72d8d2Sderaadt ** our buffers and use getcwd() not getwd(). 2191e72d8d2Sderaadt ** 2201e72d8d2Sderaadt ** This works on: 2211e72d8d2Sderaadt ** Sun Sparc 10 SunOS 4.1.3 & Solaris 1.2 2221e72d8d2Sderaadt ** HP 9000/700 HP/UX 8.07 & HP/UX 9.01 2231e72d8d2Sderaadt ** Tektronix XD88/10 UTekV 3.2e 2241e72d8d2Sderaadt ** IBM RS6000 AIX 3.2 2251e72d8d2Sderaadt ** Dec Alpha OSF 1 ???? 2261e72d8d2Sderaadt ** Intel 386 BSDI BSD/386 2271e72d8d2Sderaadt ** Intel 386 SCO OpenServer Release 5 2281e72d8d2Sderaadt ** Apollo Domain 10.4 2291e72d8d2Sderaadt ** NEC SVR4 2301e72d8d2Sderaadt */ 2311e72d8d2Sderaadt 2321e72d8d2Sderaadt /* On MOST systems this will get you MAXPATHLEN. 2331e72d8d2Sderaadt Windows NT doesn't have this file, tho. */ 2341e72d8d2Sderaadt #ifdef HAVE_SYS_PARAM_H 2351e72d8d2Sderaadt #include <sys/param.h> 2361e72d8d2Sderaadt #endif 2371e72d8d2Sderaadt 2381e72d8d2Sderaadt #ifndef PATH_MAX 2391e72d8d2Sderaadt # ifdef MAXPATHLEN 2401e72d8d2Sderaadt # define PATH_MAX MAXPATHLEN 2411e72d8d2Sderaadt # else 2421e72d8d2Sderaadt # include <limits.h> 2431e72d8d2Sderaadt # ifndef PATH_MAX 2441e72d8d2Sderaadt # ifdef PATHSIZE 2451e72d8d2Sderaadt # define PATH_MAX PATHSIZE 2461e72d8d2Sderaadt # else /* no PATHSIZE */ 2471e72d8d2Sderaadt # ifdef _POSIX_PATH_MAX 2481e72d8d2Sderaadt # define PATH_MAX _POSIX_PATH_MAX 2491e72d8d2Sderaadt # else 2501e72d8d2Sderaadt # define PATH_MAX 1024 2511e72d8d2Sderaadt # endif /* no _POSIX_PATH_MAX */ 2521e72d8d2Sderaadt # endif /* no PATHSIZE */ 2531e72d8d2Sderaadt # endif /* no PATH_MAX */ 2541e72d8d2Sderaadt # endif /* MAXPATHLEN */ 2551e72d8d2Sderaadt #endif /* PATH_MAX */ 2561e72d8d2Sderaadt 2571e72d8d2Sderaadt 2581e72d8d2Sderaadt /* The NeXT (without _POSIX_SOURCE, which we don't want) has a utime.h 2591e72d8d2Sderaadt which doesn't define anything. It would be cleaner to have configure 2601e72d8d2Sderaadt check for struct utimbuf, but for now I'm checking NeXT here (so I don't 2611e72d8d2Sderaadt have to debug the configure check across all the machines). */ 2621e72d8d2Sderaadt #if defined (HAVE_UTIME_H) && !defined (NeXT) 2631e72d8d2Sderaadt # include <utime.h> 26450bf276cStholo #else 26550bf276cStholo # if defined (HAVE_SYS_UTIME_H) 26613571821Stholo # include <sys/utime.h> 2671e72d8d2Sderaadt # else 2681e72d8d2Sderaadt # ifndef ALTOS 2691e72d8d2Sderaadt struct utimbuf 2701e72d8d2Sderaadt { 2711e72d8d2Sderaadt long actime; 2721e72d8d2Sderaadt long modtime; 2731e72d8d2Sderaadt }; 2741e72d8d2Sderaadt # endif 2751e72d8d2Sderaadt int utime (); 2761e72d8d2Sderaadt # endif 27750bf276cStholo #endif 2781e72d8d2Sderaadt 2791e72d8d2Sderaadt #if STDC_HEADERS || HAVE_STRING_H 2801e72d8d2Sderaadt # include <string.h> 2811e72d8d2Sderaadt /* An ANSI string.h and pre-ANSI memory.h might conflict. */ 2821e72d8d2Sderaadt # if !STDC_HEADERS && HAVE_MEMORY_H 2831e72d8d2Sderaadt # include <memory.h> 2841e72d8d2Sderaadt # endif /* not STDC_HEADERS and HAVE_MEMORY_H */ 2851e72d8d2Sderaadt #else /* not STDC_HEADERS and not HAVE_STRING_H */ 2861e72d8d2Sderaadt # include <strings.h> 2871e72d8d2Sderaadt /* memory.h and strings.h conflict on some systems. */ 2881e72d8d2Sderaadt #endif /* not STDC_HEADERS and not HAVE_STRING_H */ 2891e72d8d2Sderaadt 29050bf276cStholo #ifndef ERRNO_H_MISSING 2911e72d8d2Sderaadt #include <errno.h> 29250bf276cStholo #endif 29313571821Stholo 29413571821Stholo /* Not all systems set the same error code on a non-existent-file 29513571821Stholo error. This tries to ask the question somewhat portably. 29613571821Stholo On systems that don't have ENOTEXIST, this should behave just like 29713571821Stholo x == ENOENT. "x" is probably errno, of course. */ 29813571821Stholo 29913571821Stholo #ifdef ENOTEXIST 30013571821Stholo # ifdef EOS2ERR 30113571821Stholo # define existence_error(x) \ 30213571821Stholo (((x) == ENOTEXIST) || ((x) == ENOENT) || ((x) == EOS2ERR)) 30313571821Stholo # else 30413571821Stholo # define existence_error(x) \ 30513571821Stholo (((x) == ENOTEXIST) || ((x) == ENOENT)) 30613571821Stholo # endif 30713571821Stholo #else 308c2c61682Stholo # ifdef EVMSERR 309c2c61682Stholo # define existence_error(x) \ 310c2c61682Stholo ((x) == ENOENT || (x) == EINVAL || (x) == EVMSERR) 311c2c61682Stholo # else 31213571821Stholo # define existence_error(x) ((x) == ENOENT) 31313571821Stholo # endif 314c2c61682Stholo #endif 31513571821Stholo 31613571821Stholo 3171e72d8d2Sderaadt #ifdef STDC_HEADERS 3181e72d8d2Sderaadt #include <stdlib.h> 3191e72d8d2Sderaadt #else 3201e72d8d2Sderaadt char *getenv (); 3211e72d8d2Sderaadt char *malloc (); 3221e72d8d2Sderaadt char *realloc (); 3231e72d8d2Sderaadt char *calloc (); 3241e72d8d2Sderaadt extern int errno; 3251e72d8d2Sderaadt #endif 3261e72d8d2Sderaadt 327c2c61682Stholo /* SunOS4 apparently does not define this in stdlib.h. */ 328c2c61682Stholo #ifndef EXIT_FAILURE 329c2c61682Stholo #define EXIT_FAILURE 1 330c2c61682Stholo #endif 331c2c61682Stholo 3321e72d8d2Sderaadt #if defined(USG) || defined(POSIX) 3331e72d8d2Sderaadt char *getcwd (); 3341e72d8d2Sderaadt #else 3351e72d8d2Sderaadt char *getwd (); 3361e72d8d2Sderaadt #endif 3371e72d8d2Sderaadt 33813571821Stholo /* check for POSIX signals */ 33913571821Stholo #if defined(HAVE_SIGACTION) && defined(HAVE_SIGPROCMASK) 34013571821Stholo # define POSIX_SIGNALS 34113571821Stholo #endif 34213571821Stholo 34313571821Stholo /* MINIX 1.6 doesn't properly support sigaction */ 34413571821Stholo #if defined(_MINIX) 34513571821Stholo # undef POSIX_SIGNALS 34613571821Stholo #endif 34713571821Stholo 34813571821Stholo /* If !POSIX, try for BSD.. Reason: 4.4BSD implements these as wrappers */ 34913571821Stholo #if !defined(POSIX_SIGNALS) 35013571821Stholo # if defined(HAVE_SIGVEC) && defined(HAVE_SIGSETMASK) && defined(HAVE_SIGBLOCK) 35113571821Stholo # define BSD_SIGNALS 35213571821Stholo # endif 35313571821Stholo #endif 35413571821Stholo 35513571821Stholo /* Under OS/2, this must be included _after_ stdio.h; that's why we do 35613571821Stholo it here. */ 35713571821Stholo #ifdef USE_OWN_TCPIP_H 35813571821Stholo #include "tcpip.h" 35913571821Stholo #endif 36013571821Stholo 3611e72d8d2Sderaadt #ifdef HAVE_FCNTL_H 3621e72d8d2Sderaadt #include <fcntl.h> 3631e72d8d2Sderaadt #else 3641e72d8d2Sderaadt #include <sys/file.h> 3651e72d8d2Sderaadt #endif 3661e72d8d2Sderaadt 3671e72d8d2Sderaadt #ifndef SEEK_SET 3681e72d8d2Sderaadt #define SEEK_SET 0 3691e72d8d2Sderaadt #define SEEK_CUR 1 3701e72d8d2Sderaadt #define SEEK_END 2 3711e72d8d2Sderaadt #endif 3721e72d8d2Sderaadt 3731e72d8d2Sderaadt #ifndef F_OK 3741e72d8d2Sderaadt #define F_OK 0 3751e72d8d2Sderaadt #define X_OK 1 3761e72d8d2Sderaadt #define W_OK 2 3771e72d8d2Sderaadt #define R_OK 4 3781e72d8d2Sderaadt #endif 3791e72d8d2Sderaadt 3801e72d8d2Sderaadt #if HAVE_DIRENT_H 3811e72d8d2Sderaadt # include <dirent.h> 3821e72d8d2Sderaadt # define NAMLEN(dirent) strlen((dirent)->d_name) 3831e72d8d2Sderaadt #else 3841e72d8d2Sderaadt # define dirent direct 3851e72d8d2Sderaadt # define NAMLEN(dirent) (dirent)->d_namlen 3861e72d8d2Sderaadt # if HAVE_SYS_NDIR_H 3871e72d8d2Sderaadt # include <sys/ndir.h> 3881e72d8d2Sderaadt # endif 3891e72d8d2Sderaadt # if HAVE_SYS_DIR_H 3901e72d8d2Sderaadt # include <sys/dir.h> 3911e72d8d2Sderaadt # endif 3921e72d8d2Sderaadt # if HAVE_NDIR_H 3931e72d8d2Sderaadt # include <ndir.h> 3941e72d8d2Sderaadt # endif 3951e72d8d2Sderaadt #endif 3961e72d8d2Sderaadt 3971e72d8d2Sderaadt /* Convert B 512-byte blocks to kilobytes if K is nonzero, 3981e72d8d2Sderaadt otherwise return it unchanged. */ 3991e72d8d2Sderaadt #define convert_blocks(b, k) ((k) ? ((b) + 1) / 2 : (b)) 4001e72d8d2Sderaadt 4011e72d8d2Sderaadt #ifndef S_ISLNK 4021e72d8d2Sderaadt #define lstat stat 4031e72d8d2Sderaadt #endif 4041e72d8d2Sderaadt 4051e72d8d2Sderaadt /* 4061e72d8d2Sderaadt * Some UNIX distributions don't include these in their stat.h Defined here 4071e72d8d2Sderaadt * because "config.h" is always included last. 4081e72d8d2Sderaadt */ 4091e72d8d2Sderaadt #ifndef S_IWRITE 4101e72d8d2Sderaadt #define S_IWRITE 0000200 /* write permission, owner */ 4111e72d8d2Sderaadt #endif 4121e72d8d2Sderaadt #ifndef S_IWGRP 4131e72d8d2Sderaadt #define S_IWGRP 0000020 /* write permission, grougroup */ 4141e72d8d2Sderaadt #endif 4151e72d8d2Sderaadt #ifndef S_IWOTH 4161e72d8d2Sderaadt #define S_IWOTH 0000002 /* write permission, other */ 4171e72d8d2Sderaadt #endif 4181e72d8d2Sderaadt 41950bf276cStholo /* Under non-UNIX operating systems (MS-DOS, WinNT, MacOS), many filesystem 42050bf276cStholo calls take only one argument; permission is handled very differently on 42150bf276cStholo those systems than in Unix. So we leave such systems a hook on which they 42250bf276cStholo can hang their own definitions. */ 42350bf276cStholo 42450bf276cStholo #ifndef CVS_ACCESS 42550bf276cStholo #define CVS_ACCESS access 42650bf276cStholo #endif 42750bf276cStholo 42850bf276cStholo #ifndef CVS_CHDIR 42950bf276cStholo #define CVS_CHDIR chdir 43050bf276cStholo #endif 43150bf276cStholo 43250bf276cStholo #ifndef CVS_CREAT 43350bf276cStholo #define CVS_CREAT creat 43450bf276cStholo #endif 43550bf276cStholo 43650bf276cStholo #ifndef CVS_FOPEN 43750bf276cStholo #define CVS_FOPEN fopen 43850bf276cStholo #endif 43950bf276cStholo 4401e72d8d2Sderaadt #ifndef CVS_MKDIR 4411e72d8d2Sderaadt #define CVS_MKDIR mkdir 4421e72d8d2Sderaadt #endif 4431e72d8d2Sderaadt 44450bf276cStholo #ifndef CVS_OPEN 44550bf276cStholo #define CVS_OPEN open 44650bf276cStholo #endif 44750bf276cStholo 44850bf276cStholo #ifndef CVS_OPENDIR 44950bf276cStholo #define CVS_OPENDIR opendir 45050bf276cStholo #endif 45150bf276cStholo 45250bf276cStholo #ifndef CVS_RENAME 45350bf276cStholo #define CVS_RENAME rename 45450bf276cStholo #endif 45550bf276cStholo 45650bf276cStholo #ifndef CVS_RMDIR 45750bf276cStholo #define CVS_RMDIR rmdir 45850bf276cStholo #endif 45950bf276cStholo 46050bf276cStholo #ifndef CVS_STAT 46150bf276cStholo #define CVS_STAT stat 46250bf276cStholo #endif 46350bf276cStholo 46450bf276cStholo #ifndef CVS_UNLINK 46550bf276cStholo #define CVS_UNLINK unlink 46650bf276cStholo #endif 46750bf276cStholo 468*2770ece5Stholo /* Wildcard matcher. Should be case-insensitive if the system is. */ 469*2770ece5Stholo #ifndef CVS_FNMATCH 470*2770ece5Stholo #define CVS_FNMATCH fnmatch 471*2770ece5Stholo #endif 472*2770ece5Stholo 4731e72d8d2Sderaadt /* Some file systems are case-insensitive. If FOLD_FN_CHAR is 4741e72d8d2Sderaadt #defined, it maps the character C onto its "canonical" form. In a 4751e72d8d2Sderaadt case-insensitive system, it would map all alphanumeric characters 4761e72d8d2Sderaadt to lower case. Under Windows NT, / and \ are both path component 4771e72d8d2Sderaadt separators, so FOLD_FN_CHAR would map them both to /. */ 4781e72d8d2Sderaadt #ifndef FOLD_FN_CHAR 4791e72d8d2Sderaadt #define FOLD_FN_CHAR(c) (c) 4801e72d8d2Sderaadt #define fnfold(filename) (filename) 4811e72d8d2Sderaadt #define fncmp strcmp 4821e72d8d2Sderaadt #endif 4831e72d8d2Sderaadt 4841e72d8d2Sderaadt /* Different file systems have different path component separators. 4851e72d8d2Sderaadt For the VMS port we might need to abstract further back than this. */ 4861e72d8d2Sderaadt #ifndef ISDIRSEP 4871e72d8d2Sderaadt #define ISDIRSEP(c) ((c) == '/') 4881e72d8d2Sderaadt #endif 4891e72d8d2Sderaadt 4901e72d8d2Sderaadt 4911e72d8d2Sderaadt /* On some systems, lines in text files should be terminated with CRLF, 4921e72d8d2Sderaadt not just LF, and the read and write routines do this translation 4931e72d8d2Sderaadt for you. LINES_CRLF_TERMINATED is #defined on such systems. 4941e72d8d2Sderaadt - OPEN_BINARY is the flag to pass to the open function for 4951e72d8d2Sderaadt untranslated I/O. 4961e72d8d2Sderaadt - FOPEN_BINARY_READ is the string to pass to fopen to get 4971e72d8d2Sderaadt untranslated reading. 4981e72d8d2Sderaadt - FOPEN_BINARY_WRITE is the string to pass to fopen to get 4991e72d8d2Sderaadt untranslated writing. */ 5001e72d8d2Sderaadt #if LINES_CRLF_TERMINATED 5011e72d8d2Sderaadt #define OPEN_BINARY (O_BINARY) 5021e72d8d2Sderaadt #define FOPEN_BINARY_READ ("rb") 5031e72d8d2Sderaadt #define FOPEN_BINARY_WRITE ("wb") 5041e72d8d2Sderaadt #else 5051e72d8d2Sderaadt #define OPEN_BINARY (0) 5061e72d8d2Sderaadt #define FOPEN_BINARY_READ ("r") 5071e72d8d2Sderaadt #define FOPEN_BINARY_WRITE ("w") 5081e72d8d2Sderaadt #endif 509