00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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
00041 #if defined(hpux) || defined(__hpux)
00042 # define _D_EXACT_NAMLEN(d) ((d)->d_namlen)
00043 # define _INCLUDE_POSIX_SOURCE
00044 # define _LARGEFILE64_SOURCE
00045 #endif
00046
00047 #if defined(__FreeBSD__)
00048 # define _D_EXACT_NAMLEN(d) ((d)->d_namlen)
00049 #endif
00050
00051 #if !defined(_D_EXACT_NAMLEN)
00052 # define _D_EXACT_NAMLEN(d) (strlen((d)->d_name))
00053 #endif
00054
00055 #endif
00056
00057 #include <sys/types.h>
00058 #include <sys/stat.h>
00059 #include <dirent.h>
00060
00061 typedef struct {
00062
00063 struct _ftsent *fts_cur;
00064
00065 struct _ftsent *fts_child;
00066
00067 struct _ftsent **fts_array;
00068 dev_t fts_dev;
00069
00070 char *fts_path;
00071 int fts_rfd;
00072 int fts_pathlen;
00073 int fts_nitems;
00074
00075 int (*fts_compar) (const void *, const void *)
00076 ;
00078 DIR * (*fts_opendir) (const char * path)
00079
00080 ;
00081 struct dirent * (*fts_readdir) (DIR * dir)
00082
00083 ;
00084 int (*fts_closedir) ( DIR * dir)
00085
00086 ;
00087 int (*fts_stat) (const char * path, struct stat * st)
00088
00089 ;
00090 int (*fts_lstat) (const char * path, struct stat * st)
00091
00092 ;
00093
00094 #define FTS_COMFOLLOW 0x0001
00095 #define FTS_LOGICAL 0x0002
00096 #define FTS_NOCHDIR 0x0004
00097 #define FTS_NOSTAT 0x0008
00098 #define FTS_PHYSICAL 0x0010
00099 #define FTS_SEEDOT 0x0020
00100 #define FTS_XDEV 0x0040
00101 #define FTS_WHITEOUT 0x0080
00102 #define FTS_OPTIONMASK 0x00ff
00103
00104 #define FTS_NAMEONLY 0x0100
00105 #define FTS_STOP 0x0200
00106 int fts_options;
00107 } FTS;
00108
00109 typedef struct _ftsent {
00110
00111 struct _ftsent *fts_cycle;
00112
00113 struct _ftsent *fts_parent;
00114
00115 struct _ftsent *fts_link;
00116 long fts_number;
00117
00118 void *fts_pointer;
00119
00120 char *fts_accpath;
00121
00122 char *fts_path;
00123 int fts_errno;
00124 int fts_symfd;
00125 u_short fts_pathlen;
00126 u_short fts_namelen;
00128 ino_t fts_ino;
00129 dev_t fts_dev;
00130 nlink_t fts_nlink;
00132 #define FTS_ROOTPARENTLEVEL -1
00133 #define FTS_ROOTLEVEL 0
00134 short fts_level;
00136 #define FTS_D 1
00137 #define FTS_DC 2
00138 #define FTS_DEFAULT 3
00139 #define FTS_DNR 4
00140 #define FTS_DOT 5
00141 #define FTS_DP 6
00142 #define FTS_ERR 7
00143 #define FTS_F 8
00144 #define FTS_INIT 9
00145 #define FTS_NS 10
00146 #define FTS_NSOK 11
00147 #define FTS_SL 12
00148 #define FTS_SLNONE 13
00149 #define FTS_W 14
00150 u_short fts_info;
00152 #define FTS_DONTCHDIR 0x01
00153 #define FTS_SYMFOLLOW 0x02
00154 u_short fts_flags;
00156 #define FTS_AGAIN 1
00157 #define FTS_FOLLOW 2
00158 #define FTS_NOINSTR 3
00159 #define FTS_SKIP 4
00160 u_short fts_instr;
00162
00163 struct stat *fts_statp;
00164 char fts_name[1];
00165 } FTSENT;
00166
00167 #ifdef __cplusplus
00168 extern "C" {
00169 #endif
00170
00177
00178 FTSENT *Fts_children (FTS * sp, int instr) __THROW
00179
00180 ;
00181
00187 int Fts_close ( FTS * sp) __THROW
00188
00189 ;
00190
00198
00199 FTS *Fts_open (char * const * argv, int options,
00200
00201 int (*compar) (const FTSENT **, const FTSENT **)) __THROW
00202 ;
00203
00209
00210 FTSENT *Fts_read ( FTS * sp) __THROW
00211
00212 ;
00213
00221 int Fts_set (FTS * sp, FTSENT * p, int instr) __THROW
00222 ;
00223
00224 #ifdef __cplusplus
00225 }
00226 #endif
00227
00228 #endif