/*- * Copyright (c) 1989 The Regents of the University of California. * All rights reserved. * * %sccs.include.redist.c% */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)termios.c 5.5 (Berkeley) 04/02/91"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include #include #include #include int tcgetattr(fd, t) int fd; struct termios *t; { return(ioctl(fd, TIOCGETA, t)); } int tcsetattr(fd, opt, t) int fd, opt; const struct termios *t; { struct termios localterm; if (opt & TCSASOFT) { localterm = *t; localterm.c_cflag |= CIGNORE; t = &localterm; opt &= TCSASOFT; } if (opt == TCSANOW) return (ioctl(fd, TIOCSETA, t)); else if (opt == TCSADRAIN) return (ioctl(fd, TIOCSETAW, t)); return (ioctl(fd, TIOCSETAF, t)); } int #if __STDC__ tcsetpgrp(int fd, pid_t pgrp) #else tcsetpgrp(fd, pgrp) int fd; pid_t pgrp; #endif { return(ioctl(fd, TIOCSPGRP, &pgrp)); } pid_t tcgetpgrp(fd) { int s; if (ioctl(fd, TIOCGPGRP, &s) < 0) return((pid_t)-1); return((pid_t)s); } speed_t cfgetospeed(t) const struct termios *t; { return(t->c_ospeed); } speed_t cfgetispeed(t) const struct termios *t; { return(t->c_ispeed); } int cfsetospeed(t, speed) struct termios *t; speed_t speed; { t->c_ospeed = speed; return 0; } int cfsetispeed(t, speed) struct termios *t; speed_t speed; { t->c_ispeed = speed; return 0; } void cfsetspeed(t, speed) struct termios *t; speed_t speed; { t->c_ispeed = t->c_ospeed = speed; } /* * Make a pre-existing termios structure into "raw" mode: * character-at-a-time mode with no characters interpreted, * 8-bit data path. */ void cfmakeraw(t) struct termios *t; { t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); t->c_oflag &= ~OPOST; t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); t->c_cflag &= ~(CSIZE|PARENB); t->c_cflag |= CS8; /* set MIN/TIME */ }