Compare commits
No commits in common. "1d4d5f0520cfc00d8fae2778161a059e6c4eca89" and "4b3bf5dc4ba445bb3e414339af87dc5f9e6e1d68" have entirely different histories.
1d4d5f0520
...
4b3bf5dc4b
43
Cargo.lock
generated
43
Cargo.lock
generated
@ -2,26 +2,6 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lexopt"
|
||||
version = "0.3.0"
|
||||
@ -38,29 +18,6 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
|
||||
name = "nmsrust"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"lexopt",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
@ -12,5 +12,4 @@ crate-type = ["staticlib"]
|
||||
[dependencies]
|
||||
lexopt = "0.3.0"
|
||||
libc = "0.2.147"
|
||||
atty = "0.2.14"
|
||||
|
||||
|
35
src/lib.rs
35
src/lib.rs
@ -1,17 +1,14 @@
|
||||
mod args;
|
||||
mod color;
|
||||
|
||||
use libc::{c_char, c_int, c_uchar, c_void};
|
||||
use std::ffi::CString;
|
||||
use std::process;
|
||||
|
||||
use color::Color;
|
||||
use libc::{c_int, c_void};
|
||||
use std::process;
|
||||
|
||||
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) -> c_char;
|
||||
static mut foregroundColor: c_int;
|
||||
static mut maskBlank: c_int;
|
||||
static mut autoDecrypt: c_int;
|
||||
@ -63,32 +60,4 @@ pub extern "C" fn rust_main() {
|
||||
autoDecrypt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
let output = get_input("Enter input: ");
|
||||
if output.len() == 0 {
|
||||
eprintln!("Input is empty"); //TODO use error_log()/error_print() abstraction
|
||||
process::exit(1);
|
||||
}
|
||||
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) };
|
||||
}
|
||||
|
||||
fn get_input(prompt: &str) -> String {
|
||||
use std::io::{Read, Write};
|
||||
|
||||
let mut stdin = std::io::stdin();
|
||||
let mut stdout = std::io::stdout();
|
||||
let mut buf = String::new();
|
||||
|
||||
if atty::is(atty::Stream::Stdin) {
|
||||
print!("{prompt}");
|
||||
stdout.flush().unwrap();
|
||||
stdin.read_line(&mut buf).unwrap();
|
||||
} else {
|
||||
stdin.read_to_string(&mut buf).unwrap();
|
||||
}
|
||||
|
||||
buf
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ extern void rust_main();
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
rust_main();
|
||||
/*
|
||||
unsigned char *input = NULL;
|
||||
|
||||
int r = input_get(&input, "Enter input: ");
|
||||
@ -40,7 +39,6 @@ int main(int argc, char *argv[])
|
||||
r = nmseffect_exec(input, r);
|
||||
|
||||
free(input);
|
||||
*/
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user