1 /* system-dependent definitions for CVS.
2 Copyright (C) 1989-1992 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. */
15 *** Begin the default set of autoconf includes.
18 /* Headers assumed for C89 freestanding compilers. See HACKING for more. */
23 /* C89 hosted headers assumed since they were included in UNIX version 7.
24 * See HACKING for more.
32 /* C89 hosted headers we _think_ GCC supplies even on freestanding systems.
33 * If we find any systems which do not have them, a replacement header should
34 * be discussed with the GNULIB folks.
36 * For more information, please see the `Portability' section of the `HACKING'
42 /* We assume this because it has been around forever despite not being a part
43 * of any of the other standards we assume conformance to. So far this hasn't
46 * For more information, please see the `Portability' section of the `HACKING'
49 #include <sys/types.h>
51 /* A GNULIB replacement for this C99 header is supplied when it is missing.
52 * See the comments in stdbool_.h for its limitations.
56 /* Ditto for these POSIX.2 headers. */
58 #include <getopt.h> /* Has GNU extensions, */
60 /* We assume <sys/stat.h> because GNULIB does. */
63 #if !STDC_HEADERS && HAVE_MEMORY_H
65 #endif /* !STDC_HEADERS && HAVE_MEMORY_H */
67 # include <inttypes.h>
68 #else /* ! HAVE_INTTYPES_H */
71 # endif /* HAVE_STDINT_H */
72 #endif /* HAVE_INTTYPES_H */
75 #endif /* HAVE_UNISTD_H */
76 /* End the default set of autoconf includes */
78 /* Assume these headers. */
81 /* There is a replacement stub for gettext provided by GNULIB when gettext is
87 # define DEVNULL "/dev/null"
98 /* The NeXT (without _POSIX_SOURCE, which we don't want) has a utime.h
99 which doesn't define anything. It would be cleaner to have configure
100 check for struct utimbuf, but for now I'm checking NeXT here (so I don't
101 have to debug the configure check across all the machines). */
102 #if defined (HAVE_UTIME_H) && !defined (NeXT)
105 # if defined (HAVE_SYS_UTIME_H)
106 # include <sys/utime.h>
119 /* errno.h variations:
121 * Not all systems set the same error code on a non-existent-file
122 * error. This tries to ask the question somewhat portably.
123 * On systems that don't have ENOTEXIST, this should behave just like
124 * x == ENOENT. "x" is probably errno, of course.
128 # define existence_error(x) \
129 (((x) == ENOTEXIST) || ((x) == ENOENT) || ((x) == EOS2ERR))
131 # define existence_error(x) \
132 (((x) == ENOTEXIST) || ((x) == ENOENT))
136 # define existence_error(x) \
137 ((x) == ENOENT || (x) == EINVAL || (x) == EVMSERR)
139 # define existence_error(x) ((x) == ENOENT)
143 /* check for POSIX signals */
144 #if defined(HAVE_SIGACTION) && defined(HAVE_SIGPROCMASK)
145 # define POSIX_SIGNALS
148 /* MINIX 1.6 doesn't properly support sigaction */
150 # undef POSIX_SIGNALS
153 /* If !POSIX, try for BSD.. Reason: 4.4BSD implements these as wrappers */
154 #if !defined(POSIX_SIGNALS)
155 # if defined(HAVE_SIGVEC) && defined(HAVE_SIGSETMASK) && defined(HAVE_SIGBLOCK)
160 /* Under OS/2, this must be included _after_ stdio.h; that's why we do
162 #ifdef USE_OWN_TCPIP_H
169 # include <sys/file.h>
187 # define NAMLEN(dirent) strlen((dirent)->d_name)
189 # define dirent direct
190 # define NAMLEN(dirent) (dirent)->d_namlen
192 # include <sys/ndir.h>
195 # include <sys/dir.h>
202 /* Convert B 512-byte blocks to kilobytes if K is nonzero,
203 otherwise return it unchanged. */
204 #define convert_blocks(b, k) ((k) ? ((b) + 1) / 2 : (b))
206 /* Under non-UNIX operating systems (MS-DOS, WinNT, MacOS), many filesystem
207 calls take only one argument; permission is handled very differently on
208 those systems than in Unix. So we leave such systems a hook on which they
209 can hang their own definitions. */
212 # define CVS_ACCESS access
216 # define CVS_CHDIR chdir
220 # define CVS_CREAT creat
224 # define CVS_FOPEN fopen
228 # define CVS_FDOPEN fdopen
232 # define CVS_MKDIR mkdir
236 # define CVS_OPEN open
240 # define CVS_READDIR readdir
244 # define CVS_CLOSEDIR closedir
248 # define CVS_OPENDIR opendir
252 # define CVS_RENAME rename
256 # define CVS_RMDIR rmdir
260 # define CVS_UNLINK unlink
263 /* Wildcard matcher. Should be case-insensitive if the system is. */
265 # define CVS_FNMATCH fnmatch
269 off_t
ftello (FILE *);
270 int fseeko (FILE *, off_t
, int);
271 #endif /* HAVE_FSEEKO */
273 #ifdef FILENAMES_CASE_INSENSITIVE
275 # if defined (__CYGWIN32__) || defined (WOE32)
276 /* Under Windows, filenames are case-insensitive, and both / and \
277 are path component separators. */
278 # define FOLD_FN_CHAR(c) (WNT_filename_classes[(unsigned char) (c)])
279 extern unsigned char WNT_filename_classes
[];
280 # else /* !__CYGWIN32__ && !WOE32 */
281 /* As far as I know, only Macintosh OS X & VMS make it here, but any
282 * platform defining FILENAMES_CASE_INSENSITIVE which isn't WOE32 or
283 * piggy-backing the same could, in theory. Since the OS X fold just folds
284 * A-Z into a-z, I'm just allowing it to be used for any case insensitive
285 * system which we aren't yet making other specific folds or exceptions for.
286 * WOE32 needs its own class since \ and C:\ style absolute paths also need
287 * to be accounted for.
289 # define FOLD_FN_CHAR(c) (OSX_filename_classes[(unsigned char) (c)])
290 extern unsigned char OSX_filename_classes
[];
291 # endif /* __CYGWIN32__ || WOE32 */
293 /* The following need to be declared for all case insensitive filesystems.
294 * When not FOLD_FN_CHAR is not #defined, a default definition for these
295 * functions is provided later in this header file. */
297 /* Like strcmp, but with the appropriate tweaks for file names. */
298 extern int fncmp (const char *n1
, const char *n2
);
300 /* Fold characters in FILENAME to their canonical forms. */
301 extern void fnfold (char *FILENAME
);
303 #endif /* FILENAMES_CASE_INSENSITIVE */
307 /* Some file systems are case-insensitive. If FOLD_FN_CHAR is
308 #defined, it maps the character C onto its "canonical" form. In a
309 case-insensitive system, it would map all alphanumeric characters
310 to lower case. Under Windows NT, / and \ are both path component
311 separators, so FOLD_FN_CHAR would map them both to /. */
313 # define FOLD_FN_CHAR(c) (c)
314 # define fnfold(filename) (filename)
315 # define fncmp strcmp
318 /* Different file systems can have different naming patterns which designate
319 * a path as absolute.
322 # define ISABSOLUTE(s) ISSLASH(s[FILE_SYSTEM_PREFIX_LEN(s)])
326 /* On some systems, we have to be careful about writing/reading files
327 in text or binary mode (so in text mode the system can handle CRLF
328 vs. LF, VMS text file conventions, &c). We decide to just always
329 be careful. That way we don't have to worry about whether text and
330 binary differ on this system. We just have to worry about whether
331 the system has O_BINARY and "rb". The latter is easy; all ANSI C
332 libraries have it, SunOS4 has it, and CVS has used it unguarded
333 some places for a while now without complaints (e.g. "rb" in
334 server.c (server_updated), since CVS 1.8). The former is just an
337 #define FOPEN_BINARY_READ ("rb")
338 #define FOPEN_BINARY_WRITE ("wb")
339 #define FOPEN_BINARY_READWRITE ("r+b")
342 #define OPEN_BINARY (O_BINARY)
344 #define OPEN_BINARY (0)
348 # define fd_select select