Commit | Line | Data |
---|---|---|
7ff9bbe2 KS |
1 | /* Copyright (c) 1979 Regents of the University of California */ |
2 | #include <retrofit.h> | |
3 | #include <stdio.h> | |
4 | #include <sys/types.h> | |
5 | #include <sys/stat.h> | |
6 | #include <signal.h> | |
7 | #include <sgtty.h> | |
8 | ||
9 | /* | |
10 | * Lock a terminal up until the knowledgeable Joe returns. | |
11 | */ | |
12 | char masterp[] = "hasta la vista\n"; | |
13 | struct sgttyb tty, ntty; | |
14 | char s[BUFSIZ], s1[BUFSIZ]; | |
15 | ||
16 | main(argc, argv) | |
17 | char **argv; | |
18 | { | |
19 | register int t; | |
20 | struct stat statb; | |
21 | ||
22 | for (t = 1; t <= 16; t++) | |
23 | signal(t, SIG_IGN); | |
24 | if (argc > 0) | |
25 | argv[0] = 0; | |
26 | if (gtty(0, &tty)) | |
27 | exit(1); | |
28 | gtty(0, &ntty); ntty.sg_flags &= ~ECHO; | |
29 | stty(0, &ntty); | |
30 | printf("Key: "); | |
31 | fgets(s, sizeof s, stdin); | |
32 | printf("\nAgain: "); | |
33 | fgets(s1, sizeof s1, stdin); | |
34 | putchar('\n'); | |
35 | if (strcmp(s1, s)) { | |
36 | putchar(07); | |
37 | stty(0, &tty); | |
38 | exit(1); | |
39 | } | |
40 | s[0] = 0; | |
41 | for (;;) { | |
42 | fgets(s, sizeof s, stdin); | |
43 | if (strcmp(s1, s) == 0) | |
44 | break; | |
45 | if (strcmp(s, masterp) == 0) | |
46 | break; | |
47 | putchar(07); | |
48 | if (gtty(0, &ntty)) | |
49 | exit(1); | |
50 | } | |
51 | stty(0, &tty); | |
52 | } |