1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* A GNU-like <dirent.h>.
4 Copyright (C) 2006-2010 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@
25 /* The include_next requires a split double-inclusion guard. */
26 #@INCLUDE_NEXT@ @NEXT_DIRENT_H@
31 /* Get ino_t. Needed on some systems, including glibc 2.8. */
32 #include <sys/types.h>
34 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
36 /* The definition of _GL_ARG_NONNULL is copied here. */
38 /* The definition of _GL_WARN_ON_USE is copied here. */
41 /* Declare overridden functions. */
43 #if @REPLACE_CLOSEDIR@
44 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
45 # define closedir rpl_closedir
47 _GL_FUNCDECL_RPL (closedir, int, (DIR *) _GL_ARG_NONNULL ((1)));
48 _GL_CXXALIAS_RPL (closedir, int, (DIR *));
50 _GL_CXXALIAS_SYS (closedir, int, (DIR *));
52 _GL_CXXALIASWARN (closedir);
55 # if !@HAVE_DECL_DIRFD@ && !defined dirfd
56 /* Return the file descriptor associated with the given directory stream,
57 or -1 if none exists. */
58 _GL_EXTERN_C int dirfd (DIR *dir) _GL_ARG_NONNULL ((1));
60 #elif defined GNULIB_POSIXCHECK
62 # if HAVE_RAW_DECL_DIRFD
63 _GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
64 "use gnulib module dirfd for portability");
68 #if @GNULIB_FDOPENDIR@
69 /* Open a directory stream visiting the given directory file
70 descriptor. Return NULL and set errno if fd is not visiting a
71 directory. On success, this function consumes fd (it will be
72 implicitly closed either by this function or by a subsequent
74 # if @REPLACE_FDOPENDIR@
75 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
77 # define fdopendir rpl_fdopendir
79 _GL_FUNCDECL_RPL (fdopendir, DIR *, (int fd));
80 _GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
82 # if !@HAVE_FDOPENDIR@
83 _GL_FUNCDECL_SYS (fdopendir, DIR *, (int fd));
85 _GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
87 _GL_CXXALIASWARN (fdopendir);
88 #elif defined GNULIB_POSIXCHECK
90 # if HAVE_RAW_DECL_FDOPENDIR
91 _GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
92 "use gnulib module fdopendir for portability");
97 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
98 # define opendir rpl_opendir
100 _GL_FUNCDECL_RPL (opendir, DIR *, (const char *) _GL_ARG_NONNULL ((1)));
101 _GL_CXXALIAS_RPL (opendir, DIR *, (const char *));
103 _GL_CXXALIAS_SYS (opendir, DIR *, (const char *));
105 _GL_CXXALIASWARN (opendir);
108 /* Scan the directory DIR, calling FILTER on each directory entry.
109 Entries for which FILTER returns nonzero are individually malloc'd,
110 sorted using qsort with CMP, and collected in a malloc'd array in
111 *NAMELIST. Returns the number of entries selected, or -1 on error. */
113 _GL_FUNCDECL_SYS (scandir, int,
114 (const char *dir, struct dirent ***namelist,
115 int (*filter) (const struct dirent *),
116 int (*cmp) (const struct dirent **, const struct dirent **))
117 _GL_ARG_NONNULL ((1, 2, 4)));
119 /* Need to cast, because on glibc systems, the fourth parameter is
120 int (*cmp) (const void *, const void *). */
121 _GL_CXXALIAS_SYS_CAST (scandir, int,
122 (const char *dir, struct dirent ***namelist,
123 int (*filter) (const struct dirent *),
124 int (*cmp) (const struct dirent **, const struct dirent **)));
125 _GL_CXXALIASWARN (scandir);
126 #elif defined GNULIB_POSIXCHECK
128 # if HAVE_RAW_DECL_SCANDIR
129 _GL_WARN_ON_USE (scandir, "scandir is unportable - "
130 "use gnulib module scandir for portability");
134 #if @GNULIB_ALPHASORT@
135 /* Compare two 'struct dirent' entries alphabetically. */
136 # if !@HAVE_ALPHASORT@
137 _GL_FUNCDECL_SYS (alphasort, int,
138 (const struct dirent **, const struct dirent **)
139 _GL_ARG_NONNULL ((1, 2)));
141 /* Need to cast, because on glibc systems, the parameters are
142 (const void *, const void *). */
143 _GL_CXXALIAS_SYS_CAST (alphasort, int,
144 (const struct dirent **, const struct dirent **));
145 _GL_CXXALIASWARN (alphasort);
146 #elif defined GNULIB_POSIXCHECK
148 # if HAVE_RAW_DECL_ALPHASORT
149 _GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
150 "use gnulib module alphasort for portability");
155 #endif /* _GL_DIRENT_H */
156 #endif /* _GL_DIRENT_H */