1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* A GNU-like <dirent.h>.
4 Copyright (C) 2006-2011 Free Software Foundation, Inc.
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.
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.
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/>. */
22 @PRAGMA_SYSTEM_HEADER@
26 /* The include_next requires a split double-inclusion guard. */
27 #@INCLUDE_NEXT@ @NEXT_DIRENT_H@
32 /* Get ino_t. Needed on some systems, including glibc 2.8. */
33 #include <sys/types.h>
35 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
37 /* The definition of _GL_ARG_NONNULL is copied here. */
39 /* The definition of _GL_WARN_ON_USE is copied here. */
42 /* Declare overridden functions. */
44 #if @REPLACE_CLOSEDIR@
45 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
46 # define closedir rpl_closedir
48 _GL_FUNCDECL_RPL (closedir, int, (DIR *) _GL_ARG_NONNULL ((1)));
49 _GL_CXXALIAS_RPL (closedir, int, (DIR *));
51 _GL_CXXALIAS_SYS (closedir, int, (DIR *));
53 _GL_CXXALIASWARN (closedir);
56 /* Return the file descriptor associated with the given directory stream,
57 or -1 if none exists. */
59 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
61 # define dirfd rpl_dirfd
63 _GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
64 _GL_CXXALIAS_RPL (dirfd, int, (DIR *));
66 # if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
67 /* dirfd is defined as a macro and not as a function.
68 Turn it into a function and get rid of the macro. */
69 static inline int (dirfd) (DIR *dp) { return dirfd (dp); }
72 # if !(@HAVE_DECL_DIRFD@ || defined dirfd)
73 _GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
75 _GL_CXXALIAS_SYS (dirfd, int, (DIR *));
77 _GL_CXXALIASWARN (dirfd);
78 #elif defined GNULIB_POSIXCHECK
80 # if HAVE_RAW_DECL_DIRFD
81 _GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
82 "use gnulib module dirfd for portability");
86 #if @GNULIB_FDOPENDIR@
87 /* Open a directory stream visiting the given directory file
88 descriptor. Return NULL and set errno if fd is not visiting a
89 directory. On success, this function consumes fd (it will be
90 implicitly closed either by this function or by a subsequent
92 # if @REPLACE_FDOPENDIR@
93 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
95 # define fdopendir rpl_fdopendir
97 _GL_FUNCDECL_RPL (fdopendir, DIR *, (int fd));
98 _GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
100 # if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@
101 _GL_FUNCDECL_SYS (fdopendir, DIR *, (int fd));
103 _GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
105 _GL_CXXALIASWARN (fdopendir);
106 #elif defined GNULIB_POSIXCHECK
108 # if HAVE_RAW_DECL_FDOPENDIR
109 _GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
110 "use gnulib module fdopendir for portability");
114 #if @REPLACE_OPENDIR@
115 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
116 # define opendir rpl_opendir
118 _GL_FUNCDECL_RPL (opendir, DIR *, (const char *) _GL_ARG_NONNULL ((1)));
119 _GL_CXXALIAS_RPL (opendir, DIR *, (const char *));
121 _GL_CXXALIAS_SYS (opendir, DIR *, (const char *));
123 _GL_CXXALIASWARN (opendir);
126 /* Scan the directory DIR, calling FILTER on each directory entry.
127 Entries for which FILTER returns nonzero are individually malloc'd,
128 sorted using qsort with CMP, and collected in a malloc'd array in
129 *NAMELIST. Returns the number of entries selected, or -1 on error. */
131 _GL_FUNCDECL_SYS (scandir, int,
132 (const char *dir, struct dirent ***namelist,
133 int (*filter) (const struct dirent *),
134 int (*cmp) (const struct dirent **, const struct dirent **))
135 _GL_ARG_NONNULL ((1, 2, 4)));
137 /* Need to cast, because on glibc systems, the fourth parameter is
138 int (*cmp) (const void *, const void *). */
139 _GL_CXXALIAS_SYS_CAST (scandir, int,
140 (const char *dir, struct dirent ***namelist,
141 int (*filter) (const struct dirent *),
142 int (*cmp) (const struct dirent **, const struct dirent **)));
143 _GL_CXXALIASWARN (scandir);
144 #elif defined GNULIB_POSIXCHECK
146 # if HAVE_RAW_DECL_SCANDIR
147 _GL_WARN_ON_USE (scandir, "scandir is unportable - "
148 "use gnulib module scandir for portability");
152 #if @GNULIB_ALPHASORT@
153 /* Compare two 'struct dirent' entries alphabetically. */
154 # if !@HAVE_ALPHASORT@
155 _GL_FUNCDECL_SYS (alphasort, int,
156 (const struct dirent **, const struct dirent **)
157 _GL_ARG_NONNULL ((1, 2)));
159 /* Need to cast, because on glibc systems, the parameters are
160 (const void *, const void *). */
161 _GL_CXXALIAS_SYS_CAST (alphasort, int,
162 (const struct dirent **, const struct dirent **));
163 _GL_CXXALIASWARN (alphasort);
164 #elif defined GNULIB_POSIXCHECK
166 # if HAVE_RAW_DECL_ALPHASORT
167 _GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
168 "use gnulib module alphasort for portability");
173 #endif /* _GL_DIRENT_H */
174 #endif /* _GL_DIRENT_H */