| 1 | /* |
| 2 | * Copyright (c) 1989 The Regents of the University of California. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms are permitted |
| 6 | * provided that the above copyright notice and this paragraph are |
| 7 | * duplicated in all such forms and that any documentation, |
| 8 | * advertising materials, and other materials related to such |
| 9 | * distribution and use acknowledge that the software was developed |
| 10 | * by the University of California, Berkeley. The name of the |
| 11 | * University may not be used to endorse or promote products derived |
| 12 | * from this software without specific prior written permission. |
| 13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
| 14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 16 | * |
| 17 | * @(#)fts.h 5.4 (Berkeley) %G% |
| 18 | */ |
| 19 | |
| 20 | typedef struct fts { |
| 21 | struct ftsent *fts_cur; /* current node */ |
| 22 | struct ftsent *fts_child; /* linked list of children */ |
| 23 | struct ftsent *fts_savelink; /* saved link if node had a cycle */ |
| 24 | struct ftsent **fts_array; /* sort array */ |
| 25 | dev_t sdev; /* starting device # */ |
| 26 | char *fts_path; /* path for this descent */ |
| 27 | int fts_sd; /* starting directory */ |
| 28 | int fts_pathlen; /* sizeof(path) */ |
| 29 | int fts_nitems; /* elements in the sort array */ |
| 30 | int (*fts_compar)(); /* compare function */ |
| 31 | #define FTS__STOP 0x001 /* private: unrecoverable error */ |
| 32 | #define FTS_LOGICAL 0x002 /* user: use stat(2) */ |
| 33 | #define FTS_MULTIPLE 0x004 /* user: multiple args */ |
| 34 | #define FTS_NOCHDIR 0x008 /* user: don't use chdir(2) */ |
| 35 | #define FTS_NOSTAT 0x010 /* user: don't require stat info */ |
| 36 | #define FTS_PHYSICAL 0x020 /* user: use lstat(2) */ |
| 37 | #define FTS_SEEDOT 0x040 /* user: return dot and dot-dot */ |
| 38 | #define FTS_XDEV 0x080 /* user: don't cross devices */ |
| 39 | int fts_options; /* openfts() options */ |
| 40 | } FTS; |
| 41 | |
| 42 | typedef struct ftsent { |
| 43 | struct ftsent *fts_parent; /* parent directory */ |
| 44 | struct ftsent *fts_link; /* next/cycle node */ |
| 45 | union { |
| 46 | long number; /* local numeric value */ |
| 47 | void *pointer; /* local address value */ |
| 48 | } fts_local; |
| 49 | char *fts_accpath; /* path from current directory */ |
| 50 | char *fts_path; /* path from starting directory */ |
| 51 | short fts_pathlen; /* strlen(path) */ |
| 52 | short fts_namelen; /* strlen(name) */ |
| 53 | short fts_level; /* depth (-1 to N) */ |
| 54 | #define FTS_D 1 /* preorder directory */ |
| 55 | #define FTS_DC 2 /* directory that causes cycles */ |
| 56 | #define FTS_DNR 3 /* unreadable directory */ |
| 57 | #define FTS_DNX 4 /* unsearchable 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 /* no stat(2) information */ |
| 62 | #define FTS_SL 9 /* symbolic link */ |
| 63 | #define FTS_SLNONE 10 /* symbolic link without target */ |
| 64 | #define FTS_DEFAULT 11 /* none of the above */ |
| 65 | u_short fts_info; /* file information */ |
| 66 | #define FTS_AGAIN 1 /* user: read node again */ |
| 67 | #define FTS_SKIP 2 /* user: discard node */ |
| 68 | #define FTS_FOLLOW 3 /* user: follow symbolic link */ |
| 69 | short fts_instr; /* setfts() instructions */ |
| 70 | struct stat fts_statb; /* stat(2) information */ |
| 71 | char fts_name[1]; /* file name */ |
| 72 | } FTSENT; |
| 73 | |
| 74 | #ifdef __STDC__ |
| 75 | extern FTS *ftsopen(const char **, int, int (*)(const FTSENT *, const FTSENT *); |
| 76 | extern FTSENT *ftsread(FTS *); |
| 77 | extern FTSENT *ftschildren(FTS *); |
| 78 | extern int ftsset(FTS *, FTSENT *, int); |
| 79 | extern int ftsclose(FTS *); |
| 80 | #else |
| 81 | extern FTS *ftsopen(); |
| 82 | extern FTSENT *ftschildren(), *ftsread(); |
| 83 | extern int ftsclose(), ftsset(); |
| 84 | #endif |