xref: /original-bsd/include/fts.h (revision 0669bf0d)
1 /*
2  * Copyright (c) 1989, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)fts.h	8.1 (Berkeley) 06/02/93
8  */
9 
10 #ifndef	_FTS_H_
11 #define	_FTS_H_
12 
13 typedef struct {
14 	struct _ftsent *fts_cur;	/* current node */
15 	struct _ftsent *fts_child;	/* linked list of children */
16 	struct _ftsent **fts_array;	/* sort array */
17 	dev_t fts_dev;			/* starting device # */
18 	char *fts_path;			/* path for this descent */
19 	int fts_rfd;			/* fd for root */
20 	int fts_pathlen;		/* sizeof(path) */
21 	int fts_nitems;			/* elements in the sort array */
22 	int (*fts_compar)();		/* compare function */
23 
24 #define	FTS_COMFOLLOW	0x001		/* follow command line symlinks */
25 #define	FTS_LOGICAL	0x002		/* logical walk */
26 #define	FTS_NOCHDIR	0x004		/* don't change directories */
27 #define	FTS_NOSTAT	0x008		/* don't get stat info */
28 #define	FTS_PHYSICAL	0x010		/* physical walk */
29 #define	FTS_SEEDOT	0x020		/* return dot and dot-dot */
30 #define	FTS_XDEV	0x040		/* don't cross devices */
31 #define	FTS_OPTIONMASK	0x07f		/* valid user option mask */
32 
33 #define	FTS_NAMEONLY	0x080		/* (private) child names only */
34 #define	FTS_STOP	0x100		/* (private) unrecoverable error */
35 	int fts_options;		/* fts_open options, global flags */
36 } FTS;
37 
38 typedef struct _ftsent {
39 	struct _ftsent *fts_cycle;	/* cycle node */
40 	struct _ftsent *fts_parent;	/* parent directory */
41 	struct _ftsent *fts_link;	/* next file in directory */
42 	long fts_number;	        /* local numeric value */
43 	void *fts_pointer;	        /* local address value */
44 	char *fts_accpath;		/* access path */
45 	char *fts_path;			/* root path */
46 	int fts_errno;			/* errno for this node */
47 	int fts_symfd;			/* fd for symlink */
48 	u_short fts_pathlen;		/* strlen(fts_path) */
49 	u_short fts_namelen;		/* strlen(fts_name) */
50 
51 	ino_t fts_ino;			/* inode */
52 	dev_t fts_dev;			/* device */
53 	nlink_t fts_nlink;		/* link count */
54 
55 #define	FTS_ROOTPARENTLEVEL	-1
56 #define	FTS_ROOTLEVEL		 0
57 	short fts_level;		/* depth (-1 to N) */
58 
59 #define	FTS_D		 1		/* preorder directory */
60 #define	FTS_DC		 2		/* directory that causes cycles */
61 #define	FTS_DEFAULT	 3		/* none of the above */
62 #define	FTS_DNR		 4		/* unreadable directory */
63 #define	FTS_DOT		 5		/* dot or dot-dot */
64 #define	FTS_DP		 6		/* postorder directory */
65 #define	FTS_ERR		 7		/* error; errno is set */
66 #define	FTS_F		 8		/* regular file */
67 #define	FTS_INIT	 9		/* initialized only */
68 #define	FTS_NS		10		/* stat(2) failed */
69 #define	FTS_NSOK	11		/* no stat(2) requested */
70 #define	FTS_SL		12		/* symbolic link */
71 #define	FTS_SLNONE	13		/* symbolic link without target */
72 	u_short fts_info;		/* user flags for FTSENT structure */
73 
74 #define	FTS_DONTCHDIR	 0x01		/* don't chdir .. to the parent */
75 #define	FTS_SYMFOLLOW	 0x02		/* followed a symlink to get here */
76 	u_short fts_flags;		/* private flags for FTSENT structure */
77 
78 #define	FTS_AGAIN	 1		/* read node again */
79 #define	FTS_FOLLOW	 2		/* follow symbolic link */
80 #define	FTS_NOINSTR	 3		/* no instructions */
81 #define	FTS_SKIP	 4		/* discard node */
82 	u_short fts_instr;		/* fts_set() instructions */
83 
84 	struct stat *fts_statp;		/* stat(2) information */
85 	char fts_name[1];		/* file name */
86 } FTSENT;
87 
88 #include <sys/cdefs.h>
89 
90 __BEGIN_DECLS
91 FTSENT	*fts_children __P((FTS *, int));
92 int	 fts_close __P((FTS *));
93 FTS	*fts_open __P((char * const *, int,
94 	    int (*)(const FTSENT **, const FTSENT **)));
95 FTSENT	*fts_read __P((FTS *));
96 int	 fts_set __P((FTS *, FTSENT *, int));
97 __END_DECLS
98 
99 #endif /* !_FTS_H_ */
100