From cb25a0921b6797fdfccb28eb3b8d73ff38ef8ae6 Mon Sep 17 00:00:00 2001 From: Daniel Reinhold Date: Sun, 4 May 2003 09:11:25 +0000 Subject: [PATCH] implemented tcsetattr() git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3175 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/termios/Jamfile | 1 + src/kernel/libroot/posix/termios/tcsetattr.c | 38 ++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/kernel/libroot/posix/termios/tcsetattr.c diff --git a/src/kernel/libroot/posix/termios/Jamfile b/src/kernel/libroot/posix/termios/Jamfile index 14604e3274..d6187a6cb8 100644 --- a/src/kernel/libroot/posix/termios/Jamfile +++ b/src/kernel/libroot/posix/termios/Jamfile @@ -2,6 +2,7 @@ SubDir OBOS_TOP src kernel libroot posix termios ; KernelMergeObject posix_termios.o : <$(SOURCE_GRIST)>termios.c + <$(SOURCE_GRIST)>tcsetattr.c : -fPIC -DPIC ; diff --git a/src/kernel/libroot/posix/termios/tcsetattr.c b/src/kernel/libroot/posix/termios/tcsetattr.c new file mode 100644 index 0000000000..38527268a0 --- /dev/null +++ b/src/kernel/libroot/posix/termios/tcsetattr.c @@ -0,0 +1,38 @@ +/* +** Copyright 2003, Daniel Reinhold, danielre@users.sf.net. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + +#include +#include +#include + + +/* + * tcsetattr - set the attributes for the tty device at fd + * (using the structure in the last arg for the values) + */ +int +tcsetattr(int fd, int opt, const struct termios *tp) +{ + switch (opt) { + case TCSANOW: + // set the attributes immediately + return ioctl(fd, TCSETA, tp); + + case TCSADRAIN: + // wait for ouput to finish before setting the attributes + return ioctl(fd, TCSETAW, tp); + + case TCSAFLUSH: + // wait for ouput to finish and then flush the input buffer + // before setting the attributes + return ioctl(fd, TCSETAF, tp); + + default: + // no other valid options + errno = EINVAL; + return -1; + } +} +