Slight refactor
This commit is contained in:
parent
7ee23cd20d
commit
ed640548a6
18
src/lib.rs
18
src/lib.rs
@ -65,7 +65,6 @@ pub extern "C" fn rust_main() {
|
||||
foregroundColor = n;
|
||||
}
|
||||
}
|
||||
let maskblank_c = if args.mask_blanks { 1 } else { 0 };
|
||||
|
||||
if args.clear_screen {
|
||||
unsafe {
|
||||
@ -73,17 +72,26 @@ pub extern "C" fn rust_main() {
|
||||
}
|
||||
}
|
||||
|
||||
let autodecrypt_c = if args.autodecrypt { 1 } else { 0 };
|
||||
|
||||
let output = get_input("Enter input: ");
|
||||
if output.len() == 0 {
|
||||
let input = get_input("Enter input: ");
|
||||
if input.len() == 0 {
|
||||
eprintln!("Input is empty"); //TODO use error_log()/error_print() abstraction
|
||||
process::exit(1);
|
||||
}
|
||||
let output_cstring = CString::new(output).unwrap();
|
||||
|
||||
exec_effect(input, args.autodecrypt, args.mask_blanks);
|
||||
}
|
||||
|
||||
fn exec_effect(input: String, autodecrypt: bool, maskblank: bool) {
|
||||
|
||||
let maskblank_c = if maskblank { 1 } else { 0 };
|
||||
let autodecrypt_c = if autodecrypt { 1 } else { 0};
|
||||
|
||||
let output_cstring = CString::new(input).unwrap();
|
||||
let ptr = output_cstring.as_ptr();
|
||||
let len = output_cstring.as_bytes().len();
|
||||
let _r = unsafe { nmseffect_exec(ptr, len as i32, autodecrypt_c, maskblank_c) };
|
||||
|
||||
}
|
||||
|
||||
fn get_input(prompt: &str) -> String {
|
||||
|
Loading…
Reference in New Issue
Block a user