Compare commits

..

No commits in common. "c334492ea9601bced0d4e3153bcd6a3413be594e" and "db66a6a5625c11e349b9300c2f1ec649537c8eb3" have entirely different histories.

9 changed files with 16 additions and 127 deletions

1
.github/FUNDING.yml vendored
View File

@ -1 +0,0 @@
github: bartobri

5
.gitignore vendored
View File

@ -1,8 +1,3 @@
bin/* bin/*
obj/* obj/*
.vs .vs
# Added by cargo
/target

23
Cargo.lock generated
View File

@ -1,23 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "lexopt"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baff4b617f7df3d896f97fe922b64817f6cd9a756bb81d40f8883f2f66dcb401"
[[package]]
name = "libc"
version = "0.2.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]]
name = "nmsrust"
version = "0.1.0"
dependencies = [
"lexopt",
"libc",
]

View File

@ -1,15 +0,0 @@
[package]
name = "nmsrust"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["staticlib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
lexopt = "0.3.0"
libc = "0.2.147"

View File

@ -18,7 +18,7 @@ CFLAGS ?= -Wextra -Wall -O2
.PHONY: all install uninstall clean .PHONY: all install uninstall clean
nms: $(OBJ)/input.o $(OBJ)/error.o $(OBJ)/nmscharset.o $(OBJ)/nmstermio.o $(OBJ)/nmseffect.o $(OBJ)/nms.o | $(BIN) nms: $(OBJ)/input.o $(OBJ)/error.o $(OBJ)/nmscharset.o $(OBJ)/nmstermio.o $(OBJ)/nmseffect.o $(OBJ)/nms.o | $(BIN)
$(CC) $(CFLAGS) -o $(BIN)/$@ $^ target/release/libnmsrust.a $(CC) $(CFLAGS) -o $(BIN)/$@ $^
sneakers: $(OBJ)/nmscharset.o $(OBJ)/nmstermio.o $(OBJ)/nmseffect.o $(OBJ)/sneakers.o | $(BIN) sneakers: $(OBJ)/nmscharset.o $(OBJ)/nmstermio.o $(OBJ)/nmseffect.o $(OBJ)/sneakers.o | $(BIN)
$(CC) $(CFLAGS) -o $(BIN)/$@ $^ $(CC) $(CFLAGS) -o $(BIN)/$@ $^

View File

@ -1,7 +1,5 @@
![Version](https://img.shields.io/badge/Version-1.0.1-green.svg) ![Version](https://img.shields.io/badge/Version-1.0.1-green.svg)
Like this project? Consider tipping me: [https://github.com/sponsors/bartobri](https://github.com/sponsors/bartobri)
No More Secrets No More Secrets
=============== ===============
@ -35,6 +33,7 @@ Table of Contents
2. [Usage](#usage) 2. [Usage](#usage)
3. [The NMS Library](#the-nms-library) 3. [The NMS Library](#the-nms-library)
4. [License](#license) 4. [License](#license)
5. [Tips](#tips)
Download and Install Download and Install
-------------------- --------------------
@ -144,3 +143,8 @@ License
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License. See [LICENSE](LICENSE) for under the terms of the GNU General Public License. See [LICENSE](LICENSE) for
more details. more details.
Tips
----
[Tips are always appreciated!](https://github.com/bartobri/tips)

View File

@ -1,42 +0,0 @@
use std::ffi::OsString;
use lexopt::prelude::*;
#[derive(Debug, Default)]
pub(crate) struct Args {
pub(crate) version: bool,
pub(crate) clear_screen: bool,
pub(crate) foreground: Option<OsString>,
pub(crate) autodecrypt: bool,
pub(crate) mask_blanks: bool,
}
pub(crate) fn parse_arguments() -> Result<Args, lexopt::Error> {
let mut parser = lexopt::Parser::from_env();
let mut args = Args::default();
while let Some(arg) = parser.next()? {
match arg {
Short('a') => {
args.autodecrypt = true;
}
Short('c') => {
args.clear_screen = true;
}
Short('f') => {
let foreground = parser.value()?;
args.foreground = Some(foreground);
}
Short('s') => {
args.mask_blanks = true;
}
Short('v') => {
args.version = true;
}
_ => return Err(arg.unexpected()),
}
}
Ok(args)
}

View File

@ -1,35 +0,0 @@
mod args;
use libc::{c_int, c_void};
const VERSION: &str = "2.0.0";
extern "C" {
fn nmseffect_set_autodecrypt(_: c_int) -> c_void;
fn nmseffect_set_clearscr(_: c_int) -> c_void;
}
#[no_mangle]
pub extern "C" fn rust_main() {
println!("Hello from rust");
let args = args::parse_arguments().unwrap();
if args.version {
println!("nms version {VERSION}");
std::process::exit(0);
}
if args.clear_screen {
unsafe {
nmseffect_set_clearscr(1);
}
}
if args.autodecrypt {
unsafe {
nmseffect_set_autodecrypt(1);
}
}
println!("{:?}", args);
}

View File

@ -15,11 +15,8 @@
#define VERSION "1.0.1" #define VERSION "1.0.1"
extern void rust_main();
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
rust_main();
int r, o; int r, o;
unsigned char *input; unsigned char *input;
@ -32,9 +29,18 @@ int main(int argc, char *argv[])
case 'f': case 'f':
nmseffect_set_foregroundcolor(optarg); nmseffect_set_foregroundcolor(optarg);
break; break;
case 'a':
nmseffect_set_autodecrypt(1);
break;
case 's': case 's':
nmseffect_set_maskblank(1); nmseffect_set_maskblank(1);
break; break;
case 'c':
nmseffect_set_clearscr(1);
break;
case 'v':
printf("nms version " VERSION "\n");
return EXIT_SUCCESS;
case '?': case '?':
if (isprint(optopt)) if (isprint(optopt))
{ {