Annotation of 41BSD/cmd/lock.c, revision 1.1

1.1     ! root        1: static char *sccsid = "@(#)lock.c      4.1 (Berkeley) 10/1/80";
        !             2: #include <stdio.h>
        !             3: #include <sys/types.h>
        !             4: #include <stat.h>
        !             5: #include <signal.h>
        !             6: #include <sgtty.h>
        !             7: 
        !             8: /*
        !             9:  * Lock a terminal up until the knowledgeable Joe returns.
        !            10:  */
        !            11: char   masterp[] =     "hasta la vista\n";
        !            12: struct sgttyb tty, ntty;
        !            13: char   s[BUFSIZ], s1[BUFSIZ];
        !            14: 
        !            15: main(argc, argv)
        !            16:        char **argv;
        !            17: {
        !            18:        register int t;
        !            19:        struct stat statb;
        !            20: 
        !            21:        for (t = 1; t <= 16; t++)
        !            22:                if (t != SIGHUP)
        !            23:                signal(t, SIG_IGN);
        !            24:        if (argc > 0)
        !            25:                argv[0] = 0;
        !            26:        if (gtty(0, &tty))
        !            27:                exit(1);
        !            28:        ntty = tty; 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: }

unix.superglobalmegacorp.com

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