From 251ec8bdd0f8010ffb1f82853652d6566e1e6a13 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 7 Oct 2015 10:21:47 -0700 Subject: Add automated testing of FFI bindings --- src/channel.rs | 14 +++++++------- src/session.rs | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/channel.rs b/src/channel.rs index 40933a1..cb4cf0f 100644 --- a/src/channel.rs +++ b/src/channel.rs @@ -2,7 +2,7 @@ use std::cmp; use std::io::prelude::*; use std::io::{self, ErrorKind}; use std::slice; -use libc::{c_uint, c_int, size_t, c_char, c_void, c_uchar}; +use libc::{c_uint, c_int, size_t, c_char, c_void, c_uchar, c_ulong}; use {raw, Session, Error}; use util::{Binding, SessionBinding}; @@ -274,17 +274,17 @@ impl<'sess> Channel<'sess> { /// /// 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: u32, force: bool) - -> Result { + pub fn adjust_receive_window(&mut self, adjust: u64, force: bool) + -> Result { let mut ret = 0; let rc = unsafe { raw::libssh2_channel_receive_window_adjust2(self.raw, - adjust as c_uint, + adjust as c_ulong, force as c_uchar, &mut ret) }; try!(self.sess.rc(rc)); - Ok(ret as u32) + Ok(ret as u64) } /// Artificially limit the number of bytes that will be read from this @@ -390,7 +390,7 @@ impl<'channel, 'sess> Read for Stream<'channel, 'sess> { self.id as c_int, data.as_mut_ptr() as *mut _, data.len() as size_t); - self.channel.sess.rc(rc).map(|()| rc as usize) + self.channel.sess.rc(rc as c_int).map(|()| rc as usize) }; match ret { Ok(n) => { @@ -411,7 +411,7 @@ impl<'channel, 'sess> Write for Stream<'channel, 'sess> { self.id as c_int, data.as_ptr() as *mut _, data.len() as size_t); - self.channel.sess.rc(rc).map(|()| rc as usize) + self.channel.sess.rc(rc as c_int).map(|()| rc as usize) }.map_err(|e| { io::Error::new(ErrorKind::Other, e) }) diff --git a/src/session.rs b/src/session.rs index 30ac664..1a23f5b 100644 --- a/src/session.rs +++ b/src/session.rs @@ -37,7 +37,8 @@ impl Session { pub fn new() -> Option { ::init(); unsafe { - let ret = raw::libssh2_session_init_ex(None, None, None); + let ret = raw::libssh2_session_init_ex(None, None, None, + 0 as *mut _); if ret.is_null() {None} else {Some(Binding::from_raw(ret))} } } @@ -455,7 +456,7 @@ impl Session { let ret = raw::libssh2_scp_send64(self.raw, path.as_ptr(), mode as c_int, - size, + size as i64, mtime as libc::time_t, atime as libc::time_t); SessionBinding::from_raw_opt(self, ret) @@ -562,11 +563,10 @@ 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 set_keepalive(&self, want_reply: bool, interval: u32) - -> Result<(), Error> { + pub fn set_keepalive(&self, want_reply: bool, interval: u32) { unsafe { - self.rc(raw::libssh2_keepalive_config(self.raw, want_reply as c_int, - interval as c_uint)) + raw::libssh2_keepalive_config(self.raw, want_reply as c_int, + interval as c_uint) } } -- cgit v1.2.3