]> Kevux Git Server - fll/commitdiff
Feature: Provide fll_program_parameter_process_empty().
authorKevin Day <thekevinday@gmail.com>
Sat, 1 May 2021 01:03:09 +0000 (20:03 -0500)
committerKevin Day <thekevinday@gmail.com>
Sat, 1 May 2021 01:03:09 +0000 (20:03 -0500)
This should further simplify the standard color processing code for when color codes are replaced with empty strings.

21 files changed:
level_2/fll_program/c/program.c
level_2/fll_program/c/program.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/fake.c
level_3/firewall/c/firewall.c
level_3/fss_basic_list_read/c/fss_basic_list_read.c
level_3/fss_basic_list_write/c/fss_basic_list_write.c
level_3/fss_basic_read/c/fss_basic_read.c
level_3/fss_basic_write/c/fss_basic_write.c
level_3/fss_embedded_list_read/c/fss_embedded_list_read.c
level_3/fss_embedded_list_write/c/fss_embedded_list_write.c
level_3/fss_extended_list_read/c/fss_extended_list_read.c
level_3/fss_extended_list_write/c/fss_extended_list_write.c
level_3/fss_extended_read/c/fss_extended_read.c
level_3/fss_extended_write/c/fss_extended_write.c
level_3/fss_status_code/c/fss_status_code.c
level_3/iki_read/c/iki_read.c
level_3/iki_write/c/iki_write.c
level_3/status_code/c/status_code.c

