Debian Codegraph @

src/OVAL/fts_sun.h

raw symbols SCIP
1 /*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)fts.h 8.3 (Berkeley) 8/14/94
30 */
31
32 #include "config.h"
33
34 #if !defined(HAVE_FTS_OPEN)
35
36 #ifndef _FTS_H
37 #define _FTS_H 1
38
39
40 #if defined(__GLIBC__)
41 #include <features.h>
42 #else
43
44 # define __THROW
45 #ifdef __cplusplus
46 # define __BEGIN_DECLS extern "C" {
47 # define __END_DECLS }
48 #else
49 # define __BEGIN_DECLS
50 # define __END_DECLS
51 #endif
52
53 #if defined(OS_HPUX)
54 # define _D_EXACT_NAMLEN(d) ((d)->d_namlen)
55 # define _INCLUDE_POSIX_SOURCE
56 # define _LARGEFILE64_SOURCE
57 #endif
58
59 /* This needs to be ifdef SOLARIS */
60 #if defined(OS_SOLARIS)
61 # define _D_EXACT_NAMLEN(d) (strlen((d)->d_name))
62 # ifndef _INCLUDE_POSIX_SOURCE
63 # define _INCLUDE_POSIX_SOURCE
64 # endif
65 # ifndef _LARGEFILE64_SOURCE
66 # define _LARGEFILE64_SOURCE
67 # endif
68 #endif
69
70 #endif
71
72 #include <sys/types.h>
73 #include <sys/stat.h>
74 #include <dirent.h>
75
76 /* The fts interface is incompatible with the LFS interface which
77 transparently uses the 64-bit file access functions. */
78
79 #ifdef __USE_FILE_OFFSET64
80 # error "<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64"
81 #endif
82
83
84 typedef struct {
85 /*@owned@*/
86 struct _ftsent *fts_cur; /*!< current node */
87 /*@owned@*/ /*@null@*/
88 struct _ftsent *fts_child; /*!< linked list of children */
89 /*@owned@*/ /*@null@*/
90 struct _ftsent **fts_array; /*!< sort array */
91 dev_t fts_dev; /*!< starting device # */
92 /*@owned@*/
93 char *fts_path; /*!< path for this descent */
94 int fts_rfd; /*!< fd for root */
95 int fts_pathlen; /*!< sizeof(path) */
96 int fts_nitems; /*!< elements in the sort array */
97 /*@null@*/
98 int (*fts_compar) (const void *, const void *)
99 /*@*/; /*!< compare fn */
100
101 DIR * (*fts_opendir) (const char * path)
102 /*@globals fileSystem @*/
103 /*@modifies fileSystem @*/;
104 struct dirent * (*fts_readdir) (DIR * dir)
105 /*@globals fileSystem @*/
106 /*@modifies *dir, fileSystem @*/;
107 int (*fts_closedir) (/*@only@*/ DIR * dir)
108 /*@globals fileSystem @*/
109 /*@modifies *dir, fileSystem @*/;
110 int (*fts_stat) (const char * path, /*@out@*/ struct stat * st)
111 /*@globals fileSystem @*/
112 /*@modifies *st, fileSystem @*/;
113 int (*fts_lstat) (const char * path, /*@out@*/ struct stat * st)
114 /*@globals fileSystem @*/
115 /*@modifies *st, fileSystem @*/;
116
117 #define FTS_COMFOLLOW 0x0001 /*!< follow command line symlinks */
118 #define FTS_LOGICAL 0x0002 /*!< logical walk */
119 #define FTS_NOCHDIR 0x0004 /*!< don't change directories */
120 #define FTS_NOSTAT 0x0008 /*!< don't get stat info */
121 #define FTS_PHYSICAL 0x0010 /*!< physical walk */
122 #define FTS_SEEDOT 0x0020 /*!< return dot and dot-dot */
123 #define FTS_XDEV 0x0040 /*!< don't cross devices */
124 #define FTS_WHITEOUT 0x0080 /*!< return whiteout information */
125 #define FTS_OPTIONMASK 0x00ff /*!< valid user option mask */
126
127 #define FTS_NAMEONLY 0x0100 /*!< (private) child names only */
128 #define FTS_STOP 0x0200 /*!< (private) unrecoverable error */
129 int fts_options; /*!< fts_open options, global flags */
130 } FTS;
131
132 typedef struct _ftsent {
133 /*@dependent@*/
134 struct _ftsent *fts_cycle; /*!< cycle node */
135 /*@dependent@*/
136 struct _ftsent *fts_parent; /*!< parent directory */
137 /*@dependent@*/
138 struct _ftsent *fts_link; /*!< next file in directory */
139 long fts_number; /*!< local numeric value */
140 void *fts_pointer; /*!< local address value */
141 /*@dependent@*/
142 char *fts_accpath; /*!< access path */
143 /*@dependent@*/
144 char *fts_path; /*!< root path */
145 int fts_errno; /*!< errno for this node */
146 int fts_symfd; /*!< fd for symlink */
147 u_short fts_pathlen; /*!< strlen(fts_path) */
148 u_short fts_namelen; /*!< strlen(fts_name) */
149
150 ino_t fts_ino; /*!< inode */
151 dev_t fts_dev; /*!< device */
152 nlink_t fts_nlink; /*!< link count */
153
154 #define FTS_ROOTPARENTLEVEL -1
155 #define FTS_ROOTLEVEL 0
156 short fts_level; /*!< depth (-1 to N) */
157
158 #define FTS_D 1 /*!< preorder directory */
159 #define FTS_DC 2 /*!< directory that causes cycles */
160 #define FTS_DEFAULT 3 /*!< none of the above */
161 #define FTS_DNR 4 /*!< unreadable directory */
162 #define FTS_DOT 5 /*!< dot or dot-dot */
163 #define FTS_DP 6 /*!< postorder directory */
164 #define FTS_ERR 7 /*!< error; errno is set */
165 #define FTS_F 8 /*!< regular file */
166 #define FTS_INIT 9 /*!< initialized only */
167 #define FTS_NS 10 /*!< stat(2) failed */
168 #define FTS_NSOK 11 /*!< no stat(2) requested */
169 #define FTS_SL 12 /*!< symbolic link */
170 #define FTS_SLNONE 13 /*!< symbolic link without target */
171 #define FTS_W 14 /*!< whiteout object */
172 u_short fts_info; /*!< user flags for FTSENT structure */
173
174 #define FTS_DONTCHDIR 0x01 /*!< don't chdir .. to the parent */
175 #define FTS_SYMFOLLOW 0x02 /*!< followed a symlink to get here */
176 u_short fts_flags; /*!< private flags for FTSENT structure */
177
178 #define FTS_AGAIN 1 /*!< read node again */
179 #define FTS_FOLLOW 2 /*!< follow symbolic link */
180 #define FTS_NOINSTR 3 /*!< no instructions */
181 #define FTS_SKIP 4 /*!< discard node */
182 u_short fts_instr; /*!< fts_set() instructions */
183
184 /*@dependent@*/
185 struct stat *fts_statp; /*!< stat(2) information */
186 char fts_name[1]; /*!< file name */
187 } FTSENT;
188
189 __BEGIN_DECLS
190
191 extern int dirfd (DIR * dirp);
192
193 /**
194 * Return list of children of the current node.
195 * @param sp file hierarchy state
196 * @param instr
197 * @return file set member
198 */
199 /*@unused@*/ /*@dependent@*/
200 FTSENT *fts_children (FTS * sp, int instr) __THROW
201 /*@globals fileSystem, internalState @*/
202 /*@modifies *sp, fileSystem, internalState @*/;
203
204 /**
205 * Destroy a file hierarchy traversal handle.
206 * @param sp file hierarchy state
207 * @return 0 on sucess, -1 on error
208 */
209 /*@unused@*/
210 int fts_close (/*@only@*/ FTS * sp) __THROW
211 /*@globals fileSystem, internalState @*/
212 /*@modifies *sp, fileSystem, internalState @*/;
213
214 /**
215 * Create a handle for file hierarchy traversal.
216 * @param argv paths that compose a logical file hierarchy
217 * @param options traversal options
218 * @param compar traversal ordering (or NULL)
219 * @return file hierarchy state (or NULL on error)
220 */
221 /*@unused@*/ /*@only@*/
222 FTS *fts_open (char * const * argv, int options,
223 /*@null@*/
224 int (*compar) (const FTSENT **, const FTSENT **)) __THROW
225 /*@*/;
226
227 /**
228 * Return next node in the file hierarchy traversal.
229 * @param sp file hierarchy state
230 * @return file set member
231 */
232 /*@unused@*/ /*@null@*/
233 FTSENT *fts_read (FTS * sp) __THROW
234 /*@globals fileSystem, internalState @*/
235 /*@modifies *sp, fileSystem, internalState @*/;
236
237 /**
238 * Modify the traversal for a file set member.
239 * @param sp file hierarchy state
240 * @param p file set member
241 * @param instr new disposition for file set member
242 * @return 0 on sucess, -1 on error
243 */
244 /*@unused@*/
245 int fts_set (FTS * sp, FTSENT * p, int instr) __THROW
246 /*@modifies *p @*/;
247
248 __END_DECLS
249
250 #endif /* fts.h */
251 #else
252 #if defined(OS_SOLARIS)
253 #include <fts.h>
254 #endif /* defined(OS_SOLARIS) */
255
256 #endif /* HAVE_FTS_OPEN */