Autodecrypt in rust

This commit is contained in:
Greg Shuflin 2023-07-23 20:18:44 -07:00
parent 30b77617e2
commit b02247fbe6
3 changed files with 7 additions and 18 deletions

View File

@ -8,10 +8,10 @@ use std::process;
const VERSION: &str = "2.0.0"; const VERSION: &str = "2.0.0";
extern "C" { extern "C" {
fn nmseffect_set_autodecrypt(_: c_int) -> c_void;
fn nmseffect_set_clearscr(_: c_int) -> c_void; fn nmseffect_set_clearscr(_: c_int) -> c_void;
static mut foregroundColor: c_int; static mut foregroundColor: c_int;
static mut maskBlank: c_int; static mut maskBlank: c_int;
static mut autoDecrypt: c_int;
} }
#[no_mangle] #[no_mangle]
@ -53,9 +53,11 @@ pub extern "C" fn rust_main() {
} }
} }
if args.autodecrypt { unsafe {
unsafe { if args.autodecrypt {
nmseffect_set_autodecrypt(1); autoDecrypt = 1;
} else {
autoDecrypt = 0;
} }
} }
} }

View File

@ -32,7 +32,7 @@
#define REVEAL_LOOP_SPEED 50 // miliseconds between each reveal loop #define REVEAL_LOOP_SPEED 50 // miliseconds between each reveal loop
// Behavior settings // Behavior settings
static int autoDecrypt = 0; // Auto-decrypt flag int autoDecrypt = 0; // Auto-decrypt flag
int maskBlank = 0; // Mask blank spaces int maskBlank = 0; // Mask blank spaces
static int colorOn = 1; // Terminal color flag static int colorOn = 1; // Terminal color flag
@ -290,18 +290,6 @@ char nmseffect_exec(unsigned char *string, int string_len) {
return ret; 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 * Pass the 'setting' argument to the nmstermio module where it will set

View File

@ -11,7 +11,6 @@
// Function prototypes // Function prototypes
char nmseffect_exec(unsigned char *, int string_len); char nmseffect_exec(unsigned char *, int string_len);
void nmseffect_set_returnopts(char *); void nmseffect_set_returnopts(char *);
void nmseffect_set_autodecrypt(int);
void nmseffect_set_clearscr(int); void nmseffect_set_clearscr(int);
void nmseffect_use_color(int); void nmseffect_use_color(int);
void nmseffect_set_input_position(int, int); void nmseffect_set_input_position(int, int);