index e7e102ea66bb1108a76fc509825ce6a3d29aced7..2b488b832151f129646a4aba62f2f43fe238b533 100644 (file)
@@ -99,6 +99,7 @@ extern "C" {
 
 #ifndef _di_fll_program_parameter_process_
   f_status_t fll_program_parameter_process(const f_console_arguments_t arguments, f_console_parameters_t parameters, const f_console_parameter_ids_t choices, const bool right, f_array_lengths_t *remaining, f_color_context_t *context) {
+
     f_status_t status = F_none;
 
     status = f_console_parameter_process(arguments, parameters, remaining);
@@ -132,6 +133,26 @@ extern "C" {
   }
 #endif // _di_fll_program_parameter_process_
 
+#ifndef _di_fll_program_parameter_process_empty_
+  void fll_program_parameter_process_empty(f_color_context_t *context, f_color_set_t *sets[]) {
+
+    context->set.warning = f_color_set_empty_s;
+    context->set.error = f_color_set_empty_s;
+    context->set.title = f_color_set_empty_s;
+    context->set.notable = f_color_set_empty_s;
+    context->set.important = f_color_set_empty_s;
+    context->set.standout = f_color_set_empty_s;
+    context->set.normal = f_color_set_empty_s;
+    context->set.normal_reset = f_color_set_empty_s;
+
+    if (sets) {
+      for (f_array_length_t i = 0; sets[i]; ++i) {
+        *sets[i] = f_color_set_empty_s;
+      }
+    }
+  }
+#endif // _di_fll_program_parameter_process_empty_
+
 #ifndef _di_fll_program_parameter_additional_append_
   f_status_t fll_program_parameter_additional_append(const f_string_t *argv, const f_array_lengths_t values, f_string_dynamics_t *destination) {
     #ifndef _di_level_2_parameter_checking_
index 14b0a279ef9e893de0c9eda8ff9f1da7f6b4ae23..c43da39b8757c798a84a027a4ca7e9afaee5737b 100644 (file)
@@ -207,6 +207,21 @@ extern "C" {
 #endif // _di_fll_program_parameter_process_
 
 /**
+ * Set the provided context to empty along with all additional color sets.
+ *
+ * This will allow for safe usage of the color context and color sets to be safely processed when colors are disabled.
+ *
+ * @param context
+ *   The primary color context to assign.
+ * @param sets
+ *   (optional) A NULL terminated array representing additional sets to assign as empty.
+ *   Set to NULL to not use.
+ */
+#ifndef _di_fll_program_parameter_process_empty_
+  extern void fll_program_parameter_process_empty(f_color_context_t *context, f_color_set_t *sets[]);
+#endif // _di_fll_program_parameter_process_empty_
+
+/**
  * Allocate new strings from all of the provided locations.
  *
  * These new strings are appended onto the destination.
index cc618d3dfd3d6f500e1a139de0763c3285f0fe7f..47e829399cbce56b96860becfbcae68351a246e1 100644 (file)
@@ -94,17 +94,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 0d1d11a6bf7f802e29d70c260fb14df20693a7ae..7c4ab1be2d9ca3c7a5a5721c64a0679cf2f3fe5d 100644 (file)
@@ -47,20 +47,9 @@ extern "C" {
           data->warning.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
-
-          data->warning.context = f_color_set_empty_s;
-          data->warning.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, &data->warning.context, &data->warning.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 8b5932800ce72ca67371f2296cab021e51bf3014..56970da01f0af305252eb6773e601c330e049914 100644 (file)
@@ -69,20 +69,9 @@ extern "C" {
           data->warning.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
-
-          data->warning.context = f_color_set_empty_s;
-          data->warning.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, &data->warning.context, &data->warning.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 66ccaab9ce4047cb387133d211de232ca95c6554..a92e16a423b675932942c892b3a1697141c4aac6 100644 (file)
@@ -117,17 +117,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index b7390b50bf5b1363a710596944860006700eee6a..d704f15f9d82d919bba240ece6ce6f94f566aa14 100644 (file)
@@ -73,17 +73,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 9322ddb704cf742b6048ab2e78fc3921ed272f79..2bcd2df5c441c1173b35bcdd3b894d0f55ca80be 100644 (file)
@@ -176,17 +176,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index cd960205451144ccd83235239c63fc9fedc53f78..af0ee24e93976f9fc30d082f94906d31a3d095fd 100644 (file)
@@ -103,17 +103,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 3dfebc370164e0db490a793bf805c87797edbde3..3c5b107c4dc8d26225109be1e0610c673bf38408 100644 (file)
@@ -176,17 +176,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 476d7319eb4a444a9b6e2c96cebfb0b9517685c2..41222117d720fdbaf3bcb7aa98eee8bc8fcca954 100644 (file)
@@ -101,17 +101,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 40956f20f247a9717eb4d6ac53926cec1899fed3..03c21520416f7d35a37ed6577d43dba018a22c7e 100644 (file)
@@ -176,17 +176,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 61c7a0708a20721d71590f2de1ef5d70d43b8662..0ae10457d76c9ccc4a113270c614fe397cc95b9a 100644 (file)
@@ -109,17 +109,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 25a5b26a453032d3ea0d9f697de34dc091cd24ad..8cf31368985b1f195fbeb3a4e04eeba3ab67061d 100644 (file)
@@ -176,17 +176,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index d7f2f808e54fe881c79d7d9d91be3594e81e1ae6..e5bdd09f8a34fd3846953d16364bfa62d0062093 100644 (file)
@@ -109,17 +109,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 0f6d9fa2ca2260482da4f656978e5552afd9fddf..761ae1b342ec80342de971d9c7c8da4805cce936 100644 (file)
@@ -176,17 +176,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index e8555a9023b262aab6117e8be45c2868dd10df49..9fa7856a92bc16e71bd1a6505e5156df97c4d794 100644 (file)
@@ -101,17 +101,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index e5138ecbea56b4d0483224974e08243bc07bee6d..62e956fd895ca86ec45a84d7cbc2031f0579f8ee 100644 (file)
@@ -51,17 +51,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 895f872a0ad1c789dbd6f40b16363184888e3e8e..d2d92f4ebfde2ad936cc56d1ec8cad85969503cc 100644 (file)
@@ -106,17 +106,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 94a128ae8055f4687f2df37f3cb2f3d51bad19fe..a3535025779546336aabfff5d8efcc9148ee36f8 100644 (file)
@@ -69,17 +69,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {
index 59daaea74ec7d02c6f55f2eddcbcb243976032d9..7f641ea0611510ac72e626a571c9e10b3b302bb6 100644 (file)
@@ -51,17 +51,9 @@ extern "C" {
           data->error.notable = data->context.set.notable;
         }
         else {
-          data->context.set.warning = f_color_set_empty_s;
-          data->context.set.error = f_color_set_empty_s;
-          data->context.set.title = f_color_set_empty_s;
-          data->context.set.notable = f_color_set_empty_s;
-          data->context.set.important = f_color_set_empty_s;
-          data->context.set.standout = f_color_set_empty_s;
-          data->context.set.normal = f_color_set_empty_s;
-          data->context.set.normal_reset = f_color_set_empty_s;
-
-          data->error.context = f_color_set_empty_s;
-          data->error.notable = f_color_set_empty_s;
+          f_color_set_t *sets[] = { &data->error.context, &data->error.notable, 0 };
+
+          fll_program_parameter_process_empty(&data->context, sets);
         }
 
         if (F_status_is_error(status)) {