From 3efadf1b06e6f97e627e4a8b9a5850fc5a05f233 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 26 Jan 2023 23:40:43 -0600 Subject: [PATCH] Update: Have the program print version use first last bit argument. I like this idea that I implemented for fll_program_print_copyright(). The version now prints a new line before and after like everything else now. The first and last can be disabled using the appropriate parameters. --- level_2/fll_program/c/program/print.c | 14 +++++++++++++- level_2/fll_program/c/program/print.h | 8 ++++++-- level_3/byte_dump/c/byte_dump.c | 2 +- level_3/control/c/control.c | 2 +- level_3/controller/c/controller.c | 6 +----- level_3/fake/c/main/fake.c | 2 +- level_3/firewall/c/firewall.c | 2 +- level_3/fss_basic_list_read/c/fss_basic_list_read.c | 2 +- level_3/fss_basic_read/c/fss_basic_read.c | 2 +- level_3/fss_embedded_list_read/c/fss_embedded_list_read.c | 2 +- level_3/fss_extended_list_read/c/fss_extended_list_read.c | 2 +- level_3/fss_extended_read/c/fss_extended_read.c | 2 +- level_3/fss_identify/c/fss_identify.c | 2 +- level_3/fss_payload_read/c/fss_payload_read.c | 2 +- level_3/fss_write/c/main/fss_write.c | 2 +- level_3/iki_read/c/main/iki_read.c | 2 +- level_3/iki_write/c/main/iki_write.c | 2 +- level_3/status_code/c/main/status_code.c | 2 +- level_3/utf8/c/main/utf8.c | 2 +- 19 files changed, 36 insertions(+), 24 deletions(-) diff --git a/level_2/fll_program/c/program/print.c b/level_2/fll_program/c/program/print.c index dd2892f..945a2ed 100644 --- a/level_2/fll_program/c/program/print.c +++ b/level_2/fll_program/c/program/print.c @@ -519,11 +519,23 @@ extern "C" { #endif // _di_fll_program_print_signal_received_ #ifndef _di_fll_program_print_version_ - f_status_t fll_program_print_version(const fl_print_t print, const f_string_static_t version) { + f_status_t fll_program_print_version(const fl_print_t print, const uint8_t first_last, const f_string_static_t version) { + + f_file_stream_lock(print.to); + + if (first_last & 0x1) { + f_print_dynamic_raw(f_string_eol_s, print.to); + } f_print_dynamic(version, print.to); f_print_dynamic_raw(f_string_eol_s, print.to); + if (first_last & 0x2) { + f_print_dynamic_raw(f_string_eol_s, print.to); + } + + f_file_stream_unlock(print.to); + return F_none; } #endif // _di_fll_program_print_version_ diff --git a/level_2/fll_program/c/program/print.h b/level_2/fll_program/c/program/print.h index 1060555..011bc5f 100644 --- a/level_2/fll_program/c/program/print.h +++ b/level_2/fll_program/c/program/print.h @@ -22,7 +22,7 @@ extern "C" { * @param print * The output structure to print to. * The print.verbosity is used to determine how much detail is printed (except for when _di_detailed_copyright_ is set). - * @param uint8_t + * @param first_last * Bitwise variable representing whether or not to print the first and last new line. * Set bit 0x1 to printing first line. * Set bit 0x2 to printing last line. @@ -832,6 +832,10 @@ extern "C" { * The output structure to print to. * This uses but does not lock or unlock file stream. * This requires print.set to be non-NULL. + * @param first_last + * Bitwise variable representing whether or not to print the first and last new line. + * Set bit 0x1 to printing first line. + * Set bit 0x2 to printing last line. * @param version * The version number of the program. * @@ -842,7 +846,7 @@ extern "C" { * @see fl_print_format() */ #ifndef _di_fll_program_print_version_ - extern f_status_t fll_program_print_version(const fl_print_t print, const f_string_static_t version); + extern f_status_t fll_program_print_version(const fl_print_t print, const uint8_t first_last, const f_string_static_t version); #endif // _di_fll_program_print_version_ #ifdef __cplusplus diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index e7b63fc..9ab996d 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -149,7 +149,7 @@ extern "C" { } if (main->parameters.array[byte_dump_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, byte_dump_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), byte_dump_program_version_s); return F_none; } diff --git a/level_3/control/c/control.c b/level_3/control/c/control.c index 1ad7632..f413bb4 100644 --- a/level_3/control/c/control.c +++ b/level_3/control/c/control.c @@ -66,7 +66,7 @@ extern "C" { } if (main->parameters.array[control_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, control_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), control_program_version_s); return F_none; } diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index 1bf10a2..c6b7a14 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -71,11 +71,7 @@ extern "C" { } if (main->parameters.array[controller_parameter_version_e].result & f_console_result_found_e) { - controller_lock_print(main->output.to, 0); - - fll_program_print_version(main->message, controller_program_version_s); - - controller_unlock_print_flush(main->output.to, 0); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), controller_program_version_s); return F_none; } diff --git a/level_3/fake/c/main/fake.c b/level_3/fake/c/main/fake.c index 657e30b..bd2172e 100644 --- a/level_3/fake/c/main/fake.c +++ b/level_3/fake/c/main/fake.c @@ -33,7 +33,7 @@ extern "C" { } if (setting->flag & fake_main_flag_version_e) { - fll_program_print_version(main->message, fake_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fake_program_version_s); return; } diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index a22727d..a48c5a7 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -73,7 +73,7 @@ extern "C" { } if (main->parameters.array[firewall_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, firewall_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), firewall_program_version_s); return F_none; } diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index d2a3908..d93a73c 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -66,7 +66,7 @@ extern "C" { } if (main->parameters.array[fss_basic_list_read_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, fss_basic_list_read_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_basic_list_read_program_version_s); return F_none; } diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index f516c08..1fb9145 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -66,7 +66,7 @@ extern "C" { } if (main->parameters.array[fss_basic_read_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, fss_basic_read_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_basic_read_program_version_s); return F_none; } diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c index ede790f..cc4486e 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c @@ -66,7 +66,7 @@ extern "C" { } if (main->parameters.array[fss_embedded_list_read_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, fss_embedded_list_read_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_embedded_list_read_program_version_s); return F_none; } diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index 944c56a..294dd56 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -66,7 +66,7 @@ extern "C" { } if (main->parameters.array[fss_extended_list_read_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, fss_extended_list_read_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_extended_list_read_program_version_s); return status; } diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index 8b00764..36fbda7 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -66,7 +66,7 @@ extern "C" { } if (main->parameters.array[fss_extended_read_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, fss_extended_read_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_extended_read_program_version_s); return status; } diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index 307b1f6..4436d39 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -65,7 +65,7 @@ extern "C" { } if (main->parameters.array[fss_identify_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, fss_identify_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_identify_program_version_s); return F_none; } diff --git a/level_3/fss_payload_read/c/fss_payload_read.c b/level_3/fss_payload_read/c/fss_payload_read.c index 56e5f98..334220e 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.c +++ b/level_3/fss_payload_read/c/fss_payload_read.c @@ -66,7 +66,7 @@ extern "C" { } if (main->parameters.array[fss_payload_read_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, fss_payload_read_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_payload_read_program_version_s); return status; } diff --git a/level_3/fss_write/c/main/fss_write.c b/level_3/fss_write/c/main/fss_write.c index ea8288e..48917a3 100644 --- a/level_3/fss_write/c/main/fss_write.c +++ b/level_3/fss_write/c/main/fss_write.c @@ -26,7 +26,7 @@ extern "C" { } if (setting->flag & fss_write_flag_version_e) { - fll_program_print_version(main->message, fss_write_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_write_program_version_s); return; } diff --git a/level_3/iki_read/c/main/iki_read.c b/level_3/iki_read/c/main/iki_read.c index c141a77..771f864 100644 --- a/level_3/iki_read/c/main/iki_read.c +++ b/level_3/iki_read/c/main/iki_read.c @@ -26,7 +26,7 @@ extern "C" { } if (setting->flag & iki_read_main_flag_version_e) { - fll_program_print_version(main->message, iki_read_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), iki_read_program_version_s); return; } diff --git a/level_3/iki_write/c/main/iki_write.c b/level_3/iki_write/c/main/iki_write.c index b1686ba..bc4c8c4 100644 --- a/level_3/iki_write/c/main/iki_write.c +++ b/level_3/iki_write/c/main/iki_write.c @@ -26,7 +26,7 @@ extern "C" { } if (setting->flag & iki_write_main_flag_version_e) { - fll_program_print_version(main->message, iki_write_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), iki_write_program_version_s); return; } diff --git a/level_3/status_code/c/main/status_code.c b/level_3/status_code/c/main/status_code.c index a1ef2e8..2520a46 100644 --- a/level_3/status_code/c/main/status_code.c +++ b/level_3/status_code/c/main/status_code.c @@ -40,7 +40,7 @@ extern "C" { } if (setting->flag & status_code_main_flag_version_e) { - fll_program_print_version(main->message, status_code_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), status_code_program_version_s); return; } diff --git a/level_3/utf8/c/main/utf8.c b/level_3/utf8/c/main/utf8.c index 136d97a..3d9f64c 100644 --- a/level_3/utf8/c/main/utf8.c +++ b/level_3/utf8/c/main/utf8.c @@ -28,7 +28,7 @@ extern "C" { } if (setting->flag & utf8_main_flag_version_e) { - fll_program_print_version(main->message, utf8_program_version_s); + fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), utf8_program_version_s); return; } -- 1.8.3.1