1 /* common definitions for `patch' */
3 /* $Id: common.h,v 1.18 1997/06/13 06:28:37 eggert Exp $ */
6 Copyright 1986, 1988 Larry Wall
7 Copyright 1990, 1991, 1992, 1993, 1997 Free Software Foundation, Inc.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 See the GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; see the file COPYING.
21 If not, write to the Free Software Foundation,
22 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /* We must define `volatile' and `const' first (the latter inside config.h),
30 so that they're used consistently in all system includes. */
37 /* Enable support for fseeko and ftello on hosts
38 where it is available but is turned off by default.
39 This must be defined before any system file is included. */
40 #define _LARGEFILE_SOURCE 1
46 #include <sys/types.h>
50 #if ! defined S_ISDIR && defined S_IFDIR
51 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
53 #if ! defined S_ISREG && defined S_IFREG
54 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
66 #define S_IXGRP (S_IXOTH << 3)
69 #define S_IWGRP (S_IWOTH << 3)
72 #define S_IRGRP (S_IROTH << 3)
75 #define S_IXUSR (S_IXOTH << 6)
78 #define S_IWUSR (S_IWOTH << 6)
81 #define S_IRUSR (S_IROTH << 6)
88 #define INT_MAX 2147483647
91 #define LONG_MIN (-1-2147483647L)
95 /* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given
96 as an argument to <ctype.h> macros like `isspace'. */
98 #define CTYPE_DOMAIN(c) 1
100 #define CTYPE_DOMAIN(c) ((unsigned) (c) <= 0177)
103 #define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c))
107 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
111 #ifndef FILESYSTEM_PREFIX_LEN
112 #define FILESYSTEM_PREFIX_LEN(f) 0
116 #define ISSLASH(c) ((c) == '/')
122 /* AIX predefines these. */
132 /* handy definitions */
134 #define strEQ(s1,s2) (!strcmp(s1, s2))
135 #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
139 typedef int bool; /* must promote to itself */
140 typedef long LINENUM; /* must be signed */
144 extern char const program_name[];
146 XTERN char *buf; /* general purpose buffer */
147 XTERN size_t bufsize; /* allocated size of buf */
149 XTERN bool using_plan_a; /* try to keep everything in memory */
155 XTERN struct stat instat;
157 XTERN bool posixly_correct;
159 XTERN char const *origprae;
160 XTERN char const *origbase;
162 XTERN char const * volatile TMPOUTNAME;
163 XTERN char const * volatile TMPINNAME;
164 XTERN char const * volatile TMPPATNAME;
173 XTERN bool noreverse;
175 XTERN enum { DEFAULT_VERBOSITY, SILENT, VERBOSE } verbosity;
176 XTERN bool skip_rest_of_patch;
178 XTERN bool canonicalize;
193 XTERN enum diff diff_type;
195 XTERN char *revision; /* prerequisite revision, if any */
198 # define GENERIC_OBJECT void
200 # define GENERIC_OBJECT char
203 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) || __STRICT_ANSI__
204 # define __attribute__(x)
209 # define PARAMS(args) args
211 # define PARAMS(args) ()
215 GENERIC_OBJECT *xmalloc PARAMS ((size_t));
216 void fatal_exit PARAMS ((int)) __attribute__ ((noreturn));
219 #if !STDC_HEADERS && !defined errno
223 #if STDC_HEADERS || HAVE_STRING_H
227 # define memcmp(s1, s2, n) bcmp (s1, s2, n)
228 # define memcpy(d, s, n) bcopy (s, d, n)
229 GENERIC_OBJECT *memchr ();
238 GENERIC_OBJECT *malloc ();
239 GENERIC_OBJECT *realloc ();
252 #define STDIN_FILENO 0
254 #ifndef STDOUT_FILENO
255 #define STDOUT_FILENO 1
257 #ifndef STDERR_FILENO
258 #define STDERR_FILENO 2
261 typedef off_t file_offset;
262 # define file_seek fseeko
263 # define file_tell ftello
265 typedef long file_offset;
266 # define file_seek fseek
267 # define file_tell ftell
286 #define O_BINARY _O_BINARY
296 XTERN int binary_transput; /* O_BINARY if binary i/o is desired */
298 # define binary_transput 0
302 #define NULL_DEVICE "/dev/null"
306 #define TTY_DEVICE "/dev/tty"