|
|
1.1 root 1: #include "stdio.h"
2: #include "lrnref"
3: #include "sys/types.h"
4: #include "sys/dir.h"
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 (n>sizeof(dp->d_name)) n=sizeof(dp->d_name);
24: if (dp->d_name[n-2] == '.' && dp->d_name[n-1] == 'c')
25: continue;
26: c = dp->d_name[0];
27: if (c>='a' && c<= 'z')
28: unlink(dp->d_name);
29: }
30: close(f);
31: if (ask)
32: return;
33: sprintf(where, "../../%s/L%s", sname, lesson);
34: if (access(where, 04)==0) /* there is a file */
35: return;
36: fprintf(stderr, "No lesson %s\n",lesson);
37: wrapup(1);
38: }
39:
40: fcopy(new,old)
41: char *new, *old;
42: {
43: char b[512];
44: int n, fn, fo;
45: fn = creat(new, 0666);
46: fo = open(old,0);
47: if (fo<0) return;
48: if (fn<0) return;
49: while ( (n=read(fo, b, 512)) > 0)
50: write(fn, b, n);
51: close(fn);
52: close(fo);
53: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.