1134244Stjr/*	$OpenBSD: ftw.h,v 1.1 2003/07/21 21:13:18 millert Exp $	*/
2134244Stjr
3131661Sdas/*
4134244Stjr * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
5131661Sdas *
6134244Stjr * Permission to use, copy, modify, and distribute this software for any
7134244Stjr * purpose with or without fee is hereby granted, provided that the above
8134244Stjr * copyright notice and this permission notice appear in all copies.
9131661Sdas *
10134244Stjr * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11134244Stjr * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12134244Stjr * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13134244Stjr * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14134244Stjr * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15134244Stjr * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16134244Stjr * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17134244Stjr *
18134244Stjr * Sponsored in part by the Defense Advanced Research Projects
19134244Stjr * Agency (DARPA) and Air Force Research Laboratory, Air Force
20134244Stjr * Materiel Command, USAF, under agreement number F39502-99-1-0512.
21134244Stjr *
22131661Sdas * $FreeBSD$
23131661Sdas */
24131661Sdas
25134244Stjr#ifndef	_FTW_H
26134244Stjr#define	_FTW_H
27131661Sdas
28134244Stjr#include <sys/types.h>
29131661Sdas#include <sys/stat.h>
30131661Sdas
31134244Stjr/*
32134244Stjr * Valid flags for the 3rd argument to the function that is passed as the
33134244Stjr * second argument to ftw(3) and nftw(3).  Say it three times fast!
34134244Stjr */
35134244Stjr#define	FTW_F		0	/* File.  */
36134244Stjr#define	FTW_D		1	/* Directory.  */
37134244Stjr#define	FTW_DNR		2	/* Directory without read permission.  */
38134244Stjr#define	FTW_DP		3	/* Directory with subdirectories visited.  */
39134244Stjr#define	FTW_NS		4	/* Unknown type; stat() failed.  */
40134244Stjr#define	FTW_SL		5	/* Symbolic link.  */
41134244Stjr#define	FTW_SLN		6	/* Sym link that names a nonexistent file.  */
42131661Sdas
43134244Stjr/*
44134244Stjr * Flags for use as the 4th argument to nftw(3).  These may be ORed together.
45134244Stjr */
46134244Stjr#define	FTW_PHYS	0x01	/* Physical walk, don't follow sym links.  */
47134244Stjr#define	FTW_MOUNT	0x02	/* The walk does not cross a mount point.  */
48134244Stjr#define	FTW_DEPTH	0x04	/* Subdirs visited before the dir itself. */
49134244Stjr#define	FTW_CHDIR	0x08	/* Change to a directory before reading it. */
50131661Sdas
51131661Sdasstruct FTW {
52134244Stjr	int base;
53134244Stjr	int level;
54131661Sdas};
55131661Sdas
56134244Stjr__BEGIN_DECLS
57134244Stjrint	ftw(const char *, int (*)(const char *, const struct stat *, int), int);
58134244Stjrint	nftw(const char *, int (*)(const char *, const struct stat *, int,
59134244Stjr	    struct FTW *), int, int);
60131661Sdas__END_DECLS
61131661Sdas
62134244Stjr#endif	/* !_FTW_H */
63