diff --git a/src/header/termios/constants.rs b/src/header/termios/constants.rs new file mode 100644 index 0000000000..bfcf3d3837 --- /dev/null +++ b/src/header/termios/constants.rs @@ -0,0 +1,39 @@ +// These constants have values shared between Redox and Linux. + +/* c_cc { */ +/// Non-POSIX, see . +/// +/// SWTCH character (not supported under Linux). +/// Used in System V to switch shells in `shell layers`, a predecessor to shell +/// job control. +pub const VSWTCH: usize = 7; +/// SUSP character. +/// Send `SIGTSTP` signal. +/// Canonical and Non-Canonical mode. +pub const VSUSP: usize = 10; +/// Size of the array `c_cc` for control characters. +pub const NCCS: usize = 32; +/* } c_cc */ + +/* c_iflag { */ +/// Ignore break condition. +pub const IGNBRK: usize = 0o000_001; +/// Signal interrupt on break. +pub const BRKINT: usize = 0o000_002; +/// Ignore characters with parity errors. +pub const IGNPAR: usize = 0o000_004; +/// Mark parity errors. +pub const PARMRK: usize = 0o000_010; +/// Enable input parity check. +pub const INPCK: usize = 0o000_020; +/// Strip character. +pub const ISTRIP: usize = 0o000_040; +/// Map NL to CR on input. +pub const INLCR: usize = 0o000_100; +/// Ignore CR. +pub const IGNCR: usize = 0o000_200; +/// Map CR to NL on input. +pub const ICRNL: usize = 0o000_400; +/// Enable any character to restart output. +pub const IXANY: usize = 0o004_000; +/* } c_iflag */ diff --git a/src/header/termios/linux.rs b/src/header/termios/linux.rs index 6e62307ae5..67deb633ad 100644 --- a/src/header/termios/linux.rs +++ b/src/header/termios/linux.rs @@ -29,12 +29,6 @@ pub const VTIME: usize = 5; /// Minimum number of characters for noncanonical read. /// Non-Canonical mode only. pub const VMIN: usize = 6; -/// Non-POSIX, see . -/// -/// SWTCH character (not supported under Linux). -/// Used in System V to switch shells in `shell layers`, a predecessor to shell -/// job control. -pub const VSWTCH: usize = 7; /// START character. /// Restarts output stopped by the STOP character. /// Canonical and Non-Canonical mode. @@ -43,10 +37,6 @@ pub const VSTART: usize = 8; /// Stops the output until the START character is typed. /// Canonical and Non-Canonical mode. pub const VSTOP: usize = 9; -/// SUSP character. -/// Send `SIGTSTP` signal. -/// Canonical and Non-Canonical mode. -pub const VSUSP: usize = 10; /// EOL character. /// Additional end-of-line character. /// Canonical mode only. @@ -77,25 +67,28 @@ pub const VLNEXT: usize = 15; /// EOL2 character. /// Another end-of-line character. pub const VEOL2: usize = 16; -/// Size of the array `c_cc` for control characters. -pub const NCCS: usize = 32; /* } c_cc */ /* c_iflag { */ -pub const IGNBRK: usize = 0o000_001; -pub const BRKINT: usize = 0o000_002; -pub const IGNPAR: usize = 0o000_004; -pub const PARMRK: usize = 0o000_010; -pub const INPCK: usize = 0o000_020; -pub const ISTRIP: usize = 0o000_040; -pub const INLCR: usize = 0o000_100; -pub const IGNCR: usize = 0o000_200; -pub const ICRNL: usize = 0o000_400; +/// Non-POSIX, see . +/// +/// Map uppercase characters to lowercase on input. pub const IUCLC: usize = 0o001_000; +/// Enable start/stop output control. pub const IXON: usize = 0o002_000; -pub const IXANY: usize = 0o004_000; +/// Enable start/stop input control. pub const IXOFF: usize = 0o010_000; +/// Non-POSIX, see . +/// +/// Ring bell when input queue is full. +/// +/// # Implemetation +/// Linux acts as if this is always set. pub const IMAXBEL: usize = 0o020_000; +/// Non-POSIX, see . +/// +/// Input is UTF8; this allows character-erase to be correctly performed in +/// cooked mode. pub const IUTF8: usize = 0o040_000; /* } c_iflag */ diff --git a/src/header/termios/mod.rs b/src/header/termios/mod.rs index c12e3110d2..9ec23f7653 100644 --- a/src/header/termios/mod.rs +++ b/src/header/termios/mod.rs @@ -14,6 +14,9 @@ pub use crate::header::bits_winsize::winsize; pub use self::sys::*; +pub mod constants; +pub use constants::*; + #[cfg(target_os = "linux")] #[path = "linux.rs"] pub mod sys; diff --git a/src/header/termios/redox.rs b/src/header/termios/redox.rs index 7472972e32..9d6498b61d 100644 --- a/src/header/termios/redox.rs +++ b/src/header/termios/redox.rs @@ -32,12 +32,6 @@ pub const VKILL: usize = 5; /// REPRINT character. /// Reprints unread characters. pub const VREPRINT: usize = 6; -/// Non-POSIX, see . -/// -/// SWTCH character (not supported under Linux). -/// Used in System V to switch shells in `shell layers`, a predecessor to shell -/// job control. -pub const VSWTCH: usize = 7; /// INTR character. /// Send a `SIGINT` signal. /// Canonical and Non-Canonical mode. @@ -46,10 +40,6 @@ pub const VINTR: usize = 8; /// Send a `SIGQUIT` signal. /// Canonical and Non-Canonical mode. pub const VQUIT: usize = 9; -/// SUSP character. -/// Send `SIGTSTP` signal. -/// Canonical and Non-Canonical mode. -pub const VSUSP: usize = 10; /// START character. /// Restarts output stopped by the STOP character. /// Canonical and Non-Canonical mode. @@ -77,23 +67,13 @@ pub const VMIN: usize = 16; /// Timeout in decideconds for noncanonical read. /// Non-Canonical mode only. pub const VTIME: usize = 17; -/// Size of the array `c_cc` for control characters. -pub const NCCS: usize = 32; /* } c_cc */ /* c_iflag { */ -pub const IGNBRK: usize = 0o000_001; -pub const BRKINT: usize = 0o000_002; -pub const IGNPAR: usize = 0o000_004; -pub const PARMRK: usize = 0o000_010; -pub const INPCK: usize = 0o000_020; -pub const ISTRIP: usize = 0o000_040; -pub const INLCR: usize = 0o000_100; -pub const IGNCR: usize = 0o000_200; -pub const ICRNL: usize = 0o000_400; +/// Enable start/stop output control. pub const IXON: usize = 0o001_000; +/// Enable start/stop input control. pub const IXOFF: usize = 0o002_000; -pub const IXANY: usize = 0o004_000; /* } c_iflag */ /* c_oflag { */