1: #ifndef lint
2: static char *sccsid = "@(#)lock.c 4.1 (Berkeley) 10/1/80";
3: #endif
4: #include <whoami.h>
5: #include <stdio.h>
6: #include <sys/types.h>
7: #include <stat.h>
8: #include <signal.h>
9: #include <sgtty.h>
10:
11: /*
12: * Lock a terminal up until the knowledgeable Joe returns.
13: */
14: char masterp[] = "knowledgeable Joe\n";
15: struct sgttyb tty, ntty;
16: char s[BUFSIZ], s1[BUFSIZ];
17:
18: main(argc, argv)
19: char **argv;
20: {
21: register int t;
22:
23: for (t = 1; t <= 16; t++)
24: if (t != SIGHUP)
25: signal(t, SIG_IGN);
26: #ifdef SIGTSTP
27: signal(SIGTSTP, SIG_IGN);
28: #endif
29: if (argc > 0)
30: argv[0] = 0;
31: if (gtty(0, &tty))
32: exit(1);
33: ntty = tty; ntty.sg_flags &= ~ECHO;
34: stty(0, &ntty);
35: printf("Key: ");
36: fgets(s, sizeof s, stdin);
37: printf("\nAgain: ");
38: fgets(s1, sizeof s1, stdin);
39: putchar('\n');
40: if (strcmp(s1, s)) {
41: putchar(07);
42: stty(0, &tty);
43: exit(1);
44: }
45: s[0] = 0;
46: for (;;) {
47: fgets(s, sizeof s, stdin);
48: if (strcmp(s1, s) == 0)
49: break;
50: if (strcmp(s, masterp) == 0)
51: break;
52: putchar(07);
53: if (gtty(0, &ntty))
54: exit(1);
55: }
56: stty(0, &tty);
57: }
Defined functions
main
defined in line
18;
never used
Defined variables
ntty
defined in line
15; used 4 times
s
defined in line
16; used 8 times
s1
defined in line
16; used 4 times
sccsid
defined in line
2;
never used
tty
defined in line
15; used 4 times