Skip to content

Commit

Permalink
add line field to Termios struct
Browse files Browse the repository at this point in the history
  • Loading branch information
tertsdiepraam committed Aug 21, 2022
1 parent 2a8b438 commit e83ab05
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
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` 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
44 changes: 44 additions & 0 deletions src/sys/termios.rs
Expand Up @@ -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: libc::cc_t,
/// Line number (see `termios.c_line` documentation)
#[cfg(target_os = "haiku")]
pub line: libc::c_char,
}

impl Termios {
Expand All @@ -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;
}
}
self.inner.borrow()
}
Expand All @@ -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;
}
}
self.inner.as_ptr()
}
Expand All @@ -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 = termios.c_line;
}
}
}

Expand All @@ -238,6 +275,13 @@ 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",
target_is = "redox",
))]
line: termios.c_line,
}
}
}
Expand Down

0 comments on commit e83ab05

Please sign in to comment.