diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-02-12 00:22:29 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-02-12 00:22:29 -0500 |
commit | 0b44a0315b47dd8eced9f3b7f31580cf14bbfc01 (patch) | |
tree | 6eaef0d8a720fa3da580de87b647fff796fe80b3 /src/termios | |
download | musl-0b44a0315b47dd8eced9f3b7f31580cf14bbfc01.tar.gz musl-0b44a0315b47dd8eced9f3b7f31580cf14bbfc01.tar.bz2 musl-0b44a0315b47dd8eced9f3b7f31580cf14bbfc01.tar.xz musl-0b44a0315b47dd8eced9f3b7f31580cf14bbfc01.zip |
initial check-in, version 0.5.0v0.5.0
Diffstat (limited to 'src/termios')
-rw-r--r-- | src/termios/cfgetospeed.c | 12 | ||||
-rw-r--r-- | src/termios/cfsetospeed.c | 22 | ||||
-rw-r--r-- | src/termios/tcdrain.c | 7 | ||||
-rw-r--r-- | src/termios/tcflow.c | 7 | ||||
-rw-r--r-- | src/termios/tcflush.c | 7 | ||||
-rw-r--r-- | src/termios/tcgetattr.c | 10 | ||||
-rw-r--r-- | src/termios/tcgetsid.c | 10 | ||||
-rw-r--r-- | src/termios/tcsendbreak.c | 8 | ||||
-rw-r--r-- | src/termios/tcsetattr.c | 13 |
9 files changed, 96 insertions, 0 deletions
diff --git a/src/termios/cfgetospeed.c b/src/termios/cfgetospeed.c new file mode 100644 index 00000000..0ebc198c --- /dev/null +++ b/src/termios/cfgetospeed.c @@ -0,0 +1,12 @@ +#include <termios.h> +#include <sys/ioctl.h> + +speed_t cfgetospeed(const struct termios *tio) +{ + return tio->c_cflag & CBAUD; +} + +speed_t cfgetispeed(const struct termios *tio) +{ + return cfgetospeed(tio); +} diff --git a/src/termios/cfsetospeed.c b/src/termios/cfsetospeed.c new file mode 100644 index 00000000..80c790f1 --- /dev/null +++ b/src/termios/cfsetospeed.c @@ -0,0 +1,22 @@ +#include <termios.h> +#include <sys/ioctl.h> +#include <errno.h> +#include "libc.h" + +int cfsetospeed(struct termios *tio, speed_t speed) +{ + if (speed & ~CBAUD) { + errno = EINVAL; + return -1; + } + tio->c_cflag &= ~CBAUD; + tio->c_cflag |= speed; + return 0; +} + +int cfsetispeed(struct termios *tio, speed_t speed) +{ + return speed ? cfsetospeed(tio, speed) : 0; +} + +weak_alias(cfsetospeed, cfsetspeed); diff --git a/src/termios/tcdrain.c b/src/termios/tcdrain.c new file mode 100644 index 00000000..c51dd401 --- /dev/null +++ b/src/termios/tcdrain.c @@ -0,0 +1,7 @@ +#include <termios.h> +#include <sys/ioctl.h> + +int tcdrain(int fd) +{ + return ioctl(fd, TCSBRK, 1); +} diff --git a/src/termios/tcflow.c b/src/termios/tcflow.c new file mode 100644 index 00000000..c7fc3fe2 --- /dev/null +++ b/src/termios/tcflow.c @@ -0,0 +1,7 @@ +#include <termios.h> +#include <sys/ioctl.h> + +int tcflow(int fd, int action) +{ + return ioctl(fd, TCXONC, action); +} diff --git a/src/termios/tcflush.c b/src/termios/tcflush.c new file mode 100644 index 00000000..50222669 --- /dev/null +++ b/src/termios/tcflush.c @@ -0,0 +1,7 @@ +#include <termios.h> +#include <sys/ioctl.h> + +int tcflush(int fd, int queue) +{ + return ioctl(fd, TCFLSH, queue); +} diff --git a/src/termios/tcgetattr.c b/src/termios/tcgetattr.c new file mode 100644 index 00000000..d9ce786e --- /dev/null +++ b/src/termios/tcgetattr.c @@ -0,0 +1,10 @@ +#include <termios.h> +#include <sys/ioctl.h> +#include <string.h> + +int tcgetattr(int fd, struct termios *tio) +{ + if (ioctl(fd, TCGETS, tio)) + return -1; + return 0; +} diff --git a/src/termios/tcgetsid.c b/src/termios/tcgetsid.c new file mode 100644 index 00000000..1053fd64 --- /dev/null +++ b/src/termios/tcgetsid.c @@ -0,0 +1,10 @@ +#include <termios.h> +#include <sys/ioctl.h> + +pid_t tcgetsid(int fd) +{ + int sid; + if (ioctl(fd, TIOCGSID, &sid) < 0) + return -1; + return sid; +} diff --git a/src/termios/tcsendbreak.c b/src/termios/tcsendbreak.c new file mode 100644 index 00000000..b6df0a23 --- /dev/null +++ b/src/termios/tcsendbreak.c @@ -0,0 +1,8 @@ +#include <termios.h> +#include <sys/ioctl.h> + +int tcsendbreak(int fd, int dur) +{ + /* nonzero duration is implementation-defined, so ignore it */ + return ioctl(fd, TCSBRK, 0); +} diff --git a/src/termios/tcsetattr.c b/src/termios/tcsetattr.c new file mode 100644 index 00000000..e9a168f3 --- /dev/null +++ b/src/termios/tcsetattr.c @@ -0,0 +1,13 @@ +#include <termios.h> +#include <sys/ioctl.h> +#include <string.h> +#include <errno.h> + +int tcsetattr(int fd, int act, const struct termios *tio) +{ + if (act < 0 || act > 2) { + errno = EINVAL; + return -1; + } + return ioctl(fd, TCSETS+act, tio); +} |