-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ioctl call with nix 0.4.* #201
Comments
Maybe I should use libc directly ? libc::ioctl(libc::STDOUT_FILENO, TIOCGWINSZ, &mut size) http://doc.rust-lang.org/libc/x86_64-apple-darwin/libc/fn.ioctl.html |
This works: #![feature(libc)]
#[macro_use]
extern crate nix;
extern crate libc;
use std::mem;
use libc::c_ushort;
#[derive(Debug)]
#[repr(C)]
struct winsize {
ws_row: c_ushort,
ws_col: c_ushort,
ws_xpixel: c_ushort,
ws_ypixel: c_ushort
}
mod ioctl {
use libc;
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
const TIOCGWINSZ: libc::c_ulong = 0x40087468;
#[cfg(any(target_os = "linux", target_os = "android"))]
const TIOCGWINSZ: libc::c_ulong = 0x5413;
ioctl!(bad read_winsize with TIOCGWINSZ);
}
fn main() {
unsafe {
let mut size: winsize = std::mem::zeroed();
ioctl::read_winsize(0, mem::transmute(&mut size as *mut winsize)).unwrap();
println!("Size: {:?}", size);
}
} |
Thanks. |
I think the original implementation did probably find the wrong level of abstraction. Here, it would be nice to use the semantics you get with For now, I certainly don't want to introduce another set of breaking changes. |
Hello,
What it is the equivalent in version 0.4.* to the following call in version 0.3.*:
(https://github.com/gwenn/rustyline/blob/master/src/lib.rs#L185)
Thanks
The text was updated successfully, but these errors were encountered: