Compare commits

...

4 Commits

Author SHA1 Message Date
Greg Shuflin
733693258c Perform in rust 2023-11-15 19:53:30 -08:00
Greg Shuflin
66429e6714 print all strings 2023-11-15 18:34:17 -08:00
Greg Shuflin
e159df38cc install crossterm 2023-11-15 02:25:44 -08:00
Greg Shuflin
8e8f16646b secrets strings:wq 2023-11-15 02:13:17 -08:00
5 changed files with 277 additions and 183 deletions

212
Cargo.lock generated
View File

@ -13,12 +13,55 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "crossterm"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df"
dependencies = [
"bitflags 2.4.1",
"crossterm_winapi",
"libc",
"mio",
"parking_lot",
"signal-hook",
"signal-hook-mio",
"winapi",
]
[[package]]
name = "crossterm_winapi"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.10" version = "0.2.10"
@ -51,16 +94,68 @@ version = "0.2.147"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]]
name = "lock_api"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "mio"
version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
dependencies = [
"libc",
"log",
"wasi",
"windows-sys",
]
[[package]] [[package]]
name = "nmsrust" name = "nmsrust"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"atty", "atty",
"crossterm",
"lexopt", "lexopt",
"libc", "libc",
"rand", "rand",
] ]
[[package]]
name = "parking_lot"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets",
]
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.17" version = "0.2.17"
@ -97,6 +192,57 @@ dependencies = [
"getrandom", "getrandom",
] ]
[[package]]
name = "redox_syscall"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "signal-hook"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801"
dependencies = [
"libc",
"signal-hook-registry",
]
[[package]]
name = "signal-hook-mio"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af"
dependencies = [
"libc",
"mio",
"signal-hook",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
dependencies = [
"libc",
]
[[package]]
name = "smallvec"
version = "1.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.11.0+wasi-snapshot-preview1" version = "0.11.0+wasi-snapshot-preview1"
@ -124,3 +270,69 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"

View File

@ -14,4 +14,5 @@ lexopt = "0.3.0"
libc = "0.2.147" libc = "0.2.147"
atty = "0.2.14" atty = "0.2.14"
rand = "0.8.5" rand = "0.8.5"
crossterm = "0.27.0"

View File

@ -84,7 +84,7 @@ pub extern "C" fn rust_main() {
exec_effect(input, args.autodecrypt, args.mask_blanks, args.clear_screen); exec_effect(input, args.autodecrypt, args.mask_blanks, args.clear_screen);
} }
fn exec_effect(input: String, autodecrypt: bool, maskblank: bool, clear_screen: bool) { pub(crate) fn exec_effect(input: String, autodecrypt: bool, maskblank: bool, clear_screen: bool) {
let maskblank_c = if maskblank { 1 } else { 0 }; let maskblank_c = if maskblank { 1 } else { 0 };
let autodecrypt_c = if autodecrypt { 1 } else { 0}; let autodecrypt_c = if autodecrypt { 1 } else { 0};

View File

@ -17,184 +17,5 @@ int main(void) {
rust_sneakers_effect(); rust_sneakers_effect();
int termCols, spaces = 0;
unsigned char *display_uc = NULL;
char *display = NULL;
char *head1Left = "DATANET PROC RECORD: 45-3456-W-3452";
char *head1Right = "Transnet on/xc-3";
char *head2Center = "FEDERAL RESERVE TRANSFER NODE";
char *head3Center = "National Headquarters";
char *head4Center = "************ Remote Systems Network Input Station ************";
char *head5Center = "================================================================";
char *menu1 = "[1] Interbank Funds Transfer (Code Prog: 485-GWU)";
char *menu2 = "[2] International Telelink Access (Code Lim: XRP-262)";
char *menu3 = "[3] Remote Facsimile Send/Receive (Code Tran: 2LZP-517)";
char *menu4 = "[4] Regional Bank Interconnect (Security Code: 47-B34)";
char *menu5 = "[5] Update System Parameters (Entry Auth. Req.)";
char *menu6 = "[6] Remote Operator Logon/Logoff";
char *foot1Center = "================================================================";
char *foot2Center = "[ ] Select Option or ESC to Abort";
// Get terminal dimentions (needed for centering)
struct winsize w;
// if not an interactive tty, w is not populated, resulting in UB
if (ioctl(0, TIOCGWINSZ, &w) == -1) {
perror("Input not from an interactive terminal");
return 1;
}
termCols = w.ws_col;
// Allocate space for our display string
if ((display = malloc(20 * termCols)) == NULL)
{
fprintf(stderr, "Memory Allocation Error. Quitting!\n");
return 1;
}
// Allocate space for our display string
if ((display_uc = malloc(20 * termCols)) == NULL)
{
free(display);
fprintf(stderr, "Memory Allocation Error. Quitting!\n");
return 1;
}
memset(display, 0, 20 * termCols);
memset(display_uc, 0, 20 * termCols);
// Start building the display string
strcpy(display, head1Left);
spaces = termCols - strlen(head1Left) - strlen(head1Right);
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, head1Right);
strcat(display, "\n");
spaces = (termCols - strlen(head2Center)) / 2;
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, head2Center);
strcat(display, "\n");
strcat(display, "\n");
spaces = (termCols - strlen(head3Center)) / 2;
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, head3Center);
strcat(display, "\n");
strcat(display, "\n");
spaces = (termCols - strlen(head4Center)) / 2;
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, head4Center);
strcat(display, "\n");
spaces = (termCols - strlen(head5Center)) / 2;
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, head5Center);
strcat(display, "\n");
strcat(display, "\n");
spaces = ((termCols - strlen(head5Center)) / 2) + 3;
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, menu1);
strcat(display, "\n");
spaces = ((termCols - strlen(head5Center)) / 2) + 3;
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, menu2);
strcat(display, "\n");
spaces = ((termCols - strlen(head5Center)) / 2) + 3;
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, menu3);
strcat(display, "\n");
spaces = ((termCols - strlen(head5Center)) / 2) + 3;
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, menu4);
strcat(display, "\n");
spaces = ((termCols - strlen(head5Center)) / 2) + 3;
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, menu5);
strcat(display, "\n");
spaces = ((termCols - strlen(head5Center)) / 2) + 3;
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, menu6);
strcat(display, "\n");
strcat(display, "\n");
spaces = (termCols - strlen(foot1Center)) / 2;
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, foot1Center);
strcat(display, "\n");
strcat(display, "\n");
spaces = (termCols - strlen(foot2Center)) / 2;
while (spaces > 0) {
strcat(display, " ");
--spaces;
}
strcat(display, foot2Center);
nmseffect_set_clearscr(1);
memcpy(display_uc, display, 20 * termCols);
// Execute effect
nmseffect_exec(display_uc, strlen(display), 0, 0, 1);
free(display);
free(display_uc);
return 0; return 0;
} }

