Commit | Line | Data |
---|---|---|
4dedc488 KB |
1 | /* |
2 | * Copyright (c) 1989 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
863005e5 | 5 | * %sccs.include.redist.c% |
4dedc488 | 6 | * |
90831685 | 7 | * @(#)fts.h 5.24 (Berkeley) %G% |
4dedc488 KB |
8 | */ |
9 | ||
d2b7358e KB |
10 | #ifndef _FTS_H_ |
11 | #define _FTS_H_ | |
12 | ||
e5f81e84 KB |
13 | typedef struct { |
14 | struct _ftsent *fts_cur; /* current node */ | |
15 | struct _ftsent *fts_child; /* linked list of children */ | |
e5f81e84 | 16 | struct _ftsent **fts_array; /* sort array */ |
45b7ab12 | 17 | dev_t fts_dev; /* starting device # */ |
762bfe00 | 18 | char *fts_path; /* path for this descent */ |
b0086cd8 | 19 | int fts_rfd; /* fd for root */ |
762bfe00 KB |
20 | int fts_pathlen; /* sizeof(path) */ |
21 | int fts_nitems; /* elements in the sort array */ | |
22 | int (*fts_compar)(); /* compare function */ | |
b0086cd8 | 23 | |
a9f467bc KB |
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 */ | |
0341aad6 KB |
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 */ | |
4dedc488 KB |
36 | } FTS; |
37 | ||
e5f81e84 | 38 | typedef struct _ftsent { |
c5facbff | 39 | struct _ftsent *fts_cycle; /* cycle node */ |
e5f81e84 | 40 | struct _ftsent *fts_parent; /* parent directory */ |
c5facbff | 41 | struct _ftsent *fts_link; /* next file in directory */ |
f6c14546 EA |
42 | long fts_number; /* local numeric value */ |
43 | void *fts_pointer; /* local address value */ | |
e5f81e84 KB |
44 | char *fts_accpath; /* access path */ |
45 | char *fts_path; /* root path */ | |
9baf9be1 | 46 | int fts_errno; /* errno for this node */ |
9fb387bb | 47 | int fts_symfd; /* fd for symlink */ |
45b7ab12 KB |
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 */ | |
fcc61451 KB |
54 | |
55 | #define FTS_ROOTPARENTLEVEL -1 | |
56 | #define FTS_ROOTLEVEL 0 | |
762bfe00 | 57 | short fts_level; /* depth (-1 to N) */ |
b0086cd8 | 58 | |
4dedc488 KB |
59 | #define FTS_D 1 /* preorder directory */ |
60 | #define FTS_DC 2 /* directory that causes cycles */ | |
b0086cd8 KB |
61 | #define FTS_DEFAULT 3 /* none of the above */ |
62 | #define FTS_DNR 4 /* unreadable directory */ | |
45b7ab12 KB |
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 */ | |
b0086cd8 KB |
72 | u_short fts_info; /* user flags for FTSENT structure */ |
73 | ||
9fb387bb | 74 | #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ |
90831685 | 75 | #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ |
9fb387bb KB |
76 | u_short fts_flags; /* private flags for FTSENT structure */ |
77 | ||
b0086cd8 KB |
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 | ||
45b7ab12 | 84 | struct stat *fts_statp; /* stat(2) information */ |
762bfe00 | 85 | char fts_name[1]; /* file name */ |
4dedc488 KB |
86 | } FTSENT; |
87 | ||
5e24c41d KB |
88 | #include <sys/cdefs.h> |
89 | ||
90 | __BEGIN_DECLS | |
0341aad6 | 91 | FTSENT *fts_children __P((FTS *, int)); |
5e24c41d | 92 | int fts_close __P((FTS *)); |
eb90680d KB |
93 | FTS *fts_open __P((char * const *, int, |
94 | int (*)(const FTSENT **, const FTSENT **))); | |
5e24c41d KB |
95 | FTSENT *fts_read __P((FTS *)); |
96 | int fts_set __P((FTS *, FTSENT *, int)); | |
97 | __END_DECLS | |
d2b7358e KB |
98 | |
99 | #endif /* !_FTS_H_ */ |