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 | * |
e9855bb8 | 7 | * @(#)fts.h 5.11 (Berkeley) %G% |
4dedc488 KB |
8 | */ |
9 | ||
e5f81e84 KB |
10 | typedef struct { |
11 | struct _ftsent *fts_cur; /* current node */ | |
12 | struct _ftsent *fts_child; /* linked list of children */ | |
13 | struct _ftsent *fts_savelink; /* saved link if node had a cycle */ | |
14 | struct _ftsent **fts_array; /* sort array */ | |
53feaac1 | 15 | dev_t sdev; /* starting device # */ |
762bfe00 | 16 | char *fts_path; /* path for this descent */ |
e5f81e84 | 17 | int fts_sd; /* fd for root */ |
762bfe00 KB |
18 | int fts_pathlen; /* sizeof(path) */ |
19 | int fts_nitems; /* elements in the sort array */ | |
20 | int (*fts_compar)(); /* compare function */ | |
4dedc488 KB |
21 | #define FTS__STOP 0x001 /* private: unrecoverable error */ |
22 | #define FTS_LOGICAL 0x002 /* user: use stat(2) */ | |
23e61c79 KB |
23 | #define FTS_NOCHDIR 0x004 /* user: don't use chdir(2) */ |
24 | #define FTS_NOSTAT 0x008 /* user: don't require stat info */ | |
25 | #define FTS_PHYSICAL 0x010 /* user: use lstat(2) */ | |
26 | #define FTS_SEEDOT 0x020 /* user: return dot and dot-dot */ | |
27 | #define FTS_XDEV 0x040 /* user: don't cross devices */ | |
762bfe00 | 28 | int fts_options; /* openfts() options */ |
4dedc488 KB |
29 | } FTS; |
30 | ||
e5f81e84 KB |
31 | typedef struct _ftsent { |
32 | struct _ftsent *fts_parent; /* parent directory */ | |
33 | struct _ftsent *fts_link; /* cycle or next file structure */ | |
4dedc488 KB |
34 | union { |
35 | long number; /* local numeric value */ | |
36 | void *pointer; /* local address value */ | |
762bfe00 | 37 | } fts_local; |
e5f81e84 KB |
38 | #define fts_number fts_local.number |
39 | #define fts_pointer fts_local.pointer | |
40 | char *fts_accpath; /* access path */ | |
41 | char *fts_path; /* root path */ | |
42 | short fts_pathlen; /* strlen(fts_path) */ | |
43 | short fts_namelen; /* strlen(fts_name) */ | |
762bfe00 | 44 | short fts_level; /* depth (-1 to N) */ |
4dedc488 KB |
45 | #define FTS_D 1 /* preorder directory */ |
46 | #define FTS_DC 2 /* directory that causes cycles */ | |
47 | #define FTS_DNR 3 /* unreadable directory */ | |
48 | #define FTS_DNX 4 /* unsearchable directory */ | |
49 | #define FTS_DP 5 /* postorder directory */ | |
50 | #define FTS_ERR 6 /* error; errno is set */ | |
51 | #define FTS_F 7 /* regular file */ | |
52 | #define FTS_NS 8 /* no stat(2) information */ | |
53 | #define FTS_SL 9 /* symbolic link */ | |
54 | #define FTS_SLNONE 10 /* symbolic link without target */ | |
55 | #define FTS_DEFAULT 11 /* none of the above */ | |
e5f81e84 KB |
56 | u_short fts_info; /* flags for FTSENT structure */ |
57 | #define FTS__NOINSTR 0 /* private: no instructions */ | |
4dedc488 KB |
58 | #define FTS_AGAIN 1 /* user: read node again */ |
59 | #define FTS_SKIP 2 /* user: discard node */ | |
60 | #define FTS_FOLLOW 3 /* user: follow symbolic link */ | |
e5f81e84 | 61 | short fts_instr; /* private: fts_set() instructions */ |
762bfe00 KB |
62 | struct stat fts_statb; /* stat(2) information */ |
63 | char fts_name[1]; /* file name */ | |
4dedc488 KB |
64 | } FTSENT; |
65 | ||
5e24c41d KB |
66 | #include <sys/cdefs.h> |
67 | ||
68 | __BEGIN_DECLS | |
69 | FTSENT *fts_children __P((FTS *)); | |
70 | int fts_close __P((FTS *)); | |
71 | FTS *fts_open | |
e9855bb8 | 72 | __P((char * const *, int, int (*)(const FTSENT *, const FTSENT *))); |
5e24c41d KB |
73 | FTSENT *fts_read __P((FTS *)); |
74 | int fts_set __P((FTS *, FTSENT *, int)); | |
75 | __END_DECLS |