v2.1, add preprocessor flags for protection, small output changes, remove debug stuff

This commit is contained in:
hornet 2025-10-17 23:22:14 +05:00
parent 52841bf885
commit 37c8b24342
5 changed files with 23 additions and 9 deletions

1
main.c
View file

@ -13,6 +13,7 @@ author: hornetmaidan
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <curl/curl.h>
#include "src/globals.h"
#include "src/cache.h"
#include "src/network.h"

View file

@ -1,4 +1,5 @@
#include "globals.h"
#ifndef DEFCON_CACHE_
#define DEFCON_CACHE_
int check_cache(void) {
if (access(FILENAME, F_OK) != 0) {
@ -7,4 +8,6 @@ int check_cache(void) {
fputc('5', fp);
fclose(fp);
}
}
}
#endif

View file

@ -1,3 +1,6 @@
#ifndef DEFCON_GLOBALS_
#define DEFCON_GLOBALS_
// ANSI colors
#define COLOR_RESET "\033[0m"
#define COLOR_RED "\033[31m"
@ -7,4 +10,6 @@
#define COLOR_MAGENTA "\033[35m"
#define COLOR_CYAN "\033[36m"
#define COLOR_WHITE "\033[37m"
#define COLOR_BLINK "\033[5m"
#define COLOR_BLINK "\033[5m"
#endif

View file

@ -1,5 +1,5 @@
#include <curl/curl.h>
#include "globals.h"
#ifndef DEFCON_NETWORK_
#define DEFCON_NETWORK_
char failsafe;
@ -30,7 +30,6 @@ int query_defcon() {
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
result = curl_easy_perform(curl); // actual request performing
curl_easy_cleanup(curl);
fprintf(stdout, "%scurl success!%s\n", COLOR_GREEN, COLOR_RESET);
if (result != CURLE_OK) {
fprintf(stderr, "%serror: %s%s\n", COLOR_MAGENTA, curl_easy_strerror(result), COLOR_RESET);
@ -40,4 +39,6 @@ int query_defcon() {
}
fclose(fp);
}
}
#endif

View file

@ -1,4 +1,5 @@
#include "globals.h"
#ifndef DEFCON_OUTPUT_
#define DEFCON_OUTPUT_
int print_output() {
@ -8,7 +9,8 @@ int print_output() {
last_known[0] = (char)ch;
last_known[1] = '\0';
fclose(fp);
fprintf(stdout, "%c", last_known);
fprintf(stdout, "%s----------------------------------------------------------------------%s\n", COLOR_GREEN, COLOR_RESET);
fprintf(stdout, "%sdefcon-chan at your service! v2.1%s\n", COLOR_MAGENTA, COLOR_RESET);
if (strcmp(last_known, "5") == 0) {
fprintf(stdout, "the current DEFCON level is: %s%s%s - FADE OUT%s%s\n", COLOR_BLUE, COLOR_BLINK, last_known, COLOR_RESET, COLOR_RESET);
@ -32,3 +34,5 @@ int print_output() {
}
fprintf(stdout, "%s----------------------------------------------------------------------%s\n", COLOR_GREEN, COLOR_RESET);
}
#endif