1 /*-
2 * Copyright (c) 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.proprietary.c%
6 */
7
8 #ifndef lint
9 static char copyright[] =
10 "@(#) Copyright (c) 1986, 1993\n\
11 The Regents of the University of California. All rights reserved.\n";
12 #endif /* not lint */
13
14 #ifndef lint
15 static char sccsid[] = "@(#)learn.c 8.1 (Berkeley) 06/06/93";
16 #endif /* not lint */
17
18 #include <sys/signal.h>
19 #include <stdio.h>
20 #include "lrnref.h"
21 #include "pathnames.h"
22
23 char *direct = _PATH_LEARN;
24 int more;
25 char *level;
26 int speed;
27 char *sname;
28 char *todo;
29 FILE *incopy = NULL;
30 int didok;
31 int sequence = 1;
32 int comfile = -1;
33 int status;
34 int wrong;
35 char *pwline;
36 char *dir;
37 FILE *scrin;
38 int logging = 1; /* set to 0 to turn off logging */
39 int ask;
40 int again;
41 int skip;
42 int teed;
43 int total;
44
45 extern void hangup(), intrpt();
46
main(argc,argv)47 main(argc,argv)
48 int argc;
49 char *argv[];
50 {
51 extern char * getlogin(), *malloc();
52
53 speed = 0;
54 more = 1;
55 pwline = getlogin();
56 #ifndef BSD4_2
57 setbuf(stdout, malloc(BUFSIZ));
58 setbuf(stderr, malloc(BUFSIZ));
59 #endif
60 selsub(argc, argv);
61 chgenv();
62 signal(SIGHUP, hangup);
63 signal(SIGINT, intrpt);
64 while (more) {
65 selunit();
66 dounit();
67 whatnow();
68 }
69 wrapup(0);
70 }
71
72 void
hangup()73 hangup()
74 {
75 wrapup(1);
76 }
77
78 void
intrpt()79 intrpt()
80 {
81 char response[20], *p;
82
83 signal(SIGINT, hangup);
84 write(2, "\nInterrupt.\nWant to go on? ", 28);
85 p = response;
86 *p = 'n';
87 while (read(0, p, 1) == 1 && *p != '\n')
88 p++;
89 if (response[0] != 'y')
90 wrapup(0);
91 ungetc('\n', stdin);
92 signal(SIGINT, intrpt);
93 }
94