]> Kevux Git Server - fll/commitdiff
Progress: Begin breaking out internal parameters to allow for better caller control...
authorKevin Day <thekevinday@gmail.com>
Thu, 11 Aug 2022 04:06:20 +0000 (23:06 -0500)
committerKevin Day <thekevinday@gmail.com>
Thu, 11 Aug 2022 04:06:20 +0000 (23:06 -0500)
Starting with utf8, start the process of breaking out the parameter settings into a variable that the caller can customize.
This should improve extensibility such that the caller can provide their own initializers.

Other incidental changes are made.

53 files changed:
level_3/byte_dump/c/byte_dump.c
level_3/byte_dump/c/main.c
level_3/control/c/main.c
level_3/control/c/private-control.c
level_3/controller/c/controller/private-controller.c
level_3/controller/c/main.c
level_3/fake/c/main.c
level_3/fake/c/private-fake.c
level_3/fake/c/private-make-operate.c
level_3/fake/c/private-make-operate_process_type.c
level_3/fake/c/private-skeleton.c
level_3/firewall/c/main.c
level_3/firewall/c/private-firewall.c
level_3/fss_basic_list_read/c/fss_basic_list_read.c
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/main.c
level_3/fss_basic_read/c/fss_basic_read.c
level_3/fss_basic_read/c/main.c
level_3/fss_basic_write/c/fss_basic_write.c
level_3/fss_basic_write/c/main.c
level_3/fss_embedded_list_read/c/fss_embedded_list_read.c
level_3/fss_embedded_list_read/c/main.c
level_3/fss_embedded_list_write/c/fss_embedded_list_write.c
level_3/fss_embedded_list_write/c/main.c
level_3/fss_extended_list_read/c/fss_extended_list_read.c
level_3/fss_extended_list_read/c/main.c
level_3/fss_extended_list_write/c/fss_extended_list_write.c
level_3/fss_extended_list_write/c/main.c
level_3/fss_extended_read/c/fss_extended_read.c
level_3/fss_extended_read/c/main.c
level_3/fss_extended_write/c/fss_extended_write.c
level_3/fss_extended_write/c/main.c
level_3/fss_identify/c/fss_identify.c
level_3/fss_identify/c/main.c
level_3/fss_payload_read/c/fss_payload_read.c
level_3/fss_payload_read/c/main.c
level_3/fss_payload_write/c/fss_payload_write.c
level_3/fss_payload_write/c/main.c
level_3/fss_status_code/c/main.c
level_3/iki_read/c/iki_read.c
level_3/iki_read/c/main.c
level_3/iki_write/c/iki_write.c
level_3/iki_write/c/main.c
level_3/status_code/c/main.c
level_3/utf8/c/common.h
level_3/utf8/c/main.c
level_3/utf8/c/private-common.c
level_3/utf8/c/private-common.h
level_3/utf8/c/private-utf8_bytesequence.c
level_3/utf8/c/private-utf8_codepoint.c
level_3/utf8/c/utf8.c
level_3/utf8/c/utf8.h

