Open SCAP Library
|
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 #include "config.h" 00033 00034 #if !defined(HAVE_FTS_OPEN) 00035 00036 #ifndef _FTS_H 00037 #define _FTS_H 1 00038 00039 00040 #if defined(__GLIBC__) 00041 #include <features.h> 00042 #else 00043 00044 # define __THROW 00045 #ifdef __cplusplus 00046 # define __BEGIN_DECLS extern "C" { 00047 # define __END_DECLS } 00048 #else 00049 # define __BEGIN_DECLS 00050 # define __END_DECLS 00051 #endif 00052 00053 #if defined(hpux) 00054 # define _D_EXACT_NAMLEN(d) ((d)->d_namlen) 00055 # define _INCLUDE_POSIX_SOURCE 00056 # define _LARGEFILE64_SOURCE 00057 #endif 00058 00059 /* This needs to be ifdef SOLARIS */ 00060 #if defined(__SVR4) 00061 # define _D_EXACT_NAMLEN(d) (strlen((d)->d_name)) 00062 # ifndef _INCLUDE_POSIX_SOURCE 00063 # define _INCLUDE_POSIX_SOURCE 00064 # endif 00065 # ifndef _LARGEFILE64_SOURCE 00066 # define _LARGEFILE64_SOURCE 00067 # endif 00068 #endif 00069 00070 #endif 00071 00072 #include <sys/types.h> 00073 #include <sys/stat.h> 00074 #include <dirent.h> 00075 00076 /* The fts interface is incompatible with the LFS interface which 00077 transparently uses the 64-bit file access functions. */ 00078 00079 #ifdef __USE_FILE_OFFSET64 00080 # error "<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64" 00081 #endif 00082 00083 00084 typedef struct { 00085 /*@owned@*/ 00086 struct _ftsent *fts_cur; 00087 /*@owned@*/ /*@null@*/ 00088 struct _ftsent *fts_child; 00089 /*@owned@*/ /*@null@*/ 00090 struct _ftsent **fts_array; 00091 dev_t fts_dev; 00092 /*@owned@*/ 00093 char *fts_path; 00094 int fts_rfd; 00095 int fts_pathlen; 00096 int fts_nitems; 00097 /*@null@*/ 00098 int (*fts_compar) (const void *, const void *) 00099 /*@*/; 00101 DIR * (*fts_opendir) (const char * path) 00102 /*@globals fileSystem @*/ 00103 /*@modifies fileSystem @*/; 00104 struct dirent * (*fts_readdir) (DIR * dir) 00105 /*@globals fileSystem @*/ 00106 /*@modifies *dir, fileSystem @*/; 00107 int (*fts_closedir) (/*@only@*/ DIR * dir) 00108 /*@globals fileSystem @*/ 00109 /*@modifies *dir, fileSystem @*/; 00110 int (*fts_stat) (const char * path, /*@out@*/ struct stat * st) 00111 /*@globals fileSystem @*/ 00112 /*@modifies *st, fileSystem @*/; 00113 int (*fts_lstat) (const char * path, /*@out@*/ struct stat * st) 00114 /*@globals fileSystem @*/ 00115 /*@modifies *st, fileSystem @*/; 00116 00117 #define FTS_COMFOLLOW 0x0001 00118 #define FTS_LOGICAL 0x0002 00119 #define FTS_NOCHDIR 0x0004 00120 #define FTS_NOSTAT 0x0008 00121 #define FTS_PHYSICAL 0x0010 00122 #define FTS_SEEDOT 0x0020 00123 #define FTS_XDEV 0x0040 00124 #define FTS_WHITEOUT 0x0080 00125 #define FTS_OPTIONMASK 0x00ff 00127 #define FTS_NAMEONLY 0x0100 00128 #define FTS_STOP 0x0200 00129 int fts_options; 00130 } FTS; 00131 00132 typedef struct _ftsent { 00133 /*@dependent@*/ 00134 struct _ftsent *fts_cycle; 00135 /*@dependent@*/ 00136 struct _ftsent *fts_parent; 00137 /*@dependent@*/ 00138 struct _ftsent *fts_link; 00139 long fts_number; 00140 void *fts_pointer; 00141 /*@dependent@*/ 00142 char *fts_accpath; 00143 /*@dependent@*/ 00144 char *fts_path; 00145 int fts_errno; 00146 int fts_symfd; 00147 u_short fts_pathlen; 00148 u_short fts_namelen; 00150 ino_t fts_ino; 00151 dev_t fts_dev; 00152 nlink_t fts_nlink; 00154 #define FTS_ROOTPARENTLEVEL -1 00155 #define FTS_ROOTLEVEL 0 00156 short fts_level; 00158 #define FTS_D 1 00159 #define FTS_DC 2 00160 #define FTS_DEFAULT 3 00161 #define FTS_DNR 4 00162 #define FTS_DOT 5 00163 #define FTS_DP 6 00164 #define FTS_ERR 7 00165 #define FTS_F 8 00166 #define FTS_INIT 9 00167 #define FTS_NS 10 00168 #define FTS_NSOK 11 00169 #define FTS_SL 12 00170 #define FTS_SLNONE 13 00171 #define FTS_W 14 00172 u_short fts_info; 00174 #define FTS_DONTCHDIR 0x01 00175 #define FTS_SYMFOLLOW 0x02 00176 u_short fts_flags; 00178 #define FTS_AGAIN 1 00179 #define FTS_FOLLOW 2 00180 #define FTS_NOINSTR 3 00181 #define FTS_SKIP 4 00182 u_short fts_instr; 00184 /*@dependent@*/ 00185 struct stat *fts_statp; 00186 char fts_name[1]; 00187 } FTSENT; 00188 00189 __BEGIN_DECLS 00190 00191 extern int dirfd (DIR * dirp); 00192 00199 /*@unused@*/ /*@dependent@*/ 00200 FTSENT *fts_children (FTS * sp, int instr) __THROW 00201 /*@globals fileSystem, internalState @*/ 00202 /*@modifies *sp, fileSystem, internalState @*/; 00203 00209 /*@unused@*/ 00210 int fts_close (/*@only@*/ FTS * sp) __THROW 00211 /*@globals fileSystem, internalState @*/ 00212 /*@modifies *sp, fileSystem, internalState @*/; 00213 00221 /*@unused@*/ /*@only@*/ 00222 FTS *fts_open (char * const * argv, int options, 00223 /*@null@*/ 00224 int (*compar) (const FTSENT **, const FTSENT **)) __THROW 00225 /*@*/; 00226 00232 /*@unused@*/ /*@null@*/ 00233 FTSENT *fts_read (FTS * sp) __THROW 00234 /*@globals fileSystem, internalState @*/ 00235 /*@modifies *sp, fileSystem, internalState @*/; 00236 00244 /*@unused@*/ 00245 int fts_set (FTS * sp, FTSENT * p, int instr) __THROW 00246 /*@modifies *p @*/; 00247 00248 __END_DECLS 00249 00250 #endif /* fts.h */ 00251 00252 #endif /* HAVE_FTS_OPEN */