fts.h revision 103726
1178825Sdfr/* 2178825Sdfr * Copyright (c) 1989, 1993 3178825Sdfr * The Regents of the University of California. All rights reserved. 4178825Sdfr * 5233294Sstas * Redistribution and use in source and binary forms, with or without 6233294Sstas * modification, are permitted provided that the following conditions 7178825Sdfr * are met: 8178825Sdfr * 1. Redistributions of source code must retain the above copyright 9178825Sdfr * notice, this list of conditions and the following disclaimer. 10178825Sdfr * 2. Redistributions in binary form must reproduce the above copyright 11178825Sdfr * notice, this list of conditions and the following disclaimer in the 12178825Sdfr * documentation and/or other materials provided with the distribution. 13178825Sdfr * 3. All advertising materials mentioning features or use of this software 14178825Sdfr * must display the following acknowledgement: 15178825Sdfr * This product includes software developed by the University of 16178825Sdfr * California, Berkeley and its contributors. 17178825Sdfr * 4. Neither the name of the University nor the names of its contributors 18178825Sdfr * may be used to endorse or promote products derived from this software 19178825Sdfr * without specific prior written permission. 20178825Sdfr * 21178825Sdfr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22178825Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23178825Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24178825Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25178825Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26178825Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27178825Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28178825Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29178825Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30178825Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31178825Sdfr * SUCH DAMAGE. 32178825Sdfr * 33178825Sdfr * @(#)fts.h 8.3 (Berkeley) 8/14/94 34178825Sdfr * $FreeBSD: head/include/fts.h 103726 2002-09-21 01:28:41Z wollman $ 35178825Sdfr */ 36178825Sdfr 37178825Sdfr#ifndef _FTS_H_ 38178825Sdfr#define _FTS_H_ 39178825Sdfr 40178825Sdfrtypedef struct { 41178825Sdfr struct _ftsent *fts_cur; /* current node */ 42178825Sdfr struct _ftsent *fts_child; /* linked list of children */ 43178825Sdfr struct _ftsent **fts_array; /* sort array */ 44178825Sdfr dev_t fts_dev; /* starting device # */ 45178825Sdfr char *fts_path; /* path for this descent */ 46178825Sdfr int fts_rfd; /* fd for root */ 47178825Sdfr int fts_pathlen; /* sizeof(path) */ 48178825Sdfr int fts_nitems; /* elements in the sort array */ 49178825Sdfr int (*fts_compar) /* compare function */ 50178825Sdfr (const struct _ftsent * const *, const struct _ftsent * const *); 51178825Sdfr 52178825Sdfr#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ 53178825Sdfr#define FTS_LOGICAL 0x002 /* logical walk */ 54178825Sdfr#define FTS_NOCHDIR 0x004 /* don't change directories */ 55178825Sdfr#define FTS_NOSTAT 0x008 /* don't get stat info */ 56178825Sdfr#define FTS_PHYSICAL 0x010 /* physical walk */ 57178825Sdfr#define FTS_SEEDOT 0x020 /* return dot and dot-dot */ 58178825Sdfr#define FTS_XDEV 0x040 /* don't cross devices */ 59178825Sdfr#define FTS_WHITEOUT 0x080 /* return whiteout information */ 60233294Sstas#define FTS_OPTIONMASK 0x0ff /* valid user option mask */ 61233294Sstas 62233294Sstas#define FTS_NAMEONLY 0x100 /* (private) child names only */ 63178825Sdfr#define FTS_STOP 0x200 /* (private) unrecoverable error */ 64178825Sdfr int fts_options; /* fts_open options, global flags */ 65178825Sdfr void *fts_clientptr; /* thunk for sort function */ 66178825Sdfr} FTS; 67178825Sdfr 68178825Sdfrtypedef struct _ftsent { 69178825Sdfr struct _ftsent *fts_cycle; /* cycle node */ 70178825Sdfr struct _ftsent *fts_parent; /* parent directory */ 71178825Sdfr struct _ftsent *fts_link; /* next file in directory */ 72233294Sstas long fts_number; /* local numeric value */ 73233294Sstas void *fts_pointer; /* local address value */ 74233294Sstas char *fts_accpath; /* access path */ 75233294Sstas char *fts_path; /* root path */ 76233294Sstas int fts_errno; /* errno for this node */ 77233294Sstas int fts_symfd; /* fd for symlink */ 78178825Sdfr u_short fts_pathlen; /* strlen(fts_path) */ 79178825Sdfr u_short fts_namelen; /* strlen(fts_name) */ 80178825Sdfr 81233294Sstas ino_t fts_ino; /* inode */ 82233294Sstas dev_t fts_dev; /* device */ 83233294Sstas nlink_t fts_nlink; /* link count */ 84178825Sdfr 85178825Sdfr#define FTS_ROOTPARENTLEVEL -1 86178825Sdfr#define FTS_ROOTLEVEL 0 87178825Sdfr short fts_level; /* depth (-1 to N) */ 88178825Sdfr 89178825Sdfr#define FTS_D 1 /* preorder directory */ 90233294Sstas#define FTS_DC 2 /* directory that causes cycles */ 91233294Sstas#define FTS_DEFAULT 3 /* none of the above */ 92178825Sdfr#define FTS_DNR 4 /* unreadable directory */ 93178825Sdfr#define FTS_DOT 5 /* dot or dot-dot */ 94178825Sdfr#define FTS_DP 6 /* postorder directory */ 95178825Sdfr#define FTS_ERR 7 /* error; errno is set */ 96178825Sdfr#define FTS_F 8 /* regular file */ 97233294Sstas#define FTS_INIT 9 /* initialized only */ 98178825Sdfr#define FTS_NS 10 /* stat(2) failed */ 99178825Sdfr#define FTS_NSOK 11 /* no stat(2) requested */ 100178825Sdfr#define FTS_SL 12 /* symbolic link */ 101178825Sdfr#define FTS_SLNONE 13 /* symbolic link without target */ 102178825Sdfr#define FTS_W 14 /* whiteout object */ 103233294Sstas u_short fts_info; /* user flags for FTSENT structure */ 104233294Sstas 105178825Sdfr#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ 106233294Sstas#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ 107233294Sstas#define FTS_ISW 0x04 /* this is a whiteout object */ 108178825Sdfr u_short fts_flags; /* private flags for FTSENT structure */ 109233294Sstas 110233294Sstas#define FTS_AGAIN 1 /* read node again */ 111233294Sstas#define FTS_FOLLOW 2 /* follow symbolic link */ 112233294Sstas#define FTS_NOINSTR 3 /* no instructions */ 113233294Sstas#define FTS_SKIP 4 /* discard node */ 114233294Sstas u_short fts_instr; /* fts_set() instructions */ 115233294Sstas 116233294Sstas struct stat *fts_statp; /* stat(2) information */ 117233294Sstas char *fts_name; /* file name */ 118233294Sstas FTS *fts_fts; /* back pointer to main FTS */ 119233294Sstas} FTSENT; 120233294Sstas 121233294Sstas#include <sys/cdefs.h> 122233294Sstas 123178825Sdfr__BEGIN_DECLS 124178825SdfrFTSENT *fts_children(FTS *, int); 125178825Sdfrint fts_close(FTS *); 126233294Sstasvoid *fts_get_clientptr(FTS *); 127233294Sstas#define fts_get_clientptr(fts) ((fts)->fts_clientptr) 128233294SstasFTS *fts_get_stream(FTSENT *); 129178825Sdfr#define fts_get_stream(ftsent) ((ftsent)->fts_fts) 130178825SdfrFTS *fts_open(char * const *, int, 131178825Sdfr int (*)(const FTSENT * const *, const FTSENT * const *)); 132178825SdfrFTSENT *fts_read(FTS *); 133178825Sdfrint fts_set(FTS *, FTSENT *, int); 134178825Sdfrvoid fts_set_clientptr(FTS *, void *); 135233294Sstas__END_DECLS 136178825Sdfr 137178825Sdfr#endif /* !_FTS_H_ */ 138178825Sdfr