]> git.cworth.org Git - tar/blob - gnu/dirent.in.h
ddb78d8385898f040f0fe2aa226b520868b98ba4
[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-2010 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 _GL_DIRENT_H
20
21 #if __GNUC__ >= 3
22 @PRAGMA_SYSTEM_HEADER@
23 #endif
24
25 /* The include_next requires a split double-inclusion guard.  */
26 #@INCLUDE_NEXT@ @NEXT_DIRENT_H@
27
28 #ifndef _GL_DIRENT_H
29 #define _GL_DIRENT_H
30
31 /* Get ino_t.  Needed on some systems, including glibc 2.8.  */
32 #include <sys/types.h>
33
34 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
35
36 /* The definition of _GL_ARG_NONNULL is copied here.  */
37
38 /* The definition of _GL_WARN_ON_USE is copied here.  */
39
40
41 /* Declare overridden functions.  */
42
43 #if @REPLACE_CLOSEDIR@
44 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
45 #  define closedir rpl_closedir
46 # endif
47 _GL_FUNCDECL_RPL (closedir, int, (DIR *) _GL_ARG_NONNULL ((1)));
48 _GL_CXXALIAS_RPL (closedir, int, (DIR *));
49 #else
50 _GL_CXXALIAS_SYS (closedir, int, (DIR *));
51 #endif
52 _GL_CXXALIASWARN (closedir);
53
54 #if @GNULIB_DIRFD@
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));
59 # endif
60 #elif defined GNULIB_POSIXCHECK
61 # undef dirfd
62 # if HAVE_RAW_DECL_DIRFD
63 _GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
64                  "use gnulib module dirfd for portability");
65 # endif
66 #endif
67
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
73    closedir).  */
74 # if @REPLACE_FDOPENDIR@
75 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
76 #   undef fdopendir
77 #   define fdopendir rpl_fdopendir
78 #  endif
79 _GL_FUNCDECL_RPL (fdopendir, DIR *, (int fd));
80 _GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
81 # else
82 #  if !@HAVE_FDOPENDIR@
83 _GL_FUNCDECL_SYS (fdopendir, DIR *, (int fd));
84 #  endif
85 _GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
86 # endif
87 _GL_CXXALIASWARN (fdopendir);
88 #elif defined GNULIB_POSIXCHECK
89 # undef fdopendir
90 # if HAVE_RAW_DECL_FDOPENDIR
91 _GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
92                  "use gnulib module fdopendir for portability");
93 # endif
94 #endif
95
96 #if @REPLACE_OPENDIR@
97 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
98 #  define opendir rpl_opendir
99 # endif
100 _GL_FUNCDECL_RPL (opendir, DIR *, (const char *) _GL_ARG_NONNULL ((1)));
101 _GL_CXXALIAS_RPL (opendir, DIR *, (const char *));
102 #else
103 _GL_CXXALIAS_SYS (opendir, DIR *, (const char *));
104 #endif
105 _GL_CXXALIASWARN (opendir);
106
107 #if @GNULIB_SCANDIR@
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.  */
112 # if !@HAVE_SCANDIR@
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)));
118 # endif
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
127 # undef scandir
128 # if HAVE_RAW_DECL_SCANDIR
129 _GL_WARN_ON_USE (scandir, "scandir is unportable - "
130                  "use gnulib module scandir for portability");
131 # endif
132 #endif
133
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)));
140 # endif
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
147 # undef alphasort
148 # if HAVE_RAW_DECL_ALPHASORT
149 _GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
150                  "use gnulib module alphasort for portability");
151 # endif
152 #endif
153
154
155 #endif /* _GL_DIRENT_H */
156 #endif /* _GL_DIRENT_H */