wrong arg to readdir
[unix-history] / usr / src / local / sccscmds / sccscmds.ok / com / dofile.c
CommitLineData
754200b1 1# include "../hdr/defines.h"
81c97830 2# include <ndir.h>
754200b1 3
6d687db5 4SCCSID(@(#)dofile.c 1.3);
754200b1
EA
5
6int nfiles;
7char had_dir;
8char had_standinp;
9
10
11do_file(p,func)
12register char *p;
13int (*func)();
14{
15 extern char *Ffile;
16 char str[FILESIZE];
17 char ibuf[FILESIZE];
81c97830
SL
18 DIR *dir;
19 struct direct *dp;
754200b1
EA
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;
81c97830 36 if((dir = opendir(p)) == 0)
754200b1 37 return;
81c97830
SL
38 (void) readdir(dir); /* skip . */
39 (void) readdir(dir); /* and .. */
6d687db5 40 while (dp = readdir(dir)) {
81c97830 41 sprintf(str,"%s/%s", p, dp->d_name);
754200b1
EA
42 if(sccsfile(str)) {
43 Ffile = str;
44 (*func)(str);
45 nfiles++;
46 }
47 }
81c97830 48 closedir(dir);
754200b1
EA
49 }
50 else {
51 Ffile = p;
52 (*func)(p);
53 nfiles++;
54 }
55}