comparison src/sysfile.h @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
1 /*
2 Copyright (C) 1995 Free Software Foundation, Inc.
3
4 This file is part of XEmacs.
5
6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
10
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 /* Synched up with: Not really in FSF. */
22
23 #include <errno.h>
24 #include <sys/errno.h> /* <errno.h> does not always imply this */
25 /* Load sys/types.h if not already loaded.
26 In some systems loading it twice is suicidal. */
27 #ifndef makedev
28 #include <sys/types.h> /* some typedefs are used in sys/file.h */
29 #endif
30 #include <sys/file.h>
31 #include <sys/stat.h>
32 #include <sys/param.h>
33
34 #if NeXT
35 /* what is needed from here? Do others need it too? */
36 # include <sys/fcntl.h>
37 #endif /* NeXT */
38
39 #ifdef VMS
40 #ifndef __GNUC__
41 #include <file.h>
42 #endif
43 #include <rms.h>
44 #include <rmsdef.h>
45 #include <fab.h>
46 #include <nam.h>
47 #include <perror.h>
48 #include <stddef.h>
49 #endif
50
51 #ifdef WINDOWSNT
52 #define NOMINMAX
53 #include <windows.h>
54 #include <stdlib.h> /* for proper declaration of environ */
55 #include <fcntl.h>
56 #include "nt.h"
57 #define _P_NOWAIT 1 /* from process.h */
58 #endif
59
60 #ifdef MSDOS
61 #include <dos.h>
62 #include "msdos.h"
63 #endif /* MSDOS */
64
65 #ifndef O_RDONLY
66 #define O_RDONLY 0
67 #endif
68
69 #ifndef O_WRONLY
70 #define O_WRONLY 1
71 #endif
72
73 #ifndef O_RDWR
74 #define O_RDWR 2
75 #endif
76
77 /* if system does not have symbolic links, it does not have lstat.
78 In that case, use ordinary stat instead. */
79
80 #ifndef S_IFLNK
81 #define lstat stat
82 #endif
83
84 #if !S_IRUSR
85 # if S_IREAD
86 # define S_IRUSR S_IREAD
87 # else
88 # define S_IRUSR 00400
89 # endif
90 #endif
91
92 #if !S_IWUSR
93 # if S_IWRITE
94 # define S_IWUSR S_IWRITE
95 # else
96 # define S_IWUSR 00200
97 # endif
98 #endif
99
100 #if !S_IXUSR
101 # if S_IEXEC
102 # define S_IXUSR S_IEXEC
103 # else
104 # define S_IXUSR 00100
105 # endif
106 #endif
107
108 #ifdef STAT_MACROS_BROKEN
109 #undef S_ISBLK
110 #undef S_ISCHR
111 #undef S_ISDIR
112 #undef S_ISFIFO
113 #undef S_ISLNK
114 #undef S_ISMPB
115 #undef S_ISMPC
116 #undef S_ISNWK
117 #undef S_ISREG
118 #undef S_ISSOCK
119 #endif /* STAT_MACROS_BROKEN. */
120
121 #if !defined(S_ISBLK) && defined(S_IFBLK)
122 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
123 #endif
124 #if !defined(S_ISCHR) && defined(S_IFCHR)
125 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
126 #endif
127 #if !defined(S_ISDIR) && defined(S_IFDIR)
128 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
129 #endif
130 #if !defined(S_ISREG) && defined(S_IFREG)
131 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
132 #endif
133 #if !defined(S_ISFIFO) && defined(S_IFIFO)
134 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
135 #endif
136 #if !defined(S_ISLNK) && defined(S_IFLNK)
137 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
138 #endif
139 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
140 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
141 #endif
142 #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
143 #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
144 #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
145 #endif
146 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
147 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
148 #endif
149
150 #if !defined (USG) && !defined (VMS) && !defined (WINDOWSNT)
151 # define HAVE_FSYNC
152 #endif
153
154 #ifndef MAXPATHLEN
155 /* in 4.1, param.h fails to define this. */
156 #define MAXPATHLEN 1024
157 #endif /* not MAXPATHLEN */
158
159 #ifndef X_OK
160 # define X_OK 01
161 #endif
162
163 #ifndef FD_CLOEXEC
164 # define FD_CLOEXEC 1
165 #endif
166
167 /* encapsulations: file-information calls */
168
169 #ifdef ENCAPSULATE_ACCESS
170 extern int sys_access (CONST char *path, int mode);
171 #endif
172 #if defined (ENCAPSULATE_ACCESS) && !defined (DONT_ENCAPSULATE)
173 # undef access
174 # define access sys_access
175 #endif
176 #if !defined (ENCAPSULATE_ACCESS) && defined (DONT_ENCAPSULATE)
177 # define sys_access access
178 #endif
179
180 #ifdef ENCAPSULATE_LSTAT
181 extern int sys_lstat (CONST char *path, struct stat *buf);
182 #endif
183 #if defined (ENCAPSULATE_LSTAT) && !defined (DONT_ENCAPSULATE)
184 # undef lstat
185 # define lstat sys_lstat
186 #endif
187 #if !defined (ENCAPSULATE_LSTAT) && defined (DONT_ENCAPSULATE)
188 # define sys_lstat lstat
189 #endif
190
191 #ifdef ENCAPSULATE_READLINK
192 extern int sys_readlink (CONST char *path, char *buf, int bufsiz);
193 #endif
194 #if defined (ENCAPSULATE_READLINK) && !defined (DONT_ENCAPSULATE)
195 # undef readlink
196 # define readlink sys_readlink
197 #endif
198 #if !defined (ENCAPSULATE_READLINK) && defined (DONT_ENCAPSULATE)
199 # define sys_readlink readlink
200 #endif
201
202 #ifdef ENCAPSULATE_STAT
203 extern int sys_stat (CONST char *path, struct stat *buf);
204 #endif
205 #if defined (ENCAPSULATE_STAT) && !defined (DONT_ENCAPSULATE)
206 # undef stat
207 /* Need to use arguments to avoid messing with struct stat */
208 # define stat(path, buf) sys_stat (path, buf)
209 #endif
210 #if !defined (ENCAPSULATE_STAT) && defined (DONT_ENCAPSULATE)
211 # define sys_stat stat
212 #endif
213
214 /* encapsulations: file-manipulation calls */
215
216 #ifdef ENCAPSULATE_CHMOD
217 extern int sys_chmod (CONST char *path, int mode);
218 #endif
219 #if defined (ENCAPSULATE_CHMOD) && !defined (DONT_ENCAPSULATE)
220 # undef chmod
221 # define chmod sys_chmod
222 #endif
223 #if !defined (ENCAPSULATE_CHMOD) && defined (DONT_ENCAPSULATE)
224 # define sys_chmod chmod
225 #endif
226
227 #ifdef ENCAPSULATE_CREAT
228 extern int sys_creat (CONST char *path, int mode);
229 #endif
230 #if defined (ENCAPSULATE_CREAT) && !defined (DONT_ENCAPSULATE)
231 # undef creat
232 # define creat sys_creat
233 #endif
234 #if !defined (ENCAPSULATE_CREAT) && defined (DONT_ENCAPSULATE)
235 # define sys_creat creat
236 #endif
237
238 #ifdef ENCAPSULATE_LINK
239 extern int sys_link (CONST char *existing, CONST char *new);
240 #endif
241 #if defined (ENCAPSULATE_LINK) && !defined (DONT_ENCAPSULATE)
242 # undef link
243 # define link sys_link
244 #endif
245 #if !defined (ENCAPSULATE_LINK) && defined (DONT_ENCAPSULATE)
246 # define sys_link link
247 #endif
248
249 #ifdef ENCAPSULATE_RENAME
250 extern int sys_rename (CONST char *old, CONST char *new);
251 #endif
252 #if defined (ENCAPSULATE_RENAME) && !defined (DONT_ENCAPSULATE)
253 # undef rename
254 # define rename sys_rename
255 #endif
256 #if !defined (ENCAPSULATE_RENAME) && defined (DONT_ENCAPSULATE)
257 # define sys_rename rename
258 #endif
259
260 #ifdef ENCAPSULATE_SYMLINK
261 extern int sys_symlink (CONST char *name1, CONST char *name2);
262 #endif
263 #if defined (ENCAPSULATE_SYMLINK) && !defined (DONT_ENCAPSULATE)
264 # undef symlink
265 # define symlink sys_symlink
266 #endif
267 #if !defined (ENCAPSULATE_SYMLINK) && defined (DONT_ENCAPSULATE)
268 # define sys_symlink symlink
269 #endif
270
271 #ifdef ENCAPSULATE_UNLINK
272 extern int sys_unlink (CONST char *path);
273 #endif
274 #if defined (ENCAPSULATE_UNLINK) && !defined (DONT_ENCAPSULATE)
275 # undef unlink
276 # define unlink sys_unlink
277 #endif
278 #if !defined (ENCAPSULATE_UNLINK) && defined (DONT_ENCAPSULATE)
279 # define sys_unlink unlink
280 #endif