summaryrefslogtreecommitdiff
path: root/src/channel.rs
diff options
context:
space:
mode:
authorWez Furlong <wez@wezfurlong.org>2019-12-03 08:52:12 -0800
committerWez Furlong <wez@wezfurlong.org>2019-12-08 09:09:38 -0800
commit7cb3d36aedac87cdfa25b4c60e155d1e0e88a512 (patch)
treea12237e340108f11ac26046b24e116f34f1f8680 /src/channel.rs
parent692f5d77e199f8065998223f49a0f790adebc226 (diff)
downloadssh2-rs-7cb3d36aedac87cdfa25b4c60e155d1e0e88a512.zip
A PtyModes helper for specifying terminal modes
Closes: https://github.com/alexcrichton/ssh2-rs/issues/145
Diffstat (limited to 'src/channel.rs')
-rw-r--r--src/channel.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/channel.rs b/src/channel.rs
index 679a6c1..9156f57 100644
--- a/src/channel.rs
+++ b/src/channel.rs
@@ -5,7 +5,7 @@ use std::io::prelude::*;
use std::slice;
use std::sync::Arc;
-use {raw, Error, ExtendedData, SessionInner};
+use {raw, Error, ExtendedData, PtyModes, SessionInner};
/// A channel represents a portion of an SSH connection on which data can be
/// read and written.
@@ -105,17 +105,19 @@ impl Channel {
pub fn request_pty(
&mut self,
term: &str,
- mode: Option<&str>,
+ mode: Option<PtyModes>,
dim: Option<(u32, u32, u32, u32)>,
) -> Result<(), Error> {
+ let mode = mode.map(PtyModes::finish);
+ let mode = mode.as_ref().map(Vec::as_slice).unwrap_or(&[]);
self.sess.rc(unsafe {
let (width, height, width_px, height_px) = dim.unwrap_or((80, 24, 0, 0));
raw::libssh2_channel_request_pty_ex(
self.raw,
term.as_ptr() as *const _,
term.len() as c_uint,
- mode.map(|s| s.as_ptr()).unwrap_or(0 as *const _) as *const _,
- mode.map(|s| s.len()).unwrap_or(0) as c_uint,
+ mode.as_ptr() as *const _,
+ mode.len() as c_uint,
width as c_int,
height as c_int,
width_px as c_int,