From f5061b180458bee93d9f6a01153366b43ef81df9 Mon Sep 17 00:00:00 2001 From: millert <> Date: Mon, 21 Jul 2003 21:13:18 +0000 Subject: [PATCH] Need ftw.h for ftw(3) and nftw(3) --- src/include/Makefile | 20 +++++++-------- src/include/ftw.h | 60 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 src/include/ftw.h diff --git a/src/include/Makefile b/src/include/Makefile index 89d7eac6..7f2818f4 100644 --- a/src/include/Makefile +++ b/src/include/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.120 2003/07/15 19:18:00 deraadt Exp $ +# $OpenBSD: Makefile,v 1.121 2003/07/21 21:13:18 millert Exp $ # $NetBSD: Makefile,v 1.59 1996/05/15 21:36:43 jtc Exp $ # @(#)Makefile 5.45.1.1 (Berkeley) 5/6/91 @@ -10,15 +10,15 @@ FILES= a.out.h ar.h assert.h bitstring.h blf.h bm.h bsd_auth.h cast.h \ cpio.h ctype.h curses.h db.h dbm.h des.h dirent.h disktab.h \ - dlfcn.h elf_abi.h err.h fnmatch.h fstab.h fts.h getopt.h glob.h grp.h \ - ifaddrs.h inttypes.h iso646.h kvm.h langinfo.h libgen.h limits.h \ - locale.h login_cap.h malloc.h math.h md4.h md5.h memory.h mpool.h \ - ndbm.h netdb.h netgroup.h nlist.h nl_types.h ohash.h olf_abi.h \ - paths.h poll.h pwd.h ranlib.h re_comp.h readpassphrase.h regex.h \ - resolv.h rmd160.h search.h setjmp.h sgtty.h sha1.h sha2.h skipjack.h \ - signal.h stab.h stdbool.h stddef.h stdio.h stdlib.h string.h \ - strings.h struct.h sysexits.h tar.h time.h ttyent.h tzfile.h \ - unistd.h utime.h utmp.h vis.h + dlfcn.h elf_abi.h err.h fnmatch.h fstab.h fts.h ftw.h getopt.h \ + glob.h grp.h ifaddrs.h inttypes.h iso646.h kvm.h langinfo.h \ + libgen.h limits.h locale.h login_cap.h malloc.h math.h md4.h \ + md5.h memory.h mpool.h ndbm.h netdb.h netgroup.h nlist.h nl_types.h \ + ohash.h olf_abi.h paths.h poll.h pwd.h ranlib.h re_comp.h \ + readpassphrase.h regex.h resolv.h rmd160.h search.h setjmp.h \ + sgtty.h sha1.h sha2.h skipjack.h signal.h stab.h stdbool.h stddef.h \ + stdio.h stdlib.h string.h strings.h struct.h sysexits.h tar.h \ + time.h ttyent.h tzfile.h unistd.h utime.h utmp.h vis.h FILES+= link.h link_aout.h link_elf.h diff --git a/src/include/ftw.h b/src/include/ftw.h new file mode 100644 index 00000000..1601ad2b --- /dev/null +++ b/src/include/ftw.h @@ -0,0 +1,60 @@ +/* $OpenBSD: ftw.h,v 1.1 2003/07/21 21:13:18 millert Exp $ */ + +/* + * Copyright (c) 2003 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F39502-99-1-0512. + */ + +#ifndef _FTW_H +#define _FTW_H + +#include +#include + +/* + * Valid flags for the 3rd argument to the function that is passed as the + * second argument to ftw(3) and nftw(3). Say it three times fast! + */ +#define FTW_F 0 /* File. */ +#define FTW_D 1 /* Directory. */ +#define FTW_DNR 2 /* Directory without read permission. */ +#define FTW_DP 3 /* Directory with subdirectories visited. */ +#define FTW_NS 4 /* Unknown type; stat() failed. */ +#define FTW_SL 5 /* Symbolic link. */ +#define FTW_SLN 6 /* Sym link that names a nonexistent file. */ + +/* + * Flags for use as the 4th argument to nftw(3). These may be ORed together. + */ +#define FTW_PHYS 0x01 /* Physical walk, don't follow sym links. */ +#define FTW_MOUNT 0x02 /* The walk does not cross a mount point. */ +#define FTW_DEPTH 0x04 /* Subdirs visited before the dir itself. */ +#define FTW_CHDIR 0x08 /* Change to a directory before reading it. */ + +struct FTW { + int base; + int level; +}; + +__BEGIN_DECLS +int ftw(const char *, int (*)(const char *, const struct stat *, int), int); +int nftw(const char *, int (*)(const char *, const struct stat *, int, + struct FTW *), int, int); +__END_DECLS + +#endif /* !_FTW_H */