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