no-more-secrets-rust/src/lib.rs

47 lines
929 B
Rust
Raw Normal View History

2023-07-23 03:04:59 -07:00
mod args;
2023-07-23 19:52:25 -07:00
mod color;
2023-07-23 03:03:23 -07:00
2023-07-23 03:14:49 -07:00
use libc::{c_int, c_void};
2023-07-23 19:52:25 -07:00
use color::Color;
2023-07-23 03:14:38 -07:00
2023-07-23 19:52:25 -07:00
const VERSION: &str = "2.0.0";
2023-07-23 03:19:40 -07:00
2023-07-23 03:14:49 -07:00
extern "C" {
fn nmseffect_set_autodecrypt(_: c_int) -> c_void;
2023-07-23 03:19:40 -07:00
fn nmseffect_set_clearscr(_: c_int) -> c_void;
2023-07-23 19:35:15 -07:00
static mut foregroundColor: c_int;
2023-07-23 03:14:38 -07:00
}
2023-07-23 03:03:23 -07:00
#[no_mangle]
pub extern "C" fn rust_main() {
println!("Hello from rust");
2023-07-23 03:14:38 -07:00
let args = args::parse_arguments().unwrap();
2023-07-23 19:52:25 -07:00
println!("{:?}", args);
2023-07-23 03:14:38 -07:00
2023-07-23 03:19:40 -07:00
if args.version {
println!("nms version {VERSION}");
std::process::exit(0);
}
2023-07-23 19:52:25 -07:00
if let Some(color) = args.foreground {
let color = Color::try_from(color).unwrap_or_default();
let n = color as c_int;
2023-07-23 19:35:15 -07:00
unsafe {
2023-07-23 19:52:25 -07:00
foregroundColor = n;
2023-07-23 19:35:15 -07:00
}
}
2023-07-23 03:19:40 -07:00
if args.clear_screen {
unsafe {
nmseffect_set_clearscr(1);
}
}
2023-07-23 03:14:38 -07:00
if args.autodecrypt {
unsafe {
nmseffect_set_autodecrypt(1);
}
}
2023-07-23 03:03:23 -07:00
}