#include #include #include #include "draw.h" #include "main.h" int main(int argc, char *argv[]) { char input[4096]; char* data = NULL; size_t data_len = 0; if (argc > 1) { // Read from file FILE *f = fopen(argv[1], "rb"); if (f == NULL) { perror("Error opening file"); return 1; } fseek(f, 0, SEEK_END); data_len = ftell(f); fseek(f, 0, SEEK_SET); data = malloc(data_len + 1); if (data == NULL) { fprintf(stderr, "Memory allocation failed\n"); fclose(f); return 1; } fread(data, 1, data_len, f); data[data_len] = '\0'; fclose(f); } else { // Get input from user drawEdges(); drawEmptyLines(1); drawTitle(TITLE); drawEmptyLines(1); drawEdges(); getUserInput(input, "What's weighing on your soul?"); data = strdup(input); data_len = strlen(data); } if (data == NULL || strlen(data) == 0) { printf("The void remains silent. (No input provided)\n"); return 0; } // Main interaction loop int choice = -1; while (choice != 0) { printf("\033[H\033[J"); // Clear screen drawEdges(); drawEmptyLines(1); drawTitle("THE VOID AWAITS"); drawEmptyLines(1); if (argc > 1) { char file_info[256]; snprintf(file_info, sizeof(file_info), "File: %s (%zu bytes)", argv[1], data_len); drawTitle(file_info); } else { // Show a preview of the string char preview[100]; strncpy(preview, data, 96); if (strlen(data) > 96) strcat(preview, "..."); drawTitle(preview); } drawEmptyLines(1); drawEdges(); drawEmptyLines(1); drawTitle("1. Scream it into the void (Standard)"); drawTitle("2. Let it burn (Fire)"); drawTitle("3. Let it dissolve (Acid)"); drawTitle("0. Keep it to yourself (Exit)"); drawEmptyLines(1); drawEdges(); printf("Choose your release: "); if (scanf("%d", &choice) != 1) { while (getchar() != '\n'); // clear buffer continue; } switch (choice) { case 1: screamIntoVoid(data); choice = 0; // Exit after screaming break; case 2: burnText(data); choice = 0; break; case 3: dissolveText(data); choice = 0; break; case 0: break; default: printf("Invalid choice.\n"); sleep_ms(1000); break; } } free(data); return 0; }