~ubuntu-branches/ubuntu/vivid/gzip/vivid

« back to all changes in this revision

Viewing changes to lib/dirent.in.h

  • Committer: Steve Langasek
  • Date: 2012-06-29 02:07:40 UTC
  • mfrom: (4.1.9 sid)
  • Revision ID: steve.langasek@canonical.com-20120629020740-qqikrblzana08v2y
Merge version 1.5-1.1 from Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* A GNU-like <dirent.h>.
2
 
   Copyright (C) 2006-2010 Free Software Foundation, Inc.
 
2
   Copyright (C) 2006-2012 Free Software Foundation, Inc.
3
3
 
4
4
   This program is free software: you can redistribute it and/or modify
5
5
   it under the terms of the GNU General Public License as published by
14
14
   You should have received a copy of the GNU General Public License
15
15
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
16
16
 
17
 
#ifndef _GL_DIRENT_H
 
17
#ifndef _@GUARD_PREFIX@_DIRENT_H
18
18
 
19
19
#if __GNUC__ >= 3
20
20
@PRAGMA_SYSTEM_HEADER@
21
21
#endif
 
22
@PRAGMA_COLUMNS@
22
23
 
23
24
/* The include_next requires a split double-inclusion guard.  */
24
 
#@INCLUDE_NEXT@ @NEXT_DIRENT_H@
 
25
#if @HAVE_DIRENT_H@
 
26
# @INCLUDE_NEXT@ @NEXT_DIRENT_H@
 
27
#endif
25
28
 
26
 
#ifndef _GL_DIRENT_H
27
 
#define _GL_DIRENT_H
 
29
#ifndef _@GUARD_PREFIX@_DIRENT_H
 
30
#define _@GUARD_PREFIX@_DIRENT_H
28
31
 
29
32
/* Get ino_t.  Needed on some systems, including glibc 2.8.  */
30
33
#include <sys/types.h>
31
34
 
32
 
/* The definition of GL_LINK_WARNING is copied here.  */
 
35
#if !@HAVE_DIRENT_H@
 
36
/* Define types DIR and 'struct dirent'.  */
 
37
# if !GNULIB_defined_struct_dirent
 
38
struct dirent
 
39
{
 
40
  char d_type;
 
41
  char d_name[1];
 
42
};
 
43
/* Possible values for 'd_type'.  */
 
44
#  define DT_UNKNOWN 0
 
45
#  define DT_FIFO    1          /* FIFO */
 
46
#  define DT_CHR     2          /* character device */
 
47
#  define DT_DIR     4          /* directory */
 
48
#  define DT_BLK     6          /* block device */
 
49
#  define DT_REG     8          /* regular file */
 
50
#  define DT_LNK    10          /* symbolic link */
 
51
#  define DT_SOCK   12          /* socket */
 
52
#  define DT_WHT    14          /* whiteout */
 
53
typedef struct gl_directory DIR;
 
54
#  define GNULIB_defined_struct_dirent 1
 
55
# endif
 
56
#endif
 
57
 
 
58
/* The __attribute__ feature is available in gcc versions 2.5 and later.
 
59
   The attribute __pure__ was added in gcc 2.96.  */
 
60
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
 
61
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
 
62
#else
 
63
# define _GL_ATTRIBUTE_PURE /* empty */
 
64
#endif
 
65
 
 
66
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
33
67
 
34
68
/* The definition of _GL_ARG_NONNULL is copied here.  */
35
69
 
 
70
/* The definition of _GL_WARN_ON_USE is copied here.  */
36
71
 
37
 
#ifdef __cplusplus
38
 
extern "C" {
39
 
#endif
40
72
 
41
73
/* Declare overridden functions.  */
42
74
 
43
 
#if @REPLACE_CLOSEDIR@
44
 
# define closedir rpl_closedir
45
 
extern int closedir (DIR *) _GL_ARG_NONNULL ((1));
 
75
#if @GNULIB_OPENDIR@
 
76
# if @REPLACE_OPENDIR@
 
77
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
78
#   undef opendir
 
79
#   define opendir rpl_opendir
 
80
#  endif
 
81
_GL_FUNCDECL_RPL (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
 
82
_GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
 
83
# else
 
84
#  if !@HAVE_OPENDIR@
 
85
_GL_FUNCDECL_SYS (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
 
86
#  endif
 
87
_GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name));
 
88
# endif
 
89
_GL_CXXALIASWARN (opendir);
 
90
#elif defined GNULIB_POSIXCHECK
 
91
# undef opendir
 
92
# if HAVE_RAW_DECL_OPENDIR
 
93
_GL_WARN_ON_USE (opendir, "opendir is not portable - "
 
94
                 "use gnulib module opendir for portability");
 
95
# endif
 
96
#endif
 
97
 
 
98
#if @GNULIB_READDIR@
 
99
# if !@HAVE_READDIR@
 
100
_GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1)));
 
