]> git.cworth.org Git - tar/blob - gnu/dirent.in.h
Imported Upstream version 1.24
[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 @PRAGMA_COLUMNS@
25
26 /* The include_next requires a split double-inclusion guard.  */
27 #@INCLUDE_NEXT@ @NEXT_DIRENT_H@
28
29 #ifndef _GL_DIRENT_H
30 #define _GL_DIRENT_H
31
32 /* Get ino_t.  Needed on some systems, including glibc 2.8.  */
33 #include <sys/types.h>
34
35 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
36
37 /* The definition of _GL_ARG_NONNULL is copied here.  */
38
39 /* The definition of _GL_WARN_ON_USE is copied here.  */
40
41
42 /* Declare overridden functions.  */
43
44 #if @REPLACE_CLOSEDIR@
45 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
46 #  define closedir rpl_closedir
47 # endif
48 _GL_FUNCDECL_RPL (closedir, int, (DIR *) _GL_ARG_NONNULL ((1)));
49 _GL_CXXALIAS_RPL (closedir, int, (DIR *));
50 #else
51 _GL_CXXALIAS_SYS (closedir, int, (DIR *));
52 #endif
53 _GL_CXXALIASWARN (closedir);
54
55 #if @GNULIB_DIRFD@
56 /* Return the file descriptor associated with the given directory stream,
57    or -1 if none exists.  */
58 # if @REPLACE_DIRFD@
59 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
60 #   undef dirfd
61 #   define dirfd rpl_dirfd
62 #  endif
63 _GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
64 _GL_CXXALIAS_RPL (dirfd, int, (DIR *));
65 # else
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); }
70 #   undef dirfd
71 #  endif
72 #  if !(@HAVE_DECL_DIRFD@ || defined dirfd)
73 _GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
74 #  endif
75 _GL_CXXALIAS_SYS (dirfd, int, (DIR *));
76 # endif
77 _GL_CXXALIASWARN (dirfd);
78 #elif defined GNULIB_POSIXCHECK
79 # undef dirfd
80 # if HAVE_RAW_DECL_DIRFD
81 _GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
82                  "use gnulib module dirfd for portability");
83 # endif
84 #endif
85
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
91    closedir).  */
92 # if @REPLACE_FDOPENDIR@
93 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
94 #   undef fdopendir
95 #   define fdopendir rpl_fdopendir
96 #  endif
97 _GL_FUNCDECL_RPL (fdopendir, DIR *, (int fd));
98 _GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
99 # else
100 #  if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@
101 _GL_FUNCDECL_SYS (fdopendir, DIR *, (int fd));
102 #  endif
103 _GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
104 # endif
105 _GL_CXXALIASWARN (fdopendir);
106 #elif defined GNULIB_POSIXCHECK
107 # undef fdopendir
108 # if HAVE_RAW_DECL_FDOPENDIR
109 _GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
110                  "use gnulib module fdopendir for portability");
111 # endif
112 #endif
113
114 #if @REPLACE_OPENDIR@
115 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
116 #  define opendir rpl_opendir
117 # endif
118 _GL_FUNCDECL_RPL (opendir, DIR *, (const char *) _GL_ARG_NONNULL ((1)));
119 _GL_CXXALIAS_RPL (opendir, DIR *, (const char *));
120 #else
121 _GL_CXXALIAS_SYS (opendir, DIR *, (const char *));
122 #endif
123 _GL_CXXALIASWARN (opendir);
124
125 #if @GNULIB_SCANDIR@
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.  */
130 # if !@HAVE_SCANDIR@
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)));
136 # endif
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
145 # undef scandir
146 # if HAVE_RAW_DECL_SCANDIR
147 _GL_WARN_ON_USE (scandir, "scandir is unportable - "
148                  "use gnulib module scandir for portability");
149 # endif
150 #endif
151
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)));
158 # endif
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
165 # undef alphasort
166 # if HAVE_RAW_DECL_ALPHASORT
167 _GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
168                  "use gnulib module alphasort for portability");
169 # endif
170 #endif
171
172
173 #endif /* _GL_DIRENT_H */
174 #endif /* _GL_DIRENT_H */