Temporary downgrade to libc 0.1.8

This commit is contained in:
Konstantin Gribov
2016-12-25 04:22:54 +03:00
parent 00bee9a0c1
commit b4112bbac2
3 changed files with 26 additions and 22 deletions

View File

@@ -8,6 +8,6 @@ license = "GPL-3.0+"
keywords = ["smbclient", "samba", "cifs"] keywords = ["smbclient", "samba", "cifs"]
[dependencies] [dependencies]
libc = "^0.2.18" libc = "^0.1.8"
log = "^0.3.6" log = "^0.3.6"
smbclient-sys = "^0.1.0" smbclient-sys = "^0.1.0"

View File

@@ -30,11 +30,10 @@
//! # fn main() {} //! # fn main() {}
//! ``` //! ```
//#![warn(missing_docs)]
#[macro_use] #[macro_use]
extern crate log; extern crate log;
extern crate libc; extern crate libc;
extern crate smbclient_sys;
#[macro_use] #[macro_use]
mod util; mod util;

View File

@@ -28,13 +28,16 @@ use std::ptr;
use std::borrow::Cow; use std::borrow::Cow;
use std::io::{Read, Write, Seek, SeekFrom}; use std::io::{Read, Write, Seek, SeekFrom};
use libc::{self, c_char, c_int, c_void}; use libc::{self, c_char, c_int, c_void, mode_t, off_t};
use smblient_sys::*; use smbclient_sys::*;
use util::*; use util::*;
use result::Result; use result::Result;
// 1}}} // 1}}}
const SMBC_FALSE: smbc_bool = 0;
const SMBC_TRUE: smbc_bool = 1;
// types {{{1 // types {{{1
// {{{2 // {{{2
/// ## Basic info /// ## Basic info
@@ -163,7 +166,7 @@ impl<'a> SmbClient<'a> {
} }
/// Auth wrapper passed to `SMBCCTX` to authenticate requests to SMB servers. /// Auth wrapper passed to `SMBCCTX` to authenticate requests to SMB servers.
unsafe extern "C" fn auth_wrapper<F: 'a>(ctx: *mut SMBCCTX, extern "C" fn auth_wrapper<F: 'a>(ctx: *mut SMBCCTX,
srv: *const c_char, srv: *const c_char,
shr: *const c_char, shr: *const c_char,
wg: *mut c_char, wg: *mut c_char,
@@ -174,21 +177,23 @@ impl<'a> SmbClient<'a> {
pwlen: c_int) pwlen: c_int)
-> () -> ()
where F: for<'b> Fn(&'b str, &'b str) -> (Cow<'a, str>, Cow<'a, str>, Cow<'a, str>) { where F: for<'b> Fn(&'b str, &'b str) -> (Cow<'a, str>, Cow<'a, str>, Cow<'a, str>) {
let srv = cstr(srv); unsafe {
let shr = cstr(shr); let srv = cstr(srv);
trace!(target: "smbc", "authenticating on {}\\{}", &srv, &shr); let shr = cstr(shr);
trace!(target: "smbc", "authenticating on {}\\{}", &srv, &shr);
let auth: &'a F = mem::transmute(smbc_getOptionUserData(ctx) as *const c_void); let auth: &'a F = mem::transmute(smbc_getOptionUserData(ctx) as *const c_void);
let auth = panic::AssertUnwindSafe(auth); let auth = panic::AssertUnwindSafe(auth);
let r = panic::catch_unwind(|| { let r = panic::catch_unwind(|| {
trace!(target: "smbc", "auth with {:?}\\{:?}", srv, shr); trace!(target: "smbc", "auth with {:?}\\{:?}", srv, shr);
auth(&srv, &shr) auth(&srv, &shr)
}); });
let (workgroup, username, password) = r.unwrap_or(DEF_CRED); let (workgroup, username, password) = r.unwrap_or(DEF_CRED);
trace!(target: "smbc", "cred: {}\\{} {}", &workgroup, &username, &password); trace!(target: "smbc", "cred: {}\\{} {}", &workgroup, &username, &password);
write_to_cstr(wg as *mut u8, wglen as usize, &workgroup); write_to_cstr(wg as *mut u8, wglen as usize, &workgroup);
write_to_cstr(un as *mut u8, unlen as usize, &username); write_to_cstr(un as *mut u8, unlen as usize, &username);
write_to_cstr(pw as *mut u8, pwlen as usize, &password); write_to_cstr(pw as *mut u8, pwlen as usize, &password);
}
() ()
} }
@@ -425,7 +430,7 @@ impl<'a, 'b> Read for SmbFile<'a, 'b> {
read_fn(self.smbc.ctx, read_fn(self.smbc.ctx,
self.fd, self.fd,
buf.as_mut_ptr() as *mut c_void, buf.as_mut_ptr() as *mut c_void,
buf.len()) buf.len() as _)
})); }));
Ok(bytes_read as usize) Ok(bytes_read as usize)
} }
@@ -440,7 +445,7 @@ impl<'a, 'b> Write for SmbFile<'a, 'b> {
write_fn(self.smbc.ctx, write_fn(self.smbc.ctx,
self.fd, self.fd,
buf.as_ptr() as *const c_void, buf.as_ptr() as *const c_void,
buf.len()) buf.len() as _)
})); }));
Ok(bytes_wrote as usize) Ok(bytes_wrote as usize)
} }