101
# endif
 
102
_GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp));
 
103
_GL_CXXALIASWARN (readdir);
 
104
#elif defined GNULIB_POSIXCHECK
 
105
# undef readdir
 
106
# if HAVE_RAW_DECL_READDIR
 
107
_GL_WARN_ON_USE (readdir, "readdir is not portable - "
 
108
                 "use gnulib module readdir for portability");
 
109
# endif
 
110
#endif
 
111
 
 
112
#if @GNULIB_REWINDDIR@
 
113
# if !@HAVE_REWINDDIR@
 
114
_GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1)));
 
115
# endif
 
116
_GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp));
 
117
_GL_CXXALIASWARN (rewinddir);
 
118
#elif defined GNULIB_POSIXCHECK
 
119
# undef rewinddir
 
120
# if HAVE_RAW_DECL_REWINDDIR
 
121
_GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
 
122
                 "use gnulib module rewinddir for portability");
 
123
# endif
 
124
#endif
 
125
 
 
126
#if @GNULIB_CLOSEDIR@
 
127
# if @REPLACE_CLOSEDIR@
 
128
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
129
#   undef closedir
 
130
#   define closedir rpl_closedir
 
131
#  endif
 
132
_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
 
133
_GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
 
134
# else
 
135
#  if !@HAVE_CLOSEDIR@
 
136
_GL_FUNCDECL_SYS (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
 
137
#  endif
 
138
_GL_CXXALIAS_SYS (closedir, int, (DIR *dirp));
 
139
# endif
 
140
_GL_CXXALIASWARN (closedir);
 
141
#elif defined GNULIB_POSIXCHECK
 
142
# undef closedir
 
143
# if HAVE_RAW_DECL_CLOSEDIR
 
144
_GL_WARN_ON_USE (closedir, "closedir is not portable - "
 
145
                 "use gnulib module closedir for portability");
 
146
# endif
46
147
#endif
47
148
 
48
149
#if @GNULIB_DIRFD@
49
 
# if !@HAVE_DECL_DIRFD@ && !defined dirfd
50
150
/* Return the file descriptor associated with the given directory stream,
51
151
   or -1 if none exists.  */
52
 
extern int dirfd (DIR *dir) _GL_ARG_NONNULL ((1));
 
152
# if @REPLACE_DIRFD@
 
153
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
154
#   undef dirfd
 
155
#   define dirfd rpl_dirfd
 
156
#  endif
 
157
_GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
 
158
_GL_CXXALIAS_RPL (dirfd, int, (DIR *));
 
159
# else
 
160
#  if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
 
161
    /* dirfd is defined as a macro and not as a function.
 
162
       Turn it into a function and get rid of the macro.  */
 
163
static inline int (dirfd) (DIR *dp) { return dirfd (dp); }
 
164
#   undef dirfd
 
165
#  endif
 
166
#  if !(@HAVE_DECL_DIRFD@ || defined dirfd)
 
167
_GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
 
168
#  endif
 
169
_GL_CXXALIAS_SYS (dirfd, int, (DIR *));
53
170
# endif
 
171
_GL_CXXALIASWARN (dirfd);
54
172
#elif defined GNULIB_POSIXCHECK
55
173
# undef dirfd
56
 
# define dirfd(d) \
57
 
    (GL_LINK_WARNING ("dirfd is unportable - " \
58
 
                      "use gnulib module dirfd for portability"), \
59
 
     dirfd (d))
 
174
# if HAVE_RAW_DECL_DIRFD
 
175
_GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
 
176
                 "use gnulib module dirfd for portability");
 
177
# endif
60
178
#endif
61
179
 
62
180
#if @GNULIB_FDOPENDIR@
63
 
# if @REPLACE_FDOPENDIR@
64
 
#  undef fdopendir
65
 
#  define fdopendir rpl_fdopendir
66
 
# endif
67
 
# if !@HAVE_FDOPENDIR@ || @REPLACE_FDOPENDIR@
68
181
/* Open a directory stream visiting the given directory file
69
182
   descriptor.  Return NULL and set errno if fd is not visiting a
70
183
   directory.  On success, this function consumes fd (it will be
71
184
   implicitly closed either by this function or by a subsequent
72
185
   closedir).  */
73
 
extern DIR *fdopendir (int fd);
 
186
# if @REPLACE_FDOPENDIR@
 
187
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
188
#   undef fdopendir
 
189
#   define fdopendir rpl_fdopendir
 
190
#  endif
 
191
_GL_FUNCDECL_RPL (fdopendir, DIR *, (int fd));
 
192
_GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
 
193
# else
 
194
#  if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@
 
