From 9e2c37a8b2ac0021dea18a7e99656f271d93e722 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sat, 13 Feb 2021 10:46:09 +0330 Subject: [PATCH] LibC: Add 'cfmakeraw()' --- Userland/Libraries/LibC/termios.cpp | 12 ++++++++++++ Userland/Libraries/LibC/termios.h | 1 + 2 files changed, 13 insertions(+) diff --git a/Userland/Libraries/LibC/termios.cpp b/Userland/Libraries/LibC/termios.cpp index c1c4238b5c..66935db700 100644 --- a/Userland/Libraries/LibC/termios.cpp +++ b/Userland/Libraries/LibC/termios.cpp @@ -145,4 +145,16 @@ int cfsetospeed(struct termios* tp, speed_t speed) } __RETURN_WITH_ERRNO(ospeed, 0, -1); } + +void cfmakeraw(struct termios* tp) +{ + if (!tp) + return; + + auto& termios = *tp; + termios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); + termios.c_lflag &= ~OPOST; + termios.c_cflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); + termios.c_cflag |= CS8; +} } diff --git a/Userland/Libraries/LibC/termios.h b/Userland/Libraries/LibC/termios.h index 028ddc06a5..0cd45b517e 100644 --- a/Userland/Libraries/LibC/termios.h +++ b/Userland/Libraries/LibC/termios.h @@ -56,6 +56,7 @@ speed_t cfgetispeed(const struct termios*); speed_t cfgetospeed(const struct termios*); int cfsetispeed(struct termios*, speed_t); int cfsetospeed(struct termios*, speed_t); +void cfmakeraw(struct termios*); /* c_cc characters */ #define VINTR 0