Annotation of researchv10no/cmd/movie/hsupport.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: 
                      3: #ifdef SYS_V
                      4: #include <termio.h>
                      5: struct termio tty, svtty;
                      6: #else
                      7: #include <sgtty.h>
                      8: struct sgttyb tty, svtty;
                      9: #endif
                     10: 
                     11: extern int dbg;
                     12: 
                     13: char *emalloc(n)
                     14: {
                     15:        char *p, *calloc();
                     16: 
                     17:        p = calloc(n, 1);
                     18:        assert(p != NULL, "out of space in emalloc");
                     19:        return p;
                     20: }
                     21: 
                     22: sendbuf(buf, p)        /* write buf..buf+p-1 to jerq */
                     23:        char *buf, *p;
                     24: {
                     25:        write(1, buf, p-buf);
                     26: }
                     27: 
                     28: assert(c, s1, s2, s3)  /* poor man's assertion */
                     29:        char *s1, *s2, *s3;
                     30: {
                     31:        if (!c) {
                     32:                fprintf(stderr, "assertion failed: ");
                     33:                fprintf(stderr, s1, s2, s3);
                     34:                fprintf(stderr, "\n");
                     35:                reset_tty();
                     36:                abort();
                     37:        }
                     38: }
                     39: 
                     40: readbyte()     /* receive one byte */
                     41: {
                     42:        char buf[2];
                     43: 
                     44:        read(0, buf, 1);
                     45:        return buf[0];
                     46: }
                     47: 
                     48: set_tty()      /* set jerq terminal mode */
                     49: {
                     50:        if (dbg)
                     51:                return;
                     52: #ifdef SYS_V
                     53:        ioctl(1, TCGETA, &tty);
                     54:        svtty = tty;
                     55:        tty.c_iflag = IGNBRK;
                     56:        tty.c_iflag &= ~(INLCR|IGNCR|ICRNL|IGNPAR|PARMRK);
                     57:        tty.c_cflag = (tty.c_cflag & (CBAUD|CLOCAL))| CS8|CREAD;
                     58:        tty.c_cc[VMIN] = 1;
                     59:        tty.c_lflag &= ~(ECHO|ICANON|ECHOK|ECHONL|ECHOE);
                     60:        tty.c_oflag &= ~(ONLCR|OCRNL|ONOCR|ONLRET|OFILL);
                     61:        ioctl(1, TCSETAW, &tty);
                     62: #else
                     63:        ioctl(1, TIOCGETP, &tty);
                     64:        svtty = tty;
                     65:        tty.sg_flags |= RAW;
                     66:        tty.sg_flags &= ~ECHO;
                     67:        ioctl(1, TIOCSETN, &tty);
                     68: #endif
                     69: }
                     70: 
                     71: reset_tty()
                     72: {
                     73:        if (dbg)
                     74:                return;
                     75: #ifdef SYS_V
                     76:        ioctl(1, TCSETAW, &svtty);
                     77: #else
                     78:        ioctl(1, TIOCSETP, &svtty);     /* SETN??? */
                     79: #endif
                     80: }

unix.superglobalmegacorp.com

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