Merge remote-tracking branch 'origin/main'
This commit is contained in:
+273
@@ -9,6 +9,7 @@
|
||||
#include <time.h>
|
||||
#include <getopt.h>
|
||||
|
||||
<<<<<<< HEAD
|
||||
static char RESET[20];
|
||||
static char INCORRECT[20];
|
||||
static char CORRECT[20];
|
||||
@@ -19,6 +20,19 @@ static char INCORRECT_USER[20];
|
||||
static char CORRECT_USER[20];
|
||||
static char OUTOFPLACE_USER[20];
|
||||
static char ASCII_USER[20];
|
||||
=======
|
||||
char *RESET = "\x1b[0m";
|
||||
char *INCORRECT = "\x1b[31m";
|
||||
char *CORRECT = "\x1b[32m";
|
||||
char *OUTOFPLACE = "\x1b[33m";
|
||||
char *ASCII = "\x1b[7m";
|
||||
|
||||
char *RESET_USER = "\x1b[0m";
|
||||
char *INCORRECT_USER = "\x1b[31m";
|
||||
char *CORRECT_USER = "\x1b[32m";
|
||||
char *OUTOFPLACE_USER = "\x1b[33m";
|
||||
char *ASCII_USER = "\x1b[7m";
|
||||
>>>>>>> origin/main
|
||||
|
||||
int flag_light_theme = 0;
|
||||
int flag_user_theme = 0;
|
||||
@@ -91,6 +105,45 @@ void show_win_lose_message();
|
||||
*/
|
||||
int argparse(int argc, char *argv[]) {
|
||||
int flag_error = 0;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
for (int i = 0; i < argc; i++) {
|
||||
/*
|
||||
look for invalid arguments
|
||||
*/
|
||||
if (strcmp(argv[i], argv[0]) != 0 &&
|
||||
strcmp(argv[i], "-h") != 0 &&
|
||||
strcmp(argv[i], "--help") != 0 &&
|
||||
strcmp(argv[i], "-l") != 0 &&
|
||||
strcmp(argv[i], "--light-theme") != 0 &&
|
||||
strcmp(argv[i], "-t") != 0 &&
|
||||
strcmp(argv[i], "--theme") != 0 &&
|
||||
strcmp(argv[i-1], "-t") != 0 && // RESET color
|
||||
strcmp(argv[i-1], "--theme") != 0 &&
|
||||
strcmp(argv[i-2], "-t") != 0 && // INCORRECT color,
|
||||
strcmp(argv[i-2], "--theme") != 0 &&
|
||||
strcmp(argv[i-3], "-t") != 0 && // CORRECT color
|
||||
strcmp(argv[i-3], "--theme") != 0 &&
|
||||
strcmp(argv[i-4], "-t") != 0 && // OUTOFPLACE color
|
||||
strcmp(argv[i-4], "--theme") != 0 &&
|
||||
strcmp(argv[i-5], "-t") != 0 && // ASCII color
|
||||
strcmp(argv[i-5], "--theme") != 0 &&
|
||||
strcmp(argv[i], "-v") != 0 &&
|
||||
strcmp(argv[i], "--verbose") != 0 &&
|
||||
) {
|
||||
fprintf(stderr, "Invalid argument %s\n", argv[i]);
|
||||
flag_error = 1;
|
||||
}
|
||||
if (strcmp(argv[i], "-w") != 0 &&
|
||||
strcmp(argv[i], "--wordlist") != 0
|
||||
) {
|
||||
if (strcmp(argv[i-1], "-w") != 0 &&
|
||||
strcmp(argv[i-1], "--wordlist") != 0
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
||||
>>>>>>> origin/main
|
||||
|
||||
int option;
|
||||
char theme_values[4][2] = { " ", " ", " ", " " };
|
||||
@@ -148,7 +201,61 @@ int argparse(int argc, char *argv[]) {
|
||||
if (flag_verbose == 1) printf("wordlist_path gets the default path /usr/lib/wordlists/wordlist\n");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
return flag_error;
|
||||
=======
|
||||
/*
|
||||
getting the path to the wordlist
|
||||
*/
|
||||
if (strcmp(argv[i], "--wordlist") == 0 && flag_wordlist == 0) {
|
||||
flag_wordlist = 1;
|
||||
if (argv[i+1] != NULL) { // if there is an argument present after that, read it as the wordlist path
|
||||
strcpy(wordlist_path, argv[i+1]);
|
||||
} else {
|
||||
fprintf(stderr, "Missing argument after %s\nUsage: %s <path_to_wordlist_file>\n", argv[i], argv[i]);
|
||||
flag_error = 1;
|
||||
}
|
||||
} else if (strcmp(argv[i], "--wordlist") != 0 && flag_wordlist == 0) {
|
||||
strcpy(wordlist_path, "lib/wordlist");
|
||||
flag_wordlist = 1;
|
||||
}
|
||||
// --------------------------------------------------------------
|
||||
if (strcmp(argv[i], "-w") == 0 && flag_wordlist == 0) {
|
||||
flag_wordlist = 1;
|
||||
if (argv[i+1] != NULL) { // if there is an argument present after that, read it as the wordlist path
|
||||
strcpy(wordlist_path, argv[i+1]);
|
||||
} else {
|
||||
fprintf(stderr, "Missing argument after %s\nUsage: %s <path_to_wordlist_file>\n", argv[i], argv[i]);
|
||||
flag_error = 1;
|
||||
}
|
||||
} else if (strcmp(argv[i], "-w") != 0 && flag_wordlist == 0) {
|
||||
strcpy(wordlist_path, "lib/wordlist");
|
||||
flag_wordlist = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
getting user-specified theme colors
|
||||
*/
|
||||
if (strcmp(argv[i], "-t") != 0 && flag_user_theme == 0) {
|
||||
flag_user_theme = 1;
|
||||
set_user_theme(argv[i+1], argv[i+2], argv[i+3], argv[i+4], argv[i+5]);
|
||||
}
|
||||
// --------------------------------------------------------------
|
||||
if (strcmp(argv[i], "--theme") != 0 && flag_user_theme == 0) {
|
||||
flag_user_theme = 1;
|
||||
set_user_theme(argv[i+1], argv[i+2], argv[i+3], argv[i+4], argv[i+5]);
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists(wordlist_path) == 0) {
|
||||
fprintf(stderr, "File %s not found\n", wordlist_path);
|
||||
flag_error = 1;
|
||||
}
|
||||
|
||||
if (flag_verbose == 1) printf("wordlist_path: %s\n", wordlist_path);
|
||||
|
||||
return flag_error;
|
||||
>>>>>>> origin/main
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -315,12 +422,21 @@ void print_help_and_usage() {
|
||||
" specify a custom wordlist\n"
|
||||
" RULES: five characters on each line (no empty lines),\n"
|
||||
" each new line is separated by '\\n' (Enter/Return)\n"
|
||||
<<<<<<< HEAD
|
||||
"-t/--theme <correct_color> <incorrect_color> <out_of_place_color>\n"
|
||||
" specify the colors in which the playfield will be visible\n"
|
||||
" RULES: choose the color from this list:\n"
|
||||
" [ 'b' (black), 'r' (red), 'g' (green), 'y' (yellow), 'l' (blue), 'm' (magenta), 'c' (cyan), 'w' (white) ]\n"
|
||||
" the format is <foreground_color><background_color>\n"
|
||||
" EXAMPLE: '-t rwgwlw'\n"
|
||||
=======
|
||||
"-t/--theme <default_color> <correct_color> <incorrect_color> <out_of_place_color> <ascii_art_color>\n" // TODO: make work
|
||||
" specify the colors in which the playfield will be visible\n"
|
||||
" RULES: choose the color from this list:\n"
|
||||
" [ 'x' (default/reset), 'b' (black), 'r' (red), 'g' (green), 'y' (yellow), 'l' (blue), 'm' (magenta), 'c' (cyan), 'w' (white) ]\n"
|
||||
" the format is <foreground_color><background_color>\n"
|
||||
" EXAMPLE: '-t xx gb bw bb wb'\n"
|
||||
>>>>>>> origin/main
|
||||
"-l/--light-theme\n"
|
||||
" activate light theme\n"
|
||||
"-v/--verbose\n"
|
||||
@@ -380,6 +496,7 @@ void set_theme() {
|
||||
if (flag_user_theme != 1) {
|
||||
// handle light/dark mode
|
||||
if (flag_light_theme == 1) {
|
||||
<<<<<<< HEAD
|
||||
snprintf(RESET, sizeof(RESET), "\x1b[0;0m");
|
||||
snprintf(INCORRECT, sizeof(INCORRECT), "\x1b[41;41m");
|
||||
snprintf(CORRECT, sizeof(CORRECT), "\x1b[42;42m");
|
||||
@@ -399,14 +516,42 @@ void set_theme() {
|
||||
snprintf(CORRECT, sizeof(CORRECT), "%s", CORRECT_USER);
|
||||
snprintf(OUTOFPLACE, sizeof(OUTOFPLACE), "%s", OUTOFPLACE_USER);
|
||||
//snprintf(ASCII, sizeof(ASCII), "%s", ASCII_USER);
|
||||
=======
|
||||
RESET = "\x1b[0;0m";
|
||||
INCORRECT = "\x1b[0;41m";
|
||||
CORRECT = "\x1b[0;42m";
|
||||
OUTOFPLACE = "\x1b[0;43m";
|
||||
ASCII = "\x1b[0;7m";
|
||||
} else {
|
||||
RESET = "\x1b[37;0m";
|
||||
INCORRECT = "\x1b[37;41m";
|
||||
CORRECT = "\x1b[37;42m";
|
||||
OUTOFPLACE = "\x1b[37;43m";
|
||||
ASCII = "\x1b[37;90m";
|
||||
}
|
||||
} else {
|
||||
// handle user-specified theme
|
||||
|
||||
strcpy(RESET, RESET_USER);
|
||||
strcpy(INCORRECT, INCORRECT_USER);
|
||||
strcpy(CORRECT, CORRECT_USER);
|
||||
strcpy(OUTOFPLACE, OUTOFPLACE_USER);
|
||||
strcpy(ASCII, ASCII_USER);
|
||||
>>>>>>> origin/main
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
set user-specified theme
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
void set_user_theme(char incorrect[], char correct[], char outofplace[]) {
|
||||
/* b = black
|
||||
=======
|
||||
void set_user_theme(char reset[], char incorrect[], char correct[], char outofplace[], char ascii[]) {
|
||||
/* x = reset
|
||||
* b = black
|
||||
>>>>>>> origin/main
|
||||
* r = red
|
||||
* g = green
|
||||
* y = yellow
|
||||
@@ -416,6 +561,7 @@ void set_user_theme(char incorrect[], char correct[], char outofplace[]) {
|
||||
* w = white
|
||||
*/
|
||||
|
||||
<<<<<<< HEAD
|
||||
int incorrect_int[2];
|
||||
int correct_int[2];
|
||||
int outofplace_int[2];
|
||||
@@ -423,6 +569,62 @@ void set_user_theme(char incorrect[], char correct[], char outofplace[]) {
|
||||
// converting the flags into usable numbers
|
||||
for (int i = 0; i < 2; i++) {
|
||||
switch (incorrect[i]) {
|
||||
=======
|
||||
int reset_int[2];
|
||||
int incorrect_int[2];
|
||||
int correct_int[2];
|
||||
int outofplace_int[2];
|
||||
int ascii_int[2];
|
||||
|
||||
// converting the flags into usable numbers
|
||||
for (int i = 0; i < 2; i++) {
|
||||
switch (reset[i]) {
|
||||
case 'x':
|
||||
if (i == 0) reset_int[i] = 0;
|
||||
if (i == 1) reset_int[i] = 0;
|
||||
break;
|
||||
case 'b':
|
||||
if (i == 0) reset_int[i] = 30;
|
||||
if (i == 1) reset_int[i] = 40;
|
||||
break;
|
||||
case 'r':
|
||||
if (i == 0) reset_int[i] = 31;
|
||||
if (i == 1) reset_int[i] = 41;
|
||||
break;
|
||||
case 'g':
|
||||
if (i == 0) reset_int[i] = 32;
|
||||
if (i == 1) reset_int[i] = 42;
|
||||
break;
|
||||
case 'y':
|
||||
if (i == 0) reset_int[i] = 33;
|
||||
if (i == 1) reset_int[i] = 43;
|
||||
break;
|
||||
case 'l':
|
||||
if (i == 0) reset_int[i] = 34;
|
||||
if (i == 1) reset_int[i] = 44;
|
||||
break;
|
||||
case 'm':
|
||||
if (i == 0) reset_int[i] = 35;
|
||||
if (i == 1) reset_int[i] = 45;
|
||||
break;
|
||||
case 'c':
|
||||
if (i == 0) reset_int[i] = 36;
|
||||
if (i == 1) reset_int[i] = 46;
|
||||
break;
|
||||
case 'w':
|
||||
if (i == 0) reset_int[i] = 37;
|
||||
if (i == 1) reset_int[i] = 47;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
switch (incorrect[i]) {
|
||||
case 'x':
|
||||
if (i == 0) incorrect_int[i] = 0;
|
||||
if (i == 1) incorrect_int[i] = 0;
|
||||
break;
|
||||
>>>>>>> origin/main
|
||||
case 'b':
|
||||
if (i == 0) incorrect_int[i] = 30;
|
||||
if (i == 1) incorrect_int[i] = 40;
|
||||
@@ -460,6 +662,13 @@ void set_user_theme(char incorrect[], char correct[], char outofplace[]) {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
switch (correct[i]) {
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
case 'x':
|
||||
if (i == 0) correct_int[i] = 0;
|
||||
if (i == 1) correct_int[i] = 0;
|
||||
break;
|
||||
>>>>>>> origin/main
|
||||
case 'b':
|
||||
if (i == 0) correct_int[i] = 30;
|
||||
if (i == 1) correct_int[i] = 40;
|
||||
@@ -497,6 +706,13 @@ void set_user_theme(char incorrect[], char correct[], char outofplace[]) {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
switch (outofplace[i]) {
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
case 'x':
|
||||
if (i == 0) outofplace_int[i] = 0;
|
||||
if (i == 1) outofplace_int[i] = 0;
|
||||
break;
|
||||
>>>>>>> origin/main
|
||||
case 'b':
|
||||
if (i == 0) outofplace_int[i] = 30;
|
||||
if (i == 1) outofplace_int[i] = 40;
|
||||
@@ -532,12 +748,59 @@ void set_user_theme(char incorrect[], char correct[], char outofplace[]) {
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
for (int i = 0; i < 2; i++) {
|
||||
switch (ascii[i]) {
|
||||
case 'x':
|
||||
if (i == 0) ascii_int[i] = 0;
|
||||
if (i == 1) ascii_int[i] = 0;
|
||||
break;
|
||||
case 'b':
|
||||
if (i == 0) ascii_int[i] = 30;
|
||||
if (i == 1) ascii_int[i] = 40;
|
||||
break;
|
||||
case 'r':
|
||||
if (i == 0) ascii_int[i] = 31;
|
||||
if (i == 1) ascii_int[i] = 41;
|
||||
break;
|
||||
case 'g':
|
||||
if (i == 0) ascii_int[i] = 32;
|
||||
if (i == 1) ascii_int[i] = 42;
|
||||
break;
|
||||
case 'y':
|
||||
if (i == 0) ascii_int[i] = 33;
|
||||
if (i == 1) ascii_int[i] = 43;
|
||||
break;
|
||||
case 'l':
|
||||
if (i == 0) ascii_int[i] = 34;
|
||||
if (i == 1) ascii_int[i] = 44;
|
||||
break;
|
||||
case 'm':
|
||||
if (i == 0) ascii_int[i] = 35;
|
||||
if (i == 1) ascii_int[i] = 45;
|
||||
break;
|
||||
case 'c':
|
||||
if (i == 0) ascii_int[i] = 36;
|
||||
if (i == 1) ascii_int[i] = 46;
|
||||
break;
|
||||
case 'w':
|
||||
if (i == 0) ascii_int[i] = 37;
|
||||
if (i == 1) ascii_int[i] = 47;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int reset_f = reset_int[0];
|
||||
int reset_b = reset_int[1];
|
||||
>>>>>>> origin/main
|
||||
int incorrect_f = incorrect_int[0];
|
||||
int incorrect_b = incorrect_int[1];
|
||||
int correct_f = correct_int[0];
|
||||
int correct_b = correct_int[1];
|
||||
int outofplace_f = outofplace_int[0];
|
||||
int outofplace_b = outofplace_int[1];
|
||||
<<<<<<< HEAD
|
||||
|
||||
snprintf(INCORRECT_USER, sizeof(INCORRECT_USER), "\x1b[%d;%dm", incorrect_f, incorrect_b);
|
||||
snprintf(CORRECT_USER, sizeof(CORRECT_USER), "\x1b[%d;%dm", correct_f, correct_b);
|
||||
@@ -545,6 +808,16 @@ void set_user_theme(char incorrect[], char correct[], char outofplace[]) {
|
||||
//snprintf(ASCII_USER, sizeof(ASCII_USER), "\x1b[%d;%dm", ascii_f, ascii_b);
|
||||
|
||||
set_theme();
|
||||
=======
|
||||
int ascii_f = ascii_int[0];
|
||||
int ascii_b = ascii_int[1];
|
||||
|
||||
sprintf(RESET_USER, "\x1b[%d;%dm", reset_f, reset_b);
|
||||
sprintf(INCORRECT_USER, "\x1b[%d;%dm", incorrect_f, incorrect_b);
|
||||
sprintf(CORRECT_USER, "\x1b[%d;%dm", correct_f, correct_b);
|
||||
sprintf(OUTOFPLACE_USER, "\x1b[%d;%dm", outofplace_f, outofplace_b);
|
||||
sprintf(ASCII_USER, "\x1b[%d;%dm", ascii_f, ascii_b);
|
||||
>>>>>>> origin/main
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user