static char sccsid
[] = "@(#)selsub.c 4.2 (Berkeley) 4/25/83";
if (argc
> 1 && argv
[1][0] == '-') {
if (chdir(direct
) != 0) {
fprintf(stderr
, "Selsub: couldn't cd to non-standard directory\n");
sname
= argc
> 1 ? argv
[1] : 0;
strcpy (level
=ans2
, argv
[2]);
if (strcmp(level
, "-") == 0) /* no lesson name is - */
again
= 1; /* treat as if "again lesson" */
printf("These are the available courses -\n");
printf("If you want more information about the courses,\n");
printf("or if you have never used 'learn' before,\n");
printf("press RETURN; otherwise type the name of\n");
printf("the course you want, followed by RETURN.\n");
printf("\nWhich subject? ");
} while (sname
[0] == '\0');
total
= statbuf
.st_size
/ 16 - 2; /* size/dirsize-(.+..) */
printf("If you were in the middle of this subject\n");
printf("and want to start where you left off, type\n");
printf("the last lesson number the computer printed.\n");
printf("If you don't know the number, type in a word\n");
printf("you think might appear in the lesson you want,\n");
printf("and I will look for the first lesson containing it.\n");
printf("To start at the beginning, just hit RETURN.\n");
/* make new directory for user to play in */
if (chdir("/tmp") != 0) {
fprintf(stderr
, "Selsub: couldn't cd to public directory\n");
sprintf(dir
=dirname
, "pl%da", getpid());
sprintf(ans1
, "mkdir %s", dir
);
fprintf(stderr
, "Selsub: couldn't make play directory with %s.\nBye.\n", ans1
);
/* after this point, we have a working directory. */
/* have to call wrapup to clean up */
if (access(sprintf(ans1
, "%s/%s/Init", direct
, sname
), 04)==0)
if (system(sprintf(ans1
, "%s/%s/Init %s", direct
, sname
, level
)) != 0) {
printf("Leaving learn.\n");
if (access(name
, 05) < 0) {
printf("Sorry, there is no subject or lesson named %s.\nBye.\n", name
);