1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
extern crate libc;
use std::io;
use std::mem;
use std::os::unix::io::RawFd;
use libc::c_int;
#[cfg(target_os = "linux")]
pub use os::linux::*;
#[cfg(target_os = "macos")]
pub use os::macos::*;
mod os;
pub fn tiocexcl(fd: RawFd) -> io::Result<()> {
match unsafe { ioctl(fd, TIOCEXCL) } {
0 => Ok(()),
_ => Err(io::Error::last_os_error())
}
}
pub fn tiocnxlc(fd: RawFd) -> io::Result<()> {
match unsafe { ioctl(fd, TIOCNXCL) } {
0 => Ok(()),
_ => Err(io::Error::last_os_error())
}
}
pub fn tiocmget(fd: RawFd) -> io::Result<c_int> {
let mut bits: c_int = unsafe { mem::uninitialized() };
match unsafe { ioctl(fd, TIOCMGET, &mut bits) } {
0 => Ok(bits),
_ => Err(io::Error::last_os_error())
}
}
pub fn tiocmset(fd: RawFd, bits: c_int) -> io::Result<()> {
match unsafe { ioctl(fd, TIOCMSET, &bits) } {
0 => Ok(()),
_ => Err(io::Error::last_os_error())
}
}
pub fn tiocmbis(fd: RawFd, bits: c_int) -> io::Result<()> {
match unsafe { ioctl(fd, TIOCMBIS, &bits) } {
0 => Ok(()),
_ => Err(io::Error::last_os_error())
}
}
pub fn tiocmbic(fd: RawFd, bits: c_int) -> io::Result<()> {
match unsafe { ioctl(fd, TIOCMBIC, &bits) } {
0 => Ok(()),
_ => Err(io::Error::last_os_error())
}
}