fts.h revision 1539
11539Srgrimes/* 21539Srgrimes * Copyright (c) 1989, 1993 31539Srgrimes * The Regents of the University of California. All rights reserved. 41539Srgrimes * 51539Srgrimes * Redistribution and use in source and binary forms, with or without 61539Srgrimes * modification, are permitted provided that the following conditions 71539Srgrimes * are met: 81539Srgrimes * 1. Redistributions of source code must retain the above copyright 91539Srgrimes * notice, this list of conditions and the following disclaimer. 101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111539Srgrimes * notice, this list of conditions and the following disclaimer in the 121539Srgrimes * documentation and/or other materials provided with the distribution. 131539Srgrimes * 3. All advertising materials mentioning features or use of this software 141539Srgrimes * must display the following acknowledgement: 151539Srgrimes * This product includes software developed by the University of 161539Srgrimes * California, Berkeley and its contributors. 171539Srgrimes * 4. Neither the name of the University nor the names of its contributors 181539Srgrimes * may be used to endorse or promote products derived from this software 191539Srgrimes * without specific prior written permission. 201539Srgrimes * 211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311539Srgrimes * SUCH DAMAGE. 321539Srgrimes * 331539Srgrimes * @(#)fts.h 8.1 (Berkeley) 6/2/93 341539Srgrimes */ 351539Srgrimes 361539Srgrimes#ifndef _FTS_H_ 371539Srgrimes#define _FTS_H_ 381539Srgrimes 391539Srgrimestypedef struct { 401539Srgrimes struct _ftsent *fts_cur; /* current node */ 411539Srgrimes struct _ftsent *fts_child; /* linked list of children */ 421539Srgrimes struct _ftsent **fts_array; /* sort array */ 431539Srgrimes dev_t fts_dev; /* starting device # */ 441539Srgrimes char *fts_path; /* path for this descent */ 451539Srgrimes int fts_rfd; /* fd for root */ 461539Srgrimes int fts_pathlen; /* sizeof(path) */ 471539Srgrimes int fts_nitems; /* elements in the sort array */ 481539Srgrimes int (*fts_compar)(); /* compare function */ 491539Srgrimes 501539Srgrimes#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ 511539Srgrimes#define FTS_LOGICAL 0x002 /* logical walk */ 521539Srgrimes#define FTS_NOCHDIR 0x004 /* don't change directories */ 531539Srgrimes#define FTS_NOSTAT 0x008 /* don't get stat info */ 541539Srgrimes#define FTS_PHYSICAL 0x010 /* physical walk */ 551539Srgrimes#define FTS_SEEDOT 0x020 /* return dot and dot-dot */ 561539Srgrimes#define FTS_XDEV 0x040 /* don't cross devices */ 571539Srgrimes#define FTS_OPTIONMASK 0x07f /* valid user option mask */ 581539Srgrimes 591539Srgrimes#define FTS_NAMEONLY 0x080 /* (private) child names only */ 601539Srgrimes#define FTS_STOP 0x100 /* (private) unrecoverable error */ 611539Srgrimes int fts_options; /* fts_open options, global flags */ 621539Srgrimes} FTS; 631539Srgrimes 641539Srgrimestypedef struct _ftsent { 651539Srgrimes struct _ftsent *fts_cycle; /* cycle node */ 661539Srgrimes struct _ftsent *fts_parent; /* parent directory */ 671539Srgrimes struct _ftsent *fts_link; /* next file in directory */ 681539Srgrimes long fts_number; /* local numeric value */ 691539Srgrimes void *fts_pointer; /* local address value */ 701539Srgrimes char *fts_accpath; /* access path */ 711539Srgrimes char *fts_path; /* root path */ 721539Srgrimes int fts_errno; /* errno for this node */ 731539Srgrimes int fts_symfd; /* fd for symlink */ 741539Srgrimes u_short fts_pathlen; /* strlen(fts_path) */ 751539Srgrimes u_short fts_namelen; /* strlen(fts_name) */ 761539Srgrimes 771539Srgrimes ino_t fts_ino; /* inode */ 781539Srgrimes dev_t fts_dev; /* device */ 791539Srgrimes nlink_t fts_nlink; /* link count */ 801539Srgrimes 811539Srgrimes#define FTS_ROOTPARENTLEVEL -1 821539Srgrimes#define FTS_ROOTLEVEL 0 831539Srgrimes short fts_level; /* depth (-1 to N) */ 841539Srgrimes 851539Srgrimes#define FTS_D 1 /* preorder directory */ 861539Srgrimes#define FTS_DC 2 /* directory that causes cycles */ 871539Srgrimes#define FTS_DEFAULT 3 /* none of the above */ 881539Srgrimes#define FTS_DNR 4 /* unreadable directory */ 891539Srgrimes#define FTS_DOT 5 /* dot or dot-dot */ 901539Srgrimes#define FTS_DP 6 /* postorder directory */ 911539Srgrimes#define FTS_ERR 7 /* error; errno is set */ 921539Srgrimes#define FTS_F 8 /* regular file */ 931539Srgrimes#define FTS_INIT 9 /* initialized only */ 941539Srgrimes#define FTS_NS 10 /* stat(2) failed */ 951539Srgrimes#define FTS_NSOK 11 /* no stat(2) requested */ 961539Srgrimes#define FTS_SL 12 /* symbolic link */ 971539Srgrimes#define FTS_SLNONE 13 /* symbolic link without target */ 981539Srgrimes u_short fts_info; /* user flags for FTSENT structure */ 991539Srgrimes 1001539Srgrimes#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ 1011539Srgrimes#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ 1021539Srgrimes u_short fts_flags; /* private flags for FTSENT structure */ 1031539Srgrimes 1041539Srgrimes#define FTS_AGAIN 1 /* read node again */ 1051539Srgrimes#define FTS_FOLLOW 2 /* follow symbolic link */ 1061539Srgrimes#define FTS_NOINSTR 3 /* no instructions */ 1071539Srgrimes#define FTS_SKIP 4 /* discard node */ 1081539Srgrimes u_short fts_instr; /* fts_set() instructions */ 1091539Srgrimes 1101539Srgrimes struct stat *fts_statp; /* stat(2) information */ 1111539Srgrimes char fts_name[1]; /* file name */ 1121539Srgrimes} FTSENT; 1131539Srgrimes 1141539Srgrimes#include <sys/cdefs.h> 1151539Srgrimes 1161539Srgrimes__BEGIN_DECLS 1171539SrgrimesFTSENT *fts_children __P((FTS *, int)); 1181539Srgrimesint fts_close __P((FTS *)); 1191539SrgrimesFTS *fts_open __P((char * const *, int, 1201539Srgrimes int (*)(const FTSENT **, const FTSENT **))); 1211539SrgrimesFTSENT *fts_read __P((FTS *)); 1221539Srgrimesint fts_set __P((FTS *, FTSENT *, int)); 1231539Srgrimes__END_DECLS 1241539Srgrimes 1251539Srgrimes#endif /* !_FTS_H_ */ 126