]> Kevux Git Server - kevux-tools/commitdiff
Progress: Continue working on completing the remove program.
authorKevin Day <Kevin@kevux.org>
Thu, 23 Jan 2025 07:02:18 +0000 (01:02 -0600)
committerKevin Day <Kevin@kevux.org>
Thu, 23 Jan 2025 07:02:18 +0000 (01:02 -0600)
A good portion of the settings loader is simplified.

Swithc to using `fl_path_clean()` instead of `fl_path_canonical()`.
I find the shorter paths more convenient at this time than the full canonical ones.
I may add a custom option in the future that toggles on canonical paths.

Update to the latest signal handling logic.

12 files changed:
data/build/stand_alone/configs/remove-config.h
data/build/stand_alone/configs/tacocat-config.h
sources/c/program/kevux/tools/remove/main/common.c
sources/c/program/kevux/tools/remove/main/common/define.h
sources/c/program/kevux/tools/remove/main/common/print.c
sources/c/program/kevux/tools/remove/main/common/print.h
sources/c/program/kevux/tools/remove/main/common/type.h
sources/c/program/kevux/tools/remove/main/operate.c
sources/c/program/kevux/tools/remove/main/remove.c
sources/c/program/kevux/tools/remove/main/signal.c
sources/c/program/kevux/tools/tacocat/main/common/type.h
sources/c/program/kevux/tools/tacocat/main/signal.c

index 726d7767812ae8330819783ad212e9bee01043e8..7fd66e3da7d94363d137b17c5526dd79951c7756 100644 (file)
 //#define _di_fll_program_standard_set_down_
 //#define _di_fll_program_standard_set_up_
 //#define _di_fll_program_standard_signal_handle_
-#define _di_fll_program_standard_signal_received_
+//#define _di_fll_program_standard_signal_received_
+//#define _di_fll_program_standard_signal_received_wait_
 #define _di_private_inline_f_print_to_error_
 #define _di_private_inline_private_f_print_to_error_
index 90734194dc3076951f36eee3b2b33b7509269a94..575c89c05b94902481d6eae222cfe5bf6ec758c9 100644 (file)
 //#define _di_fll_program_standard_set_down_
 //#define _di_fll_program_standard_set_up_
 //#define _di_fll_program_standard_signal_handle_
-#define _di_fll_program_standard_signal_received_
+//#define _di_fll_program_standard_signal_received_
+//#define _di_fll_program_standard_signal_received_wait_
 #define _di_private_inline_f_print_to_error_
 #define _di_private_inline_private_f_print_to_error_
