From a1f2a6b1795c0897dfbf085be37451915d3e848a Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 16 Oct 2011 16:44:17 +0000 Subject: [PATCH] Add cfmakeraw. Like cf{get/set}{i/o}speed, it iisn't POSIx standard but is used often enough and simple enough to write that we should allow it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42865 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/posix/termios.h | 1 + src/system/libroot/posix/termios.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/headers/posix/termios.h b/headers/posix/termios.h index 5d01343d46..88db94675a 100644 --- a/headers/posix/termios.h +++ b/headers/posix/termios.h @@ -223,6 +223,7 @@ extern speed_t cfgetispeed(const struct termios *termios); extern speed_t cfgetospeed(const struct termios *termios); extern int cfsetispeed(struct termios *termios, speed_t speed); extern int cfsetospeed(struct termios *termios, speed_t speed); +extern void cfmakeraw(struct termios *termios); extern int tcgetattr(int fd, struct termios *termios); extern int tcsetattr(int fd, int option, const struct termios *termios); extern int tcsendbreak(int fd, int duration); diff --git a/src/system/libroot/posix/termios.c b/src/system/libroot/posix/termios.c index 77d3e8dd46..0158f86b30 100644 --- a/src/system/libroot/posix/termios.c +++ b/src/system/libroot/posix/termios.c @@ -146,3 +146,15 @@ cfsetospeed(struct termios *termios, speed_t speed) termios->c_cflag |= speed; return 0; } + + +void +cfmakeraw(struct termios *termios) +{ + termios->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR + | ICRNL | IXON); + termios->c_oflag &= ~OPOST; + termios->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); + termios->c_cflag &= ~(CSIZE | PARENB); + termios->c_cflag |= CS8; +}