00001 /* 00002 * Copyright (c) 1989, 1993 00003 * The Regents of the University of California. All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 4. Neither the name of the University nor the names of its contributors 00014 * may be used to endorse or promote products derived from this software 00015 * without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00018 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00021 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00023 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00024 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00025 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00026 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00027 * SUCH DAMAGE. 00028 * 00029 * @(#)fts.h 8.3 (Berkeley) 8/14/94 00030 */ 00031 00032 #ifndef _FTS_H 00033 #define _FTS_H 1 00034 00035 #if defined(__GLIBC__) 00036 #include <features.h> 00037 #else 00038 00039 # define __THROW 00040 #ifdef __cplusplus 00041 # define __BEGIN_DECLS extern "C" { 00042 # define __END_DECLS } 00043 #else 00044 # define __BEGIN_DECLS 00045 # define __END_DECLS 00046 #endif 00047 00048 #if defined(hpux) 00049 # define _D_EXACT_NAMLEN(d) ((d)->d_namlen) 00050 # define _INCLUDE_POSIX_SOURCE 00051 # define _LARGEFILE64_SOURCE 00052 #endif 00053 00054 #if defined(sun) 00055 # define _D_EXACT_NAMLEN(d) ((d)->d_reclen) 00056 #endif 00057 00058 #endif 00059 00060 #include <sys/types.h> 00061 #include <sys/stat.h> 00062 #include <dirent.h> 00063 00064 typedef struct { 00065 /*@owned@*/ /*@relnull@*/ 00066 struct _ftsent *fts_cur; 00067 /*@owned@*/ /*@null@*/ 00068 struct _ftsent *fts_child; 00069 /*@owned@*/ /*@null@*/ 00070 struct _ftsent **fts_array; 00071 dev_t fts_dev; 00072 /*@owned@*/ /*@relnull@*/ 00073 char *fts_path; 00074 int fts_rfd; 00075 int fts_pathlen; 00076 int fts_nitems; 00077 /*@null@*/ 00078 int (*fts_compar) (const void *, const void *) 00079 /*@*/; 00081 DIR * (*fts_opendir) (const char * path) 00082 /*@globals fileSystem @*/ 00083 /*@modifies fileSystem @*/; 00084 struct dirent * (*fts_readdir) (DIR * dir) 00085 /*@globals fileSystem @*/ 00086 /*@modifies *dir, fileSystem @*/; 00087 int (*fts_closedir) (/*@only@*/ DIR * dir) 00088 /*@globals fileSystem @*/ 00089 /*@modifies *dir, fileSystem @*/; 00090 int (*fts_stat) (const char * path, /*@out@*/ struct stat * st) 00091 /*@globals fileSystem @*/ 00092 /*@modifies *st, fileSystem @*/; 00093 int (*fts_lstat) (const char * path, /*@out@*/ struct stat * st) 00094 /*@globals fileSystem @*/ 00095 /*@modifies *st, fileSystem @*/; 00096 00097 #define FTS_COMFOLLOW 0x0001 00098 #define FTS_LOGICAL 0x0002 00099 #define FTS_NOCHDIR 0x0004 00100 #define FTS_NOSTAT 0x0008 00101 #define FTS_PHYSICAL 0x0010 00102 #define FTS_SEEDOT 0x0020 00103 #define FTS_XDEV 0x0040 00104 #define FTS_WHITEOUT 0x0080 00105 #define FTS_OPTIONMASK 0x00ff 00107 #define FTS_NAMEONLY 0x0100 00108 #define FTS_STOP 0x0200 00109 int fts_options; 00110 } FTS; 00111 00112 typedef struct _ftsent { 00113 /*@dependent@*/ 00114 struct _ftsent *fts_cycle; 00115 /*@dependent@*/ /*@relnull@*/ 00116 struct _ftsent *fts_parent; 00117 /*@dependent@*/ /*@null@*/ 00118 struct _ftsent *fts_link; 00119 long fts_number; 00120 /*@null@*/ 00121 void *fts_pointer; 00122 /*@dependent@*/ 00123 char *fts_accpath; 00124 /*@dependent@*/ 00125 char *fts_path; 00126 int fts_errno; 00127 int fts_symfd; 00128 u_short fts_pathlen; 00129 u_short fts_namelen; 00131 ino_t fts_ino; 00132 dev_t fts_dev; 00133 nlink_t fts_nlink; 00135 #define FTS_ROOTPARENTLEVEL -1 00136 #define FTS_ROOTLEVEL 0 00137 short fts_level; 00139 #define FTS_D 1 00140 #define FTS_DC 2 00141 #define FTS_DEFAULT 3 00142 #define FTS_DNR 4 00143 #define FTS_DOT 5 00144 #define FTS_DP 6 00145 #define FTS_ERR 7 00146 #define FTS_F 8 00147 #define FTS_INIT 9 00148 #define FTS_NS 10 00149 #define FTS_NSOK 11 00150 #define FTS_SL 12 00151 #define FTS_SLNONE 13 00152 #define FTS_W 14 00153 u_short fts_info; 00155 #define FTS_DONTCHDIR 0x01 00156 #define FTS_SYMFOLLOW 0x02 00157 u_short fts_flags; 00159 #define FTS_AGAIN 1 00160 #define FTS_FOLLOW 2 00161 #define FTS_NOINSTR 3 00162 #define FTS_SKIP 4 00163 u_short fts_instr; 00165 /*@dependent@*/ 00166 struct stat *fts_statp; 00167 char fts_name[1]; 00168 } FTSENT; 00169 00170 __BEGIN_DECLS 00171 00178 /*@dependent@*/ /*@null@*/ 00179 FTSENT *Fts_children (FTS * sp, int instr) __THROW 00180 /*@globals fileSystem, internalState @*/ 00181 /*@modifies *sp, fileSystem, internalState @*/; 00182 00188 int Fts_close (/*@only@*/ /*@null@*/ FTS * sp) __THROW 00189 /*@globals fileSystem, internalState @*/ 00190 /*@modifies *sp, fileSystem, internalState @*/; 00191 00199 /*@only@*/ /*@null@*/ 00200 FTS *Fts_open (char * const * argv, int options, 00201 /*@null@*/ 00202 int (*compar) (const FTSENT **, const FTSENT **)) __THROW 00203 /*@*/; 00204 00210 /*@null@*/ 00211 FTSENT *Fts_read (/*@null@*/ FTS * sp) __THROW 00212 /*@globals fileSystem, internalState @*/ 00213 /*@modifies *sp, fileSystem, internalState @*/; 00214 00222 int Fts_set (FTS * sp, FTSENT * p, int instr) __THROW 00223 /*@modifies *p @*/; 00224 00225 __END_DECLS 00226 00227 #endif /* fts.h */