Commit | Line | Data |
---|---|---|
4dedc488 KB |
1 | /* |
2 | * Copyright (c) 1989 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
1c15e888 C |
5 | * Redistribution and use in source and binary forms are permitted provided |
6 | * that: (1) source distributions retain this entire copyright notice and | |
7 | * comment, and (2) distributions including binaries display the following | |
8 | * acknowledgement: ``This product includes software developed by the | |
9 | * University of California, Berkeley and its contributors'' in the | |
10 | * documentation or other materials provided with the distribution and in | |
11 | * all advertising materials mentioning features or use of this software. | |
12 | * Neither the name of the University nor the names of its contributors may | |
13 | * be used to endorse or promote products derived from this software without | |
14 | * specific prior written permission. | |
15 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED | |
16 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | |
17 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
4dedc488 | 18 | * |
1c15e888 | 19 | * @(#)fts.h 5.8 (Berkeley) 7/1/90 |
4dedc488 KB |
20 | */ |
21 | ||
1c15e888 C |
22 | typedef struct fts { |
23 | struct ftsent *fts_cur; /* current node */ | |
24 | struct ftsent *fts_child; /* linked list of children */ | |
25 | struct ftsent *fts_savelink; /* saved link if node had a cycle */ | |
26 | struct ftsent **fts_array; /* sort array */ | |
53feaac1 | 27 | dev_t sdev; /* starting device # */ |
762bfe00 | 28 | char *fts_path; /* path for this descent */ |
1c15e888 | 29 | int fts_sd; /* starting directory */ |
762bfe00 KB |
30 | int fts_pathlen; /* sizeof(path) */ |
31 | int fts_nitems; /* elements in the sort array */ | |
32 | int (*fts_compar)(); /* compare function */ | |
4dedc488 KB |
33 | #define FTS__STOP 0x001 /* private: unrecoverable error */ |
34 | #define FTS_LOGICAL 0x002 /* user: use stat(2) */ | |
23e61c79 KB |
35 | #define FTS_NOCHDIR 0x004 /* user: don't use chdir(2) */ |
36 | #define FTS_NOSTAT 0x008 /* user: don't require stat info */ | |
37 | #define FTS_PHYSICAL 0x010 /* user: use lstat(2) */ | |
38 | #define FTS_SEEDOT 0x020 /* user: return dot and dot-dot */ | |
39 | #define FTS_XDEV 0x040 /* user: don't cross devices */ | |
762bfe00 | 40 | int fts_options; /* openfts() options */ |
4dedc488 KB |
41 | } FTS; |
42 | ||
1c15e888 C |
43 | typedef struct ftsent { |
44 | struct ftsent *fts_parent; /* parent directory */ | |
45 | struct ftsent *fts_link; /* next/cycle node */ | |
4dedc488 KB |
46 | union { |
47 | long number; /* local numeric value */ | |
48 | void *pointer; /* local address value */ | |
762bfe00 | 49 | } fts_local; |
1c15e888 C |
50 | char *fts_accpath; /* path from current directory */ |
51 | char *fts_path; /* path from starting directory */ | |
52 | short fts_pathlen; /* strlen(path) */ | |
53 | short fts_namelen; /* strlen(name) */ | |
762bfe00 | 54 | short fts_level; /* depth (-1 to N) */ |
4dedc488 KB |
55 | #define FTS_D 1 /* preorder directory */ |
56 | #define FTS_DC 2 /* directory that causes cycles */ | |
57 | #define FTS_DNR 3 /* unreadable directory */ | |
58 | #define FTS_DNX 4 /* unsearchable 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 /* no stat(2) information */ | |
63 | #define FTS_SL 9 /* symbolic link */ | |
64 | #define FTS_SLNONE 10 /* symbolic link without target */ | |
65 | #define FTS_DEFAULT 11 /* none of the above */ | |
1c15e888 | 66 | u_short fts_info; /* file information */ |
4dedc488 KB |
67 | #define FTS_AGAIN 1 /* user: read node again */ |
68 | #define FTS_SKIP 2 /* user: discard node */ | |
69 | #define FTS_FOLLOW 3 /* user: follow symbolic link */ | |
1c15e888 | 70 | short fts_instr; /* setfts() instructions */ |
762bfe00 KB |
71 | struct stat fts_statb; /* stat(2) information */ |
72 | char fts_name[1]; /* file name */ | |
4dedc488 KB |
73 | } FTSENT; |
74 | ||
6670c0eb | 75 | #if __STDC__ || c_plusplus |
1c15e888 C |
76 | extern FTS *ftsopen(const char **, int, int (*)(const FTSENT *, const FTSENT *)); |
77 | extern FTSENT *ftsread(FTS *); | |
78 | extern FTSENT *ftschildren(FTS *); | |
79 | extern int ftsset(FTS *, FTSENT *, int); | |
80 | extern int ftsclose(FTS *); | |
762bfe00 | 81 | #else |
1c15e888 C |
82 | extern FTS *ftsopen(); |
83 | extern FTSENT *ftschildren(), *ftsread(); | |
84 | extern int ftsclose(), ftsset(); | |
762bfe00 | 85 | #endif |