Annotation of 42BSD/ucb/lock.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char *sccsid = "@(#)lock.c      4.3 (Berkeley) 6/10/83";
                      3: #endif
                      4: 
                      5: /*
                      6:  * Lock a terminal up until the knowledgeable Joe returns.
                      7:  */
                      8: #include <stdio.h>
                      9: #include <sys/types.h>
                     10: #include <sys/stat.h>
                     11: #include <signal.h>
                     12: #include <sgtty.h>
                     13: 
                     14: char   masterp[] =     "hasta la vista\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:        struct stat statb;
                     23: 
                     24:        signal(SIGINT, SIG_IGN);
                     25:        signal(SIGQUIT, SIG_IGN);
                     26:        signal(SIGTSTP, SIG_IGN);
                     27:        if (argc > 0)
                     28:                argv[0] = 0;
                     29:        if (ioctl(0, TIOCGETP, &tty))
                     30:                exit(1);
                     31:        ntty = tty; ntty.sg_flags &= ~ECHO;
                     32:        ioctl(0, TIOCSETN, &ntty);
                     33:        printf("Key: ");
                     34:        fgets(s, sizeof s, stdin);
                     35:        printf("\nAgain: ");
                     36:        fgets(s1, sizeof s1, stdin);
                     37:        putchar('\n');
                     38:        if (strcmp(s1, s)) {
                     39:                putchar(07);
                     40:                stty(0, &tty);
                     41:                exit(1);
                     42:        }
                     43:        s[0] = 0;
                     44:        for (;;) {
                     45:                fgets(s, sizeof s, stdin);
                     46:                if (strcmp(s1, s) == 0)
                     47:                        break;
                     48:                if (strcmp(s, masterp) == 0)
                     49:                        break;
                     50:                putchar(07);
                     51:                if (ioctl(0, TIOCGETP, &ntty))
                     52:                        exit(1);
                     53:        }
                     54:        ioctl(0, TIOCSETN, &tty);
                     55: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.