]> Kevux Git Server - fll/commitdiff
Cleanup: Utilize f_console_parameter_ids to simplify parameters for fll_program_proce...
authorKevin Day <thekevinday@gmail.com>
Sun, 8 Sep 2019 22:44:10 +0000 (17:44 -0500)
committerKevin Day <thekevinday@gmail.com>
Sun, 8 Sep 2019 22:44:10 +0000 (17:44 -0500)
Althought not ideal, the ids must be in an explicit order of no_color, light, and dark.
This has been added to the functional documentation.

13 files changed:
level_2/fll_program/c/program.c
level_2/fll_program/c/program.h
level_3/bit_dump/c/bit_dump.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_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/init/c/init.c
level_3/status_code/c/status_code.c

index 175af26590212b70bcfcc7c67e45a650ba90dd95..ceca97b3957d66e198b79c4725c145ac7048c413 100644 (file)
@@ -79,23 +79,18 @@ extern "C" {
 #endif // _di_fll_program_print_version_
 
 #ifndef _di_fll_program_process_parameters_
-  f_return_status fll_program_process_parameters(const f_console_arguments arguments, f_console_parameters parameters, const f_array_length parameter_no_color, const f_array_length parameter_light, const f_array_length parameter_dark, f_string_lengths *remaining, fl_color_context *context) {
+  f_return_status fll_program_process_parameters(const f_console_arguments arguments, f_console_parameters parameters, const f_console_parameter_ids choices, f_string_lengths *remaining, fl_color_context *context) {
     f_status status = f_none;
     f_status allocation_status = f_none;
 
     status = fl_console_parameter_process(arguments, parameters, remaining);
 
-    f_console_parameter_ids choices = f_console_parameter_ids_initialize;
-    f_console_parameter_id decision = parameter_dark;
-    f_console_parameter_id ids[3] = { parameter_no_color, parameter_light, parameter_dark};
-
-    choices.id = ids;
-    choices.used = 3;
+    f_console_parameter_id decision = choices.id[2];
 
     fl_console_parameter_prioritize(parameters, choices, &decision);
 
     // load colors unless told not to.
-    if (decision != parameter_no_color) {
+    if (decision != choices.id[0]) {
       fl_macro_color_context_new(allocation_status, (*context));
 
       if (f_status_is_error(allocation_status)) {
@@ -103,7 +98,7 @@ extern "C" {
         return allocation_status;
       }
 
-      fl_color_load_context(context, decision == parameter_light);
+      fl_color_load_context(context, decision == choices.id[1]);
     }
 
     if (f_status_is_error(status)) {
index 923aa7cc35446b5ec270a3d35490d2b5a2f18b0a..da45dd1f250a92dfbbac73d88f56e78fbf598abf 100644 (file)
@@ -124,12 +124,9 @@ extern "C" {
  *   The parameters passed to the process.
  * @param parameters
  *   The console parameters to look for.
- * @param parameter_no_color
- *   The parameter in the parameters array representing the no-color option.
- * @param parameter_light
- *   The parameter in the parameters array representing the light-color option.
- * @param parameter_dark
- *   The parameter in the parameters array representing the dark-color option.
+ * @param choices
+ *   A set of the color options: no-color option, light-color option, dark-color option.
+ *   This must have its used size set to 3 and the ids are expected to be in this order: no_color, light, and dark.
  * @param remaining
  *   A list of remaining parameters not associated with anything.
  * @param context
@@ -142,7 +139,7 @@ extern "C" {
  *   f_reallocation_error (with error bit) on memory reallocation error.
  */
 #ifndef _di_fll_program_process_parameters_
-  extern f_return_status fll_program_process_parameters(const f_console_arguments arguments, f_console_parameters parameters, const f_array_length parameter_no_color, const f_array_length parameter_light, const f_array_length parameter_dark, f_string_lengths *remaining, fl_color_context *context);
+  extern f_return_status fll_program_process_parameters(const f_console_arguments arguments, f_console_parameters parameters, const f_console_parameter_ids choices, f_string_lengths *remaining, fl_color_context *context);
 #endif // _di_fll_program_process_parameters_
 
 #ifdef __cplusplus
index c3362ae36545d51f1a8d873b7769fd4d0d311661..5cedaa9c24e69bd59f2be269eaab1e328c4436de 100644 (file)
@@ -44,7 +44,10 @@ extern "C" {
 
     {
       f_console_parameters parameters = { data->parameters, bit_dump_total_parameters };
-      status = fll_program_process_parameters(arguments, parameters, bit_dump_parameter_no_color, bit_dump_parameter_light, bit_dump_parameter_dark, &data->remaining, &data->context);
+      f_console_parameter_id ids[3] = { bit_dump_parameter_no_color, bit_dump_parameter_light, bit_dump_parameter_dark };
+      f_console_parameter_ids choices = { ids, 3 };
+
+      status = fll_program_process_parameters(arguments, parameters, choices, &data->remaining, &data->context);
     }
 
     if (f_status_is_error(status)) {
index 7d9fa5bb4f09595adbc525a38bb1080b03d9fdfd..4c4dc652e4d985b12c34f7a377eb107c63ad65b5 100644 (file)
@@ -60,7 +60,10 @@ extern "C" {
 
     {
       f_console_parameters parameters = { data->parameters, firewall_total_parameters };
-      status = fll_program_process_parameters(arguments, parameters, firewall_parameter_no_color, firewall_parameter_light, firewall_parameter_dark, &data->remaining, &data->context);
+      f_console_parameter_id ids[3] = { firewall_parameter_no_color, firewall_parameter_light, firewall_parameter_dark };
+      f_console_parameter_ids choices = { ids, 3 };
+
+      status = fll_program_process_parameters(arguments, parameters, choices, &data->remaining, &data->context);
     }
 
     if (f_status_is_error(status)) {
index 26e75f32295375c258aaf783cc8167cc09c43a7b..5e44f2322cb6b264ffd5f19191c8d1fcfefc09e8 100644 (file)
@@ -37,7 +37,10 @@ extern "C" {
 
     {
       f_console_parameters parameters = { data->parameters, fss_basic_list_read_total_parameters };
-      status = fll_program_process_parameters(arguments, parameters, fss_basic_list_read_parameter_no_color, fss_basic_list_read_parameter_light, fss_basic_list_read_parameter_dark, &data->remaining, &data->context);
+      f_console_parameter_id ids[3] = { fss_basic_list_read_parameter_no_color, fss_basic_list_read_parameter_light, fss_basic_list_read_parameter_dark };
+      f_console_parameter_ids choices = { ids, 3 };
+
+      status = fll_program_process_parameters(arguments, parameters, choices, &data->remaining, &data->context);
     }
 
     if (f_status_is_error(status)) {
index 4cca4dc4b52a8a44ab35297ed1e3a4bbe0064a9e..99e790dfd854a41b69bb22bb6ca64ce7f59b3375 100644 (file)
@@ -32,7 +32,10 @@ extern "C" {
 
     {
       f_console_parameters parameters = { data->parameters, fss_basic_list_write_total_parameters };
-      status = fll_program_process_parameters(arguments, parameters, fss_basic_list_write_parameter_no_color, fss_basic_list_write_parameter_light, fss_basic_list_write_parameter_dark, &data->remaining, &data->context);
+      f_console_parameter_id ids[3] = { fss_basic_list_write_parameter_no_color, fss_basic_list_write_parameter_light, fss_basic_list_write_parameter_dark };
+      f_console_parameter_ids choices = { ids, 3 };
+
+      status = fll_program_process_parameters(arguments, parameters, choices, &data->remaining, &data->context);
     }
 
     if (f_status_is_error(status)) {
index 611467a5dabc971fd60e8ff921980cbdbc99ba1e..fe7b1f7a7a8c08d95be45573c5bbc3197135f116 100644 (file)
@@ -35,7 +35,10 @@ extern "C" {
 
     {
       f_console_parameters parameters = { data->parameters, fss_basic_read_total_parameters };
-      status = fll_program_process_parameters(arguments, parameters, fss_basic_read_parameter_no_color, fss_basic_read_parameter_light, fss_basic_read_parameter_dark, &data->remaining, &data->context);
+      f_console_parameter_id ids[3] = { fss_basic_read_parameter_no_color, fss_basic_read_parameter_light, fss_basic_read_parameter_dark };
+      f_console_parameter_ids choices = { ids, 3 };
+
+      status = fll_program_process_parameters(arguments, parameters, choices, &data->remaining, &data->context);
     }
 
     if (f_status_is_error(status)) {
index 3c28a6d9c2e346ddb509089cb01c03318248286f..20d368f9e1e7f7bb24ac30221296c6972572ff53 100644 (file)
@@ -32,7 +32,10 @@ extern "C" {
 
     {
       f_console_parameters parameters = { data->parameters, fss_basic_write_total_parameters };
-       status = fll_program_process_parameters(arguments, parameters, fss_basic_write_parameter_no_color, fss_basic_write_parameter_light, fss_basic_write_parameter_dark, &data->remaining, &data->context);
+      f_console_parameter_id ids[3] = { fss_basic_write_parameter_no_color, fss_basic_write_parameter_light, fss_basic_write_parameter_dark };
+      f_console_parameter_ids choices = { ids, 3 };
+
+       status = fll_program_process_parameters(arguments, parameters, choices, &data->remaining, &data->context);
     }
 
     if (f_status_is_error(status)) {
index 6ce66f297088bcab0a604a3180bdb879b3aded10..87aeeb6fd9d29bcd7e9802aaf012683853eca777 100644 (file)
@@ -36,7 +36,10 @@ extern "C" {
 
     {
       f_console_parameters parameters = { data->parameters, fss_extended_read_total_parameters };
-      status = fll_program_process_parameters(arguments, parameters, fss_extended_read_parameter_no_color, fss_extended_read_parameter_light, fss_extended_read_parameter_dark, &data->remaining, &data->context);
+      f_console_parameter_id ids[3] = { fss_extended_read_parameter_no_color, fss_extended_read_parameter_light, fss_extended_read_parameter_dark };
+      f_console_parameter_ids choices = { ids, 3 };
+
+      status = fll_program_process_parameters(arguments, parameters, choices, &data->remaining, &data->context);
     }
 
     if (f_status_is_error(status)) {
index fcf36ed1c53eeda12a69ddecb4e753487745d27b..b3439824141c55930befb7289d7f93ef5f42a2df 100644 (file)
@@ -33,7 +33,10 @@ extern "C" {
 
     {
       f_console_parameters parameters = { data->parameters, fss_extended_write_total_parameters };
-      status = fll_program_process_parameters(arguments, parameters, fss_extended_write_parameter_no_color, fss_extended_write_parameter_light, fss_extended_write_parameter_dark, &data->remaining, &data->context);
+      f_console_parameter_id ids[3] = { fss_extended_write_parameter_no_color, fss_extended_write_parameter_light, fss_extended_write_parameter_dark };
+      f_console_parameter_ids choices = { ids, 3 };
+
+      status = fll_program_process_parameters(arguments, parameters, choices, &data->remaining, &data->context);
     }
 
     if (f_status_is_error(status)) {
index 796e04cdca4c8e4de6f95d92bd5f0144fd87f841..43e7490f95bcc1e3145fa61097e8d6076d438c5f 100644 (file)
@@ -33,7 +33,10 @@ extern "C" {
 
     {
       f_console_parameters parameters = { data->parameters, fss_status_code_total_parameters };
-      status = fll_program_process_parameters(arguments, parameters, fss_status_code_parameter_no_color, fss_status_code_parameter_light, fss_status_code_parameter_dark, &data->remaining, &data->context);
+      f_console_parameter_id ids[3] = { fss_status_code_parameter_no_color, fss_status_code_parameter_light, fss_status_code_parameter_dark };
+      f_console_parameter_ids choices = { ids, 3 };
+
+      status = fll_program_process_parameters(arguments, parameters, choices, &data->remaining, &data->context);
     }
 
     if (f_status_is_error(status)) {
index b84189367066c1901018a6c0f0bfcf272f3a0e45..b161905a15da30d5b38303324e55d0f9c721a6fd 100644 (file)
@@ -54,7 +54,10 @@ extern "C" {
 
     {
       f_console_parameters parameters = { data->parameters, init_total_parameters };
-      status = fll_program_process_parameters(arguments, parameters, init_parameter_no_color, init_parameter_light, init_parameter_dark, &data->remaining, &data->context);
+      f_console_parameter_id ids[3] = { init_parameter_no_color, init_parameter_light, init_parameter_dark };
+      f_console_parameter_ids choices = { ids, 3 };
+
+      status = fll_program_process_parameters(arguments, parameters, choices, &data->remaining, &data->context);
     }
 
     if (f_status_is_error(status)) {
index 634cba032da0a7951e0134f3bdeb7b69075bcf7e..8e8fc701e7eb027b01562fec39cd3cc218222b5e 100644 (file)
@@ -33,7 +33,10 @@ extern "C" {
 
     {
       f_console_parameters parameters = { data->parameters, status_code_total_parameters };
-      status = fll_program_process_parameters(arguments, parameters, status_code_parameter_no_color, status_code_parameter_light, status_code_parameter_dark, &data->remaining, &data->context);
+      f_console_parameter_id ids[3] = { status_code_parameter_no_color, status_code_parameter_light, status_code_parameter_dark };
+      f_console_parameter_ids choices = { ids, 3 };
+
+      status = fll_program_process_parameters(arguments, parameters, choices, &data->remaining, &data->context);
     }
 
     if (f_status_is_error(status)) {