diff --git a/main.c b/main.c index 6b7ad26..8e73220 100644 --- a/main.c +++ b/main.c @@ -13,6 +13,7 @@ author: hornetmaidan #include #include #include +#include #include "src/globals.h" #include "src/cache.h" #include "src/network.h" diff --git a/src/cache.h b/src/cache.h index 5f8794b..ebaf40a 100644 --- a/src/cache.h +++ b/src/cache.h @@ -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); } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/globals.h b/src/globals.h index 033270e..d787190 100644 --- a/src/globals.h +++ b/src/globals.h @@ -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" \ No newline at end of file +#define COLOR_BLINK "\033[5m" + +#endif \ No newline at end of file diff --git a/src/network.h b/src/network.h index c9fdd46..205290f 100644 --- a/src/network.h +++ b/src/network.h @@ -1,5 +1,5 @@ -#include -#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); -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/output.h b/src/output.h index ec9adee..9811bde 100644 --- a/src/output.h +++ b/src/output.h @@ -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