]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/cvs/diff/system.h
This commit was generated by cvs2svn to compensate for changes in r100928,
[FreeBSD/FreeBSD.git] / contrib / cvs / diff / system.h
1 /* System dependent declarations.
2    Copyright (C) 1988, 1989, 1992, 1993, 1994 Free Software Foundation, Inc.
3
4 This file is part of GNU DIFF.
5
6 GNU DIFF is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU DIFF is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 */
17
18 /* We must define `volatile' and `const' first (the latter inside config.h),
19    so that they're used consistently in all system includes.  */
20 #if !__STDC__
21 #ifndef volatile
22 #define volatile
23 #endif
24 #endif
25 #include <config.h>
26
27 #include <sys/types.h>
28 #include <sys/stat.h>
29
30 /* Note that PARAMS is just internal to the diff library; diffrun.h
31    has its own mechanism, which will hopefully be less likely to
32    conflict with the library's caller's namespace.  */
33 #if __STDC__
34 #define PARAMS(args) args
35 #define VOID void
36 #else
37 #define PARAMS(args) ()
38 #define VOID char
39 #endif
40
41 #if STAT_MACROS_BROKEN
42 #undef S_ISBLK
43 #undef S_ISCHR
44 #undef S_ISDIR
45 #undef S_ISFIFO
46 #undef S_ISREG
47 #undef S_ISSOCK
48 #endif
49 #ifndef S_ISDIR
50 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
51 #endif
52 #ifndef S_ISREG
53 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
54 #endif
55 #if !defined(S_ISBLK) && defined(S_IFBLK)
56 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
57 #endif
58 #if !defined(S_ISCHR) && defined(S_IFCHR)
59 #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
60 #endif
61 #if !defined(S_ISFIFO) && defined(S_IFFIFO)
62 #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
63 #endif
64 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
65 #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
66 #endif
67
68 #if HAVE_UNISTD_H
69 #include <unistd.h>
70 #endif
71
72 #ifndef SEEK_SET
73 #define SEEK_SET 0
74 #endif
75 #ifndef SEEK_CUR
76 #define SEEK_CUR 1
77 #endif
78
79 #ifndef STDIN_FILENO
80 #define STDIN_FILENO 0
81 #endif
82 #ifndef STDOUT_FILENO
83 #define STDOUT_FILENO 1
84 #endif
85 #ifndef STDERR_FILENO
86 #define STDERR_FILENO 2
87 #endif
88
89 /* I believe that all relevant systems have
90    time.h.  It is in ANSI, for example.  The
91    code below looks quite bogus as I don't think
92    sys/time.h is ever a substitute for time.h;
93    it is something different.  */
94 #define HAVE_TIME_H 1
95
96 #if HAVE_TIME_H
97 #include <time.h>
98 #else
99 #include <sys/time.h>
100 #endif
101
102 #if HAVE_FCNTL_H
103 #include <fcntl.h>
104 #else
105 #if HAVE_SYS_FILE_H
106 #include <sys/file.h>
107 #endif
108 #endif
109
110 #ifndef O_RDONLY
111 #define O_RDONLY 0
112 #endif
113
114 #if HAVE_SYS_WAIT_H
115 #include <sys/wait.h>
116 #endif
117 #ifndef WEXITSTATUS
118 #define WEXITSTATUS(stat_val) ((unsigned) (stat_val) >> 8)
119 #endif
120 #ifndef WIFEXITED
121 #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
122 #endif
123
124 #ifndef STAT_BLOCKSIZE
125 #if HAVE_ST_BLKSIZE
126 #define STAT_BLOCKSIZE(s) (s).st_blksize
127 #else
128 #define STAT_BLOCKSIZE(s) (8 * 1024)
129 #endif
130 #endif
131
132 #if HAVE_DIRENT_H
133 # include <dirent.h>
134 # define NAMLEN(dirent) strlen((dirent)->d_name)
135 #else
136 # define dirent direct
137 # define NAMLEN(dirent) ((dirent)->d_namlen)
138 # if HAVE_SYS_NDIR_H
139 #  include <sys/ndir.h>
140 # endif
141 # if HAVE_SYS_DIR_H
142 #  include <sys/dir.h>
143 # endif
144 # if HAVE_NDIR_H
145 #  include <ndir.h>
146 # endif
147 #endif
148
149 #if HAVE_VFORK_H
150 #include <vfork.h>
151 #endif
152
153 #if HAVE_STDLIB_H || defined(STDC_HEADERS)
154 #include <stdlib.h>
155 #else
156 VOID *malloc ();
157 VOID *realloc ();
158 #endif
159 #ifndef getenv
160 char *getenv ();
161 #endif
162
163 #if HAVE_LIMITS_H
164 #include <limits.h>
165 #endif
166 #ifndef INT_MAX
167 #define INT_MAX 2147483647
168 #endif
169 #ifndef CHAR_BIT
170 #define CHAR_BIT 8
171 #endif
172
173 #if STDC_HEADERS || HAVE_STRING_H
174 # include <string.h>
175 # ifndef bzero
176 #  define bzero(s, n) memset (s, 0, n)
177 # endif
178 #else
179 # if !HAVE_STRCHR
180 #  define strchr index
181 #  define strrchr rindex
182 # endif
183 char *strchr (), *strrchr ();
184 # if !HAVE_MEMCHR
185 #  define memcmp(s1, s2, n) bcmp (s1, s2, n)
186 #  define memcpy(d, s, n) bcopy (s, d, n)
187 void *memchr ();
188 # endif
189 #endif
190
191 #include <ctype.h>
192 /* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given
193    as an argument to <ctype.h> macros like `isspace'.  */
194 #if STDC_HEADERS
195 #define CTYPE_DOMAIN(c) 1
196 #else
197 #define CTYPE_DOMAIN(c) ((unsigned) (c) <= 0177)
198 #endif
199 #ifndef ISPRINT
200 #define ISPRINT(c) (CTYPE_DOMAIN (c) && isprint (c))
201 #endif
202 #ifndef ISSPACE
203 #define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c))
204 #endif
205 #ifndef ISUPPER
206 #define ISUPPER(c) (CTYPE_DOMAIN (c) && isupper (c))
207 #endif
208
209 #ifndef ISDIGIT
210 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
211 #endif
212
213 #include <errno.h>
214 #if !STDC_HEADERS
215 extern int errno;
216 #endif
217
218 #ifdef min
219 #undef min
220 #endif
221 #ifdef max
222 #undef max
223 #endif
224 #define min(a,b) ((a) <= (b) ? (a) : (b))
225 #define max(a,b) ((a) >= (b) ? (a) : (b))
226 \f
227 /* This section contains Posix-compliant defaults for macros
228    that are meant to be overridden by hand in config.h as needed.  */
229
230 #ifndef filename_cmp
231 #define filename_cmp(a, b) strcmp (a, b)
232 #endif
233
234 #ifndef filename_lastdirchar
235 #define filename_lastdirchar(filename) strrchr (filename, '/')
236 #endif
237
238 #ifndef HAVE_FORK
239 #define HAVE_FORK 1
240 #endif
241
242 #ifndef HAVE_SETMODE
243 #define HAVE_SETMODE 0
244 #endif
245
246 #ifndef initialize_main
247 #define initialize_main(argcp, argvp)
248 #endif
249
250 /* Do struct stat *S, *T describe the same file?  Answer -1 if unknown.  */
251 #ifndef same_file
252 #define same_file(s,t) ((s)->st_ino==(t)->st_ino && (s)->st_dev==(t)->st_dev)
253 #endif
254
255 /* Place into Q a quoted version of A suitable for `popen' or `system',
256    incrementing Q and junking A.
257    Do not increment Q by more than 4 * strlen (A) + 2.  */
258 #ifndef SYSTEM_QUOTE_ARG
259 #define SYSTEM_QUOTE_ARG(q, a) \
260   { \
261     *(q)++ = '\''; \
262     for (;  *(a);  *(q)++ = *(a)++) \
263       if (*(a) == '\'') \
264         { \
265           *(q)++ = '\''; \
266           *(q)++ = '\\'; \
267           *(q)++ = '\''; \
268         } \
269     *(q)++ = '\''; \
270   }
271 #endif
272
273 /* these come from CVS's lib/system.h, but I wasn't sure how to include that
274  * properly or even if I really should
275  */
276 #ifndef CVS_OPENDIR
277 #define CVS_OPENDIR opendir
278 #endif
279 #ifndef CVS_READDIR
280 #define CVS_READDIR readdir
281 #endif
282 #ifndef CVS_CLOSEDIR
283 #define CVS_CLOSEDIR closedir
284 #endif