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