]> Kevux Git Server - fll/commitdiff
Cleanup: replace argc and argv usage with a single structure of argc and argv (f_cons...
authorKevin Day <thekevinday@gmail.com>
Sun, 8 Sep 2019 21:46:27 +0000 (16:46 -0500)
committerKevin Day <thekevinday@gmail.com>
Sun, 8 Sep 2019 21:49:02 +0000 (16:49 -0500)
Simplify the parameters being passed to functions by providing a helper structure called f_console_arguments to handle the argc and argv standard arguments.
Due to being standard arguments, I am leaving the names as 'argc' and 'argv' despite it being a violation of the naming policy of this project.
('argc' should be something like 'used', and 'argv' should be 'arguments'.)

The firewall had a naming conflict, so rename the usage of "arguments" in firewall into "parameters".

38 files changed:
level_0/f_console/c/console.h
level_1/fl_console/c/console.c
level_1/fl_console/c/console.h
level_2/fll_program/c/program.c
level_2/fll_program/c/program.h
level_3/bit_dump/c/bit_dump.c
level_3/bit_dump/c/bit_dump.h
level_3/bit_dump/c/main.c
level_3/firewall/c/firewall.c
level_3/firewall/c/firewall.h
level_3/firewall/c/main.c
level_3/fss_basic_list_read/c/fss_basic_list_read.c
level_3/fss_basic_list_read/c/fss_basic_list_read.h
level_3/fss_basic_list_read/c/main.c
level_3/fss_basic_list_write/c/fss_basic_list_write.c
level_3/fss_basic_list_write/c/fss_basic_list_write.h
level_3/fss_basic_list_write/c/main.c
level_3/fss_basic_read/c/fss_basic_read.c
level_3/fss_basic_read/c/fss_basic_read.h
level_3/fss_basic_read/c/main.c
level_3/fss_basic_write/c/fss_basic_write.c
level_3/fss_basic_write/c/fss_basic_write.h
level_3/fss_basic_write/c/main.c
level_3/fss_extended_read/c/fss_extended_read.c
level_3/fss_extended_read/c/fss_extended_read.h
level_3/fss_extended_read/c/main.c
level_3/fss_extended_write/c/fss_extended_write.c
level_3/fss_extended_write/c/fss_extended_write.h
level_3/fss_extended_write/c/main.c
level_3/fss_status_code/c/fss_status_code.c
level_3/fss_status_code/c/fss_status_code.h
level_3/fss_status_code/c/main.c
level_3/init/c/init.c
level_3/init/c/init.h
level_3/init/c/main.c
level_3/status_code/c/main.c
level_3/status_code/c/status_code.c
level_3/status_code/c/status_code.h

index 10931ad9a898721b8b3200b798f181fa096f3c0e..60409c23eafaf735fecbe44065e8b631a1998902 100644 (file)
@@ -179,6 +179,20 @@ extern "C" {
 #endif // _di_f_console_parameter_id_
 
 /**
+ * Provide a helper structure for referencing the argc and argv standard main arguments.
+ *
+ * This is intended to only store the argc and argv and should not be treated as dynamic.
+ *
+ * No structure initializer is provided due to the use of constant properties.
+ */
+#ifndef _di_f_console_arguments_
+  typedef struct {
+    const int  argc;
+    const f_string *argv;
+  } f_console_arguments;
+#endif // _di_f_console_arguments_
+
+/**
  * Determine the type code the given input parameter represents.
  *
  * @param input
index da63b503a9fecf9eaa2fcf98d5fcc6f8ff78d7fc..df0419b108d321941d1f488f639bb4446a56f047 100644 (file)
@@ -5,7 +5,7 @@ extern "C" {
 #endif
 
 #ifndef _di_fl_console_parameter_process_
-  f_return_status fl_console_parameter_process(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length parameters_total, f_string_lengths *remaining) {
+  f_return_status fl_console_parameter_process(const f_console_arguments arguments, f_console_parameter parameters[], const f_array_length parameters_total, f_string_lengths *remaining) {
     #ifndef _di_level_1_parameter_checking_
       if (remaining == 0) return f_status_set_error(f_invalid_parameter);
     #endif // _di_level_1_parameter_checking_
@@ -27,10 +27,10 @@ extern "C" {
     f_string_lengths needs_additional = f_string_lengths_initialize;
 
     // loop through and read all parameters
-    while (location < argc) {
-      f_console_identify(argv[location], &result);
+    while (location < arguments.argc) {
+      f_console_identify(arguments.argv[location], &result);
 
-      string_length = strnlen(argv[location], f_console_max_size);
+      string_length = strnlen(arguments.argv[location], f_console_max_size);
 
       // process the current parameter
       if (result == f_console_short_enable || result == f_console_short_disable) {
@@ -100,7 +100,7 @@ extern "C" {
                 continue;
               }
 
-              if (strncmp(&argv[location][sub_location], parameters[parameter_counter].symbol_short, increment_by + 1) != 0) {
+              if (strncmp(&arguments.argv[location][sub_location], parameters[parameter_counter].symbol_short, increment_by + 1) != 0) {
                 continue;
               }
             }
@@ -109,7 +109,7 @@ extern "C" {
                 continue;
               }
 
-              if (strncmp(&argv[location][sub_location], parameters[parameter_counter].symbol_long, increment_by + 1) != 0) {
+              if (strncmp(&arguments.argv[location][sub_location], parameters[parameter_counter].symbol_long, increment_by + 1) != 0) {
                 continue;
               }
             }
@@ -162,7 +162,7 @@ extern "C" {
             continue;
           }
 
-          if (strncmp(argv[location], parameters[parameter_counter].symbol_other, string_length + 1) != 0) {
+          if (strncmp(arguments.argv[location], parameters[parameter_counter].symbol_other, string_length + 1) != 0) {
             continue;
           }
 
index 58b0f373b72fcb73757f32b4cada3b57d292dfd9..223d67b1f7f4fbb3cabe9a6b51a5420c3709160d 100644 (file)
@@ -48,9 +48,7 @@ extern "C" {
  *
  * The UTF-8 BOM is not allowed in the parameters.
  *
- * @param argc
- *   The number of parameters passed to the process.
- * @param argv
+ * @param arguments
  *   The parameters passed to the process.
  * @param parameters
  *   The console parameters to look for.
@@ -66,7 +64,7 @@ extern "C" {
  *   f_reallocation_error (with error bit) on memory reallocation error.
  */
 #ifndef _di_fl_console_parameter_process_
-  extern f_return_status fl_console_parameter_process(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length parameters_total, f_string_lengths *remaining);
+  extern f_return_status fl_console_parameter_process(const f_console_arguments arguments, f_console_parameter parameters[], const f_array_length parameters_total, f_string_lengths *remaining);
 #endif // _di_fl_console_parameter_process_
 
 /**
index 92b358821d5325c6a650c122b28125b1cd8d424f..184ca4bc02731712c5af193f9620161656497137 100644 (file)
@@ -79,11 +79,11 @@ extern "C" {
 #endif // _di_fll_program_print_version_
 
 #ifndef _di_fll_program_process_parameters_
-  f_return_status fll_program_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length parameters_total, 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_parameter parameters[], const f_array_length parameters_total, 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_status status = f_none;
     f_status allocation_status = f_none;
 
-    status = fl_console_parameter_process(argc, argv, parameters, parameters_total, remaining);
+    status = fl_console_parameter_process(arguments, parameters, parameters_total, remaining);
 
     f_console_parameter_ids choices = f_console_parameter_ids_initialize;
     f_console_parameter_id decision = parameter_dark;
index 80c9dbf8d80e9d644a676a69e6234924c64c1ea6..2a5b86518e3acf6c348a4703c7a3befd08ff022c 100644 (file)
@@ -120,9 +120,7 @@ extern "C" {
 /**
  * Perform basic parameter loading, including initialization of color context and printing errors.
  *
- * @param argc
- *   The number of parameters passed to the process.
- * @param argv
+ * @param arguments
  *   The parameters passed to the process.
  * @param parameters
  *   The console parameters to look for.
@@ -146,7 +144,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_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length parameters_total, 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_parameter parameters[], const f_array_length parameters_total, 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);
 #endif // _di_fll_program_process_parameters_
 
 #ifdef __cplusplus
index 20ebbc45da5d77c5a21505b8632178aebec2f5ca..b4a9a39dd04be17a777359d70d07e1b79e343947 100644 (file)
@@ -39,8 +39,8 @@ extern "C" {
 #endif // _di_bit_dump_print_help_
 
 #ifndef _di_bit_dump_main_
-  f_return_status bit_dump_main(const f_array_length argc, const f_string argv[], bit_dump_data *data) {
-    f_status status = fll_program_process_parameters(argc, argv, data->parameters, bit_dump_total_parameters, bit_dump_parameter_no_color, bit_dump_parameter_light, bit_dump_parameter_dark, &data->remaining, &data->context);
+  f_return_status bit_dump_main(const f_console_arguments arguments, bit_dump_data *data) {
+    f_status status = fll_program_process_parameters(arguments, data->parameters, bit_dump_total_parameters, bit_dump_parameter_no_color, bit_dump_parameter_light, bit_dump_parameter_dark, &data->remaining, &data->context);
 
     if (f_status_is_error(status)) {
       bit_dump_delete_data(data);
@@ -136,7 +136,7 @@ extern "C" {
         return f_status_set_error(status);
       }
       else if (data->parameters[bit_dump_parameter_width].result == f_console_result_additional) {
-        uint64_t number = atoll(argv[data->parameters[bit_dump_parameter_width].additional.array[0]]);
+        uint64_t number = atoll(arguments.argv[data->parameters[bit_dump_parameter_width].additional.array[0]]);
         if (number < 1 || number >= 0xfb) {
           fl_color_print_line(f_standard_output, data->context.error, data->context.reset, "Width option can only be a number between 0 and 251.");
 
@@ -154,7 +154,7 @@ extern "C" {
         return f_status_set_error(status);
       }
       else if (data->parameters[bit_dump_parameter_first].result == f_console_result_additional) {
-        uint64_t number = atoll(argv[data->parameters[bit_dump_parameter_first].additional.array[0]]);
+        uint64_t number = atoll(arguments.argv[data->parameters[bit_dump_parameter_first].additional.array[0]]);
         if (number < 1 || number >= 0xffffffffffffffff) {
           fl_color_print_line(f_standard_output, data->context.error, data->context.reset, "First option can only be a number between 0 and 18446744073709551615.");
 
@@ -172,7 +172,7 @@ extern "C" {
         return f_status_set_error(status);
       }
       else if (data->parameters[bit_dump_parameter_last].result == f_console_result_additional) {
-        uint64_t number = atoll(argv[data->parameters[bit_dump_parameter_last].additional.array[0]]);
+        uint64_t number = atoll(arguments.argv[data->parameters[bit_dump_parameter_last].additional.array[0]]);
         if (number < 1 || number >= 0xffffffffffffffff) {
           fl_color_print_line(f_standard_output, data->context.error, data->context.reset, "Last option can only be a number between 0 and 18446744073709551615.");
 
@@ -204,13 +204,13 @@ extern "C" {
           f_status missing_files = f_none;
 
           for (f_array_length counter = 0; counter < data->remaining.used; counter++) {
-            status = f_file_exists(argv[data->remaining.array[counter]]);
+            status = f_file_exists(arguments.argv[data->remaining.array[counter]]);
             if (status == f_false || f_status_is_error(status)) {
               if (missing_files == f_none) {
                 missing_files = status;
               }
 
-              bit_dump_print_file_error(data->context, status, "f_file_exists", argv[data->remaining.array[counter]]);
+              bit_dump_print_file_error(data->context, status, "f_file_exists", arguments.argv[data->remaining.array[counter]]);
             }
           } // for
 
@@ -225,18 +225,18 @@ extern "C" {
         for (f_array_length counter = 0; counter < data->remaining.used; counter++) {
           f_file file = f_file_initialize;
 
-          status = f_file_open(&file, argv[data->remaining.array[counter]]);
+          status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]);
           if (f_status_is_error(status)) {
-            bit_dump_print_file_error(data->context, status, "f_file_open", argv[data->remaining.array[counter]]);
+            bit_dump_print_file_error(data->context, status, "f_file_open", arguments.argv[data->remaining.array[counter]]);
             bit_dump_delete_data(data);
             return status;
           }
 
           printf("%c", f_string_eol);
           fl_color_print(f_standard_output, data->context.title, data->context.reset, "Byte Dump of: ");
-          fl_color_print_line(f_standard_output, data->context.notable, data->context.reset, "%s", argv[data->remaining.array[counter]]);
+          fl_color_print_line(f_standard_output, data->context.notable, data->context.reset, "%s", arguments.argv[data->remaining.array[counter]]);
 
-          status = bit_dump_file(*data, argv[data->remaining.array[counter]], file);
+          status = bit_dump_file(*data, arguments.argv[data->remaining.array[counter]], file);
 
           f_file_close(&file);
 
index cddcf74265f3416803c4fe7f778ec98b87600911..f106b7ea69e3d2e1c2dabb249df3bab0e3f105de 100644 (file)
@@ -217,9 +217,7 @@ extern "C" {
  *
  * Be sure to call bit_dump_delete_data() after executing this.
  *
- * @param argc
- *   The number of parameters passed to the process.
- * @param argv
+ * @param arguments
  *   The parameters passed to the process.
  * @param data
  *   The program data.
@@ -231,7 +229,7 @@ extern "C" {
  * @see bit_dump_delete_data()
  */
 #ifndef _di_bit_dump_main_
-  extern f_return_status bit_dump_main(const f_array_length argc, const f_string argv[], bit_dump_data *data);
+  extern f_return_status bit_dump_main(const f_console_arguments arguments, bit_dump_data *data);
 #endif // _di_bit_dump_main_
 
 /**
index f6c10b279d591c32a8f32a1375632e16d293f12f..b20d152616ee4af1954c6669f07acfc63d12136b 100644 (file)
@@ -1,13 +1,14 @@
 #include <level_3/bit_dump.h>
 
-int main(const f_array_length argc, const f_string argv[]) {
+int main(const int argc, const f_string *argv) {
+  const f_console_arguments arguments = { argc, argv };
   bit_dump_data data = bit_dump_data_initialize;
 
   if (f_pipe_exists()) {
     data.process_pipe = f_true;
   }
 
-  f_status status = bit_dump_main(argc, argv, &data);
+  f_status status = bit_dump_main(arguments, &data);
 
   if (f_status_is_error(status)) {
     return 1;
index 4dd189c8e18df7f4357931b3fb51fa442e1aab6c..39d400731fcd9b729db392aeda4d517e9928f274 100644 (file)
@@ -55,8 +55,8 @@ extern "C" {
 #endif // _di_firewall_print_help_
 
 #ifndef _di_firewall_main_
-  f_return_status firewall_main(const f_s_int argc, const f_string argv[], firewall_data *data) {
-    f_status status = fll_program_process_parameters(argc, argv, data->parameters, firewall_total_parameters, firewall_parameter_no_color, firewall_parameter_light, firewall_parameter_dark, &data->remaining, &data->context);
+  f_return_status firewall_main(const f_console_arguments arguments, firewall_data *data) {
+    f_status status = fll_program_process_parameters(arguments, data->parameters, firewall_total_parameters, firewall_parameter_no_color, firewall_parameter_light, firewall_parameter_dark, &data->remaining, &data->context);
 
     if (f_status_is_error(status)) {
       firewall_delete_data(data);
@@ -141,7 +141,7 @@ extern "C" {
           f_bool show_mangle = f_true;
           f_bool show_ports = f_true;
 
-          f_string_dynamics arguments = f_string_dynamics_initialize;
+          f_string_dynamics parameters = f_string_dynamics_initialize;
           f_s_int results = 0;
 
           if (data->remaining.used > 0) {
@@ -152,10 +152,10 @@ extern "C" {
             f_string_length counter = 0;
 
             for (; counter < data->remaining.used; counter++) {
-              if (strncmp("nat", argv[data->remaining.array[counter]], 4) != 0) {
-                if (strncmp("mangle",  argv[data->remaining.array[counter]], 7) != 0) {
-                  if (strncmp("ports",  argv[data->remaining.array[counter]], 6) != 0) {
-                    fl_color_print_line(f_standard_warning, data->context.warning, data->context.reset, "WARNING: '%s' is not a valid show option", argv[data->remaining.array[counter]]);
+              if (strncmp("nat", arguments.argv[data->remaining.array[counter]], 4) != 0) {
+                if (strncmp("mangle",  arguments.argv[data->remaining.array[counter]], 7) != 0) {
+                  if (strncmp("ports",  arguments.argv[data->remaining.array[counter]], 6) != 0) {
+                    fl_color_print_line(f_standard_warning, data->context.warning, data->context.reset, "WARNING: '%s' is not a valid show option", arguments.argv[data->remaining.array[counter]]);
                   }
                   else {
                     show_ports = f_true;
@@ -171,7 +171,7 @@ extern "C" {
             } // for
           }
 
-          f_macro_string_dynamics_resize(status, arguments, 7);
+          f_macro_string_dynamics_resize(status, parameters, 7);
 
           if (f_status_is_error(status)) {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
@@ -186,23 +186,23 @@ extern "C" {
             fl_color_print_line(f_standard_output, data->context.standout, data->context.reset, " ============================");
             fflush(f_standard_output);
 
-            arguments.used = 6;
+            parameters.used = 6;
 
-            arguments.array[0].string = (f_string) "-x";
-            arguments.array[1].string = (f_string) "-v";
-            arguments.array[2].string = (f_string) "-t";
-            arguments.array[3].string = (f_string) "nat";
-            arguments.array[4].string = (f_string) "--numeric";
-            arguments.array[5].string = (f_string) "--list";
+            parameters.array[0].string = (f_string) "-x";
+            parameters.array[1].string = (f_string) "-v";
+            parameters.array[2].string = (f_string) "-t";
+            parameters.array[3].string = (f_string) "nat";
+            parameters.array[4].string = (f_string) "--numeric";
+            parameters.array[5].string = (f_string) "--list";
 
-            arguments.array[0].used = 2;
-            arguments.array[1].used = 2;
-            arguments.array[2].used = 2;
-            arguments.array[3].used = 3;
-            arguments.array[4].used = 9;
-            arguments.array[5].used = 6;
+            parameters.array[0].used = 2;
+            parameters.array[1].used = 2;
+            parameters.array[2].used = 2;
+            parameters.array[3].used = 3;
+            parameters.array[4].used = 9;
+            parameters.array[5].used = 6;
 
-            status = fll_execute_program((f_string) firewall_tool_iptables, arguments, &results);
+            status = fll_execute_program((f_string) firewall_tool_iptables, parameters, &results);
 
             fprintf(f_standard_output, "\n");
             fflush(f_standard_output);
@@ -214,23 +214,23 @@ extern "C" {
             fl_color_print_line(f_standard_output, data->context.standout, data->context.reset, " ==========================");
             fflush(f_standard_output);
 
-            arguments.used = 6;
+            parameters.used = 6;
 
-            arguments.array[0].string = (f_string) "-x";
-            arguments.array[1].string = (f_string) "-v";
-            arguments.array[2].string = (f_string) "-t";
-            arguments.array[3].string = (f_string) "mangle";
-            arguments.array[4].string = (f_string) "--numeric";
-            arguments.array[5].string = (f_string) "--list";
+            parameters.array[0].string = (f_string) "-x";
+            parameters.array[1].string = (f_string) "-v";
+            parameters.array[2].string = (f_string) "-t";
+            parameters.array[3].string = (f_string) "mangle";
+            parameters.array[4].string = (f_string) "--numeric";
+            parameters.array[5].string = (f_string) "--list";
 
-            arguments.array[0].used = 2;
-            arguments.array[1].used = 2;
-            arguments.array[2].used = 2;
-            arguments.array[3].used = 6;
-            arguments.array[4].used = 9;
-            arguments.array[5].used = 6;
+            parameters.array[0].used = 2;
+            parameters.array[1].used = 2;
+            parameters.array[2].used = 2;
+            parameters.array[3].used = 6;
+            parameters.array[4].used = 9;
+            parameters.array[5].used = 6;
 
-            status = fll_execute_program((f_string) firewall_tool_iptables, arguments, &results);
+            status = fll_execute_program((f_string) firewall_tool_iptables, parameters, &results);
 
             fprintf(f_standard_output, "\n");
             fflush(f_standard_output);
@@ -242,19 +242,19 @@ extern "C" {
             fl_color_print_line(f_standard_output, data->context.standout, data->context.reset, " ==========================");
             fflush(f_standard_output);
 
-            arguments.used = 4;
+            parameters.used = 4;
 
-            arguments.array[0].string = (f_string) "-x";
-            arguments.array[1].string = (f_string) "-v";
-            arguments.array[2].string = (f_string) "--numeric";
-            arguments.array[3].string = (f_string) "--list";
+            parameters.array[0].string = (f_string) "-x";
+            parameters.array[1].string = (f_string) "-v";
+            parameters.array[2].string = (f_string) "--numeric";
+            parameters.array[3].string = (f_string) "--list";
 
-            arguments.array[0].used = 2;
-            arguments.array[1].used = 2;
-            arguments.array[2].used = 9;
-            arguments.array[3].used = 6;
+            parameters.array[0].used = 2;
+            parameters.array[1].used = 2;
+            parameters.array[2].used = 9;
+            parameters.array[3].used = 6;
 
-            status = fll_execute_program((f_string) firewall_tool_iptables, arguments, &results);
+            status = fll_execute_program((f_string) firewall_tool_iptables, parameters, &results);
 
             fprintf(f_standard_output, "\n");
             fflush(f_standard_output);
@@ -275,8 +275,8 @@ extern "C" {
               fl_color_print_code(f_standard_error, data->context.error);
 
               fprintf(f_standard_error, "%s ", firewall_tool_iptables);
-              for (; i < arguments.used; i++) {
-                fprintf(f_standard_error, "%s ", arguments.array[i].string);
+              for (; i < parameters.used; i++) {
+                fprintf(f_standard_error, "%s ", parameters.array[i].string);
               } // for
 
               fl_color_print_code(f_standard_error, data->context.reset);
@@ -286,22 +286,22 @@ extern "C" {
             status = f_status_set_error(status);
           }
 
-          arguments.array[0].string = 0;
-          arguments.array[1].string = 0;
-          arguments.array[2].string = 0;
-          arguments.array[3].string = 0;
-          arguments.array[4].string = 0;
-          arguments.array[5].string = 0;
-          arguments.array[6].string = 0;
-          arguments.array[0].used = 0;
-          arguments.array[1].used = 0;
-          arguments.array[2].used = 0;
-          arguments.array[3].used = 0;
-          arguments.array[4].used = 0;
-          arguments.array[5].used = 0;
-          arguments.array[6].used = 0;
-
-          f_macro_string_dynamics_delete(status, arguments);
+          parameters.array[0].string = 0;
+          parameters.array[1].string = 0;
+          parameters.array[2].string = 0;
+          parameters.array[3].string = 0;
+          parameters.array[4].string = 0;
+          parameters.array[5].string = 0;
+          parameters.array[6].string = 0;
+          parameters.array[0].used = 0;
+          parameters.array[1].used = 0;
+          parameters.array[2].used = 0;
+          parameters.array[3].used = 0;
+          parameters.array[4].used = 0;
+          parameters.array[5].used = 0;
+          parameters.array[6].used = 0;
+
+          f_macro_string_dynamics_delete(status, parameters);
           firewall_delete_local_data(&local);
           firewall_delete_data(data);
           return status;
index dff27085f1073b376ec9b7ab5e10c187152485ca..c3c05250010f384c24055e5037fcaa8e74e25e55 100644 (file)
@@ -293,24 +293,54 @@ extern "C" {
     }
 #endif // _di_firewall_data_
 
+/**
+ * Print help to standard output.
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ */
 #ifndef _di_firewall_print_help_
-  /**
-   * Print help.
-   */
   extern f_return_status firewall_print_help(const firewall_data data);
 #endif // _di_firewall_print_help_
 
+/**
+ * Execute main program.
+ *
+ * Be sure to call firewall_delete_data() after executing this.
+ *
+ * @param arguments
+ *   The parameters passed to the process.
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see firewall_delete_data()
+ */
 #ifndef _di_firewall_main_
-  /**
-   * Main.
-   */
-  extern f_return_status firewall_main(const f_s_int argc, const f_string argv[], firewall_data *data);
+  extern f_return_status firewall_main(const f_console_arguments arguments, firewall_data *data);
 #endif // _di_firewall_main_
 
+/**
+ * Deallocate data.
+ *
+ * Be sure to call this after executing firewall_main().
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see firewall_main()
+ */
 #ifndef _di_firewall_delete_data_
-  /**
-   * Deallocate data.
-   */
   extern f_return_status firewall_delete_data(firewall_data *data);
 #endif // _di_firewall_delete_data_
 
index 72163adc0574104daaeeb1506d9e6f43c9096194..14a81a6861950539739601be3b9a1a5f326f9dc0 100644 (file)
@@ -1,10 +1,11 @@
 #include <level_0/status.h>
 #include <level_3/firewall.h>
 
-int main(const f_s_int argc, const f_string argv[]) {
+int main(const int argc, const f_string *argv) {
+  const f_console_arguments arguments = { argc, argv };
   firewall_data data = firewall_data_initialize;
 
-  if (f_status_is_error(firewall_main(argc, argv, &data))) {
+  if (f_status_is_error(firewall_main(arguments, &data))) {
     return 1;
   }
 
index f8b90d1dd58ae966393498bd40a58bad507274db..f8573dfc68fa68e6b5a77642f4de96513c09128f 100644 (file)
@@ -30,10 +30,10 @@ extern "C" {
 #endif // _di_fss_basic_list_read_print_help_
 
 #ifndef _di_fss_basic_list_read_main_
-  f_return_status fss_basic_list_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data, const f_string filename, const f_string_length target) __attribute__((visibility ("internal")));
+  f_return_status fss_basic_list_read_main_process_file(const f_console_arguments arguments, fss_basic_list_read_data *data, const f_string filename, const f_string_length target) __attribute__((visibility ("internal")));
 
-  f_return_status fss_basic_list_read_main(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data) {
-    f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_basic_list_read_total_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_return_status fss_basic_list_read_main(const f_console_arguments arguments, fss_basic_list_read_data *data) {
+    f_status status = fll_program_process_parameters(arguments, data->parameters, fss_basic_list_read_total_parameters, fss_basic_list_read_parameter_no_color, fss_basic_list_read_parameter_light, fss_basic_list_read_parameter_dark, &data->remaining, &data->context);
 
     if (f_status_is_error(status)) {
       fss_basic_list_read_delete_data(data);
@@ -56,7 +56,7 @@ extern "C" {
       f_string_length original_size = data->file_position.total_elements;
 
       if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
-        target = (f_string_length) atoll(argv[data->parameters[fss_basic_list_read_parameter_count].additional.array[0]]);
+        target = (f_string_length) atoll(arguments.argv[data->parameters[fss_basic_list_read_parameter_count].additional.array[0]]);
       }
 
       if (data->process_pipe) {
@@ -89,7 +89,7 @@ extern "C" {
           return status;
         }
 
-        status = fss_basic_list_read_main_process_file(argc, argv, data, "-", target);
+        status = fss_basic_list_read_main_process_file(arguments, data, "-", target);
 
         if (f_status_is_error(status)) {
           return status;
@@ -104,7 +104,7 @@ extern "C" {
       for (; counter < data->remaining.used; counter++) {
         f_file file = f_file_initialize;
 
-        status = f_file_open(&file, argv[data->remaining.array[counter]]);
+        status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]);
 
         data->file_position.total_elements = original_size;
 
@@ -115,13 +115,13 @@ extern "C" {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
           }
           else if (status == f_file_not_found) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", arguments.argv[data->remaining.array[counter]]);
           }
           else if (status == f_file_open_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", arguments.argv[data->remaining.array[counter]]);
           }
           else if (status == f_file_descriptor_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->remaining.array[counter]]);
           }
           else {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
@@ -156,16 +156,16 @@ extern "C" {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
           }
           else if (status == f_overflow) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", arguments.argv[data->remaining.array[counter]]);
           }
           else if (status == f_file_not_open) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open", arguments.argv[data->remaining.array[counter]]);
           }
           else if (status == f_file_seek_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'", arguments.argv[data->remaining.array[counter]]);
           }
           else if (status == f_file_read_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'", arguments.argv[data->remaining.array[counter]]);
           }
           else if (status == f_allocation_error || status == f_reallocation_error) {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
@@ -178,7 +178,7 @@ extern "C" {
           return f_status_set_error(status);
         }
 
-        status = fss_basic_list_read_main_process_file(argc, argv, data, argv[data->remaining.array[counter]], target);
+        status = fss_basic_list_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[counter]], target);
 
         if (f_status_is_error(status)) {
           return status;
@@ -199,7 +199,7 @@ extern "C" {
     return status;
   }
 
-  f_return_status fss_basic_list_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data, const f_string filename, const f_string_length target) {
+  f_return_status fss_basic_list_read_main_process_file(const f_console_arguments arguments, fss_basic_list_read_data *data, const f_string filename, const f_string_length target) {
     f_status status = f_none;
     f_status status2 = f_none;
 
@@ -280,7 +280,7 @@ extern "C" {
                 if (data->contents.array[current].used > 0) {
                   f_string_length counter = data->contents.array[current].array[0].start;
                   f_string_length position = 0;
-                  f_string_length target = (f_string_length) atoll(argv[data->parameters[fss_basic_list_read_parameter_line].additional.array[0]]);
+                  f_string_length target = (f_string_length) atoll(arguments.argv[data->parameters[fss_basic_list_read_parameter_line].additional.array[0]]);
                   f_string_location range = f_string_location_initialize;
 
                   // use an invalid range to communicate range not found
@@ -356,14 +356,14 @@ extern "C" {
         f_string_length argv_length = 0;
 
         if (data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_additional) {
-          argv_length = strlen(argv[data->parameters[fss_basic_list_read_parameter_name].additional.array[0]]);
+          argv_length = strlen(arguments.argv[data->parameters[fss_basic_list_read_parameter_name].additional.array[0]]);
 
           if (data->parameters[fss_basic_list_read_parameter_object].result == f_console_result_none) {
             for (; current < data->objects.used; current++) {
               name_length = data->objects.array[current].stop - data->objects.array[current].start + 1;
 
               if (name_length == argv_length) {
-                if (fl_string_compare(data->buffer.string + data->objects.array[current].start, argv[data->parameters[fss_basic_list_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
+                if (fl_string_compare(data->buffer.string + data->objects.array[current].start, arguments.argv[data->parameters[fss_basic_list_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
 
                   if (data->parameters[fss_basic_list_read_parameter_size].result == f_console_result_found) {
                     if (data->contents.array[current].used > 0) {
@@ -387,7 +387,7 @@ extern "C" {
                     if (data->contents.array[current].used > 0) {
                       f_string_length counter = data->contents.array[current].array[0].start;
                       f_string_length position = 0;
-                      f_string_length target = (f_string_length) atoll(argv[data->parameters[fss_basic_list_read_parameter_line].additional.array[0]]);
+                      f_string_length target = (f_string_length) atoll(arguments.argv[data->parameters[fss_basic_list_read_parameter_line].additional.array[0]]);
                       f_string_location range = f_string_location_initialize;
 
                       // use an invalid range to communicate range not found
@@ -457,7 +457,7 @@ extern "C" {
                 name_length = data->contents.array[current].array[0].stop - data->contents.array[current].array[0].start + 1;
 
                 if (name_length == argv_length) {
-                  if (fl_string_compare(data->buffer.string + data->contents.array[current].array[0].start, argv[data->parameters[fss_basic_list_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
+                  if (fl_string_compare(data->buffer.string + data->contents.array[current].array[0].start, arguments.argv[data->parameters[fss_basic_list_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
                     if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
                       f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
                       fprintf(f_standard_output, "\n");
index 695bab14995b15721d7e54b471d2515b6a7036a2..00e017876d9cbde6b7e35b852ad6e5d177f6a45a 100644 (file)
@@ -128,24 +128,54 @@ extern "C" {
     }
 #endif // _di_fss_basic_list_read_data_
 
+/**
+ * Print help to standard output.
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ */
 #ifndef _di_fss_basic_list_read_print_help_
-  /**
-   * Print help.
-   */
   extern f_return_status fss_basic_list_read_print_help(const fss_basic_list_read_data data);
 #endif // _di_fss_basic_list_read_print_help_
 
+/**
+ * Execute main program.
+ *
+ * Be sure to call fss_basic_list_read_delete_data() after executing this.
+ *
+ * @param arguments
+ *   The parameters passed to the process.
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_basic_list_read_delete_data()
+ */
 #ifndef _di_fss_basic_list_read_main_
-  /**
-   * Main
-   */
-  extern f_return_status fss_basic_list_read_main(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data);
+  extern f_return_status fss_basic_list_read_main(const f_console_arguments arguments, fss_basic_list_read_data *data);
 #endif // _di_fss_basic_list_read_main_
 
+/**
+ * Deallocate data.
+ *
+ * Be sure to call this after executing fss_basic_list_read_main().
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_basic_list_read_main()
+ */
 #ifndef _di_fss_basic_list_read_delete_data_
-  /**
-   * Deallocate data.
-   */
   extern f_return_status fss_basic_list_read_delete_data(fss_basic_list_read_data *data);
 #endif // _di_fss_basic_list_read_delete_data_
 
index 4daf61c4c87e1d931583e78b2b5d4572a1c4eba9..9d493f523922f77558d92a9863f92e872a9d30d5 100644 (file)
@@ -1,13 +1,14 @@
 #include <level_3/fss_basic_list_read.h>
 
-int main(const f_array_length argc, const f_string argv[]) {
+int main(const int argc, const f_string *argv) {
+  const f_console_arguments arguments = { argc, argv };
   fss_basic_list_read_data data = fss_basic_list_read_data_initialize;
 
   if (f_pipe_exists()) {
     data.process_pipe = f_true;
   }
 
-  if (f_status_is_error(fss_basic_list_read_main(argc, argv, &data))) {
+  if (f_status_is_error(fss_basic_list_read_main(arguments, &data))) {
     return 1;
   }
 
index caa414a01249fa66a913f417445460b7930f8adc..642825371c6341f3ad09e60f66100d40fd2210b8 100644 (file)
@@ -27,8 +27,8 @@ extern "C" {
 #endif // _di_fss_basic_list_write_print_help_
 
 #ifndef _di_fss_basic_list_write_main_
-  f_return_status fss_basic_list_write_main(const f_array_length argc, const f_string argv[], fss_basic_list_write_data *data) {
-    f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_basic_list_write_total_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_return_status fss_basic_list_write_main(const f_console_arguments arguments, fss_basic_list_write_data *data) {
+    f_status status = fll_program_process_parameters(arguments, data->parameters, fss_basic_list_write_total_parameters, fss_basic_list_write_parameter_no_color, fss_basic_list_write_parameter_light, fss_basic_list_write_parameter_dark, &data->remaining, &data->context);
 
     if (f_status_is_error(status)) {
       fss_basic_list_write_delete_data(data);
@@ -108,7 +108,7 @@ extern "C" {
       else if (data->parameters[fss_basic_list_write_parameter_string].result == f_console_result_additional) {
         f_string_dynamic input = f_string_dynamic_initialize;
 
-        input.string = argv[data->parameters[fss_basic_list_write_parameter_string].additional.array[0]];
+        input.string = arguments.argv[data->parameters[fss_basic_list_write_parameter_string].additional.array[0]];
         input.used = strlen(input.string);
 
         location.start = 0;
@@ -136,7 +136,7 @@ extern "C" {
         f_file output = f_file_initialize;
 
         output.mode = f_file_write_append;
-        status = f_file_open(&output, argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
+        status = f_file_open(&output, arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
 
         if (f_status_is_error(status)) {
           status = f_status_set_fine(status);
@@ -147,13 +147,13 @@ extern "C" {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
           }
           else if (status == f_file_not_found) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
           }
           else if (status == f_file_open_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
           }
           else if (status == f_file_descriptor_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
           }
           else {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
@@ -173,7 +173,7 @@ extern "C" {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()");
           }
           else if (status == f_file_write_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
           }
           else {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", f_status_set_error(status));
index 472791b122ca6e12321366d2b1d4c8b5d247d777..aa48b46bb34c9a93cc435d4404d4f8b970b7b9b3 100644 (file)
@@ -104,24 +104,54 @@ extern "C" {
     }
 #endif // _di_fss_basic_list_write_data_
 
+/**
+ * Print help to standard output.
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ */
 #ifndef _di_fss_basic_list_write_print_help_
-  /**
-   * Print help.
-   */
   extern f_return_status fss_basic_list_write_print_help(const fss_basic_list_write_data data);
 #endif // _di_fss_basic_list_write_print_help_
 
+/**
+ * Execute main program.
+ *
+ * Be sure to call fss_basic_list_write_delete_data() after executing this.
+ *
+ * @param arguments
+ *   The parameters passed to the process.
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_basic_list_write_delete_data()
+ */
 #ifndef _di_fss_basic_list_write_main_
-  /**
-   * Main.
-   */
-  extern f_return_status fss_basic_list_write_main(const f_array_length argc, const f_string argv[], fss_basic_list_write_data *data);
+  extern f_return_status fss_basic_list_write_main(const f_console_arguments arguments, fss_basic_list_write_data *data);
 #endif // _di_fss_basic_list_write_main_
 
+/**
+ * Deallocate data.
+ *
+ * Be sure to call this after executing fss_basic_list_write_main().
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_basic_list_write_main()
+ */
 #ifndef _di_fss_basic_list_write_delete_data_
-  /**
-   * Deallocate data.
-   */
   extern f_return_status fss_basic_list_write_delete_data(fss_basic_list_write_data *data);
 #endif // _di_fss_basic_list_write_delete_data_
 
index 4b3052d9993695e30766f09555f1b69bcb3470af..e631ff8a7f5a79dc4baf8321461b800ec5003191 100644 (file)
@@ -1,13 +1,14 @@
 #include <level_3/fss_basic_list_write.h>
 
-int main(const f_array_length argc, const f_string argv[]) {
+int main(const int argc, const f_string *argv) {
+  const f_console_arguments arguments = { argc, argv };
   fss_basic_list_write_data data = fss_basic_list_write_data_initialize;
 
   if (f_pipe_exists()) {
     data.process_pipe = f_true;
   }
 
-  if (f_status_is_error(fss_basic_list_write_main(argc, argv, &data))) {
+  if (f_status_is_error(fss_basic_list_write_main(arguments, &data))) {
     return 1;
   }
 
index df8e010d8f673bf15c43c15950e7797dc5c77d2a..fc73792d55b96e7be12ddaf95a28bd8eb3dc9ebc 100644 (file)
@@ -28,10 +28,10 @@ extern "C" {
 #endif // _di_fss_basic_read_print_help_
 
 #ifndef _di_fss_basic_read_main_
-  f_return_status fss_basic_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_read_data *data, const f_string filename, const f_string_length target) f_gcc_attribute_visibility_internal;
+  f_return_status fss_basic_read_main_process_file(const f_console_arguments arguments, fss_basic_read_data *data, const f_string filename, const f_string_length target) f_gcc_attribute_visibility_internal;
 
-  f_return_status fss_basic_read_main(const f_array_length argc, const f_string argv[], fss_basic_read_data *data) {
-    f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_basic_read_total_parameters, fss_basic_read_parameter_no_color, fss_basic_read_parameter_light, fss_basic_read_parameter_dark, &data->remaining, &data->context);
+  f_return_status fss_basic_read_main(const f_console_arguments arguments, fss_basic_read_data *data) {
+    f_status status = fll_program_process_parameters(arguments, data->parameters, fss_basic_read_total_parameters, fss_basic_read_parameter_no_color, fss_basic_read_parameter_light, fss_basic_read_parameter_dark, &data->remaining, &data->context);
 
     if (f_status_is_error(status)) {
       fss_basic_read_delete_data(data);
@@ -54,7 +54,7 @@ extern "C" {
       f_string_length original_size = data->file_position.total_elements;
 
       if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
-        target = (f_string_length) atoll(argv[data->parameters[fss_basic_read_parameter_count].additional.array[0]]);
+        target = (f_string_length) atoll(arguments.argv[data->parameters[fss_basic_read_parameter_count].additional.array[0]]);
       }
 
       if (data->process_pipe) {
@@ -93,7 +93,7 @@ extern "C" {
           return f_status_set_error(status);
         }
 
-        status = fss_basic_read_main_process_file(argc, argv, data, "-", target);
+        status = fss_basic_read_main_process_file(arguments, data, "-", target);
 
         if (f_status_is_error(status)) {
           return status;
@@ -109,7 +109,7 @@ extern "C" {
         for (; counter < data->remaining.used; counter++) {
           f_file file = f_file_initialize;
 
-          status = f_file_open(&file, argv[data->remaining.array[counter]]);
+          status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]);
 
           data->file_position.total_elements = original_size;
 
@@ -120,13 +120,13 @@ extern "C" {
               fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
             }
             else if (status == f_file_not_found) {
-              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", argv[data->remaining.array[counter]]);
+              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", arguments.argv[data->remaining.array[counter]]);
             }
             else if (status == f_file_open_error) {
-              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", argv[data->remaining.array[counter]]);
+              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", arguments.argv[data->remaining.array[counter]]);
             }
             else if (status == f_file_descriptor_error) {
-              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->remaining.array[counter]]);
+              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->remaining.array[counter]]);
             }
             else {
               fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
@@ -161,16 +161,16 @@ extern "C" {
               fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
             }
             else if (status == f_overflow) {
-              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", argv[data->remaining.array[counter]]);
+              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", arguments.argv[data->remaining.array[counter]]);
             }
             else if (status == f_file_not_open) {
-              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open", argv[data->remaining.array[counter]]);
+              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open", arguments.argv[data->remaining.array[counter]]);
             }
             else if (status == f_file_seek_error) {
-              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'", argv[data->remaining.array[counter]]);
+              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'", arguments.argv[data->remaining.array[counter]]);
             }
             else if (status == f_file_read_error) {
-              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'", argv[data->remaining.array[counter]]);
+              fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'", arguments.argv[data->remaining.array[counter]]);
             }
             else if (status == f_allocation_error || status == f_reallocation_error) {
               fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
@@ -183,7 +183,7 @@ extern "C" {
             return f_status_set_error(status);
           }
 
-          status = fss_basic_read_main_process_file(argc, argv, data, argv[data->remaining.array[counter]], target);
+          status = fss_basic_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[counter]], target);
 
           if (f_status_is_error(status)) {
             return status;
@@ -205,7 +205,7 @@ extern "C" {
     return status;
   }
 
-  f_return_status fss_basic_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_read_data *data, const f_string filename, const f_string_length target) {
+  f_return_status fss_basic_read_main_process_file(const f_console_arguments arguments, fss_basic_read_data *data, const f_string filename, const f_string_length target) {
     f_status status = f_none;
     f_status status2 = f_none;
 
@@ -309,14 +309,14 @@ extern "C" {
         f_string_length argv_length = 0;
 
         if (data->parameters[fss_basic_read_parameter_name].result == f_console_result_additional) {
-          argv_length = strlen(argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]]);
+          argv_length = strlen(arguments.argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]]);
 
           if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_none) {
             for (; current < data->objects.used; current++) {
               name_length = data->objects.array[current].stop - data->objects.array[current].start + 1;
 
               if (name_length == argv_length) {
-                if (fl_string_compare(data->buffer.string + data->objects.array[current].start, argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
+                if (fl_string_compare(data->buffer.string + data->objects.array[current].start, arguments.argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
 
                   if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
                     if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
@@ -358,7 +358,7 @@ extern "C" {
                 name_length = data->contents.array[current].array[0].stop - data->contents.array[current].array[0].start + 1;
 
                 if (name_length == argv_length) {
-                  if (fl_string_compare(data->buffer.string + data->contents.array[current].array[0].start, argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
+                  if (fl_string_compare(data->buffer.string + data->contents.array[current].array[0].start, arguments.argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
                     if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
                       f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
                       fprintf(f_standard_output, "\n");
index e176f1ee87cc21dbf2ebe5030e00f165bffc559d..d17e369404a2c920d744c1ba29b63c718a024c5f 100644 (file)
@@ -120,24 +120,54 @@ extern "C" {
     }
 #endif // _di_fss_basic_read_data_
 
+/**
+ * Print help to standard output.
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ */
 #ifndef _di_fss_basic_read_print_help_
-  /**
-   * Print help.
-   */
   extern f_return_status fss_basic_read_print_help(const fss_basic_read_data data);
 #endif // _di_fss_basic_read_print_help_
 
+/**
+ * Execute main program.
+ *
+ * Be sure to call fss_basic_read_delete_data() after executing this.
+ *
+ * @param arguments
+ *   The parameters passed to the process.
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_basic_read_delete_data()
+ */
 #ifndef _di_fss_basic_read_main_
-  /**
-   * Main.
-   */
-  extern f_return_status fss_basic_read_main(const f_array_length argc, const f_string argv[], fss_basic_read_data *data);
+  extern f_return_status fss_basic_read_main(const f_console_arguments arguments, fss_basic_read_data *data);
 #endif // _di_fss_basic_read_main_
 
+/**
+ * Deallocate data.
+ *
+ * Be sure to call this after executing fss_basic_read_main().
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_basic_read_main()
+ */
 #ifndef _di_fss_basic_read_delete_data_
-  /**
-   * Deallocate data.
-   */
   extern f_return_status fss_basic_read_delete_data(fss_basic_read_data *data);
 #endif // _di_fss_basic_read_delete_data_
 
index 8674a0c091c1080d98147b18a921228271785557..58153736013aada66c3be24e44fda6668595ebe3 100644 (file)
@@ -1,13 +1,14 @@
 #include <level_3/fss_basic_read.h>
 
-int main(const f_array_length argc, const f_string argv[]) {
+int main(const int argc, const f_string *argv) {
+  const f_console_arguments arguments = { argc, argv };
   fss_basic_read_data data = fss_basic_read_data_initialize;
 
   if (f_pipe_exists()) {
     data.process_pipe = f_true;
   }
 
-  if (f_status_is_error(fss_basic_read_main(argc, argv, &data))) {
+  if (f_status_is_error(fss_basic_read_main(arguments, &data))) {
     return 1;
   }
 
index 7b82120f974c101695ab7d850070b5190dd63ab1..966ab7ce276d4d46b2afe3c79de40fd8322b5da4 100644 (file)
@@ -27,8 +27,8 @@ extern "C" {
 #endif // _di_fss_basic_write_print_help_
 
 #ifndef _di_fss_basic_write_main_
-  f_return_status fss_basic_write_main(const f_array_length argc, const f_string argv[], fss_basic_write_data *data) {
-    f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_basic_write_total_parameters, fss_basic_write_parameter_no_color, fss_basic_write_parameter_light, fss_basic_write_parameter_dark, &data->remaining, &data->context);
+  f_return_status fss_basic_write_main(const f_console_arguments arguments, fss_basic_write_data *data) {
+    f_status status = fll_program_process_parameters(arguments, data->parameters, fss_basic_write_total_parameters, fss_basic_write_parameter_no_color, fss_basic_write_parameter_light, fss_basic_write_parameter_dark, &data->remaining, &data->context);
 
     if (f_status_is_error(status)) {
       fss_basic_write_delete_data(data);
@@ -108,7 +108,7 @@ extern "C" {
       else if (data->parameters[fss_basic_write_parameter_string].result == f_console_result_additional) {
         f_string_dynamic input = f_string_dynamic_initialize;
 
-        input.string = argv[data->parameters[fss_basic_write_parameter_string].additional.array[0]];
+        input.string = arguments.argv[data->parameters[fss_basic_write_parameter_string].additional.array[0]];
         input.used = strlen(input.string);
 
         location.start = 0;
@@ -136,7 +136,7 @@ extern "C" {
         f_file output = f_file_initialize;
 
         output.mode = f_file_write_append;
-        status = f_file_open(&output, argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
+        status = f_file_open(&output, arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
 
         if (f_status_is_error(status)) {
           status = f_status_set_fine(status);
@@ -147,13 +147,13 @@ extern "C" {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
           }
           else if (status == f_file_not_found) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
           }
           else if (status == f_file_open_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
           }
           else if (status == f_file_descriptor_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
           }
           else {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
@@ -173,7 +173,7 @@ extern "C" {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()");
           }
           else if (status == f_file_write_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
           }
           else {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", f_status_set_error(status));
index 9a46e68b13b12fc59f50cbbd039028799c27f200..103ec2ff93b1e5791e40c7686fdd48617d504819 100644 (file)
@@ -103,24 +103,54 @@ extern "C" {
     }
 #endif // _di_fss_basic_write_data_
 
+/**
+ * Print help to standard output.
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ */
 #ifndef _di_fss_basic_write_print_help_
-  /**
-   * Print help.
-   */
   extern f_return_status fss_basic_write_print_help(const fss_basic_write_data data);
 #endif // _di_fss_basic_write_print_help_
 
+/**
+ * Execute main program.
+ *
+ * Be sure to call fss_basic_write_delete_data() after executing this.
+ *
+ * @param arguments
+ *   The parameters passed to the process.
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_basic_write_delete_data()
+ */
 #ifndef _di_fss_basic_write_main_
-  /**
-   * Main.
-   */
-  extern f_return_status fss_basic_write_main(const f_array_length argc, const f_string argv[], fss_basic_write_data *data);
+  extern f_return_status fss_basic_write_main(const f_console_arguments arguments, fss_basic_write_data *data);
 #endif // _di_fss_basic_write_main_
 
+/**
+ * Deallocate data.
+ *
+ * Be sure to call this after executing fss_basic_write_main().
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_basic_write_main()
+ */
 #ifndef _di_fss_basic_write_delete_data_
-  /**
-   * Deallocate data.
-   */
   extern f_return_status fss_basic_write_delete_data(fss_basic_write_data *data);
 #endif // _di_fss_basic_write_delete_data_
 
index eeb6d3f3996c5dca2cc5de1205596019595425bf..ed207cb0f75fef93a72acf78f3ec21758d2b1fba 100644 (file)
@@ -1,13 +1,14 @@
 #include <level_3/fss_basic_write.h>
 
-int main(const f_array_length argc, const f_string argv[]) {
+int main(const int argc, const f_string *argv) {
+  const f_console_arguments arguments = { argc, argv };
   fss_basic_write_data data = fss_basic_write_data_initialize;
 
   if (f_pipe_exists()) {
     data.process_pipe = f_true;
   }
 
-  if (f_status_is_error(fss_basic_write_main(argc, argv, &data))) {
+  if (f_status_is_error(fss_basic_write_main(arguments, &data))) {
     return 1;
   }
 
index 31cad9e0c468b6529f00d11d0355fae54708ae74..9e98b042567dd1bae4e073113b8168d2dedd9850 100644 (file)
@@ -29,10 +29,10 @@ extern "C" {
 #endif // _di_fss_extended_read_print_help_
 
 #ifndef _di_fss_extended_read_main_
-  f_return_status fss_extended_read_main_process_file(const f_array_length argc, const f_string argv[], fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) f_gcc_attribute_visibility_internal;
+  f_return_status fss_extended_read_main_process_file(const f_console_arguments arguments, fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) f_gcc_attribute_visibility_internal;
 
-  f_return_status fss_extended_read_main(const f_array_length argc, const f_string argv[], fss_extended_read_data *data) {
-    f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_extended_read_total_parameters, fss_extended_read_parameter_no_color, fss_extended_read_parameter_light, fss_extended_read_parameter_dark, &data->remaining, &data->context);
+  f_return_status fss_extended_read_main(const f_console_arguments arguments, fss_extended_read_data *data) {
+    f_status status = fll_program_process_parameters(arguments, data->parameters, fss_extended_read_total_parameters, fss_extended_read_parameter_no_color, fss_extended_read_parameter_light, fss_extended_read_parameter_dark, &data->remaining, &data->context);
 
     if (f_status_is_error(status)) {
       fss_extended_read_delete_data(data);
@@ -56,11 +56,11 @@ extern "C" {
       f_string_length original_size = data->file_position.total_elements;
 
       if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
-        target = (f_string_length) atoll(argv[data->parameters[fss_extended_read_parameter_count].additional.array[0]]);
+        target = (f_string_length) atoll(arguments.argv[data->parameters[fss_extended_read_parameter_count].additional.array[0]]);
       }
 
       if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) {
-        select = (f_string_length) atoll(argv[data->parameters[fss_extended_read_parameter_select].additional.array[0]]);
+        select = (f_string_length) atoll(arguments.argv[data->parameters[fss_extended_read_parameter_select].additional.array[0]]);
       }
 
       if (data->process_pipe) {
@@ -93,7 +93,7 @@ extern "C" {
           return f_status_set_error(status);
         }
 
-        status = fss_extended_read_main_process_file(argc, argv, data, "-", target, select);
+        status = fss_extended_read_main_process_file(arguments, data, "-", target, select);
 
 
         if (f_status_is_error(status)) {
@@ -109,7 +109,7 @@ extern "C" {
       for (; counter < data->remaining.used; counter++) {
         f_file file = f_file_initialize;
 
-        status = f_file_open(&file, argv[data->remaining.array[counter]]);
+        status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]);
 
         data->file_position.total_elements = original_size;
 
@@ -120,13 +120,13 @@ extern "C" {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
           }
           else if (status == f_file_not_found) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", arguments.argv[data->remaining.array[counter]]);
           }
           else if (status == f_file_open_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", arguments.argv[data->remaining.array[counter]]);
           }
           else if (status == f_file_descriptor_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->remaining.array[counter]]);
           }
           else {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
@@ -161,16 +161,16 @@ extern "C" {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
           }
           else if (status == f_overflow) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", arguments.argv[data->remaining.array[counter]]);
           }
           else if (status == f_file_not_open) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open", arguments.argv[data->remaining.array[counter]]);
           }
           else if (status == f_file_seek_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'", arguments.argv[data->remaining.array[counter]]);
           }
           else if (status == f_file_read_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'", argv[data->remaining.array[counter]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'", arguments.argv[data->remaining.array[counter]]);
           }
           else if (status == f_allocation_error || status == f_reallocation_error) {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
@@ -183,7 +183,7 @@ extern "C" {
           return f_status_set_error(status);
         }
 
-        status = fss_extended_read_main_process_file(argc, argv, data, argv[data->remaining.array[counter]], target, select);
+        status = fss_extended_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[counter]], target, select);
 
         if (f_status_is_error(status)) {
           return status;
@@ -204,7 +204,7 @@ extern "C" {
     return status;
   }
 
-  f_return_status fss_extended_read_main_process_file(const f_array_length argc, const f_string argv[], fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) {
+  f_return_status fss_extended_read_main_process_file(const f_console_arguments arguments, fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) {
     f_status status = f_none;
     f_status status2 = f_none;
 
@@ -307,14 +307,14 @@ extern "C" {
         f_string_length argv_length = 0;
 
         if (data->parameters[fss_extended_read_parameter_name].result == f_console_result_additional) {
-          argv_length = strlen(argv[data->parameters[fss_extended_read_parameter_name].additional.array[0]]);
+          argv_length = strlen(arguments.argv[data->parameters[fss_extended_read_parameter_name].additional.array[0]]);
 
           if (data->parameters[fss_extended_read_parameter_object].result == f_console_result_none) {
             for (; current < data->objects.used; current++) {
               name_length = data->objects.array[current].stop - data->objects.array[current].start + 1;
 
               if (name_length == argv_length) {
-                if (fl_string_compare(data->buffer.string + data->objects.array[current].start, argv[data->parameters[fss_extended_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
+                if (fl_string_compare(data->buffer.string + data->objects.array[current].start, arguments.argv[data->parameters[fss_extended_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
 
                   if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
                     if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
@@ -360,7 +360,7 @@ extern "C" {
                 name_length = data->contents.array[current].array[select].stop - data->contents.array[current].array[select].start + 1;
 
                 if (name_length == argv_length) {
-                  if (fl_string_compare(data->buffer.string + data->contents.array[current].array[select].start, argv[data->parameters[fss_extended_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
+                  if (fl_string_compare(data->buffer.string + data->contents.array[current].array[select].start, arguments.argv[data->parameters[fss_extended_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
                     if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
                       f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
                       fprintf(f_standard_output, "\n");
index 71382773a5657b8da0368f5a2295eb7b21fadcbd..64f6311d221ccb46249803497ed64385df1a378f 100644 (file)
@@ -124,24 +124,54 @@ extern "C" {
     }
 #endif // _di_fss_extended_read_data_
 
+/**
+ * Print help to standard output.
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ */
 #ifndef _di_fss_extended_read_print_help_
-  /**
-   * Print help.
-   */
   extern f_return_status fss_extended_read_print_help(const fss_extended_read_data data);
 #endif // _di_fss_extended_read_print_help_
 
+/**
+ * Execute main program.
+ *
+ * Be sure to call fss_extended_read_delete_data() after executing this.
+ *
+ * @param arguments
+ *   The parameters passed to the process.
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_extended_read_delete_data()
+ */
 #ifndef _di_fss_extended_read_main_
-  /**
-   * Main.
-   */
-  extern f_return_status fss_extended_read_main(const f_array_length argc, const f_string argv[], fss_extended_read_data *data);
+  extern f_return_status fss_extended_read_main(const f_console_arguments arguments, fss_extended_read_data *data);
 #endif // _di_fss_extended_read_main_
 
+/**
+ * Deallocate data.
+ *
+ * Be sure to call this after executing fss_extended_read_main().
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_extended_read_main()
+ */
 #ifndef _di_fss_extended_read_delete_data_
-  /**
-   * Deallocate data.
-   */
   extern f_return_status fss_extended_read_delete_data(fss_extended_read_data *data);
 #endif // _di_fss_extended_read_delete_data_
 
index 52d1bd4541d989adbab1801c4785fa7670296502..9afa9c8d72c0197ef45c2487ed34fa34c26da06f 100644 (file)
@@ -1,13 +1,14 @@
 #include <level_3/fss_extended_read.h>
 
-int main(const f_array_length argc, const f_string argv[]) {
+int main(const int argc, const f_string *argv) {
+  const f_console_arguments arguments = { argc, argv };
   fss_extended_read_data data = fss_extended_read_data_initialize;
 
   if (f_pipe_exists()) {
     data.process_pipe = f_true;
   }
 
-  if (f_status_is_error(fss_extended_read_main(argc, argv, &data))) {
+  if (f_status_is_error(fss_extended_read_main(arguments, &data))) {
     return 1;
   }
 
index 32b6ff191384efa9448ee225c2eef5d6d0850776..226efcb41174ec19ed0ccc613f81252140114d8e 100644 (file)
@@ -28,8 +28,8 @@ extern "C" {
 #endif // _di_fss_extended_write_print_help_
 
 #ifndef _di_fss_extended_write_main_
-  f_return_status fss_extended_write_main(const f_array_length argc, const f_string argv[], fss_extended_write_data *data) {
-    f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_extended_write_total_parameters, fss_extended_write_parameter_no_color, fss_extended_write_parameter_light, fss_extended_write_parameter_dark, &data->remaining, &data->context);
+  f_return_status fss_extended_write_main(const f_console_arguments arguments, fss_extended_write_data *data) {
+    f_status status = fll_program_process_parameters(arguments, data->parameters, fss_extended_write_total_parameters, fss_extended_write_parameter_no_color, fss_extended_write_parameter_light, fss_extended_write_parameter_dark, &data->remaining, &data->context);
 
     if (f_status_is_error(status)) {
       fss_extended_write_delete_data(data);
@@ -45,7 +45,7 @@ extern "C" {
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
         // TODO: there is a way to identify which parameter is incorrect
         //       to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
-        //       nothing can be 0 as that represents the program name, unless argv[] is improperly created
+        //       nothing can be 0 as that represents the program name, unless arguments.argv[] is improperly created
       }
       else if (status == f_allocation_error || status == f_reallocation_error) {
         fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
@@ -146,7 +146,7 @@ extern "C" {
         f_string_dynamic input = f_string_dynamic_initialize;
 
         if (object) {
-          input.string = argv[data->parameters[fss_extended_write_parameter_string].additional.array[0]];
+          input.string = arguments.argv[data->parameters[fss_extended_write_parameter_string].additional.array[0]];
           input.used = strlen(input.string);
 
           location.start = 0;
@@ -162,7 +162,7 @@ extern "C" {
           f_string_length i = 0;
 
           while (i < data->parameters[fss_extended_write_parameter_string].additional.used) {
-            input.string = argv[data->parameters[fss_extended_write_parameter_string].additional.array[i]];
+            input.string = arguments.argv[data->parameters[fss_extended_write_parameter_string].additional.array[i]];
             input.used = strlen(input.string);
 
             location.start = 0;
@@ -198,7 +198,7 @@ extern "C" {
         f_file output = f_file_initialize;
 
         output.mode = f_file_write_append;
-        status = f_file_open(&output, argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
+        status = f_file_open(&output, arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
 
         if (f_status_is_error(status)) {
           status = f_status_set_fine(status);
@@ -209,13 +209,13 @@ extern "C" {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
           }
           else if (status == f_file_not_found) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
           }
           else if (status == f_file_open_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
           }
           else if (status == f_file_descriptor_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
           }
           else {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
@@ -235,7 +235,7 @@ extern "C" {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()");
           }
           else if (status == f_file_write_error) {
-            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
+            fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
           }
           else {
             fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", f_status_set_error(status));
index 2988f7d9afbd3e522ef075cb95773120a2241e46..10f8ac86185fcaa0eea5c90d89e85a222e1d9d68 100644 (file)
@@ -108,24 +108,54 @@ extern "C" {
     }
 #endif // _di_fss_extended_write_data_
 
+/**
+ * Print help to standard output.
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ */
 #ifndef _di_fss_extended_write_print_help_
-  /**
-   * Print help.
-   */
   extern f_return_status fss_extended_write_print_help(const fss_extended_write_data data);
 #endif // _di_fss_extended_write_print_help_
 
+/**
+ * Execute main program.
+ *
+ * Be sure to call fss_extended_write_delete_data() after executing this.
+ *
+ * @param arguments
+ *   The parameters passed to the process.
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_extended_write_delete_data()
+ */
 #ifndef _di_fss_extended_write_main_
-  /**
-   * Main.
-   */
-  extern f_return_status fss_extended_write_main(const f_array_length argc, const f_string argv[], fss_extended_write_data *data);
+  extern f_return_status fss_extended_write_main(const f_console_arguments arguments, fss_extended_write_data *data);
 #endif // _di_fss_extended_write_main_
 
+/**
+ * Deallocate data.
+ *
+ * Be sure to call this after executing fss_extended_write_main().
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_extended_write_main()
+ */
 #ifndef _di_fss_extended_write_delete_data_
-  /**
-   * Deallocate data.
-   */
   extern f_return_status fss_extended_write_delete_data(fss_extended_write_data *data);
 #endif // _di_fss_extended_write_delete_data_
 
index cf812f00638170ed1f1be8bd89d3366f76047476..d9cab5811a4d44d754c110244572b8cd12f5f743 100644 (file)
@@ -1,13 +1,14 @@
 #include <level_3/fss_extended_write.h>
 
-int main(const f_array_length argc, const f_string argv[]) {
+int main(const int argc, const f_string *argv) {
+  const f_console_arguments arguments = { argc, argv };
   fss_extended_write_data data = fss_extended_write_data_initialize;
 
   if (f_pipe_exists()) {
     data.process_pipe = f_true;
   }
 
-  if (f_status_is_error(fss_extended_write_main(argc, argv, &data))) {
+  if (f_status_is_error(fss_extended_write_main(arguments, &data))) {
     return 1;
   }
 
index f4792c2a944848e4752a4df93648b7e5f9c008ef..453ff0611f6a8c5ae4d4e1ef0ddd2c343cd13fa0 100644 (file)
@@ -28,8 +28,8 @@ extern "C" {
 #endif // _di_fss_status_code_print_help_
 
 #ifndef _di_fss_status_code_main_
-  f_return_status fss_status_code_main(const f_array_length argc, const f_string argv[], fss_status_code_data *data) {
-    f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_status_code_total_parameters, fss_status_code_parameter_no_color, fss_status_code_parameter_light, fss_status_code_parameter_dark, &data->remaining, &data->context);
+  f_return_status fss_status_code_main(const f_console_arguments arguments, fss_status_code_data *data) {
+    f_status status = fll_program_process_parameters(arguments, data->parameters, fss_status_code_total_parameters, fss_status_code_parameter_no_color, fss_status_code_parameter_light, fss_status_code_parameter_dark, &data->remaining, &data->context);
 
     if (f_status_is_error(status)) {
       fss_status_code_delete_data(data);
@@ -54,12 +54,12 @@ extern "C" {
 
         for (; counter < data->remaining.used; counter++) {
           // only numbers are valid status codes.
-          if (f_is_digit(argv[data->remaining.array[counter]][0]) == f_false) {
+          if (f_is_digit(arguments.argv[data->remaining.array[counter]][0]) == f_false) {
             status = f_false;
             continue;
           }
 
-          long long number = atoll(argv[data->remaining.array[counter]]);
+          long long number = atoll(arguments.argv[data->remaining.array[counter]]);
           if (number >= 0x10000 || number < 0) {
             status = f_false;
             continue;
@@ -93,12 +93,12 @@ extern "C" {
 
         for (; counter < data->remaining.used; counter++) {
           // only numbers are valid status codes.
-          if (f_is_digit(argv[data->remaining.array[counter]][0]) == f_false) {
+          if (f_is_digit(arguments.argv[data->remaining.array[counter]][0]) == f_false) {
             status = f_false;
             continue;
           }
 
-          long long number = atoll(argv[data->remaining.array[counter]]);
+          long long number = atoll(arguments.argv[data->remaining.array[counter]]);
           if (number >= 0x10000 || number < 0) {
             status = f_false;
             continue;
@@ -132,12 +132,12 @@ extern "C" {
 
         for (; counter < data->remaining.used; counter++) {
           // only numbers are valid status codes.
-          if (f_is_digit(argv[data->remaining.array[counter]][0]) == f_false) {
+          if (f_is_digit(arguments.argv[data->remaining.array[counter]][0]) == f_false) {
             status = f_false;
             continue;
           }
 
-          long long number = atoll(argv[data->remaining.array[counter]]);
+          long long number = atoll(arguments.argv[data->remaining.array[counter]]);
           if (number >= 0x10000 || number < 0) {
             status = f_false;
             continue;
@@ -170,12 +170,12 @@ extern "C" {
 
         for (; counter < data->remaining.used; counter++) {
           // numbers are not valid status code strings.
-          if (f_is_digit(argv[data->remaining.array[counter]][0]) == f_true) {
+          if (f_is_digit(arguments.argv[data->remaining.array[counter]][0]) == f_true) {
             status = f_false;
             continue;
           }
 
-          status2 = fll_status_from_string(argv[data->remaining.array[counter]], &code);
+          status2 = fll_status_from_string(arguments.argv[data->remaining.array[counter]], &code);
 
           if (f_status_is_error(status2)) {
             status = status2;
@@ -206,12 +206,12 @@ extern "C" {
       if (data->remaining.used > 0) {
         for (; counter < data->remaining.used; counter++) {
           // only numbers are valid status code.
-          if (f_is_digit(argv[data->remaining.array[counter]][0]) == f_false) {
+          if (f_is_digit(arguments.argv[data->remaining.array[counter]][0]) == f_false) {
             status = f_false;
             continue;
           }
 
-          long long number = atoll(argv[data->remaining.array[counter]]);
+          long long number = atoll(arguments.argv[data->remaining.array[counter]]);
           if (number >= 0x10000 || number < 0) {
             status = f_false;
             continue;
index 3388f0829a8e6a4d390444aa536535864c056ca8..f53394fa690d8ddc0425cf668e420b07ae15eb39 100644 (file)
@@ -108,24 +108,54 @@ extern "C" {
     }
 #endif // _di_fss_status_code_data_
 
+/**
+ * Print help to standard output.
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ */
 #ifndef _di_fss_status_code_print_help_
-  /**
-   * Print help.
-   */
   extern f_return_status fss_status_code_print_help(const fss_status_code_data data);
 #endif // _di_fss_status_code_print_help_
 
+/**
+ * Execute main program.
+ *
+ * Be sure to call fss_status_code_delete_data() after executing this.
+ *
+ * @param arguments
+ *   The parameters passed to the process.
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_status_code_delete_data()
+ */
 #ifndef _di_fss_status_code_main_
-  /**
-   * Main.
-   */
-  extern f_return_status fss_status_code_main(const f_array_length argc, const f_string argv[], fss_status_code_data *data);
+  extern f_return_status fss_status_code_main(const f_console_arguments arguments, fss_status_code_data *data);
 #endif // _di_fss_status_code_main_
 
+/**
+ * Deallocate data.
+ *
+ * Be sure to call this after executing fss_status_code_main().
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see fss_status_code_main()
+ */
 #ifndef _di_fss_status_code_delete_data_
-  /**
-   * Deallocate data.
-   */
   extern f_return_status fss_status_code_delete_data(fss_status_code_data *data);
 #endif // _di_fss_status_code_delete_data_
 
index 4bc2b82fda00e90dfdc16aed549ba816aead4af7..3bf1ed5fcb1342dc46d4ce7540a3e8036b9378c4 100644 (file)
@@ -1,13 +1,14 @@
 #include <level_3/fss_status_code.h>
 
-int main(const f_array_length argc, const f_string argv[]) {
+int main(const int argc, const f_string *argv) {
+  const f_console_arguments arguments = { argc, argv };
   fss_status_code_data data = fss_status_code_data_initialize;
 
   if (f_pipe_exists()) {
     data.process_pipe = f_true;
   }
 
-  f_status status = fss_status_code_main(argc, argv, &data);
+  f_status status = fss_status_code_main(arguments, &data);
 
   if (f_status_is_error(status) || status == f_false) {
     return 1;
index 34f8461157677532c00d4c1a1b173282b6d06530..46c9aac511d801beacec6316e68c05ef74b9532b 100644 (file)
@@ -43,7 +43,7 @@ extern "C" {
 #endif // _di_init_print_help_
 
 #ifndef _di_init_main_
-  f_return_status init_main(const f_s_int argc, const f_string argv[], init_argument *argument) {
+  f_return_status init_main(const f_console_arguments arguments, init_argument *argument) {
     f_status status  = f_none;
     f_autochar run_level[init_kernel_runlevel_buffer];
 
@@ -52,7 +52,7 @@ extern "C" {
     f_u_short do_socket_file = f_true;
     f_u_short do_socket_port = f_false;
 
-    status = fll_program_process_parameters(argc, argv, data->parameters, init_total_parameters, init_parameter_no_color, init_parameter_light, init_parameter_dark, &data->remaining, &data->context);
+    status = fll_program_process_parameters(arguments, data->parameters, init_total_parameters, init_parameter_no_color, init_parameter_light, init_parameter_dark, &data->remaining, &data->context);
 
     if (f_status_is_error(status)) {
       init_delete_data(data);
@@ -63,11 +63,11 @@ extern "C" {
 
 
     if (argument->parameters[init_parameter_runlevel].result == f_console_result_found) {
-      const f_u_int parameter_length = strlen(argv[argument->parameters[init_parameter_runlevel].additional.array[0]]);
+      const f_u_int parameter_length = strlen(arguments.argv[argument->parameters[init_parameter_runlevel].additional.array[0]]);
 
       // if the run_level value is greater than the static buffer size, ignore the entire string rather than process a cut off value.
       if (parameter_length > 0 && parameter_length < init_kernel_runlevel_buffer) {
-        strncpy(&run_level, argv[argument->parameters[init_parameter_runlevel].additional.array[0]], parameter_length);
+        strncpy(&run_level, arguments.argv[argument->parameters[init_parameter_runlevel].additional.array[0]], parameter_length);
       }
     }
 
index a1365d72b2e139f7da2ce93c74cd41e2d548d42a..4b4236621acfd8bf1f769b06daf73462bdacae24 100644 (file)
@@ -219,12 +219,33 @@ extern "C" {
   extern f_return_status init_print_version(const init_argument data);
 #endif // _di_init_print_version_
 
+/**
+ * Print help to standard output.
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ */
 #ifndef _di_init_print_help_
   extern f_return_status init_print_help(const init_argument data);
 #endif // _di_init_print_help_
 
+/**
+ * Execute main program.
+ *
+ * @param arguments
+ *   The parameters passed to the process.
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ */
 #ifndef _di_init_main_
-  extern f_return_status init_main(const f_s_int argc, const f_string argv[], init_argument *data);
+  extern f_return_status init_main(const f_console_arguments arguments, init_argument *data);
 #endif // _di_init_main_
 
 #ifdef __cplusplus
index 27fe6711f237f93c7c2e8ba0b89ad89c547e794d..709b4246ce2b85412416724f4d36563b40306197 100644 (file)
@@ -1,7 +1,8 @@
 #include <level_3/init.h>
 
-int main(const f_s_int argc, const f_string argv[]) {
+int main(const int argc, const f_string *argv) {
+  const f_console_arguments arguments = { argc, argv };
   init_argument data = init_argument_initialize;
 
-  return init_main(argc, argv, &data);
+  return init_main(arguments, &data);
 }
index 76f3aee60aa302a7d4f02b49f46c5a4a2f90b070..fc6375e8429cbf6c281cb253cc9a26dc3e50ffbd 100644 (file)
@@ -1,13 +1,14 @@
 #include <level_3/status_code.h>
 
-int main(const f_array_length argc, const f_string argv[]) {
+int main(const int argc, const f_string *argv) {
+  const f_console_arguments arguments = { argc, argv };
   status_code_data data = status_code_data_initialize;
 
   if (f_pipe_exists()) {
     data.process_pipe = f_true;
   }
 
-  f_status status = status_code_main(argc, argv, &data);
+  f_status status = status_code_main(arguments, &data);
 
   if (f_status_is_error(status) || status == f_false) {
     return 1;
index 68b1b32fe5248357f08509e7696bd82348f7618e..1dcf67fdd6e3d200491ace970ad9166496d5da72 100644 (file)
@@ -28,8 +28,8 @@ extern "C" {
 #endif // _di_status_code_print_help_
 
 #ifndef _di_status_code_main_
-  f_return_status status_code_main(const f_array_length argc, const f_string argv[], status_code_data *data) {
-    f_status status = fll_program_process_parameters(argc, argv, data->parameters, status_code_total_parameters, status_code_parameter_no_color, status_code_parameter_light, status_code_parameter_dark, &data->remaining, &data->context);
+  f_return_status status_code_main(const f_console_arguments arguments, status_code_data *data) {
+    f_status status = fll_program_process_parameters(arguments, data->parameters, status_code_total_parameters, status_code_parameter_no_color, status_code_parameter_light, status_code_parameter_dark, &data->remaining, &data->context);
 
     if (f_status_is_error(status)) {
       status_code_delete_data(data);
@@ -54,12 +54,12 @@ extern "C" {
 
         for (; counter < data->remaining.used; counter++) {
           // only numbers are valid status codes.
-          if (f_is_digit(argv[data->remaining.array[counter]][0]) == f_false) {
+          if (f_is_digit(arguments.argv[data->remaining.array[counter]][0]) == f_false) {
             status = f_false;
             continue;
           }
 
-          long long number = atoll(argv[data->remaining.array[counter]]);
+          long long number = atoll(arguments.argv[data->remaining.array[counter]]);
           if (number >= 0x10000 || number < 0) {
             status = f_false;
             continue;
@@ -93,12 +93,12 @@ extern "C" {
 
         for (; counter < data->remaining.used; counter++) {
           // only numbers are valid status codes.
-          if (f_is_digit(argv[data->remaining.array[counter]][0]) == f_false) {
+          if (f_is_digit(arguments.argv[data->remaining.array[counter]][0]) == f_false) {
             status = f_false;
             continue;
           }
 
-          long long number = atoll(argv[data->remaining.array[counter]]);
+          long long number = atoll(arguments.argv[data->remaining.array[counter]]);
           if (number >= 0x10000 || number < 0) {
             status = f_false;
             continue;
@@ -132,12 +132,12 @@ extern "C" {
 
         for (; counter < data->remaining.used; counter++) {
           // only numbers are valid status codes.
-          if (f_is_digit(argv[data->remaining.array[counter]][0]) == f_false) {
+          if (f_is_digit(arguments.argv[data->remaining.array[counter]][0]) == f_false) {
             status = f_false;
             continue;
           }
 
-          long long number = atoll(argv[data->remaining.array[counter]]);
+          long long number = atoll(arguments.argv[data->remaining.array[counter]]);
           if (number >= 0x10000 || number < 0) {
             status = f_false;
             continue;
@@ -170,12 +170,12 @@ extern "C" {
 
         for (; counter < data->remaining.used; counter++) {
           // numbers are not valid status code strings.
-          if (f_is_digit(argv[data->remaining.array[counter]][0]) == f_true) {
+          if (f_is_digit(arguments.argv[data->remaining.array[counter]][0]) == f_true) {
             status = f_false;
             continue;
           }
 
-          status2 = fll_status_from_string(argv[data->remaining.array[counter]], &code);
+          status2 = fll_status_from_string(arguments.argv[data->remaining.array[counter]], &code);
           if (f_status_is_error(status2)) {
             status = status2;
             break;
@@ -205,12 +205,12 @@ extern "C" {
       if (data->remaining.used > 0) {
         for (; counter < data->remaining.used; counter++) {
           // only numbers are valid status code.
-          if (f_is_digit(argv[data->remaining.array[counter]][0]) == f_false) {
+          if (f_is_digit(arguments.argv[data->remaining.array[counter]][0]) == f_false) {
             status = f_false;
             continue;
           }
 
-          long long number = atoll(argv[data->remaining.array[counter]]);
+          long long number = atoll(arguments.argv[data->remaining.array[counter]]);
           if (number >= 0x10000 || number < 0) {
             status = f_false;
             continue;
index 2e4145a2c01f6017bdf8dae7e8073b47f2391baf..87917c443f1a753dfd3a4398b27222289cb5336a 100644 (file)
@@ -105,24 +105,54 @@ extern "C" {
     }
 #endif // _di_status_code_data_
 
+/**
+ * Print help to standard output.
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ */
 #ifndef _di_status_code_print_help_
-  /**
-   * Print help.
-   */
   extern f_return_status status_code_print_help(const status_code_data data);
 #endif // _di_status_code_print_help_
 
+/**
+ * Execute main program.
+ *
+ * Be sure to call status_code_delete_data() after executing this.
+ *
+ * @param arguments
+ *   The parameters passed to the process.
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see status_code_delete_data()
+ */
 #ifndef _di_status_code_main_
-  /**
-   * Main.
-   */
-  extern f_return_status status_code_main(const f_array_length argc, const f_string argv[], status_code_data *data);
+  extern f_return_status status_code_main(const f_console_arguments arguments, status_code_data *data);
 #endif // _di_status_code_main_
 
+/**
+ * Deallocate data.
+ *
+ * Be sure to call this after executing status_code_main().
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ *
+ * @see status_code_main()
+ */
 #ifndef _di_status_code_delete_data_
-  /**
-   * Deallocate data.
-   */
   extern f_return_status status_code_delete_data(status_code_data *data);
 #endif // _di_status_code_delete_data_