source: branches/libc-0.6/src/emx/include/dirent.h

Last change on this file was 3809, checked in by bird, 11 years ago

0.6: s/const/const/g - just use the (now) standard 'const' everywhere in emx and kLIBC code. Avoid changing external code too much. fixes #279.

  • Property cvs2svn:cvs-rev set to 1.4
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.2 KB
Line 
1/* dirent.h,v 1.4 2004/09/14 22:27:32 bird Exp */
2/** @file
3 * FreeBSD 5.1
4 * @changes bird: Merged in EMX stuff and internal LIBC stuff.
5 */
6
7/*-
8 * Copyright (c) 1989, 1993
9 * The Regents of the University of California. All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)dirent.h 8.2 (Berkeley) 7/28/94
40 * $FreeBSD: src/include/dirent.h,v 1.13 2002/09/10 18:12:16 mike Exp $
41 */
42
43#ifndef _DIRENT_H_
44#define _DIRENT_H_
45
46/*
47 * The kernel defines the format of directory entries returned by
48 * the getdirentries(2) system call.
49 */
50#include <sys/cdefs.h>
51#include <sys/dirent.h>
52
53#if __BSD_VISIBLE || __XSI_VISIBLE
54/*
55 * XXX this is probably illegal in the __XSI_VISIBLE case, but brings us closer
56 * to the specification.
57 */
58#define d_ino d_fileno /* backward and XSI compatibility */
59#endif
60
61#if __BSD_VISIBLE
62
63/* definitions for library routines operating on directories. */
64#define DIRBLKSIZ 1024
65
66struct _telldir; /* see telldir.h */
67
68/* bird: EMX internal structure. */
69struct _dircontents
70{
71 struct _dircontents * _d_next;
72 char * _d_entry;
73 __off_t _d_size;
74 unsigned short _d_time;
75 unsigned short _d_date;
76 unsigned short _d_attr;
77 unsigned char _d_type;
78};
79
80/* structure describing an open directory. */
81typedef struct _dirdesc {
82#if 0
83 int dd_fd; /* file descriptor associated with directory */
84 long dd_loc; /* offset in current buffer */
85 long dd_size; /* amount of data returned by getdirentries */
86 char *dd_buf; /* data buffer */
87 int dd_len; /* size of data buffer */
88 long dd_seek; /* magic cookie returned by getdirentries */
89 long dd_rewind; /* magic cookie for rewinding */
90 int dd_flags; /* flags for readdir */
91 void *dd_lock; /* hack to avoid including <pthread.h> */
92 struct _telldir *dd_td; /* telldir position recording */
93#else
94 int dd_id;
95 long dd_loc;
96 struct _dircontents * dd_contents;
97 struct _dircontents * dd_cp;
98 struct dirent dd_dirent;
99#endif
100} DIR;
101
102#if 0 /* bird: we do it differently. */
103#define dirfd(dirp) ((dirp)->dd_fd)
104#else /* bird */
105#define dirfd(dirp) (-2) /* bird */
106#endif /* bird */
107
108/* flags for opendir2 */
109#define DTF_HIDEW 0x0001 /* hide whiteout entries */
110#define DTF_NODUP 0x0002 /* don't return duplicate names */
111#define DTF_REWIND 0x0004 /* rewind after reading union stack */
112#define __DTF_READALL 0x0008 /* everything has been read */
113
114#ifndef NULL
115#define NULL 0
116#endif
117
118#else /* !__BSD_VISIBLE */
119
120typedef void * DIR;
121
122#endif /* __BSD_VISIBLE */
123
124#ifndef _KERNEL
125
126__BEGIN_DECLS
127#if __BSD_VISIBLE
128/** @todo DIR *__opendir2(const char *, int); */
129/** @todo int alphasort(const void *, const void *); */
130int getdents(int, char *, int);
131int getdirentries(int, char *, int, long *);
132#endif
133DIR *opendir(const char *);
134struct dirent *
135 readdir(DIR *);
136#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500
137int readdir_r(DIR *, struct dirent *, struct dirent **);
138#endif
139void rewinddir(DIR *);
140#if __BSD_VISIBLE
141int scandir(const char *, struct dirent ***,
142 int (*)(struct dirent *), int (*)(const void *, const void *));
143#endif
144#if __XSI_VISIBLE
145void seekdir(DIR *, long);
146long telldir(DIR *);
147#endif
148int closedir(DIR *);
149
150
151/* bird: EMX extra - start */
152DIR *_opendir (const char *);
153struct dirent *_readdir (DIR *);
154void _seekdir (DIR *, long);
155long _telldir (DIR *);
156int _closedir (DIR *);
157void _rewinddir (DIR *);
158/* bird: EMX extra - end */
159
160__END_DECLS
161
162#endif /* !_KERNEL */
163
164#endif /* !_DIRENT_H_ */
Note: See TracBrowser for help on using the repository browser.