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