index d67a8d5efb86c019e0e32815aa06ed7a13cde30f..427bc3461ad37bd0ac05f4df90a66d7675527b2b 100644 (file)
@@ -498,7 +498,8 @@ extern "C" {
 
           status = byte_dump_file(&data, data.argv[main->parameters.remaining.array[counter]], file);
 
-          f_file_stream_close(F_true, &file);
+          f_file_stream_flush(&file);
+          f_file_stream_close(&file);
 
           if (F_status_is_error(status)) {
             if (F_status_set_fine(status) == F_interrupt) {
index 62c3db4f3ad86d363404c39d4416b81d9976def1..586e425e82c1579fc6641ac19f76c0d5147dd74b 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = byte_dump_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index c475e01de0876620cdb876eeeeaf9d67387756a2..fa54ef2c68e20ee38917e30335665d09c9c7c1e7 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = control_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index ce8f28e59415559ca020dd88df200dcfb80ecc9f..87ceae8b9a8f0a26dc2d812940c32595d56b4c84 100644 (file)
@@ -642,7 +642,8 @@ extern "C" {
 
       status = f_file_stream_read(file, &data->cache.large);
 
-      f_file_stream_close(F_true, &file);
+      f_file_stream_flush(&file);
+      f_file_stream_close(&file);
 
       if (F_status_is_error(status)) {
         fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, data->cache.small, f_file_operation_read_s, fll_error_file_type_file_e);
index d9d8857f02009e7ddd7fed3ce752f90b8a555fae..e739ddd1042feda775e02b63c44106d66f0e3bfa 100644 (file)
@@ -94,7 +94,8 @@ extern "C" {
 
     if (F_status_is_error(status)) {
       if (!required && F_status_set_fine(status) == F_file_found_not) {
-        f_file_stream_close(F_true, &file);
+        f_file_stream_flush(&file);
+        f_file_stream_close(&file);
 
         return F_file_found_not;
       }
@@ -113,7 +114,8 @@ extern "C" {
       }
     }
 
-    f_file_stream_close(F_true, &file);
+    f_file_stream_flush(&file);
+    f_file_stream_close(&file);
 
     if (F_status_is_error_not(status)) {
       struct stat stat_file;
@@ -175,7 +177,8 @@ extern "C" {
 
     fll_print_format("%i%r", file.stream, pid, f_string_eol_s);
 
-    f_file_stream_close(F_true, &file);
+    f_file_stream_flush(&file);
+    f_file_stream_close(&file);
 
     if (F_status_is_error(status)) return status;
 
@@ -202,7 +205,11 @@ extern "C" {
     status = f_file_stream_read(pid_file, &pid_buffer);
 
     if (F_status_is_error_not(status)) {
-      status = f_file_stream_close(F_true, &pid_file);
+      status = f_file_stream_flush(&pid_file);
+    }
+
+    if (F_status_is_error_not(status)) {
+      status = f_file_stream_close(&pid_file);
     }
 
     if (F_status_is_error_not(status)) {
@@ -255,7 +262,11 @@ extern "C" {
     status = f_file_stream_read(pid_file, &pid_buffer);
 
     if (F_status_is_error_not(status)) {
-      status = f_file_stream_close(F_true, &pid_file);
+      status = f_file_stream_flush(&pid_file);
+    }
+
+    if (F_status_is_error_not(status)) {
+      status = f_file_stream_close(&pid_file);
     }
 
     if (F_status_is_error_not(status)) {
index b4b8570e37e134c6b299abcf4a93bb84f6e91bb4..2de5fd9811f777d04a365733c47a999a8f8c6266 100644 (file)
@@ -16,7 +16,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
   data.pid = getpid();
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   f_file_umask_get(&data.umask);
 
@@ -45,7 +45,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
   controller_main_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   // When the child process exits, it must return the code to the parent so the parent knows how to handle the exit.
   if (status == F_child) {
index dff053732efd941a8b9b7e201ac4bd482e1e9292..1b4ad4fb503e9ab0b73356d3c02c4cb3c2c99d06 100644 (file)
@@ -27,7 +27,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   f_file_umask_get(&data.umask);
 
@@ -35,7 +35,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (status == F_child) {
     exit(data.child);
index 55fcb53d9d6b36caa99059a7e697f8342c97c19a..e2f10c13af6f6b482c6f93d01ed1b0c47715350e 100644 (file)
@@ -131,7 +131,8 @@ extern "C" {
         name_function = "f_file_read";
         status = f_file_read(file, buffer);
 
-        f_file_stream_close(F_true, &file);
+        f_file_stream_flush(&file);
+        f_file_stream_close(&file);
       }
     }
     else if (status == F_false) {
index 07b847bee34e6bd6e08b39c487f6b3d2ab8b5648..f1ac0c4913079838b77202d2e425471bc6627a90 100644 (file)
@@ -115,7 +115,7 @@ extern "C" {
       data_make.error.context = data->main->context.set.warning;
       data_make.error.notable = data->main->context.set.notable;
       data_make.error.to.stream = F_type_warning_d;
-      data_make.error.to.id = F_type_descriptor_warning_d;
+      data_make.error.to.id = F_type_descriptor_output_d;
       data_make.error.set = &data->main->context.set;
     }
     else {
@@ -152,7 +152,8 @@ extern "C" {
       }
     }
 
-    f_file_stream_close(F_true, &data_make.path.top);
+    f_file_stream_flush(&data_make.path.top);
+    f_file_stream_close(&data_make.path.top);
 
     f_array_lengths_resize(0, &section_stack);
     fake_make_data_delete(&data_make);
index 71b3b6d7980d284b4607a76edb2c85838a6c52b5..a2a60d80a0e850db4686dbbfb6e49208bb9200cd 100644 (file)
@@ -509,7 +509,7 @@ extern "C" {
       data_make->error.context = data_make->main->context.set.warning;
       data_make->error.notable = data_make->main->context.set.notable;
       data_make->error.to.stream = F_type_warning_d;
-      data_make->error.to.id = F_type_descriptor_warning_d;
+      data_make->error.to.id = F_type_descriptor_output_d;
       data_make->error.set = &data_make->main->context.set;
     }
     else {
@@ -1964,7 +1964,8 @@ extern "C" {
       else {
         status = F_none;
 
-        f_file_stream_close(F_true, &file);
+        f_file_stream_flush(&file);
+        f_file_stream_close(&file);
       }
     }
 
@@ -2025,7 +2026,8 @@ extern "C" {
         } // for
       }
 
-      f_file_stream_close(F_true, &file);
+      f_file_stream_flush(&file);
+      f_file_stream_close(&file);
     }
 
     if (F_status_is_error(status)) return F_status_set_error(F_failure);
index 9b2844a1771e6bf2c7bc87077ddf7e6684f6342a..edd32a70b2e52f950907b0b85b06261bedf85933 100644 (file)
@@ -274,7 +274,8 @@ extern "C" {
         if (F_status_is_error(status)) {
           fll_error_file_print(data->main->error, F_status_set_fine(status), "f_file_write", F_true, path, fake_common_file_populate_pre_s, fll_error_file_type_file_e);
 
-          f_file_stream_close(F_true, &file);
+          f_file_stream_flush(&file);
+          f_file_stream_close(&file);
 
           return status;
         }
@@ -283,7 +284,8 @@ extern "C" {
           fll_print_format("File '%Q' pre-populated.%r", data->main->output.to.stream, path, f_string_eol_s);
         }
 
-        f_file_stream_close(F_true, &file);
+        f_file_stream_flush(&file);
+        f_file_stream_close(&file);
       }
     }
     else if (F_status_is_error(status)) {
index 92b05d5b9fe26cde8832134fadf62333f8ecf021..cb52c88295650de522552f7a81877773c268a5e8 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = firewall_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (status == F_child) {
     exit(data.child);
index e9450cee4ed34f8a0442176344df59076e1d42eb..c52005fdadf1ff5eddb1402e487cc76bc0546c4e 100644 (file)
@@ -578,12 +578,14 @@ f_status_t firewall_perform_commands(firewall_data_t * const data, firewall_loca
               firewall_print_error_on_unhandled(data->main->error, "f_file_open", F_status_set_fine(status));
             }
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
           }
           else {
             status = f_file_read(file, &local_buffer);
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             if (F_status_is_error(status)) {
               if (data->main->error.verbosity != f_console_verbosity_quiet_e) {
@@ -1158,7 +1160,8 @@ f_status_t firewall_buffer_rules(firewall_data_t * const data, const f_string_st
 
   status = f_file_read(file, &local->buffer);
 
-  f_file_stream_close(F_true, &file);
+  f_file_stream_flush(&file);
+  f_file_stream_close(&file);
 
   if (F_status_is_error(status)) {
     if (data->main->error.verbosity != f_console_verbosity_quiet_e) {
index cb1151073bd22b65a1aaa5c49f6fcfaf2e6d55bc..edd21887dab0c81abf5f1af5672ff2970f427088 100644 (file)
@@ -564,7 +564,8 @@ extern "C" {
           if (F_status_is_error(status)) {
             fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e);
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             break;
           }
@@ -590,7 +591,8 @@ extern "C" {
             if (F_status_is_error(status)) {
               fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e);
 
-              f_file_stream_close(F_true, &file);
+              f_file_stream_flush(&file);
+              f_file_stream_close(&file);
 
               break;
             }
@@ -610,7 +612,8 @@ extern "C" {
               if (F_status_is_error(status)) break;
             } // for
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             if (F_status_is_error(status)) {
               if (F_status_set_fine(status) != F_interrupt) {
@@ -638,7 +641,8 @@ extern "C" {
           }
         } // for
 
-        f_file_stream_close(F_true, &file);
+        f_file_stream_flush(&file);
+        f_file_stream_close(&file);
       }
 
       if (F_status_is_error_not(status)) {
index 3a68d3135d6140c9b0ac9ae826f329011e4e1066..0ded01b2404f16423bc755005b90dde140b0f4e4 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_basic_list_read_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index 71b29bb5ef70b38279f2fa2cd2e12e6b173dfff2..6a91c6f9e4db88baef5bc7403cf9ad87ac8cbe91 100644 (file)
@@ -514,9 +514,8 @@ extern "C" {
     }
 
     if (main->parameters.array[fss_basic_list_write_parameter_file_e].result == f_console_result_additional_e) {
-      if (output.id != -1) {
-        f_file_stream_close(F_true, &output);
-      }
+      f_file_stream_flush(&output);
+      f_file_stream_close(&output);
     }
 
     // Ensure a newline is always put at the end of the program execution, unless in quiet mode.
index 52566fe02f9b456321d361c7f6fe28500a29f5b3..5135c63dca70e15311cc0ebeeea655e859aafc71 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_basic_list_write_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index 23cbb198e5e4ac2c6b29bef0c67947659b95fd9b..7bbce28b94bde5b65ebc82e8a7be0146c74ed2e2 100644 (file)
@@ -571,7 +571,8 @@ extern "C" {
           if (F_status_is_error(status)) {
             fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e);
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             break;
           }
@@ -597,7 +598,8 @@ extern "C" {
             if (F_status_is_error(status)) {
               fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e);
 
-              f_file_stream_close(F_true, &file);
+              f_file_stream_flush(&file);
+              f_file_stream_close(&file);
 
               break;
             }
@@ -617,7 +619,8 @@ extern "C" {
               if (F_status_is_error(status)) break;
             } // for
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             if (F_status_is_error(status)) {
               if (F_status_set_fine(status) != F_interrupt) {
index 2703e70a0f38e48657f3cb5fd4c95939dc5405db..cdddcca9a8c2dc9f0809352a37ba8cb95eff5e11 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_basic_read_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index b1d95bed73fc818a2bc0a4c255e9833887aeee6e..5f05c505a974d8fac3eb26cb70e6803300747313 100644 (file)
@@ -505,9 +505,8 @@ extern "C" {
     }
 
     if (main->parameters.array[fss_basic_write_parameter_file_e].result == f_console_result_additional_e) {
-      if (output.id != -1) {
-        f_file_stream_close(F_true, &output);
-      }
+      f_file_stream_flush(&output);
+      f_file_stream_close(&output);
     }
 
     // Ensure a newline is always put at the end of the program execution, unless in quiet mode.
index 9a91620ffcc360b7a8f43821ede576f0652a4710..059d3fa465c54370f70c971bd9c60a2274cc6128 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_basic_write_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index a416fcec2b96df0965916484169e0df3a57f99d5..2762431a5cbec6d60ef7f0177f8f9702b6a7e10b 100644 (file)
@@ -457,7 +457,8 @@ extern "C" {
           if (F_status_is_error(status)) {
             fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e);
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             break;
           }
@@ -468,7 +469,8 @@ extern "C" {
               fll_print_format("%r%r", main->output.to.stream, f_string_ascii_0_s, f_string_eol_s);
             }
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             continue;
           }
@@ -492,7 +494,8 @@ extern "C" {
           if (F_status_is_error(status)) {
             fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e);
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             break;
           }
@@ -512,7 +515,8 @@ extern "C" {
             if (F_status_is_error(status)) break;
           } // for
 
-          f_file_stream_close(F_true, &file);
+          f_file_stream_flush(&file);
+          f_file_stream_close(&file);
 
           if (F_status_is_error(status)) {
             if (F_status_set_fine(status) != F_interrupt) {
index 9ae2ea43614d0bc0c00405348353eed9dd6de960..66a29c5bc9a34cea8aed7c24682df485d5be04e7 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_embedded_list_read_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index 0ecb59106634c70dd7bdbe68521ccd9934286d11..67d5f89502dd0796fb81d2b45bac46beec14467a 100644 (file)
@@ -520,9 +520,8 @@ extern "C" {
     }
 
     if (main->parameters.array[fss_embedded_list_write_parameter_file_e].result == f_console_result_additional_e) {
-      if (output.id != -1) {
-        f_file_stream_close(F_true, &output);
-      }
+      f_file_stream_flush(&output);
+      f_file_stream_close(&output);
     }
 
     // Ensure a newline is always put at the end of the program execution, unless in quiet mode.
index fa25afce0f720e2ca5df10b12cd92d31cac0a7f0..257b8a2c6dff900d374c73400f14aabc928635df 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_embedded_list_write_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index 2247565bf446e4942e57c84f10b377c2220aeb64..aa23486660d0eb422310aea9ac4040469042f0c2 100644 (file)
@@ -571,7 +571,8 @@ extern "C" {
           if (F_status_is_error(status)) {
             fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e);
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             break;
           }
@@ -597,7 +598,8 @@ extern "C" {
             if (F_status_is_error(status)) {
               fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e);
 
-              f_file_stream_close(F_true, &file);
+              f_file_stream_flush(&file);
+              f_file_stream_close(&file);
 
               break;
             }
@@ -617,7 +619,8 @@ extern "C" {
               if (F_status_is_error(status)) break;
             } // for
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             if (F_status_is_error(status)) {
               if (F_status_set_fine(status) != F_interrupt) {
index 2a6234b3f1c5244aa0fcfa36f772f8f3c61bb0c6..fa5f77e710fad3943c775c30710f714110b837d7 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_extended_list_read_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index fd90cdfe4cfc59475d5df3405473a4986d5bd197..46062759315153e273de421cb1e4790d672b2283 100644 (file)
@@ -519,9 +519,8 @@ extern "C" {
     }
 
     if (main->parameters.array[fss_extended_list_write_parameter_file_e].result == f_console_result_additional_e) {
-      if (output.id != -1) {
-        f_file_stream_close(F_true, &output);
-      }
+      f_file_stream_flush(&output);
+      f_file_stream_close(&output);
     }
 
     // Ensure a newline is always put at the end of the program execution, unless in quiet mode.
index 3a959ab46cbcb839d3b67c78c85fbe0c7124c805..46280945b08e1ba78e7e7f4591ccc7250f2af462 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_extended_list_write_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index a6773c9c04bde59ba414004897a6929ea7e91a7d..27d029af26e1dddad89298568762508ed40f2202 100644 (file)
@@ -570,7 +570,8 @@ extern "C" {
           if (F_status_is_error(status)) {
             fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e);
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             break;
           }
@@ -596,7 +597,8 @@ extern "C" {
             if (F_status_is_error(status)) {
               fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e);
 
-              f_file_stream_close(F_true, &file);
+              f_file_stream_flush(&file);
+              f_file_stream_close(&file);
 
               break;
             }
@@ -616,7 +618,8 @@ extern "C" {
               if (F_status_is_error(status)) break;
             } // for
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             if (F_status_is_error(status)) {
               if (F_status_set_fine(status) != F_interrupt) {
index 93a18949073e2145ac16c468783ab859dae3fe8f..ca654302d622e8844d389ceb1b1467e16c2adbca 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_extended_read_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index f99958220d845c0e598719c73d80161bea981849..12f2f30683f8619a60132236cbed8fb870dd0b57 100644 (file)
@@ -574,9 +574,8 @@ extern "C" {
     }
 
     if (main->parameters.array[fss_extended_write_parameter_file_e].result == f_console_result_additional_e) {
-      if (output.id != -1) {
-        f_file_stream_close(F_true, &output);
-      }
+      f_file_stream_flush(&output);
+      f_file_stream_close(&output);
     }
 
     // Ensure a newline is always put at the end of the program execution, unless in quiet mode.
index 952c449b4723dd2c39adfd6002814d3d0409fdf7..cd8acc425a7d39a06e578f00b28f027f4c5a9c61 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_extended_write_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index 162c02a4c3df27aa1d303ca7ca1edc6456eb12ed..f2b1d2953a0fd51e50b2bd10f0c940f3415b64c7 100644 (file)
@@ -319,7 +319,8 @@ extern "C" {
           }
         }
 
-        f_file_stream_close(F_true, &file);
+        f_file_stream_flush(&file);
+        f_file_stream_close(&file);
 
         if (F_status_is_error(status)) break;
       } // for
index d2b21977f34a1e14ab325a67c7e0bb9c1056fcec..a8274e2d371c77ba5c460f222813d498df091113 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_identify_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index c0ffa4dd7f86ddd097fb079539e9da6d1f3be4f5..c2a9e2162395d0e5fa42864e9f1b64433e101988 100644 (file)
@@ -602,7 +602,8 @@ extern "C" {
           if (F_status_is_error(status)) {
             fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e);
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             break;
           }
@@ -628,7 +629,8 @@ extern "C" {
             if (F_status_is_error(status)) {
               fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e);
 
-              f_file_stream_close(F_true, &file);
+              f_file_stream_flush(&file);
+              f_file_stream_close(&file);
 
               break;
             }
@@ -648,7 +650,8 @@ extern "C" {
               if (F_status_is_error(status)) break;
             } // for
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             if (F_status_is_error(status)) {
               if (F_status_set_fine(status) != F_interrupt) {
index fe6246cdc6f4da58d793198a8441bde5fd1f50d3..b908e0e6de2b0092bada4c904ae721a82b9d606d 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_payload_read_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index 04701d930cecc76082fc5399b964778e77ea0e8d..1534628ed058beccfb8bac1e0b025925494189a6 100644 (file)
@@ -518,9 +518,8 @@ extern "C" {
     }
 
     if (main->parameters.array[fss_payload_write_parameter_file_e].result == f_console_result_additional_e) {
-      if (output.id != -1) {
-        f_file_stream_close(F_true, &output);
-      }
+      f_file_stream_flush(&output);
+      f_file_stream_close(&output);
     }
 
     // Ensure a newline is always put at the end of the program execution, unless in quiet mode.
index cbb903cac30fb2412ae37895ae6aad39e10e0fa3..56c7ca2d14449a27d04ec94ca9a37ce0724a3aa4 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_payload_write_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index 4014fa90f4495160256dc3fb5cceb30143272a35..387dd27312a89f52cf999c5a4cc087cd64674aed 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = fss_status_code_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status) || status == F_false) return 1;
 
index 3da7f435d9629c447244ea602a0f0dd04e8c6fe3..ad8981c511f294dcde5601633d5d5054e3b182bb 100644 (file)
@@ -464,14 +464,16 @@ extern "C" {
           if (F_status_is_error(status)) {
             fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e);
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             break;
           }
 
           // Skip past empty files.
           if (!size_file) {
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             continue;
           }
@@ -492,7 +494,8 @@ extern "C" {
           if (F_status_is_error(status)) {
             fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e);
 
-            f_file_stream_close(F_true, &file);
+            f_file_stream_flush(&file);
+            f_file_stream_close(&file);
 
             break;
           }
@@ -512,7 +515,8 @@ extern "C" {
             if (F_status_is_error(status)) break;
           } // for
 
-          f_file_stream_close(F_true, &file);
+          f_file_stream_flush(&file);
+          f_file_stream_close(&file);
 
           if (F_status_is_error(status)) {
             if (F_status_set_fine(status) != F_interrupt) {
index 9ed1acf1418e7e957d2c98b7f657b35ec2fd87f9..edff724b60dac51958c6af74b75b541f93261027 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = iki_read_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index 24de7bf9e9c35a71763d81dc3d7a0a7709fe96b9..e50f74ded4559637023c826d10df397df1d8fb5a 100644 (file)
@@ -455,9 +455,8 @@ extern "C" {
     }
 
     if (main->parameters.array[iki_write_parameter_file_e].result == f_console_result_additional_e) {
-      if (file.id != -1) {
-        f_file_stream_close(F_true, &file);
-      }
+      f_file_stream_flush(&file);
+      f_file_stream_close(&file);
     }
 
     // Ensure a new line is always put at the end of the program execution, unless in quiet mode.
index b35e86cda8856a26990184cba327d421359935c0..4b140dcfa4eaa79705d6fd641c17135b81dacf34 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = iki_write_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index 6fd7860de8c8d9df8ab73b39faf052c9c4a7ca27..9326cb70df32ff555cb3535f5bb32f39196c0818 100644 (file)
@@ -13,13 +13,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     data.process_pipe = F_true;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
   const f_status_t status = status_code_main(&data, &arguments);
 
   fll_program_data_delete(&data);
 
-  fll_program_standard_setdown(&data.signal);
+  fll_program_standard_set_down(&data.signal);
 
   if (F_status_is_error(status)) return 1;
 
index 55412813ca491eac5d0b878933442acdec1fb728..c7672dc8213e8154d6f8688828c165204414ae88 100644 (file)
@@ -298,24 +298,76 @@ extern "C" {
 /**
  * Modes used to designate how to the input and output are to be processed.
  *
- * utf8_mode_from_*:
+ * utf8_mode_*_e:
+ *   - none: No modes in use.
+ *
+ * utf8_mode_from_*_e:
  *   - bytesequence: The input format is bytesequence.
  *   - codepoint:    The input format is codepoint (U+XXXX or U+XXXXXX).
  *
- * utf8_mode_to_*:
+ * utf8_mode_to_*_e:
  *   - bytesequence: The outout format is bytesequence.
  *   - codepoint:    The outout format is codepoint (U+XXXX or U+XXXXXX).
  *   - combining:    The outout format is whether or not character is combining (may be used with "width").
  *   - width:        The outout format is how wide the character is (may be used with "combining").
  */
-#ifndef _di_utf8_modes_
-  #define utf8_mode_from_bytesequence_d 0x1
-  #define utf8_mode_from_codepoint_d    0x2
-  #define utf8_mode_to_bytesequence_d   0x4
-  #define utf8_mode_to_codepoint_d      0x8
-  #define utf8_mode_to_combining_d      0x10
-  #define utf8_mode_to_width_d          0x20
-#endif // _di_utf8_modes_
+#ifndef _di_utf8_modes_e_
+  enum {
+    utf8_mode_none_e              = 0x0,
+    utf8_mode_from_bytesequence_e = 0x1,
+    utf8_mode_from_codepoint_d    = 0x2,
+    utf8_mode_to_bytesequence_d   = 0x4,
+    utf8_mode_to_codepoint_d      = 0x8,
+    utf8_mode_to_combining_d      = 0x10,
+    utf8_mode_to_width_d          = 0x20,
+  };
+#endif // _di_utf8_modes_e_
+
+/**
+ * The UTF-8 main program settings.
+ *
+ * This is passed to the program-specific main entry point to designate program settings.
+ * These program settings are often processed from the program arguments (often called the command line arguments).
+ *
+ * mode: The input/output mode (see utf8_modes_e).
+ */
+#ifndef _di_utf8_main_setting_t_
+  typedef struct {
+    uint8_t mode;
+  } utf8_main_setting_t;
+
+  #define utf8_main_setting_t_initialize \
+    { \
+      utf8_mode_from_bytesequence_d | utf8_mode_to_codepoint_d, \
+    }
+#endif // _di_utf8_main_setting_t_
+
+/*
+    f_color_set_t valid;
+    f_color_set_t valid_not;
+
+    f_string_static_t append;
+    f_string_static_t prepend;
+
+    f_string_dynamic_t buffer;
+    f_string_dynamic_t text;
+  } utf8_data_t;
+
+  #define utf8_data_t_initialize \
+    { \
+      0, \
+      0, \
+      0, \
+      f_file_t_initialize, \
+      utf8_mode_from_bytesequence_d | utf8_mode_to_codepoint_d, \
+      f_color_set_t_initialize, \
+      f_color_set_t_initialize, \
+      f_string_static_t_initialize, \
+      f_string_static_t_initialize, \
+      f_string_dynamic_t_initialize, \
+      f_string_dynamic_t_initialize, \
+    }
+    */
 
 #ifdef __cplusplus
 } // extern "C"
index 0dc25a5971dd3d1e02f2a364dc969c9c1f4bcc6d..2f51d638d9865f6d01feef051602e0ebd478e382 100644 (file)
@@ -3,25 +3,38 @@
 int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
   const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp);
+
   fll_program_data_t data = fll_program_data_t_initialize;
+  utf8_main_setting_t setting = utf8_main_setting_t_initialize;
 
   f_console_parameter_t parameters[] = utf8_console_parameter_t_initialize;
   data.parameters.array = parameters;
   data.parameters.used = utf8_total_parameters_d;
 
   if (f_pipe_input_exists()) {
-    data.process_pipe = F_true;
+    data.pipe |= fll_program_data_pipe_input_e;
   }
 
-  fll_program_standard_setup(&data.signal);
+  fll_program_standard_set_up(&data.signal);
 
-  const f_status_t status = utf8_main(&data, &arguments);
+  f_status_t status = utf8_main_setting_load(arguments, data, &setting);
 
-  fll_program_data_delete(&data);
+  if (F_status_is_error_not(status)) {
+    status = utf8_main(&data, &setting);
+  }
+
+  if (data.message.stream != data.output.stream) {
+    f_file_stream_flush(&data->output);
+    f_file_stream_close(&data->output);
+  }
+
+  utf8_main_setting_unload(data, &setting);
 
-  fll_program_standard_setdown(&data.signal);
+  utf8_main_setting_delete(&setting);
+
+  fll_program_data_delete(&data);
 
-  if (F_status_is_error(status)) return 1;
+  fll_program_standard_set_down(&data.signal);
 
-  return 0;
+  return F_status_is_error(status) ? 1 : 0;
 }
index e8bbe72a28c65161282051a6297b97384a5f4822..f6bc32618865cb871a3e29ec35526e2d4a8dae66 100644 (file)
@@ -9,10 +9,6 @@ extern "C" {
 #ifndef _di_utf8_data_delete_
   void utf8_data_delete(utf8_data_t *data) {
 
-    if (data->file.stream != data->main->output.to.stream) {
-      f_file_stream_close(F_true, &data->file);
-    }
-
     f_string_dynamic_resize(0, &data->buffer);
     f_string_dynamic_resize(0, &data->text);
   }
index ebf495f8b736d1500c06353b263b3ced74be7d9f..40fc9cb9800a33ac17cd1f47653ccdeaf19666f9 100644 (file)
@@ -48,10 +48,12 @@ extern "C" {
 /**
  * The program data.
  *
- * argv:      The argument structure in the progam data parameters for simplifying syntax.
+ * main:    The main program data.
+ * setting: The main program settings.
+ * argv:    The argument structure in the progam data parameters for simplifying syntax.
+ *
  * main:      The main program data.
  * file:      The output file for writing the processed data to (may potentially default to "output").
- * mode:      The input/output mode (see utf8_modes).
  * valid:     Designate the output context set for valid characters.
  * valid_not: Designate the output context set for invalid characters.
  * append:    A string to append. A value of NULL results in not appending.
@@ -62,10 +64,10 @@ extern "C" {
 #ifndef _di_utf8_data_t_
   typedef struct {
     fll_program_data_t *main;
+    utf8_main_setting_t *setting;
     f_string_static_t *argv;
 
-    f_file_t file;
-    uint8_t mode;
+    //f_file_t file;
 
     f_color_set_t valid;
     f_color_set_t valid_not;
@@ -81,8 +83,8 @@ extern "C" {
     { \
       0, \
       0, \
-      f_file_t_initialize, \
-      utf8_mode_from_bytesequence_d | utf8_mode_to_codepoint_d, \
+      0, \
+      //f_file_t_initialize, \
       f_color_set_t_initialize, \
       f_color_set_t_initialize, \
       f_string_static_t_initialize, \
index 7e2ce440357f442f033b863bef5dd39641e9d9cc..dd18133b267fbde3f7a0c9a219af73d6341731c0 100644 (file)
@@ -52,9 +52,7 @@ extern "C" {
       }
     }
 
-    if (valid_not || F_status_is_error(status)) {
-      return F_utf_not;
-    }
+    if (valid_not || F_status_is_error(status)) return F_utf_not;
 
     return F_none;
   }
@@ -154,9 +152,7 @@ extern "C" {
 
     data->buffer.used = 0;
 
-    if (F_status_is_error(status) || status == F_interrupt) {
-      return status;
-    }
+    if (F_status_is_error(status) || status == F_interrupt) return status;
 
     return valid;
   }
index 8389de956aabf499c0a128197bc3968a68c15263..f96c43d99ad655b94abaffd0913e1d26199344f0 100644 (file)
@@ -440,9 +440,7 @@ extern "C" {
 
     data->buffer.used = 0;
 
-    if (F_status_is_error(status) || status == F_interrupt) {
-      return status;
-    }
+    if (F_status_is_error(status) || status == F_interrupt) return status;
 
     return valid;
   }
index 7606f1ef78b384efb37db284365aa9012251c3b7..eef2f33dbd0c6025265ed33177c2697e19d684f5 100644 (file)
@@ -68,235 +68,25 @@ extern "C" {
 #endif // _di_utf8_print_help_
 
 #ifndef _di_utf8_main_
-  f_status_t utf8_main(fll_program_data_t * const main, const f_console_arguments_t *arguments) {
+  f_status_t utf8_main(fll_program_data_t * const main, utf8_main_setting_t * const setting) {
 
-    f_status_t status = F_none;
-
-    utf8_data_t data = utf8_data_t_initialize;
-    data.main = main;
-
-    // Identify priority of color parameters.
-    {
-      f_console_parameter_id_t ids[3] = { utf8_parameter_no_color_e, utf8_parameter_light_e, utf8_parameter_dark_e };
-      const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 3);
-
-      status = fll_program_parameter_process(*arguments, &main->parameters, choices, F_true, &main->context);
-
-      main->output.set = &main->context.set;
-      main->error.set = &main->context.set;
-      main->warning.set = &main->context.set;
-
-      if (main->context.set.error.before) {
-        main->output.context = f_color_set_empty_s;
-        main->output.notable = main->context.set.notable;
-
-        main->error.context = main->context.set.error;
-        main->error.notable = main->context.set.notable;
-
-        main->warning.context = main->context.set.warning;
-        main->warning.notable = main->context.set.notable;
-      }
-      else {
-        f_color_set_t *sets[] = { &main->output.context, &main->output.notable, &main->error.context, &main->error.notable, &main->warning.context, &main->warning.notable, 0 };
-
-        fll_program_parameter_process_empty(&main->context, sets);
-      }
-
-      if (F_status_is_error(status)) {
-        fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process", F_true);
-
-        utf8_data_delete(&data);
-
-        return F_status_set_error(status);
-      }
-    }
-
-    // Identify priority of verbosity related parameters.
-    {
-      f_console_parameter_id_t ids[5] = { utf8_parameter_verbosity_quiet_e, utf8_parameter_verbosity_error_e, utf8_parameter_verbosity_normal_e, utf8_parameter_verbosity_verbose_e, utf8_parameter_verbosity_debug_e };
-      f_console_parameter_id_t choice = 0;
-      const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 5);
-
-      status = f_console_parameter_prioritize_right(main->parameters, choices, &choice);
-
-      if (F_status_is_error(status)) {
-        fll_error_print(main->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true);
-
-        utf8_data_delete(&data);
-
-        return status;
-      }
-
-      if (choice == utf8_parameter_verbosity_quiet_e) {
-        main->output.verbosity = f_console_verbosity_quiet_e;
-        main->error.verbosity = f_console_verbosity_quiet_e;
-        main->warning.verbosity = f_console_verbosity_quiet_e;
-      }
-      else if (choice == utf8_parameter_verbosity_error_e) {
-        main->output.verbosity = f_console_verbosity_error_e;
-        main->error.verbosity = f_console_verbosity_error_e;
-        main->warning.verbosity = f_console_verbosity_error_e;
-      }
-      else if (choice == utf8_parameter_verbosity_normal_e) {
-        main->output.verbosity = f_console_verbosity_normal_e;
-        main->error.verbosity = f_console_verbosity_normal_e;
-        main->warning.verbosity = f_console_verbosity_normal_e;
-      }
-      else if (choice == utf8_parameter_verbosity_verbose_e) {
-        main->output.verbosity = f_console_verbosity_verbose_e;
-        main->error.verbosity = f_console_verbosity_verbose_e;
-        main->warning.verbosity = f_console_verbosity_verbose_e;
-      }
-      else if (choice == utf8_parameter_verbosity_debug_e) {
-        main->output.verbosity = f_console_verbosity_debug_e;
-        main->error.verbosity = f_console_verbosity_debug_e;
-        main->warning.verbosity = f_console_verbosity_debug_e;
-      }
-    }
-
-    // Identify and prioritize from mode parameters.
-    {
-      f_console_parameter_id_t ids[2] = { utf8_parameter_from_bytesequence_e, utf8_parameter_from_codepoint_e };
-      f_console_parameter_id_t choice = 0;
-      const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 2);
-
-      status = f_console_parameter_prioritize_right(main->parameters, choices, &choice);
-
-      if (F_status_is_error(status)) {
-        fll_error_print(main->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true);
-
-        utf8_data_delete(&data);
-
-        return status;
-      }
-
-      if (choice == utf8_parameter_from_bytesequence_e) {
-        if (data.mode & utf8_mode_from_codepoint_d) {
-          data.mode -= utf8_mode_from_codepoint_d;
-        }
-
-        data.mode |= utf8_mode_from_bytesequence_d;
-      }
-      else if (choice == utf8_parameter_from_codepoint_e) {
-        if (data.mode & utf8_mode_from_bytesequence_d) {
-          data.mode -= utf8_mode_from_bytesequence_d;
-        }
-
-        data.mode |= utf8_mode_from_codepoint_d;
-      }
-    }
-
-    // Identify and prioritize to mode parameters.
-    {
-      f_console_parameter_id_t ids[5] = { utf8_parameter_to_bytesequence_e, utf8_parameter_to_codepoint_e, utf8_parameter_to_combining_e, utf8_parameter_to_width_e };
-      f_console_parameter_id_t choice = 0;
-      const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 5);
-
-      status = f_console_parameter_prioritize_right(main->parameters, choices, &choice);
-
-      if (F_status_is_error(status)) {
-        fll_error_print(main->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true);
-
-        utf8_data_delete(&data);
-
-        return status;
-      }
-
-      if (choice == utf8_parameter_verbosity_quiet_e) {
-        main->output.verbosity = f_console_verbosity_quiet_e;
-        main->error.verbosity = f_console_verbosity_quiet_e;
-        main->warning.verbosity = f_console_verbosity_quiet_e;
-      }
-      else if (choice == utf8_parameter_verbosity_error_e) {
-        main->output.verbosity = f_console_verbosity_error_e;
-        main->error.verbosity = f_console_verbosity_error_e;
-        main->warning.verbosity = f_console_verbosity_error_e;
-      }
-      else if (choice == utf8_parameter_verbosity_normal_e) {
-        main->output.verbosity = f_console_verbosity_normal_e;
-        main->error.verbosity = f_console_verbosity_normal_e;
-        main->warning.verbosity = f_console_verbosity_normal_e;
-      }
-      else if (choice == utf8_parameter_verbosity_verbose_e) {
-        main->output.verbosity = f_console_verbosity_verbose_e;
-        main->error.verbosity = f_console_verbosity_verbose_e;
-        main->warning.verbosity = f_console_verbosity_verbose_e;
-      }
-      else if (choice == utf8_parameter_verbosity_debug_e) {
-        main->output.verbosity = f_console_verbosity_debug_e;
-        main->error.verbosity = f_console_verbosity_debug_e;
-        main->warning.verbosity = f_console_verbosity_debug_e;
-      }
-
-      if (choice == utf8_parameter_to_bytesequence_e) {
-        if (data.mode & utf8_mode_to_codepoint_d) {
-          data.mode -= utf8_mode_to_codepoint_d;
-        }
-
-        if (data.mode & utf8_mode_to_combining_d) {
-          data.mode -= utf8_mode_to_combining_d;
-        }
-
-        if (data.mode & utf8_mode_to_width_d) {
-          data.mode -= utf8_mode_to_width_d;
-        }
-
-        data.mode |= utf8_mode_to_bytesequence_d;
-      }
-      else if (choice == utf8_parameter_to_codepoint_e) {
-        if (data.mode & utf8_mode_to_bytesequence_d) {
-          data.mode -= utf8_mode_to_bytesequence_d;
-        }
-
-        if (data.mode & utf8_mode_to_combining_d) {
-          data.mode -= utf8_mode_to_combining_d;
-        }
-
-        if (data.mode & utf8_mode_to_width_d) {
-          data.mode -= utf8_mode_to_width_d;
-        }
-
-        data.mode |= utf8_mode_to_codepoint_d;
+    if (!main || !setting) {
+      if (main->error.verbosity != f_console_verbosity_quiet_e) {
+        fll_error_print(main->error, F_status_set_fine(status), "utf8_main", F_true);
+        fll_print_dynamic_raw(f_string_eol_s, main->message.to.stream);
       }
-      else if (choice == utf8_parameter_to_combining_e) {
-        if (data.mode & utf8_mode_to_bytesequence_d) {
-          data.mode -= utf8_mode_to_bytesequence_d;
-        }
-
-        if (data.mode & utf8_mode_to_codepoint_d) {
-          data.mode -= utf8_mode_to_codepoint_d;
-        }
-
-        // --to_width may be specified with --to_combining.
-        if (main->parameters.array[utf8_parameter_to_width_e].result == f_console_result_found_e) {
-          data.mode |= utf8_mode_to_width_d;
-        }
-
-        data.mode |= utf8_mode_to_combining_d;
-      }
-      else if (choice == utf8_parameter_to_width_e) {
-        if (data.mode & utf8_mode_to_bytesequence_d) {
-          data.mode -= utf8_mode_to_bytesequence_d;
-        }
-
-        if (data.mode & utf8_mode_to_codepoint_d) {
-          data.mode -= utf8_mode_to_codepoint_d;
-        }
-
-        // --to_width may be specified with --to_combining.
-        if (main->parameters.array[utf8_parameter_to_combining_e].result == f_console_result_found_e) {
-          data.mode |= utf8_mode_to_combining_d;
-        }
 
-        data.mode |= utf8_mode_to_width_d;
-      }
+      return F_status_set_error(F_paremeter);
     }
 
+    utf8_data_t data = utf8_data_t_initialize;
+    data.main = main;
+    data.setting = setting;
     data.argv = main->parameters.arguments.array;
-    status = F_none;
+    f_status_t status = F_none;
 
     if (main->parameters.array[utf8_parameter_help_e].result == f_console_result_found_e) {
-      utf8_print_help(main->output.to, main->context);
+      utf8_print_help(main->message.to, main->context);
 
       utf8_data_delete(&data);
 
@@ -304,7 +94,7 @@ extern "C" {
     }
 
     if (main->parameters.array[utf8_parameter_version_e].result == f_console_result_found_e) {
-      fll_program_print_version(main->output.to, utf8_program_version_s);
+      fll_program_print_version(main->message.to, utf8_program_version_s);
 
       utf8_data_delete(&data);
 
@@ -375,7 +165,7 @@ extern "C" {
         status = F_status_set_error(F_parameter);
       }
       else {
-        data.file = main->output.to;
+        data.file = main->message.to;
       }
     }
 
@@ -396,7 +186,7 @@ extern "C" {
         }
       }
 
-      data.valid_not = main->output.set->error;
+      data.valid_not = main->message.set->error;
     }
 
     if (F_status_is_error_not(status)) {
@@ -459,7 +249,8 @@ extern "C" {
             status = utf8_process_file_codepoint(&data, file);
           }
 
-          f_file_stream_close(F_true, &file);
+          f_file_stream_flush(&file);
+          f_file_stream_close(&file);
 
           if (main->parameters.array[utf8_parameter_verify_e].result == f_console_result_found_e) {
             if (status == F_false) {
@@ -501,28 +292,196 @@ extern "C" {
       }
     }
 
-    if (main->output.verbosity != f_console_verbosity_quiet_e && main->parameters.array[utf8_parameter_verify_e].result == f_console_result_none_e) {
+    if (main->message.verbosity != f_console_verbosity_quiet_e && main->parameters.array[utf8_parameter_verify_e].result == f_console_result_none_e) {
       if (status == F_interrupt) {
         fflush(data.file.stream);
 
-        if (data.file.stream != main->output.to.stream) {
-          fflush(main->output.to.stream);
+        if (data.file.stream != main->message.to.stream) {
+          fflush(main->message.to.stream);
         }
       }
 
-      fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream);
+      fll_print_dynamic_raw(f_string_eol_s, main->message.to.stream);
     }
 
     utf8_data_delete(&data);
 
-    if (F_status_is_error(status) || status == F_interrupt) {
-      return status;
-    }
+    if (F_status_is_error(status) || status == F_interrupt) return status;
 
     return valid;
   }
 #endif // _di_utf8_main_
 
+#ifndef _di_utf8_main_setting_delete_
+  f_status_t utf8_main_setting_delete(utf8_main_setting_t * const setting) {
+
+    return F_none;
+  }
+#endif // _di_utf8_main_setting_delete_
+
+#ifndef _di_utf8_main_setting_load_
+  f_status_t utf8_main_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, utf8_main_setting_t * const setting) {
+
+    f_status_t status = F_none;
+
+    // Identify priority of color parameters.
+    {
+      f_console_parameter_id_t ids[3] = { utf8_parameter_no_color_e, utf8_parameter_light_e, utf8_parameter_dark_e };
+      const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 3);
+
+      status = fll_program_parameter_process(arguments, choices, F_true, main);
+
+      if (F_status_is_error(status)) {
+        fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process", F_true);
+
+        return status;
+      }
+    }
+
+    {
+      const verbosity[5] = { utf8_parameter_verbosity_quiet_e, utf8_parameter_verbosity_error_e, f_console_verbosity_normal_e, utf8_parameter_verbosity_verbose_e, utf8_parameter_verbosity_debug_e };
+      f_console_parameter_id_t ids[5] = { utf8_parameter_verbosity_quiet_e, utf8_parameter_verbosity_error_e, utf8_parameter_verbosity_normal_e, utf8_parameter_verbosity_verbose_e, utf8_parameter_verbosity_debug_e };
+      const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 5);
+
+      status = fll_program_parameter_process_verbosity(choices, F_true, verbosity, main);
+
+      if (F_status_is_error(status)) {
+        fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true);
+
+        return status;
+      }
+    }
+
+    // Identify and prioritize from mode parameters.
+    {
+      f_console_parameter_id_t ids[2] = { utf8_parameter_from_bytesequence_e, utf8_parameter_from_codepoint_e };
+      f_console_parameter_id_t choice = 0;
+      const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 2);
+
+      status = f_console_parameter_prioritize_right(main->parameters, choices, &choice);
+
+      if (F_status_is_error(status)) {
+        fll_error_print(main->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true);
+
+        return status;
+      }
+
+      if (choice == utf8_parameter_from_bytesequence_e) {
+        if (data.mode & utf8_mode_from_codepoint_d) {
+          data.mode -= utf8_mode_from_codepoint_d;
+        }
+
+        data.mode |= utf8_mode_from_bytesequence_d;
+      }
+      else if (choice == utf8_parameter_from_codepoint_e) {
+        if (data.mode & utf8_mode_from_bytesequence_d) {
+          data.mode -= utf8_mode_from_bytesequence_d;
+        }
+
+        data.mode |= utf8_mode_from_codepoint_d;
+      }
+    }
+
+    // Identify and prioritize to mode parameters.
+    {
+      f_console_parameter_id_t ids[5] = { utf8_parameter_to_bytesequence_e, utf8_parameter_to_codepoint_e, utf8_parameter_to_combining_e, utf8_parameter_to_width_e };
+      f_console_parameter_id_t choice = 0;
+      const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 5);
+
+      status = f_console_parameter_prioritize_right(main->parameters, choices, &choice);
+
+      if (F_status_is_error(status)) {
+        fll_error_print(main->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true);
+
+        return status;
+      }
+
+      if (choice == utf8_parameter_to_bytesequence_e) {
+        if (data.mode & utf8_mode_to_codepoint_d) {
+          data.mode -= utf8_mode_to_codepoint_d;
+        }
+
+        if (data.mode & utf8_mode_to_combining_d) {
+          data.mode -= utf8_mode_to_combining_d;
+        }
+
+        if (data.mode & utf8_mode_to_width_d) {
+          data.mode -= utf8_mode_to_width_d;
+        }
+
+        data.mode |= utf8_mode_to_bytesequence_d;
+      }
+      else if (choice == utf8_parameter_to_codepoint_e) {
+        if (data.mode & utf8_mode_to_bytesequence_d) {
+          data.mode -= utf8_mode_to_bytesequence_d;
+        }
+
+        if (data.mode & utf8_mode_to_combining_d) {
+          data.mode -= utf8_mode_to_combining_d;
+        }
+
+        if (data.mode & utf8_mode_to_width_d) {
+          data.mode -= utf8_mode_to_width_d;
+        }
+
+        data.mode |= utf8_mode_to_codepoint_d;
+      }
+      else if (choice == utf8_parameter_to_combining_e) {
+        if (data.mode & utf8_mode_to_bytesequence_d) {
+          data.mode -= utf8_mode_to_bytesequence_d;
+        }
+
+        if (data.mode & utf8_mode_to_codepoint_d) {
+          data.mode -= utf8_mode_to_codepoint_d;
+        }
+
+        // --to_width may be specified with --to_combining.
+        if (main->parameters.array[utf8_parameter_to_width_e].result == f_console_result_found_e) {
+          data.mode |= utf8_mode_to_width_d;
+        }
+
+        data.mode |= utf8_mode_to_combining_d;
+      }
+      else if (choice == utf8_parameter_to_width_e) {
+        if (data.mode & utf8_mode_to_bytesequence_d) {
+          data.mode -= utf8_mode_to_bytesequence_d;
+        }
+
+        if (data.mode & utf8_mode_to_codepoint_d) {
+          data.mode -= utf8_mode_to_codepoint_d;
+        }
+
+        // --to_width may be specified with --to_combining.
+        if (main->parameters.array[utf8_parameter_to_combining_e].result == f_console_result_found_e) {
+          data.mode |= utf8_mode_to_combining_d;
+        }
+
+        data.mode |= utf8_mode_to_width_d;
+      }
+    }
+
+    return F_none;
+  }
+#endif // _di_utf8_main_setting_load_
+
+#ifndef _di_utf8_main_setting_unload_
+  f_status_t utf8_main_setting_unload(fll_program_data_t * const main, utf8_main_setting_t * const setting) {
+
+    if (data->file.stream) {
+      if (data->file.stream != main->message.stream && data->file.stream != main->output.stream && data->file.stream != main->error.stream && data->file.stream != main->warning.stream && data->file.stream != main->debug.stream) {
+        f_file_stream_flush(&data->file);
+        f_file_stream_close(&data->file);
+      }
+    }
+    else if (data->file.id != -1) {
+      if (data->file.id != main->message.id && data->file.id != main->output.id && data->file.id != main->error.id && data->file.id != main->warning.id && data->file.id != main->debug.id) {
+        f_file_flush(&data->file);
+        f_file_close(&data->file);
+      }
+    }
+  }
+#endif // _di_utf8_main_setting_unload_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index fa1357256b5460235969e79a77e0f12235c0536f..9d1697fc616813b7165388332cbb2b99318740b6 100644 (file)
@@ -89,8 +89,8 @@ extern "C" {
  *
  * @param main
  *   The main program data.
- * @param arguments
- *   The parameters passed to the process.
+ * @param setting
+ *   The main program setting data.
  *
  * @return
  *   F_none on success.
@@ -98,12 +98,61 @@ extern "C" {
  *   F_false on success when performing verification and verify failed.
  *   F_interrupt on (exit) signal received.
  *
- *   Status codes (with error bit) are returned on any problem.
+ *   F_parameter (with error bit) If main is NULL or setting is NULL.
  */
 #ifndef _di_utf8_main_
-  extern f_status_t utf8_main(fll_program_data_t * const main, const f_console_arguments_t *arguments);
+  extern f_status_t utf8_main(fll_program_data_t * const main, utf8_main_setting_t * const setting);
 #endif // _di_utf8_main_
 
+/**
+ * Delete the program main setting data.
+ *
+ * @param setting
+ *   The program main setting data.
+ *
+ * @return
+ *   F_none on success.
+ */
+#ifndef _di_utf8_main_setting_delete_
+  extern f_status_t utf8_main_setting_delete(utf8_main_setting_t * const setting);
+#endif // _di_utf8_main_setting_delete_
+
+/**
+ * Perform the standard program setting load process.
+ *
+ * @param arguments
+ *   The parameters passed to the process (often referred to as command line arguments).
+ * @param main
+ *   The main program data.
+ * @param setting
+ *   The main program setting data.
+ *
+ * @return
+ *   F_none on success.
+ *
+ *   Errors (with error bit) from: fll_program_parameter_process().
+ *
+ * @see fll_program_parameter_process()
+ */
+#ifndef _di_utf8_main_setting_load_
+  extern f_status_t utf8_main_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, utf8_main_setting_t * const setting);
+#endif // _di_utf8_main_setting_load_
+
+/**
+ * Perform the standard program setting unload process.
+ *
+ * @param main
+ *   The main program data.
+ * @param setting
+ *   The main program setting data.
+ *
+ * @return
+ *   F_none on success.
+ */
+#ifndef _di_utf8_main_setting_unload_
+  extern f_status_t utf8_main_setting_unload(fll_program_data_t * const main, utf8_main_setting_t * const setting);
+#endif // _di_utf8_main_setting_unload_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif