From: Kevin Day Date: Thu, 23 Jan 2025 07:02:18 +0000 (-0600) Subject: Progress: Continue working on completing the remove program. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=91156943592ece338ff5b51b9bba29b6b127c4ae;p=kevux-tools Progress: Continue working on completing the remove program. 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. --- diff --git a/data/build/stand_alone/configs/remove-config.h b/data/build/stand_alone/configs/remove-config.h index 726d776..7fd66e3 100644 --- a/data/build/stand_alone/configs/remove-config.h +++ b/data/build/stand_alone/configs/remove-config.h @@ -1754,6 +1754,7 @@ //#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_ diff --git a/data/build/stand_alone/configs/tacocat-config.h b/data/build/stand_alone/configs/tacocat-config.h index 9073419..575c89c 100644 --- a/data/build/stand_alone/configs/tacocat-config.h +++ b/data/build/stand_alone/configs/tacocat-config.h @@ -2005,6 +2005,7 @@ //#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_ diff --git a/sources/c/program/kevux/tools/remove/main/common.c b/sources/c/program/kevux/tools/remove/main/common.c index 802ee47..36c2c72 100644 --- a/sources/c/program/kevux/tools/remove/main/common.c +++ b/sources/c/program/kevux/tools/remove/main/common.c @@ -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). diff --git a/sources/c/program/kevux/tools/remove/main/common/define.h b/sources/c/program/kevux/tools/remove/main/common/define.h index ccdf623..b5b1fb9 100644 --- a/sources/c/program/kevux/tools/remove/main/common/define.h +++ b/sources/c/program/kevux/tools/remove/main/common/define.h @@ -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_ /** diff --git a/sources/c/program/kevux/tools/remove/main/common/print.c b/sources/c/program/kevux/tools/remove/main/common/print.c index 9174dcc..6c6cab4 100644 --- a/sources/c/program/kevux/tools/remove/main/common/print.c +++ b/sources/c/program/kevux/tools/remove/main/common/print.c @@ -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", diff --git a/sources/c/program/kevux/tools/remove/main/common/print.h b/sources/c/program/kevux/tools/remove/main/common/print.h index c7a7296..83d74fd 100644 --- a/sources/c/program/kevux/tools/remove/main/common/print.h +++ b/sources/c/program/kevux/tools/remove/main/common/print.h @@ -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, diff --git a/sources/c/program/kevux/tools/remove/main/common/type.h b/sources/c/program/kevux/tools/remove/main/common/type.h index 4d0ca34..ab1d8ce 100644 --- a/sources/c/program/kevux/tools/remove/main/common/type.h +++ b/sources/c/program/kevux/tools/remove/main/common/type.h @@ -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. diff --git a/sources/c/program/kevux/tools/remove/main/operate.c b/sources/c/program/kevux/tools/remove/main/operate.c index 76742e2..6ced5dc 100644 --- a/sources/c/program/kevux/tools/remove/main/operate.c +++ b/sources/c/program/kevux/tools/remove/main/operate.c @@ -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; diff --git a/sources/c/program/kevux/tools/remove/main/remove.c b/sources/c/program/kevux/tools/remove/main/remove.c index 0be2b55..d42b992 100644 --- a/sources/c/program/kevux/tools/remove/main/remove.c +++ b/sources/c/program/kevux/tools/remove/main/remove.c @@ -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; } diff --git a/sources/c/program/kevux/tools/remove/main/signal.c b/sources/c/program/kevux/tools/remove/main/signal.c index dc8aaa7..1d1a708 100644 --- a/sources/c/program/kevux/tools/remove/main/signal.c +++ b/sources/c/program/kevux/tools/remove/main/signal.c @@ -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; } } diff --git a/sources/c/program/kevux/tools/tacocat/main/common/type.h b/sources/c/program/kevux/tools/tacocat/main/common/type.h index c47a9aa..f1e11e2 100644 --- a/sources/c/program/kevux/tools/tacocat/main/common/type.h +++ b/sources/c/program/kevux/tools/tacocat/main/common/type.h @@ -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, \ diff --git a/sources/c/program/kevux/tools/tacocat/main/signal.c b/sources/c/program/kevux/tools/tacocat/main/signal.c index 6ef9a1a..b3db7fa 100644 --- a/sources/c/program/kevux/tools/tacocat/main/signal.c +++ b/sources/c/program/kevux/tools/tacocat/main/signal.c @@ -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; } }