xref: /original-bsd/include/fts.h (revision 7bd39f15)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)fts.h	5.22 (Berkeley) 03/01/92
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 	union {
43 		long number;		/* local numeric value */
44 		void *pointer;		/* local address value */
45 	} fts_local;
46 #define	fts_number	fts_local.number
47 #define	fts_pointer	fts_local.pointer
48 	char *fts_accpath;		/* access path */
49 	char *fts_path;			/* root path */
50 	int fts_errno;			/* errno for this node */
51 	int fts_symfd;			/* fd for symlink */
52 	u_short fts_pathlen;		/* strlen(fts_path) */
53 	u_short fts_namelen;		/* strlen(fts_name) */
54 
55 	ino_t fts_ino;			/* inode */
56 	dev_t fts_dev;			/* device */
57 	nlink_t fts_nlink;		/* link count */
58 
59 #define	FTS_ROOTPARENTLEVEL	-1
60 #define	FTS_ROOTLEVEL		 0
61 	short fts_level;		/* depth (-1 to N) */
62 
63 #define	FTS_D		 1		/* preorder directory */
64 #define	FTS_DC		 2		/* directory that causes cycles */
65 #define	FTS_DEFAULT	 3		/* none of the above */
66 #define	FTS_DNR		 4		/* unreadable directory */
67 #define	FTS_DOT		 5		/* dot or dot-dot */
68 #define	FTS_DP		 6		/* postorder directory */
69 #define	FTS_ERR		 7		/* error; errno is set */
70 #define	FTS_F		 8		/* regular file */
71 #define	FTS_INIT	 9		/* initialized only */
72 #define	FTS_NS		10		/* stat(2) failed */
73 #define	FTS_NSOK	11		/* no stat(2) requested */
74 #define	FTS_SL		12		/* symbolic link */
75 #define	FTS_SLNONE	13		/* symbolic link without target */
76 	u_short fts_info;		/* user flags for FTSENT structure */
77 
78 #define	FTS_DONTCHDIR	 0x01		/* don't chdir .. to the parent */
79 #define	FTS_SYMFOLLOW	 0x01		/* followed a symlink to get here */
80 	u_short fts_flags;		/* private flags for FTSENT structure */
81 
82 #define	FTS_AGAIN	 1		/* read node again */
83 #define	FTS_FOLLOW	 2		/* follow symbolic link */
84 #define	FTS_NOINSTR	 3		/* no instructions */
85 #define	FTS_SKIP	 4		/* discard node */
86 	u_short fts_instr;		/* fts_set() instructions */
87 
88 	struct stat *fts_statp;		/* stat(2) information */
89 	char fts_name[1];		/* file name */
90 } FTSENT;
91 
92 #include <sys/cdefs.h>
93 
94 __BEGIN_DECLS
95 FTSENT	*fts_children __P((FTS *, int));
96 int	 fts_close __P((FTS *));
97 FTS	*fts_open __P((char * const *, int,
98 	    int (*)(const FTSENT **, const FTSENT **)));
99 FTSENT	*fts_read __P((FTS *));
100 int	 fts_set __P((FTS *, FTSENT *, int));
101 __END_DECLS
102 
103 #endif /* !_FTS_H_ */
104