From 7c86692363ac6bb45204b3f1d14950cd218dbd69 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Fri, 6 May 2022 17:48:28 +0200 Subject: [PATCH] added inputFlags as checkVersion parameter --- include/misc.h | 4 +++- src/lib/misc.c | 13 ++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/misc.h b/include/misc.h index 038f621..acc29bb 100644 --- a/include/misc.h +++ b/include/misc.h @@ -1,7 +1,9 @@ #ifndef WHY2_MISC_H #define WHY2_MISC_H -void checkVersion(); //THIS FUNCTION CHECKS IF LATEST VERSION OF WHY2 IS USED +#include + +void checkVersion(inputFlags flags); //THIS FUNCTION CHECKS IF LATEST VERSION OF WHY2 IS USED void generateTextKeyChain(char key[], int *textKeyChain, int textKeyChainSize); //GENERATES ARRAY FOR ENCRYPTION/DECRYPTION int countIntLength(int number); //RETURNS LENGTH OF number diff --git a/src/lib/misc.c b/src/lib/misc.c index 3e1a051..96daf88 100644 --- a/src/lib/misc.c +++ b/src/lib/misc.c @@ -8,10 +8,9 @@ #include -void -checkVersion() +void checkVersion(inputFlags flags) { - if (getSkipCheck()) return; + if (flags.skipCheck) return; //FILE-CHECK VARIABLES int notFoundBuffer = 0; @@ -43,11 +42,11 @@ checkVersion() if (notFoundBuffer == NOT_FOUND_TRIES) { - fprintf(stderr, "%s'%s' not found!\n", CLEAR_SCREEN, VERSIONS_NAME); + if (!flags.noOutput) fprintf(stderr, "%s'%s' not found!\n", CLEAR_SCREEN, VERSIONS_NAME); exit(DOWNLOAD_FAILED); } - printf("%s'%s' not found (%dx)! Trying again in a second.\n", CLEAR_SCREEN, VERSIONS_NAME, notFoundBuffer); + if (!flags.noOutput) printf("%s'%s' not found (%dx)! Trying again in a second.\n", CLEAR_SCREEN, VERSIONS_NAME, notFoundBuffer); sleep(1); } @@ -67,7 +66,7 @@ checkVersion() //CHECK FOR TEXT IN buffer if (strcmp(buffer, "") == 0) { - fprintf(stderr, "You probably aren't connected to internet! This release could be unsafe!\n\n"); + if (!flags.noOutput) fprintf(stderr, "You probably aren't connected to internet! This release could be unsafe!\n\n"); //WAIT FOR 5 SECONDS sleep(5); @@ -82,7 +81,7 @@ checkVersion() if (strcmp(VERSION, json_object_get_string(active)) != 0) { - fprintf(stderr, "Your version isn't latest! This release could be unsafe! (%s/%s)\n\n", VERSION, json_object_get_string(active)); + if (!flags.noOutput) fprintf(stderr, "Your version isn't latest! This release could be unsafe! (%s/%s)\n\n", VERSION, json_object_get_string(active)); //WAIT FOR 5 SECONDS sleep(5);