View File

@ -1,10 +1,70 @@
const head1Left: &str = "DATANET PROC RECORD: 45-3456-W-3452";
const head1Right: &str = "Transnet on/xc-3";
const head2Center: &str = "FEDERAL RESERVE TRANSFER NODE";
const head3Center: &str = "National Headquarters";
const head4Center: &str = "************ Remote Systems Network Input Station ************";
const head5Center: &str = "================================================================";
const menu1: &str = "[1] Interbank Funds Transfer (Code Prog: 485-GWU)";
const menu2: &str = "[2] International Telelink Access (Code Lim: XRP-262)";
const menu3: &str = "[3] Remote Facsimile Send/Receive (Code Tran: 2LZP-517)";
const menu4: &str = "[4] Regional Bank Interconnect (Security Code: 47-B34)";
const menu5: &str = "[5] Update System Parameters (Entry Auth. Req.)";
const menu6: &str = "[6] Remote Operator Logon/Logoff";
const foot1Center: &str = "================================================================";
const foot2Center: &str = "[ ] Select Option or ESC to Abort";
#[no_mangle] #[no_mangle]
pub extern "C" fn rust_sneakers_effect() { pub extern "C" fn rust_sneakers_effect() {
println!("Rust sneakers effect");
use std::time::Duration; use std::time::Duration;
let dur = Duration::from_millis(2000); let (term_width, _term_height) = crossterm::terminal::size().expect("Error reading terminal size");
std::thread::sleep(dur); let term_width = term_width as usize;
let mut buf = String::new();
buf.push_str(head1Left);
let spaces = term_width - head1Left.len() - head1Right.len();
buf.push_str(&" ".repeat(spaces));
buf.push_str(head1Right);
buf.push('\n');
for text in [head2Center, head3Center].iter(){
let spaces = ((term_width - text.len()) / 2);
buf.push_str(&" ".repeat(spaces));
buf.push_str(text);
buf.push_str("\n\n");
};
for text in [head4Center, head5Center].iter(){
let spaces = ((term_width - text.len()) / 2);
buf.push_str(&" ".repeat(spaces));
buf.push_str(text);
buf.push('\n');
};
buf.push('\n');
for text in [menu1, menu2, menu3, menu4, menu5, menu6].iter() {
let spaces = ((term_width - head5Center.len()) / 2) + 3;
buf.push_str(&" ".repeat(spaces));
buf.push_str(text);
buf.push('\n');
}
for text in [foot1Center, foot2Center].iter() {
let spaces = ((term_width - text.len()) / 2);
buf.push('\n');
buf.push_str(&" ".repeat(spaces));
buf.push_str(text);
buf.push('\n');
};
// println!("{}", buf);
// let dur = Duration::from_millis(2000);
// std::thread::sleep(dur);
crate::exec_effect(buf, false, false, true);
} }