BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / learn / learn / wrapup.c
index 7f9bb48..a965f96 100644 (file)
@@ -1,35 +1,44 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)wrapup.c   4.2     (Berkeley)      %G%";
+static char sccsid[] = "@(#)wrapup.c   4.4     (Berkeley)      5/10/89";
 #endif not lint
 
 #endif not lint
 
-#include "signal.h"
-#include "stdio.h"
+#include <sys/signal.h>
+#include <stdio.h>
 #include "lrnref.h"
 #include "lrnref.h"
+#include "pathnames.h"
+
+extern char learnrc[];
 
 wrapup(n)
 int n;
 {
 
 wrapup(n)
 int n;
 {
+       FILE *fp;
 /* this routine does not use 'system' because it wants interrupts turned off */
 
        signal(SIGINT, SIG_IGN);
        chdir("..");
        if (fork() == 0) {
                signal(SIGHUP, SIG_IGN);
 /* this routine does not use 'system' because it wants interrupts turned off */
 
        signal(SIGINT, SIG_IGN);
        chdir("..");
        if (fork() == 0) {
                signal(SIGHUP, SIG_IGN);
-#if vax
+#if BSD4_2
                if (fork() == 0) {
                        close(1);
                if (fork() == 0) {
                        close(1);
-                       open("/dev/tty", 1);
-                       execl("/bin/stty", "stty", "new", 0);
+                       open(_PATH_TTY, 1);
+                       execl(_PATH_STTY, "stty", "new", 0);
                }
 #endif
                }
 #endif
-               execl("/bin/rm", "rm", "-rf", dir, 0);
-               execl("/usr/bin/rm", "rm", "-rf", dir, 0);
-               perror("bin/rm");
+               execl(_PATH_RM, "rm", "-rf", dir, 0);
+               perror(_PATH_RM);
                fprintf(stderr, "Wrapup:  can't find 'rm' command.\n");
                exit(0);
        }
                fprintf(stderr, "Wrapup:  can't find 'rm' command.\n");
                exit(0);
        }
-       if (!n && todo)
-               printf("To take up where you left off type \"learn %s %s\".\n", sname, todo);
+       if (n == -1)
+               unlink(learnrc);
+       else if (!n && todo) {
+               if ((fp=fopen(learnrc, "w")) == NULL)
+                       exit(0);
+               fprintf(fp, "%s %s %d\n", sname, todo, speed);
+               fclose(fp);
+       }
        printf("Bye.\n");       /* not only does this reassure user but it
                                stalls for time while deleting directory */
        fflush(stdout);
        printf("Bye.\n");       /* not only does this reassure user but it
                                stalls for time while deleting directory */
        fflush(stdout);