blob: 18b8b1abe470aa8b57bcc3b64c72d90ce0c9befb (
plain)
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
|
use libc;
use fcntl::Fd;
use {Result, from_ffi};
pub use self::ffi::Winsize;
pub use self::IoctlArg::*;
mod ffi {
use libc::c_ushort;
#[derive(Clone, Copy, Debug)]
pub struct Winsize {
pub ws_row: c_ushort,
pub ws_col: c_ushort,
pub ws_xpixel: c_ushort,
pub ws_ypixel: c_ushort,
}
#[cfg(target_os = "macos")]
pub mod os {
use libc::c_ulong;
pub const TIOCGWINSZ: c_ulong = 0x40087468;
}
#[cfg(any(target_os = "linux",
all(target_os = "android", not(target_arch = "mips"))))]
pub mod os {
use libc::c_int;
pub const TIOCGWINSZ: c_int = 0x5413;
}
}
pub enum IoctlArg<'a> {
TIOCGWINSZ(&'a mut Winsize)
}
pub fn ioctl(fd: Fd, arg: IoctlArg) -> Result<()> {
match arg {
TIOCGWINSZ(&mut ref winsize) => {
from_ffi(unsafe {
libc::funcs::bsd44::ioctl(fd, ffi::os::TIOCGWINSZ, winsize)
})
}
}
}
|