system.h revision 130303
169783Smsmith/* system-dependent definitions for CVS.
269783Smsmith   Copyright (C) 1989-1992 Free Software Foundation, Inc.
369783Smsmith
469783Smsmith   This program is free software; you can redistribute it and/or modify
569783Smsmith   it under the terms of the GNU General Public License as published by
669783Smsmith   the Free Software Foundation; either version 2, or (at your option)
769783Smsmith   any later version.
869783Smsmith
969783Smsmith   This program is distributed in the hope that it will be useful,
1069783Smsmith   but WITHOUT ANY WARRANTY; without even the implied warranty of
1169783Smsmith   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1269783Smsmith   GNU General Public License for more details.  */
1369783Smsmith
1469783Smsmith#include <sys/types.h>
1569783Smsmith#include <sys/stat.h>
1669783Smsmith
1769783Smsmith#ifdef STAT_MACROS_BROKEN
1869783Smsmith#undef S_ISBLK
1969783Smsmith#undef S_ISCHR
2069783Smsmith#undef S_ISDIR
2169783Smsmith#undef S_ISREG
2269783Smsmith#undef S_ISFIFO
2369783Smsmith#undef S_ISLNK
2469783Smsmith#undef S_ISSOCK
2569783Smsmith#undef S_ISMPB
2669783Smsmith#undef S_ISMPC
2769783Smsmith#undef S_ISNWK
2869783Smsmith#endif
2969783Smsmith
3069783Smsmith/* Not all systems have S_IFMT, but we want to use it if we have it.
3169783Smsmith   The S_IFMT code below looks right (it masks and compares).  The
3269783Smsmith   non-S_IFMT code looks bogus (are there really systems on which
3369783Smsmith   S_IFBLK, S_IFLNK, &c, each have their own bit?  I suspect it was
3469783Smsmith   written for OS/2 using the IBM C/C++ Tools 2.01 compiler).
3569783Smsmith
3669783Smsmith   Of course POSIX systems will have S_IS*, so maybe the issue is
3769783Smsmith   semi-moot.  */
3869783Smsmith
3969783Smsmith#if !defined(S_ISBLK) && defined(S_IFBLK)
4069783Smsmith# if defined(S_IFMT)
4169783Smsmith# define	S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
4269783Smsmith# else
4369783Smsmith# define S_ISBLK(m) ((m) & S_IFBLK)
4469783Smsmith# endif
4569783Smsmith#endif
46102441Sjhb
4769783Smsmith#if !defined(S_ISCHR) && defined(S_IFCHR)
4869783Smsmith# if defined(S_IFMT)
4989383Simp# define	S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
5069783Smsmith# else
5169783Smsmith# define S_ISCHR(m) ((m) & S_IFCHR)
5269783Smsmith# endif
5369783Smsmith#endif
5469783Smsmith
5569783Smsmith#if !defined(S_ISDIR) && defined(S_IFDIR)
5669783Smsmith# if defined(S_IFMT)
5769783Smsmith# define	S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
5869783Smsmith# else
5969783Smsmith# define S_ISDIR(m) ((m) & S_IFDIR)
6069783Smsmith# endif
6169783Smsmith#endif
6269783Smsmith
6369783Smsmith#if !defined(S_ISREG) && defined(S_IFREG)
6469783Smsmith# if defined(S_IFMT)
6569783Smsmith# define	S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
6669783Smsmith# else
6769783Smsmith# define S_ISREG(m) ((m) & S_IFREG)
6869783Smsmith# endif
6969783Smsmith#endif
7069783Smsmith
7169783Smsmith#if !defined(S_ISFIFO) && defined(S_IFIFO)
7269783Smsmith# if defined(S_IFMT)
7369783Smsmith# define	S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
7469783Smsmith# else
7569783Smsmith# define S_ISFIFO(m) ((m) & S_IFIFO)
7669783Smsmith# endif
7769783Smsmith#endif
7869783Smsmith
7969783Smsmith#if !defined(S_ISLNK) && defined(S_IFLNK)
8069783Smsmith# if defined(S_IFMT)
8169783Smsmith# define	S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
8269783Smsmith# else
8369783Smsmith# define S_ISLNK(m) ((m) & S_IFLNK)
8469783Smsmith# endif
8569783Smsmith#endif
8669783Smsmith
8769783Smsmith#ifndef S_ISSOCK
8869783Smsmith# if defined( S_IFSOCK )
89102441Sjhb#   ifdef S_IFMT
9069783Smsmith#     define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
9169783Smsmith#   else
9269783Smsmith#     define S_ISSOCK(m) ((m) & S_IFSOCK)
9369783Smsmith#   endif /* S_IFMT */
9469783Smsmith# elif defined( S_ISNAM )
9569783Smsmith    /* SCO OpenServer 5.0.6a */
9669783Smsmith#   define S_ISSOCK S_ISNAM
9769783Smsmith# endif /* !S_IFSOCK && S_ISNAM */
9869783Smsmith#endif /* !S_ISSOCK */
9969783Smsmith
10069783Smsmith#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
10169783Smsmith# if defined(S_IFMT)
10269783Smsmith# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
10369783Smsmith# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
10469783Smsmith# else
10569783Smsmith# define S_ISMPB(m) ((m) & S_IFMPB)
10669783Smsmith# define S_ISMPC(m) ((m) & S_IFMPC)
107102441Sjhb# endif
108102441Sjhb#endif
10969783Smsmith
11069783Smsmith#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
11169908Smsmith# if defined(S_IFMT)
11269783Smsmith# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
11369783Smsmith# else
11469783Smsmith# define S_ISNWK(m) ((m) & S_IFNWK)
11569783Smsmith# endif
11669908Smsmith#endif
11769908Smsmith
11869908Smsmith#ifdef NEED_DECOY_PERMISSIONS        /* OS/2, really */
11969953Smsmith
12069908Smsmith#define	S_IRUSR S_IREAD
12169908Smsmith#define	S_IWUSR S_IWRITE
12269908Smsmith#define	S_IXUSR S_IEXEC
12369908Smsmith#define	S_IRWXU	(S_IRUSR | S_IWUSR | S_IXUSR)
12469908Smsmith#define	S_IRGRP S_IREAD
12569783Smsmith#define	S_IWGRP S_IWRITE
12669908Smsmith#define	S_IXGRP S_IEXEC
12769908Smsmith#define	S_IRWXG	(S_IRGRP | S_IWGRP | S_IXGRP)
12869908Smsmith#define	S_IROTH S_IREAD
12969953Smsmith#define	S_IWOTH S_IWRITE
13069953Smsmith#define	S_IXOTH S_IEXEC
13169953Smsmith#define	S_IRWXO	(S_IROTH | S_IWOTH | S_IXOTH)
13269953Smsmith
13369953Smsmith#else /* ! NEED_DECOY_PERMISSIONS */
13469953Smsmith
13569953Smsmith#ifndef S_IRUSR
13669953Smsmith#define	S_IRUSR 0400
13769908Smsmith#define	S_IWUSR 0200
13869953Smsmith#define	S_IXUSR 0100
13969953Smsmith/* Read, write, and execute by owner.  */
14069953Smsmith#define	S_IRWXU	(S_IRUSR|S_IWUSR|S_IXUSR)
14169953Smsmith
14269953Smsmith#define	S_IRGRP	(S_IRUSR >> 3)	/* Read by group.  */
14369953Smsmith#define	S_IWGRP	(S_IWUSR >> 3)	/* Write by group.  */
14469953Smsmith#define	S_IXGRP	(S_IXUSR >> 3)	/* Execute by group.  */
14569908Smsmith/* Read, write, and execute by group.  */
14669908Smsmith#define	S_IRWXG	(S_IRWXU >> 3)
14769908Smsmith
14869908Smsmith#define	S_IROTH	(S_IRGRP >> 3)	/* Read by others.  */
14969908Smsmith#define	S_IWOTH	(S_IWGRP >> 3)	/* Write by others.  */
15069953Smsmith#define	S_IXOTH	(S_IXGRP >> 3)	/* Execute by others.  */
15169953Smsmith/* Read, write, and execute by others.  */
15269953Smsmith#define	S_IRWXO	(S_IRWXG >> 3)
15369953Smsmith#endif /* !def S_IRUSR */
15469953Smsmith#endif /* NEED_DECOY_PERMISSIONS */
15569953Smsmith
15669953Smsmith#if defined(POSIX) || defined(HAVE_UNISTD_H)
15769953Smsmith#include <unistd.h>
15869908Smsmith#include <limits.h>
15969908Smsmith#else
16069908Smsmithoff_t lseek ();
16169908Smsmithchar *getcwd ();
16269908Smsmith#endif
16369908Smsmith
16469908Smsmith#include "xtime.h"
16569908Smsmith
16669908Smsmith#ifdef HAVE_IO_H
16769908Smsmith#include <io.h>
16869908Smsmith#endif
16969908Smsmith
17069908Smsmith#ifdef HAVE_DIRECT_H
17169908Smsmith#include <direct.h>
17269908Smsmith#endif
17369908Smsmith
17469908Smsmith
17569908Smsmith
17669783Smsmith/*
17769783Smsmith**  MAXPATHLEN and PATH_MAX
17869783Smsmith**
17969783Smsmith**     On most systems MAXPATHLEN is defined in sys/param.h to be 1024. Of
18069783Smsmith**     those that this is not true, again most define PATH_MAX in limits.h
18169783Smsmith**     or sys/limits.h which usually gets included by limits.h. On the few
18269783Smsmith**     remaining systems that neither statement is true, _POSIX_PATH_MAX
18369783Smsmith**     is defined.
18469783Smsmith**
18569783Smsmith**     So:
18669783Smsmith**         1. If PATH_MAX is defined just use it.
18769783Smsmith**         2. If MAXPATHLEN is defined but not PATH_MAX, then define
18869783Smsmith**            PATH_MAX in terms of MAXPATHLEN.
18969783Smsmith**         3. If neither is defined, include limits.h and check for
19069783Smsmith**            PATH_MAX again.
19169783Smsmith**         3.1 If we now have PATHSIZE, define PATH_MAX in terms of that.
19269783Smsmith**             and ignore the rest.  Since _POSIX_PATH_MAX (checked for
19369783Smsmith**             next) is the *most* restrictive (smallest) value, if we
19469783Smsmith**             trust _POSIX_PATH_MAX, several of our buffers are too small.
195102441Sjhb**         4. If PATH_MAX is still not defined but _POSIX_PATH_MAX is,
19669783Smsmith**            then define PATH_MAX in terms of _POSIX_PATH_MAX.
197102441Sjhb**         5. And if even _POSIX_PATH_MAX doesn't exist just put in
198102441Sjhb**            a reasonable value.
199102441Sjhb**         *. All in all, this is an excellent argument for using pathconf()
200102441Sjhb**            when at all possible.  Or better yet, dynamically allocate
201102441Sjhb**            our buffers and use getcwd() not getwd().
202102441Sjhb**
203102441Sjhb**     This works on:
204102441Sjhb**         Sun Sparc 10        SunOS 4.1.3  &  Solaris 1.2
20569783Smsmith**         HP 9000/700         HP/UX 8.07   &  HP/UX 9.01
20669783Smsmith**         Tektronix XD88/10   UTekV 3.2e
20769783Smsmith**         IBM RS6000          AIX 3.2
20869783Smsmith**         Dec Alpha           OSF 1 ????
20969783Smsmith**         Intel 386           BSDI BSD/386
21069783Smsmith**         Intel 386           SCO OpenServer Release 5
21169783Smsmith**         Apollo              Domain 10.4
21269783Smsmith**         NEC                 SVR4
21369783Smsmith*/
21469783Smsmith
215102441Sjhb/* On MOST systems this will get you MAXPATHLEN.
21669783Smsmith   Windows NT doesn't have this file, tho.  */
21769783Smsmith#ifdef HAVE_SYS_PARAM_H
21869783Smsmith#include <sys/param.h>
21969783Smsmith#endif
22069783Smsmith
22169783Smsmith#ifndef PATH_MAX
22269783Smsmith#  ifdef MAXPATHLEN
22369783Smsmith#    define PATH_MAX                 MAXPATHLEN
22469783Smsmith#  else
22569783Smsmith#    include <limits.h>
22669783Smsmith#    ifndef PATH_MAX
22769783Smsmith#      ifdef PATHSIZE
228102441Sjhb#         define PATH_MAX               PATHSIZE
22969783Smsmith#      else /* no PATHSIZE */
23069783Smsmith#        ifdef _POSIX_PATH_MAX
23169783Smsmith#          define PATH_MAX             _POSIX_PATH_MAX
23269783Smsmith#        else
23369783Smsmith#          define PATH_MAX             1024
23469783Smsmith#        endif  /* no _POSIX_PATH_MAX */
23569783Smsmith#      endif  /* no PATHSIZE */
23669783Smsmith#    endif /* no PATH_MAX   */
23769783Smsmith#  endif  /* MAXPATHLEN */
23869783Smsmith#endif  /* PATH_MAX   */
23969783Smsmith
24069783Smsmith
24169783Smsmith/* The NeXT (without _POSIX_SOURCE, which we don't want) has a utime.h
24290388Simp   which doesn't define anything.  It would be cleaner to have configure
24390388Simp   check for struct utimbuf, but for now I'm checking NeXT here (so I don't
24490388Simp   have to debug the configure check across all the machines).  */
24590388Simp#if defined (HAVE_UTIME_H) && !defined (NeXT)
24690388Simp#  include <utime.h>
24790388Simp#else
24890388Simp#  if defined (HAVE_SYS_UTIME_H)
24990898Simp#    include <sys/utime.h>
25090388Simp#  else
25190388Simp#    ifndef ALTOS
25290388Simpstruct utimbuf
25390388Simp{
25490388Simp  long actime;
25590388Simp  long modtime;
25690388Simp};
25790388Simp#    endif
25890388Simpint utime ();
25990388Simp#  endif
26090898Simp#endif
26190388Simp
26290388Simp#include <string.h>
26390388Simp
26490388Simp#ifndef ERRNO_H_MISSING
26590388Simp#include <errno.h>
26669783Smsmith#endif
26769783Smsmith
26869783Smsmith/* Not all systems set the same error code on a non-existent-file
269102441Sjhb   error.  This tries to ask the question somewhat portably.
27069783Smsmith   On systems that don't have ENOTEXIST, this should behave just like
27169783Smsmith   x == ENOENT.  "x" is probably errno, of course. */
27269783Smsmith
27369783Smsmith#ifdef ENOTEXIST
27469783Smsmith#  ifdef EOS2ERR
27569783Smsmith#    define existence_error(x) \
27669783Smsmith     (((x) == ENOTEXIST) || ((x) == ENOENT) || ((x) == EOS2ERR))
27769783Smsmith#  else
27869783Smsmith#    define existence_error(x) \
27969783Smsmith     (((x) == ENOTEXIST) || ((x) == ENOENT))
28069783Smsmith#  endif
28169783Smsmith#else
28269783Smsmith#  ifdef EVMSERR
28369783Smsmith#     define existence_error(x) \
28469783Smsmith((x) == ENOENT || (x) == EINVAL || (x) == EVMSERR)
28569783Smsmith#  else
28669783Smsmith#    define existence_error(x) ((x) == ENOENT)
28769783Smsmith#  endif
28869783Smsmith#endif
28969783Smsmith
29069783Smsmith
29190898Simp#ifdef STDC_HEADERS
29291064Sphk# include <stdlib.h>
29390898Simp#else
29490898Simpchar *getenv ();
29590898Simpchar *malloc ();
29690898Simpchar *realloc ();
29790898Simpchar *calloc ();
29890898Simpextern int errno;
29991064Sphk#endif
30091064Sphk
30191278Simp/* SunOS4 apparently does not define this in stdlib.h.  */
30291064Sphk#ifndef EXIT_FAILURE
30391278Simp# define EXIT_FAILURE 1
30491064Sphk#endif
30591278Simp
30691064Sphk/* check for POSIX signals */
30790898Simp#if defined(HAVE_SIGACTION) && defined(HAVE_SIGPROCMASK)
30890388Simp# define POSIX_SIGNALS
30990388Simp#endif
31069783Smsmith
31169783Smsmith/* MINIX 1.6 doesn't properly support sigaction */
31269783Smsmith#if defined(_MINIX)
31369783Smsmith# undef POSIX_SIGNALS
31490388Simp#endif
31569783Smsmith
31669908Smsmith/* If !POSIX, try for BSD.. Reason: 4.4BSD implements these as wrappers */
31769908Smsmith#if !defined(POSIX_SIGNALS)
31869908Smsmith# if defined(HAVE_SIGVEC) && defined(HAVE_SIGSETMASK) && defined(HAVE_SIGBLOCK)
31969783Smsmith#  define BSD_SIGNALS
32069783Smsmith# endif
32169783Smsmith#endif
32269783Smsmith
32369783Smsmith/* Under OS/2, this must be included _after_ stdio.h; that's why we do
32469783Smsmith   it here. */
32569783Smsmith#ifdef USE_OWN_TCPIP_H
32669783Smsmith# include "tcpip.h"
32769783Smsmith#endif
32890898Simp
32991064Sphk#ifdef HAVE_FCNTL_H
33094573Simp# include <fcntl.h>
33190898Simp#else
33290898Simp# include <sys/file.h>
33390898Simp#endif
33490898Simp
33590898Simp#ifndef SEEK_SET
33691064Sphk# define SEEK_SET 0
33791064Sphk# define SEEK_CUR 1
33891278Simp# define SEEK_END 2
33991064Sphk#endif
34091278Simp
34191064Sphk#ifndef F_OK
34291278Simp# define F_OK 0
34391064Sphk# define X_OK 1
34490898Simp# define W_OK 2
34590388Simp# define R_OK 4
34690388Simp#endif
34790388Simp
34890435Simp#if HAVE_DIRENT_H
34990435Simp# include <dirent.h>
35090435Simp# define NAMLEN(dirent) strlen((dirent)->d_name)
35190435Simp#else
35290435Simp# define dirent direct
35390435Simp# define NAMLEN(dirent) (dirent)->d_namlen
35490435Simp# if HAVE_SYS_NDIR_H
35583951Sbrooks#  include <sys/ndir.h>
35669783Smsmith# endif
35783951Sbrooks# if HAVE_SYS_DIR_H
35869783Smsmith#  include <sys/dir.h>
35969908Smsmith# endif
36069908Smsmith# if HAVE_NDIR_H
36169908Smsmith#  include <ndir.h>
36269908Smsmith# endif
36369908Smsmith#endif
36469783Smsmith
36569908Smsmith/* Convert B 512-byte blocks to kilobytes if K is nonzero,
36669783Smsmith   otherwise return it unchanged. */
36769783Smsmith#define convert_blocks(b, k) ((k) ? ((b) + 1) / 2 : (b))
36869908Smsmith
36969783Smsmith#ifndef S_ISLNK
37069783Smsmith# define lstat stat
37169783Smsmith#endif
37269783Smsmith
37369783Smsmith/*
37469783Smsmith * Some UNIX distributions don't include these in their stat.h Defined here
37569783Smsmith * because "config.h" is always included last.
37669783Smsmith */
37769783Smsmith#ifndef S_IWRITE
378102441Sjhb# define	S_IWRITE	0000200    /* write permission, owner */
37969783Smsmith#endif
38069783Smsmith#ifndef S_IWGRP
38169908Smsmith# define	S_IWGRP		0000020    /* write permission, grougroup */
38269783Smsmith#endif
38369783Smsmith#ifndef S_IWOTH
38469783Smsmith# define	S_IWOTH		0000002    /* write permission, other */
38569783Smsmith#endif
38669783Smsmith
387102441Sjhb/* Under non-UNIX operating systems (MS-DOS, WinNT, MacOS), many filesystem
38869783Smsmith   calls take  only one argument; permission is handled very differently on
38969783Smsmith   those systems than in Unix.  So we leave such systems a hook on which they
39069783Smsmith   can hang their own definitions.  */
39169783Smsmith
39269783Smsmith#ifndef CVS_ACCESS
393102441Sjhb# define CVS_ACCESS access
39469783Smsmith#endif
39569783Smsmith
39669783Smsmith#ifndef CVS_CHDIR
39769783Smsmith# define CVS_CHDIR chdir
39869783Smsmith#endif
39969783Smsmith
40069783Smsmith#ifndef CVS_CREAT
40169783Smsmith# define CVS_CREAT creat
40269783Smsmith#endif
40369783Smsmith
40469783Smsmith#ifndef CVS_FOPEN
40569783Smsmith# define CVS_FOPEN fopen
40669783Smsmith#endif
40769783Smsmith
40869783Smsmith#ifndef CVS_FDOPEN
40969783Smsmith# define CVS_FDOPEN fdopen
41069783Smsmith#endif
41169783Smsmith
41269783Smsmith#ifndef CVS_MKDIR
41369783Smsmith# define CVS_MKDIR mkdir
41469783Smsmith#endif
41569783Smsmith
41669783Smsmith#ifndef CVS_OPEN
41769783Smsmith# define CVS_OPEN open
41869783Smsmith#endif
41969783Smsmith
42069783Smsmith#ifndef CVS_READDIR
42169783Smsmith# define CVS_READDIR readdir
42269783Smsmith#endif
42369783Smsmith
42469783Smsmith#ifndef CVS_CLOSEDIR
42569783Smsmith# define CVS_CLOSEDIR closedir
42669783Smsmith#endif
42769783Smsmith
42890554Smsmith#ifndef CVS_OPENDIR
429102977Sjhb# define CVS_OPENDIR opendir
430102977Sjhb#endif
43190554Smsmith
43269783Smsmith#ifndef CVS_RENAME
43369783Smsmith# define CVS_RENAME rename
434#endif
435
436#ifndef CVS_RMDIR
437# define CVS_RMDIR rmdir
438#endif
439
440#ifndef CVS_STAT
441# define CVS_STAT stat
442#endif
443
444/* Open question: should CVS_STAT be lstat by default?  We need
445   to use lstat in order to handle symbolic links correctly with
446   the PreservePermissions option. -twp */
447#ifndef CVS_LSTAT
448# define CVS_LSTAT lstat
449#endif
450
451#ifndef CVS_UNLINK
452# define CVS_UNLINK unlink
453#endif
454
455/* Wildcard matcher.  Should be case-insensitive if the system is.  */
456#ifndef CVS_FNMATCH
457# define CVS_FNMATCH fnmatch
458#endif
459
460#ifdef WIN32
461/*
462 * According to GNU conventions, we should avoid referencing any macro
463 * containing "WIN" as a reference to Microsoft Windows, as we would like to
464 * avoid any implication that we consider Microsoft Windows any sort of "win".
465 *
466 * FIXME: As of 2003-06-09, folks on the GNULIB project were discussing
467 * defining a configure macro to define WOE32 appropriately.  If they ever do
468 * write such a beast, we should use it, though in most cases it would be
469 * preferable to avoid referencing any OS or compiler anyhow, per Autoconf
470 * convention, and reference only tested features of the system.
471 */
472# define WOE32 1
473#endif /* WIN32 */
474
475
476#ifdef WOE32
477  /* Under Windows NT, filenames are case-insensitive.  */
478# define FILENAMES_CASE_INSENSITIVE 1
479#endif /* WOE32 */
480
481
482
483#ifdef FILENAMES_CASE_INSENSITIVE
484
485# if defined (__CYGWIN32__) || defined (WOE32)
486    /* Under Windows, filenames are case-insensitive, and both / and \
487       are path component separators.  */
488#   define FOLD_FN_CHAR(c) (WNT_filename_classes[(unsigned char) (c)])
489extern unsigned char WNT_filename_classes[];
490    /* Is the character C a path name separator?  Under
491       Windows NT, you can use either / or \.  */
492#   define ISDIRSEP(c) (FOLD_FN_CHAR(c) == '/')
493#   define ISABSOLUTE(s) (ISDIRSEP(s[0]) || FOLD_FN_CHAR(s[0]) >= 'a' && FOLD_FN_CHAR(s[0]) <= 'z' && s[1] == ':' && ISDIRSEP(s[2]))
494# else /* ! WOE32 */
495  /* As far as I know, just Macintosh OS X can make it here,
496   * but since the OS X fold just folds a-z into A-Z or visa-versa, I'm just
497   * allowing it to be used for any case insensitive system which we aren't
498   * yet making other specific folds or exceptions for (basically, anything
499   * case insensitive other than Windows, where \ and C:\ style absolute paths
500   * also need to be accounted for).
501   *
502   * Under Mac OS X, filenames are case-insensitive.
503   */
504#   define FOLD_FN_CHAR(c) (OSX_filename_classes[(unsigned char) (c)])
505extern unsigned char OSX_filename_classes[];
506# endif /* __CYGWIN32__ || WOE32 */
507
508/* The following need to be declared for all case insensitive filesystems.
509 * When not FOLD_FN_CHAR is not #defined, a default definition for these
510 * functions is provided later in this header file.  */
511
512/* Like strcmp, but with the appropriate tweaks for file names.  */
513extern int fncmp (const char *n1, const char *n2);
514
515/* Fold characters in FILENAME to their canonical forms.  */
516extern void fnfold (char *FILENAME);
517
518#endif /* FILENAMES_CASE_INSENSITIVE */
519
520
521
522/* Some file systems are case-insensitive.  If FOLD_FN_CHAR is
523   #defined, it maps the character C onto its "canonical" form.  In a
524   case-insensitive system, it would map all alphanumeric characters
525   to lower case.  Under Windows NT, / and \ are both path component
526   separators, so FOLD_FN_CHAR would map them both to /.  */
527#ifndef FOLD_FN_CHAR
528# define FOLD_FN_CHAR(c) (c)
529# define fnfold(filename) (filename)
530# define fncmp strcmp
531#endif
532
533/* Different file systems have different path component separators.
534   For the VMS port we might need to abstract further back than this.  */
535#ifndef ISDIRSEP
536# define ISDIRSEP(c) ((c) == '/')
537#endif
538
539/* Different file systems can have different naming patterns which designate
540 * a path as absolute
541 */
542#ifndef ISABSOLUTE
543# define ISABSOLUTE(s) ISDIRSEP(s[0])
544#endif
545
546
547/* On some systems, we have to be careful about writing/reading files
548   in text or binary mode (so in text mode the system can handle CRLF
549   vs. LF, VMS text file conventions, &c).  We decide to just always
550   be careful.  That way we don't have to worry about whether text and
551   binary differ on this system.  We just have to worry about whether
552   the system has O_BINARY and "rb".  The latter is easy; all ANSI C
553   libraries have it, SunOS4 has it, and CVS has used it unguarded
554   some places for a while now without complaints (e.g. "rb" in
555   server.c (server_updated), since CVS 1.8).  The former is just an
556   #ifdef.  */
557
558#define FOPEN_BINARY_READ ("rb")
559#define FOPEN_BINARY_WRITE ("wb")
560#define FOPEN_BINARY_READWRITE ("r+b")
561
562#ifdef O_BINARY
563#define OPEN_BINARY (O_BINARY)
564#else
565#define OPEN_BINARY (0)
566#endif
567