|
|
1.1 root 1: #include "stdio.h"
2: #include <sys/types.h>
3: #include <sys/dir.h>
4: #include "lrnref"
5: #define ND 64
6:
7: start(lesson)
8: char *lesson;
9: {
10: struct direct dv[ND], *dm, *dp;
11: int f, c, n;
12: char where [100];
13:
14: f = open(".", 0);
15: n = read(f, dv, ND*sizeof(*dp));
16: n /= sizeof(*dp);
17: if (n==ND)
18: fprintf(stderr, "lesson too long\n");
19: dm = dv+n;
20: for(dp=dv; dp<dm; dp++)
21: if (dp->d_ino) {
22: n = strlen(dp->d_name);
23: if (dp->d_name[n-2] == '.' && dp->d_name[n-1] == 'c')
24: continue;
25: c = dp->d_name[0];
26: if (c>='a' && c<= 'z')
27: unlink(dp->d_name);
28: }
29: close(f);
30: if (ask)
31: return;
32: sprintf(where, "../../%s/L%s", sname, lesson);
33: if (access(where, 04)==0) /* there is a file */
34: return;
35: fprintf(stderr, "No lesson %s\n",lesson);
36: wrapup(1);
37: }
38:
39: fcopy(new,old)
40: char *new, *old;
41: {
42: char b[BUFSIZ];
43: int n, fn, fo;
44: fn = creat(new, 0666);
45: fo = open(old,0);
46: if (fo<0) return;
47: if (fn<0) return;
48: while ( (n=read(fo, b, BUFSIZ)) > 0)
49: write(fn, b, n);
50: close(fn);
51: close(fo);
52: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.