ReactOS 0.4.16-dev-297-gc569aee
dirent.h
Go to the documentation of this file.
1/* @(#)dirent.h 1.29 11/08/04 Copyright 1987, 1998, 2000-2011 J. Schilling */
2/*
3 * Copyright (c) 1987, 1998, 2000-2011 J. Schilling
4 */
5/*
6 * The contents of this file are subject to the terms of the
7 * Common Development and Distribution License, Version 1.0 only
8 * (the "License"). You may not use this file except in compliance
9 * with the License.
10 *
11 * See the file CDDL.Schily.txt in this distribution for details.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file CDDL.Schily.txt from this distribution.
15 */
16
17#ifndef _SCHILY_DIRENT_H
18#define _SCHILY_DIRENT_H
19
20#ifndef _SCHILY_MCONFIG_H
21#include <schily/mconfig.h>
22#endif
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#ifdef JOS
29# ifdef HAVE_SYS_STYPES_H
30# ifndef _INCL_SYS_STYPES_H
31# include <sys/stypes.h>
32# define _INCL_SYS_STYPES_H
33# endif
34# endif
35# ifdef HAVE_SYS_FILEDESC_H
36# ifndef _INCL_SYS_FILEDESC_H
37# include <sys/filedesc.h>
38# define _INCL_SYS_FILEDESC_H
39# endif
40# endif
41# define NEED_READDIR
42# define dirent _direct
43# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
44# define DIRSIZE 30
45# define FOUND_DIRSIZE
46 typedef struct _dirent {
47 char name[DIRSIZE];
48 short ino;
49 } dirent;
50
51#else /* !JOS */
52
53# ifndef _SCHILY_TYPES_H
54# include <schily/types.h>
55# endif
56# ifndef _SCHILY_STAT_H
57# include <schily/stat.h>
58# endif
59# ifndef _SCHILY_LIMITS_H
60# include <schily/limits.h>
61# endif
62# ifndef _SCHILY_PARAM_H
63# include <schily/param.h>
64# endif
65# ifndef _SCHILY_STDLIB_H
66# include <schily/stdlib.h> /* MSVC: get _MAX_DIR */
67# endif
68
69# ifdef HAVE_DIRENT_H /* This a POSIX compliant system */
70# ifndef _INCL_DIRENT_H
71# include <dirent.h>
72# define _INCL_DIRENT_H
73# endif
74# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
75# define _FOUND_DIR_
76# else /* This is a Pre POSIX system */
77
78# define dirent direct
79# define DIR_NAMELEN(dirent) (dirent)->d_namlen
80
81# if defined(HAVE_SYS_DIR_H)
82# ifndef _INCL_SYS_DIR_H
83# include <sys/dir.h>
84# define _INCL_SYS_DIR_H
85# endif
86# define _FOUND_DIR_
87# endif
88
89# if defined(HAVE_NDIR_H) && !defined(_FOUND_DIR_)
90# ifndef _INCL_NDIR_H
91# include <ndir.h>
92# define _INCL_NDIR_H
93# endif
94# define _FOUND_DIR_
95# endif
96
97# if defined(HAVE_SYS_NDIR_H) && !defined(_FOUND_DIR_)
98# ifndef _INCL_SYS_NDIR_H
99# include <sys/ndir.h>
100# define _INCL_SYS_NDIR_H
101# endif
102# define _FOUND_DIR_
103# endif
104# endif /* HAVE_DIRENT_H */
105
106# if defined(_FOUND_DIR_)
107/*
108 * Don't use defaults here to allow recognition of problems.
109 */
110# if !defined(FOUND_DIRSIZE) && defined(MAXNAMELEN)
111# define DIRSIZE MAXNAMELEN /* From sys/param.h */
112# define FOUND_DIRSIZE
113# endif
114
115# if !defined(FOUND_DIRSIZE) && defined(MAXNAMLEN)
116# define DIRSIZE MAXNAMLEN /* From dirent.h */
117# define FOUND_DIRSIZE
118# endif
119
120# ifdef __never__
121 /*
122 * DIRSIZ(dp) is a parameterized macro, we cannot use it here.
123 */
124# if !defined(FOUND_DIRSIZE) && defined(DIRSIZ)
125# define DIRSIZE DIRSIZ /* From sys/dir.h */
126# define FOUND_DIRSIZE
127# endif
128# endif /* __never__ */
129
130# if !defined(FOUND_DIRSIZE) && defined(NAME_MAX)
131# define DIRSIZE NAME_MAX /* From limits.h */
132# define FOUND_DIRSIZE
133# endif
134
135# else /* !_FOUND_DIR_ */
136
137# if !defined(FOUND_DIRSIZE) && defined(_MAX_DIR)
138# if defined(__MINGW32__) || defined(_MSC_VER)
139# define DIRSIZE _MAX_DIR /* From stdlib.h */
140# define FOUND_DIRSIZE
141# define NEED_READDIR
142# undef dirent
143# define dirent _direct
144# undef DIR_NAMELEN
145# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
146# endif
147# endif
148
149# ifndef NEED_READDIR
150# define NEED_DIRENT
151# define NEED_READDIR
152# undef dirent
153# define dirent _direct
154# undef DIR_NAMELEN
155# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
156# endif /* !NEED_READDIR */
157
158# endif /* _FOUND_DIR_ */
159
160
161#ifdef NEED_DIRENT
162
163#ifndef FOUND_DIRSIZE
164#define DIRSIZE 14 /* The old UNIX standard value */
165#define FOUND_DIRSIZE
166#endif
167
168typedef struct _dirent {
169 short ino;
172
173#endif /* NEED_DIRENT */
174
175#endif /* !JOS */
176
177#ifdef NEED_READDIR
178
179#ifndef _SCHILY_STDIO_H
180#include <schily/stdio.h>
181#endif
182#if defined(__MINGW32__) || defined(_MSC_VER)
183#ifndef _SCHILY_IO_H
184#include <schily/io.h> /* for _findfirst() */
185#endif
186#ifndef _SCHILY_UTYPES_H
187#include <schily/utypes.h>
188#endif
189#endif
190
191 struct _direct {
192 unsigned long d_ino;
193 unsigned short d_reclen;
194 unsigned short d_namlen;
195 char d_name[DIRSIZE +1];
196 };
197#define HAVE_DIRENT_D_INO
198
199 typedef struct __dirdesc {
201
202#if defined(__MINGW32__) || defined(_MSC_VER)
203 struct _direct dd_dir; /* dirent for this dir */
204 struct _finddata_t dd_data; /* _findnext() results */
205 intptr_t dd_handle; /* _findnext() handle */
206 int dd_state; /* Current Dir state */
207 char dd_dirname[1]; /* Dir to open */
208#endif
210
211extern DIR *opendir __PR((const char *));
212extern int closedir __PR((DIR *));
213extern struct dirent *readdir __PR((DIR *));
214
215#endif /* NEED_READDIR */
216
217#if !defined(HAVE_DIRFD) && defined(HAVE_DIR_DD_FD)
218# define dirfd(dirp) ((dirp)->dd_fd)
219#endif
220
221#ifdef __cplusplus
222}
223#endif
224
225#endif /* _SCHILY_DIRENT_H */
int __cdecl closedir(DIR *)
DIR *__cdecl opendir(const char *)
struct dirent *__cdecl readdir(DIR *)
#define __PR(a)
Definition: prototyp.h:106
Definition: dirent.h:40
FILE * dd_fd
Definition: dirent.h:200
unsigned short d_namlen
Definition: dirent.h:194
unsigned long d_ino
Definition: dirent.h:192
unsigned short d_reclen
Definition: dirent.h:193
char d_name[DIRSIZE+1]
Definition: dirent.h:195
short ino
Definition: dirent.h:169
Definition: io.h:37
Definition: fatfs.h:198
Definition: name.c:39
#define dirent
Definition: dirent.h:153
#define DIRSIZE
Definition: dirent.h:164
int intptr_t
Definition: vcruntime.h:134