index 802ee47c1b03d4786d0c19377f8eb86ce3e8d4d0..36c2c7216f1b3c31aae375338a935174b19aadb0 100644 (file)
@@ -69,109 +69,69 @@ extern "C" {
 
     uint8_t j = 0;
 
+    main->setting.flag &= ~kt_remove_main_flag_version_copyright_help_d;
+
     if (main->program.parameters.array[kt_remove_parameter_help_e].result & f_console_result_found_e) {
       main->setting.flag |= kt_remove_main_flag_help_d;
     }
-    else {
-      main->setting.flag -= main->setting.flag & kt_remove_main_flag_help_d;
-    }
 
     if (main->program.parameters.array[kt_remove_parameter_version_e].result & f_console_result_found_e) {
       main->setting.flag |= kt_remove_main_flag_version_d;
     }
-    else {
-      main->setting.flag -= main->setting.flag & kt_remove_main_flag_version_d;
-    }
 
     if (main->program.parameters.array[kt_remove_parameter_copyright_e].result & f_console_result_found_e) {
       main->setting.flag |= kt_remove_main_flag_copyright_d;
     }
-    else {
-      main->setting.flag -= main->setting.flag & kt_remove_main_flag_copyright_d;
-    }
 
     if (main->program.parameters.array[kt_remove_parameter_block_e].result & f_console_result_found_e) {
-      main->setting.flag |= kt_remove_main_flag_block_d;
-      main->setting.flag |= kt_remove_main_flag_option_used_d;
+      main->setting.flag |= kt_remove_main_flag_block_d | kt_remove_main_flag_option_used_d;
     }
 
     if (main->program.parameters.array[kt_remove_parameter_character_e].result & f_console_result_found_e) {
-      main->setting.flag |= kt_remove_main_flag_character_d;
-      main->setting.flag |= kt_remove_main_flag_option_used_d;
+      main->setting.flag |= kt_remove_main_flag_character_d | kt_remove_main_flag_option_used_d;
     }
 
     if (main->program.parameters.array[kt_remove_parameter_different_e].result & f_console_result_found_e) {
+      main->setting.flag &= ~kt_remove_main_flag_same_d;
+      main->setting.flag |= kt_remove_main_flag_different_d | kt_remove_main_flag_option_used_d;
+
       if (main->program.parameters.array[kt_remove_parameter_same_e].result & f_console_result_found_e) {
         index = main->program.parameters.array[kt_remove_parameter_different_e].locations.used;
         index2 = main->program.parameters.array[kt_remove_parameter_same_e].locations.used;
 
-        if (main->program.parameters.array[kt_remove_parameter_different_e].locations.array[index] > main->program.parameters.array[kt_remove_parameter_same_e].locations.array[index2]) {
-          main->setting.flag |= kt_remove_main_flag_different_d;
-
-          if (main->setting.flag & kt_remove_main_flag_same_d) {
-            main->setting.flag -= kt_remove_main_flag_same_d;
-          }
-        }
-        else {
+        if (main->program.parameters.array[kt_remove_parameter_different_e].locations.array[index] < main->program.parameters.array[kt_remove_parameter_same_e].locations.array[index2]) {
+          main->setting.flag &= ~kt_remove_main_flag_different_d;
           main->setting.flag |= kt_remove_main_flag_same_d;
-
-          if (main->setting.flag & kt_remove_main_flag_different_d) {
-            main->setting.flag -= kt_remove_main_flag_different_d;
-          }
         }
       }
-      else {
-        main->setting.flag |= kt_remove_main_flag_different_d;
-
-        if (main->setting.flag & kt_remove_main_flag_same_d) {
-          main->setting.flag -= kt_remove_main_flag_same_d;
-        }
-      }
-
-      main->setting.flag |= kt_remove_main_flag_option_used_d;
     }
     else if (main->program.parameters.array[kt_remove_parameter_same_e].result & f_console_result_found_e) {
-      main->setting.flag |= kt_remove_main_flag_same_d;
-
-      if (main->setting.flag & kt_remove_main_flag_different_d) {
-        main->setting.flag -= kt_remove_main_flag_different_d;
-      }
-
-      main->setting.flag |= kt_remove_main_flag_option_used_d;
+      main->setting.flag &= ~kt_remove_main_flag_different_d;
+      main->setting.flag |= kt_remove_main_flag_same_d | kt_remove_main_flag_option_used_d;
     }
 
     if (main->program.parameters.array[kt_remove_parameter_fifo_e].result & f_console_result_found_e) {
-      main->setting.flag |= kt_remove_main_flag_fifo_d;
-      main->setting.flag |= kt_remove_main_flag_option_used_d;
+      main->setting.flag |= kt_remove_main_flag_fifo_d | kt_remove_main_flag_option_used_d;
     }
 
     if (main->program.parameters.array[kt_remove_parameter_follow_e].result & f_console_result_found_e) {
+      main->setting.flag |= kt_remove_main_flag_follow_d;
+
       if (main->program.parameters.array[kt_remove_parameter_stay_e].result & f_console_result_found_e) {
         index = main->program.parameters.array[kt_remove_parameter_follow_e].locations.used;
         index2 = main->program.parameters.array[kt_remove_parameter_stay_e].locations.used;
 
-        if (main->program.parameters.array[kt_remove_parameter_follow_e].locations.array[index] > main->program.parameters.array[kt_remove_parameter_stay_e].locations.array[index2]) {
-          main->setting.flag |= kt_remove_main_flag_follow_d;
-        }
-        else {
-          if (main->setting.flag & kt_remove_main_flag_follow_d) {
-            main->setting.flag -= kt_remove_main_flag_follow_d;
-          }
+        if (main->program.parameters.array[kt_remove_parameter_follow_e].locations.array[index] < main->program.parameters.array[kt_remove_parameter_stay_e].locations.array[index2]) {
+          main->setting.flag &= ~kt_remove_main_flag_follow_d;
         }
       }
-      else {
-        main->setting.flag |= kt_remove_main_flag_follow_d;
-      }
     }
     else if (main->program.parameters.array[kt_remove_parameter_stay_e].result & f_console_result_found_e) {
-      if (main->setting.flag & kt_remove_main_flag_follow_d) {
-        main->setting.flag -= kt_remove_main_flag_follow_d;
-      }
+      main->setting.flag &= ~kt_remove_main_flag_follow_d;
     }
 
     if (main->program.parameters.array[kt_remove_parameter_directory_e].result & f_console_result_found_e) {
-      main->setting.flag |= kt_remove_main_flag_directory_d;
-      main->setting.flag |= kt_remove_main_flag_option_used_d;
+      main->setting.flag |= kt_remove_main_flag_directory_d | kt_remove_main_flag_option_used_d;
     }
 
     if (main->program.parameters.array[kt_remove_parameter_force_e].result & f_console_result_found_e) {
@@ -179,8 +139,7 @@ extern "C" {
     }
 
     if (main->program.parameters.array[kt_remove_parameter_link_e].result & f_console_result_found_e) {
-      main->setting.flag |= kt_remove_main_flag_link_d;
-      main->setting.flag |= kt_remove_main_flag_option_used_d;
+      main->setting.flag |= kt_remove_main_flag_link_d | kt_remove_main_flag_option_used_d;
     }
 
     if (main->program.parameters.array[kt_remove_parameter_recurse_e].result & f_console_result_found_e) {
@@ -188,8 +147,7 @@ extern "C" {
     }
 
     if (main->program.parameters.array[kt_remove_parameter_regular_e].result & f_console_result_found_e) {
-      main->setting.flag |= kt_remove_main_flag_regular_d;
-      main->setting.flag |= kt_remove_main_flag_option_used_d;
+      main->setting.flag |= kt_remove_main_flag_regular_d | kt_remove_main_flag_option_used_d;
     }
 
     if (main->program.parameters.array[kt_remove_parameter_simulate_e].result & f_console_result_found_e) {
@@ -197,8 +155,7 @@ extern "C" {
     }
 
     if (main->program.parameters.array[kt_remove_parameter_socket_e].result & f_console_result_found_e) {
-      main->setting.flag |= kt_remove_main_flag_socket_d;
-      main->setting.flag |= kt_remove_main_flag_option_used_d;
+      main->setting.flag |= kt_remove_main_flag_socket_d | kt_remove_main_flag_option_used_d;
     }
 
     if (main->program.parameters.array[kt_remove_parameter_tree_e].result & f_console_result_found_e) {
@@ -343,65 +300,20 @@ extern "C" {
 
         index = main->program.parameters.array[kt_remove_parameter_empty_e].values.array[total_arguments - 1];
 
+        main->setting.flag &= ~kt_remove_main_flag_empty_all_d;
+        main->setting.flag |= kt_remove_main_flag_option_used_d;
+
         if (f_compare_dynamic(kt_remove_not_s, main->program.parameters.arguments.array[index]) == F_equal_to) {
           main->setting.flag |= kt_remove_main_flag_empty_not_d;
-
-          if (main->setting.flag & kt_remove_main_flag_empty_not_fail_d) {
-            main->setting.flag -= kt_remove_main_flag_empty_not_fail_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_empty_only_d) {
-            main->setting.flag -= kt_remove_main_flag_empty_only_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_empty_only_fail_d) {
-            main->setting.flag -= kt_remove_main_flag_empty_only_fail_d;
-          }
         }
         else if (f_compare_dynamic(kt_remove_not_fail_s, main->program.parameters.arguments.array[index]) == F_equal_to) {
           main->setting.flag |= kt_remove_main_flag_empty_not_fail_d;
-
-          if (main->setting.flag & kt_remove_main_flag_empty_not_d) {
-            main->setting.flag -= kt_remove_main_flag_empty_not_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_empty_only_d) {
-            main->setting.flag -= kt_remove_main_flag_empty_only_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_empty_only_fail_d) {
-            main->setting.flag -= kt_remove_main_flag_empty_only_fail_d;
-          }
         }
         else if (f_compare_dynamic(kt_remove_only_s, main->program.parameters.arguments.array[index]) == F_equal_to) {
           main->setting.flag |= kt_remove_main_flag_empty_only_d;
-
-          if (main->setting.flag & kt_remove_main_flag_empty_not_d) {
-            main->setting.flag -= kt_remove_main_flag_empty_not_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_empty_not_fail_d) {
-            main->setting.flag -= kt_remove_main_flag_empty_not_fail_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_empty_only_fail_d) {
-            main->setting.flag -= kt_remove_main_flag_empty_only_fail_d;
-          }
         }
         else if (f_compare_dynamic(kt_remove_only_fail_s, main->program.parameters.arguments.array[index]) == F_equal_to) {
           main->setting.flag |= kt_remove_main_flag_empty_only_fail_d;
-
-          if (main->setting.flag & kt_remove_main_flag_empty_not_d) {
-            main->setting.flag -= kt_remove_main_flag_empty_not_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_empty_not_fail_d) {
-            main->setting.flag -= kt_remove_main_flag_empty_not_fail_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_empty_only_d) {
-            main->setting.flag -= kt_remove_main_flag_empty_only_d;
-          }
         }
         else {
           main->setting.state.status = F_status_set_error(F_parameter);
@@ -410,8 +322,6 @@ extern "C" {
 
           return;
         }
-
-        main->setting.flag |= kt_remove_main_flag_option_used_d;
       }
       else {
         main->setting.state.status = F_status_set_error(F_parameter);
@@ -457,8 +367,7 @@ extern "C" {
           ++main->setting.groups.used;
         } // for
 
-        main->setting.flag |= kt_remove_main_flag_group_d;
-        main->setting.flag |= kt_remove_main_flag_option_used_d;
+        main->setting.flag |= kt_remove_main_flag_group_d | kt_remove_main_flag_option_used_d;
       }
       else {
         main->setting.state.status = F_status_set_error(F_parameter);
@@ -492,7 +401,7 @@ extern "C" {
           }
         }
 
-        uint8_t enumerations[] = {
+        const uint8_t enumerations[] = {
           kt_remove_flag_mode_different_d,
           kt_remove_flag_mode_same_d,
           kt_remove_flag_mode_similar_d,
@@ -503,7 +412,7 @@ extern "C" {
           kt_remove_flag_mode_not_d,
         };
 
-        f_string_static_t strings[] = {
+        const f_string_static_t strings[] = {
           kt_remove_mode_symbol_different_s,
           kt_remove_mode_symbol_same_s,
           kt_remove_mode_symbol_similar_s,
@@ -545,8 +454,7 @@ extern "C" {
           }
         } // for
 
-        main->setting.flag |= kt_remove_main_flag_mode_d;
-        main->setting.flag |= kt_remove_main_flag_option_used_d;
+        main->setting.flag |= kt_remove_main_flag_mode_d | kt_remove_main_flag_option_used_d;
       }
       else {
         main->setting.state.status = F_status_set_error(F_parameter);
@@ -592,8 +500,7 @@ extern "C" {
           ++main->setting.users.used;
         } // for
 
-        main->setting.flag |= kt_remove_main_flag_user_d;
-        main->setting.flag |= kt_remove_main_flag_option_used_d;
+        main->setting.flag |= kt_remove_main_flag_user_d | kt_remove_main_flag_option_used_d;
       }
       else {
         main->setting.state.status = F_status_set_error(F_parameter);
@@ -618,65 +525,19 @@ extern "C" {
 
         index = main->program.parameters.array[kt_remove_parameter_prompt_e].values.array[total_arguments - 1];
 
+        main->setting.flag &= ~kt_remove_main_flag_prompt_all_d;
+
         if (f_compare_dynamic(kt_remove_all_s, main->program.parameters.arguments.array[index]) == F_equal_to) {
           main->setting.flag |= kt_remove_main_flag_prompt_each_d;
-
-          if (main->setting.flag & kt_remove_main_flag_prompt_follow_d) {
-            main->setting.flag -= kt_remove_main_flag_prompt_follow_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_prompt_once_d) {
-            main->setting.flag -= kt_remove_main_flag_prompt_once_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_prompt_never_d) {
-            main->setting.flag -= kt_remove_main_flag_prompt_never_d;
-          }
         }
         else if (f_compare_dynamic(kt_remove_follow_s, main->program.parameters.arguments.array[index]) == F_equal_to) {
           main->setting.flag |= kt_remove_main_flag_prompt_follow_d;
-
-          if (main->setting.flag & kt_remove_main_flag_prompt_each_d) {
-            main->setting.flag -= kt_remove_main_flag_prompt_each_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_prompt_once_d) {
-            main->setting.flag -= kt_remove_main_flag_prompt_once_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_prompt_never_d) {
-            main->setting.flag -= kt_remove_main_flag_prompt_never_d;
-          }
         }
         else if (f_compare_dynamic(kt_remove_once_s, main->program.parameters.arguments.array[index]) == F_equal_to) {
           main->setting.flag |= kt_remove_main_flag_prompt_once_d;
-
-          if (main->setting.flag & kt_remove_main_flag_prompt_each_d) {
-            main->setting.flag -= kt_remove_main_flag_prompt_each_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_prompt_follow_d) {
-            main->setting.flag -= kt_remove_main_flag_prompt_follow_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_prompt_never_d) {
-            main->setting.flag -= kt_remove_main_flag_prompt_never_d;
-          }
         }
         else if (f_compare_dynamic(kt_remove_never_s, main->program.parameters.arguments.array[index]) == F_equal_to) {
           main->setting.flag |= kt_remove_main_flag_prompt_never_d;
-
-          if (main->setting.flag & kt_remove_main_flag_prompt_each_d) {
-            main->setting.flag -= kt_remove_main_flag_prompt_each_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_prompt_follow_d) {
-            main->setting.flag -= kt_remove_main_flag_prompt_follow_d;
-          }
-
-          if (main->setting.flag & kt_remove_main_flag_prompt_once_d) {
-            main->setting.flag -= kt_remove_main_flag_prompt_once_d;
-          }
         }
         else {
           main->setting.state.status = F_status_set_error(F_parameter);
@@ -696,29 +557,20 @@ extern "C" {
     }
 
     if (main->program.parameters.array[kt_remove_parameter_utc_e].result & f_console_result_found_e) {
+      main->setting.flag |= kt_remove_main_flag_utc_d;
 
       // Use the right most parameter when both --utc and --local are passed.
       if (main->program.parameters.array[kt_remove_parameter_local_e].result & f_console_result_found_e) {
-        const f_number_unsigned_t last_local = main->program.parameters.array[kt_remove_parameter_local_e].locations.array[main->program.parameters.array[kt_remove_parameter_local_e].locations.used];
-        const f_number_unsigned_t last_utc = main->program.parameters.array[kt_remove_parameter_utc_e].locations.array[main->program.parameters.array[kt_remove_parameter_utc_e].locations.used];
+        index = main->program.parameters.array[kt_remove_parameter_local_e].locations.array[main->program.parameters.array[kt_remove_parameter_local_e].locations.used];
+        index2 = main->program.parameters.array[kt_remove_parameter_utc_e].locations.array[main->program.parameters.array[kt_remove_parameter_utc_e].locations.used];
 
-        if (last_local > kt_remove_parameter_utc_e) {
-          if (main->setting.flag & kt_remove_main_flag_utc_d) {
-            main->setting.flag -= kt_remove_main_flag_utc_d;
-          }
-        }
-        else {
-          main->setting.flag |= kt_remove_main_flag_utc_d;
+        if (index > index2) {
+          main->setting.flag &= ~kt_remove_main_flag_utc_d;
         }
       }
-      else {
-        main->setting.flag |= kt_remove_main_flag_utc_d;
-      }
     }
     else if (main->program.parameters.array[kt_remove_parameter_local_e].result & f_console_result_found_e) {
-      if (main->setting.flag & kt_remove_main_flag_utc_d) {
-        main->setting.flag -= kt_remove_main_flag_utc_d;
-      }
+      main->setting.flag &= ~kt_remove_main_flag_utc_d;
     }
 
     // Load all remaining files as static strings (setting size to 0).
index ccdf62364468e49ae0b8760f1409295c20403bb0..b5b1fb9f81cdc9ba3cc1625aa776838e244d293e 100644 (file)
@@ -244,6 +244,7 @@ extern "C" {
   #define kt_remove_main_flag_changed_d                0x10
   #define kt_remove_main_flag_different_d              0x20
   #define kt_remove_main_flag_directory_d              0x40
+  #define kt_remove_main_flag_empty_all_d              0x780
   #define kt_remove_main_flag_empty_only_d             0x80
   #define kt_remove_main_flag_empty_only_fail_d        0x100
   #define kt_remove_main_flag_empty_not_d              0x200
@@ -256,6 +257,7 @@ extern "C" {
   #define kt_remove_main_flag_link_d                   0x10000
   #define kt_remove_main_flag_mode_d                   0x20000
   #define kt_remove_main_flag_option_used_d            0x40000
+  #define kt_remove_main_flag_prompt_all_d             0x780000
   #define kt_remove_main_flag_prompt_each_d            0x80000
   #define kt_remove_main_flag_prompt_follow_d          0x100000
   #define kt_remove_main_flag_prompt_never_d           0x200000
@@ -271,9 +273,6 @@ extern "C" {
   #define kt_remove_main_flag_utc_d                    0x80000000
   #define kt_remove_main_flag_version_d                0x100000000
   #define kt_remove_main_flag_version_copyright_help_d 0x100008008
-
-  #define kt_remove_main_flag_empty_all_d (kt_remove_main_flag_empty_only_d | kt_remove_main_flag_empty_only_fail_d | kt_remove_main_flag_empty_not_d | kt_remove_main_flag_empty_not_fail_d)
-  #define kt_remove_main_flag_prompt_all_d (kt_remove_main_flag_prompt_each_d | kt_remove_main_flag_prompt_follow_d | kt_remove_main_flag_prompt_never_d | kt_remove_main_flag_prompt_once_d)
 #endif // _di_kt_remove_main_flag_e_
 
 /**
index 9174dccde9b4536b103029ad2048033d3e4d62ec..6c6cab4fde2f10b2c597f72b24ed3dc69a37e2e2 100644 (file)
@@ -18,7 +18,7 @@ extern "C" {
     "f_utf_is_whitespace",
     "fl_conversion_dynamic_partial_to_unsigned_detect",
     "fl_conversion_dynamic_to_unsigned_detect",
-    "fl_path_canonical",
+    "fl_path_clean",
     "fll_program_parameter_process_context",
     "fll_program_parameter_process_empty",
     "fll_program_parameter_process_verbosity",
index c7a7296cb388139047f6b3eb666846918a5372bd..83d74fd250562b0d717da6eef807b296d26c94e1 100644 (file)
@@ -51,7 +51,7 @@ extern "C" {
     kt_remove_f_f_utf_is_whitespace_e,
     kt_remove_f_fl_conversion_dynamic_partial_to_unsigned_detect_e,
     kt_remove_f_fl_conversion_dynamic_to_unsigned_detect_e,
-    kt_remove_f_fl_path_canonical_e,
+    kt_remove_f_fl_path_clean_e,
     kt_remove_f_fll_program_parameter_process_context_e,
     kt_remove_f_fll_program_parameter_process_empty_e,
     kt_remove_f_fll_program_parameter_process_verbosity_e,
index 4d0ca342422f3b49fee5aa67606671641933d7e3..ab1d8ceb954c6e9df0352b65655d09cb0748ca1e 100644 (file)
@@ -141,7 +141,7 @@ extern "C" {
  * The program cache.
  *
  * buffer: The generic buffer.
- * file:   The current file being processed (generally canonicalized).
+ * file:   The current file being processed (generally cleaned up).
  */
 #ifndef _di_kt_remove_cache_t_
   typedef struct {
@@ -170,7 +170,7 @@ extern "C" {
  * program_name:      The short name of the program.
  * program_name_long: The human friendly name of the program.
  *
- * files:  An array of file names (full paths to the files) to remove.
+ * files: An array of file names (full paths to the files) to remove.
  *
  * accessed: An array of last accessed dates used for comparison.
  * changed:  An array of changed on dates used for comparison.
index 76742e23428a75b7a4604b3ed8ca63995226126a..6ced5dc3eb6eafa1ec9155a6e3cf4f01aed81160 100644 (file)
@@ -15,7 +15,7 @@ extern "C" {
       return;
     }
 
-    if (main->program.signal_received) return;
+    if (kt_remove_signal_check(main)) return;
 
     const uint8_t flag = kt_remove_operate_file_simulate(main, path);
     if (F_status_is_error(main->setting.state.status)) return;
@@ -23,12 +23,12 @@ extern "C" {
     if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) {
       if (flag & kt_remove_flag_file_operate_directory_d) {
         kt_remove_operate_file_directory(main, path, flag);
-        if (F_status_is_error(main->setting.state.status)) return;
       }
       else {
         kt_remove_operate_file_normal(main, path, flag);
-        if (F_status_is_error(main->setting.state.status)) return;
       }
+
+      if (F_status_is_error(main->setting.state.status)) return;
     }
 
     main->setting.state.status = F_okay;
@@ -113,12 +113,12 @@ extern "C" {
 
         if (flag & kt_remove_flag_file_operate_directory_d) {
           kt_remove_operate_file_directory(main, name, flag);
-          if (F_status_is_error(main->setting.state.status)) return;
         }
         else {
           kt_remove_operate_file_normal(main, name, flag);
-          if (F_status_is_error(main->setting.state.status)) return;
         }
+
+        if (F_status_is_error(main->setting.state.status)) return;
       }
 
       return;
@@ -194,7 +194,7 @@ extern "C" {
       return 0;
     }
 
-    if (main->program.signal_received) return 0;
+    if (kt_remove_signal_check(main)) return 0;
 
     kt_remove_print_simulate_operate_file(&main->program.output, path);
 
@@ -224,7 +224,7 @@ extern "C" {
       return 0;
     }
 
-    if (main->program.signal_received) return 0;
+    if (kt_remove_signal_check(main)) return 0;
 
     f_number_unsigned_t i = 0;
     uint8_t flag = (main->setting.flag & kt_remove_main_flag_option_used_d) ? 0 : kt_remove_flag_file_operate_remove_d;
@@ -296,7 +296,7 @@ extern "C" {
     if (main->setting.flag & kt_remove_main_flag_user_d) {
       for (i = 0; i < main->setting.users.used; ++i) {
 
-        if (main->program.signal_received) return flag;
+        if (kt_remove_signal_check(main)) return flag;
         if (statistics.st_uid == (uid_t) main->setting.users.array[i]) break;
       } // for
 
@@ -320,7 +320,7 @@ extern "C" {
     if (main->setting.flag & kt_remove_main_flag_group_d) {
       for (i = 0; i < main->setting.groups.used; ++i) {
 
-        if (main->program.signal_received) return flag;
+        if (kt_remove_signal_check(main)) return flag;
         if (statistics.st_gid == (gid_t) main->setting.groups.array[i]) break;
       } // for
 
@@ -334,7 +334,7 @@ extern "C" {
 
       for (i = 0; i < main->setting.modes.used; ++i) {
 
-        if (main->program.signal_received) return flag;
+        if (kt_remove_signal_check(main)) return flag;
 
         if (main->setting.modes.array[i].type == kt_remove_flag_mode_different_d) {
           if (main->setting.modes.array[i].mode & ~mode) break;
index 0be2b55f09fe198bfb7002c22fffe614a4cb2819..d42b9920f21f05c85f76e6d1b4035da195662eb8 100644 (file)
@@ -29,14 +29,11 @@ extern "C" {
 
     if (main->setting.process_normal) {
       main->setting.process_normal(main);
-      if (F_status_is_error(main->setting.state.status)) return;
     }
 
-    if (main->program.signal_received) {
+    if (kt_remove_signal_check(main)) {
       main->setting.state.status = F_status_set_error(F_interrupt);
-    }
 
-    if (main->setting.state.status == F_status_set_error(F_interrupt)) {
       fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
     }
   }
@@ -61,10 +58,10 @@ extern "C" {
 
       main->cache.file.used = 0;
 
-      fl_path_canonical(main->setting.files.array[i], &main->cache.file);
+      fl_path_clean(main->setting.files.array[i], &main->cache.file);
 
       if (F_status_is_error(main->setting.state.status)) {
-        kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(fl_path_canonical), main->setting.files.array[i], f_file_operation_process_s, fll_error_file_type_path_e);
+        kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(fl_path_clean), main->setting.files.array[i], f_file_operation_process_s, fll_error_file_type_path_e);
 
         break;
       }
index dc8aaa7d2cdc470c59ce5364aeb1657a6cd85c4f..1d1a708881bcae46dcc489ad2c4f4aacc0943912 100644 (file)
@@ -7,11 +7,11 @@ extern "C" {
 #if !defined(_di_kt_remove_signal_check_) && defined(_di_thread_support_)
   f_status_t kt_remove_signal_check(kt_remove_main_t * const main) {
 
-    if (!main) return F_false;
-    if (main->program.signal.id == -1) return F_false;
+    if (!main || main->program.signal.id == -1) return F_false;
+    if (main->program.signal_received) return F_true;
 
     if (!((++main->program.signal_check) % kt_remove_signal_check_d)) {
-      if (fll_program_standard_signal_received(&main->program)) return F_true;
+      if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interupt) return F_true;
 
       main->program.signal_check = 0;
     }
@@ -23,8 +23,7 @@ extern "C" {
 #if !defined(_di_kt_remove_signal_check_) && !defined(_di_thread_support_)
   f_status_t kt_remove_signal_check(kt_remove_main_t * const main) {
 
-    if (!main) return F_false;
-    if (main->program.signal.id == -1) return F_false;
+    if (!main || main->program.signal.id == -1) return F_false;
     if (main->program.signal_received) return F_true;
 
     return F_false;
@@ -36,13 +35,6 @@ extern "C" {
 
     if (!main) return;
 
-    siginfo_t information;
-    f_number_unsigned_t failsafe = 0;
-
-    memset(&information, 0, sizeof(siginfo_t));
-
-    main->program.signal_received = 0;
-
     f_signal_set_empty(&main->program.signal.set);
     f_signal_set_add(F_signal_abort, &main->program.signal.set);
     f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
@@ -52,44 +44,20 @@ extern "C" {
     f_signal_set_add(F_signal_termination, &main->program.signal.set);
 
     if (main->program.signal.id == -1) {
-      main->setting.status_thread = f_signal_open(&main->program.signal);
+      main->program.signal_status = f_signal_open(&main->program.signal);
 
-      if (F_status_is_error(main->setting.status_thread)) {
+      if (F_status_is_error(main->program.signal_status)) {
         main->program.signal_received = F_signal_abort;
 
         return;
       }
     }
 
-    do {
-      memset(&information, 0, sizeof(siginfo_t));
-
-      main->setting.status_thread = f_signal_wait(&main->program.signal.set, &information);
-
-      if (F_status_is_error(main->setting.status_thread) && F_status_set_fine(main->setting.status_thread) != F_interrupt) {
-        if (++failsafe >= kt_remove_signal_check_failsafe_d) break;
-      }
-
-      switch (information.si_signo) {
-        case F_signal_abort:
-        case F_signal_broken_pipe:
-        case F_signal_hangup:
-        case F_signal_interrupt:
-        case F_signal_quit:
-        case F_signal_termination:
-          main->program.signal_received = information.si_signo;
-
-          break;
-      }
-
-      failsafe = 0;
-      main->setting.status_thread = F_okay;
-
-    } while (!main->program.signal_received);
+    fll_program_standard_signal_received_wait(&main->program, kt_remove_signal_check_failsafe_d);
 
     f_signal_close(&main->program.signal);
 
-    if (F_status_is_error(main->setting.status_thread)) {
+    if (F_status_is_error(main->program.signal_status)) {
       main->program.signal_received = F_signal_abort;
     }
   }
index c47a9aaca6aaab33f6a563b394d99b28317a3968..f1e11e2496ded77179d14a923424303c41362148 100644 (file)
@@ -291,7 +291,6 @@ extern "C" {
  *
  * status_receive: A status used exclusively by the receive thread.
  * status_send:    A status used exclusively by the send thread.
- * status_signal:  A status used exclusively by the threaded signal handler.
  *
  * state: The state data used when processing data.
  *
@@ -312,7 +311,6 @@ extern "C" {
 
     f_status_t status_receive;
     f_status_t status_send;
-    f_status_t status_signal;
 
     f_state_t state;
 
@@ -333,7 +331,6 @@ extern "C" {
       0, \
       F_okay, \
       F_okay, \
-      F_okay, \
       macro_f_state_t_initialize_1(kt_tacocat_allocation_large_d, kt_tacocat_allocation_small_d, F_okay, 0, 0, &fll_program_standard_signal_handle, 0, 0, 0, 0), \
       f_polls_t_initialize, \
       f_polls_t_initialize, \
index 6ef9a1a6f140c8256f71fc738e750e75d976fc3c..b3db7fa021d2fa3e292af64ac62232cfb765ab3f 100644 (file)
@@ -7,10 +7,11 @@ extern "C" {
 #if !defined(_di_kt_tacocat_signal_check_) && defined(_di_thread_support_)
   f_status_t kt_tacocat_signal_check(kt_tacocat_main_t * const main) {
 
-    if (!main || main->program.signal.id == -1) return F_false;
+    if (!main) return F_false;
+    if (main->program.signal_received) return F_true;
 
     if (!((++main->program.signal_check) % kt_tacocat_signal_check_d)) {
-      if (fll_program_standard_signal_received(&main->program)) return F_true;
+      if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interupt) return F_true;
 
       main->program.signal_check = 0;
     }
@@ -34,13 +35,6 @@ extern "C" {
 
     if (!main) return;
 
-    siginfo_t information;
-    f_number_unsigned_t failsafe = 0;
-
-    memset(&information, 0, sizeof(siginfo_t));
-
-    main->program.signal_received = 0;
-
     f_signal_set_empty(&main->program.signal.set);
     f_signal_set_add(F_signal_abort, &main->program.signal.set);
     f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
@@ -49,45 +43,9 @@ extern "C" {
     f_signal_set_add(F_signal_quit, &main->program.signal.set);
     f_signal_set_add(F_signal_termination, &main->program.signal.set);
 
-    if (main->program.signal.id == -1) {
-      main->setting.status_signal = f_signal_open(&main->program.signal);
-
-      if (F_status_is_error(main->setting.status_signal)) {
-        main->program.signal_received = F_signal_abort;
-
-        return;
-      }
-    }
-
-    do {
-      memset(&information, 0, sizeof(siginfo_t));
-
-      main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
-      if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
-        if (++failsafe >= kt_tacocat_signal_check_failsafe_d) break;
-      }
-
-      switch (information.si_signo) {
-        case F_signal_abort:
-        case F_signal_broken_pipe:
-        case F_signal_hangup:
-        case F_signal_interrupt:
-        case F_signal_quit:
-        case F_signal_termination:
-          main->program.signal_received = information.si_signo;
-
-          break;
-      }
-
-      failsafe = 0;
-      main->setting.status_signal = F_okay;
-
-    } while (!main->program.signal_received);
-
-    f_signal_close(&main->program.signal);
+    fll_program_standard_signal_received_wait(&main->program, kt_tacocat_signal_check_failsafe_d);
 
-    if (F_status_is_error(main->setting.status_signal)) {
+    if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) {
       main->program.signal_received = F_signal_abort;
     }
   }