12134Seric # include "../hdr/defines.h" 2*19940Ssam # include <sys/dir.h> 32134Seric 4*19940Ssam SCCSID(@(#)dofile.c 1.5); 52134Seric 62134Seric int nfiles; 72134Seric char had_dir; 82134Seric char had_standinp; 92134Seric 102134Seric do_file(p,func)112134Sericdo_file(p,func) 122134Seric register char *p; 132134Seric int (*func)(); 142134Seric { 152134Seric extern char *Ffile; 162134Seric char str[FILESIZE]; 172134Seric char ibuf[FILESIZE]; 186579Ssam DIR *dir; 196579Ssam struct direct *dp; 202134Seric register char *s; 212134Seric int fd; 222134Seric 232134Seric if (p[0] == '-') { 242134Seric had_standinp = 1; 252134Seric while (gets(ibuf) != NULL) { 262134Seric if (sccsfile(ibuf)) { 272134Seric Ffile = ibuf; 282134Seric (*func)(ibuf); 292134Seric nfiles++; 302134Seric } 312134Seric } 322134Seric } 332134Seric else if (exists(p) && (Statbuf.st_mode & S_IFMT) == S_IFDIR) { 342134Seric had_dir = 1; 352134Seric Ffile = p; 366579Ssam if((dir = opendir(p)) == 0) 372134Seric return; 386579Ssam (void) readdir(dir); /* skip . */ 396579Ssam (void) readdir(dir); /* and .. */ 406780Ssam while (dp = readdir(dir)) { 416579Ssam sprintf(str,"%s/%s", p, dp->d_name); 422134Seric if(sccsfile(str)) { 432134Seric Ffile = str; 442134Seric (*func)(str); 452134Seric nfiles++; 462134Seric } 472134Seric } 486579Ssam closedir(dir); 492134Seric } 502134Seric else { 512134Seric Ffile = p; 522134Seric (*func)(p); 532134Seric nfiles++; 542134Seric } 552134Seric } 56