~ubuntu-branches/ubuntu/trusty/libprelude/trusty

« back to all changes in this revision

Viewing changes to libmissing/sys_stat.in.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-04-29 11:31:50 UTC
  • mfrom: (1.1.12 upstream) (2.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090429113150-qw9oxc1e50ldljck
Tags: 0.9.22-2ubuntu1
* Merge from debian unstable, remaining changes:
  - Build-Depend on libltdl7-dev.

Show diffs side-by-side

added added

removed removed

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