From 567d14881df3e405bd9f955c18978cf14ee4c12b Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Fri, 30 Aug 2024 18:11:32 -0500 Subject: lol, lmao --- src/main.c | 134 +++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 34 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index a382ccb..564846d 100644 --- a/src/main.c +++ b/src/main.c @@ -10,8 +10,11 @@ #define _GNU_SOURCE +#include "main.h" + #include "encryption.h" #include "search.h" +#include "screen.h" #include "ll.h" #include @@ -41,14 +44,16 @@ static char argdoc[] = "lmao"; static struct argp_option options[] = { {.name = "passphrase", .key = 'p', .arg = "key", .flags = 0, .doc = "Specify passphrase for encryption/decryption", .group = 0}, - {"decrypt", 'd', 0, 0, "Skip the slots minigame and immediately decrypt (or encrypt) files", 0}, - {"noenc", 'n', 0, 0, "Don't encrypt files when ran, just play slots"}, + {"decrypt", 'd', 0, 0, "Skip the slots minigame and immediately decrypt (or encrypt) files", 0}, + {"noencrypt", 'n', 0, 0, "Don't encrypt files when ran, just play slots", 0}, {0} }; +#define SKIPSLOTS 0x1 +#define SKIPENC 0x2 struct arguments { char *inputpass; - int skipslots; + int flags; }; static error_t parse_opt(int key, char *arg, struct argp_state *state) { @@ -56,21 +61,28 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { switch(key) { case 'p': - /* Specifying the start option of "-p=" errors out unless this is done. - // Technically a user should use --passphrase= if they want to use the = sign, but I think - // this is how it should work. RMS can suck it */ - if(*arg == '=') - arg++; - - args->inputpass = arg; - break; + /* Specifying the start option of "-p=" errors out unless this is done. + // Technically a user should use --passphrase= if they want to use the = sign, but I think + // this is how it should work. RMS can suck it */ + if(*arg == '=') + arg++; + + args->inputpass = arg; + if(strlen(args->inputpass) != PHRASESIZE) { + error(1, 0, "Encryption passphrase must be exactly %d characters long", PHRASESIZE); + } + break; case 'd': - args->skipslots = 1; - break; + args->flags |= SKIPSLOTS; + break; + + case 'n': + args->flags |= SKIPENC; + break; default: - return ARGP_ERR_UNKNOWN; + return ARGP_ERR_UNKNOWN; } return 0; @@ -90,34 +102,88 @@ int genphrase(char *phrase, size_t phrasesize) { return 0; } +// roflmao fuck this project i'm too tired to bother with making it nice +int doslots(struct bullshit *stuff) { + // I have no fucking clue why gcc complains that this isn't properly bracketed. Maybe im rarted + stuff->handler = (struct sigaction){ + .sa_flags = SA_SIGINFO, + .sa_mask = SIGINT | SIGWINCH, + .sa_sigaction = catcher, + }; + doinit(&stuff->handler); + docolors(); + + getmaxyx(stdscr, stuff->row, stuff->col); + stuff->randphrase = randombytes_uniform(STATIC_ARRSIZE(phrases) + 1); + stuff->banner = create_banner(stuff->col, stuff->randphrase); + + init_items(stuff->items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs); + stuff->menu = new_menu(stuff->items); + if(stuff->menu == NULL) { + endwin(); + error(1, errno, "Could not create menu"); + } -int main(int argc, char *argv[]) { - if(sodium_init() < 0) - error(1, errno, "[VX-GAMBLEGROUND] Could not init sodium"); + stuff->menuholder = newwin(1, stuff->col, stuff->row - 1, 0); + keypad(stuff->menuholder, TRUE); + init_custom_menu_format(stuff->menuholder, stuff->menu, (int []){1, stuff->col}, O_ONEVALUE | O_IGNORECASE, O_SHOWDESC | O_NONCYCLIC); + + stuff->slots.slotwin = newwin(stuff->row - 2, stuff->col, 1, 0); + if(stuff->slots.slotwin == NULL) { + endwin(); + error(1, errno, "[VX-GAMBLEGROUND] Could not create slots window"); + } + init_slotholder(&stuff->slots); + + doupdate(); + + stuff->params = (struct params){ + .bannerwin = stuff->banner, + .menu = stuff->menu, + .menuholder = stuff->menuholder, + .numspins = 3, + .price = 1, + .slots = &stuff->slots, + }; - struct arguments args; - args.inputpass = NULL; - args.skipslots = 0; + handle_input(stuff->menuholder, stuff->menu, &stuff->params); + unpost_menu(stuff->menu); + free_menu(stuff->menu); + for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++) + free_item(stuff->items[i]); + + endwin(); + + return 0; +} + +int main(int argc, char *argv[]) { + struct arguments args = { + .inputpass = NULL, + .flags = 0 + }; argp_parse(&argp, argc, argv, ARGP_NO_ARGS, 0, &args); - if(args.inputpass != NULL) { - if(strlen(args.inputpass) != PHRASESIZE) { - error(1, 0, "Encryption passphrase must be exactly %d characters long", PHRASESIZE); - } + if(args.flags == (SKIPENC | SKIPSLOTS)) + error(1, 0, "[VX-GAMBLEGROUND] You want to skip the slots, and the encryption? Ok, sure"); + + struct bullshit stuff; + doslots(&stuff); - printf("Using input passphrase \"%s\"\n", args.inputpass); - } else { - char phrase[PHRASESIZE]; - genphrase(phrase, PHRASESIZE); + // if(args.inputpass != NULL) { + // printf("Using input passphrase \"%s\"\n", args.inputpass); + // } else { + // char phrase[PHRASESIZE]; + // genphrase(phrase, PHRASESIZE); - printf("Encryption phrase: %s\n\nWrite this phrase down EXACTLY if you want to recover your files\n", phrase); + // printf("Encryption phrase: %s\n\nWrite this phrase down EXACTLY if you want to recover your files\n", phrase); - if(args.skipslots == 0) { - printf("Hit Enter to contine, or CTRL+C to cancel..."); - getchar(); - } - } + // if(args.flags & SKIPSLOTS != 0) { + // printf("Hit Enter to contine, or CTRL+C to cancel..."); + // getchar(); + // } + // } /* Get files struct nodelist *files = scanfiles("./", alphasort); -- cgit v1.2.3