Print this page
opendir, dirfd are in XPG7
alphasort and scandir are new in XPG7
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/dirent.h
+++ new/usr/src/head/dirent.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 +/*
28 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
29 + */
30 +
27 31 /* Copyright (c) 1988 AT&T */
28 32 /* All Rights Reserved */
29 33
30 34 #ifndef _DIRENT_H
31 35 #define _DIRENT_H
32 36
33 -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6.1.5 */
34 -
35 37 #include <sys/feature_tests.h>
36 38
37 39 #include <sys/types.h>
38 40 #include <sys/dirent.h>
39 41
40 42 #ifdef __cplusplus
41 43 extern "C" {
42 44 #endif
43 45
44 46 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
45 47
46 48 #define MAXNAMLEN 512 /* maximum filename length */
47 49 #define DIRBUF 8192 /* buffer size for fs-indep. dirs */
48 50
49 51 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */
50 52
51 53 #if !defined(__XOPEN_OR_POSIX)
52 54
53 55 typedef struct {
54 56 int dd_fd; /* file descriptor */
55 57 int dd_loc; /* offset in block */
56 58 int dd_size; /* amount of valid data */
57 59 char *dd_buf; /* directory block */
58 60 } DIR; /* stream data from opendir() */
59 61
60 62
61 63 #else
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
62 64
63 65 typedef struct {
64 66 int d_fd; /* file descriptor */
65 67 int d_loc; /* offset in block */
66 68 int d_size; /* amount of valid data */
67 69 char *d_buf; /* directory block */
68 70 } DIR; /* stream data from opendir() */
69 71
70 72 #endif /* !defined(__XOPEN_OR_POSIX) */
71 73
72 -#if defined(__STDC__)
73 -
74 74 /* large file compilation environment setup */
75 75 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
76 76 #ifdef __PRAGMA_REDEFINE_EXTNAME
77 77 #pragma redefine_extname readdir readdir64
78 78 #pragma redefine_extname scandir scandir64
79 79 #pragma redefine_extname alphasort alphasort64
80 80 #else
81 81 #define readdir readdir64
82 82 #define scandir scandir64
83 83 #define alphasort alphasort64
84 84 #endif
85 85 #endif /* _FILE_OFFSET_BITS == 64 */
86 86
87 87 /* In the LP64 compilation environment, all APIs are already large file */
88 88 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
89 89 #ifdef __PRAGMA_REDEFINE_EXTNAME
90 90 #pragma redefine_extname readdir64 readdir
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
91 91 #pragma redefine_extname scandir64 scandir
92 92 #pragma redefine_extname alphasort64 alphasort
93 93 #else
94 94 #define readdir64 readdir
95 95 #define scandir64 scandir
96 96 #define alphsort64 alphasort
97 97 #endif
98 98 #endif /* _LP64 && _LARGEFILE64_SOURCE */
99 99
100 100 extern DIR *opendir(const char *);
101 -#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
101 +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG7) || \
102 102 defined(_ATFILE_SOURCE)
103 103 extern DIR *fdopendir(int);
104 104 extern int dirfd(DIR *);
105 105 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
106 -#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
107 -extern int scandir(const char *, struct dirent *(*[]),
106 +
107 +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG7)
108 +extern int scandir(const char *, struct dirent ***,
108 109 int (*)(const struct dirent *),
109 110 int (*)(const struct dirent **,
110 111 const struct dirent **));
111 112 extern int alphasort(const struct dirent **,
112 113 const struct dirent **);
113 -#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */
114 +#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
115 +
114 116 extern struct dirent *readdir(DIR *);
115 117 #if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || \
116 118 defined(_XOPEN_SOURCE)
117 119 extern long telldir(DIR *);
118 120 extern void seekdir(DIR *, long);
119 121 #endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) ... */
120 122 extern void rewinddir(DIR *);
121 123 extern int closedir(DIR *);
122 124
123 125 /* transitional large file interface */
124 126 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
125 127 !defined(__PRAGMA_REDEFINE_EXTNAME))
126 128 extern struct dirent64 *readdir64(DIR *);
127 129 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
128 -extern int scandir64(const char *, struct dirent64 *(*[]),
130 +extern int scandir64(const char *, struct dirent64 ***,
129 131 int (*)(const struct dirent64 *),
130 132 int (*)(const struct dirent64 **,
131 133 const struct dirent64 **));
132 134 extern int alphasort64(const struct dirent64 **, const struct dirent64 **);
133 135 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */
134 136 #endif
135 137
136 -#else
137 -
138 -extern DIR *opendir();
139 -#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
140 - defined(_ATFILE_SOURCE)
141 -extern DIR *fdopendir();
142 -extern int dirfd();
143 -#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
144 -extern struct dirent *readdir();
145 138 #if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || \
146 139 defined(_XOPEN_SOURCE)
147 -extern long telldir();
148 -extern void seekdir();
149 -#endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) ... */
150 -extern void rewinddir();
151 -extern int closedir();
152 -
153 -/* transitional large file interface */
154 -#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
155 - !defined(__PRAGMA_REDEFINE_EXTNAME))
156 -extern struct dirent64 *readdir64();
157 -#endif
158 -
159 -#endif
160 -
161 -#if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || \
162 - defined(_XOPEN_SOURCE)
163 140 #define rewinddir(dirp) seekdir(dirp, 0L)
164 141 #endif
165 142
166 143 /*
167 144 * readdir_r() prototype is defined here.
168 145 *
169 146 * There are several variations, depending on whether compatibility with old
170 147 * POSIX draft specifications or the final specification is desired and on
171 148 * whether the large file compilation environment is active. To combat a
172 149 * combinatorial explosion, enabling large files implies using the final
173 150 * specification (since the definition of the large file environment
174 151 * considerably postdates that of the final readdir_r specification).
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
175 152 *
176 153 * In the LP64 compilation environment, all APIs are already large file,
177 154 * and since there are no 64-bit applications that can have seen the
178 155 * draft implementation, again, we use the final POSIX specification.
179 156 */
180 157
181 158 #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
182 159 !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
183 160 defined(_POSIX_PTHREAD_SEMANTICS)
184 161
185 -#if defined(__STDC__)
186 -
187 162 #if !defined(_LP64) && _FILE_OFFSET_BITS == 32
188 163
189 164 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
190 165
191 166 #ifdef __PRAGMA_REDEFINE_EXTNAME
192 167 #pragma redefine_extname readdir_r __posix_readdir_r
193 168 extern int readdir_r(DIR *_RESTRICT_KYWD, struct dirent *_RESTRICT_KYWD,
194 169 struct dirent **_RESTRICT_KYWD);
195 170 #else /* __PRAGMA_REDEFINE_EXTNAME */
196 171
197 172 extern int __posix_readdir_r(DIR *_RESTRICT_KYWD,
198 173 struct dirent *_RESTRICT_KYWD, struct dirent **_RESTRICT_KYWD);
199 174
200 175 #ifdef __lint
201 176 #define readdir_r __posix_readdir_r
202 177 #else /* !__lint */
203 178
204 179 static int
205 180 readdir_r(DIR *_RESTRICT_KYWD __dp, struct dirent *_RESTRICT_KYWD __ent,
206 181 struct dirent **_RESTRICT_KYWD __res) {
207 182 return (__posix_readdir_r(__dp, __ent, __res));
208 183 }
209 184
210 185 #endif /* !__lint */
211 186 #endif /* __PRAGMA_REDEFINE_EXTNAME */
212 187
213 188 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
214 189
215 190 extern struct dirent *readdir_r(DIR *__dp, struct dirent *__ent);
216 191
217 192 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
218 193
219 194 #else /* !_LP64 && _FILE_OFFSET_BITS == 32 */
220 195
221 196 #if defined(_LP64)
222 197 #ifdef __PRAGMA_REDEFINE_EXTNAME
223 198 #pragma redefine_extname readdir64_r readdir_r
224 199 #else
225 200 #define readdir64_r readdir_r
226 201 #endif
227 202 #else /* _LP64 */
228 203 #ifdef __PRAGMA_REDEFINE_EXTNAME
229 204 #pragma redefine_extname readdir_r readdir64_r
230 205 #else
231 206 #define readdir_r readdir64_r
232 207 #endif
233 208 #endif /* _LP64 */
234 209 extern int readdir_r(DIR *_RESTRICT_KYWD, struct dirent *_RESTRICT_KYWD,
235 210 struct dirent **_RESTRICT_KYWD);
↓ open down ↓ |
39 lines elided |
↑ open up ↑ |
236 211
237 212 #endif /* !_LP64 && _FILE_OFFSET_BITS == 32 */
238 213
239 214 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
240 215 !defined(__PRAGMA_REDEFINE_EXTNAME))
241 216 /* transitional large file interface */
242 217 extern int readdir64_r(DIR *_RESTRICT_KYWD, struct dirent64 *_RESTRICT_KYWD,
243 218 struct dirent64 **_RESTRICT_KYWD);
244 219 #endif
245 220
246 -#else /* __STDC__ */
247 -
248 -#if !defined(_LP64) && _FILE_OFFSET_BITS == 32
249 -
250 -#if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
251 -
252 -#ifdef __PRAGMA_REDEFINE_EXTNAME
253 -#pragma redefine_extname readdir_r __posix_readdir_r
254 -extern int readdir_r();
255 -#else /* __PRAGMA_REDEFINE_EXTNAME */
256 -
257 -extern int __posix_readdir_r();
258 -
259 -#ifdef __lint
260 -#define readdir_r __posix_readdir_r
261 -#else /* !__lint */
262 -
263 -static int
264 -readdir_r(DIR *_RESTRICT_KYWD __dp, struct dirent *_RESTRICT_KYWD __ent,
265 - struct dirent **_RESTRICT_KYWD __res)
266 -{
267 - return (__posix_readdir_r(__dp, __ent, __res));
268 -}
269 -
270 -#endif /* !__lint */
271 -#endif /* __PRAGMA_REDEFINE_EXTNAME */
272 -
273 -#else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
274 -
275 -extern struct dirent *readdir_r();
276 -
277 -#endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
278 -
279 -#else /* !_LP64 && _FILE_OFFSET_BITS == 32 */
280 -
281 -#if defined(_LP64)
282 -#ifdef __PRAGMA_REDEFINE_EXTNAME
283 -#pragma redefine_extname readdir64_r readdir_r
284 -#else
285 -#define readdir64_r readdir
286 -#endif
287 -#else /* _LP64 */
288 -#ifdef __PRAGMA_REDEFINE_EXTNAME
289 -#pragma redefine_extname readdir_r readdir64_r
290 -#else
291 -#define readdir_r readdir64_r
292 -#endif
293 -#endif /* _LP64 */
294 -extern int readdir_r();
295 -
296 -#endif /* !_LP64 && _FILE_OFFSET_BITS == 32 */
297 -
298 -#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
299 - !defined(__PRAGMA_REDEFINE_EXTNAME))
300 -/* transitional large file interface */
301 -extern int readdir64_r();
302 -#endif
303 -
304 -#endif /* __STDC__ */
305 -
306 221 #endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */
307 222
308 223 #ifdef __cplusplus
309 224 }
310 225 #endif
311 226
312 227 #endif /* _DIRENT_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX