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