diff options
author | Alex Crichton <alex@alexcrichton.com> | 2015-01-09 08:23:30 -0800 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-09 08:23:49 -0800 |
commit | 56b71e79aeb29f83dd0181f9c39a6711b23bc5e5 (patch) | |
tree | 9601c935631f99b94266a7ab8b23364cac153b82 /src | |
parent | 5bc8f658884dd131139cf93c8b98997c9325b983 (diff) | |
download | ssh2-rs-56b71e79aeb29f83dd0181f9c39a6711b23bc5e5.zip |
Update to rust master
Diffstat (limited to 'src')
-rw-r--r-- | src/agent.rs | 4 | ||||
-rw-r--r-- | src/channel.rs | 56 | ||||
-rw-r--r-- | src/error.rs | 7 | ||||
-rw-r--r-- | src/knownhosts.rs | 14 | ||||
-rw-r--r-- | src/lib.rs | 90 | ||||
-rw-r--r-- | src/listener.rs | 2 | ||||
-rw-r--r-- | src/session.rs | 26 | ||||
-rw-r--r-- | src/sftp.rs | 36 |
8 files changed, 118 insertions, 117 deletions
diff --git a/src/agent.rs b/src/agent.rs index 913ebed..a5a0eb1 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -1,5 +1,5 @@ use std::ffi::CString; -use std::kinds::marker; +use std::marker; use std::slice; use std::str; @@ -122,7 +122,7 @@ impl<'agent> PublicKey<'agent> { pub fn blob(&self) -> &[u8] { unsafe { slice::from_raw_mut_buf(&(*self.raw).blob, - (*self.raw).blob_len as uint) + (*self.raw).blob_len as usize) } } diff --git a/src/channel.rs b/src/channel.rs index 25227c6..3f5047d 100644 --- a/src/channel.rs +++ b/src/channel.rs @@ -1,6 +1,6 @@ use std::cmp; use std::io; -use std::kinds::marker; +use std::marker; use libc::{c_uint, c_int, size_t, c_char, c_void, c_uchar}; use {raw, Session, Error}; @@ -33,11 +33,11 @@ pub struct ExitSignal { pub struct ReadWindow { /// The number of bytes which the remote end may send without overflowing /// the window limit. - pub remaining: uint, + pub remaining: u32, /// The number of bytes actually available to be read. - pub available: uint, + pub available: u32, /// The window_size_initial as defined by the channel open request - pub window_size_initial: uint, + pub window_size_initial: u32, } /// Description of the write window as returned by `Channel::write_window` @@ -45,9 +45,9 @@ pub struct ReadWindow { pub struct WriteWindow { /// The number of bytes which may be safely written on the channel without /// blocking. - pub remaining: uint, + pub remaining: u32, /// The window_size_initial as defined by the channel open request - pub window_size_initial: uint, + pub window_size_initial: u32, } impl<'a> Channel<'a> { @@ -124,7 +124,7 @@ impl<'a> Channel<'a> { /// height_px) pub fn request_pty(&mut self, term: &str, mode: Option<&str>, - dim: Option<(uint, uint, uint, uint)>) + dim: Option<(u32, u32, u32, u32)>) -> Result<(), Error>{ self.sess.rc(unsafe { let (width, height, width_px, height_px) = @@ -145,8 +145,8 @@ impl<'a> Channel<'a> { } /// Request a PTY of a specified size - pub fn request_pty_size(&mut self, width: uint, height: uint, - width_px: Option<uint>, height_px: Option<uint>) + pub fn request_pty_size(&mut self, width: u32, height: u32, + width_px: Option<u32>, height_px: Option<u32>) -> Result<(), Error> { let width_px = width_px.unwrap_or(0); let height_px = height_px.unwrap_or(0); @@ -191,7 +191,7 @@ impl<'a> Channel<'a> { /// /// * FLUSH_EXTENDED_DATA - Flush all extended data substreams /// * FLUSH_ALL - Flush all substreams - pub fn flush_stream(&mut self, stream_id: uint) -> Result<(), Error> { + pub fn flush_stream(&mut self, stream_id: i32) -> Result<(), Error> { unsafe { self.sess.rc(raw::libssh2_channel_flush_ex(self.raw, stream_id as c_int)) @@ -209,7 +209,7 @@ impl<'a> Channel<'a> { /// and may have up to 2^32 extended data streams as identified by the /// selected stream_id. The SSH2 protocol currently defines a stream ID of 1 /// to be the stderr substream. - pub fn write_stream(&mut self, stream_id: uint, data: &[u8]) + pub fn write_stream(&mut self, stream_id: i32, data: &[u8]) -> Result<(), Error> { unsafe { let rc = raw::libssh2_channel_write_ex(self.raw, @@ -250,7 +250,7 @@ impl<'a> Channel<'a> { unsafe fn convert(chan: &Channel, ptr: *mut c_char, len: size_t) -> Option<String> { if ptr.is_null() { return None } - let ret = Vec::from_raw_buf(ptr as *const u8, len as uint); + let ret = Vec::from_raw_buf(ptr as *const u8, len as usize); raw::libssh2_free(chan.sess.raw(), ptr as *mut c_void); String::from_utf8(ret).ok() } @@ -261,11 +261,11 @@ impl<'a> Channel<'a> { /// /// Note that the exit status may not be available if the remote end has not /// yet set its status to closed. - pub fn exit_status(&self) -> Result<int, Error> { + pub fn exit_status(&self) -> Result<i32, Error> { let ret = unsafe { raw::libssh2_channel_get_exit_status(self.raw) }; match Error::last_error(self.sess) { Some(err) => Err(err), - None => Ok(ret as int) + None => Ok(ret as i32) } } @@ -275,14 +275,14 @@ impl<'a> Channel<'a> { /// and may have up to 2^32 extended data streams as identified by the /// selected stream_id. The SSH2 protocol currently defines a stream ID of 1 /// to be the stderr substream. - pub fn read_stream(&mut self, stream_id: uint, data: &mut [u8]) - -> Result<uint, Error> { + pub fn read_stream(&mut self, stream_id: i32, data: &mut [u8]) + -> Result<usize, Error> { if self.eof() { return Err(Error::eof()) } let data = match self.read_limit { Some(amt) => { let len = data.len(); - data.slice_to_mut(cmp::min(amt as uint, len)) + data.slice_to_mut(cmp::min(amt as usize, len)) } None => data, }; @@ -297,12 +297,12 @@ impl<'a> Channel<'a> { Some(ref mut amt) => *amt -= rc as u64, None => {} } - Ok(rc as uint) + Ok(rc as usize) } } /// Read from the stderr stream . - pub fn read_stderr(&mut self, data: &mut [u8]) -> Result<uint, Error> { + pub fn read_stderr(&mut self, data: &mut [u8]) -> Result<usize, Error> { self.read_stream(::EXTENDED_DATA_STDERR, data) } @@ -339,9 +339,9 @@ impl<'a> Channel<'a> { &mut avail, &mut init); ReadWindow { - remaining: remaining as uint, - available: avail as uint, - window_size_initial: init as uint, + remaining: remaining as u32, + available: avail as u32, + window_size_initial: init as u32, } } } @@ -353,8 +353,8 @@ impl<'a> Channel<'a> { let remaining = raw::libssh2_channel_window_write_ex(self.raw, &mut init); WriteWindow { - remaining: remaining as uint, - window_size_initial: init as uint, + remaining: remaining as u32, + window_size_initial: init as u32, } } } @@ -366,8 +366,8 @@ impl<'a> Channel<'a> { /// /// This function returns the new size of the receive window (as understood /// by remote end) on success. - pub fn adjust_receive_window(&mut self, adjust: uint, force: bool) - -> Result<uint, Error> { + pub fn adjust_receive_window(&mut self, adjust: u32, force: bool) + -> Result<u32, Error> { let mut ret = 0; let rc = unsafe { raw::libssh2_channel_receive_window_adjust2(self.raw, @@ -376,7 +376,7 @@ impl<'a> Channel<'a> { &mut ret) }; try!(self.sess.rc(rc)); - Ok(ret as uint) + Ok(ret as u32) } /// Artificially limit the number of bytes that will be read from this @@ -409,7 +409,7 @@ impl<'a> Writer for Channel<'a> { } impl<'a> Reader for Channel<'a> { - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> io::IoResult<usize> { self.read_stream(0, buf).map_err(|e| { if self.eof() { io::standard_error(io::EndOfFile) diff --git a/src/error.rs b/src/error.rs index 76a120b..7118fa9 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,15 +1,15 @@ use std::fmt; -use std::kinds::marker; use std::str; use libc; use {raw, Session}; /// Representation of an error that can occur within libssh2 +#[derive(Show)] +#[allow(missing_copy_implementations)] pub struct Error { code: libc::c_int, msg: &'static str, - marker: marker::NoCopy, } impl Error { @@ -33,7 +33,6 @@ impl Error { Error { code: code, msg: msg, - marker: marker::NoCopy, } } @@ -102,7 +101,7 @@ impl Error { pub fn code(&self) -> libc::c_int { self.code } } -impl fmt::Show for Error { +impl fmt::String for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{}] {}", self.code, self.msg) } diff --git a/src/knownhosts.rs b/src/knownhosts.rs index db88254..3c6d724 100644 --- a/src/knownhosts.rs +++ b/src/knownhosts.rs @@ -1,5 +1,5 @@ use std::ffi::CString; -use std::kinds::marker; +use std::marker; use std::str; use libc::{c_int, size_t}; @@ -81,14 +81,14 @@ impl<'sess> KnownHosts<'sess> { /// Reads a collection of known hosts from a specified file and adds them to /// the collection of known hosts. pub fn read_file(&mut self, file: &Path, kind: KnownHostFileKind) - -> Result<uint, Error> { + -> Result<u32, Error> { let file = CString::from_slice(file.as_vec()); let n = unsafe { raw::libssh2_knownhost_readfile(self.raw, file.as_ptr(), kind as c_int) }; if n < 0 { try!(self.sess.rc(n)) } - Ok(n as uint) + Ok(n as u32) } /// Read a line as if it were from a known hosts file. @@ -130,10 +130,10 @@ impl<'sess> KnownHosts<'sess> { &mut outlen, kind as c_int); if rc == raw::LIBSSH2_ERROR_BUFFER_TOO_SMALL { - v.reserve(outlen as uint); + v.reserve(outlen as usize); } else { try!(self.sess.rc(rc)); - v.set_len(outlen as uint); + v.set_len(outlen as usize); break } } @@ -164,10 +164,10 @@ impl<'sess> KnownHosts<'sess> { /// Same as `check`, but takes a port as well. pub fn check_port(&self, host: &str, port: u16, key: &[u8]) -> CheckResult { - self.check_port_(host, port as int, key) + self.check_port_(host, port as i32, key) } - fn check_port_(&self, host: &str, port: int, key: &[u8]) -> CheckResult { + fn check_port_(&self, host: &str, port: i32, key: &[u8]) -> CheckResult { let host = CString::from_slice(host.as_bytes()); let flags = raw::LIBSSH2_KNOWNHOST_TYPE_PLAIN | raw::LIBSSH2_KNOWNHOST_KEYENC_RAW; @@ -89,7 +89,9 @@ //! ``` #![feature(unsafe_destructor)] -#![deny(warnings, missing_docs)] +#![deny(missing_docs)] +#![cfg_attr(test, deny(warnings))] +#![allow(unstable)] extern crate "libssh2-sys" as raw; extern crate libc; @@ -148,23 +150,23 @@ unsafe fn opt_bytes<'a, T>(_: &'a T, #[derive(Copy)] pub enum DisconnectCode { HostNotAllowedToConnect = - raw::SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT as int, - ProtocolError = raw::SSH_DISCONNECT_PROTOCOL_ERROR as int, - KeyExchangeFailed = raw::SSH_DISCONNECT_KEY_EXCHANGE_FAILED as int, - Reserved = raw::SSH_DISCONNECT_RESERVED as int, - MacError = raw::SSH_DISCONNECT_MAC_ERROR as int, - CompressionError = raw::SSH_DISCONNECT_COMPRESSION_ERROR as int, - ServiceNotAvailable = raw::SSH_DISCONNECT_SERVICE_NOT_AVAILABLE as int, + raw::SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT as isize, + ProtocolError = raw::SSH_DISCONNECT_PROTOCOL_ERROR as isize, + KeyExchangeFailed = raw::SSH_DISCONNECT_KEY_EXCHANGE_FAILED as isize, + Reserved = raw::SSH_DISCONNECT_RESERVED as isize, + MacError = raw::SSH_DISCONNECT_MAC_ERROR as isize, + CompressionError = raw::SSH_DISCONNECT_COMPRESSION_ERROR as isize, + ServiceNotAvailable = raw::SSH_DISCONNECT_SERVICE_NOT_AVAILABLE as isize, ProtocolVersionNotSupported = - raw::SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED as int, - HostKeyNotVerifiable = raw::SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE as int, - ConnectionLost = raw::SSH_DISCONNECT_CONNECTION_LOST as int, - ByApplication = raw::SSH_DISCONNECT_BY_APPLICATION as int, - TooManyConnections = raw::SSH_DISCONNECT_TOO_MANY_CONNECTIONS as int, - AuthCancelledByUser = raw::SSH_DISCONNECT_AUTH_CANCELLED_BY_USER as int, + raw::SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED as isize, + HostKeyNotVerifiable = raw::SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE as isize, + ConnectionLost = raw::SSH_DISCONNECT_CONNECTION_LOST as isize, + ByApplication = raw::SSH_DISCONNECT_BY_APPLICATION as isize, + TooManyConnections = raw::SSH_DISCONNECT_TOO_MANY_CONNECTIONS as isize, + AuthCancelledByUser = raw::SSH_DISCONNECT_AUTH_CANCELLED_BY_USER as isize, NoMoreAuthMethodsAvailable = - raw::SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE as int, - IllegalUserName = raw::SSH_DISCONNECT_ILLEGAL_USER_NAME as int, + raw::SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE as isize, + IllegalUserName = raw::SSH_DISCONNECT_ILLEGAL_USER_NAME as isize, } /// Flags to be enabled/disabled on a Session @@ -172,75 +174,75 @@ pub enum DisconnectCode { pub enum SessionFlag { /// If set, libssh2 will not attempt to block SIGPIPEs but will let them /// trigger from the underlying socket layer. - SigPipe = raw::LIBSSH2_FLAG_SIGPIPE as int, + SigPipe = raw::LIBSSH2_FLAG_SIGPIPE as isize, /// If set - before the connection negotiation is performed - libssh2 will /// try to negotiate compression enabling for this connection. By default /// libssh2 will not attempt to use compression. - Compress = raw::LIBSSH2_FLAG_COMPRESS as int, + Compress = raw::LIBSSH2_FLAG_COMPRESS as isize, } #[allow(missing_docs)] #[derive(Copy)] pub enum HostKeyType { - Unknown = raw::LIBSSH2_HOSTKEY_TYPE_UNKNOWN as int, - Rsa = raw::LIBSSH2_HOSTKEY_TYPE_RSA as int, - Dss = raw::LIBSSH2_HOSTKEY_TYPE_DSS as int, + Unknown = raw::LIBSSH2_HOSTKEY_TYPE_UNKNOWN as isize, + Rsa = raw::LIBSSH2_HOSTKEY_TYPE_RSA as isize, + Dss = raw::LIBSSH2_HOSTKEY_TYPE_DSS as isize, } #[allow(missing_docs)] #[derive(Copy)] pub enum MethodType { - Kex = raw::LIBSSH2_METHOD_KEX as int, - HostKey = raw::LIBSSH2_METHOD_HOSTKEY as int, - CryptCs = raw::LIBSSH2_METHOD_CRYPT_CS as int, - CryptSc = raw::LIBSSH2_METHOD_CRYPT_SC as int, - MacCs = raw::LIBSSH2_METHOD_MAC_CS as int, - MacSc = raw::LIBSSH2_METHOD_MAC_SC as int, - CompCs = raw::LIBSSH2_METHOD_COMP_CS as int, - CompSc = raw::LIBSSH2_METHOD_COMP_SC as int, - LangCs = raw::LIBSSH2_METHOD_LANG_CS as int, - LangSc = raw::LIBSSH2_METHOD_LANG_SC as int, + Kex = raw::LIBSSH2_METHOD_KEX as isize, + HostKey = raw::LIBSSH2_METHOD_HOSTKEY as isize, + CryptCs = raw::LIBSSH2_METHOD_CRYPT_CS as isize, + CryptSc = raw::LIBSSH2_METHOD_CRYPT_SC as isize, + MacCs = raw::LIBSSH2_METHOD_MAC_CS as isize, + MacSc = raw::LIBSSH2_METHOD_MAC_SC as isize, + CompCs = raw::LIBSSH2_METHOD_COMP_CS as isize, + CompSc = raw::LIBSSH2_METHOD_COMP_SC as isize, + LangCs = raw::LIBSSH2_METHOD_LANG_CS as isize, + LangSc = raw::LIBSSH2_METHOD_LANG_SC as isize, } /// When passed to `Channel::flush_stream`, flushes all extended data /// substreams. -pub static FLUSH_EXTENDED_DATA: uint = -1; +pub static FLUSH_EXTENDED_DATA: i32 = -1; /// When passed to `Channel::flush_stream`, flushes all substream. -pub static FLUSH_ALL: uint = -2; +pub static FLUSH_ALL: i32 = -2; /// Stream ID of the stderr channel for stream-related methods on `Channel` -pub static EXTENDED_DATA_STDERR: uint = 1; +pub static EXTENDED_DATA_STDERR: i32 = 1; #[allow(missing_docs)] #[derive(Copy)] pub enum HashType { - Md5 = raw::LIBSSH2_HOSTKEY_HASH_MD5 as int, - Sha1 = raw:: LIBSSH2_HOSTKEY_HASH_SHA1 as int, + Md5 = raw::LIBSSH2_HOSTKEY_HASH_MD5 as isize, + Sha1 = raw:: LIBSSH2_HOSTKEY_HASH_SHA1 as isize, } #[allow(missing_docs)] #[derive(Copy)] pub enum KnownHostFileKind { - OpenSSH = raw::LIBSSH2_KNOWNHOST_FILE_OPENSSH as int, + OpenSSH = raw::LIBSSH2_KNOWNHOST_FILE_OPENSSH as isize, } /// Possible results of a call to `KnownHosts::check` #[derive(Copy)] pub enum CheckResult { /// Hosts and keys match - Match = raw::LIBSSH2_KNOWNHOST_CHECK_MATCH as int, + Match = raw::LIBSSH2_KNOWNHOST_CHECK_MATCH as isize, /// Host was found, but the keys didn't match! - Mismatch = raw::LIBSSH2_KNOWNHOST_CHECK_MISMATCH as int, + Mismatch = raw::LIBSSH2_KNOWNHOST_CHECK_MISMATCH as isize, /// No host match was found - NotFound = raw::LIBSSH2_KNOWNHOST_CHECK_NOTFOUND as int, + NotFound = raw::LIBSSH2_KNOWNHOST_CHECK_NOTFOUND as isize, /// Something prevented the check to be made - Failure = raw::LIBSSH2_KNOWNHOST_CHECK_FAILURE as int, + Failure = raw::LIBSSH2_KNOWNHOST_CHECK_FAILURE as isize, } #[allow(missing_docs)] #[derive(Copy)] pub enum KnownHostKeyFormat { - Rsa1 = raw::LIBSSH2_KNOWNHOST_KEY_RSA1 as int, - SshRsa = raw::LIBSSH2_KNOWNHOST_KEY_SSHRSA as int, - SshDss = raw::LIBSSH2_KNOWNHOST_KEY_SSHDSS as int, + Rsa1 = raw::LIBSSH2_KNOWNHOST_KEY_RSA1 as isize, + SshRsa = raw::LIBSSH2_KNOWNHOST_KEY_SSHRSA as isize, + SshDss = raw::LIBSSH2_KNOWNHOST_KEY_SSHDSS as isize, } diff --git a/src/listener.rs b/src/listener.rs index 5db3b80..ab88abe 100644 --- a/src/listener.rs +++ b/src/listener.rs @@ -1,4 +1,4 @@ -use std::kinds::marker; +use std::marker; use {raw, Session, Error, Channel}; diff --git a/src/session.rs b/src/session.rs index 1f5ce7d..a98e63a 100644 --- a/src/session.rs +++ b/src/session.rs @@ -1,6 +1,6 @@ use std::ffi::CString; use std::io; -use std::kinds::marker; +use std::marker; use std::mem; use std::slice; use std::str; @@ -123,8 +123,8 @@ impl Session { /// wait until they time out. /// /// A timeout of 0 signifies no timeout. - pub fn timeout(&self) -> uint { - unsafe { raw::libssh2_session_get_timeout(self.raw) as uint } + pub fn timeout(&self) -> u32 { + unsafe { raw::libssh2_session_get_timeout(self.raw) as u32 } } /// Set timeout for blocking functions. @@ -135,7 +135,7 @@ impl Session { /// /// By default or if you set the timeout to zero, libssh2 has no timeout /// for blocking functions. - pub fn set_timeout(&self, timeout_ms: uint) { + pub fn set_timeout(&self, timeout_ms: u32) { let timeout_ms = timeout_ms as c_long; unsafe { raw::libssh2_session_set_timeout(self.raw, timeout_ms) } } @@ -150,7 +150,7 @@ impl Session { let ret = raw::libssh2_session_hostkey(self.raw, &mut len, &mut kind); if ret.is_null() { return None } let ret = ret as *const u8; - let data = mem::transmute(slice::from_raw_buf(&ret, len as uint)); + let data = mem::transmute(slice::from_raw_buf(&ret, len as usize)); let kind = match kind { raw::LIBSSH2_HOSTKEY_TYPE_RSA => HostKeyType::Rsa, raw::LIBSSH2_HOSTKEY_TYPE_DSS => HostKeyType::Dss, @@ -221,7 +221,7 @@ impl Session { let rc = raw::libssh2_session_supported_algs(self.raw, method_type, &mut ptr); if rc <= 0 { try!(self.rc(rc)) } - for i in range(0, rc as int) { + for i in range(0, rc as isize) { let s = ::opt_bytes(&STATIC, *ptr.offset(i)).unwrap();; let s = str::from_utf8(s).unwrap(); ret.push(s); @@ -263,7 +263,7 @@ impl Session { /// `channel_open_session`, `channel_direct_tcpip`, or /// `channel_forward_listen`. pub fn channel_open(&self, channel_type: &str, - window_size: uint, packet_size: uint, + window_size: u32, packet_size: u32, message: Option<&str>) -> Result<Channel, Error> { let ret = unsafe { let message_len = message.map(|s| s.len()).unwrap_or(0); @@ -287,8 +287,8 @@ impl Session { /// Establish a new session-based channel. pub fn channel_session(&self) -> Result<Channel, Error> { self.channel_open("session", - raw::LIBSSH2_CHANNEL_WINDOW_DEFAULT as uint, - raw::LIBSSH2_CHANNEL_PACKET_DEFAULT as uint, None) + raw::LIBSSH2_CHANNEL_WINDOW_DEFAULT as u32, + raw::LIBSSH2_CHANNEL_PACKET_DEFAULT as u32, None) } /// Tunnel a TCP connection through an SSH session. @@ -328,7 +328,7 @@ impl Session { pub fn channel_forward_listen(&self, remote_port: u16, host: Option<&str>, - queue_maxsize: Option<uint>) + queue_maxsize: Option<u32>) -> Result<(Listener, u16), Error> { let mut bound_port = 0; let ret = unsafe { @@ -454,7 +454,7 @@ impl Session { /// The interval argument is number of seconds that can pass without any /// I/O, use 0 (the default) to disable keepalives. To avoid some busy-loop /// corner-cases, if you specify an interval of 1 it will be treated as 2. - pub fn keepalive_set(&self, want_reply: bool, interval: uint) + pub fn keepalive_set(&self, want_reply: bool, interval: u32) -> Result<(), Error> { unsafe { self.rc(raw::libssh2_keepalive_config(self.raw, want_reply as c_int, @@ -466,11 +466,11 @@ impl Session { /// /// Returns how many seconds you can sleep after this call before you need /// to call it again. - pub fn keepalive_send(&self) -> Result<uint, Error> { + pub fn keepalive_send(&self) -> Result<u32, Error> { let mut ret = 0; let rc = unsafe { raw::libssh2_keepalive_send(self.raw, &mut ret) }; try!(self.rc(rc)); - Ok(ret as uint) + Ok(ret as u32) } /// Init a collection of known hosts for this session. diff --git a/src/sftp.rs b/src/sftp.rs index 789ca00..07380ef 100644 --- a/src/sftp.rs +++ b/src/sftp.rs @@ -1,4 +1,4 @@ -use std::kinds::marker; +use std::marker; use std::mem; use std::io; use libc::{c_int, c_ulong, c_long, c_uint, size_t}; @@ -36,15 +36,15 @@ pub struct FileStat { /// File size, in bytes of the file. pub size: Option<u64>, /// Owner ID of the file - pub uid: Option<uint>, + pub uid: Option<u32>, /// Owning group of the file - pub gid: Option<uint>, + pub gid: Option<u32>, /// Permissions (mode) of the file - pub perm: Option<uint>, + pub perm: Option<u32>, /// Last access time of the file - pub atime: Option<uint>, + pub atime: Option<u64>, /// Last modification time of the file - pub mtime: Option<uint>, + pub mtime: Option<u64>, } bitflags! { @@ -92,9 +92,9 @@ bitflags! { #[derive(Copy)] pub enum OpenType { /// Specify that a file shoud be opened. - File = raw::LIBSSH2_SFTP_OPENFILE as int, + File = raw::LIBSSH2_SFTP_OPENFILE as isize, /// Specify that a directory should be opened. - Dir = raw::LIBSSH2_SFTP_OPENDIR as int, + Dir = raw::LIBSSH2_SFTP_OPENDIR as isize, } impl<'a> Sftp<'a> { @@ -282,7 +282,7 @@ impl<'a> Sftp<'a> { if rc < 0 { Err(self.last_error()) } else { - unsafe { ret.set_len(rc as uint) } + unsafe { ret.set_len(rc as usize) } Ok(Path::new(ret)) } } @@ -407,7 +407,7 @@ impl<'a> File<'a> { } else if rc == 0 { return Err(Error::new(raw::LIBSSH2_ERROR_FILE, "no more files")) } else { - unsafe { buf.set_len(rc as uint); } + unsafe { buf.set_len(rc as usize); } } Ok((Path::new(buf), FileStat::from_raw(&stat))) } @@ -422,7 +422,7 @@ impl<'a> File<'a> { } impl<'a> Reader for File<'a> { - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> io::IoResult<usize> { unsafe { let rc = raw::libssh2_sftp_read(self.raw, buf.as_mut_ptr() as *mut _, @@ -434,7 +434,7 @@ impl<'a> Reader for File<'a> { desc: "read error", detail: Some(self.sftp.last_error().to_string()), }), - n => Ok(n as uint) + n => Ok(n as usize) } } } @@ -455,7 +455,7 @@ impl<'a> Writer for File<'a> { detail: Some(self.sftp.last_error().to_string()), }) } - buf = buf.slice_from(rc as uint); + buf = buf.slice_from(rc as usize); } Ok(()) } @@ -519,15 +519,15 @@ impl FileStat { FileStat { size: val(raw, &raw.filesize, raw::LIBSSH2_SFTP_ATTR_SIZE), uid: val(raw, &raw.uid, raw::LIBSSH2_SFTP_ATTR_UIDGID) - .map(|s| s as uint), + .map(|s| s as u32), gid: val(raw, &raw.gid, raw::LIBSSH2_SFTP_ATTR_UIDGID) - .map(|s| s as uint), + .map(|s| s as u32), perm: val(raw, &raw.permissions, raw::LIBSSH2_SFTP_ATTR_PERMISSIONS) - .map(|s| s as uint), + .map(|s| s as u32), mtime: val(raw, &raw.mtime, raw::LIBSSH2_SFTP_ATTR_ACMODTIME) - .map(|s| s as uint), + .map(|s| s as u64), atime: val(raw, &raw.atime, raw::LIBSSH2_SFTP_ATTR_ACMODTIME) - .map(|s| s as uint), + .map(|s| s as u64), } } |