summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cuddeback <david.cuddeback@gmail.com>2015-05-02 20:20:32 -0700
committerDavid Cuddeback <david.cuddeback@gmail.com>2015-05-02 20:32:50 -0700
commitf04abba74fbdc5843417da63c319f3db2e3b9829 (patch)
tree206f8ddc3ce19a25a8e02be49b02abc60a3b6125
parent94ac72e5cf820486ea7314d097ebfdc034ca1c7b (diff)
downloadtermios-rs-f04abba74fbdc5843417da63c319f3db2e3b9829.zip
exports OS-specific modules
-rw-r--r--src/ffi.rs18
-rw-r--r--src/lib.rs34
-rw-r--r--src/os/mod.rs15
3 files changed, 29 insertions, 38 deletions
diff --git a/src/ffi.rs b/src/ffi.rs
index c8f8d1f..3c36b57 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -4,21 +4,19 @@ extern crate libc;
use libc::{c_int,pid_t};
-use super::os::*;
-
#[link(name = "c")]
extern "C" {
- pub fn tcgetattr(fd: c_int, termios_p: *mut termios) -> c_int;
- pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios_p: *const termios) -> c_int;
+ pub fn tcgetattr(fd: c_int, termios_p: *mut ::os::target::termios) -> c_int;
+ pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios_p: *const ::os::target::termios) -> c_int;
pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int;
pub fn tcdrain(fd: c_int) -> c_int;
pub fn tcflush(fd: c_int, queue_selector: c_int) -> c_int;
pub fn tcflow(fd: c_int, action: c_int) -> c_int;
- pub fn cfmakeraw(termios_p: *mut termios);
- pub fn cfgetispeed(termios_p: *const termios) -> speed_t;
- pub fn cfgetospeed(termios_p: *const termios) -> speed_t;
- pub fn cfsetispeed(termios_p: *mut termios, speed: speed_t) -> c_int;
- pub fn cfsetospeed(termios_p: *mut termios, speed: speed_t) -> c_int;
- pub fn cfsetspeed(termios_p: *mut termios, speed: speed_t) -> c_int;
+ pub fn cfmakeraw(termios_p: *mut ::os::target::termios);
+ pub fn cfgetispeed(termios_p: *const ::os::target::termios) -> ::os::target::speed_t;
+ pub fn cfgetospeed(termios_p: *const ::os::target::termios) -> ::os::target::speed_t;
+ pub fn cfsetispeed(termios_p: *mut ::os::target::termios, speed: ::os::target::speed_t) -> c_int;
+ pub fn cfsetospeed(termios_p: *mut ::os::target::termios, speed: ::os::target::speed_t) -> c_int;
+ pub fn cfsetspeed(termios_p: *mut ::os::target::termios, speed: ::os::target::speed_t) -> c_int;
pub fn tcgetsid(fd: c_int) -> pid_t;
}
diff --git a/src/lib.rs b/src/lib.rs
index f371520..3990014 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -81,12 +81,12 @@
//!
//! #[cfg(target_os = "linux")]
//! fn set_fastest_speed(termios: &mut Termios) -> io::Result<()> {
-//! cfsetspeed(termios, termios::os::B4000000)
+//! cfsetspeed(termios, termios::os::linux::B4000000)
//! }
//!
//! #[cfg(target_os = "macos")]
//! fn set_fastest_speed(termios: &mut Termios) -> io::Result<()> {
-//! cfsetspeed(termios, termios::os::B230400)
+//! cfsetspeed(termios, termios::os::macos::B230400)
//! }
//!
//! # let fd = 1;
@@ -103,15 +103,15 @@ use std::os::unix::io::RawFd;
use libc::{c_int,pid_t};
-pub use os::{cc_t,speed_t,tcflag_t}; // types
-pub use os::{VEOF,VEOL,VERASE,VINTR,VKILL,VMIN,VQUIT,VSTART,VSTOP,VSUSP,VTIME}; // c_cc subscripts
-pub use os::{BRKINT,ICRNL,IGNBRK,IGNCR,IGNPAR,INLCR,INPCK,ISTRIP,IXANY,IXOFF,IXON,PARMRK}; // input modes
-pub use os::{OPOST,ONLCR,OCRNL,ONOCR,ONLRET,OFILL,NLDLY,NL0,NL1,CRDLY,CR0,CR1,CR2,CR3,TABDLY,TAB0,TAB1,TAB2,TAB3,BSDLY,BS0,BS1,VTDLY,VT0,VT1,FFDLY,FF0,FF1}; // output modes
-pub use os::{B0,B50,B75,B110,B134,B150,B200,B300,B600,B1200,B1800,B2400,B4800,B9600,B19200,B38400}; // baud rate selection
-pub use os::{CSIZE,CS5,CS6,CS7,CS8,CSTOPB,CREAD,PARENB,PARODD,HUPCL,CLOCAL}; // control modes
-pub use os::{ECHO,ECHOE,ECHOK,ECHONL,ICANON,IEXTEN,ISIG,NOFLSH,TOSTOP}; // local modes
-pub use os::{TCSANOW,TCSADRAIN,TCSAFLUSH}; // attribute selection
-pub use os::{TCIFLUSH,TCIOFLUSH,TCOFLUSH,TCIOFF,TCION,TCOOFF,TCOON}; // line control
+pub use ::os::target::{cc_t,speed_t,tcflag_t}; // types
+pub use ::os::target::{VEOF,VEOL,VERASE,VINTR,VKILL,VMIN,VQUIT,VSTART,VSTOP,VSUSP,VTIME}; // c_cc subscripts
+pub use ::os::target::{BRKINT,ICRNL,IGNBRK,IGNCR,IGNPAR,INLCR,INPCK,ISTRIP,IXANY,IXOFF,IXON,PARMRK}; // input modes
+pub use ::os::target::{OPOST,ONLCR,OCRNL,ONOCR,ONLRET,OFILL,NLDLY,NL0,NL1,CRDLY,CR0,CR1,CR2,CR3,TABDLY,TAB0,TAB1,TAB2,TAB3,BSDLY,BS0,BS1,VTDLY,VT0,VT1,FFDLY,FF0,FF1}; // output modes
+pub use ::os::target::{B0,B50,B75,B110,B134,B150,B200,B300,B600,B1200,B1800,B2400,B4800,B9600,B19200,B38400}; // baud rate selection
+pub use ::os::target::{CSIZE,CS5,CS6,CS7,CS8,CSTOPB,CREAD,PARENB,PARODD,HUPCL,CLOCAL}; // control modes
+pub use ::os::target::{ECHO,ECHOE,ECHOK,ECHONL,ICANON,IEXTEN,ISIG,NOFLSH,TOSTOP}; // local modes
+pub use ::os::target::{TCSANOW,TCSADRAIN,TCSAFLUSH}; // attribute selection
+pub use ::os::target::{TCIFLUSH,TCIOFLUSH,TCOFLUSH,TCIOFF,TCION,TCOOFF,TCOON}; // line control
pub mod ffi;
pub mod os;
@@ -154,7 +154,7 @@ pub mod os;
/// ```
#[derive(Debug,Copy,Clone,Eq,PartialEq)]
pub struct Termios {
- inner: os::termios
+ inner: ::os::target::termios
}
impl Termios {
@@ -170,25 +170,25 @@ impl Termios {
}
}
- fn inner(&self) -> &os::termios {
+ fn inner(&self) -> &::os::target::termios {
&self.inner
}
- fn inner_mut(&mut self) -> &mut os::termios {
+ fn inner_mut(&mut self) -> &mut ::os::target::termios {
&mut self.inner
}
}
impl Deref for Termios {
- type Target = os::termios;
+ type Target = ::os::target::termios;
- fn deref(&self) -> &os::termios {
+ fn deref(&self) -> &::os::target::termios {
self.inner()
}
}
impl DerefMut for Termios {
- fn deref_mut(&mut self) -> &mut os::termios {
+ fn deref_mut(&mut self) -> &mut ::os::target::termios {
self.inner_mut()
}
}
diff --git a/src/os/mod.rs b/src/os/mod.rs
index d95b618..0199033 100644
--- a/src/os/mod.rs
+++ b/src/os/mod.rs
@@ -1,14 +1,7 @@
//! OS-specific definitions.
-#[cfg(target_os = "linux")]
-pub use self::linux::*;
+#[cfg(target_os = "linux")] pub use self::linux as target;
+#[cfg(target_os = "macos")] pub use self::macos as target;
-#[cfg(target_os = "macos")]
-pub use self::macos::*;
-
-
-#[cfg(target_os = "linux")]
-mod linux;
-
-#[cfg(target_os = "macos")]
-mod macos;
+#[cfg(target_os = "linux")] pub mod linux;
+#[cfg(target_os = "macos")] pub mod macos;