Make dc_open arguments rusty

This commit is contained in:
Alexander Krotov
2019-07-29 03:04:59 +03:00
parent c34e66adb6
commit 2d5b04148f
8 changed files with 41 additions and 62 deletions

View File

@@ -503,10 +503,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
"open" => {
ensure!(!arg1.is_empty(), "Argument <file> missing");
dc_close(context);
ensure!(
0 != dc_open(context, arg1_c, 0 as *const libc::c_char),
"Open failed"
);
ensure!(dc_open(context, arg1, None), "Open failed");
}
"close" => {
dc_close(context);

View File

@@ -399,12 +399,7 @@ fn main_0(args: Vec<String>) -> Result<(), failure::Error> {
unsafe { dc_cmdline_skip_auth() };
if args.len() == 2 {
if 0 == unsafe {
let a = to_cstring(&args[1]);
let res = dc_open(&mut context, a, 0 as *const _);
free(a as *mut _);
res
} {
if unsafe { !dc_open(&mut context, &args[1], None) } {
println!("Error: Cannot open {}.", args[0],);
}
} else if args.len() != 1 {