summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author@syxhe <https://t.me/syxhe>2024-07-22 00:08:01 -0500
committer@syxhe <https://t.me/syxhe>2024-07-22 00:08:01 -0500
commit55af7ae0f136863f0781630e22c66b75b1afe3bc (patch)
tree46da5fc42b2f9b8004a7e1945a0d6b204e4e01fe
parentd620fbb88ea8767e2ea586e3ff57fd9e20ddc7ec (diff)
Get random phrases working and remove off-by-1 error
-rw-r--r--src/Makefile3
-rw-r--r--src/screen.c54
2 files changed, 33 insertions, 24 deletions
diff --git a/src/Makefile b/src/Makefile
index 94d2674..55268aa 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,6 +1,7 @@
1CC = gcc 1CC = gcc
2CFLAGS = -Wall -Wextra -Wpedantic -fanalyzer -Wanalyzer-too-complex -Og -g3 -ggdb 2CFLAGS = -Wall -Wextra -Wpedantic -fanalyzer -Wanalyzer-too-complex -Og -g3 -ggdb
3 3
4SHELL := /usr/bin/env -S bash
4BINARY_FILES := main encryption.o search.o ll.o 5BINARY_FILES := main encryption.o search.o ll.o
5 6
6.PHONY: all clean 7.PHONY: all clean
@@ -15,7 +16,7 @@ main: main.c search.o encryption.o ll.o
15 16
16encryption.o: encryption.c encryption.h 17encryption.o: encryption.c encryption.h
17screen: screen.c screen.h 18screen: screen.c screen.h
18 $(CC) $(CFLAGS) screen.c -o screen -lncurses -lmenu 19 set -e -o pipefail && $(CC) $(CFLAGS) $$(pkg-config --cflags libsodium) screen.c -o screen -lncurses -lmenu $$(pkg-config --libs libsodium)
19 20
20search.o: search.c search.h 21search.o: search.c search.h
21ll.o: ll.c ll.h \ No newline at end of file 22ll.o: ll.c ll.h \ No newline at end of file
diff --git a/src/screen.c b/src/screen.c
index b9e0b11..598557a 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -24,21 +24,20 @@ SLOTS HERE
24 24
25#include "screen.h" 25#include "screen.h"
26#include <curses.h> 26#include <curses.h>
27#include <menu.h>
28#include <locale.h> 27#include <locale.h>
29 28#include <sodium.h>
30#include <errno.h> 29#include <errno.h>
31#include <error.h> 30#include <error.h>
31#include <menu.h>
32 32
33#include <stdio.h> 33#include <stdio.h>
34#include <stdlib.h>
35 34
36static const char *phrases[] = { 35static const char *phrases[] = {
37 // By @syxhe on telegram 36 // By @syxhe on telegram
38 "WE CLOWN IN THIS MF, TAKE YO SENSITIVE ASS BACK TO @GENTOOMEMES", 37 "WE CLOWN IN THIS MF, TAKE YO SENSITIVE ASS BACK TO @GENTOOMEMES",
39 "R.I.P VxHeaven", 38 "R.I.P VxHeaven",
40 "tmp(2) nuked by Smelly", 39 "tmp(2) nuked by Smelly",
41 "99% of Randomware Operators quit before compromising a bank", 40 "99% of Ransomware Operators quit before compromising a bank",
42 "Equation Group wuz here", 41 "Equation Group wuz here",
43 "Lazarus wuz here", 42 "Lazarus wuz here",
44 "LockBit wuz here", 43 "LockBit wuz here",
@@ -74,8 +73,6 @@ static const char *phrases[] = {
74 "Hab you seen a alien pls?", 73 "Hab you seen a alien pls?",
75 "using a flipperzero makes me an APT, right?", 74 "using a flipperzero makes me an APT, right?",
76 "Subscribe to PewDiePie", 75 "Subscribe to PewDiePie",
77
78 NULL
79}; 76};
80 77
81static const char *menu_choices[] = { 78static const char *menu_choices[] = {
@@ -99,17 +96,25 @@ static int init_rgb_color(int colornum, int red, int green, int blue) {
99} 96}
100 97
101int main() { 98int main() {
99 if(sodium_init() < 0)
100 error(1, errno, "[VX-GAMBLEGROUND] Could not initialize sodium");
101
102 if(setlocale(LC_ALL, "") == NULL) // Clear out the locale so it doesn't default to ncurses' ISO-8859-1 setting 102 if(setlocale(LC_ALL, "") == NULL) // Clear out the locale so it doesn't default to ncurses' ISO-8859-1 setting
103 error(1, errno, "Could not set proper locale"); 103 error(1, errno, "[VX-GAMBLEGROUND] Could not set proper locale");
104 104
105 if(initscr() == NULL) // Initialize curses 105 if(initscr() == NULL) // Initialize curses
106 error(1, errno, "Could not init standard screen"); 106 error(1, errno, "[VX-GAMBLEGROUND] Could not init standard screen");
107 107
108 if(has_colors() && can_change_color()) { // Init colors if available & create color pairings 108 if(has_colors() && can_change_color()) { // Init colors if available & create color pairings
109 start_color(); 109 start_color();
110 110
111 // Init colors here 111 // Init colors here
112 // TODO: FIGURE OUT WHY COLORS ARE SO FUCKEY 112 // TODO: FIGURE OUT WHY COLORS ARE SO FUCKEY
113 /* The colors were being weird because I was being retarded and redefining already existing colors
114 // to numbers well outside curses' 0-1000 range. Making an enum that redefined the already existing
115 // curses colors made this go away. Also VSCode's terminal theming is fucking with it as well, so
116 // use a normal terminal for accurate colors */
117
113 init_rgb_color(CC_RED, 255, 0, 0); 118 init_rgb_color(CC_RED, 255, 0, 0);
114 init_rgb_color(CC_ORANGE, 255, 128, 0); 119 init_rgb_color(CC_ORANGE, 255, 128, 0);
115 init_rgb_color(CC_YELLOW, 255, 255, 0); 120 init_rgb_color(CC_YELLOW, 255, 255, 0);
@@ -125,11 +130,29 @@ int main() {
125 cbreak(); // Disables character buffering 130 cbreak(); // Disables character buffering
126 noecho(); // Disable echoing characters 131 noecho(); // Disable echoing characters
127 keypad(stdscr, TRUE); // Enable keypad on the standard screen 132 keypad(stdscr, TRUE); // Enable keypad on the standard screen
133 curs_set(0);
128 134
129 int row = -1, col = -1; 135 int row = -1, col = -1;
130 getmaxyx(stdscr, row, col); 136 getmaxyx(stdscr, row, col);
131 137
132 138
139 int randomnum = randombytes_uniform(STATIC_ARRSIZE(phrases));
140 if(randomnum < 0)
141 error(1, errno, "[VX-GAMBLEGROUND] Call to randombytes_uniform failed, can't get random phrase");
142
143 // Making this a subwindow of stdscr might be a good idea (maybe)
144 WINDOW *phrase = NULL;
145 phrase = newwin(1, col, 0, 0);
146 if(phrase == NULL)
147 error(1, errno, "[VX-GAMBLEGROUND] Could not create banner window");
148
149 wbkgd(phrase, COLOR_PAIR(1));
150 mvwaddstr(phrase, 0, 1, "VX-GAMBLEGROUND: ");
151 waddstr(phrase, phrases[randomnum]);
152 wrefresh(phrase);
153
154 wgetch(phrase);
155
133 /* Ignore 156 /* Ignore
134 for(int c = getch();; c = getch()) 157 for(int c = getch();; c = getch())
135 mvaddch(c % row, c % col, c | A_BOLD); 158 mvaddch(c % row, c % col, c | A_BOLD);
@@ -174,21 +197,6 @@ int main() {
174 free_menu(menu); 197 free_menu(menu);
175 //*/ 198 //*/
176 199
177 // Making this a subwindow of stdscr might be a good idea (maybe)
178 int height = 1;
179 int width = col;
180 int starty = 0; /* Calculating for a center placement */
181 int startx = 0; /* of the window */
182
183 WINDOW *phrase = NULL;
184 phrase = newwin(height, width, starty, startx);
185 wbkgd(phrase, COLOR_PAIR(1));
186 mvwaddstr(phrase, 0, 1, "VX-GAMBLEGROUND: ");
187 waddstr(phrase, phrases[1]);
188 wrefresh(phrase);
189
190 wgetch(phrase);
191
192 endwin(); // Clean up curses 200 endwin(); // Clean up curses
193 return 0; 201 return 0;
194} \ No newline at end of file 202} \ No newline at end of file