1*18e528e7Smillert /* $OpenBSD: fts.h,v 1.6 2001/05/15 21:14:37 millert Exp $ */ 2df930be7Sderaadt /* $NetBSD: fts.h,v 1.5 1994/12/28 01:41:50 mycroft Exp $ */ 3df930be7Sderaadt 4df930be7Sderaadt /* 5df930be7Sderaadt * Copyright (c) 1989, 1993 6df930be7Sderaadt * The Regents of the University of California. All rights reserved. 7df930be7Sderaadt * 8df930be7Sderaadt * Redistribution and use in source and binary forms, with or without 9df930be7Sderaadt * modification, are permitted provided that the following conditions 10df930be7Sderaadt * are met: 11df930be7Sderaadt * 1. Redistributions of source code must retain the above copyright 12df930be7Sderaadt * notice, this list of conditions and the following disclaimer. 13df930be7Sderaadt * 2. Redistributions in binary form must reproduce the above copyright 14df930be7Sderaadt * notice, this list of conditions and the following disclaimer in the 15df930be7Sderaadt * documentation and/or other materials provided with the distribution. 16df930be7Sderaadt * 3. All advertising materials mentioning features or use of this software 17df930be7Sderaadt * must display the following acknowledgement: 18df930be7Sderaadt * This product includes software developed by the University of 19df930be7Sderaadt * California, Berkeley and its contributors. 20df930be7Sderaadt * 4. Neither the name of the University nor the names of its contributors 21df930be7Sderaadt * may be used to endorse or promote products derived from this software 22df930be7Sderaadt * without specific prior written permission. 23df930be7Sderaadt * 24df930be7Sderaadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25df930be7Sderaadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26df930be7Sderaadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27df930be7Sderaadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28df930be7Sderaadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29df930be7Sderaadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30df930be7Sderaadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31df930be7Sderaadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32df930be7Sderaadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33df930be7Sderaadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34df930be7Sderaadt * SUCH DAMAGE. 35df930be7Sderaadt * 36df930be7Sderaadt * @(#)fts.h 8.3 (Berkeley) 8/14/94 37df930be7Sderaadt */ 38df930be7Sderaadt 39df930be7Sderaadt #ifndef _FTS_H_ 40df930be7Sderaadt #define _FTS_H_ 41df930be7Sderaadt 42df930be7Sderaadt typedef struct { 43df930be7Sderaadt struct _ftsent *fts_cur; /* current node */ 44df930be7Sderaadt struct _ftsent *fts_child; /* linked list of children */ 45df930be7Sderaadt struct _ftsent **fts_array; /* sort array */ 46df930be7Sderaadt dev_t fts_dev; /* starting device # */ 47df930be7Sderaadt char *fts_path; /* path for this descent */ 48df930be7Sderaadt int fts_rfd; /* fd for root */ 49*18e528e7Smillert size_t fts_pathlen; /* sizeof(path) */ 50df930be7Sderaadt int fts_nitems; /* elements in the sort array */ 51df930be7Sderaadt int (*fts_compar)(); /* compare function */ 52df930be7Sderaadt 53bc8371e6Smillert #define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */ 54bc8371e6Smillert #define FTS_LOGICAL 0x0002 /* logical walk */ 55bc8371e6Smillert #define FTS_NOCHDIR 0x0004 /* don't change directories */ 56bc8371e6Smillert #define FTS_NOSTAT 0x0008 /* don't get stat info */ 57bc8371e6Smillert #define FTS_PHYSICAL 0x0010 /* physical walk */ 58bc8371e6Smillert #define FTS_SEEDOT 0x0020 /* return dot and dot-dot */ 59bc8371e6Smillert #define FTS_XDEV 0x0040 /* don't cross devices */ 60bc8371e6Smillert #define FTS_WHITEOUT 0x0080 /* return whiteout information */ 61*18e528e7Smillert #define FTS_OPTIONMASK 0x00ff /* valid user option mask */ 62df930be7Sderaadt 63bc8371e6Smillert #define FTS_NAMEONLY 0x1000 /* (private) child names only */ 64bc8371e6Smillert #define FTS_STOP 0x2000 /* (private) unrecoverable error */ 65df930be7Sderaadt int fts_options; /* fts_open options, global flags */ 66df930be7Sderaadt } FTS; 67df930be7Sderaadt 68df930be7Sderaadt typedef struct _ftsent { 69df930be7Sderaadt struct _ftsent *fts_cycle; /* cycle node */ 70df930be7Sderaadt struct _ftsent *fts_parent; /* parent directory */ 71df930be7Sderaadt struct _ftsent *fts_link; /* next file in directory */ 72df930be7Sderaadt long fts_number; /* local numeric value */ 73df930be7Sderaadt void *fts_pointer; /* local address value */ 74df930be7Sderaadt char *fts_accpath; /* access path */ 75df930be7Sderaadt char *fts_path; /* root path */ 76df930be7Sderaadt int fts_errno; /* errno for this node */ 77df930be7Sderaadt int fts_symfd; /* fd for symlink */ 78*18e528e7Smillert size_t fts_pathlen; /* strlen(fts_path) */ 79*18e528e7Smillert size_t fts_namelen; /* strlen(fts_name) */ 80df930be7Sderaadt 81df930be7Sderaadt ino_t fts_ino; /* inode */ 82df930be7Sderaadt dev_t fts_dev; /* device */ 83df930be7Sderaadt nlink_t fts_nlink; /* link count */ 84df930be7Sderaadt 85df930be7Sderaadt #define FTS_ROOTPARENTLEVEL -1 86df930be7Sderaadt #define FTS_ROOTLEVEL 0 87df930be7Sderaadt short fts_level; /* depth (-1 to N) */ 88df930be7Sderaadt 89df930be7Sderaadt #define FTS_D 1 /* preorder directory */ 90df930be7Sderaadt #define FTS_DC 2 /* directory that causes cycles */ 91df930be7Sderaadt #define FTS_DEFAULT 3 /* none of the above */ 92df930be7Sderaadt #define FTS_DNR 4 /* unreadable directory */ 93df930be7Sderaadt #define FTS_DOT 5 /* dot or dot-dot */ 94df930be7Sderaadt #define FTS_DP 6 /* postorder directory */ 95df930be7Sderaadt #define FTS_ERR 7 /* error; errno is set */ 96df930be7Sderaadt #define FTS_F 8 /* regular file */ 97df930be7Sderaadt #define FTS_INIT 9 /* initialized only */ 98df930be7Sderaadt #define FTS_NS 10 /* stat(2) failed */ 99df930be7Sderaadt #define FTS_NSOK 11 /* no stat(2) requested */ 100df930be7Sderaadt #define FTS_SL 12 /* symbolic link */ 101df930be7Sderaadt #define FTS_SLNONE 13 /* symbolic link without target */ 102df930be7Sderaadt #define FTS_W 14 /* whiteout object */ 103df930be7Sderaadt u_short fts_info; /* user flags for FTSENT structure */ 104df930be7Sderaadt 105df930be7Sderaadt #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ 106df930be7Sderaadt #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ 107df930be7Sderaadt #define FTS_ISW 0x04 /* this is a whiteout object */ 108df930be7Sderaadt u_short fts_flags; /* private flags for FTSENT structure */ 109df930be7Sderaadt 110df930be7Sderaadt #define FTS_AGAIN 1 /* read node again */ 111df930be7Sderaadt #define FTS_FOLLOW 2 /* follow symbolic link */ 112df930be7Sderaadt #define FTS_NOINSTR 3 /* no instructions */ 113df930be7Sderaadt #define FTS_SKIP 4 /* discard node */ 114df930be7Sderaadt u_short fts_instr; /* fts_set() instructions */ 115df930be7Sderaadt 116df930be7Sderaadt struct stat *fts_statp; /* stat(2) information */ 117df930be7Sderaadt char fts_name[1]; /* file name */ 118df930be7Sderaadt } FTSENT; 119df930be7Sderaadt 120df930be7Sderaadt #include <sys/cdefs.h> 121df930be7Sderaadt 122df930be7Sderaadt __BEGIN_DECLS 123df930be7Sderaadt FTSENT *fts_children __P((FTS *, int)); 124df930be7Sderaadt int fts_close __P((FTS *)); 125df930be7Sderaadt FTS *fts_open __P((char * const *, int, 126df930be7Sderaadt int (*)(const FTSENT **, const FTSENT **))); 127df930be7Sderaadt FTSENT *fts_read __P((FTS *)); 128df930be7Sderaadt int fts_set __P((FTS *, FTSENT *, int)); 129df930be7Sderaadt __END_DECLS 130df930be7Sderaadt 131df930be7Sderaadt #endif /* !_FTS_H_ */ 132