| 1 | # include "../hdr/defines.h" |
| 2 | # include <ndir.h> |
| 3 | |
| 4 | SCCSID(@(#)dofile.c 1.3); |
| 5 | |
| 6 | int nfiles; |
| 7 | char had_dir; |
| 8 | char had_standinp; |
| 9 | |
| 10 | |
| 11 | do_file(p,func) |
| 12 | register char *p; |
| 13 | int (*func)(); |
| 14 | { |
| 15 | extern char *Ffile; |
| 16 | char str[FILESIZE]; |
| 17 | char ibuf[FILESIZE]; |
| 18 | DIR *dir; |
| 19 | struct direct *dp; |
| 20 | register char *s; |
| 21 | int fd; |
| 22 | |
| 23 | if (p[0] == '-') { |
| 24 | had_standinp = 1; |
| 25 | while (gets(ibuf) != NULL) { |
| 26 | if (sccsfile(ibuf)) { |
| 27 | Ffile = ibuf; |
| 28 | (*func)(ibuf); |
| 29 | nfiles++; |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | else if (exists(p) && (Statbuf.st_mode & S_IFMT) == S_IFDIR) { |
| 34 | had_dir = 1; |
| 35 | Ffile = p; |
| 36 | if((dir = opendir(p)) == 0) |
| 37 | return; |
| 38 | (void) readdir(dir); /* skip . */ |
| 39 | (void) readdir(dir); /* and .. */ |
| 40 | while (dp = readdir(dir)) { |
| 41 | sprintf(str,"%s/%s", p, dp->d_name); |
| 42 | if(sccsfile(str)) { |
| 43 | Ffile = str; |
| 44 | (*func)(str); |
| 45 | nfiles++; |
| 46 | } |
| 47 | } |
| 48 | closedir(dir); |
| 49 | } |
| 50 | else { |
| 51 | Ffile = p; |
| 52 | (*func)(p); |
| 53 | nfiles++; |
| 54 | } |
| 55 | } |