]> git.cworth.org Git - tar/blob - lib/sys_stat.in.h
Imported Upstream version 1.21
[tar] / lib / sys_stat.in.h
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Provide a more complete sys/stat header file.
4    Copyright (C) 2005-2008 Free Software Foundation, Inc.
5
6    This program 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 3, or (at your option)
9    any later version.
10
11    This program 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    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software Foundation,
18    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19
20 /* Written by Eric Blake, Paul Eggert, and Jim Meyering.  */
21
22 /* This file is supposed to be used on platforms where <sys/stat.h> is
23    incomplete.  It is intended to provide definitions and prototypes
24    needed by an application.  Start with what the system provides.  */
25
26 #if __GNUC__ >= 3
27 @PRAGMA_SYSTEM_HEADER@
28 #endif
29
30 #if defined __need_system_sys_stat_h
31 /* Special invocation convention.  */
32
33 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
34
35 #else
36 /* Normal invocation convention.  */
37
38 #ifndef _GL_SYS_STAT_H
39
40 /* The include_next requires a split double-inclusion guard.  */
41 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
42
43 #ifndef _GL_SYS_STAT_H
44 #define _GL_SYS_STAT_H
45
46 /* The definition of GL_LINK_WARNING is copied here.  */
47
48 /* Before doing "#define mkdir rpl_mkdir" below, we need to include all
49    headers that may declare mkdir().  */
50 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
51 # include <io.h>
52 #endif
53
54 #ifndef S_IFMT
55 # define S_IFMT 0170000
56 #endif
57
58 #if STAT_MACROS_BROKEN
59 # undef S_ISBLK
60 # undef S_ISCHR
61 # undef S_ISDIR
62 # undef S_ISFIFO
63 # undef S_ISLNK
64 # undef S_ISNAM
65 # undef S_ISMPB
66 # undef S_ISMPC
67 # undef S_ISNWK
68 # undef S_ISREG
69 # undef S_ISSOCK
70 #endif
71
72 #ifndef S_ISBLK
73 # ifdef S_IFBLK
74 #  define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
75 # else
76 #  define S_ISBLK(m) 0
77 # endif
78 #endif
79
80 #ifndef S_ISCHR
81 # ifdef S_IFCHR
82 #  define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
83 # else
84 #  define S_ISCHR(m) 0
85 # endif
86 #endif
87
88 #ifndef S_ISDIR
89 # ifdef S_IFDIR
90 #  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
91 # else
92 #  define S_ISDIR(m) 0
93 # endif
94 #endif
95
96 #ifndef S_ISDOOR /* Solaris 2.5 and up */
97 # define S_ISDOOR(m) 0
98 #endif
99
100 #ifndef S_ISFIFO
101 # ifdef S_IFIFO
102 #  define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
103 # else
104 #  define S_ISFIFO(m) 0
105 # endif
106 #endif
107
108 #ifndef S_ISLNK
109 # ifdef S_IFLNK
110 #  define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
111 # else
112 #  define S_ISLNK(m) 0
113 # endif
114 #endif
115
116 #ifndef S_ISMPB /* V7 */
117 # ifdef S_IFMPB
118 #  define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
119 #  define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
120 # else
121 #  define S_ISMPB(m) 0
122 #  define S_ISMPC(m) 0
123 # endif
124 #endif
125
126 #ifndef S_ISNAM /* Xenix */
127 # ifdef S_IFNAM
128 #  define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
129 # else
130 #  define S_ISNAM(m) 0
131 # endif
132 #endif
133
134 #ifndef S_ISNWK /* HP/UX */
135 # ifdef S_IFNWK
136 #  define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
137 # else
138 #  define S_ISNWK(m) 0
139 # endif
140 #endif
141
142 #ifndef S_ISPORT /* Solaris 10 and up */
143 # define S_ISPORT(m) 0
144 #endif
145
146 #ifndef S_ISREG
147 # ifdef S_IFREG
148 #  define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
149 # else
150 #  define S_ISREG(m) 0
151 # endif
152 #endif
153
154 #ifndef S_ISSOCK
155 # ifdef S_IFSOCK
156 #  define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
157 # else
158 #  define S_ISSOCK(m) 0
159 # endif
160 #endif
161
162
163 #ifndef S_TYPEISMQ
164 # define S_TYPEISMQ(p) 0
165 #endif
166
167 #ifndef S_TYPEISTMO
168 # define S_TYPEISTMO(p) 0
169 #endif
170
171
172 #ifndef S_TYPEISSEM
173 # ifdef S_INSEM
174 #  define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
175 # else
176 #  define S_TYPEISSEM(p) 0
177 # endif
178 #endif
179
180 #ifndef S_TYPEISSHM
181 # ifdef S_INSHD
182 #  define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
183 # else
184 #  define S_TYPEISSHM(p) 0
185 # endif
186 #endif
187
188 /* high performance ("contiguous data") */
189 #ifndef S_ISCTG
190 # define S_ISCTG(p) 0
191 #endif
192
193 /* Cray DMF (data migration facility): off line, with data  */
194 #ifndef S_ISOFD
195 # define S_ISOFD(p) 0
196 #endif
197
198 /* Cray DMF (data migration facility): off line, with no data  */
199 #ifndef S_ISOFL
200 # define S_ISOFL(p) 0
201 #endif
202
203 /* 4.4BSD whiteout */
204 #ifndef S_ISWHT
205 # define S_ISWHT(m) 0
206 #endif
207
208 /* If any of the following are undefined,
209    define them to their de facto standard values.  */
210 #if !S_ISUID
211 # define S_ISUID 04000
212 #endif
213 #if !S_ISGID
214 # define S_ISGID 02000
215 #endif
216
217 /* S_ISVTX is a common extension to POSIX.  */
218 #ifndef S_ISVTX
219 # define S_ISVTX 01000
220 #endif
221
222 #if !S_IRUSR && S_IREAD
223 # define S_IRUSR S_IREAD
224 #endif
225 #if !S_IRUSR
226 # define S_IRUSR 00400
227 #endif
228 #if !S_IRGRP
229 # define S_IRGRP (S_IRUSR >> 3)
230 #endif
231 #if !S_IROTH
232 # define S_IROTH (S_IRUSR >> 6)
233 #endif
234
235 #if !S_IWUSR && S_IWRITE
236 # define S_IWUSR S_IWRITE
237 #endif
238 #if !S_IWUSR
239 # define S_IWUSR 00200
240 #endif
241 #if !S_IWGRP
242 # define S_IWGRP (S_IWUSR >> 3)
243 #endif
244 #if !S_IWOTH
245 # define S_IWOTH (S_IWUSR >> 6)
246 #endif
247
248 #if !S_IXUSR && S_IEXEC
249 # define S_IXUSR S_IEXEC
250 #endif
251 #if !S_IXUSR
252 # define S_IXUSR 00100
253 #endif
254 #if !S_IXGRP
255 # define S_IXGRP (S_IXUSR >> 3)
256 #endif
257 #if !S_IXOTH
258 # define S_IXOTH (S_IXUSR >> 6)
259 #endif
260
261 #if !S_IRWXU
262 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
263 #endif
264 #if !S_IRWXG
265 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
266 #endif
267 #if !S_IRWXO
268 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
269 #endif
270
271 /* S_IXUGO is a common extension to POSIX.  */
272 #if !S_IXUGO
273 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
274 #endif
275
276 #ifndef S_IRWXUGO
277 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
278 #endif
279
280 #if @GNULIB_LSTAT@
281 # if ! @HAVE_LSTAT@
282 /* mingw does not support symlinks, therefore it does not have lstat.  But
283    without links, stat does just fine.  */
284 #  define lstat stat
285 # elif @REPLACE_LSTAT@
286 #  undef lstat
287 #  define lstat rpl_lstat
288 extern int rpl_lstat (const char *name, struct stat *buf);
289 # endif
290 #elif defined GNULIB_POSIXCHECK
291 # undef lstat
292 # define lstat(p,b)                                                     \
293   (GL_LINK_WARNING ("lstat is unportable - "                            \
294                     "use gnulib module lstat for portability"),         \
295    lstat (p, b))
296 #endif
297
298
299 #if @REPLACE_MKDIR@
300 # undef mkdir
301 # define mkdir rpl_mkdir
302 extern int mkdir (char const *name, mode_t mode);
303 #else
304 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
305    Additionally, it declares _mkdir (and depending on compile flags, an
306    alias mkdir), only in the nonstandard <io.h>, which is included above.  */
307 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
308
309 static inline int
310 rpl_mkdir (char const *name, mode_t mode)
311 {
312   return _mkdir (name);
313 }
314
315 #  define mkdir rpl_mkdir
316 # endif
317 #endif
318
319
320 /* Declare BSD extensions.  */
321
322 #if @GNULIB_LCHMOD@
323 /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
324    denotes a symbolic link.  */
325 # if !@HAVE_LCHMOD@
326 /* The lchmod replacement follows symbolic links.  Callers should take
327    this into account; lchmod should be applied only to arguments that
328    are known to not be symbolic links.  On hosts that lack lchmod,
329    this can lead to race conditions between the check and the
330    invocation of lchmod, but we know of no workarounds that are
331    reliable in general.  You might try requesting support for lchmod
332    from your operating system supplier.  */
333 #  define lchmod chmod
334 # endif
335 # if 0 /* assume already declared */
336 extern int lchmod (const char *filename, mode_t mode);
337 # endif
338 #elif defined GNULIB_POSIXCHECK
339 # undef lchmod
340 # define lchmod(f,m) \
341     (GL_LINK_WARNING ("lchmod is unportable - " \
342                       "use gnulib module lchmod for portability"), \
343      lchmod (f, m))
344 #endif
345
346 #endif /* _GL_SYS_STAT_H */
347 #endif /* _GL_SYS_STAT_H */
348 #endif