Skip to content
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

Add line field to Termios struct #1805

Merged
merged 1 commit into from Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## [Unreleased] - ReleaseDate
### Added

- Added `line_discipline` 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
Expand Down
39 changes: 39 additions & 0 deletions src/sys/termios.rs
Expand Up @@ -181,6 +181,15 @@ pub struct Termios {
pub local_flags: LocalFlags,
/// Control characters (see `termios.c_cc` documentation)
pub control_chars: [libc::cc_t; NCCS],
/// Line discipline (see `termios.c_line` documentation)
#[cfg(any(
target_os = "linux",
target_os = "android",
))]
pub line_discipline: libc::cc_t,
/// Line discipline (see `termios.c_line` documentation)
#[cfg(target_os = "haiku")]
pub line_discipline: libc::c_char,
}

impl Termios {
Expand All @@ -196,6 +205,14 @@ 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",
))]
{
termios.c_line = self.line_discipline;
}
}
self.inner.borrow()
}
Expand All @@ -214,6 +231,14 @@ 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",
))]
{
termios.c_line = self.line_discipline;
}
}
self.inner.as_ptr()
}
Expand All @@ -226,6 +251,14 @@ 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",
))]
{
self.line_discipline = termios.c_line;
}
}
}

Expand All @@ -238,6 +271,12 @@ impl From<libc::termios> 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",
))]
line_discipline: termios.c_line,
}
}
}
Expand Down