1 /* 2 * Copyright (c) 1989 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)fts.h 5.17 (Berkeley) 12/30/91 8 */ 9 10 #ifndef _FTS_H_ 11 #define _FTS_H_ 12 13 typedef struct { 14 struct _ftsent *fts_cur; /* current node */ 15 struct _ftsent *fts_child; /* linked list of children */ 16 struct _ftsent **fts_array; /* sort array */ 17 dev_t rdev; /* starting device # */ 18 char *fts_path; /* path for this descent */ 19 int fts_rfd; /* fd for root */ 20 int fts_pathlen; /* sizeof(path) */ 21 int fts_nitems; /* elements in the sort array */ 22 int (*fts_compar)(); /* compare function */ 23 24 #define FTS_LOGICAL 0x001 /* logical walk */ 25 #define FTS_NOCHDIR 0x002 /* don't change directories */ 26 #define FTS_NOSTAT 0x004 /* don't get stat info */ 27 #define FTS_PHYSICAL 0x008 /* physical walk */ 28 #define FTS_SEEDOT 0x010 /* return dot and dot-dot */ 29 #define FTS_STOP 0x020 /* (private) unrecoverable error */ 30 #define FTS_XDEV 0x040 /* don't cross devices */ 31 int fts_options; /* openfts() options */ 32 } FTS; 33 34 typedef struct _ftsent { 35 struct _ftsent *fts_cycle; /* cycle node */ 36 struct _ftsent *fts_parent; /* parent directory */ 37 struct _ftsent *fts_link; /* next file in directory */ 38 union { 39 long number; /* local numeric value */ 40 void *pointer; /* local address value */ 41 } fts_local; 42 #define fts_number fts_local.number 43 #define fts_pointer fts_local.pointer 44 char *fts_accpath; /* access path */ 45 char *fts_path; /* root path */ 46 int fts_cderr; /* chdir failed -- errno */ 47 short fts_pathlen; /* strlen(fts_path) */ 48 short fts_namelen; /* strlen(fts_name) */ 49 50 #define FTS_ROOTPARENTLEVEL -1 51 #define FTS_ROOTLEVEL 0 52 short fts_level; /* depth (-1 to N) */ 53 54 #define FTS_D 1 /* preorder directory */ 55 #define FTS_DC 2 /* directory that causes cycles */ 56 #define FTS_DEFAULT 3 /* none of the above */ 57 #define FTS_DNR 4 /* unreadable directory */ 58 #define FTS_DP 5 /* postorder directory */ 59 #define FTS_ERR 6 /* error; errno is set */ 60 #define FTS_F 7 /* regular file */ 61 #define FTS_NS 8 /* stat(2) failed */ 62 #define FTS_NSOK 9 /* no stat(2) requested */ 63 #define FTS_SL 10 /* symbolic link */ 64 #define FTS_SLNONE 11 /* symbolic link without target */ 65 u_short fts_info; /* user flags for FTSENT structure */ 66 67 #define FTS_AGAIN 1 /* read node again */ 68 #define FTS_FOLLOW 2 /* follow symbolic link */ 69 #define FTS_NOINSTR 3 /* no instructions */ 70 #define FTS_SKIP 4 /* discard node */ 71 u_short fts_instr; /* fts_set() instructions */ 72 73 struct stat fts_statb; /* stat(2) information */ 74 char fts_name[1]; /* file name */ 75 } FTSENT; 76 77 #include <sys/cdefs.h> 78 79 __BEGIN_DECLS 80 FTSENT *fts_children __P((FTS *)); 81 int fts_close __P((FTS *)); 82 FTS *fts_open __P((char * const *, int, 83 int (*)(const FTSENT **, const FTSENT **))); 84 FTSENT *fts_read __P((FTS *)); 85 int fts_set __P((FTS *, FTSENT *, int)); 86 __END_DECLS 87 88 #endif /* !_FTS_H_ */ 89