summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Samuelsson <msamuelsson@storvix.eu>2023-07-14 10:07:59 +0200
committercos <cos>2023-07-14 18:19:42 +0200
commitf67d4809ab56e82df883ea01368a9f90803d7d14 (patch)
treeaff0c0d58bd3d1bbd4f20404c51a62a6d89cac52
parenteb4b8271dce28a44461799e2ba24d1ffdf8ad897 (diff)
downloadtermios-rs-topic/use_bindgen.zip
Switch implementation to use termios-systopic/use_bindgen
-rw-r--r--termios/CHANGELOG.md4
-rw-r--r--termios/Cargo.toml3
-rw-r--r--termios/src/os/android.rs235
-rw-r--r--termios/src/os/common.rs30
-rw-r--r--termios/src/os/dragonfly.rs206
-rw-r--r--termios/src/os/freebsd.rs166
-rw-r--r--termios/src/os/illumos.rs244
-rw-r--r--termios/src/os/linux.rs246
-rw-r--r--termios/src/os/macos.rs237
-rw-r--r--termios/src/os/mod.rs22
-rw-r--r--termios/src/os/netbsd.rs203
-rw-r--r--termios/src/os/openbsd.rs195
-rw-r--r--termios/src/os/solaris.rs244
-rw-r--r--termios/src/os/unknown.rs5
14 files changed, 595 insertions, 1445 deletions
diff --git a/termios/CHANGELOG.md b/termios/CHANGELOG.md
index b15c67f..931201f 100644
--- a/termios/CHANGELOG.md
+++ b/termios/CHANGELOG.md
@@ -1,5 +1,9 @@
# Change Log
+## 0.3.4 (2023-07-14)
+### Changed
+* Added support for any POSIX platform, without needing to to handcraft bindings.
+
## 0.3.2 (2020-04-05)
### Added
* ([#22](https://github.com/dcuddeback/termios-rs/pull/22))
diff --git a/termios/Cargo.toml b/termios/Cargo.toml
index bb3ee55..57c8dc3 100644
--- a/termios/Cargo.toml
+++ b/termios/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "termios"
-version = "0.3.3"
+version = "0.3.4"
authors = ["David Cuddeback <david.cuddeback@gmail.com>"]
description = "Safe bindings for the termios library."
license = "MIT"
@@ -12,3 +12,4 @@ keywords = ["termios", "tty", "terminal", "posix"]
[dependencies]
libc = "0.2"
+termios-sys = { version = "0.1", path = "../termios-sys" }
diff --git a/termios/src/os/android.rs b/termios/src/os/android.rs
index b991579..0b7e7a8 100644
--- a/termios/src/os/android.rs
+++ b/termios/src/os/android.rs
@@ -1,176 +1,75 @@
-#![allow(non_camel_case_types)]
+extern crate termios_sys;
-use libc::{c_int,c_uint,c_uchar};
+pub use ::os::common::*;
-pub type cc_t = c_uchar;
-pub type speed_t = c_uint;
-pub type tcflag_t = c_uint;
+pub use self::termios_sys::{
+ termios,
+ NCCS,
-#[derive(Debug,Copy,Clone,Eq,PartialEq)]
-#[repr(C)]
-pub struct termios {
- pub c_iflag: tcflag_t,
- pub c_oflag: tcflag_t,
- pub c_cflag: tcflag_t,
- pub c_lflag: tcflag_t,
- c_line: cc_t,
- pub c_cc: [cc_t; NCCS]
-}
+ // c_cc characters
+ VSWTC,
+ VREPRINT,
+ VDISCARD,
+ VWERASE,
+ VLNEXT,
-pub const NCCS: usize = 19;
+ // c_iflag bits
+ IUCLC,
+ IMAXBEL,
+ IUTF8,
-// c_cc characters
-pub const VINTR: usize = 0;
-pub const VQUIT: usize = 1;
-pub const VERASE: usize = 2;
-pub const VKILL: usize = 3;
-pub const VEOF: usize = 4;
-pub const VTIME: usize = 5;
-pub const VMIN: usize = 6;
-pub const VSWTC: usize = 7;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VEOL: usize = 11;
-pub const VREPRINT: usize = 12;
-pub const VDISCARD: usize = 13;
-pub const VWERASE: usize = 14;
-pub const VLNEXT: usize = 15;
-pub const VEOL2: usize = 16;
+ // c_oflag bits
+ OLCUC,
+ OFILL,
+ OFDEL,
+ NLDLY,
+ NL0,
+ NL1,
+ CRDLY,
+ CR0,
+ CR1,
+ CR2,
+ CR3,
+ TABDLY,
+ TAB1,
+ TAB2,
+ TAB3,
+ BSDLY,
+ BS0,
+ BS1,
+ FFDLY,
+ FF0,
+ FF1,
+ VTDLY,
+ VT0,
+ VT1,
+ XTABS,
-// c_iflag bits
-pub const IGNBRK: tcflag_t = 0o000001;
-pub const BRKINT: tcflag_t = 0o000002;
-pub const IGNPAR: tcflag_t = 0o000004;
-pub const PARMRK: tcflag_t = 0o000010;
-pub const INPCK: tcflag_t = 0o000020;
-pub const ISTRIP: tcflag_t = 0o000040;
-pub const INLCR: tcflag_t = 0o000100;
-pub const IGNCR: tcflag_t = 0o000200;
-pub const ICRNL: tcflag_t = 0o000400;
-pub const IUCLC: tcflag_t = 0o001000;
-pub const IXON: tcflag_t = 0o002000;
-pub const IXANY: tcflag_t = 0o004000;
-pub const IXOFF: tcflag_t = 0o010000;
-pub const IMAXBEL: tcflag_t = 0o020000;
-pub const IUTF8: tcflag_t = 0o040000;
+ // c_cflag bits
+ CBAUD,
+ CBAUDEX,
+ CIBAUD,
+ CMSPAR,
+ CRTSCTS,
-// c_oflag bits
-pub const OPOST: tcflag_t = 0o000001;
-pub const OLCUC: tcflag_t = 0o000002;
-pub const ONLCR: tcflag_t = 0o000004;
-pub const OCRNL: tcflag_t = 0o000010;
-pub const ONOCR: tcflag_t = 0o000020;
-pub const ONLRET: tcflag_t = 0o000040;
-pub const OFILL: tcflag_t = 0o000100;
-pub const OFDEL: tcflag_t = 0o000200;
-pub const NLDLY: tcflag_t = 0o000400;
-pub const NL0: tcflag_t = 0o000000;
-pub const NL1: tcflag_t = 0o000400;
-pub const CRDLY: tcflag_t = 0o003000;
-pub const CR0: tcflag_t = 0o000000;
-pub const CR1: tcflag_t = 0o001000;
-pub const CR2: tcflag_t = 0o002000;
-pub const CR3: tcflag_t = 0o003000;
-pub const TABDLY: tcflag_t = 0o014000;
-pub const TAB0: tcflag_t = 0o000000;
-pub const TAB1: tcflag_t = 0o004000;
-pub const TAB2: tcflag_t = 0o010000;
-pub const TAB3: tcflag_t = 0o014000;
-pub const BSDLY: tcflag_t = 0o020000;
-pub const BS0: tcflag_t = 0o000000;
-pub const BS1: tcflag_t = 0o020000;
-pub const FFDLY: tcflag_t = 0o100000;
-pub const FF0: tcflag_t = 0o000000;
-pub const FF1: tcflag_t = 0o100000;
-pub const VTDLY: tcflag_t = 0o040000;
-pub const VT0: tcflag_t = 0o000000;
-pub const VT1: tcflag_t = 0o040000;
-pub const XTABS: tcflag_t = 0o014000;
+ // c_lflag bits
+ XCASE,
+ FLUSHO,
+ PENDIN,
+ EXTPROC,
-// c_cflag bits
-pub const CBAUD: tcflag_t = 0o010017;
-pub const CSIZE: tcflag_t = 0o000060;
-pub const CS5: tcflag_t = 0o000000;
-pub const CS6: tcflag_t = 0o000020;
-pub const CS7: tcflag_t = 0o000040;
-pub const CS8: tcflag_t = 0o000060;
-pub const CSTOPB: tcflag_t = 0o000100;
-pub const CREAD: tcflag_t = 0o000200;
-pub const PARENB: tcflag_t = 0o000400;
-pub const PARODD: tcflag_t = 0o001000;
-pub const HUPCL: tcflag_t = 0o002000;
-pub const CLOCAL: tcflag_t = 0o004000;
-pub const CBAUDEX: tcflag_t = 0o010000;
-pub const CIBAUD: tcflag_t = 0o02003600000;
-pub const CMSPAR: tcflag_t = 0o10000000000;
-pub const CRTSCTS: tcflag_t = 0o20000000000;
-
-// c_lflag bits
-pub const ISIG: tcflag_t = 0o000001;
-pub const ICANON: tcflag_t = 0o000002;
-pub const XCASE: tcflag_t = 0o000004;
-pub const ECHO: tcflag_t = 0o000010;
-pub const ECHOE: tcflag_t = 0o000020;
-pub const ECHOK: tcflag_t = 0o000040;
-pub const ECHONL: tcflag_t = 0o000100;
-pub const NOFLSH: tcflag_t = 0o000200;
-pub const TOSTOP: tcflag_t = 0o000400;
-pub const ECHOCTL: tcflag_t = 0o001000;
-pub const ECHOPRT: tcflag_t = 0o002000;
-pub const ECHOKE: tcflag_t = 0o004000;
-pub const FLUSHO: tcflag_t = 0o010000;
-pub const PENDIN: tcflag_t = 0o040000;
-pub const IEXTEN: tcflag_t = 0o100000;
-pub const EXTPROC: tcflag_t = 0o200000;
-
-// baud rates
-pub const B0: speed_t = 0o000000;
-pub const B50: speed_t = 0o000001;
-pub const B75: speed_t = 0o000002;
-pub const B110: speed_t = 0o000003;
-pub const B134: speed_t = 0o000004;
-pub const B150: speed_t = 0o000005;
-pub const B200: speed_t = 0o000006;
-pub const B300: speed_t = 0o000007;
-pub const B600: speed_t = 0o000010;
-pub const B1200: speed_t = 0o000011;
-pub const B1800: speed_t = 0o000012;
-pub const B2400: speed_t = 0o000013;
-pub const B4800: speed_t = 0o000014;
-pub const B9600: speed_t = 0o000015;
-pub const B19200: speed_t = 0o000016;
-pub const B38400: speed_t = 0o000017;
-pub const EXTA: speed_t = B19200;
-pub const EXTB: speed_t = B38400;
-pub const B57600: speed_t = 0o010001;
-pub const B115200: speed_t = 0o010002;
-pub const B230400: speed_t = 0o010003;
-pub const B460800: speed_t = 0o010004;
-pub const B500000: speed_t = 0o010005;
-pub const B576000: speed_t = 0o010006;
-pub const B921600: speed_t = 0o010007;
-pub const B1000000: speed_t = 0o010010;
-pub const B1152000: speed_t = 0o010011;
-pub const B1500000: speed_t = 0o010012;
-pub const B2000000: speed_t = 0o010013;
-pub const B2500000: speed_t = 0o010014;
-pub const B3000000: speed_t = 0o010015;
-pub const B3500000: speed_t = 0o010016;
-pub const B4000000: speed_t = 0o010017;
-
-// tcflow()
-pub const TCOOFF: c_int = 0;
-pub const TCOON: c_int = 1;
-pub const TCIOFF: c_int = 2;
-pub const TCION: c_int = 3;
-
-// tcflush()
-pub const TCIFLUSH: c_int = 0;
-pub const TCOFLUSH: c_int = 1;
-pub const TCIOFLUSH: c_int = 2;
-
-// tcsetattr()
-pub const TCSANOW: c_int = 0;
-pub const TCSADRAIN: c_int = 1;
-pub const TCSAFLUSH: c_int = 2;
+ // baud rates
+ EXTA,
+ EXTB,
+ B57600,
+ B115200,
+ B230400,
+ B460800,
+ B576000,
+ B921600,
+ B1000000,
+ B1152000,
+ B2500000,
+ B3500000,
+ B4000000,
+};
diff --git a/termios/src/os/common.rs b/termios/src/os/common.rs
new file mode 100644
index 0000000..4ebf528
--- /dev/null
+++ b/termios/src/os/common.rs
@@ -0,0 +1,30 @@
+extern crate termios_sys;
+
+pub use self::termios_sys::{
+ // types
+ cc_t,speed_t,tcflag_t,
+
+ // c_cc subscripts
+ VEOF,VEOL,VERASE,VINTR,VKILL,VMIN,VQUIT,VSTART,VSTOP,VSUSP,VTIME,
+
+ // input modes
+ BRKINT,ICRNL,IGNBRK,IGNCR,IGNPAR,INLCR,INPCK,ISTRIP,IXANY,IXOFF,IXON,PARMRK,
+
+ // output modes
+ OPOST,ONLCR,OCRNL,ONOCR,ONLRET,
+
+ // baud rate selection
+ B0,B50,B75,B110,B134,B150,B200,B300,B600,B1200,B1800,B2400,B4800,B9600,B19200,B38400,
+
+ // control modes
+ CSIZE,CS5,CS6,CS7,CS8,CSTOPB,CREAD,PARENB,PARODD,HUPCL,CLOCAL,
+
+ // local modes
+ ECHO,ECHOE,ECHOK,ECHONL,ICANON,IEXTEN,ISIG,NOFLSH,TOSTOP,
+
+ // attribute selection
+ TCSANOW,TCSADRAIN,TCSAFLUSH,
+
+ // line control
+ TCIFLUSH,TCIOFLUSH,TCOFLUSH,TCIOFF,TCION,TCOOFF,TCOON,
+};
diff --git a/termios/src/os/dragonfly.rs b/termios/src/os/dragonfly.rs
index ad51ee2..037e9c2 100644
--- a/termios/src/os/dragonfly.rs
+++ b/termios/src/os/dragonfly.rs
@@ -1,151 +1,55 @@
-#![allow(non_camel_case_types)]
-
-use libc::{c_int,c_uint,c_uchar};
-
-pub type cc_t = c_uchar;
-pub type speed_t = c_uint;
-pub type tcflag_t = c_uint;
-
-#[derive(Debug,Copy,Clone,Eq,PartialEq)]
-#[repr(C)]
-pub struct termios {
- pub c_iflag: tcflag_t,
- pub c_oflag: tcflag_t,
- pub c_cflag: tcflag_t,
- pub c_lflag: tcflag_t,
- pub c_cc: [cc_t; NCCS],
- c_ispeed: speed_t,
- c_ospeed: speed_t
-}
-
-pub const NCCS: usize = 20;
-
-// c_cc characters
-pub const VEOF: usize = 0;
-pub const VEOL: usize = 1;
-pub const VEOL2: usize = 2;
-pub const VERASE: usize = 3;
-pub const VWERASE: usize = 4;
-pub const VKILL: usize = 5;
-pub const VREPRINT: usize = 6;
-pub const VERASE2: usize = 7;
-pub const VINTR: usize = 8;
-pub const VQUIT: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VDSUSP: usize = 11;
-pub const VSTART: usize = 12;
-pub const VSTOP: usize = 13;
-pub const VLNEXT: usize = 14;
-pub const VDISCARD: usize = 15;
-pub const VMIN: usize = 16;
-pub const VTIME: usize = 17;
-pub const VSTATUS: usize = 18;
-pub const VCHECKPT: usize = 19;
-
-// c_iflag bits
-pub const IGNBRK: tcflag_t = 0x00000001;
-pub const BRKINT: tcflag_t = 0x00000002;
-pub const IGNPAR: tcflag_t = 0x00000004;
-pub const PARMRK: tcflag_t = 0x00000008;
-pub const INPCK: tcflag_t = 0x00000010;
-pub const ISTRIP: tcflag_t = 0x00000020;
-pub const INLCR: tcflag_t = 0x00000040;
-pub const IGNCR: tcflag_t = 0x00000080;
-pub const ICRNL: tcflag_t = 0x00000100;
-pub const IXON: tcflag_t = 0x00000200;
-pub const IXOFF: tcflag_t = 0x00000400;
-pub const IXANY: tcflag_t = 0x00000800;
-pub const IMAXBEL: tcflag_t = 0x00002000;
-
-// c_oflag bits
-pub const OPOST: tcflag_t = 0x00000001;
-pub const ONLCR: tcflag_t = 0x00000002;
-pub const OXTABS: tcflag_t = 0x00000004;
-pub const ONOEOT: tcflag_t = 0x00000008;
-pub const OCRNL: tcflag_t = 0x00000010;
-pub const ONOCR: tcflag_t = 0x00000020;
-pub const ONLRET: tcflag_t = 0x00000040;
-
-// c_cflag bits
-pub const CIGNORE: tcflag_t = 0x00000001;
-pub const CSIZE: tcflag_t = 0x00000300;
-pub const CS5: tcflag_t = 0x00000000;
-pub const CS6: tcflag_t = 0x00000100;
-pub const CS7: tcflag_t = 0x00000200;
-pub const CS8: tcflag_t = 0x00000300;
-pub const CSTOPB: tcflag_t = 0x00000400;
-pub const CREAD: tcflag_t = 0x00000800;
-pub const PARENB: tcflag_t = 0x00001000;
-pub const PARODD: tcflag_t = 0x00002000;
-pub const HUPCL: tcflag_t = 0x00004000;
-pub const CLOCAL: tcflag_t = 0x00008000;
-pub const CCTS_OFLOW: tcflag_t = 0x00010000;
-pub const CRTSCTS: tcflag_t = CCTS_OFLOW | CRTS_IFLOW;
-pub const CRTS_IFLOW: tcflag_t = 0x00020000;
-pub const CDTR_IFLOW: tcflag_t = 0x00040000;
-pub const CDSR_OFLOW: tcflag_t = 0x00080000;
-pub const CCAR_OFLOW: tcflag_t = 0x00100000;
-pub const MDMBUF: tcflag_t = 0x00100000;
-
-// c_lflag bits
-pub const ECHOKE: tcflag_t = 0x00000001;
-pub const ECHOE: tcflag_t = 0x00000002;
-pub const ECHOK: tcflag_t = 0x00000004;
-pub const ECHO: tcflag_t = 0x00000008;
-pub const ECHONL: tcflag_t = 0x00000010;
-pub const ECHOPRT: tcflag_t = 0x00000020;
-pub const ECHOCTL: tcflag_t = 0x00000040;
-pub const ISIG: tcflag_t = 0x00000080;
-pub const ICANON: tcflag_t = 0x00000100;
-pub const ALTWERASE: tcflag_t = 0x00000200;
-pub const IEXTEN: tcflag_t = 0x00000400;
-pub const EXTPROC: tcflag_t = 0x00000800;
-pub const TOSTOP: tcflag_t = 0x00400000;
-pub const FLUSHO: tcflag_t = 0x00800000;
-pub const NOKERNINFO: tcflag_t = 0x02000000;
-pub const PENDIN: tcflag_t = 0x20000000;
-pub const NOFLSH: tcflag_t = 0x80000000;
-
-// baud rates
-pub const B0: speed_t = 0;
-pub const B50: speed_t = 50;
-pub const B75: speed_t = 75;
-pub const B110: speed_t = 110;
-pub const B134: speed_t = 134;
-pub const B150: speed_t = 150;
-pub const B200: speed_t = 200;
-pub const B300: speed_t = 300;
-pub const B600: speed_t = 600;
-pub const B1200: speed_t = 1200;
-pub const B1800: speed_t = 1800;
-pub const B2400: speed_t = 2400;
-pub const B4800: speed_t = 4800;
-pub const B9600: speed_t = 9600;
-pub const B19200: speed_t = 19200;
-pub const B38400: speed_t = 38400;
-pub const B7200: speed_t = 7200;
-pub const B14400: speed_t = 14400;
-pub const B28800: speed_t = 28800;
-pub const B57600: speed_t = 57600;
-pub const B76800: speed_t = 76800;
-pub const B115200: speed_t = 115200;
-pub const B230400: speed_t = 230400;
-pub const EXTA: speed_t = 19200;
-pub const EXTB: speed_t = 38400;
-
-// tcsetattr()
-pub const TCSANOW: c_int = 0;
-pub const TCSADRAIN: c_int = 1;
-pub const TCSAFLUSH: c_int = 2;
-pub const TCSASOFT: c_int = 0x10;
-
-// tcflush()
-pub const TCIFLUSH: c_int = 1;
-pub const TCOFLUSH: c_int = 2;
-pub const TCIOFLUSH: c_int = 3;
-
-// tcflow()
-pub const TCOOFF: c_int = 1;
-pub const TCOON: c_int = 2;
-pub const TCIOFF: c_int = 3;
-pub const TCION: c_int = 4;
+extern crate termios_sys;
+
+pub use ::os::common::*;
+
+pub use self::termios_sys::{
+ termios,
+ NCCS,
+
+ // c_cc characters
+ VWERASE,
+ VREPRINT,
+ VDSUSP,
+ VLNEXT,
+ VDISCARD,
+ VSTATUS,
+ VCHECKPT,
+
+ // c_iflag bits
+ IMAXBEL,
+
+ // c_oflag bits
+ OXTABS,
+ ONOEOT,
+
+ // c_cflag bits
+ CIGNORE,
+ CCTS_OFLOW,
+ CRTSCTS,
+ CRTS_IFLOW,
+ CDTR_IFLOW,
+ CDSR_OFLOW,
+ CCAR_OFLOW,
+ MDMBUF,
+
+ // c_lflag bits
+ ALTWERASE,
+ EXTPROC,
+ FLUSHO,
+ NOKERNINFO,
+ PENDIN,
+
+ // baud rates
+ B7200,
+ B14400,
+ B28800,
+ B57600,
+ B76800,
+ B115200,
+ B230400,
+ EXTA,
+ EXTB,
+
+ // tcsetattr()
+ TCSASOFT,
+};
diff --git a/termios/src/os/freebsd.rs b/termios/src/os/freebsd.rs
index 7baa5ce..ceecd18 100644
--- a/termios/src/os/freebsd.rs
+++ b/termios/src/os/freebsd.rs
@@ -1,155 +1,19 @@
-#![allow(non_camel_case_types)]
+extern crate termios_sys;
-use libc::{c_int,c_uint,c_uchar};
+pub use ::os::common::*;
-pub type cc_t = c_uchar;
-pub type speed_t = c_uint;
-pub type tcflag_t = c_uint;
+pub use self::termios_sys::{
+ termios,
+ NCCS,
-#[derive(Debug,Copy,Clone,Eq,PartialEq)]
-#[repr(C)]
-pub struct termios {
- pub c_iflag: tcflag_t,
- pub c_oflag: tcflag_t,
- pub c_cflag: tcflag_t,
- pub c_lflag: tcflag_t,
- pub c_cc: [cc_t; NCCS],
- c_ispeed: speed_t,
- c_ospeed: speed_t
-}
+ // c_cc characters
+ VWERASE,
+ VREPRINT,
+ VDSUSP,
+ VLNEXT,
+ VDISCARD,
+ VSTATUS,
-pub const NCCS: usize = 20;
-
-// c_cc characters
-pub const VEOF: usize = 0;
-pub const VEOL: usize = 1;
-pub const VEOL2: usize = 2;
-pub const VERASE: usize = 3;
-pub const VWERASE: usize = 4;
-pub const VKILL: usize = 5;
-pub const VREPRINT: usize = 6;
-pub const VERASE2: usize = 7;
-pub const VINTR: usize = 8;
-pub const VQUIT: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VDSUSP: usize = 11;
-pub const VSTART: usize = 12;
-pub const VSTOP: usize = 13;
-pub const VLNEXT: usize = 14;
-pub const VDISCARD: usize = 15;
-pub const VMIN: usize = 16;
-pub const VTIME: usize = 17;
-pub const VSTATUS: usize = 18;
-
-// c_iflag bits
-pub const IGNBRK: tcflag_t = 0x00000001;
-pub const BRKINT: tcflag_t = 0x00000002;
-pub const IGNPAR: tcflag_t = 0x00000004;
-pub const PARMRK: tcflag_t = 0x00000008;
-pub const INPCK: tcflag_t = 0x00000010;
-pub const ISTRIP: tcflag_t = 0x00000020;
-pub const INLCR: tcflag_t = 0x00000040;
-pub const IGNCR: tcflag_t = 0x00000080;
-pub const ICRNL: tcflag_t = 0x00000100;
-pub const IXON: tcflag_t = 0x00000200;
-pub const IXOFF: tcflag_t = 0x00000400;
-pub const IXANY: tcflag_t = 0x00000800;
-pub const IMAXBEL: tcflag_t = 0x00002000;
-
-// c_oflag bits
-pub const OPOST: tcflag_t = 0x00000001;
-pub const ONLCR: tcflag_t = 0x00000002;
-pub const TABDLY: tcflag_t = 0x00000004;
-pub const TAB0: tcflag_t = 0x00000000;
-pub const TAB3: tcflag_t = 0x00000004;
-pub const OXTABS: tcflag_t = TAB3;
-pub const ONOEOT: tcflag_t = 0x00000008;
-pub const OCRNL: tcflag_t = 0x00000010;
-pub const ONOCR: tcflag_t = 0x00000020;
-pub const ONLRET: tcflag_t = 0x00000040;
-
-// c_cflag bits
-pub const CIGNORE: tcflag_t = 0x00000001;
-pub const CSIZE: tcflag_t = 0x00000300;
-pub const CS5: tcflag_t = 0x00000000;
-pub const CS6: tcflag_t = 0x00000100;
-pub const CS7: tcflag_t = 0x00000200;
-pub const CS8: tcflag_t = 0x00000300;
-pub const CSTOPB: tcflag_t = 0x00000400;
-pub const CREAD: tcflag_t = 0x00000800;
-pub const PARENB: tcflag_t = 0x00001000;
-pub const PARODD: tcflag_t = 0x00002000;
-pub const HUPCL: tcflag_t = 0x00004000;
-pub const CLOCAL: tcflag_t = 0x00008000;
-pub const CCTS_OFLOW: tcflag_t = 0x00010000;
-pub const CRTSCTS: tcflag_t = CCTS_OFLOW | CRTS_IFLOW;
-pub const CRTS_IFLOW: tcflag_t = 0x00020000;
-pub const CDTR_IFLOW: tcflag_t = 0x00040000;
-pub const CDSR_OFLOW: tcflag_t = 0x00080000;
-pub const CCAR_OFLOW: tcflag_t = 0x00100000;
-pub const MDMBUF: tcflag_t = CCAR_OFLOW;
-
-// c_lflag bits
-pub const ECHOKE: tcflag_t = 0x00000001;
-pub const ECHOE: tcflag_t = 0x00000002;
-pub const ECHOK: tcflag_t = 0x00000004;
-pub const ECHO: tcflag_t = 0x00000008;
-pub const ECHONL: tcflag_t = 0x00000010;
-pub const ECHOPRT: tcflag_t = 0x00000020;
-pub const ECHOCTL: tcflag_t = 0x00000040;
-pub const ISIG: tcflag_t = 0x00000080;
-pub const ICANON: tcflag_t = 0x00000100;
-pub const ALTWERASE: tcflag_t = 0x00000200;
-pub const IEXTEN: tcflag_t = 0x00000400;
-pub const EXTPROC: tcflag_t = 0x00000800;
-pub const TOSTOP: tcflag_t = 0x00400000;
-pub const FLUSHO: tcflag_t = 0x00800000;
-pub const NOKERNINFO: tcflag_t = 0x02000000;
-pub const PENDIN: tcflag_t = 0x20000000;
-pub const NOFLSH: tcflag_t = 0x80000000;
-
-// baud rates
-pub const B0: speed_t = 0;
-pub const B50: speed_t = 50;
-pub const B75: speed_t = 75;
-pub const B110: speed_t = 110;
-pub const B134: speed_t = 134;
-pub const B150: speed_t = 150;
-pub const B200: speed_t = 200;
-pub const B300: speed_t = 300;
-pub const B600: speed_t = 600;
-pub const B1200: speed_t = 1200;
-pub const B1800: speed_t = 1800;
-pub const B2400: speed_t = 2400;
-pub const B4800: speed_t = 4800;
-pub const B9600: speed_t = 9600;
-pub const B19200: speed_t = 19200;
-pub const B38400: speed_t = 38400;
-pub const B7200: speed_t = 7200;
-pub const B14400: speed_t = 14400;
-pub const B28800: speed_t = 28800;
-pub const B57600: speed_t = 57600;
-pub const B76800: speed_t = 76800;
-pub const B115200: speed_t = 115200;
-pub const B230400: speed_t = 230400;
-pub const B460800: speed_t = 460800;
-pub const B921600: speed_t = 921600;
-pub const EXTA: speed_t = 19200;
-pub const EXTB: speed_t = 38400;
-
-// tcflow()
-pub const TCOOFF: c_int = 1;
-pub const TCOON: c_int = 2;
-pub const TCIOFF: c_int = 3;
-pub const TCION: c_int = 4;
-
-// tcflush()
-pub const TCIFLUSH: c_int = 1;
-pub const TCOFLUSH: c_int = 2;
-pub const TCIOFLUSH: c_int = 3;
-
-// tcsetattr()
-pub const TCSANOW: c_int = 0;
-pub const TCSADRAIN: c_int = 1;
-pub const TCSAFLUSH: c_int = 2;
-pub const TCSASOFT: c_int = 0x10;
+ // tcsetattr()
+ TCSASOFT,
+};
diff --git a/termios/src/os/illumos.rs b/termios/src/os/illumos.rs
index eca1686..76fbb6d 100644
--- a/termios/src/os/illumos.rs
+++ b/termios/src/os/illumos.rs
@@ -1,179 +1,81 @@
-#![allow(non_camel_case_types)]
+extern crate termios_sys;
-use libc::{c_int,c_uint,c_uchar};
+pub use ::os::common::*;
-pub type cc_t = c_uchar;
-pub type speed_t = c_uint;
-pub type tcflag_t = c_uint;
+pub use self::termios_sys::{
+ termios,
+ NCCS,
-#[derive(Debug,Copy,Clone,Eq,PartialEq)]
-#[repr(C)]
-pub struct termios {
- pub c_iflag: tcflag_t,
- pub c_oflag: tcflag_t,
- pub c_cflag: tcflag_t,
- pub c_lflag: tcflag_t,
- pub c_cc: [cc_t; NCCS]
-}
+ // c_cc characters
+ VSWTCH,
+ VDSUSP,
+ VREPRINT,
+ VDISCARD,
+ VWERASE,
+ VLNEXT,
+ VSTATUS,
-pub const NCCS: usize = 19;
+ // c_iflag bits
+ IUCLC,
+ IMAXBEL,
+ DOSMODE,
-// c_cc characters
-pub const VINTR: usize = 0;
-pub const VQUIT: usize = 1;
-pub const VERASE: usize = 2;
-pub const VKILL: usize = 3;
-pub const VEOF: usize = 4;
-pub const VEOL: usize = 5;
-pub const VEOL2: usize = 6;
-pub const VMIN: usize = 4;
-pub const VTIME: usize = 5;
-pub const VSWTCH: usize = 7;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VDSUSP: usize = 11;
-pub const VREPRINT: usize = 12;
-pub const VDISCARD: usize = 13;
-pub const VWERASE: usize = 14;
-pub const VLNEXT: usize = 15;
-pub const VSTATUS: usize = 16;
-pub const VERASE2: usize = 17;
+ // c_oflag bits
+ OLCUC,
+ OFILL,
+ OFDEL,
+ NLDLY,
+ NL0,
+ NL1,
+ CRDLY,
+ CR0,
+ CR1,
+ CR2,
+ CR3,
+ TABDLY,
+ TAB1,
+ TAB2,
+ TAB3,
+ XTABS,
+ BSDLY,
+ BS0,
+ BS1,
+ VTDLY,
+ VT0,
+ VT1,
+ FFDLY,
+ FF0,
+ FF1,
+ PAGEOUT,
+ WRAP,
-// c_iflag bits
-pub const IGNBRK: tcflag_t = 0o000001;
-pub const BRKINT: tcflag_t = 0o000002;
-pub const IGNPAR: tcflag_t = 0o000004;
-pub const PARMRK: tcflag_t = 0o000010;
-pub const INPCK: tcflag_t = 0o000020;
-pub const ISTRIP: tcflag_t = 0o000040;
-pub const INLCR: tcflag_t = 0o000100;
-pub const IGNCR: tcflag_t = 0o000200;
-pub const ICRNL: tcflag_t = 0o000400;
-pub const IUCLC: tcflag_t = 0o001000;
-pub const IXON: tcflag_t = 0o002000;
-pub const IXANY: tcflag_t = 0o004000;
-pub const IXOFF: tcflag_t = 0o010000;
-pub const IMAXBEL: tcflag_t = 0o020000;
-pub const DOSMODE: tcflag_t = 0o100000;
+ // c_cflag bits
+ CBAUD,
+ RCV1EN,
+ XMT1EN,
+ LOBLK,
+ XCLUDE,
+ CRTSXOFF,
+ CRTSCTS,
+ CIBAUD,
+ PAREXT,
+ CBAUDEXT,
+ CIBAUDEXT,
-// c_oflag bits
-pub const OPOST: tcflag_t = 0o000001;
-pub const OLCUC: tcflag_t = 0o000002;
-pub const ONLCR: tcflag_t = 0o000004;
-pub const OCRNL: tcflag_t = 0o000010;
-pub const ONOCR: tcflag_t = 0o000020;
-pub const ONLRET: tcflag_t = 0o000040;
-pub const OFILL: tcflag_t = 0o000100;
-pub const OFDEL: tcflag_t = 0o000200;
-pub const NLDLY: tcflag_t = 0o000400;
-pub const NL0: tcflag_t = 0o000000;
-pub const NL1: tcflag_t = 0o000400;
-pub const CRDLY: tcflag_t = 0o003000;
-pub const CR0: tcflag_t = 0o000000;
-pub const CR1: tcflag_t = 0o001000;
-pub const CR2: tcflag_t = 0o002000;
-pub const CR3: tcflag_t = 0o003000;
-pub const TABDLY: tcflag_t = 0o014000;
-pub const TAB0: tcflag_t = 0o000000;
-pub const TAB1: tcflag_t = 0o004000;
-pub const TAB2: tcflag_t = 0o010000;
-pub const TAB3: tcflag_t = 0o014000;
-pub const XTABS: tcflag_t = 0o014000;
-pub const BSDLY: tcflag_t = 0o020000;
-pub const BS0: tcflag_t = 0o000000;
-pub const BS1: tcflag_t = 0o020000;
-pub const VTDLY: tcflag_t = 0o040000;
-pub const VT0: tcflag_t = 0o000000;
-pub const VT1: tcflag_t = 0o040000;
-pub const FFDLY: tcflag_t = 0o100000;
-pub const FF0: tcflag_t = 0o000000;
-pub const FF1: tcflag_t = 0o100000;
-pub const PAGEOUT: tcflag_t = 0o200000;
-pub const WRAP: tcflag_t = 0o400000;
+ // c_lflag bits
+ XCASE,
+ FLUSHO,
+ PENDIN,
-// c_cflag bits
-pub const CBAUD: tcflag_t = 0o000017;
-pub const CSIZE: tcflag_t = 0o000060;
-pub const CS5: tcflag_t = 0o000000;
-pub const CS6: tcflag_t = 0o000020;
-pub const CS7: tcflag_t = 0o000040;
-pub const CS8: tcflag_t = 0o000060;
-pub const CSTOPB: tcflag_t = 0o000100;
-pub const CREAD: tcflag_t = 0o000200;
-pub const PARENB: tcflag_t = 0o000400;
-pub const PARODD: tcflag_t = 0o001000;
-pub const HUPCL: tcflag_t = 0o002000;
-pub const CLOCAL: tcflag_t = 0o004000;
-pub const RCV1EN: tcflag_t = 0o010000;
-pub const XMT1EN: tcflag_t = 0o020000;
-pub const LOBLK: tcflag_t = 0o040000;
-pub const XCLUDE: tcflag_t = 0o100000;
-pub const CRTSXOFF: tcflag_t = 0o10000000000;
-pub const CRTSCTS: tcflag_t = 0o20000000000;
-pub const CIBAUD: tcflag_t = 0o3600000;
-pub const PAREXT: tcflag_t = 0o4000000;
-pub const CBAUDEXT: tcflag_t = 0o10000000;
-pub const CIBAUDEXT: tcflag_t = 0o20000000;
-
-// c_lflag bits
-pub const ISIG: tcflag_t = 0o000001;
-pub const ICANON: tcflag_t = 0o000002;
-pub const XCASE: tcflag_t = 0o000004;
-pub const ECHO: tcflag_t = 0o000010;
-pub const ECHOE: tcflag_t = 0o000020;
-pub const ECHOK: tcflag_t = 0o000040;
-pub const ECHONL: tcflag_t = 0o000100;
-pub const NOFLSH: tcflag_t = 0o000200;
-pub const TOSTOP: tcflag_t = 0o000400;
-pub const ECHOCTL: tcflag_t = 0o001000;
-pub const ECHOPRT: tcflag_t = 0o002000;
-pub const ECHOKE: tcflag_t = 0o004000;
-pub const DEFECHO: tcflag_t = 0o010000;
-pub const FLUSHO: tcflag_t = 0o020000;
-pub const PENDIN: tcflag_t = 0o040000;
-pub const IEXTEN: tcflag_t = 0o100000;
-
-// baud rates
-pub const B0: speed_t = 0;
-pub const B50: speed_t = 1;
-pub const B75: speed_t = 2;
-pub const B110: speed_t = 3;
-pub const B134: speed_t = 4;
-pub const B150: speed_t = 5;
-pub const B200: speed_t = 6;
-pub const B300: speed_t = 7;
-pub const B600: speed_t = 8;
-pub const B1200: speed_t = 9;
-pub const B1800: speed_t = 10;
-pub const B2400: speed_t = 11;
-pub const B4800: speed_t = 12;
-pub const B9600: speed_t = 13;
-pub const B19200: speed_t = 14;
-pub const B38400: speed_t = 15;
-pub const EXTA: speed_t = B19200;
-pub const EXTB: speed_t = B38400;
-pub const B57600: speed_t = 16;
-pub const B76800: speed_t = 17;
-pub const B115200: speed_t = 18;
-pub const B153600: speed_t = 19;
-pub const B230400: speed_t = 20;
-pub const B307200: speed_t = 21;
-pub const B460800: speed_t = 22;
-pub const B921600: speed_t = 23;
-
-// tcflow()
-pub const TCOOFF: c_int = 0;
-pub const TCOON: c_int = 1;
-pub const TCIOFF: c_int = 2;
-pub const TCION: c_int = 3;
-
-// tcflush()
-pub const TCIFLUSH: c_int = 0;
-pub const TCOFLUSH: c_int = 1;
-pub const TCIOFLUSH: c_int = 2;
-
-// tcsetattr()
-pub const TCSANOW: c_int = 0x540E;
-pub const TCSADRAIN: c_int = 0x540F;
-pub const TCSAFLUSH: c_int = 0x5410;
+ // baud rates
+ EXTA,
+ EXTB,
+ B57600,
+ B76800,
+ B115200,
+ B153600,
+ B230400,
+ B307200,
+ B460800,
+ B921600,
+};
diff --git a/termios/src/os/linux.rs b/termios/src/os/linux.rs
index c4d91c4..b4df353 100644
--- a/termios/src/os/linux.rs
+++ b/termios/src/os/linux.rs
@@ -1,178 +1,84 @@
-#![allow(non_camel_case_types)]
+extern crate termios_sys;
-use libc::{c_int,c_uint,c_uchar};
+pub use ::os::common::*;
-pub type cc_t = c_uchar;
-pub type speed_t = c_uint;
-pub type tcflag_t = c_uint;
+pub use self::termios_sys::{
+ termios,
+ NCCS,
-#[derive(Debug,Copy,Clone,Eq,PartialEq)]
-#[repr(C)]
-pub struct termios {
- pub c_iflag: tcflag_t,
- pub c_oflag: tcflag_t,
- pub c_cflag: tcflag_t,
- pub c_lflag: tcflag_t,
- c_line: cc_t,
- pub c_cc: [cc_t; NCCS],
- c_ispeed: speed_t,
- c_ospeed: speed_t
-}
+ // c_cc characters
+ VSWTC,
+ VREPRINT,
+ VDISCARD,
+ VWERASE,
+ VLNEXT,
+ VEOL2,
-pub const NCCS: usize = 32;
+ // c_iflag bits
+ IUCLC,
+ IMAXBEL,
+ IUTF8,
-// c_cc characters
-pub const VINTR: usize = 0;
-pub const VQUIT: usize = 1;
-pub const VERASE: usize = 2;
-pub const VKILL: usize = 3;
-pub const VEOF: usize = 4;
-pub const VTIME: usize = 5;
-pub const VMIN: usize = 6;
-pub const VSWTC: usize = 7;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VEOL: usize = 11;
-pub const VREPRINT: usize = 12;
-pub const VDISCARD: usize = 13;
-pub const VWERASE: usize = 14;
-pub const VLNEXT: usize = 15;
-pub const VEOL2: usize = 16;
+ // c_oflag bits
+ OLCUC,
+ OFILL,
+ OFDEL,
+ NLDLY,
+ NL0,
+ NL1,
+ CRDLY,
+ CR0,
+ CR1,
+ CR2,
+ CR3,
+ TABDLY,
+ TAB0,
+ TAB1,
+ TAB2,
+ TAB3,
+ BSDLY,
+ BS0,
+ BS1,
+ FFDLY,
+ FF0,
+ FF1,
+ VTDLY,
+ VT0,
+ VT1,
+ XTABS,
-// c_iflag bits
-pub const IGNBRK: tcflag_t = 0o000001;
-pub const BRKINT: tcflag_t = 0o000002;
-pub const IGNPAR: tcflag_t = 0o000004;
-pub const PARMRK: tcflag_t = 0o000010;
-pub const INPCK: tcflag_t = 0o000020;
-pub const ISTRIP: tcflag_t = 0o000040;
-pub const INLCR: tcflag_t = 0o000100;
-pub const IGNCR: tcflag_t = 0o000200;
-pub const ICRNL: tcflag_t = 0o000400;
-pub const IUCLC: tcflag_t = 0o001000;
-pub const IXON: tcflag_t = 0o002000;
-pub const IXANY: tcflag_t = 0o004000;
-pub const IXOFF: tcflag_t = 0o010000;
-pub const IMAXBEL: tcflag_t = 0o020000;
-pub const IUTF8: tcflag_t = 0o040000;
+ // c_cflag bits
+ CBAUD,
+ CBAUDEX,
+ CIBAUD,
+ CMSPAR,
+ CRTSCTS,
-// c_oflag bits
-pub const OPOST: tcflag_t = 0o000001;
-pub const OLCUC: tcflag_t = 0o000002;
-pub const ONLCR: tcflag_t = 0o000004;
-pub const OCRNL: tcflag_t = 0o000010;
-pub const ONOCR: tcflag_t = 0o000020;
-pub const ONLRET: tcflag_t = 0o000040;
-pub const OFILL: tcflag_t = 0o000100;
-pub const OFDEL: tcflag_t = 0o000200;
-pub const NLDLY: tcflag_t = 0o000400;
-pub const NL0: tcflag_t = 0o000000;
-pub const NL1: tcflag_t = 0o000400;
-pub const CRDLY: tcflag_t = 0o003000;
-pub const CR0: tcflag_t = 0o000000;
-pub const CR1: tcflag_t = 0o001000;
-pub const CR2: tcflag_t = 0o002000;
-pub const CR3: tcflag_t = 0o003000;
-pub const TABDLY: tcflag_t = 0o014000;
-pub const TAB0: tcflag_t = 0o000000;
-pub const TAB1: tcflag_t = 0o004000;
-pub const TAB2: tcflag_t = 0o010000;
-pub const TAB3: tcflag_t = 0o014000;
-pub const BSDLY: tcflag_t = 0o020000;
-pub const BS0: tcflag_t = 0o000000;
-pub const BS1: tcflag_t = 0o020000;
-pub const FFDLY: tcflag_t = 0o100000;
-pub const FF0: tcflag_t = 0o000000;
-pub const FF1: tcflag_t = 0o100000;
-pub const VTDLY: tcflag_t = 0o040000;
-pub const VT0: tcflag_t = 0o000000;
-pub const VT1: tcflag_t = 0o040000;
-pub const XTABS: tcflag_t = 0o014000;
+ // c_lflag bits
+ XCASE,
+ ECHOCTL,
+ ECHOPRT,
+ ECHOKE,
+ FLUSHO,
+ PENDIN,
+ EXTPROC,
-// c_cflag bits
-pub const CBAUD: tcflag_t = 0o010017;
-pub const CSIZE: tcflag_t = 0o000060;
-pub const CS5: tcflag_t = 0o000000;
-pub const CS6: tcflag_t = 0o000020;
-pub const CS7: tcflag_t = 0o000040;
-pub const CS8: tcflag_t = 0o000060;
-pub const CSTOPB: tcflag_t = 0o000100;
-pub const CREAD: tcflag_t = 0o000200;
-pub const PARENB: tcflag_t = 0o000400;
-pub const PARODD: tcflag_t = 0o001000;
-pub const HUPCL: tcflag_t = 0o002000;
-pub const CLOCAL: tcflag_t = 0o004000;
-pub const CBAUDEX: tcflag_t = 0o010000;
-pub const CIBAUD: tcflag_t = 0o02003600000;
-pub const CMSPAR: tcflag_t = 0o10000000000;
-pub const CRTSCTS: tcflag_t = 0o20000000000;
-
-// c_lflag bits
-pub const ISIG: tcflag_t = 0o000001;
-pub const ICANON: tcflag_t = 0o000002;
-pub const XCASE: tcflag_t = 0o000004;
-pub const ECHO: tcflag_t = 0o000010;
-pub const ECHOE: tcflag_t = 0o000020;
-pub const ECHOK: tcflag_t = 0o000040;
-pub const ECHONL: tcflag_t = 0o000100;
-pub const NOFLSH: tcflag_t = 0o000200;
-pub const TOSTOP: tcflag_t = 0o000400;
-pub const ECHOCTL: tcflag_t = 0o001000;
-pub const ECHOPRT: tcflag_t = 0o002000;
-pub const ECHOKE: tcflag_t = 0o004000;
-pub const FLUSHO: tcflag_t = 0o010000;
-pub const PENDIN: tcflag_t = 0o040000;
-pub const IEXTEN: tcflag_t = 0o100000;
-pub const EXTPROC: tcflag_t = 0o200000;
-
-// baud rates
-pub const B0: speed_t = 0o000000;
-pub const B50: speed_t = 0o000001;
-pub const B75: speed_t = 0o000002;
-pub const B110: speed_t = 0o000003;
-pub const B134: speed_t = 0o000004;
-pub const B150: speed_t = 0o000005;
-pub const B200: speed_t = 0o000006;
-pub const B300: speed_t = 0o000007;
-pub const B600: speed_t = 0o000010;
-pub const B1200: speed_t = 0o000011;
-pub const B1800: speed_t = 0o000012;
-pub const B2400: speed_t = 0o000013;
-pub const B4800: speed_t = 0o000014;
-pub const B9600: speed_t = 0o000015;
-pub const B19200: speed_t = 0o000016;
-pub const B38400: speed_t = 0o000017;
-pub const EXTA: speed_t = B19200;
-pub const EXTB: speed_t = B38400;
-pub const B57600: speed_t = 0o010001;
-pub const B115200: speed_t = 0o010002;
-pub const B230400: speed_t = 0o010003;
-pub const B460800: speed_t = 0o010004;
-pub const B500000: speed_t = 0o010005;
-pub const B576000: speed_t = 0o010006;
-pub const B921600: speed_t = 0o010007;
-pub const B1000000: speed_t = 0o010010;
-pub const B1152000: speed_t = 0o010011;
-pub const B1500000: speed_t = 0o010012;
-pub const B2000000: speed_t = 0o010013;
-pub const B2500000: speed_t = 0o010014;
-pub const B3000000: speed_t = 0o010015;
-pub const B3500000: speed_t = 0o010016;
-pub const B4000000: speed_t = 0o010017;
-
-// tcflow()
-pub const TCOOFF: c_int = 0;
-pub const TCOON: c_int = 1;
-pub const TCIOFF: c_int = 2;
-pub const TCION: c_int = 3;
-
-// tcflush()
-pub const TCIFLUSH: c_int = 0;
-pub const TCOFLUSH: c_int = 1;
-pub const TCIOFLUSH: c_int = 2;
-
-// tcsetattr()
-pub const TCSANOW: c_int = 0;
-pub const TCSADRAIN: c_int = 1;
-pub const TCSAFLUSH: c_int = 2;
+ // baud rates
+ EXTA,
+ EXTB,
+ B57600,
+ B115200,
+ B230400,
+ B460800,
+ B500000,
+ B576000,
+ B921600,
+ B1000000,
+ B1152000,
+ B1500000,
+ B2000000,
+ B2500000,
+ B3000000,
+ B3500000,
+ B4000000,
+};
diff --git a/termios/src/os/macos.rs b/termios/src/os/macos.rs
index a00c978..1d088b4 100644
--- a/termios/src/os/macos.rs
+++ b/termios/src/os/macos.rs
@@ -1,176 +1,79 @@
-#![allow(non_camel_case_types)]
+extern crate termios_sys;
-use libc::{c_int,c_uchar,c_ulong};
+pub use ::os::common::*;
-pub type tcflag_t = c_ulong;
-pub type cc_t = c_uchar;
-pub type speed_t = c_ulong;
+pub use self::termios_sys::{
+ NCCS,
-#[derive(Debug,Copy,Clone,Eq,PartialEq)]
-#[repr(C)]
-pub struct termios {
- pub c_iflag: tcflag_t,
- pub c_oflag: tcflag_t,
- pub c_cflag: tcflag_t,
- pub c_lflag: tcflag_t,
- pub c_cc: [cc_t; NCCS],
- c_ispeed: speed_t,
- c_ospeed: speed_t
-}
+ // c_cc characters
+ VWERASE,
+ VREPRINT,
+ VDSUSP,
+ VLNEXT,
+ VDISCARD,
+ VSTATUS,
-pub const NCCS: usize = 20;
+ // c_iflag bits
+ IMAXBEL,
+ IUTF8,
-// c_cc characters
-pub const VEOF: usize = 0;
-pub const VEOL: usize = 1;
-pub const VEOL2: usize = 2;
-pub const VERASE: usize = 3;
-pub const VWERASE: usize = 4;
-pub const VKILL: usize = 5;
-pub const VREPRINT: usize = 6;
-pub const VINTR: usize = 8;
-pub const VQUIT: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VDSUSP: usize = 11;
-pub const VSTART: usize = 12;
-pub const VSTOP: usize = 13;
-pub const VLNEXT: usize = 14;
-pub const VDISCARD: usize = 15;
-pub const VMIN: usize = 16;
-pub const VTIME: usize = 17;
-pub const VSTATUS: usize = 18;
+ // c_oflag bits
+ OXTABS,
+ ONOEOT,
+ OFILL,
+ NLDLY,
+ TABDLY,
+ CRDLY,
+ FFDLY,
+ BSDLY,
+ VTDLY,
+ OFDEL,
+ NL0,
+ NL1,
+ NL2,
+ NL3,
+ TAB1,
+ TAB2,
+ TAB3,
+ CR0,
+ CR1,
+ CR2,
+ CR3,
+ FF0,
+ FF1,
+ BS0,
+ BS1,
+ VT0,
+ VT1,
-// c_iflag bits
-pub const IGNBRK: tcflag_t = 0x00000001;
-pub const BRKINT: tcflag_t = 0x00000002;
-pub const IGNPAR: tcflag_t = 0x00000004;
-pub const PARMRK: tcflag_t = 0x00000008;
-pub const INPCK: tcflag_t = 0x00000010;
-pub const ISTRIP: tcflag_t = 0x00000020;
-pub const INLCR: tcflag_t = 0x00000040;
-pub const IGNCR: tcflag_t = 0x00000080;
-pub const ICRNL: tcflag_t = 0x00000100;
-pub const IXON: tcflag_t = 0x00000200;
-pub const IXOFF: tcflag_t = 0x00000400;
-pub const IXANY: tcflag_t = 0x00000800;
-pub const IMAXBEL: tcflag_t = 0x00002000;
-pub const IUTF8: tcflag_t = 0x00004000;
+ // c_cflag bits
+ CIGNORE,
+ CCTS_OFLOW,
+ CRTSCTS,
+ CRTS_IFLOW,
+ CDTR_IFLOW,
+ CDSR_OFLOW,
+ CCAR_OFLOW,
+ MDMBUF,
-// c_oflag bits
-pub const OPOST: tcflag_t = 0x00000001;
-pub const ONLCR: tcflag_t = 0x00000002;
-pub const OXTABS: tcflag_t = 0x00000004;
-pub const ONOEOT: tcflag_t = 0x00000008;
-pub const OCRNL: tcflag_t = 0x00000010;
-pub const ONOCR: tcflag_t = 0x00000020;
-pub const ONLRET: tcflag_t = 0x00000040;
-pub const OFILL: tcflag_t = 0x00000080;
-pub const NLDLY: tcflag_t = 0x00000300;
-pub const TABDLY: tcflag_t = 0x00000c04;
-pub const CRDLY: tcflag_t = 0x00003000;
-pub const FFDLY: tcflag_t = 0x00004000;
-pub const BSDLY: tcflag_t = 0x00008000;
-pub const VTDLY: tcflag_t = 0x00010000;
-pub const OFDEL: tcflag_t = 0x00020000;
-pub const NL0: tcflag_t = 0x00000000;
-pub const NL1: tcflag_t = 0x00000100;
-pub const NL2: tcflag_t = 0x00000200;
-pub const NL3: tcflag_t = 0x00000300;
-pub const TAB0: tcflag_t = 0x00000000;
-pub const TAB1: tcflag_t = 0x00000400;
-pub const TAB2: tcflag_t = 0x00000800;
-pub const TAB3: tcflag_t = 0x00000004;
-pub const CR0: tcflag_t = 0x00000000;
-pub const CR1: tcflag_t = 0x00001000;
-pub const CR2: tcflag_t = 0x00002000;
-pub const CR3: tcflag_t = 0x00003000;
-pub const FF0: tcflag_t = 0x00000000;
-pub const FF1: tcflag_t = 0x00004000;
-pub const BS0: tcflag_t = 0x00000000;
-pub const BS1: tcflag_t = 0x00008000;
-pub const VT0: tcflag_t = 0x00000000;
-pub const VT1: tcflag_t = 0x00010000;
+ // c_lflag bits
+ ALTWERASE,
+ EXTPROC,
+ FLUSHO,
+ NOKERNINFO,
+ PENDIN,
-// c_cflag bits
-pub const CIGNORE: tcflag_t = 0x00000001;
-pub const CSIZE: tcflag_t = 0x00000300;
-pub const CS5: tcflag_t = 0x00000000;
-pub const CS6: tcflag_t = 0x00000100;
-pub const CS7: tcflag_t = 0x00000200;
-pub const CS8: tcflag_t = 0x00000300;
-pub const CSTOPB: tcflag_t = 0x00000400;
-pub const CREAD: tcflag_t = 0x00000800;
-pub const PARENB: tcflag_t = 0x00001000;
-pub const PARODD: tcflag_t = 0x00002000;
-pub const HUPCL: tcflag_t = 0x00004000;
-pub const CLOCAL: tcflag_t = 0x00008000;
-pub const CCTS_OFLOW: tcflag_t = 0x00010000;
-pub const CRTSCTS: tcflag_t = CCTS_OFLOW | CRTS_IFLOW;
-pub const CRTS_IFLOW: tcflag_t = 0x00020000;
-pub const CDTR_IFLOW: tcflag_t = 0x00040000;
-pub const CDSR_OFLOW: tcflag_t = 0x00080000;
-pub const CCAR_OFLOW: tcflag_t = 0x00100000;
-pub const MDMBUF: tcflag_t = 0x00100000;
+ // baud speeds
+ B7200,
+ B14400,
+ B28800,
+ B57600,
+ B76800,
+ B115200,
+ B230400,
+ EXTA,
+ EXTB,
-// c_lflag bits
-pub const ECHOKE: tcflag_t = 0x00000001;
-pub const ECHOE: tcflag_t = 0x00000002;
-pub const ECHOK: tcflag_t = 0x00000004;
-pub const ECHO: tcflag_t = 0x00000008;
-pub const ECHONL: tcflag_t = 0x00000010;
-pub const ECHOPRT: tcflag_t = 0x00000020;
-pub const ECHOCTL: tcflag_t = 0x00000040;
-pub const ISIG: tcflag_t = 0x00000080;
-pub const ICANON: tcflag_t = 0x00000100;
-pub const ALTWERASE: tcflag_t = 0x00000200;
-pub const IEXTEN: tcflag_t = 0x00000400;
-pub const EXTPROC: tcflag_t = 0x00000800;
-pub const TOSTOP: tcflag_t = 0x00400000;
-pub const FLUSHO: tcflag_t = 0x00800000;
-pub const NOKERNINFO: tcflag_t = 0x02000000;
-pub const PENDIN: tcflag_t = 0x20000000;
-pub const NOFLSH: tcflag_t = 0x80000000;
-
-// baud speeds
-pub const B0: speed_t = 0;
-pub const B50: speed_t = 50;
-pub const B75: speed_t = 75;
-pub const B110: speed_t = 110;
-pub const B134: speed_t = 134;
-pub const B150: speed_t = 150;
-pub const B200: speed_t = 200;
-pub const B300: speed_t = 300;
-pub const B600: speed_t = 600;
-pub const B1200: speed_t = 1200;
-pub const B1800: speed_t = 1800;
-pub const B2400: speed_t = 2400;
-pub const B4800: speed_t = 4800;
-pub const B9600: speed_t = 9600;
-pub const B19200: speed_t = 19200;
-pub const B38400: speed_t = 38400;
-pub const B7200: speed_t = 7200;
-pub const B14400: speed_t = 14400;
-pub const B28800: speed_t = 28800;
-pub const B57600: speed_t = 57600;
-pub const B76800: speed_t = 76800;
-pub const B115200: speed_t = 115200;
-pub const B230400: speed_t = 230400;
-pub const EXTA: speed_t = 19200;
-pub const EXTB: speed_t = 38400;
-
-// tcflow()
-pub const TCOOFF: c_int = 1;
-pub const TCOON: c_int = 2;
-pub const TCIOFF: c_int = 3;
-pub const TCION: c_int = 4;
-
-// tcflush()
-pub const TCIFLUSH: c_int = 1;
-pub const TCOFLUSH: c_int = 2;
-pub const TCIOFLUSH: c_int = 3;
-
-// tcsetattr()
-pub const TCSANOW: c_int = 0;
-pub const TCSADRAIN: c_int = 1;
-pub const TCSAFLUSH: c_int = 2;
-pub const TCSASOFT: c_int = 0x10;
+ // tcsetattr()
+ TCSASOFT,
+};
diff --git a/termios/src/os/mod.rs b/termios/src/os/mod.rs
index 7ac120f..e00aab1 100644
--- a/termios/src/os/mod.rs
+++ b/termios/src/os/mod.rs
@@ -1,5 +1,7 @@
//! OS-specific definitions.
+mod common;
+
#[cfg(target_os = "linux")] pub use self::linux as target;
#[cfg(target_os = "android")] pub use self::android as target;
#[cfg(target_os = "macos")] pub use self::macos as target;
@@ -19,3 +21,23 @@
#[cfg(target_os = "dragonfly")] pub mod dragonfly;
#[cfg(target_os = "solaris")] pub mod solaris;
#[cfg(target_os = "illumos")] pub mod illumos;
+
+#[cfg(not(any(target_os = "android",
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "illumos",
+ target_os = "linux",
+ target_os = "macos",
+ target_os = "openbsd",
+ target_os = "solaris")))]
+pub mod unknown;
+
+#[cfg(not(any(target_os = "android",
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "illumos",
+ target_os = "linux",
+ target_os = "macos",
+ target_os = "openbsd",
+ target_os = "solaris")))]
+pub use self::unknown as target;
diff --git a/termios/src/os/netbsd.rs b/termios/src/os/netbsd.rs
index d62b654..069f381 100644
--- a/termios/src/os/netbsd.rs
+++ b/termios/src/os/netbsd.rs
@@ -1,149 +1,54 @@
-#![allow(non_camel_case_types)]
-
-use libc::{c_int,c_uint,c_uchar};
-
-pub type cc_t = c_uchar;
-pub type speed_t = c_uint;
-pub type tcflag_t = c_uint;
-
-#[derive(Debug,Copy,Clone,Eq,PartialEq)]
-#[repr(C)]
-pub struct termios {
- pub c_iflag: tcflag_t,
- pub c_oflag: tcflag_t,
- pub c_cflag: tcflag_t,
- pub c_lflag: tcflag_t,
- pub c_cc: [cc_t; NCCS],
- c_ispeed: c_int,
- c_ospeed: c_int
-}
-
-pub const NCCS: usize = 20;
-
-// c_cc characters
-pub const VEOF: usize = 0;
-pub const VEOL: usize = 1;
-pub const VEOL2: usize = 2;
-pub const VERASE: usize = 3;
-pub const VWERASE: usize = 4;
-pub const VKILL: usize = 5;
-pub const VREPRINT: usize = 6;
-pub const VINTR: usize = 8;
-pub const VQUIT: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VSTART: usize = 12;
-pub const VSTOP: usize = 13;
-pub const VLNEXT: usize = 14;
-pub const VDISCARD: usize = 15;
-pub const VMIN: usize = 16;
-pub const VTIME: usize = 17;
-pub const VSTATUS: usize = 18;
-
-// c_iflag bits
-pub const IGNBRK: tcflag_t = 0x00000001;
-pub const BRKINT: tcflag_t = 0x00000002;
-pub const IGNPAR: tcflag_t = 0x00000004;
-pub const PARMRK: tcflag_t = 0x00000008;
-pub const INPCK: tcflag_t = 0x00000010;
-pub const ISTRIP: tcflag_t = 0x00000020;
-pub const INLCR: tcflag_t = 0x00000040;
-pub const IGNCR: tcflag_t = 0x00000080;
-pub const ICRNL: tcflag_t = 0x00000100;
-pub const IXON: tcflag_t = 0x00000200;
-pub const IXOFF: tcflag_t = 0x00000400;
-pub const IXANY: tcflag_t = 0x00000800;
-pub const IMAXBEL: tcflag_t = 0x00002000;
-
-// c_oflag bits
-pub const OPOST: tcflag_t = 0x00000001;
-pub const ONLCR: tcflag_t = 0x00000002;
-pub const OXTABS: tcflag_t = 0x00000004;
-pub const ONOEOT: tcflag_t = 0x00000008;
-pub const OCRNL: tcflag_t = 0x00000010;
-pub const ONOCR: tcflag_t = 0x00000020;
-pub const ONLRET: tcflag_t = 0x00000040;
-
-// c_cflag bits
-pub const CIGNORE: tcflag_t = 0x00000001;
-pub const CSIZE: tcflag_t = 0x00000300;
-pub const CS5: tcflag_t = 0x00000000;
-pub const CS6: tcflag_t = 0x00000100;
-pub const CS7: tcflag_t = 0x00000200;
-pub const CS8: tcflag_t = 0x00000300;
-pub const CSTOPB: tcflag_t = 0x00000400;
-pub const CREAD: tcflag_t = 0x00000800;
-pub const PARENB: tcflag_t = 0x00001000;
-pub const PARODD: tcflag_t = 0x00002000;
-pub const HUPCL: tcflag_t = 0x00004000;
-pub const CLOCAL: tcflag_t = 0x00008000;
-pub const CRTSCTS: tcflag_t = 0x00010000;
-pub const CRTS_IFLOW: tcflag_t = CRTSCTS;
-pub const CCTS_OFLOW: tcflag_t = CRTSCTS;
-pub const CDTRCTS: tcflag_t = 0x00020000;
-pub const MDMBUF: tcflag_t = 0x00100000;
-pub const CHWFLOW: tcflag_t = MDMBUF|CRTSCTS|CDTRCTS;
-
-// c_lflag bits
-pub const ECHOKE: tcflag_t = 0x00000001;
-pub const ECHOE: tcflag_t = 0x00000002;
-pub const ECHOK: tcflag_t = 0x00000004;
-pub const ECHO: tcflag_t = 0x00000008;
-pub const ECHONL: tcflag_t = 0x00000010;
-pub const ECHOPRT: tcflag_t = 0x00000020;
-pub const ECHOCTL: tcflag_t = 0x00000040;
-pub const ISIG: tcflag_t = 0x00000080;
-pub const ICANON: tcflag_t = 0x00000100;
-pub const ALTWERASE: tcflag_t = 0x00000200;
-pub const IEXTEN: tcflag_t = 0x00000400;
-pub const EXTPROC: tcflag_t = 0x00000800;
-pub const TOSTOP: tcflag_t = 0x00400000;
-pub const FLUSHO: tcflag_t = 0x00800000;
-pub const NOKERNINFO: tcflag_t = 0x02000000;
-pub const PENDIN: tcflag_t = 0x20000000;
-pub const NOFLSH: tcflag_t = 0x80000000;
-
-// baud rates
-pub const B0: speed_t = 0;
-pub const B50: speed_t = 50;
-pub const B75: speed_t = 75;
-pub const B110: speed_t = 110;
-pub const B134: speed_t = 134;
-pub const B150: speed_t = 150;
-pub const B200: speed_t = 200;
-pub const B300: speed_t = 300;
-pub const B600: speed_t = 600;
-pub const B1200: speed_t = 1200;
-pub const B1800: speed_t = 1800;
-pub const B2400: speed_t = 2400;
-pub const B4800: speed_t = 4800;
-pub const B9600: speed_t = 9600;
-pub const B19200: speed_t = 19200;
-pub const B38400: speed_t = 38400;
-pub const B7200: speed_t = 7200;
-pub const B14400: speed_t = 14400;
-pub const B28800: speed_t = 28800;
-pub const B57600: speed_t = 57600;
-pub const B76800: speed_t = 76800;
-pub const B115200: speed_t = 115200;
-pub const B230400: speed_t = 230400;
-pub const B460800: speed_t = 460800;
-pub const B921600: speed_t = 921600;
-pub const EXTA: speed_t = 19200;
-pub const EXTB: speed_t = 38400;
-
-// tcflow()
-pub const TCOOFF: c_int = 1;
-pub const TCOON: c_int = 2;
-pub const TCIOFF: c_int = 3;
-pub const TCION: c_int = 4;
-
-// tcflush()
-pub const TCIFLUSH: c_int = 1;
-pub const TCOFLUSH: c_int = 2;
-pub const TCIOFLUSH: c_int = 3;
-
-// tcsetattr()
-pub const TCSANOW: c_int = 0;
-pub const TCSADRAIN: c_int = 1;
-pub const TCSAFLUSH: c_int = 2;
-pub const TCSASOFT: c_int = 0x10;
+extern crate termios_sys;
+
+pub use ::os::common::*;
+
+pub use self::termios_sys::{
+ termios,
+ NCCS,
+
+ // c_cc characters
+ VWERASE,
+ VREPRINT,
+ VLNEXT,
+ VDISCARD,
+ VSTATUS,
+
+ // c_iflag bits
+ IMAXBEL,
+
+ // c_oflag bits
+ OXTABS,
+ ONOEOT,
+
+ // c_cflag bits
+ CIGNORE,
+ CRTSCTS,
+ CRTS_IFLOW,
+ CCTS_OFLOW,
+ CDTRCTS,
+ MDMBUF,
+ CHWFLOW,
+
+ // c_lflag bits
+ ALTWERASE,
+ EXTPROC,
+ FLUSHO,
+ NOKERNINFO,
+ PENDIN,
+
+ // baud rates
+ B7200,
+ B14400,
+ B28800,
+ B57600,
+ B76800,
+ B115200,
+ B230400,
+ B460800,
+ B921600,
+ EXTA,
+ EXTB,
+
+ // tcsetattr()
+ TCSASOFT,
+};
diff --git a/termios/src/os/openbsd.rs b/termios/src/os/openbsd.rs
index 68b3707..cdc0ffb 100644
--- a/termios/src/os/openbsd.rs
+++ b/termios/src/os/openbsd.rs
@@ -1,146 +1,49 @@
-#![allow(non_camel_case_types)]
-
-use libc::{c_int,c_uint,c_uchar};
-
-pub type cc_t = c_uchar;
-pub type speed_t = c_uint;
-pub type tcflag_t = c_uint;
-
-#[derive(Debug,Copy,Clone,Eq,PartialEq)]
-#[repr(C)]
-pub struct termios {
- pub c_iflag: tcflag_t,
- pub c_oflag: tcflag_t,
- pub c_cflag: tcflag_t,
- pub c_lflag: tcflag_t,
- pub c_cc: [cc_t; NCCS],
- c_ispeed: speed_t,
- c_ospeed: speed_t
-}
-
-pub const NCCS: usize = 20;
-
-// c_cc characters
-pub const VEOF: usize = 0;
-pub const VEOL: usize = 1;
-pub const VEOL2: usize = 2;
-pub const VERASE: usize = 3;
-pub const VWERASE: usize = 4;
-pub const VKILL: usize = 5;
-pub const VREPRINT: usize = 6;
-pub const VERASE2: usize = 7;
-pub const VINTR: usize = 8;
-pub const VQUIT: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VSTART: usize = 12;
-pub const VSTOP: usize = 13;
-pub const VLNEXT: usize = 14;
-pub const VDISCARD: usize = 15;
-pub const VMIN: usize = 16;
-pub const VTIME: usize = 17;
-
-// c_iflag bits
-pub const IGNBRK: tcflag_t = 0x00000001;
-pub const BRKINT: tcflag_t = 0x00000002;
-pub const IGNPAR: tcflag_t = 0x00000004;
-pub const PARMRK: tcflag_t = 0x00000008;
-pub const INPCK: tcflag_t = 0x00000010;
-pub const ISTRIP: tcflag_t = 0x00000020;
-pub const INLCR: tcflag_t = 0x00000040;
-pub const IGNCR: tcflag_t = 0x00000080;
-pub const ICRNL: tcflag_t = 0x00000100;
-pub const IXON: tcflag_t = 0x00000200;
-pub const IXOFF: tcflag_t = 0x00000400;
-pub const IXANY: tcflag_t = 0x00000800;
-pub const IMAXBEL: tcflag_t = 0x00002000;
-
-// c_oflag bits
-pub const OPOST: tcflag_t = 0x00000001;
-pub const ONLCR: tcflag_t = 0x00000002;
-pub const TAB3: tcflag_t = 0x00000004;
-pub const OXTABS: tcflag_t = TAB3;
-pub const ONOEOT: tcflag_t = 0x00000008;
-pub const OCRNL: tcflag_t = 0x00000010;
-pub const ONOCR: tcflag_t = 0x00000040;
-pub const ONLRET: tcflag_t = 0x00000080;
-
-// c_cflag bits
-pub const CIGNORE: tcflag_t = 0x00000001;
-pub const CSIZE: tcflag_t = 0x00000300;
-pub const CS5: tcflag_t = 0x00000000;
-pub const CS6: tcflag_t = 0x00000100;
-pub const CS7: tcflag_t = 0x00000200;
-pub const CS8: tcflag_t = 0x00000300;
-pub const CSTOPB: tcflag_t = 0x00000400;
-pub const CREAD: tcflag_t = 0x00000800;
-pub const PARENB: tcflag_t = 0x00001000;
-pub const PARODD: tcflag_t = 0x00002000;
-pub const HUPCL: tcflag_t = 0x00004000;
-pub const CLOCAL: tcflag_t = 0x00008000;
-pub const CRTSCTS: tcflag_t = 0x00010000;
-pub const CRTS_IFLOW: tcflag_t = CRTSCTS;
-pub const CCTS_OFLOW: tcflag_t = CRTSCTS;
-pub const MDMBUF: tcflag_t = 0x00100000;
-
-// c_lflag bits
-pub const ECHOKE: tcflag_t = 0x00000001;
-pub const ECHOE: tcflag_t = 0x00000002;
-pub const ECHOK: tcflag_t = 0x00000004;
-pub const ECHO: tcflag_t = 0x00000008;
-pub const ECHONL: tcflag_t = 0x00000010;
-pub const ECHOPRT: tcflag_t = 0x00000020;
-pub const ECHOCTL: tcflag_t = 0x00000040;
-pub const ISIG: tcflag_t = 0x00000080;
-pub const ICANON: tcflag_t = 0x00000100;
-pub const ALTWERASE: tcflag_t = 0x00000200;
-pub const IEXTEN: tcflag_t = 0x00000400;
-pub const EXTPROC: tcflag_t = 0x00000800;
-pub const TOSTOP: tcflag_t = 0x00400000;
-pub const FLUSHO: tcflag_t = 0x00800000;
-pub const NOKERNINFO: tcflag_t = 0x02000000;
-pub const PENDIN: tcflag_t = 0x20000000;
-pub const NOFLSH: tcflag_t = 0x80000000;
-
-// baud rates
-pub const B0: speed_t = 0;
-pub const B50: speed_t = 50;
-pub const B75: speed_t = 75;
-pub const B110: speed_t = 110;
-pub const B134: speed_t = 134;
-pub const B150: speed_t = 150;
-pub const B200: speed_t = 200;
-pub const B300: speed_t = 300;
-pub const B600: speed_t = 600;
-pub const B1200: speed_t = 1200;
-pub const B1800: speed_t = 1800;
-pub const B2400: speed_t = 2400;
-pub const B4800: speed_t = 4800;
-pub const B9600: speed_t = 9600;
-pub const B19200: speed_t = 19200;
-pub const B38400: speed_t = 38400;
-pub const B7200: speed_t = 7200;
-pub const B14400: speed_t = 14400;
-pub const B28800: speed_t = 28800;
-pub const B57600: speed_t = 57600;
-pub const B76800: speed_t = 76800;
-pub const B115200: speed_t = 115200;
-pub const B230400: speed_t = 230400;
-pub const EXTA: speed_t = 19200;
-pub const EXTB: speed_t = 38400;
-
-// tcflow()
-pub const TCOOFF: c_int = 1;
-pub const TCOON: c_int = 2;
-pub const TCIOFF: c_int = 3;
-pub const TCION: c_int = 4;
-
-// tcflush()
-pub const TCIFLUSH: c_int = 1;
-pub const TCOFLUSH: c_int = 2;
-pub const TCIOFLUSH: c_int = 3;
-
-// tcsetattr()
-pub const TCSANOW: c_int = 0;
-pub const TCSADRAIN: c_int = 1;
-pub const TCSAFLUSH: c_int = 2;
-pub const TCSASOFT: c_int = 0x10;
+extern crate termios_sys;
+
+pub use ::os::common::*;
+
+pub use self::termios_sys::{
+ termios,
+ NCCS,
+
+ // c_cc characters
+ VWERASE,
+ VREPRINT,
+ VLNEXT,
+ VDISCARD,
+
+ // c_iflag bits
+ IMAXBEL,
+
+ // c_oflag bits
+ TAB3,
+ OXTABS,
+ ONOEOT,
+
+ // c_cflag bits
+ CIGNORE,
+ CRTSCTS,
+ CRTS_IFLOW,
+ CCTS_OFLOW,
+ MDMBUF,
+
+ // c_lflag bits
+ ALTWERASE,
+ EXTPROC,
+ FLUSHO,
+ NOKERNINFO,
+ PENDIN,
+
+ // baud rates
+ B7200,
+ B14400,
+ B28800,
+ B57600,
+ B76800,
+ B115200,
+ B230400,
+ EXTA,
+ EXTB,
+
+ TCSASOFT,
+};
diff --git a/termios/src/os/solaris.rs b/termios/src/os/solaris.rs
index eca1686..76fbb6d 100644
--- a/termios/src/os/solaris.rs
+++ b/termios/src/os/solaris.rs
@@ -1,179 +1,81 @@
-#![allow(non_camel_case_types)]
+extern crate termios_sys;
-use libc::{c_int,c_uint,c_uchar};
+pub use ::os::common::*;
-pub type cc_t = c_uchar;
-pub type speed_t = c_uint;
-pub type tcflag_t = c_uint;
+pub use self::termios_sys::{
+ termios,
+ NCCS,
-#[derive(Debug,Copy,Clone,Eq,PartialEq)]
-#[repr(C)]
-pub struct termios {
- pub c_iflag: tcflag_t,
- pub c_oflag: tcflag_t,
- pub c_cflag: tcflag_t,
- pub c_lflag: tcflag_t,
- pub c_cc: [cc_t; NCCS]
-}
+ // c_cc characters
+ VSWTCH,
+ VDSUSP,
+ VREPRINT,
+ VDISCARD,
+ VWERASE,
+ VLNEXT,
+ VSTATUS,
-pub const NCCS: usize = 19;
+ // c_iflag bits
+ IUCLC,
+ IMAXBEL,
+ DOSMODE,
-// c_cc characters
-pub const VINTR: usize = 0;
-pub const VQUIT: usize = 1;
-pub const VERASE: usize = 2;
-pub const VKILL: usize = 3;
-pub const VEOF: usize = 4;
-pub const VEOL: usize = 5;
-pub const VEOL2: usize = 6;
-pub const VMIN: usize = 4;
-pub const VTIME: usize = 5;
-pub const VSWTCH: usize = 7;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VDSUSP: usize = 11;
-pub const VREPRINT: usize = 12;
-pub const VDISCARD: usize = 13;
-pub const VWERASE: usize = 14;
-pub const VLNEXT: usize = 15;
-pub const VSTATUS: usize = 16;
-pub const VERASE2: usize = 17;
+ // c_oflag bits
+ OLCUC,
+ OFILL,
+ OFDEL,
+ NLDLY,
+ NL0,
+ NL1,
+ CRDLY,
+ CR0,
+ CR1,
+ CR2,
+ CR3,
+ TABDLY,
+ TAB1,
+ TAB2,
+ TAB3,
+ XTABS,
+ BSDLY,
+ BS0,
+ BS1,
+ VTDLY,
+ VT0,
+ VT1,
+ FFDLY,
+ FF0,
+ FF1,
+ PAGEOUT,
+ WRAP,
-// c_iflag bits
-pub const IGNBRK: tcflag_t = 0o000001;
-pub const BRKINT: tcflag_t = 0o000002;
-pub const IGNPAR: tcflag_t = 0o000004;
-pub const PARMRK: tcflag_t = 0o000010;
-pub const INPCK: tcflag_t = 0o000020;
-pub const ISTRIP: tcflag_t = 0o000040;
-pub const INLCR: tcflag_t = 0o000100;
-pub const IGNCR: tcflag_t = 0o000200;
-pub const ICRNL: tcflag_t = 0o000400;
-pub const IUCLC: tcflag_t = 0o001000;
-pub const IXON: tcflag_t = 0o002000;
-pub const IXANY: tcflag_t = 0o004000;
-pub const IXOFF: tcflag_t = 0o010000;
-pub const IMAXBEL: tcflag_t = 0o020000;
-pub const DOSMODE: tcflag_t = 0o100000;
+ // c_cflag bits
+ CBAUD,
+ RCV1EN,
+ XMT1EN,
+ LOBLK,
+ XCLUDE,
+ CRTSXOFF,
+ CRTSCTS,
+ CIBAUD,
+ PAREXT,
+ CBAUDEXT,
+ CIBAUDEXT,
-// c_oflag bits
-pub const OPOST: tcflag_t = 0o000001;
-pub const OLCUC: tcflag_t = 0o000002;
-pub const ONLCR: tcflag_t = 0o000004;
-pub const OCRNL: tcflag_t = 0o000010;
-pub const ONOCR: tcflag_t = 0o000020;
-pub const ONLRET: tcflag_t = 0o000040;
-pub const OFILL: tcflag_t = 0o000100;
-pub const OFDEL: tcflag_t = 0o000200;
-pub const NLDLY: tcflag_t = 0o000400;
-pub const NL0: tcflag_t = 0o000000;
-pub const NL1: tcflag_t = 0o000400;
-pub const CRDLY: tcflag_t = 0o003000;
-pub const CR0: tcflag_t = 0o000000;
-pub const CR1: tcflag_t = 0o001000;
-pub const CR2: tcflag_t = 0o002000;
-pub const CR3: tcflag_t = 0o003000;
-pub const TABDLY: tcflag_t = 0o014000;
-pub const TAB0: tcflag_t = 0o000000;
-pub const TAB1: tcflag_t = 0o004000;
-pub const TAB2: tcflag_t = 0o010000;
-pub const TAB3: tcflag_t = 0o014000;
-pub const XTABS: tcflag_t = 0o014000;
-pub const BSDLY: tcflag_t = 0o020000;
-pub const BS0: tcflag_t = 0o000000;
-pub const BS1: tcflag_t = 0o020000;
-pub const VTDLY: tcflag_t = 0o040000;
-pub const VT0: tcflag_t = 0o000000;
-pub const VT1: tcflag_t = 0o040000;
-pub const FFDLY: tcflag_t = 0o100000;
-pub const FF0: tcflag_t = 0o000000;
-pub const FF1: tcflag_t = 0o100000;
-pub const PAGEOUT: tcflag_t = 0o200000;
-pub const WRAP: tcflag_t = 0o400000;
+ // c_lflag bits
+ XCASE,
+ FLUSHO,
+ PENDIN,
-// c_cflag bits
-pub const CBAUD: tcflag_t = 0o000017;
-pub const CSIZE: tcflag_t = 0o000060;
-pub const CS5: tcflag_t = 0o000000;
-pub const CS6: tcflag_t = 0o000020;
-pub const CS7: tcflag_t = 0o000040;
-pub const CS8: tcflag_t = 0o000060;
-pub const CSTOPB: tcflag_t = 0o000100;
-pub const CREAD: tcflag_t = 0o000200;
-pub const PARENB: tcflag_t = 0o000400;
-pub const PARODD: tcflag_t = 0o001000;
-pub const HUPCL: tcflag_t = 0o002000;
-pub const CLOCAL: tcflag_t = 0o004000;
-pub const RCV1EN: tcflag_t = 0o010000;
-pub const XMT1EN: tcflag_t = 0o020000;
-pub const LOBLK: tcflag_t = 0o040000;
-pub const XCLUDE: tcflag_t = 0o100000;
-pub const CRTSXOFF: tcflag_t = 0o10000000000;
-pub const CRTSCTS: tcflag_t = 0o20000000000;
-pub const CIBAUD: tcflag_t = 0o3600000;
-pub const PAREXT: tcflag_t = 0o4000000;
-pub const CBAUDEXT: tcflag_t = 0o10000000;
-pub const CIBAUDEXT: tcflag_t = 0o20000000;
-
-// c_lflag bits
-pub const ISIG: tcflag_t = 0o000001;
-pub const ICANON: tcflag_t = 0o000002;
-pub const XCASE: tcflag_t = 0o000004;
-pub const ECHO: tcflag_t = 0o000010;
-pub const ECHOE: tcflag_t = 0o000020;
-pub const ECHOK: tcflag_t = 0o000040;
-pub const ECHONL: tcflag_t = 0o000100;
-pub const NOFLSH: tcflag_t = 0o000200;
-pub const TOSTOP: tcflag_t = 0o000400;
-pub const ECHOCTL: tcflag_t = 0o001000;
-pub const ECHOPRT: tcflag_t = 0o002000;
-pub const ECHOKE: tcflag_t = 0o004000;
-pub const DEFECHO: tcflag_t = 0o010000;
-pub const FLUSHO: tcflag_t = 0o020000;
-pub const PENDIN: tcflag_t = 0o040000;
-pub const IEXTEN: tcflag_t = 0o100000;
-
-// baud rates
-pub const B0: speed_t = 0;
-pub const B50: speed_t = 1;
-pub const B75: speed_t = 2;
-pub const B110: speed_t = 3;
-pub const B134: speed_t = 4;
-pub const B150: speed_t = 5;
-pub const B200: speed_t = 6;
-pub const B300: speed_t = 7;
-pub const B600: speed_t = 8;
-pub const B1200: speed_t = 9;
-pub const B1800: speed_t = 10;
-pub const B2400: speed_t = 11;
-pub const B4800: speed_t = 12;
-pub const B9600: speed_t = 13;
-pub const B19200: speed_t = 14;
-pub const B38400: speed_t = 15;
-pub const EXTA: speed_t = B19200;
-pub const EXTB: speed_t = B38400;
-pub const B57600: speed_t = 16;
-pub const B76800: speed_t = 17;
-pub const B115200: speed_t = 18;
-pub const B153600: speed_t = 19;
-pub const B230400: speed_t = 20;
-pub const B307200: speed_t = 21;
-pub const B460800: speed_t = 22;
-pub const B921600: speed_t = 23;
-
-// tcflow()
-pub const TCOOFF: c_int = 0;
-pub const TCOON: c_int = 1;
-pub const TCIOFF: c_int = 2;
-pub const TCION: c_int = 3;
-
-// tcflush()
-pub const TCIFLUSH: c_int = 0;
-pub const TCOFLUSH: c_int = 1;
-pub const TCIOFLUSH: c_int = 2;
-
-// tcsetattr()
-pub const TCSANOW: c_int = 0x540E;
-pub const TCSADRAIN: c_int = 0x540F;
-pub const TCSAFLUSH: c_int = 0x5410;
+ // baud rates
+ EXTA,
+ EXTB,
+ B57600,
+ B76800,
+ B115200,
+ B153600,
+ B230400,
+ B307200,
+ B460800,
+ B921600,
+};
diff --git a/termios/src/os/unknown.rs b/termios/src/os/unknown.rs
new file mode 100644
index 0000000..4b6a751
--- /dev/null
+++ b/termios/src/os/unknown.rs
@@ -0,0 +1,5 @@
+extern crate termios_sys;
+
+pub use ::os::common::*;
+
+pub use self::termios_sys::termios;