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