Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / include / dirdefs.h
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
4  * The behaviour and appearence of the program code below can differ to a major
5  * extent from the version distributed by the original author(s).
6  *
7  * For details, see Changelog file distributed with the cdrkit package. If you
8  * received this file from another source then ask the distributing person for
9  * a log of modifications.
10  *
11  */
12
13 /* @(#)dirdefs.h        1.15 04/06/16 Copyright 1987, 1998 J. Schilling */
14 /*
15  *      Copyright (c) 1987, 1998 J. Schilling
16  */
17 /*
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License version 2
20  * as published by the Free Software Foundation.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License along with
28  * this program; see the file COPYING.  If not, write to the Free Software
29  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30  */
31
32 #ifndef _DIRDEFS_H
33 #define _DIRDEFS_H
34
35 #ifndef _MCONFIG_H
36 #include <mconfig.h>
37 #endif
38
39 #ifdef  __cplusplus
40 extern "C" {
41 #endif
42
43 #ifdef JOS
44 #       ifndef  _INCL_SYS_STYPES_H
45 #       include <sys/stypes.h>
46 #       define  _INCL_SYS_STYPES_H
47 #       endif
48 #       ifndef  _INCL_SYS_FILEDESC_H
49 #       include <sys/filedesc.h>
50 #       define  _INCL_SYS_FILEDESC_H
51 #       endif
52 #       define  NEED_READDIR
53 #       define  dirent                  _direct
54 #       define  DIR_NAMELEN(dirent)     strlen((dirent)->d_name)
55 #       define  DIRSIZE 30
56 #       define  FOUND_DIRSIZE
57         typedef struct _dirent {
58                 char    name[DIRSIZE];
59                 short   ino;
60         } dirent;
61
62 #else   /* !JOS */
63
64 #       ifndef  _INCL_SYS_TYPES_H
65 #       include <sys/types.h>
66 #       define  _INCL_SYS_TYPES_H
67 #       endif
68 #       ifndef  _INCL_SYS_STAT_H
69 #       include <sys/stat.h>
70 #       define  _INCL_SYS_STAT_H
71 #       endif
72 #       ifdef   HAVE_LIMITS_H
73 #               ifndef  _INCL_LIMITS_H
74 #               include <limits.h>
75 #               define  _INCL_LIMITS_H
76 #               endif
77 #       endif
78 #       ifdef   HAVE_SYS_PARAM_H
79 #               ifndef  _INCL_SYS_PARAM_H
80 #               include <sys/param.h>
81 #               define  _INCL_SYS_PARAM_H
82 #               endif
83 #       endif
84
85 #       ifdef   HAVE_DIRENT_H           /* This a POSIX compliant system */
86 #               ifndef  _INCL_DIRENT_H
87 #               include <dirent.h>
88 #               define  _INCL_DIRENT_H
89 #               endif
90 #               define  DIR_NAMELEN(dirent)     strlen((dirent)->d_name)
91 #               define  _FOUND_DIR_
92 #       else                            /* This is a Pre POSIX system    */
93
94 #       define  dirent  direct
95 #       define  DIR_NAMELEN(dirent)     (dirent)->d_namlen
96
97 #       if      defined(HAVE_SYS_DIR_H)
98 #               ifndef  _INCL_SYS_DIR_H
99 #               include <sys/dir.h>
100 #               define  _INCL_SYS_DIR_H
101 #               endif
102 #               define  _FOUND_DIR_
103 #       endif
104
105 #       if      defined(HAVE_NDIR_H) && !defined(_FOUND_DIR_)
106 #               ifndef  _INCL_NDIR_H
107 #               include <ndir.h>
108 #               define  _INCL_NDIR_H
109 #               endif
110 #               define  _FOUND_DIR_
111 #       endif
112
113 #       if      defined(HAVE_SYS_NDIR_H) && !defined(_FOUND_DIR_)
114 #               ifndef  _INCL_SYS_NDIR_H
115 #               include <sys/ndir.h>
116 #               define  _INCL_SYS_NDIR_H
117 #               endif
118 #               define  _FOUND_DIR_
119 #       endif
120 #       endif   /* HAVE_DIRENT_H */
121
122 #       if      defined(_FOUND_DIR_)
123 /*
124  * Don't use defaults here to allow recognition of problems.
125  */
126 #       ifdef   MAXNAMELEN
127 #               define  DIRSIZE         MAXNAMELEN      /* From sys/param.h */
128 #               define  FOUND_DIRSIZE
129 #       else
130 #       ifdef   MAXNAMLEN
131 #               define  DIRSIZE         MAXNAMLEN       /* From dirent.h    */
132 #               define  FOUND_DIRSIZE
133 #       else
134 #       ifdef   DIRSIZ
135 #               define  DIRSIZE         DIRSIZ          /* From sys/dir.h   */
136 #               define  FOUND_DIRSIZE
137 #       endif
138 #       endif
139 #       endif
140 #       else    /* !_FOUND_DIR_ */
141
142 #               define  NEED_DIRENT
143 #               define  NEED_READDIR
144 #               define  dirent                  _direct
145 #               define  DIR_NAMELEN(dirent)     strlen((dirent)->d_name)
146
147 #       endif   /* _FOUND_DIR_ */
148
149
150 #ifdef  NEED_DIRENT
151
152 #ifndef FOUND_DIRSIZE
153 #define DIRSIZE         14      /* The old UNIX standard value */
154 #define FOUND_DIRSIZE
155 #endif
156
157 typedef struct _dirent {
158         short   ino;
159         char    name[DIRSIZE];
160 } dirent;
161
162 #endif  /* NEED_DIRENT */
163
164 #endif  /* !JOS */
165
166 #ifdef  NEED_READDIR
167         typedef struct __dirdesc {
168                 FILE    *dd_fd;
169         } DIR;
170
171         struct _direct {
172                 unsigned long   d_ino;
173                 unsigned short  d_reclen;
174                 unsigned short  d_namlen;
175                 char            d_name[DIRSIZE +1];
176         };
177
178 extern  DIR             *opendir();
179 extern                  closedir();
180 extern  struct dirent   *readdir();
181
182 #endif  /* NEED_READDIR */
183
184 #ifdef  __cplusplus
185 }
186 #endif
187
188 #endif  /* _DIRDEFS_H */