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 | * |
23e61c79 | 7 | * @(#)fts.h 5.7 (Berkeley) %G% |
4dedc488 KB |
8 | */ |
9 | ||
10 | typedef struct fts { | |
762bfe00 KB |
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 */ |
5eb92891 | 17 | int fts_sd; /* starting directory */ |
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 | ||
31 | typedef struct ftsent { | |
762bfe00 KB |
32 | struct ftsent *fts_parent; /* parent directory */ |
33 | struct ftsent *fts_link; /* next/cycle node */ | |
4dedc488 KB |
34 | union { |
35 | long number; /* local numeric value */ | |
36 | void *pointer; /* local address value */ | |
762bfe00 KB |
37 | } fts_local; |
38 | char *fts_accpath; /* path from current directory */ | |
39 | char *fts_path; /* path from starting directory */ | |
40 | short fts_pathlen; /* strlen(path) */ | |
41 | short fts_namelen; /* strlen(name) */ | |
42 | short fts_level; /* depth (-1 to N) */ | |
4dedc488 KB |
43 | #define FTS_D 1 /* preorder directory */ |
44 | #define FTS_DC 2 /* directory that causes cycles */ | |
45 | #define FTS_DNR 3 /* unreadable directory */ | |
46 | #define FTS_DNX 4 /* unsearchable directory */ | |
47 | #define FTS_DP 5 /* postorder directory */ | |
48 | #define FTS_ERR 6 /* error; errno is set */ | |
49 | #define FTS_F 7 /* regular file */ | |
50 | #define FTS_NS 8 /* no stat(2) information */ | |
51 | #define FTS_SL 9 /* symbolic link */ | |
52 | #define FTS_SLNONE 10 /* symbolic link without target */ | |
53 | #define FTS_DEFAULT 11 /* none of the above */ | |
762bfe00 | 54 | u_short fts_info; /* file information */ |
4dedc488 KB |
55 | #define FTS_AGAIN 1 /* user: read node again */ |
56 | #define FTS_SKIP 2 /* user: discard node */ | |
57 | #define FTS_FOLLOW 3 /* user: follow symbolic link */ | |
762bfe00 KB |
58 | short fts_instr; /* setfts() instructions */ |
59 | struct stat fts_statb; /* stat(2) information */ | |
60 | char fts_name[1]; /* file name */ | |
4dedc488 KB |
61 | } FTSENT; |
62 | ||
6670c0eb | 63 | #if __STDC__ || c_plusplus |
762bfe00 KB |
64 | extern FTS *ftsopen(const char **, int, int (*)(const FTSENT *, const FTSENT *); |
65 | extern FTSENT *ftsread(FTS *); | |
66 | extern FTSENT *ftschildren(FTS *); | |
67 | extern int ftsset(FTS *, FTSENT *, int); | |
68 | extern int ftsclose(FTS *); | |
69 | #else | |
70 | extern FTS *ftsopen(); | |
71 | extern FTSENT *ftschildren(), *ftsread(); | |
72 | extern int ftsclose(), ftsset(); | |
73 | #endif |