wrong arg to readdir
[unix-history] / usr / src / local / sccscmds / sccscmds.ok / com / dofile.c
... / ...
CommitLineData
1# include "../hdr/defines.h"
2# include <ndir.h>
3
4SCCSID(@(#)dofile.c 1.3);
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];
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}