Annotation of 43BSDReno/lib/libc/gen/termios.c, revision 1.1.1.1

1.1       root        1: /*-
                      2:  * Copyright (c) 1989 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted provided
                      6:  * that: (1) source distributions retain this entire copyright notice and
                      7:  * comment, and (2) distributions including binaries display the following
                      8:  * acknowledgement:  ``This product includes software developed by the
                      9:  * University of California, Berkeley and its contributors'' in the
                     10:  * documentation or other materials provided with the distribution and in
                     11:  * all advertising materials mentioning features or use of this software.
                     12:  * Neither the name of the University nor the names of its contributors may
                     13:  * be used to endorse or promote products derived from this software without
                     14:  * specific prior written permission.
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     16:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     17:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     18:  */
                     19: 
                     20: #if defined(LIBC_SCCS) && !defined(lint)
                     21: static char sccsid[] = "@(#)termios.c  5.2 (Berkeley) 6/26/90";
                     22: #endif /* LIBC_SCCS and not lint */
                     23: 
                     24: #include <sys/types.h>
                     25: #include <sys/errno.h>
                     26: #include <sys/ioctl.h>
                     27: #include <sys/tty.h>
                     28: #include <sys/termios.h>
                     29: #include <stdio.h>
                     30: 
                     31: tcgetattr(fd, t)
                     32:        int fd;
                     33:        struct termios *t;
                     34: {
                     35:        extern errno;
                     36: 
                     37:        return(ioctl(fd, TIOCGETA, t));
                     38: }
                     39: 
                     40: tcsetattr(fd, opt, t)
                     41:        int fd, opt;
                     42:        struct termios *t;
                     43: {
                     44:        struct termios localterm;
                     45: 
                     46:        if (opt & TCSASOFT) {
                     47:                localterm = *t;
                     48:                localterm.c_cflag |= CIGNORE;
                     49:                t = &localterm;
                     50:                opt &= TCSASOFT;
                     51:        }
                     52:        if (opt == TCSANOW)
                     53:                return (ioctl(fd, TIOCSETA, t));
                     54:        else if (opt == TCSADRAIN)
                     55:                return (ioctl(fd, TIOCSETAW, t));
                     56:        else
                     57:                return (ioctl(fd, TIOCSETAF, t));
                     58: }
                     59: 
                     60: tcsetpgrp(fd, pgrp)
                     61: {
                     62:        return(ioctl(fd, TIOCSPGRP, &pgrp));
                     63: }
                     64: 
                     65: tcgetpgrp(fd)
                     66: {
                     67:        int pgrp;
                     68: 
                     69:        if (ioctl(fd, TIOCGPGRP, &pgrp) < 0)
                     70:                return(-1);
                     71:        return(pgrp);
                     72: }
                     73: 
                     74: cfgetospeed(t)
                     75:        struct termios *t;
                     76: {
                     77:        return(t->c_ospeed);
                     78: }
                     79: 
                     80: cfgetispeed(t)
                     81:        struct termios *t;
                     82: {
                     83:        return(t->c_ispeed);
                     84: }
                     85: 
                     86: cfsetospeed(t, speed)
                     87:        struct termios *t;
                     88: {
                     89:        t->c_ospeed = speed;
                     90: }
                     91: 
                     92: cfsetispeed(t, speed)
                     93:        struct termios *t;
                     94: {
                     95:        t->c_ispeed = speed;
                     96: }
                     97: 
                     98: cfsetspeed(t, speed)
                     99:        struct termios *t;
                    100: {
                    101:        t->c_ispeed = t->c_ospeed = speed;
                    102: }
                    103: 
                    104: cfmakeraw(t)
                    105:        struct termios *t;
                    106: {
                    107:        t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|INLCR|IGNCR|ICRNL|IXON);
                    108:        t->c_oflag &= ~(ONLCR|OXTABS);
                    109:        t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
                    110:        /* set MIN/TIME */
                    111: }

unix.superglobalmegacorp.com

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