xref: /original-bsd/include/fts.h (revision 2611fccd)
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.19 (Berkeley) 01/15/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_LOGICAL	0x001		/* logical walk */
25 #define	FTS_NOCHDIR	0x002		/* don't change directories */
26 #define	FTS_NOSTAT	0x004		/* don't get stat info */
27 #define	FTS_PHYSICAL	0x008		/* physical walk */
28 #define	FTS_SEEDOT	0x010		/* return dot and dot-dot */
29 #define	FTS_STOP	0x020		/* (private) unrecoverable error */
30 #define	FTS_XDEV	0x040		/* don't cross devices */
31 	int fts_options;		/* openfts() options */
32 } FTS;
33 
34 typedef struct _ftsent {
35 	struct _ftsent *fts_cycle;	/* cycle node */
36 	struct _ftsent *fts_parent;	/* parent directory */
37 	struct _ftsent *fts_link;	/* next file in directory */
38 	union {
39 		long number;		/* local numeric value */
40 		void *pointer;		/* local address value */
41 	} fts_local;
42 #define	fts_number	fts_local.number
43 #define	fts_pointer	fts_local.pointer
44 	char *fts_accpath;		/* access path */
45 	char *fts_path;			/* root path */
46 	int fts_errno;			/* errno for this node */
47 	u_short fts_pathlen;		/* strlen(fts_path) */
48 	u_short fts_namelen;		/* strlen(fts_name) */
49 
50 	ino_t fts_ino;			/* inode */
51 	dev_t fts_dev;			/* device */
52 	nlink_t fts_nlink;		/* link count */
53 
54 #define	FTS_ROOTPARENTLEVEL	-1
55 #define	FTS_ROOTLEVEL		 0
56 	short fts_level;		/* depth (-1 to N) */
57 
58 #define	FTS_D		 1		/* preorder directory */
59 #define	FTS_DC		 2		/* directory that causes cycles */
60 #define	FTS_DEFAULT	 3		/* none of the above */
61 #define	FTS_DNR		 4		/* unreadable directory */
62 #define	FTS_DOT		 5		/* dot or dot-dot */
63 #define	FTS_DP		 6		/* postorder directory */
64 #define	FTS_ERR		 7		/* error; errno is set */
65 #define	FTS_F		 8		/* regular file */
66 #define	FTS_INIT	 9		/* initialized only */
67 #define	FTS_NS		10		/* stat(2) failed */
68 #define	FTS_NSOK	11		/* no stat(2) requested */
69 #define	FTS_SL		12		/* symbolic link */
70 #define	FTS_SLNONE	13		/* symbolic link without target */
71 	u_short fts_info;		/* user flags for FTSENT structure */
72 
73 #define	FTS_AGAIN	 1		/* read node again */
74 #define	FTS_FOLLOW	 2		/* follow symbolic link */
75 #define	FTS_NOINSTR	 3		/* no instructions */
76 #define	FTS_SKIP	 4		/* discard node */
77 	u_short fts_instr;		/* fts_set() instructions */
78 
79 	struct stat *fts_statp;		/* stat(2) information */
80 	char fts_name[1];		/* file name */
81 } FTSENT;
82 
83 #include <sys/cdefs.h>
84 
85 __BEGIN_DECLS
86 FTSENT	*fts_children __P((FTS *));
87 int	 fts_close __P((FTS *));
88 FTS	*fts_open __P((char * const *, int,
89 	    int (*)(const FTSENT **, const FTSENT **)));
90 FTSENT	*fts_read __P((FTS *));
91 int	 fts_set __P((FTS *, FTSENT *, int));
92 __END_DECLS
93 
94 #endif /* !_FTS_H_ */
95