From 8a0efa53e44919bcf5ccb1d3353618a82afdf8bc Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 17 Feb 2000 19:39:52 +0000 Subject: import newlib-2000-02-17 snapshot --- newlib/libc/sys/sysvi386/tcline.c | 84 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 newlib/libc/sys/sysvi386/tcline.c (limited to 'newlib/libc/sys/sysvi386/tcline.c') diff --git a/newlib/libc/sys/sysvi386/tcline.c b/newlib/libc/sys/sysvi386/tcline.c new file mode 100644 index 000000000..39d4699e0 --- /dev/null +++ b/newlib/libc/sys/sysvi386/tcline.c @@ -0,0 +1,84 @@ +#define _NO_MACROS +#include +#include +#include + +int +tcsendbreak (int fd, int dur) { + do { + if (_ioctl (fd, _TCSBRK, 0) == -1) + return -1; + } while (dur--); + return 0; +} + +int +tcdrain (int fd) { + return _ioctl (fd, _TCSBRK, 1); +} + +int +tcflush(int fd, int what) { + return _ioctl (fd, _TCFLSH, what); +} + +/* + * I'm not positive about this function. I *think* it's right, + * but I could be missing something. + */ + +int +tcflow (int fd, int action) { + struct termios t; + + switch (action) { + case TCOOFF: + case TCOON: + return _ioctl (fd, _TCXONC, action); +/* + * Here is where I'm not terribly certain. 1003.1 says: + * if action is TCIOFF, the system shall transmit a STOP + * character, which is intended to cause the terminal device + * to stop transmitting data to the system. (Similarly for + * TCION.) + * I *assume* that means I find out what VSTOP for the + * terminal device is, and then write it. 1003.1 also does + * not say what happens if c_cc[VSTOP] is _POSIX_VDISABLE; + * I assume it should reaturn EINVAL, so that's what I do. + * Anyway, here's the code. It might or might not be right. + */ + case TCIOFF: + if (tcgetattr (fd, &t) == -1) + return -1; + if (tcgetattr (fd, &t) == -1) + return -1; +#ifdef _POSIX_VDISABLE + if (t.c_cc[VSTOP] == _POSIX_VDISABLE) { + errno = EINVAL; + return -1; + } +#endif + if (write (fd, &t.c_cc[VSTOP], 1) == 1) + return 0; + else + return -1; + case TCION: + if (tcgetattr (fd, &t) == -1) + return -1; + if (tcgetattr (fd, &t) == -1) + return -1; +#ifdef _POSIX_VDISABLE + if (t.c_cc[VSTART] == _POSIX_VDISABLE) { + errno = EINVAL; + return -1; + } +#endif + if (write (fd, &t.c_cc[VSTART], 1) == 1) + return 0; + else + return -1; + default: + errno = EINVAL; + return -1; + } +} -- cgit v1.2.3