@@ -28,13 +28,16 @@ use std::ptr;
28
28
use std:: borrow:: Cow ;
29
29
use std:: io:: { Read , Write , Seek , SeekFrom } ;
30
30
31
- use libc:: { self , c_char, c_int, c_void} ;
31
+ use libc:: { self , c_char, c_int, c_void, mode_t , off_t } ;
32
32
33
- use smblient_sys :: * ;
33
+ use smbclient_sys :: * ;
34
34
use util:: * ;
35
35
use result:: Result ;
36
36
// 1}}}
37
37
38
+ const SMBC_FALSE : smbc_bool = 0 ;
39
+ const SMBC_TRUE : smbc_bool = 1 ;
40
+
38
41
// types {{{1
39
42
// {{{2
40
43
/// ## Basic info
@@ -163,7 +166,7 @@ impl<'a> SmbClient<'a> {
163
166
}
164
167
165
168
/// Auth wrapper passed to `SMBCCTX` to authenticate requests to SMB servers.
166
- unsafe extern "C" fn auth_wrapper < F : ' a > ( ctx : * mut SMBCCTX ,
169
+ extern "C" fn auth_wrapper < F : ' a > ( ctx : * mut SMBCCTX ,
167
170
srv : * const c_char ,
168
171
shr : * const c_char ,
169
172
wg : * mut c_char ,
@@ -174,21 +177,23 @@ impl<'a> SmbClient<'a> {
174
177
pwlen : c_int )
175
178
-> ( )
176
179
where F : for < ' b > Fn ( & ' b str , & ' b str ) -> ( Cow < ' a , str > , Cow < ' a , str > , Cow < ' a , str > ) {
177
- let srv = cstr ( srv) ;
178
- let shr = cstr ( shr) ;
179
- trace ! ( target: "smbc" , "authenticating on {}\\ {}" , & srv, & shr) ;
180
-
181
- let auth: & ' a F = mem:: transmute ( smbc_getOptionUserData ( ctx) as * const c_void ) ;
182
- let auth = panic:: AssertUnwindSafe ( auth) ;
183
- let r = panic:: catch_unwind ( || {
184
- trace ! ( target: "smbc" , "auth with {:?}\\ {:?}" , srv, shr) ;
185
- auth ( & srv, & shr)
186
- } ) ;
187
- let ( workgroup, username, password) = r. unwrap_or ( DEF_CRED ) ;
188
- trace ! ( target: "smbc" , "cred: {}\\ {} {}" , & workgroup, & username, & password) ;
189
- write_to_cstr ( wg as * mut u8 , wglen as usize , & workgroup) ;
190
- write_to_cstr ( un as * mut u8 , unlen as usize , & username) ;
191
- write_to_cstr ( pw as * mut u8 , pwlen as usize , & password) ;
180
+ unsafe {
181
+ let srv = cstr ( srv) ;
182
+ let shr = cstr ( shr) ;
183
+ trace ! ( target: "smbc" , "authenticating on {}\\ {}" , & srv, & shr) ;
184
+
185
+ let auth: & ' a F = mem:: transmute ( smbc_getOptionUserData ( ctx) as * const c_void ) ;
186
+ let auth = panic:: AssertUnwindSafe ( auth) ;
187
+ let r = panic:: catch_unwind ( || {
188
+ trace ! ( target: "smbc" , "auth with {:?}\\ {:?}" , srv, shr) ;
189
+ auth ( & srv, & shr)
190
+ } ) ;
191
+ let ( workgroup, username, password) = r. unwrap_or ( DEF_CRED ) ;
192
+ trace ! ( target: "smbc" , "cred: {}\\ {} {}" , & workgroup, & username, & password) ;
193
+ write_to_cstr ( wg as * mut u8 , wglen as usize , & workgroup) ;
194
+ write_to_cstr ( un as * mut u8 , unlen as usize , & username) ;
195
+ write_to_cstr ( pw as * mut u8 , pwlen as usize , & password) ;
196
+ }
192
197
( )
193
198
}
194
199
@@ -425,7 +430,7 @@ impl<'a, 'b> Read for SmbFile<'a, 'b> {
425
430
read_fn ( self . smbc . ctx ,
426
431
self . fd ,
427
432
buf. as_mut_ptr ( ) as * mut c_void ,
428
- buf. len ( ) )
433
+ buf. len ( ) as _ )
429
434
} ) ) ;
430
435
Ok ( bytes_read as usize )
431
436
}
@@ -440,7 +445,7 @@ impl<'a, 'b> Write for SmbFile<'a, 'b> {
440
445
write_fn ( self . smbc . ctx ,
441
446
self . fd ,
442
447
buf. as_ptr ( ) as * const c_void ,
443
- buf. len ( ) )
448
+ buf. len ( ) as _ )
444
449
} ) ) ;
445
450
Ok ( bytes_wrote as usize )
446
451
}
0 commit comments