util: Add file tree walk interface
[Samba.git] / lib / util / tftw.h
blob0d3d007ad3b0ca7e1a22ecd290aeef240df0bb1c
1 #include <talloc.h>
3 enum tftw_flags_e {
4 /* Regular file. */
5 TFTW_FLAG_FILE,
6 /* Directory. */
7 TFTW_FLAG_DIR,
8 /* Unreadable directory. */
9 TFTW_FLAG_DNR,
10 /* Unstatable file. */
11 TFTW_FLAG_NSTAT,
12 /* Symbolic link. */
13 TFTW_FLAG_SLINK,
14 /* Special file (fifo, ...). */
15 TFTW_FLAG_SPEC,
17 /* Directory, all subdirs have been visited. */
18 TFTW_FLAG_DP,
19 /* Symbolic link naming non-existing file. */
20 TFTW_FLAG_SLN
23 /* Maximum number of subdirectories to descend into */
24 #define TFTW_MAX_DEPTH 50
26 typedef int (*tftw_walker_fn)(TALLOC_CTX *mem_ctx,
27 const char *fpath,
28 const struct stat *sb,
29 enum tftw_flags_e flag,
30 void *userdata);
32 int tftw(TALLOC_CTX *mem_ctx, const char *fpath, tftw_walker_fn fn, size_t depth, void *userdata);