]> Kevux Git Server - fll/commitdiff
Update: Have the program print version use first last bit argument.
authorKevin Day <kevin@kevux.org>
Fri, 27 Jan 2023 05:40:43 +0000 (23:40 -0600)
committerKevin Day <kevin@kevux.org>
Fri, 27 Jan 2023 05:40:43 +0000 (23:40 -0600)
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.

19 files changed:
level_2/fll_program/c/program/print.c
level_2/fll_program/c/program/print.h
level_3/byte_dump/c/byte_dump.c
level_3/control/c/control.c
level_3/controller/c/controller.c
level_3/fake/c/main/fake.c
level_3/firewall/c/firewall.c
level_3/fss_basic_list_read/c/fss_basic_list_read.c
level_3/fss_basic_read/c/fss_basic_read.c
level_3/fss_embedded_list_read/c/fss_embedded_list_read.c
level_3/fss_extended_list_read/c/fss_extended_list_read.c
level_3/fss_extended_read/c/fss_extended_read.c
level_3/fss_identify/c/fss_identify.c
level_3/fss_payload_read/c/fss_payload_read.c
level_3/fss_write/c/main/fss_write.c
level_3/iki_read/c/main/iki_read.c
level_3/iki_write/c/main/iki_write.c
level_3/status_code/c/main/status_code.c
level_3/utf8/c/main/utf8.c

index dd2892f1785402d6b44204be51a06610f07c2f26..945a2edb81844a7c78ed8f7d287c5a0d9d12c4b3 100644 (file)
@@ -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_
index 10605555639250235870beca967b971f2131626b..011bc5f97b06a56a8e4a094bee1c781afc302490 100644 (file)
@@ -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
index e7b63fc52b78b190dce952844657f99e9a0ff8e6..9ab996d82d8f75c8baa853179e1169fa6721e2b3 100644 (file)
@@ -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;
     }
index 1ad7632ed1172e8c25dae0a8e1ccd83fb65cdb99..f413bb47f6eace582eaef8be4190d5a0b91ffb0c 100644 (file)
@@ -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;
     }
index 1bf10a2464022e1ffa86a1e0325ba7ded1026ede..c6b7a14c75887ec8aa6fa518ccabf4327e0d6ef7 100644 (file)
@@ -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;
     }
index 657e30b6fcaa556cf40c2eaef5035e7b47480da6..bd2172e2fd5c70888556f5940fe478d3896e06ed 100644 (file)
@@ -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;
     }
index a22727d50774804d512c10037cd1b719d65d92aa..a48c5a7d0d599a105001f7171dcb06eb3b5c9169 100644 (file)
@@ -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;
     }
index d2a3908faf1677140847efaf0f806709a70d85bd..d93a73c9817a898b298c54311dc84af6bfd641e6 100644 (file)
@@ -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;
     }
index f516c08932aa663107a45c7061b1c09bc5ec3621..1fb9145afda6d84ced3654de6cfd0ce9d7f321c4 100644 (file)
@@ -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;
     }
index ede790fa3a32c73f4634903c78f9d3ce89a785c8..cc4486e744f6fb2246fab6748892ed52e86392e3 100644 (file)
@@ -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;
     }
index 944c56aee9cc7536466e148574583787d3380913..294dd568685b9ae1768b9c8905909818bd5b29ea 100644 (file)
@@ -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;
     }
index 8b0076488287ef71061b25bef66c1bee9c29a5b9..36fbda7a39cd7f21fc68b512aef04f84cacc75e4 100644 (file)
@@ -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;
     }
index 307b1f63d3e80f2416d034ca797f5c339d2935c4..4436d397718bc5a8e0c9c3646ad92b4645784fdc 100644 (file)
@@ -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;
     }
index 56e5f9823abd740e4bbf6ace44a97a07598c710c..334220e92e43c1ab52446c35b189ff8400473504 100644 (file)
@@ -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;
     }
index ea8288ee0ddd67eb21880d71615fc564e32cb805..48917a366e0f3a1f6c832ec1eedeb7089d7e1c6e 100644 (file)
@@ -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;
     }
index c141a77602abf1e32d94ef36917987ec219b51f0..771f8643b36dc1a2cb559c756d9340c8ce06c557 100644 (file)
@@ -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;
     }
index b1686baeef2cb8a528858baa2cfbc420ec8f66a9..bc4c8c4e3bc7c7f54187b0dd097c18877e642e7d 100644 (file)
@@ -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;
     }
index a1ef2e8ea22fef2fd1fb28081704e83c38851d1f..2520a464cd1f4516973b588728921bde9e880b20 100644 (file)
@@ -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;
     }
index 136d97afdd2893b98314ca29e68a5a8402a3f3b7..3d9f64c5e6932f86b75fe0252bd462eb7903bec2 100644 (file)
@@ -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;
     }