From b02247fbe6e5f85394b453b297e9fbb04c64a878 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 23 Jul 2023 20:18:44 -0700 Subject: [PATCH] Autodecrypt in rust --- src/lib.rs | 10 ++++++---- src/nmseffect.c | 14 +------------- src/nmseffect.h | 1 - 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 970d0c2..bb270ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,10 +8,10 @@ use std::process; const VERSION: &str = "2.0.0"; extern "C" { - fn nmseffect_set_autodecrypt(_: c_int) -> c_void; fn nmseffect_set_clearscr(_: c_int) -> c_void; static mut foregroundColor: c_int; static mut maskBlank: c_int; + static mut autoDecrypt: c_int; } #[no_mangle] @@ -53,9 +53,11 @@ pub extern "C" fn rust_main() { } } - if args.autodecrypt { - unsafe { - nmseffect_set_autodecrypt(1); + unsafe { + if args.autodecrypt { + autoDecrypt = 1; + } else { + autoDecrypt = 0; } } } diff --git a/src/nmseffect.c b/src/nmseffect.c index 068a614..1a12d48 100644 --- a/src/nmseffect.c +++ b/src/nmseffect.c @@ -32,7 +32,7 @@ #define REVEAL_LOOP_SPEED 50 // miliseconds between each reveal loop // Behavior settings -static int autoDecrypt = 0; // Auto-decrypt flag +int autoDecrypt = 0; // Auto-decrypt flag int maskBlank = 0; // Mask blank spaces static int colorOn = 1; // Terminal color flag @@ -290,18 +290,6 @@ char nmseffect_exec(unsigned char *string, int string_len) { return ret; } -/* - * Set the autoDecrypt flag according to the true/false value of the - * 'setting' argument. When set to true, nmseffect_exec() will not - * require a key press to start the decryption effect. - */ -void nmseffect_set_autodecrypt(int setting) { - if (setting) - autoDecrypt = 1; - else - autoDecrypt = 0; -} - /* * Pass the 'setting' argument to the nmstermio module where it will set diff --git a/src/nmseffect.h b/src/nmseffect.h index ba93031..9a82475 100644 --- a/src/nmseffect.h +++ b/src/nmseffect.h @@ -11,7 +11,6 @@ // Function prototypes char nmseffect_exec(unsigned char *, int string_len); void nmseffect_set_returnopts(char *); -void nmseffect_set_autodecrypt(int); void nmseffect_set_clearscr(int); void nmseffect_use_color(int); void nmseffect_set_input_position(int, int);