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