195
_GL_FUNCDECL_SYS (fdopendir, DIR *, (int fd));
 
196
#  endif
 
197
_GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
74
198
# endif
 
199
_GL_CXXALIASWARN (fdopendir);
75
200
#elif defined GNULIB_POSIXCHECK
76
201
# undef fdopendir
77
 
# define fdopendir(f) \
78
 
    (GL_LINK_WARNING ("fdopendir is unportable - " \
79
 
                      "use gnulib module fdopendir for portability"), \
80
 
     fdopendir (f))
81
 
#endif
82
 
 
83
 
#if @REPLACE_OPENDIR@
84
 
# define opendir rpl_opendir
85
 
extern DIR * opendir (const char *) _GL_ARG_NONNULL ((1));
 
202
# if HAVE_RAW_DECL_FDOPENDIR
 
203
_GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
 
204
                 "use gnulib module fdopendir for portability");
 
205
# endif
86
206
#endif
87
207
 
88
208
#if @GNULIB_SCANDIR@
91
211
   sorted using qsort with CMP, and collected in a malloc'd array in
92
212
   *NAMELIST.  Returns the number of entries selected, or -1 on error.  */
93
213
# if !@HAVE_SCANDIR@
94
 
extern int scandir (const char *dir, struct dirent ***namelist,
95
 
                    int (*filter) (const struct dirent *),
96
 
                    int (*cmp) (const struct dirent **, const struct dirent **))
97
 
     _GL_ARG_NONNULL ((1, 2, 4));
 
214
_GL_FUNCDECL_SYS (scandir, int,
 
215
                  (const char *dir, struct dirent ***namelist,
 
216
                   int (*filter) (const struct dirent *),
 
217
                   int (*cmp) (const struct dirent **, const struct dirent **))
 
218
                  _GL_ARG_NONNULL ((1, 2, 4)));
98
219
# endif
 
220
/* Need to cast, because on glibc systems, the fourth parameter is
 
221
                        int (*cmp) (const void *, const void *).  */
 
222
_GL_CXXALIAS_SYS_CAST (scandir, int,
 
223
                       (const char *dir, struct dirent ***namelist,
 
224
                        int (*filter) (const struct dirent *),
 
225
                        int (*cmp) (const struct dirent **, const struct dirent **)));
 
226
_GL_CXXALIASWARN (scandir);
99
227
#elif defined GNULIB_POSIXCHECK
100
228
# undef scandir
101
 
# define scandir(d,n,f,c) \
102
 
    (GL_LINK_WARNING ("scandir is unportable - " \
103
 
                      "use gnulib module scandir for portability"), \
104
 
     scandir (d, n, f, c))
 
229
# if HAVE_RAW_DECL_SCANDIR
 
230
_GL_WARN_ON_USE (scandir, "scandir is unportable - "
 
231
                 "use gnulib module scandir for portability");
 
232
# endif
105
233
#endif
106
234
 
107
235
#if @GNULIB_ALPHASORT@
108
236
/* Compare two 'struct dirent' entries alphabetically.  */
109
237
# if !@HAVE_ALPHASORT@
110
 
extern int alphasort (const struct dirent **, const struct dirent **)
111
 
     _GL_ARG_NONNULL ((1, 2));
 
238
_GL_FUNCDECL_SYS (alphasort, int,
 
239
                  (const struct dirent **, const struct dirent **)
 
240
                  _GL_ATTRIBUTE_PURE
 
241
                  _GL_ARG_NONNULL ((1, 2)));
112
242
# endif
 
243
/* Need to cast, because on glibc systems, the parameters are
 
244
                       (const void *, const void *).  */
 
245
_GL_CXXALIAS_SYS_CAST (alphasort, int,
 
246
                       (const struct dirent **, const struct dirent **));
 
247
_GL_CXXALIASWARN (alphasort);
113
248
#elif defined GNULIB_POSIXCHECK
114
249
# undef alphasort
115
 
# define alphasort(a,b) \
116
 
    (GL_LINK_WARNING ("alphasort is unportable - " \
117
 
                      "use gnulib module alphasort for portability"), \
118
 
     alphasort (a, b))
119
 
#endif
120
 
 
121
 
#ifdef __cplusplus
122
 
}
123
 
#endif
124
 
 
125
 
 
126
 
#endif /* _GL_DIRENT_H */
127
 
#endif /* _GL_DIRENT_H */
 
250
# if HAVE_RAW_DECL_ALPHASORT
 
251
_GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
 
252
                 "use gnulib module alphasort for portability");
 
253
# endif
 
254
#endif
 
255
 
 
256
 
 
257
#endif /* _@GUARD_PREFIX@_DIRENT_H */
 
258
#endif /* _@GUARD_PREFIX@_DIRENT_H */