1fec65c98Schristos /* $OpenBSD: fts.h,v 1.14 2012/12/05 23:19:57 deraadt Exp $ */ 29ff1f2acSchristos /* NetBSD: fts.h,v 1.7 2012/03/01 16:18:51 hans Exp */ 3fec65c98Schristos 4fec65c98Schristos /* 5fec65c98Schristos * Copyright (c) 1989, 1993 6fec65c98Schristos * The Regents of the University of California. All rights reserved. 7fec65c98Schristos * 8fec65c98Schristos * Redistribution and use in source and binary forms, with or without 9fec65c98Schristos * modification, are permitted provided that the following conditions 10fec65c98Schristos * are met: 11fec65c98Schristos * 1. Redistributions of source code must retain the above copyright 12fec65c98Schristos * notice, this list of conditions and the following disclaimer. 13fec65c98Schristos * 2. Redistributions in binary form must reproduce the above copyright 14fec65c98Schristos * notice, this list of conditions and the following disclaimer in the 15fec65c98Schristos * documentation and/or other materials provided with the distribution. 16fec65c98Schristos * 3. Neither the name of the University nor the names of its contributors 17fec65c98Schristos * may be used to endorse or promote products derived from this software 18fec65c98Schristos * without specific prior written permission. 19fec65c98Schristos * 20fec65c98Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21fec65c98Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22fec65c98Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23fec65c98Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24fec65c98Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25fec65c98Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26fec65c98Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27fec65c98Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28fec65c98Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29fec65c98Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30fec65c98Schristos * SUCH DAMAGE. 31fec65c98Schristos * 32fec65c98Schristos * @(#)fts.h 8.3 (Berkeley) 8/14/94 33fec65c98Schristos */ 34fec65c98Schristos 35fec65c98Schristos #ifndef _FTS_H_ 36fec65c98Schristos #define _FTS_H_ 37fec65c98Schristos 38fec65c98Schristos typedef struct { 39fec65c98Schristos struct _ftsent *fts_cur; /* current node */ 40fec65c98Schristos struct _ftsent *fts_child; /* linked list of children */ 41*9508192eSchristos struct _ftsent **fts_array; /* sort array */ 42fec65c98Schristos dev_t fts_dev; /* starting device # */ 43fec65c98Schristos char *fts_path; /* path for this descent */ 44fec65c98Schristos size_t fts_pathlen; /* sizeof(path) */ 45*9508192eSchristos int fts_nitems; /* elements in the sort array */ 46*9508192eSchristos int (*fts_compar)(); /* compare function */ 47fec65c98Schristos 48fec65c98Schristos #define FTS_NOCHDIR 0x0004 /* don't change directories */ 49fec65c98Schristos #define FTS_PHYSICAL 0x0010 /* physical walk */ 50fec65c98Schristos #define FTS_XDEV 0x0040 /* don't cross devices */ 519ff1f2acSchristos #define FTS_OPTIONMASK 0x0054 /* valid user option mask */ 52fec65c98Schristos 53fec65c98Schristos #define FTS_STOP 0x2000 /* (private) unrecoverable error */ 54fec65c98Schristos int fts_options; /* fts_open options, global flags */ 55fec65c98Schristos } FTS; 56fec65c98Schristos 57fec65c98Schristos typedef struct _ftsent { 58fec65c98Schristos struct _ftsent *fts_cycle; /* cycle node */ 59fec65c98Schristos struct _ftsent *fts_parent; /* parent directory */ 60fec65c98Schristos struct _ftsent *fts_link; /* next file in directory */ 61fec65c98Schristos char *fts_accpath; /* access path */ 62fec65c98Schristos char *fts_path; /* root path */ 63fec65c98Schristos int fts_errno; /* errno for this node */ 64fec65c98Schristos size_t fts_pathlen; /* strlen(fts_path) */ 65fec65c98Schristos size_t fts_namelen; /* strlen(fts_name) */ 66fec65c98Schristos 67fec65c98Schristos ino_t fts_ino; /* inode */ 68fec65c98Schristos dev_t fts_dev; /* device */ 69fec65c98Schristos nlink_t fts_nlink; /* link count */ 70fec65c98Schristos 71fec65c98Schristos #define FTS_ROOTPARENTLEVEL -1 72fec65c98Schristos #define FTS_ROOTLEVEL 0 73fec65c98Schristos #define FTS_MAXLEVEL 0x7fffffff 74fec65c98Schristos int fts_level; /* depth (-1 to N) */ 75fec65c98Schristos 76fec65c98Schristos #define FTS_D 1 /* preorder directory */ 77fec65c98Schristos #define FTS_DC 2 /* directory that causes cycles */ 78fec65c98Schristos #define FTS_DEFAULT 3 /* none of the above */ 79fec65c98Schristos #define FTS_DNR 4 /* unreadable directory */ 80fec65c98Schristos #define FTS_DOT 5 /* dot or dot-dot */ 81fec65c98Schristos #define FTS_DP 6 /* postorder directory */ 82fec65c98Schristos #define FTS_ERR 7 /* error; errno is set */ 83fec65c98Schristos #define FTS_F 8 /* regular file */ 84fec65c98Schristos #define FTS_INIT 9 /* initialized only */ 85fec65c98Schristos #define FTS_NS 10 /* stat(2) failed */ 86fec65c98Schristos #define FTS_NSOK 11 /* no stat(2) requested */ 87fec65c98Schristos #define FTS_SL 12 /* symbolic link */ 88fec65c98Schristos unsigned short fts_info; /* user flags for FTSENT structure */ 89fec65c98Schristos 90fec65c98Schristos #define FTS_NOINSTR 3 /* no instructions */ 91fec65c98Schristos #define FTS_SKIP 4 /* discard node */ 92fec65c98Schristos unsigned short fts_instr; /* fts_set() instructions */ 93fec65c98Schristos 94fec65c98Schristos struct stat *fts_statp; /* stat(2) information */ 95fec65c98Schristos char fts_name[1]; /* file name */ 96fec65c98Schristos } FTSENT; 97fec65c98Schristos 989ff1f2acSchristos 99fec65c98Schristos int fts_close(FTS *); 100*9508192eSchristos FTS *fts_open(char * const *, int, 101*9508192eSchristos int (*)(const FTSENT **, const FTSENT **)); 102fec65c98Schristos FTSENT *fts_read(FTS *); 103fec65c98Schristos int fts_set(FTS *, FTSENT *, int); 104fec65c98Schristos 105fec65c98Schristos #endif /* !_FTS_H_ */ 106