1 /* Test of <sys/stat.h> substitute.
2 Copyright (C) 2007-2012 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 3 of the License, or
7 (at your option) any later version.
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.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */
25 /* Check the existence of some macros. */
29 #ifdef S_IFBLK /* missing on MSVC */
32 S_IFCHR
, S_IFDIR
, S_IFIFO
, S_IFREG
,
33 #ifdef S_IFLNK /* missing on native Windows and DJGPP */
36 #ifdef S_IFSOCK /* missing on native Windows and DJGPP */
39 S_IRWXU
, S_IRUSR
, S_IWUSR
, S_IXUSR
,
40 S_IRWXG
, S_IRGRP
, S_IWGRP
, S_IXGRP
,
41 S_IRWXO
, S_IROTH
, S_IWOTH
, S_IXOTH
,
42 S_ISUID
, S_ISGID
, S_ISVTX
,
63 verify (S_IRWXU
== (S_IRUSR
| S_IWUSR
| S_IXUSR
));
64 verify (S_IRWXG
== (S_IRGRP
| S_IWGRP
| S_IXGRP
));
65 verify (S_IRWXO
== (S_IROTH
| S_IWOTH
| S_IXOTH
));
68 verify (S_ISBLK (S_IFBLK
));
70 verify (!S_ISBLK (S_IFCHR
));
71 verify (!S_ISBLK (S_IFDIR
));
72 verify (!S_ISBLK (S_IFIFO
));
73 verify (!S_ISBLK (S_IFREG
));
75 verify (!S_ISBLK (S_IFLNK
));
78 verify (!S_ISBLK (S_IFSOCK
));
82 verify (!S_ISCHR (S_IFBLK
));
84 verify (S_ISCHR (S_IFCHR
));
85 verify (!S_ISCHR (S_IFDIR
));
86 verify (!S_ISCHR (S_IFIFO
));
87 verify (!S_ISCHR (S_IFREG
));
89 verify (!S_ISCHR (S_IFLNK
));
92 verify (!S_ISCHR (S_IFSOCK
));
96 verify (!S_ISDIR (S_IFBLK
));
98 verify (!S_ISDIR (S_IFCHR
));
99 verify (S_ISDIR (S_IFDIR
));
100 verify (!S_ISDIR (S_IFIFO
));
101 verify (!S_ISDIR (S_IFREG
));
103 verify (!S_ISDIR (S_IFLNK
));
106 verify (!S_ISDIR (S_IFSOCK
));
110 verify (!S_ISFIFO (S_IFBLK
));
112 verify (!S_ISFIFO (S_IFCHR
));
113 verify (!S_ISFIFO (S_IFDIR
));
114 verify (S_ISFIFO (S_IFIFO
));
115 verify (!S_ISFIFO (S_IFREG
));
117 verify (!S_ISFIFO (S_IFLNK
));
120 verify (!S_ISFIFO (S_IFSOCK
));
124 verify (!S_ISREG (S_IFBLK
));
126 verify (!S_ISREG (S_IFCHR
));
127 verify (!S_ISREG (S_IFDIR
));
128 verify (!S_ISREG (S_IFIFO
));
129 verify (S_ISREG (S_IFREG
));
131 verify (!S_ISREG (S_IFLNK
));
134 verify (!S_ISREG (S_IFSOCK
));
138 verify (!S_ISLNK (S_IFBLK
));
140 verify (!S_ISLNK (S_IFCHR
));
141 verify (!S_ISLNK (S_IFDIR
));
142 verify (!S_ISLNK (S_IFIFO
));
143 verify (!S_ISLNK (S_IFREG
));
145 verify (S_ISLNK (S_IFLNK
));
148 verify (!S_ISLNK (S_IFSOCK
));
152 verify (!S_ISSOCK (S_IFBLK
));
154 verify (!S_ISSOCK (S_IFCHR
));
155 verify (!S_ISSOCK (S_IFDIR
));
156 verify (!S_ISSOCK (S_IFIFO
));
157 verify (!S_ISSOCK (S_IFREG
));
159 verify (!S_ISSOCK (S_IFLNK
));
162 verify (S_ISSOCK (S_IFSOCK
));
166 verify (!S_ISDOOR (S_IFBLK
));
168 verify (!S_ISDOOR (S_IFCHR
));
169 verify (!S_ISDOOR (S_IFDIR
));
170 verify (!S_ISDOOR (S_IFIFO
));
171 verify (!S_ISDOOR (S_IFREG
));
173 verify (!S_ISDOOR (S_IFLNK
));
176 verify (!S_ISDOOR (S_IFSOCK
));
180 verify (!S_ISMPB (S_IFBLK
));
182 verify (!S_ISMPB (S_IFCHR
));
183 verify (!S_ISMPB (S_IFDIR
));
184 verify (!S_ISMPB (S_IFIFO
));
185 verify (!S_ISMPB (S_IFREG
));
187 verify (!S_ISMPB (S_IFLNK
));
190 verify (!S_ISMPB (S_IFSOCK
));
194 verify (!S_ISNAM (S_IFBLK
));
196 verify (!S_ISNAM (S_IFCHR
));
197 verify (!S_ISNAM (S_IFDIR
));
198 verify (!S_ISNAM (S_IFIFO
));
199 verify (!S_ISNAM (S_IFREG
));
201 verify (!S_ISNAM (S_IFLNK
));
204 verify (!S_ISNAM (S_IFSOCK
));
208 verify (!S_ISNWK (S_IFBLK
));
210 verify (!S_ISNWK (S_IFCHR
));
211 verify (!S_ISNWK (S_IFDIR
));
212 verify (!S_ISNWK (S_IFIFO
));
213 verify (!S_ISNWK (S_IFREG
));
215 verify (!S_ISNWK (S_IFLNK
));
218 verify (!S_ISNWK (S_IFSOCK
));
222 verify (!S_ISPORT (S_IFBLK
));
224 verify (!S_ISPORT (S_IFCHR
));
225 verify (!S_ISPORT (S_IFDIR
));
226 verify (!S_ISPORT (S_IFIFO
));
227 verify (!S_ISPORT (S_IFREG
));
229 verify (!S_ISPORT (S_IFLNK
));
232 verify (!S_ISPORT (S_IFSOCK
));
236 verify (!S_ISCTG (S_IFBLK
));
238 verify (!S_ISCTG (S_IFCHR
));
239 verify (!S_ISCTG (S_IFDIR
));
240 verify (!S_ISCTG (S_IFIFO
));
241 verify (!S_ISCTG (S_IFREG
));
243 verify (!S_ISCTG (S_IFLNK
));
246 verify (!S_ISCTG (S_IFSOCK
));
250 verify (!S_ISOFD (S_IFBLK
));
252 verify (!S_ISOFD (S_IFCHR
));
253 verify (!S_ISOFD (S_IFDIR
));
254 verify (!S_ISOFD (S_IFIFO
));
255 verify (!S_ISOFD (S_IFREG
));
257 verify (!S_ISOFD (S_IFLNK
));
260 verify (!S_ISOFD (S_IFSOCK
));
264 verify (!S_ISOFL (S_IFBLK
));
266 verify (!S_ISOFL (S_IFCHR
));
267 verify (!S_ISOFL (S_IFDIR
));
268 verify (!S_ISOFL (S_IFIFO
));
269 verify (!S_ISOFL (S_IFREG
));
271 verify (!S_ISOFL (S_IFLNK
));
274 verify (!S_ISOFL (S_IFSOCK
));
278 verify (!S_ISWHT (S_IFBLK
));
280 verify (!S_ISWHT (S_IFCHR
));
281 verify (!S_ISWHT (S_IFDIR
));
282 verify (!S_ISWHT (S_IFIFO
));
283 verify (!S_ISWHT (S_IFREG
));
285 verify (!S_ISWHT (S_IFLNK
));
288 verify (!S_ISWHT (S_IFSOCK
));
291 /* POSIX 2008 requires traditional encoding of permission constants. */
292 verify (S_IRWXU
== 00700);
293 verify (S_IRUSR
== 00400);
294 verify (S_IWUSR
== 00200);
295 verify (S_IXUSR
== 00100);
296 verify (S_IRWXG
== 00070);
297 verify (S_IRGRP
== 00040);
298 verify (S_IWGRP
== 00020);
299 verify (S_IXGRP
== 00010);
300 verify (S_IRWXO
== 00007);
301 verify (S_IROTH
== 00004);
302 verify (S_IWOTH
== 00002);
303 verify (S_IXOTH
== 00001);
304 verify (S_ISUID
== 04000);
305 verify (S_ISGID
== 02000);
306 verify (S_ISVTX
== 01000);
308 #if ((0 <= UTIME_NOW && UTIME_NOW < 1000000000) \
309 || (0 <= UTIME_OMIT && UTIME_OMIT < 1000000000) \
310 || UTIME_NOW == UTIME_OMIT)
314 /* Check the existence of some types. */