Annotation of researchv10no/ipc/mgrs/authmgr/res_tty.c, revision 1.1

1.1     ! root        1: #include <sgtty.h>
        !             2: #include <sys/filio.h>
        !             3: 
        !             4: struct sgttyb save_sgb;
        !             5: int pushed_ld = 0;
        !             6: 
        !             7: 
        !             8: setecho(on)
        !             9:        int on;
        !            10: {
        !            11:        struct sgttyb sgb;
        !            12: 
        !            13:        ioctl(0, TIOCGETP, &sgb);
        !            14:        if (on)
        !            15:                sgb.sg_flags |= ECHO;
        !            16:        else
        !            17:                sgb.sg_flags &= ~ECHO;
        !            18:        ioctl(0, TIOCSETP, &sgb);
        !            19: }
        !            20: 
        !            21: setraw(on)
        !            22:        int on;
        !            23: {
        !            24:        struct sgttyb sgb;
        !            25: 
        !            26:        ioctl(0, TIOCGETP, &sgb);
        !            27:        if (on)
        !            28:                sgb.sg_flags |= RAW;
        !            29:        else
        !            30:                sgb.sg_flags &= ~RAW;
        !            31:        ioctl(0, TIOCSETP, &sgb);
        !            32: }
        !            33: 
        !            34: settty()
        !            35: {
        !            36:        /* make sure interface is usable by humans */
        !            37:        struct tchars tcbuf;
        !            38:        extern int tty_ld;
        !            39: 
        !            40:        if(ioctl(0, TIOCGETC, &tcbuf) < 0) {
        !            41:                /* no tty ld (of any type) present; push one */
        !            42:                if(ioctl(0, FIOPUSHLD, &tty_ld) < 0)
        !            43:                        printf("No tty processing supported; sorry\n");
        !            44:                pushed_ld++;
        !            45:        } else
        !            46:                ioctl(0, TIOCGETP, &save_sgb);
        !            47: }
        !            48: 
        !            49: restoretty()
        !            50: {
        !            51:        if(pushed_ld)
        !            52:                ioctl(0, FIOPOPLD, (void *)0);
        !            53:        else
        !            54:                ioctl(0, TIOCSETP, &save_sgb);
        !            55: }

unix.superglobalmegacorp.com

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