rpm  5.4.10
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 # define __THROW
39 #if defined(hpux) || defined(__hpux)
40 # define _INCLUDE_POSIX_SOURCE
41 # define _LARGEFILE64_SOURCE
42 #endif
43 #endif
44 
45 #include <sys/types.h>
46 #include <sys/stat.h>
47 #include <dirent.h>
48 
49 /*@unchecked@*/
50 extern int _fts_debug;
51 
54 typedef struct {
55 /*@owned@*/ /*@relnull@*/
56  struct _ftsent *fts_cur;
57 /*@owned@*/ /*@null@*/
58  struct _ftsent *fts_child;
59 /*@owned@*/ /*@null@*/
60  struct _ftsent **fts_array;
61  dev_t fts_dev;
62 /*@owned@*/ /*@relnull@*/
63  char *fts_path;
64  int fts_rfd;
66  int fts_nitems;
67 /*@null@*/
68  int (*fts_compar) (const void *, const void *)
69  /*@*/;
71  DIR * (*fts_opendir) (const char * path)
72  /*@globals fileSystem @*/
73  /*@modifies fileSystem @*/;
74  struct dirent * (*fts_readdir) (DIR * dir)
75  /*@globals fileSystem @*/
76  /*@modifies *dir, fileSystem @*/;
77  int (*fts_closedir) (/*@only@*/ DIR * dir)
78  /*@globals fileSystem @*/
79  /*@modifies *dir, fileSystem @*/;
80  int (*fts_stat) (const char * path, /*@out@*/ struct stat * st)
81  /*@globals fileSystem @*/
82  /*@modifies *st, fileSystem @*/;
83  int (*fts_lstat) (const char * path, /*@out@*/ struct stat * st)
84  /*@globals fileSystem @*/
85  /*@modifies *st, fileSystem @*/;
86 
87 #define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */
88 #define FTS_LOGICAL 0x0002 /* logical walk */
89 #define FTS_NOCHDIR 0x0004 /* don't change directories */
90 #define FTS_NOSTAT 0x0008 /* don't get stat info */
91 #define FTS_PHYSICAL 0x0010 /* physical walk */
92 #define FTS_SEEDOT 0x0020 /* return dot and dot-dot */
93 #define FTS_XDEV 0x0040 /* don't cross devices */
94 #define FTS_WHITEOUT 0x0080 /* return whiteout information */
95 #define FTS_OPTIONMASK 0x00ff /* valid user option mask */
96 
97 #define FTS_NAMEONLY 0x0100 /* (private) child names only */
98 #define FTS_STOP 0x0200 /* (private) unrecoverable error */
100 } FTS;
101 
102 typedef struct _ftsent {
103 /*@dependent@*/
104  struct _ftsent *fts_cycle;
105 /*@dependent@*/ /*@relnull@*/
106  struct _ftsent *fts_parent;
107 /*@dependent@*/ /*@null@*/
108  struct _ftsent *fts_link;
109  long fts_number;
110 /*@null@*/
111  void *fts_pointer;
112 /*@dependent@*/
113  char *fts_accpath;
114 /*@dependent@*/
115  char *fts_path;
116  int fts_errno;
117  int fts_symfd;
118  u_short fts_pathlen;
119  u_short fts_namelen;
121  ino_t fts_ino;
122  dev_t fts_dev;
123  nlink_t fts_nlink;
125 #define FTS_ROOTPARENTLEVEL -1
126 #define FTS_ROOTLEVEL 0
127  short fts_level;
129 #define FTS_D 1 /* preorder directory */
130 #define FTS_DC 2 /* directory that causes cycles */
131 #define FTS_DEFAULT 3 /* none of the above */
132 #define FTS_DNR 4 /* unreadable directory */
133 #define FTS_DOT 5 /* dot or dot-dot */
134 #define FTS_DP 6 /* postorder directory */
135 #define FTS_ERR 7 /* error; errno is set */
136 #define FTS_F 8 /* regular file */
137 #define FTS_INIT 9 /* initialized only */
138 #define FTS_NS 10 /* stat(2) failed */
139 #define FTS_NSOK 11 /* no stat(2) requested */
140 #define FTS_SL 12 /* symbolic link */
141 #define FTS_SLNONE 13 /* symbolic link without target */
142 #define FTS_W 14 /* whiteout object */
143  u_short fts_info;
145 #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */
146 #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */
147  u_short fts_flags;
149 #define FTS_AGAIN 1 /* read node again */
150 #define FTS_FOLLOW 2 /* follow symbolic link */
151 #define FTS_NOINSTR 3 /* no instructions */
152 #define FTS_SKIP 4 /* discard node */
153  u_short fts_instr;
155 /*@dependent@*/
156  struct stat *fts_statp;
157  char fts_name[1];
158 } FTSENT;
159 
160 #ifdef __cplusplus
161 extern "C" {
162 #endif
163 
170 /*@dependent@*/ /*@null@*/
171 FTSENT *Fts_children (FTS * sp, int instr)
172  /*@globals fileSystem, internalState @*/
173  /*@modifies *sp, fileSystem, internalState @*/;
174 
180 int Fts_close (/*@only@*/ /*@null@*/ FTS * sp)
181  /*@globals fileSystem, internalState @*/
182  /*@modifies *sp, fileSystem, internalState @*/;
183 
191 /*@only@*/ /*@null@*/
192 FTS *Fts_open (char * const * argv, int options,
193  /*@null@*/
194  int (*compar) (const FTSENT **, const FTSENT **))
195  /*@*/;
196 
202 /*@null@*/
203 FTSENT *Fts_read (/*@null@*/ FTS * sp)
204  /*@globals fileSystem, internalState @*/
205  /*@modifies *sp, fileSystem, internalState @*/;
206 
214 int Fts_set (FTS * sp, FTSENT * p, int instr)
215  /*@modifies *p @*/;
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #endif /* fts.h */