rpm  4.5
fts.h
Go to the documentation of this file.
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 #ifndef _FTS_H
33 #define _FTS_H 1
34 
35 #if defined(__GLIBC__)
36 #include <features.h>
37 #else
38 
39 # define __THROW
40 
41 #if defined(hpux) || defined(__hpux)
42 # define _D_EXACT_NAMLEN(d) ((d)->d_namlen)
43 # define _INCLUDE_POSIX_SOURCE
44 # define _LARGEFILE64_SOURCE
45 #endif
46 
47 #if defined(__FreeBSD__)
48 # define _D_EXACT_NAMLEN(d) ((d)->d_namlen)
49 #endif
50 
51 #if !defined(_D_EXACT_NAMLEN)
52 # define _D_EXACT_NAMLEN(d) (strlen((d)->d_name))
53 #endif
54 
55 #endif
56 
57 #include <sys/types.h>
58 #include <sys/stat.h>
59 #include <dirent.h>
60 
61 typedef struct {
62 /*@owned@*/ /*@relnull@*/
63  struct _ftsent *fts_cur;
64 /*@owned@*/ /*@null@*/
65  struct _ftsent *fts_child;
66 /*@owned@*/ /*@null@*/
67  struct _ftsent **fts_array;
68  dev_t fts_dev;
69 /*@owned@*/ /*@relnull@*/
70  char *fts_path;
71  int fts_rfd;
73  int fts_nitems;
74 /*@null@*/
75  int (*fts_compar) (const void *, const void *)
76  /*@*/;
78  DIR * (*fts_opendir) (const char * path)
79  /*@globals fileSystem @*/
80  /*@modifies fileSystem @*/;
81  struct dirent * (*fts_readdir) (DIR * dir)
82  /*@globals fileSystem @*/
83  /*@modifies *dir, fileSystem @*/;
84  int (*fts_closedir) (/*@only@*/ DIR * dir)
85  /*@globals fileSystem @*/
86  /*@modifies *dir, fileSystem @*/;
87  int (*fts_stat) (const char * path, /*@out@*/ struct stat * st)
88  /*@globals fileSystem @*/
89  /*@modifies *st, fileSystem @*/;
90  int (*fts_lstat) (const char * path, /*@out@*/ struct stat * st)
91  /*@globals fileSystem @*/
92  /*@modifies *st, fileSystem @*/;
93 
94 #define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */
95 #define FTS_LOGICAL 0x0002 /* logical walk */
96 #define FTS_NOCHDIR 0x0004 /* don't change directories */
97 #define FTS_NOSTAT 0x0008 /* don't get stat info */
98 #define FTS_PHYSICAL 0x0010 /* physical walk */
99 #define FTS_SEEDOT 0x0020 /* return dot and dot-dot */
100 #define FTS_XDEV 0x0040 /* don't cross devices */
101 #define FTS_WHITEOUT 0x0080 /* return whiteout information */
102 #define FTS_OPTIONMASK 0x00ff /* valid user option mask */
103 
104 #define FTS_NAMEONLY 0x0100 /* (private) child names only */
105 #define FTS_STOP 0x0200 /* (private) unrecoverable error */
107 } FTS;
108 
109 typedef struct _ftsent {
110 /*@dependent@*/
111  struct _ftsent *fts_cycle;
112 /*@dependent@*/ /*@relnull@*/
113  struct _ftsent *fts_parent;
114 /*@dependent@*/ /*@null@*/
115  struct _ftsent *fts_link;
116  long fts_number;
117 /*@null@*/
118  void *fts_pointer;
119 /*@dependent@*/
120  char *fts_accpath;
121 /*@dependent@*/
122  char *fts_path;
123  int fts_errno;
124  int fts_symfd;
125  u_short fts_pathlen;
126  u_short fts_namelen;
128  ino_t fts_ino;
129  dev_t fts_dev;
130  nlink_t fts_nlink;
132 #define FTS_ROOTPARENTLEVEL -1
133 #define FTS_ROOTLEVEL 0
134  short fts_level;
136 #define FTS_D 1 /* preorder directory */
137 #define FTS_DC 2 /* directory that causes cycles */
138 #define FTS_DEFAULT 3 /* none of the above */
139 #define FTS_DNR 4 /* unreadable directory */
140 #define FTS_DOT 5 /* dot or dot-dot */
141 #define FTS_DP 6 /* postorder directory */
142 #define FTS_ERR 7 /* error; errno is set */
143 #define FTS_F 8 /* regular file */
144 #define FTS_INIT 9 /* initialized only */
145 #define FTS_NS 10 /* stat(2) failed */
146 #define FTS_NSOK 11 /* no stat(2) requested */
147 #define FTS_SL 12 /* symbolic link */
148 #define FTS_SLNONE 13 /* symbolic link without target */
149 #define FTS_W 14 /* whiteout object */
150  u_short fts_info;
152 #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */
153 #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */
154  u_short fts_flags;
156 #define FTS_AGAIN 1 /* read node again */
157 #define FTS_FOLLOW 2 /* follow symbolic link */
158 #define FTS_NOINSTR 3 /* no instructions */
159 #define FTS_SKIP 4 /* discard node */
160  u_short fts_instr;
162 /*@dependent@*/
163  struct stat *fts_statp;
164  char fts_name[1];
165 } FTSENT;
166 
167 #ifdef __cplusplus
168 extern "C" {
169 #endif
170 
177 /*@dependent@*/ /*@null@*/
178 FTSENT *Fts_children (FTS * sp, int instr) __THROW
179  /*@globals fileSystem, internalState @*/
180  /*@modifies *sp, fileSystem, internalState @*/;
181 
187 int Fts_close (/*@only@*/ /*@null@*/ FTS * sp) __THROW
188  /*@globals fileSystem, internalState @*/
189  /*@modifies *sp, fileSystem, internalState @*/;
190 
198 /*@only@*/ /*@null@*/
199 FTS *Fts_open (char * const * argv, int options,
200  /*@null@*/
201  int (*compar) (const FTSENT **, const FTSENT **)) __THROW
202  /*@*/;
203 
209 /*@null@*/
210 FTSENT *Fts_read (/*@null@*/ FTS * sp) __THROW
211  /*@globals fileSystem, internalState @*/
212  /*@modifies *sp, fileSystem, internalState @*/;
213 
221 int Fts_set (FTS * sp, FTSENT * p, int instr) __THROW
222  /*@modifies *p @*/;
223 
224 #ifdef __cplusplus
225 }
226 #endif
227 
228 #endif /* fts.h */