diff --git a/include/misc.h b/include/misc.h index 89236c1..4d51811 100644 --- a/include/misc.h +++ b/include/misc.h @@ -30,7 +30,6 @@ extern "C" { void why2_generate_text_key_chain(char *key, int *text_key_chain, int text_key_chain_size); //GENERATES ARRAY FOR ENCRYPTION/DECRYPTION char *why2_generate_key(int key_length); //GENERATE ENCRYPTION KEY void why2_deallocate_output(why2_output_flags flags); //DEALLOCATES flags -char *why2_get_version(void); //GET VERSION FILE OF WHY2 enum WHY2_EXIT_CODES why2_check_version(void); //THIS FUNCTION CHECKS IF LATEST WHY2_VERSION OF WHY2 IS USED enum WHY2_EXIT_CODES why2_check_key(char *key); //CHECKS IF KEY IS VALID enum WHY2_EXIT_CODES why2_check_text(char *text); //CHECKS IF TEXT IS VALID diff --git a/src/core/lib/utils/misc.c b/src/core/lib/utils/misc.c index d0313e6..3ce8873 100644 --- a/src/core/lib/utils/misc.c +++ b/src/core/lib/utils/misc.c @@ -52,31 +52,6 @@ int removeDirectory(char *path) return nftw(path, unlink_cb, 64, FTW_DEPTH | FTW_PHYS); } -char *why2_get_version(void) -{ - //COUNT LENGTH OF buffer AND STORE IT IN bufferSize - FILE *file_buffer = why2_fopen(WHY2_VERSIONS_NAME, "r"); - fseek(file_buffer, 0, SEEK_END); - long buffer_size = ftell(file_buffer); - rewind(file_buffer); //REWIND file_buffer (NO SHIT) - - //SET LENGTH OF buffer - char *buffer = why2_calloc(buffer_size + 1, sizeof(char)); - - //LOAD jsonFile - if (fread(buffer, buffer_size, 1, file_buffer) != 1) - { - if (!why2_get_flags().no_output) fprintf(stderr, "Reading file failed!\n"); - - // BELOW CODE IS COMMENTED OUT, BECAUSE IT IS PROBABLY UNNECESSARY - // why2_clean_memory("core_version_check"); - // return WHY2_DOWNLOAD_FAILED; - } - - buffer[buffer_size] = '\0'; - return buffer; -} - enum WHY2_EXIT_CODES why2_check_version(void) { if (why2_get_flags().no_check) return WHY2_SUCCESS; @@ -119,10 +94,32 @@ enum WHY2_EXIT_CODES why2_check_version(void) } //JSON VARIABLES - char *buffer = why2_get_version(); + char *buffer; + long buffer_size; struct json_object *parsed_json; struct json_object *active; + //COUNT LENGTH OF buffer AND STORE IT IN bufferSize + file_buffer = why2_fopen(WHY2_VERSIONS_NAME, "r"); + fseek(file_buffer, 0, SEEK_END); + buffer_size = ftell(file_buffer); + rewind(file_buffer); //REWIND file_buffer (NO SHIT) + + //SET LENGTH OF buffer + buffer = why2_calloc(buffer_size + 1, sizeof(char)); + + //LOAD jsonFile + if (fread(buffer, buffer_size, 1, file_buffer) != 1) + { + if (!why2_get_flags().no_output) fprintf(stderr, "Reading file failed!\n"); + + // BELOW CODE IS COMMENTED OUT, BECAUSE IT IS PROBABLY UNNECESSARY + // why2_clean_memory("core_version_check"); + // return WHY2_DOWNLOAD_FAILED; + } + + buffer[buffer_size] = '\0'; + //CHECK FOR TEXT IN buffer if (strcmp(buffer, "") == 0) {