xref: /openbsd/include/ftw.h (revision bf198cc6)
1*bf198cc6Smillert /*	$OpenBSD: ftw.h,v 1.2 2019/01/25 00:19:25 millert Exp $	*/
2e60b1ed4Smillert 
3e60b1ed4Smillert /*
4*bf198cc6Smillert  * Copyright (c) 2003 Todd C. Miller <millert@openbsd.org>
5e60b1ed4Smillert  *
6e60b1ed4Smillert  * Permission to use, copy, modify, and distribute this software for any
7e60b1ed4Smillert  * purpose with or without fee is hereby granted, provided that the above
8e60b1ed4Smillert  * copyright notice and this permission notice appear in all copies.
9e60b1ed4Smillert  *
10e60b1ed4Smillert  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11e60b1ed4Smillert  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12e60b1ed4Smillert  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13e60b1ed4Smillert  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14e60b1ed4Smillert  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15e60b1ed4Smillert  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16e60b1ed4Smillert  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17e60b1ed4Smillert  *
18e60b1ed4Smillert  * Sponsored in part by the Defense Advanced Research Projects
19e60b1ed4Smillert  * Agency (DARPA) and Air Force Research Laboratory, Air Force
20e60b1ed4Smillert  * Materiel Command, USAF, under agreement number F39502-99-1-0512.
21e60b1ed4Smillert  */
22e60b1ed4Smillert 
23e60b1ed4Smillert #ifndef	_FTW_H
24e60b1ed4Smillert #define	_FTW_H
25e60b1ed4Smillert 
26e60b1ed4Smillert #include <sys/types.h>
27e60b1ed4Smillert #include <sys/stat.h>
28e60b1ed4Smillert 
29e60b1ed4Smillert /*
30e60b1ed4Smillert  * Valid flags for the 3rd argument to the function that is passed as the
31e60b1ed4Smillert  * second argument to ftw(3) and nftw(3).  Say it three times fast!
32e60b1ed4Smillert  */
33e60b1ed4Smillert #define	FTW_F		0	/* File.  */
34e60b1ed4Smillert #define	FTW_D		1	/* Directory.  */
35e60b1ed4Smillert #define	FTW_DNR		2	/* Directory without read permission.  */
36e60b1ed4Smillert #define	FTW_DP		3	/* Directory with subdirectories visited.  */
37e60b1ed4Smillert #define	FTW_NS		4	/* Unknown type; stat() failed.  */
38e60b1ed4Smillert #define	FTW_SL		5	/* Symbolic link.  */
39e60b1ed4Smillert #define	FTW_SLN		6	/* Sym link that names a nonexistent file.  */
40e60b1ed4Smillert 
41e60b1ed4Smillert /*
42e60b1ed4Smillert  * Flags for use as the 4th argument to nftw(3).  These may be ORed together.
43e60b1ed4Smillert  */
44e60b1ed4Smillert #define	FTW_PHYS	0x01	/* Physical walk, don't follow sym links.  */
45e60b1ed4Smillert #define	FTW_MOUNT	0x02	/* The walk does not cross a mount point.  */
46e60b1ed4Smillert #define	FTW_DEPTH	0x04	/* Subdirs visited before the dir itself. */
47e60b1ed4Smillert #define	FTW_CHDIR	0x08	/* Change to a directory before reading it. */
48e60b1ed4Smillert 
49e60b1ed4Smillert struct FTW {
50e60b1ed4Smillert 	int base;
51e60b1ed4Smillert 	int level;
52e60b1ed4Smillert };
53e60b1ed4Smillert 
54e60b1ed4Smillert __BEGIN_DECLS
55e60b1ed4Smillert int	ftw(const char *, int (*)(const char *, const struct stat *, int), int);
56e60b1ed4Smillert int	nftw(const char *, int (*)(const char *, const struct stat *, int,
57e60b1ed4Smillert 	    struct FTW *), int, int);
58e60b1ed4Smillert __END_DECLS
59e60b1ed4Smillert 
60e60b1ed4Smillert #endif	/* !_FTW_H */
61