From 5fcddd0aaf75edd33361622eabec17b2392ce8b6 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Sun, 7 Jul 2024 20:56:36 +0300 Subject: [PATCH] main.c: show custom seed Print configuration in parts in order to do that --- include/common.h | 29 ++++++++++++++++------------- src/main.c | 23 ++++++++++++++++------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/include/common.h b/include/common.h index 9ab61a0..11e8f4e 100644 --- a/include/common.h +++ b/include/common.h @@ -71,19 +71,6 @@ enum configurations { return EXIT_FAILURE; \ } while (0) -/* macros: lambdas */ -#define STRINGIZE(x) #x -#define INT2STR(x) STRINGIZE(x) -#define YES_NO(x) ((x) ? "yes" : "no") -#define READ_CONFIG(x) (config & (x)) -#define SET_CONFIG(x) \ - config |= (x) -#define CLEAR_CONFIG(x) \ - config &= ~(x) -#define LOOP_ACTION_CONFIG(f, x) \ - f(x); \ - continue - /* macros: definitions */ #ifndef SIZE_T_C # if defined(UINT64_MAX) && SIZE_MAX == UINT64_MAX @@ -99,4 +86,20 @@ enum configurations { # define SIZE_MAX (~SIZE_T_C(0)) #endif +#define STR_YN_YES "yes" +#define STR_YN_NO "no" + +/* macros: lambdas */ +#define STRINGIZE(x) #x +#define INT2STR(x) STRINGIZE(x) +#define YES_NO(x) ((x) ? STR_YN_YES : STR_YN_NO) +#define READ_CONFIG(x) (config & (x)) +#define SET_CONFIG(x) \ + config |= (x) +#define CLEAR_CONFIG(x) \ + config &= ~(x) +#define LOOP_ACTION_CONFIG(f, x) \ + f(x); \ + continue + #endif /* _COMMON_H */ diff --git a/src/main.c b/src/main.c index 2b59871..d02ae0c 100644 --- a/src/main.c +++ b/src/main.c @@ -287,18 +287,27 @@ int main(int argc, char** argv) { // FIXME: interprets *.txt files as binary file_type = determine_file_type(file, file_path); + // print configuration: only damaging file contents, preserving line + // endings, operating on printable ASCII characters exclusively printf("Configuration:\n" "> Only damaging file contents (PNG, BMP, WAV): %s\n" "> Preserving line endings: %s\n" - "> Operating on printable ASCII characters exclusively: %s\n" - "> Custom seed: %s\n" - "> File type: %s\n" - "\n", + "> Operating on printable ASCII characters exclusively: %s\n", YES_NO(READ_CONFIG(C_CONTENTS)), YES_NO(READ_CONFIG(C_LINE_ENDINGS)), - YES_NO(READ_CONFIG(C_PRINTABLE)), - YES_NO(READ_CONFIG(C_CUSTOM_SEED)), - file_type_to_string(file_type)); + YES_NO(READ_CONFIG(C_PRINTABLE))); + + // print configuration: custom seed + printf("> Custom seed: "); + if (READ_CONFIG(C_CUSTOM_SEED)) { + printf("%" PRIu32 "\n", PRNG_seed_value); + } else { + puts(STR_YN_NO); + } + + // print configuration: file type + printf("> File type: %s\n" + "\n", file_type_to_string(file_type)); printf("Parameters:\n" "> Probability: %" PRIu8 "\n"