From 326ae901039b70bbbd248c53e4fc3b0c580f21fd Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sun, 21 Aug 2022 00:37:17 +0200 Subject: [PATCH] add line field to Termios struct --- CHANGELOG.md | 3 +++ src/sys/termios.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56ab09fff2..45891d444a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] - ReleaseDate ### Added +- Added `line` field to `Termios` on Linux, Android and Haiku + ([#1805](https://github.com/nix-rust/nix/pull/1805)) + ### Changed - The MSRV is now 1.56.1 diff --git a/src/sys/termios.rs b/src/sys/termios.rs index c5b27d28ea..bbb6389da7 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs @@ -181,6 +181,16 @@ pub struct Termios { pub local_flags: LocalFlags, /// Control characters (see `termios.c_cc` documentation) pub control_chars: [libc::cc_t; NCCS], + /// Line number (see `termios.c_line` documentation) + #[cfg(any( + target_os = "linux", + target_os = "android", + target_is = "redox", + ))] + pub line_discipline: libc::cc_t, + /// Line number (see `termios.c_line` documentation) + #[cfg(target_os = "haiku")] + pub line_discipline: libc::c_char, } impl Termios { @@ -196,6 +206,15 @@ impl Termios { termios.c_cflag = self.control_flags.bits(); termios.c_lflag = self.local_flags.bits(); termios.c_cc = self.control_chars; + #[cfg(any( + target_os = "linux", + target_os = "android", + target_os = "haiku", + target_is = "redox", + ))] + { + termios.c_line = self.line_discipline; + } } self.inner.borrow() } @@ -214,6 +233,15 @@ impl Termios { termios.c_cflag = self.control_flags.bits(); termios.c_lflag = self.local_flags.bits(); termios.c_cc = self.control_chars; + #[cfg(any( + target_os = "linux", + target_os = "android", + target_os = "haiku", + target_is = "redox", + ))] + { + termios.c_line = self.line_discipline; + } } self.inner.as_ptr() } @@ -226,6 +254,15 @@ impl Termios { self.control_flags = ControlFlags::from_bits_truncate(termios.c_cflag); self.local_flags = LocalFlags::from_bits_truncate(termios.c_lflag); self.control_chars = termios.c_cc; + #[cfg(any( + target_os = "linux", + target_os = "android", + target_os = "haiku", + target_is = "redox", + ))] + { + self.line_discipline = termios.c_line; + } } } @@ -238,6 +275,13 @@ impl From for Termios { control_flags: ControlFlags::from_bits_truncate(termios.c_cflag), local_flags: LocalFlags::from_bits_truncate(termios.c_lflag), control_chars: termios.c_cc, + #[cfg(any( + target_os = "linux", + target_os = "android", + target_os = "haiku", + target_is = "redox", + ))] + line_discipline: termios.c_line, } } }