1*2134Seric # include "../hdr/defines.h" 2*2134Seric # include "dir.h" 3*2134Seric 4*2134Seric SCCSID(@(#)dofile.c 1.1); 5*2134Seric 6*2134Seric int nfiles; 7*2134Seric char had_dir; 8*2134Seric char had_standinp; 9*2134Seric 10*2134Seric 11*2134Seric do_file(p,func) 12*2134Seric register char *p; 13*2134Seric int (*func)(); 14*2134Seric { 15*2134Seric extern char *Ffile; 16*2134Seric char str[FILESIZE]; 17*2134Seric char ibuf[FILESIZE]; 18*2134Seric char dbuf[BUFSIZ]; 19*2134Seric FILE *iop; 20*2134Seric struct dir dir[2]; 21*2134Seric register char *s; 22*2134Seric int fd; 23*2134Seric 24*2134Seric if (p[0] == '-') { 25*2134Seric had_standinp = 1; 26*2134Seric while (gets(ibuf) != NULL) { 27*2134Seric if (sccsfile(ibuf)) { 28*2134Seric Ffile = ibuf; 29*2134Seric (*func)(ibuf); 30*2134Seric nfiles++; 31*2134Seric } 32*2134Seric } 33*2134Seric } 34*2134Seric else if (exists(p) && (Statbuf.st_mode & S_IFMT) == S_IFDIR) { 35*2134Seric had_dir = 1; 36*2134Seric Ffile = p; 37*2134Seric if((iop = fopen(p,"r")) == NULL) 38*2134Seric return; 39*2134Seric setbuf(iop,dbuf); 40*2134Seric dir[1].d_ino = 0; 41*2134Seric fread(dir,sizeof(dir[0]),1,iop); /* skip "." */ 42*2134Seric fread(dir,sizeof(dir[0]),1,iop); /* skip ".." */ 43*2134Seric while(fread(dir,sizeof(dir[0]),1,iop) == 1) { 44*2134Seric if(dir[0].d_ino == 0) continue; 45*2134Seric sprintf(str,"%s/%s",p,dir[0].d_name); 46*2134Seric if(sccsfile(str)) { 47*2134Seric Ffile = str; 48*2134Seric (*func)(str); 49*2134Seric nfiles++; 50*2134Seric } 51*2134Seric } 52*2134Seric fclose(iop); 53*2134Seric } 54*2134Seric else { 55*2134Seric Ffile = p; 56*2134Seric (*func)(p); 57*2134Seric nfiles++; 58*2134Seric } 59*2134Seric } 60