1 /*
2 * Copyright © 2005-2020 Rich Felker, et al.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 
24 #ifndef _FTW_H
25 #define	_FTW_H
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #include <sys/features.h>
32 #include <sys/stat.h>
33 
34 /*
35  * Valid flags for the 3rd argument to the function that is passed as the
36  * second argument to ftw(3) and nftw(3).  Say it three times fast!
37  */
38 #define	FTW_F		0	/* File.  */
39 #define	FTW_D		1	/* Directory.  */
40 #define	FTW_DNR		2	/* Directory without read permission.  */
41 #define	FTW_DP		3	/* Directory with subdirectories visited.  */
42 #define	FTW_NS		4	/* Unknown type; stat() failed.  */
43 #define	FTW_SL		5	/* Symbolic link.  */
44 #define	FTW_SLN		6	/* Sym link that names a nonexistent file.  */
45 
46 /*
47  * Flags for use as the 4th argument to nftw(3).  These may be ORed together.
48  */
49 #define	FTW_PHYS	0x01	/* Physical walk, don't follow sym links.  */
50 #define	FTW_MOUNT	0x02	/* The walk does not cross a mount point.  */
51 #define	FTW_DEPTH	0x04	/* Subdirs visited before the dir itself. */
52 #define	FTW_CHDIR	0x08	/* Change to a directory before reading it. */
53 
54 struct FTW {
55 	int base;
56 	int level;
57 };
58 
59 int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
60 int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *), int, int);
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif
67