diff options
| author | svn2git <svn2git@FreeBSD.org> | 1994-05-01 08:00:00 +0000 | 
|---|---|---|
| committer | svn2git <svn2git@FreeBSD.org> | 1994-05-01 08:00:00 +0000 | 
| commit | a16f65c7d117419bd266c28a1901ef129a337569 (patch) | |
| tree | 2626602f66dc3551e7a7c7bc9ad763c3bc7ab40a /gnu/libexec/uucp/libunix/walk.c | |
| parent | 8503f4f13f77abf7adc8f7e329c6f9c1d52b6a20 (diff) | |
Diffstat (limited to 'gnu/libexec/uucp/libunix/walk.c')
| -rw-r--r-- | gnu/libexec/uucp/libunix/walk.c | 59 | 
1 files changed, 59 insertions, 0 deletions
diff --git a/gnu/libexec/uucp/libunix/walk.c b/gnu/libexec/uucp/libunix/walk.c new file mode 100644 index 000000000000..ab96123127dd --- /dev/null +++ b/gnu/libexec/uucp/libunix/walk.c @@ -0,0 +1,59 @@ +/* walk.c +   Walk a directory tree.  */ + +#include "uucp.h" + +#include "uudefs.h" +#include "sysdep.h" +#include "system.h" + +#if HAVE_FTW_H +#include <ftw.h> +#endif + +static int iswalk_dir P((const char *zname, const struct stat *qstat, +			 int iflag)); + +/* Walk a directory tree.  */ + +static size_t cSlen; +static void (*puSfn) P((const char *zfull, const char *zrelative, +			pointer pinfo)); +static pointer pSinfo; + +boolean +usysdep_walk_tree (zdir, pufn, pinfo) +     const char *zdir; +     void (*pufn) P((const char *zfull, const char *zrelative, +		     pointer pinfo)); +     pointer pinfo; +{ +  cSlen = strlen (zdir) + 1; +  puSfn = pufn; +  pSinfo = pinfo; +  return ftw ((char *) zdir, iswalk_dir, 5) == 0; +} + +/* Pass a file found in the directory tree to the system independent +   function.  */ + +/*ARGSUSED*/ +static int +iswalk_dir (zname, qstat, iflag) +     const char *zname; +     const struct stat *qstat; +     int iflag; +{ +  char *zcopy; + +  if (iflag != FTW_F) +    return 0; + +  zcopy = zbufcpy (zname + cSlen); + +  (*puSfn) (zname, zcopy, pSinfo); + +  ubuffree (zcopy); + +  return 0; +}  | 
