From 0cc9b20c15460213e488bf5e70963b941482f628 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Tue, 14 Jan 2025 16:06:02 -0600 Subject: Add source. --- sdk/dev/stty.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 sdk/dev/stty.c (limited to 'sdk/dev/stty.c') diff --git a/sdk/dev/stty.c b/sdk/dev/stty.c new file mode 100644 index 0000000..9a465da --- /dev/null +++ b/sdk/dev/stty.c @@ -0,0 +1,29 @@ +/* + * Portable routines to get and set serial device attributes. + * $Id$ + * Copyright (c) 1997 by Tycho Softworks. + * For conditions of distribution and reuse see product license. + */ + +#include + +#ifndef TERMIOS_H_MISSING +#include + +stty_t getstty(fd_t fd) +{ + stty_t stty = (stty_t)malloc(sizeof(struct termios)); + tcgetattr(fd, stty); + return stty; +} + +void putstty(fd_t fd, stty_t stty, bool now) +{ + if(now) + tcsetattr(fd, TCSANOW, stty); + else + tcsetattr(fd, TCSADRAIN, stty); + free(stty); +} +#endif + -- cgit v1.2.3-54-g00ecf