Compare commits
No commits in common. "7ee23cd20d4f4df61cb20ddd9cd6d5ff22762331" and "4fc23d0a7663aeb4c2fc0bd3d07b67860f2a7faf" have entirely different histories.
7ee23cd20d
...
4fc23d0a76
27
src/lib.rs
27
src/lib.rs
@ -12,22 +12,9 @@ const VERSION: &str = "2.0.0";
|
||||
|
||||
extern "C" {
|
||||
fn nmseffect_set_clearscr(_: c_int) -> c_void;
|
||||
fn nmseffect_exec(
|
||||
input: *const c_char,
|
||||
len: c_int,
|
||||
autodecrypt_c: c_int,
|
||||
maskblank_c: 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;
|
||||
}
|
||||
|
||||
///Sleep for the number of milliseconds indicated by argument
|
||||
#[no_mangle]
|
||||
pub extern "C" fn nmseffect_sleep(t: c_int) {
|
||||
use std::time::Duration;
|
||||
|
||||
let dur = Duration::from_millis(t as u64);
|
||||
std::thread::sleep(dur);
|
||||
static mut maskBlank: c_int;
|
||||
}
|
||||
|
||||
/// Return a random character from charTable[].
|
||||
@ -65,7 +52,13 @@ pub extern "C" fn rust_main() {
|
||||
foregroundColor = n;
|
||||
}
|
||||
}
|
||||
let maskblank_c = if args.mask_blanks { 1 } else { 0 };
|
||||
unsafe {
|
||||
if args.mask_blanks {
|
||||
maskBlank = 1;
|
||||
} else {
|
||||
maskBlank = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if args.clear_screen {
|
||||
unsafe {
|
||||
@ -83,7 +76,7 @@ pub extern "C" fn rust_main() {
|
||||
let output_cstring = CString::new(output).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) };
|
||||
let _r = unsafe { nmseffect_exec(ptr, len as i32, autodecrypt_c) };
|
||||
}
|
||||
|
||||
fn get_input(prompt: &str) -> String {
|
||||
|
@ -32,6 +32,7 @@
|
||||
#define REVEAL_LOOP_SPEED 50 // miliseconds between each reveal loop
|
||||
|
||||
// Behavior settings
|
||||
int maskBlank = 0; // Mask blank spaces
|
||||
const int colorOn = 1; // Terminal color flag - nothing actually sets this to be false ever
|
||||
|
||||
// Character attribute structure, linked list. Keeps track of every
|
||||
@ -46,14 +47,14 @@ struct charAttr {
|
||||
};
|
||||
|
||||
// Static function prototypes
|
||||
extern void nmseffect_sleep(int);
|
||||
static void nmseffect_sleep(int);
|
||||
|
||||
/*
|
||||
* This function applies the data decryption effect to the character
|
||||
* string that is provided as an argument. It returns the last character
|
||||
* pressed by the user.
|
||||
*/
|
||||
char nmseffect_exec(unsigned char *string, int string_len, int autoDecrypt, int maskBlank) {
|
||||
char nmseffect_exec(unsigned char *string, int string_len, int autoDecrypt) {
|
||||
struct charAttr *list_pointer = NULL;
|
||||
struct charAttr *list_head = NULL;
|
||||
struct charAttr *list_temp = NULL;
|
||||
@ -297,3 +298,15 @@ char nmseffect_exec(unsigned char *string, int string_len, int autoDecrypt, int
|
||||
void nmseffect_set_clearscr(int setting) {
|
||||
nmstermio_set_clearscr(setting);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sleep for the number of milliseconds indicated by argument 't'.
|
||||
*/
|
||||
static void nmseffect_sleep(int t) {
|
||||
struct timespec ts;
|
||||
|
||||
ts.tv_sec = t / 1000;
|
||||
ts.tv_nsec = (t % 1000) * 1000000;
|
||||
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
#define NMSEFFECT_H 1
|
||||
|
||||
// Function prototypes
|
||||
char nmseffect_exec(unsigned char *, int string_len, int autoDecrypt, int maskblank);
|
||||
char nmseffect_exec(unsigned char *, int string_len, int autoDecrypt);
|
||||
void nmseffect_set_returnopts(char *);
|
||||
void nmseffect_set_clearscr(int);
|
||||
void nmseffect_use_color(int);
|
||||
|
Loading…
Reference in New Issue
Block a user