no-more-secrets-rust/src/lib.rs
2023-07-23 19:56:31 -07:00

47 lines
929 B
Rust

mod args;
mod color;
use libc::{c_int, c_void};
use color::Color;
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;
}
#[no_mangle]
pub extern "C" fn rust_main() {
println!("Hello from rust");
let args = args::parse_arguments().unwrap();
println!("{:?}", args);
if args.version {
println!("nms version {VERSION}");
std::process::exit(0);
}
if let Some(color) = args.foreground {
let color = Color::try_from(color).unwrap_or_default();
let n = color as c_int;
unsafe {
foregroundColor = n;
}
}
if args.clear_screen {
unsafe {
nmseffect_set_clearscr(1);
}
}
if args.autodecrypt {
unsafe {
nmseffect_set_autodecrypt(1);
}
}
}