Added missing elf part.
[gnutls.git] / gl / dirent.in.h
blob808b3608565136d3afed9dc927decc1fa6bf8156
1 /* A GNU-like <dirent.h>.
2 Copyright (C) 2006-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 #ifndef _@GUARD_PREFIX@_DIRENT_H
19 #if __GNUC__ >= 3
20 @PRAGMA_SYSTEM_HEADER@
21 #endif
22 @PRAGMA_COLUMNS@
24 /* The include_next requires a split double-inclusion guard. */
25 #if @HAVE_DIRENT_H@
26 # @INCLUDE_NEXT@ @NEXT_DIRENT_H@
27 #endif
29 #ifndef _@GUARD_PREFIX@_DIRENT_H
30 #define _@GUARD_PREFIX@_DIRENT_H
32 /* Get ino_t. Needed on some systems, including glibc 2.8. */
33 #include <sys/types.h>
35 #if !@HAVE_DIRENT_H@
36 /* Define types DIR and 'struct dirent'. */
37 # if !GNULIB_defined_struct_dirent
38 struct dirent
40 char d_type;
41 char d_name[1];
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
58 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
60 /* The definition of _GL_ARG_NONNULL is copied here. */
62 /* The definition of _GL_WARN_ON_USE is copied here. */
65 /* Declare overridden functions. */
67 #if @GNULIB_OPENDIR@
68 # if @REPLACE_OPENDIR@
69 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
70 # undef opendir
71 # define opendir rpl_opendir
72 # endif
73 _GL_FUNCDECL_RPL (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
74 _GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
75 # else
76 # if !@HAVE_OPENDIR@
77 _GL_FUNCDECL_SYS (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
78 # endif
79 _GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name));
80 # endif
81 _GL_CXXALIASWARN (opendir);
82 #elif defined GNULIB_POSIXCHECK
83 # undef opendir
84 # if HAVE_RAW_DECL_OPENDIR
85 _GL_WARN_ON_USE (opendir, "opendir is not portable - "
86 "use gnulib module opendir for portability");
87 # endif
88 #endif
90 #if @GNULIB_READDIR@
91 # if !@HAVE_READDIR@
92 _GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1)));
93 # endif
94 _GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp));
95 _GL_CXXALIASWARN (readdir);
96 #elif defined GNULIB_POSIXCHECK
97 # undef readdir
98 # if HAVE_RAW_DECL_READDIR
99 _GL_WARN_ON_USE (readdir, "readdir is not portable - "
100 "use gnulib module readdir for portability");
101 # endif
102 #endif
104 #if @GNULIB_REWINDDIR@
105 # if !@HAVE_REWINDDIR@
106 _GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1)));
107 # endif
108 _GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp));
109 _GL_CXXALIASWARN (rewinddir);
110 #elif defined GNULIB_POSIXCHECK
111 # undef rewinddir
112 # if HAVE_RAW_DECL_REWINDDIR
113 _GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
114 "use gnulib module rewinddir for portability");
115 # endif
116 #endif
118 #if @GNULIB_CLOSEDIR@
119 # if @REPLACE_CLOSEDIR@
120 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
121 # undef closedir
122 # define closedir rpl_closedir
123 # endif
124 _GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
125 _GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
126 # else
127 # if !@HAVE_CLOSEDIR@
128 _GL_FUNCDECL_SYS (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
129 # endif
130 _GL_CXXALIAS_SYS (closedir, int, (DIR *dirp));
131 # endif
132 _GL_CXXALIASWARN (closedir);
133 #elif defined GNULIB_POSIXCHECK
134 # undef closedir
135 # if HAVE_RAW_DECL_CLOSEDIR
136 _GL_WARN_ON_USE (closedir, "closedir is not portable - "
137 "use gnulib module closedir for portability");
138 # endif
139 #endif
141 #if @GNULIB_DIRFD@
142 /* Return the file descriptor associated with the given directory stream,
143 or -1 if none exists. */
144 # if @REPLACE_DIRFD@
145 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
146 # undef dirfd
147 # define dirfd rpl_dirfd
148 # endif
149 _GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
150 _GL_CXXALIAS_RPL (dirfd, int, (DIR *));
151 # else
152 # if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
153 /* dirfd is defined as a macro and not as a function.
154 Turn it into a function and get rid of the macro. */
155 static inline int (dirfd) (DIR *dp) { return dirfd (dp); }
156 # undef dirfd
157 # endif
158 # if !(@HAVE_DECL_DIRFD@ || defined dirfd)
159 _GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
160 # endif
161 _GL_CXXALIAS_SYS (dirfd, int, (DIR *));
162 # endif
163 _GL_CXXALIASWARN (dirfd);
164 #elif defined GNULIB_POSIXCHECK
165 # undef dirfd
166 # if HAVE_RAW_DECL_DIRFD
167 _GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
168 "use gnulib module dirfd for portability");
169 # endif
170 #endif
172 #if @GNULIB_FDOPENDIR@
173 /* Open a directory stream visiting the given directory file
174 descriptor. Return NULL and set errno if fd is not visiting a
175 directory. On success, this function consumes fd (it will be
176 implicitly closed either by this function or by a subsequent
177 closedir). */
178 # if @REPLACE_FDOPENDIR@
179 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
180 # undef fdopendir
181 # define fdopendir rpl_fdopendir
182 # endif
183 _GL_FUNCDECL_RPL (fdopendir, DIR *, (int fd));
184 _GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
185 # else
186 # if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@
187 _GL_FUNCDECL_SYS (fdopendir, DIR *, (int fd));
188 # endif
189 _GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
190 # endif
191 _GL_CXXALIASWARN (fdopendir);
192 #elif defined GNULIB_POSIXCHECK
193 # undef fdopendir
194 # if HAVE_RAW_DECL_FDOPENDIR
195 _GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
196 "use gnulib module fdopendir for portability");
197 # endif
198 #endif
200 #if @GNULIB_SCANDIR@
201 /* Scan the directory DIR, calling FILTER on each directory entry.
202 Entries for which FILTER returns nonzero are individually malloc'd,
203 sorted using qsort with CMP, and collected in a malloc'd array in
204 *NAMELIST. Returns the number of entries selected, or -1 on error. */
205 # if !@HAVE_SCANDIR@
206 _GL_FUNCDECL_SYS (scandir, int,
207 (const char *dir, struct dirent ***namelist,
208 int (*filter) (const struct dirent *),
209 int (*cmp) (const struct dirent **, const struct dirent **))
210 _GL_ARG_NONNULL ((1, 2, 4)));
211 # endif
212 /* Need to cast, because on glibc systems, the fourth parameter is
213 int (*cmp) (const void *, const void *). */
214 _GL_CXXALIAS_SYS_CAST (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_CXXALIASWARN (scandir);
219 #elif defined GNULIB_POSIXCHECK
220 # undef scandir
221 # if HAVE_RAW_DECL_SCANDIR
222 _GL_WARN_ON_USE (scandir, "scandir is unportable - "
223 "use gnulib module scandir for portability");
224 # endif
225 #endif
227 #if @GNULIB_ALPHASORT@
228 /* Compare two 'struct dirent' entries alphabetically. */
229 # if !@HAVE_ALPHASORT@
230 _GL_FUNCDECL_SYS (alphasort, int,
231 (const struct dirent **, const struct dirent **)
232 _GL_ARG_NONNULL ((1, 2)));
233 # endif
234 /* Need to cast, because on glibc systems, the parameters are
235 (const void *, const void *). */
236 _GL_CXXALIAS_SYS_CAST (alphasort, int,
237 (const struct dirent **, const struct dirent **));
238 _GL_CXXALIASWARN (alphasort);
239 #elif defined GNULIB_POSIXCHECK
240 # undef alphasort
241 # if HAVE_RAW_DECL_ALPHASORT
242 _GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
243 "use gnulib module alphasort for portability");
244 # endif
245 #endif
248 #endif /* _@GUARD_PREFIX@_DIRENT_H */
249 #endif /* _@GUARD_PREFIX@_DIRENT_H */