Remove autoDecrypt as global
This commit is contained in:
parent
da8bc84c36
commit
193817fda6
15
src/lib.rs
15
src/lib.rs
@ -2,7 +2,7 @@ mod args;
|
|||||||
mod charset;
|
mod charset;
|
||||||
mod color;
|
mod color;
|
||||||
|
|
||||||
use libc::{c_char, c_int, c_uchar, c_void};
|
use libc::{c_char, c_int, c_void};
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
@ -12,10 +12,9 @@ const VERSION: &str = "2.0.0";
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn nmseffect_set_clearscr(_: c_int) -> c_void;
|
fn nmseffect_set_clearscr(_: c_int) -> c_void;
|
||||||
fn nmseffect_exec(input: *const c_char, len: c_int) -> c_char;
|
fn nmseffect_exec(input: *const c_char, len: c_int, autodecrypt_c: c_int) -> c_char;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a random character from charTable[].
|
/// Return a random character from charTable[].
|
||||||
@ -67,13 +66,7 @@ pub extern "C" fn rust_main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
let autodecrypt_c = if args.autodecrypt { 1 } else { 0 };
|
||||||
if args.autodecrypt {
|
|
||||||
autoDecrypt = 1;
|
|
||||||
} else {
|
|
||||||
autoDecrypt = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let output = get_input("Enter input: ");
|
let output = get_input("Enter input: ");
|
||||||
if output.len() == 0 {
|
if output.len() == 0 {
|
||||||
@ -83,7 +76,7 @@ pub extern "C" fn rust_main() {
|
|||||||
let output_cstring = CString::new(output).unwrap();
|
let output_cstring = CString::new(output).unwrap();
|
||||||
let ptr = output_cstring.as_ptr();
|
let ptr = output_cstring.as_ptr();
|
||||||
let len = output_cstring.as_bytes().len();
|
let len = output_cstring.as_bytes().len();
|
||||||
let _r = unsafe { nmseffect_exec(ptr, len as i32) };
|
let _r = unsafe { nmseffect_exec(ptr, len as i32, autodecrypt_c) };
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_input(prompt: &str) -> String {
|
fn get_input(prompt: &str) -> String {
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#define REVEAL_LOOP_SPEED 50 // miliseconds between each reveal loop
|
#define REVEAL_LOOP_SPEED 50 // miliseconds between each reveal loop
|
||||||
|
|
||||||
// Behavior settings
|
// Behavior settings
|
||||||
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
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ static void nmseffect_sleep(int);
|
|||||||
* string that is provided as an argument. It returns the last character
|
* string that is provided as an argument. It returns the last character
|
||||||
* pressed by the user.
|
* pressed by the user.
|
||||||
*/
|
*/
|
||||||
char nmseffect_exec(unsigned char *string, int string_len) {
|
char nmseffect_exec(unsigned char *string, int string_len, int autoDecrypt) {
|
||||||
struct charAttr *list_pointer = NULL;
|
struct charAttr *list_pointer = NULL;
|
||||||
struct charAttr *list_head = NULL;
|
struct charAttr *list_head = NULL;
|
||||||
struct charAttr *list_temp = NULL;
|
struct charAttr *list_temp = NULL;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#define NMSEFFECT_H 1
|
#define NMSEFFECT_H 1
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
char nmseffect_exec(unsigned char *, int string_len);
|
char nmseffect_exec(unsigned char *, int string_len, int autoDecrypt);
|
||||||
void nmseffect_set_returnopts(char *);
|
void nmseffect_set_returnopts(char *);
|
||||||
void nmseffect_set_clearscr(int);
|
void nmseffect_set_clearscr(int);
|
||||||
void nmseffect_use_color(int);
|
void nmseffect_use_color(int);
|
||||||
|
Loading…
Reference in New Issue
Block a user