Skip to content

Commit

Permalink
Add cfmakeraw/cfsetspeed
Browse files Browse the repository at this point in the history
  • Loading branch information
Susurrus committed Feb 25, 2017
1 parent cb1c915 commit 78ce86e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/sys/termios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ mod ffi {
extern {
pub fn cfgetispeed(termios: *const Termios) -> speed_t;
pub fn cfgetospeed(termios: *const Termios) -> speed_t;
pub fn cfmakeraw(termios: *mut Termios);
pub fn cfsetspeed(termios: *mut Termios, speed: speed_t) -> c_int;
pub fn cfsetispeed(termios: *mut Termios, speed: speed_t) -> c_int;
pub fn cfsetospeed(termios: *mut Termios, speed: speed_t) -> c_int;
pub fn tcgetattr(fd: c_int, termios: *mut Termios) -> c_int;
Expand Down Expand Up @@ -599,6 +601,18 @@ pub fn cfgetospeed(termios: &Termios) -> BaudRate {
}
}

pub fn cfmakeraw(termios: &mut Termios) {
unsafe {
ffi::cfmakeraw(termios);
}
}

pub fn cfsetspeed(termios: &mut Termios, baud: BaudRate) -> Result<()> {
Errno::result(unsafe {
ffi::cfsetspeed(termios, baud as speed_t)
}).map(drop)
}

pub fn cfsetispeed(termios: &mut Termios, baud: BaudRate) -> Result<()> {
Errno::result(unsafe {
ffi::cfsetispeed(termios, baud as speed_t)
Expand Down

0 comments on commit 78ce86e

Please sign in to comment.