xref: /titanic_41/usr/src/lib/libast/amd64/include/ast/fts.h (revision 3e14f97f673e8a630f076077de35afdd43dc1587)
1da2e3ebdSchin 
2da2e3ebdSchin /* : : generated by proto : : */
3da2e3ebdSchin /***********************************************************************
4da2e3ebdSchin *                                                                      *
5da2e3ebdSchin *               This software is part of the ast package               *
6*3e14f97fSRoger A. Faulkner *          Copyright (c) 1985-2010 AT&T Intellectual Property          *
7da2e3ebdSchin *                      and is licensed under the                       *
8da2e3ebdSchin *                  Common Public License, Version 1.0                  *
97c2fbfb3SApril Chin *                    by AT&T Intellectual Property                     *
10da2e3ebdSchin *                                                                      *
11da2e3ebdSchin *                A copy of the License is available at                 *
12da2e3ebdSchin *            http://www.opensource.org/licenses/cpl1.0.txt             *
13da2e3ebdSchin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
14da2e3ebdSchin *                                                                      *
15da2e3ebdSchin *              Information and Software Systems Research               *
16da2e3ebdSchin *                            AT&T Research                             *
17da2e3ebdSchin *                           Florham Park NJ                            *
18da2e3ebdSchin *                                                                      *
19da2e3ebdSchin *                 Glenn Fowler <gsf@research.att.com>                  *
20da2e3ebdSchin *                  David Korn <dgk@research.att.com>                   *
21da2e3ebdSchin *                   Phong Vo <kpv@research.att.com>                    *
22da2e3ebdSchin *                                                                      *
23da2e3ebdSchin ***********************************************************************/
24da2e3ebdSchin 
25da2e3ebdSchin /*
26da2e3ebdSchin  * Glenn Fowler
27da2e3ebdSchin  * David Korn
28da2e3ebdSchin  * Phong Vo
29da2e3ebdSchin  * AT&T Research
30da2e3ebdSchin  *
31da2e3ebdSchin  * fts interface definitions
32da2e3ebdSchin  */
33da2e3ebdSchin 
34da2e3ebdSchin #ifndef	_FTS_H
35da2e3ebdSchin #if !defined(__PROTO__)
36da2e3ebdSchin #include <prototyped.h>
37da2e3ebdSchin #endif
38da2e3ebdSchin #if !defined(__LINKAGE__)
39da2e3ebdSchin #define __LINKAGE__		/* 2004-08-11 transition */
40da2e3ebdSchin #endif
41da2e3ebdSchin 
42da2e3ebdSchin #define _FTS_H
43da2e3ebdSchin 
44*3e14f97fSRoger A. Faulkner #include <ast_std.h>
45*3e14f97fSRoger A. Faulkner #include <ast_fs.h>
46*3e14f97fSRoger A. Faulkner #include <ast_mode.h>
47da2e3ebdSchin 
48da2e3ebdSchin /*
49da2e3ebdSchin  * fts_open flags
50da2e3ebdSchin  */
51da2e3ebdSchin 
52da2e3ebdSchin #define FTS_LOGICAL	0	/* logical traversal, follow symlinks	*/
53da2e3ebdSchin #define FTS_META	(1<<0)	/* follow top dir symlinks even if phys	*/
54da2e3ebdSchin #define FTS_NOCHDIR	(1<<1)	/* don't chdir				*/
55da2e3ebdSchin #define FTS_NOPOSTORDER	(1<<2)	/* no postorder visits			*/
56da2e3ebdSchin #define FTS_NOPREORDER	(1<<3)	/* no preorder visits			*/
57da2e3ebdSchin #define FTS_NOSEEDOTDIR	(1<<11)	/* never retain leading . dir		*/
58da2e3ebdSchin #define FTS_NOSTAT	(1<<4)	/* don't stat children			*/
59da2e3ebdSchin #define FTS_ONEPATH	(1<<5)	/* pathnames arg is one const char*	*/
60da2e3ebdSchin #define FTS_PHYSICAL	(1<<6)	/* physical traversal, don't follow	*/
61da2e3ebdSchin #define FTS_SEEDOT	(1<<7)	/* return . and ..			*/
62da2e3ebdSchin #define FTS_SEEDOTDIR	(1<<10)	/* always retain leading . dir		*/
63da2e3ebdSchin #define FTS_TOP		(1<<8)	/* don't traverse subdirectories	*/
64da2e3ebdSchin #define FTS_XDEV	(1<<9)	/* don't cross mount points		*/
65da2e3ebdSchin 
66da2e3ebdSchin #define FTS_USER	(1<<12)	/* first user flag bit			*/
67da2e3ebdSchin 
68da2e3ebdSchin #define FTS_COMFOLLOW	FTS_META
69da2e3ebdSchin 
70da2e3ebdSchin /*
71da2e3ebdSchin  * fts_info flags
72da2e3ebdSchin  */
73da2e3ebdSchin 
74da2e3ebdSchin #define FTS_DEFAULT	0	/* ok, someone must have wanted this	*/
75da2e3ebdSchin 
76da2e3ebdSchin #define FTS_NS		(1<<0)	/* stat failed				*/
77da2e3ebdSchin #define FTS_F		(1<<1)	/* file - not directory or symbolic link*/
78da2e3ebdSchin #define FTS_SL		(1<<2)	/* symbolic link			*/
79da2e3ebdSchin #define FTS_D		(1<<3)	/* directory - pre-order visit		*/
80da2e3ebdSchin 
81da2e3ebdSchin #define FTS_C		(1<<4)	/* causes cycle				*/
82da2e3ebdSchin #define FTS_ERR		(1<<5)	/* some other error			*/
83da2e3ebdSchin #define FTS_DD		(1<<6)	/* . or ..				*/
84da2e3ebdSchin #define FTS_NR		(1<<7)	/* cannot read				*/
85da2e3ebdSchin #define FTS_NX		(1<<8)	/* cannot search			*/
86da2e3ebdSchin #define FTS_OK		(1<<9)	/* no info but otherwise ok		*/
87da2e3ebdSchin #define FTS_P		(1<<10)	/* post-order visit			*/
88da2e3ebdSchin 
89da2e3ebdSchin #define FTS_DC		(FTS_D|FTS_C)	/* dir - would cause cycle	*/
90da2e3ebdSchin #define FTS_DNR		(FTS_D|FTS_NR)	/* dir - no read permission	*/
91da2e3ebdSchin #define FTS_DNX		(FTS_D|FTS_NX)	/* dir - no search permission	*/
92da2e3ebdSchin #define FTS_DOT		(FTS_D|FTS_DD)	/* . or ..			*/
93da2e3ebdSchin #define FTS_DP		(FTS_D|FTS_P)	/* dir - post-order visit	*/
94da2e3ebdSchin #define FTS_NSOK	(FTS_NS|FTS_OK)	/* no stat (because you asked)	*/
95da2e3ebdSchin #define FTS_SLNONE	(FTS_SL|FTS_NS)	/* symlink - to nowhere		*/
96da2e3ebdSchin 
97da2e3ebdSchin /*
98da2e3ebdSchin  * fts_set flags
99da2e3ebdSchin  */
100da2e3ebdSchin 
101da2e3ebdSchin #define FTS_AGAIN	FTS_TOP		/* process entry again		*/
102da2e3ebdSchin #define FTS_FOLLOW	FTS_META	/* follow FTS_SL symlink	*/
103da2e3ebdSchin #define FTS_SKIP	FTS_NOSTAT	/* skip FTS_D directory		*/
104da2e3ebdSchin #define FTS_STAT	FTS_PHYSICAL	/* stat() done by user		*/
105da2e3ebdSchin 
106da2e3ebdSchin typedef struct Fts FTS;
107da2e3ebdSchin typedef struct Ftsent FTSENT;
108da2e3ebdSchin 
109da2e3ebdSchin struct Ftsent
110da2e3ebdSchin {
111da2e3ebdSchin 	char*		fts_accpath;	/* path relative to .		*/
112da2e3ebdSchin 	char*		fts_name;	/* file name			*/
113da2e3ebdSchin 	char*		fts_path;	/* path relative to top dir	*/
114da2e3ebdSchin 	FTSENT*		fts_cycle;	/* offender if cycle		*/
115da2e3ebdSchin 	FTSENT*		fts_link;	/* next child			*/
116da2e3ebdSchin 	FTSENT*		fts_parent;	/* parent directory		*/
117da2e3ebdSchin 	struct stat*	fts_statp;	/* stat info			*/
118da2e3ebdSchin #ifdef _FTSENT_LOCAL_PRIVATE_
119da2e3ebdSchin 	_FTSENT_LOCAL_PRIVATE_
120da2e3ebdSchin #else
121da2e3ebdSchin 	__V_*		fts_pointer;	/* local pointer value		*/
122da2e3ebdSchin #endif
123da2e3ebdSchin 	long		fts_number;	/* local numeric value		*/
124da2e3ebdSchin 	int		fts_errno;	/* errno for this entry		*/
125da2e3ebdSchin 	unsigned short	fts_info;	/* info flags			*/
12634f9b3eeSRoland Mainz 
12734f9b3eeSRoland Mainz 	unsigned short	_fts_namelen;	/* old fts_namelen		*/
12834f9b3eeSRoland Mainz 	unsigned short	_fts_pathlen;	/* old fts_pathlen		*/
12934f9b3eeSRoland Mainz 	short		_fts_level;	/* old fts_level		*/
13034f9b3eeSRoland Mainz 
13134f9b3eeSRoland Mainz 	short		_fts_status;	/* <ftwalk.h> compatibility	*/
13234f9b3eeSRoland Mainz 	struct stat	_fts_statb;	/* <ftwalk.h> compatibility	*/
13334f9b3eeSRoland Mainz 
13434f9b3eeSRoland Mainz 	FTS*		fts;		/* fts_open() handle		*/
13534f9b3eeSRoland Mainz 	size_t		fts_namelen;	/* strlen(fts_name)		*/
13634f9b3eeSRoland Mainz 	size_t		fts_pathlen;	/* strlen(fts_path)		*/
13734f9b3eeSRoland Mainz 	ssize_t		fts_level;	/* file tree depth, 0 at top	*/
138da2e3ebdSchin 
139da2e3ebdSchin #ifdef _FTSENT_PRIVATE_
140da2e3ebdSchin 	_FTSENT_PRIVATE_
141da2e3ebdSchin #endif
142da2e3ebdSchin 
143da2e3ebdSchin };
144da2e3ebdSchin 
145da2e3ebdSchin struct Fts
146da2e3ebdSchin {
147da2e3ebdSchin 	int		fts_errno;	/* last errno			*/
1487c2fbfb3SApril Chin 	__V_*		fts_handle;	/* user defined handle		*/
149da2e3ebdSchin 
150da2e3ebdSchin #ifdef _FTS_PRIVATE_
151da2e3ebdSchin 	_FTS_PRIVATE_
152da2e3ebdSchin #endif
153da2e3ebdSchin 
154da2e3ebdSchin };
155da2e3ebdSchin 
156da2e3ebdSchin #if _BLD_ast && defined(__EXPORT__)
157da2e3ebdSchin #undef __MANGLE__
158da2e3ebdSchin #define __MANGLE__ __LINKAGE__		__EXPORT__
159da2e3ebdSchin #endif
160da2e3ebdSchin 
161da2e3ebdSchin extern __MANGLE__ FTSENT*	fts_children __PROTO__((FTS*, int));
162da2e3ebdSchin extern __MANGLE__ int	fts_close __PROTO__((FTS*));
163da2e3ebdSchin extern __MANGLE__ int	fts_flags __PROTO__((void));
1647c2fbfb3SApril Chin extern __MANGLE__ int	fts_local __PROTO__((FTSENT*));
165da2e3ebdSchin extern __MANGLE__ int	fts_notify __PROTO__((int(*)(FTS*, FTSENT*, __V_*), __V_*));
166da2e3ebdSchin extern __MANGLE__ FTS*	fts_open __PROTO__((char* const*, int, int(*)(FTSENT* const*, FTSENT* const*)));
167da2e3ebdSchin extern __MANGLE__ FTSENT*	fts_read __PROTO__((FTS*));
168da2e3ebdSchin extern __MANGLE__ int	fts_set __PROTO__((FTS*, FTSENT*, int));
169da2e3ebdSchin 
170da2e3ebdSchin #undef __MANGLE__
171da2e3ebdSchin #define __MANGLE__ __LINKAGE__
172da2e3ebdSchin 
173da2e3ebdSchin #endif
174