From 6595bdeea3b7b392892a511480f2fc56ea8136fa Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 30 Jul 2024 21:42:49 -0500 Subject: [PATCH] Refactor: Change bit-wise enumerations into defines. I did some reviewing of how the enumerations used for flags are used. These generally are not being used as a type. An enumeration slightly increases the resulting binary size. Enumeration values might be limited to just type of int. This seems like an easy (small) optimization to just use defines rather than enumerations for flags and other bit-wise numbers. --- sources/c/remove/main/common.c | 296 ++++++++++++++-------------- sources/c/remove/main/common.h | 2 +- sources/c/remove/main/common/define.h | 244 +++++++++++++++++++++-- sources/c/remove/main/common/enumeration.h | 223 --------------------- sources/c/remove/main/common/type.h | 2 +- sources/c/remove/main/convert.c | 62 +++--- sources/c/remove/main/main.c | 12 +- sources/c/remove/main/operate.c | 118 +++++------ sources/c/remove/main/print/simulate.c | 78 ++++---- sources/c/remove/main/print/simulate.h | 10 +- sources/c/remove/main/print/warning.c | 2 +- sources/c/remove/main/print/warning.h | 6 +- sources/c/remove/main/remove.c | 10 +- sources/c/tacocat/main/common.c | 42 ++-- sources/c/tacocat/main/common/define.h | 129 +++++++++++- sources/c/tacocat/main/common/enumeration.h | 112 ----------- sources/c/tacocat/main/common/type.h | 2 +- sources/c/tacocat/main/main.c | 10 +- sources/c/tacocat/main/packet.c | 8 +- sources/c/tacocat/main/process.c | 10 +- sources/c/tacocat/main/receive.c | 2 +- sources/c/tacocat/main/tacocat.c | 8 +- 22 files changed, 686 insertions(+), 702 deletions(-) diff --git a/sources/c/remove/main/common.c b/sources/c/remove/main/common.c index 357b449..ef64b89 100644 --- a/sources/c/remove/main/common.c +++ b/sources/c/remove/main/common.c @@ -49,7 +49,7 @@ extern "C" { if (!main) return; - main->setting.flag -= main->setting.flag & kt_remove_main_flag_option_used_e; + main->setting.flag -= main->setting.flag & kt_remove_main_flag_option_used_d; main->setting.state.step_small = kt_remove_allocation_console_d; @@ -110,34 +110,34 @@ extern "C" { uint8_t j = 0; if (main->program.parameters.array[kt_remove_parameter_help_e].result & f_console_result_found_e) { - main->setting.flag |= kt_remove_main_flag_help_e; + main->setting.flag |= kt_remove_main_flag_help_d; } else { - main->setting.flag -= main->setting.flag & kt_remove_main_flag_help_e; + 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_e; + main->setting.flag |= kt_remove_main_flag_version_d; } else { - main->setting.flag -= main->setting.flag & kt_remove_main_flag_version_e; + 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_e; + main->setting.flag |= kt_remove_main_flag_copyright_d; } else { - main->setting.flag -= main->setting.flag & kt_remove_main_flag_copyright_e; + 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_e; - main->setting.flag |= kt_remove_main_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_block_d; + main->setting.flag |= 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_e; - main->setting.flag |= kt_remove_main_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_character_d; + main->setting.flag |= kt_remove_main_flag_option_used_d; } if (main->program.parameters.array[kt_remove_parameter_different_e].result & f_console_result_found_e) { @@ -146,43 +146,43 @@ extern "C" { 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_e; + main->setting.flag |= kt_remove_main_flag_different_d; - if (main->setting.flag & kt_remove_main_flag_same_e) { - main->setting.flag -= kt_remove_main_flag_same_e; + if (main->setting.flag & kt_remove_main_flag_same_d) { + main->setting.flag -= kt_remove_main_flag_same_d; } } else { - main->setting.flag |= kt_remove_main_flag_same_e; + main->setting.flag |= kt_remove_main_flag_same_d; - if (main->setting.flag & kt_remove_main_flag_different_e) { - main->setting.flag -= kt_remove_main_flag_different_e; + 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_e; + main->setting.flag |= kt_remove_main_flag_different_d; - if (main->setting.flag & kt_remove_main_flag_same_e) { - main->setting.flag -= kt_remove_main_flag_same_e; + 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_e; + 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_e; + main->setting.flag |= kt_remove_main_flag_same_d; - if (main->setting.flag & kt_remove_main_flag_different_e) { - main->setting.flag -= kt_remove_main_flag_different_e; + 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_e; + main->setting.flag |= 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_e; - main->setting.flag |= kt_remove_main_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_fifo_d; + main->setting.flag |= kt_remove_main_flag_option_used_d; } if (main->program.parameters.array[kt_remove_parameter_follow_e].result & f_console_result_found_e) { @@ -191,53 +191,53 @@ extern "C" { 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_e; + main->setting.flag |= kt_remove_main_flag_follow_d; } else { - if (main->setting.flag & kt_remove_main_flag_follow_e) { - main->setting.flag -= kt_remove_main_flag_follow_e; + if (main->setting.flag & kt_remove_main_flag_follow_d) { + main->setting.flag -= kt_remove_main_flag_follow_d; } } } else { - main->setting.flag |= kt_remove_main_flag_follow_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_follow_e; + 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_force_e].result & f_console_result_found_e) { - main->setting.flag |= kt_remove_main_flag_force_e; + main->setting.flag |= kt_remove_main_flag_force_d; } if (main->program.parameters.array[kt_remove_parameter_link_e].result & f_console_result_found_e) { - main->setting.flag |= kt_remove_main_flag_link_e; - main->setting.flag |= kt_remove_main_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_link_d; + main->setting.flag |= kt_remove_main_flag_option_used_d; } if (main->program.parameters.array[kt_remove_parameter_recurse_e].result & f_console_result_found_e) { - main->setting.flag |= kt_remove_main_flag_recurse_e; + main->setting.flag |= kt_remove_main_flag_recurse_d; } if (main->program.parameters.array[kt_remove_parameter_regular_e].result & f_console_result_found_e) { - main->setting.flag |= kt_remove_main_flag_regular_e; - main->setting.flag |= kt_remove_main_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_regular_d; + main->setting.flag |= kt_remove_main_flag_option_used_d; } if (main->program.parameters.array[kt_remove_parameter_simulate_e].result & f_console_result_found_e) { - main->setting.flag |= kt_remove_main_flag_simulate_e; + main->setting.flag |= kt_remove_main_flag_simulate_d; } if (main->program.parameters.array[kt_remove_parameter_socket_e].result & f_console_result_found_e) { - main->setting.flag |= kt_remove_main_flag_socket_e; - main->setting.flag |= kt_remove_main_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_socket_d; + main->setting.flag |= kt_remove_main_flag_option_used_d; } if (main->program.parameters.array[kt_remove_parameter_tree_e].result & f_console_result_found_e) { - main->setting.flag |= kt_remove_main_flag_tree_e; + main->setting.flag |= kt_remove_main_flag_tree_d; } { @@ -293,18 +293,18 @@ extern "C" { } uint8_t enumerations[] = { - kt_remove_flag_date_equal_e, - kt_remove_flag_date_less_e, - kt_remove_flag_date_less_equal_e, - kt_remove_flag_date_more_e, - kt_remove_flag_date_more_equal_e, - kt_remove_flag_date_not_e, - kt_remove_flag_date_equal_e, - kt_remove_flag_date_less_e, - kt_remove_flag_date_less_equal_e, - kt_remove_flag_date_more_e, - kt_remove_flag_date_more_equal_e, - kt_remove_flag_date_not_e, + kt_remove_flag_date_equal_d, + kt_remove_flag_date_less_d, + kt_remove_flag_date_less_equal_d, + kt_remove_flag_date_more_d, + kt_remove_flag_date_more_equal_d, + kt_remove_flag_date_not_d, + kt_remove_flag_date_equal_d, + kt_remove_flag_date_less_d, + kt_remove_flag_date_less_equal_d, + kt_remove_flag_date_more_d, + kt_remove_flag_date_more_equal_d, + kt_remove_flag_date_not_d, }; f_string_static_t strings[] = { @@ -359,7 +359,7 @@ extern "C" { } // for } - main->setting.flag |= kt_remove_main_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_option_used_d; } // for } } @@ -387,63 +387,63 @@ extern "C" { index = main->program.parameters.array[kt_remove_parameter_empty_e].values.array[total_arguments - 1]; 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_e; + main->setting.flag |= kt_remove_main_flag_empty_not_d; - if (main->setting.flag & kt_remove_main_flag_empty_not_fail_e) { - main->setting.flag -= kt_remove_main_flag_empty_not_fail_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_empty_only_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_empty_only_fail_e; + 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_e; + main->setting.flag |= kt_remove_main_flag_empty_not_fail_d; - if (main->setting.flag & kt_remove_main_flag_empty_not_e) { - main->setting.flag -= kt_remove_main_flag_empty_not_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_empty_only_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_empty_only_fail_e; + 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_e; + main->setting.flag |= kt_remove_main_flag_empty_only_d; - if (main->setting.flag & kt_remove_main_flag_empty_not_e) { - main->setting.flag -= kt_remove_main_flag_empty_not_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_empty_not_fail_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_empty_only_fail_e; + 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_e; + main->setting.flag |= kt_remove_main_flag_empty_only_fail_d; - if (main->setting.flag & kt_remove_main_flag_empty_not_e) { - main->setting.flag -= kt_remove_main_flag_empty_not_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_empty_not_fail_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_empty_only_e; + if (main->setting.flag & kt_remove_main_flag_empty_only_d) { + main->setting.flag -= kt_remove_main_flag_empty_only_d; } } else { @@ -454,7 +454,7 @@ extern "C" { return; } - main->setting.flag |= kt_remove_main_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_option_used_d; } // kt_remove_parameter_group_e, needs additional parameters (gid). @@ -500,8 +500,8 @@ extern "C" { ++main->setting.groups.used; } // for - main->setting.flag |= kt_remove_main_flag_group_e; - main->setting.flag |= kt_remove_main_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_group_d; + main->setting.flag |= kt_remove_main_flag_option_used_d; } // kt_remove_parameter_isolate_e, needs additional parameters (all, ignore, or root). @@ -528,36 +528,36 @@ extern "C" { // index = main->program.parameters.array[kt_remove_parameter_isolate_e].values.array[total_arguments - 1]; // // if (f_compare_dynamic(kt_remove_all_s, main->program.parameters.arguments.array[index]) == F_equal_to) { - // main->setting.flag |= kt_remove_main_flag_isolate_all_e; + // main->setting.flag |= kt_remove_main_flag_isolate_all_d; // - // if (main->setting.flag & kt_remove_main_flag_isolate_ignore_e) { - // main->setting.flag -= kt_remove_main_flag_isolate_ignore_e; + // if (main->setting.flag & kt_remove_main_flag_isolate_ignore_d) { + // main->setting.flag -= kt_remove_main_flag_isolate_ignore_d; // } // - // if (main->setting.flag & kt_remove_main_flag_isolate_root_e) { - // main->setting.flag -= kt_remove_main_flag_isolate_root_e; + // if (main->setting.flag & kt_remove_main_flag_isolate_root_d) { + // main->setting.flag -= kt_remove_main_flag_isolate_root_d; // } // } // else if (f_compare_dynamic(kt_remove_ignore_s, main->program.parameters.arguments.array[index]) == F_equal_to) { - // main->setting.flag |= kt_remove_main_flag_isolate_ignore_e; + // main->setting.flag |= kt_remove_main_flag_isolate_ignore_d; // - // if (main->setting.flag & kt_remove_main_flag_isolate_all_e) { - // main->setting.flag -= kt_remove_main_flag_isolate_all_e; + // if (main->setting.flag & kt_remove_main_flag_isolate_all_d) { + // main->setting.flag -= kt_remove_main_flag_isolate_all_d; // } // - // if (main->setting.flag & kt_remove_main_flag_isolate_root_e) { - // main->setting.flag -= kt_remove_main_flag_isolate_root_e; + // if (main->setting.flag & kt_remove_main_flag_isolate_root_d) { + // main->setting.flag -= kt_remove_main_flag_isolate_root_d; // } // } // else if (f_compare_dynamic(kt_remove_root_s, main->program.parameters.arguments.array[index]) == F_equal_to) { - // main->setting.flag |= kt_remove_main_flag_isolate_root_e; + // main->setting.flag |= kt_remove_main_flag_isolate_root_d; // - // if (main->setting.flag & kt_remove_main_flag_isolate_all_e) { - // main->setting.flag -= kt_remove_main_flag_isolate_all_e; + // if (main->setting.flag & kt_remove_main_flag_isolate_all_d) { + // main->setting.flag -= kt_remove_main_flag_isolate_all_d; // } // - // if (main->setting.flag & kt_remove_main_flag_isolate_ignore_e) { - // main->setting.flag -= kt_remove_main_flag_isolate_ignore_e; + // if (main->setting.flag & kt_remove_main_flag_isolate_ignore_d) { + // main->setting.flag -= kt_remove_main_flag_isolate_ignore_d; // } // } // else { @@ -601,14 +601,14 @@ extern "C" { } uint8_t enumerations[] = { - kt_remove_flag_mode_different_e, - kt_remove_flag_mode_same_e, - kt_remove_flag_mode_similar_e, - kt_remove_flag_mode_not_e, - kt_remove_flag_mode_different_e, - kt_remove_flag_mode_same_e, - kt_remove_flag_mode_similar_e, - kt_remove_flag_mode_not_e, + kt_remove_flag_mode_different_d, + kt_remove_flag_mode_same_d, + kt_remove_flag_mode_similar_d, + kt_remove_flag_mode_not_d, + kt_remove_flag_mode_different_d, + kt_remove_flag_mode_same_d, + kt_remove_flag_mode_similar_d, + kt_remove_flag_mode_not_d, }; f_string_static_t strings[] = { @@ -653,8 +653,8 @@ extern "C" { } } // for - main->setting.flag |= kt_remove_main_flag_mode_e; - main->setting.flag |= kt_remove_main_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_mode_d; + main->setting.flag |= kt_remove_main_flag_option_used_d; } // kt_remove_parameter_user_e, needs additional parameters. @@ -700,8 +700,8 @@ extern "C" { ++main->setting.users.used; } // for - main->setting.flag |= kt_remove_main_flag_user_e; - main->setting.flag |= kt_remove_main_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_user_d; + main->setting.flag |= kt_remove_main_flag_option_used_d; } // kt_remove_parameter_prompt_e, needs additional parameters (all, follow, once). @@ -727,63 +727,63 @@ extern "C" { index = main->program.parameters.array[kt_remove_parameter_prompt_e].values.array[total_arguments - 1]; 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_all_e; + main->setting.flag |= kt_remove_main_flag_prompt_each_d; - if (main->setting.flag & kt_remove_main_flag_prompt_follow_e) { - main->setting.flag -= kt_remove_main_flag_prompt_follow_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_prompt_once_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_prompt_never_e; + 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_e; + main->setting.flag |= kt_remove_main_flag_prompt_follow_d; - if (main->setting.flag & kt_remove_main_flag_prompt_all_e) { - main->setting.flag -= kt_remove_main_flag_prompt_all_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_prompt_once_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_prompt_never_e; + 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_e; + main->setting.flag |= kt_remove_main_flag_prompt_once_d; - if (main->setting.flag & kt_remove_main_flag_prompt_all_e) { - main->setting.flag -= kt_remove_main_flag_prompt_all_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_prompt_follow_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_prompt_never_e; + 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_e; + main->setting.flag |= kt_remove_main_flag_prompt_never_d; - if (main->setting.flag & kt_remove_main_flag_prompt_all_e) { - main->setting.flag -= kt_remove_main_flag_prompt_all_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_prompt_follow_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_prompt_once_e; + if (main->setting.flag & kt_remove_main_flag_prompt_once_d) { + main->setting.flag -= kt_remove_main_flag_prompt_once_d; } } else { @@ -803,21 +803,21 @@ extern "C" { 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]; if (last_local > kt_remove_parameter_utc_e) { - if (main->setting.flag & kt_remove_main_flag_utc_e) { - main->setting.flag -= kt_remove_main_flag_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_e; + main->setting.flag |= kt_remove_main_flag_utc_d; } } else { - main->setting.flag |= kt_remove_main_flag_utc_e; + 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_e) { - main->setting.flag -= kt_remove_main_flag_utc_e; + if (main->setting.flag & kt_remove_main_flag_utc_d) { + main->setting.flag -= kt_remove_main_flag_utc_d; } } diff --git a/sources/c/remove/main/common.h b/sources/c/remove/main/common.h index d92ffbc..efe1100 100644 --- a/sources/c/remove/main/common.h +++ b/sources/c/remove/main/common.h @@ -68,7 +68,7 @@ extern "C" { * @param main * The main program and settings data. * - * The setting.flag has kt_remove_flag_option_used_e forcibly cleared on the start of this function. + * The setting.flag has kt_remove_flag_option_used_d forcibly cleared on the start of this function. * * This alters setting.status: * F_okay on success. diff --git a/sources/c/remove/main/common/define.h b/sources/c/remove/main/common/define.h index ca23a9a..3b060c1 100644 --- a/sources/c/remove/main/common/define.h +++ b/sources/c/remove/main/common/define.h @@ -22,11 +22,6 @@ extern "C" { * Leap Year: * - If can be evenly divided by 4, then this is a leap year. (@fixme relocate or move "Leap Year" comments where appropriate.) * - * kt_remove_allocation_*_d: - * - console: An allocation step used for small buffers specifically for console parameter. - * - large: An allocation step used for buffers that are anticipated to have large buffers. - * - small: An allocation step used for buffers that are anticipated to have small buffers. - * * kt_remove_depth_*_d: * - max: The maximum recursion depth to perform when recursing into a directory. * @@ -46,10 +41,6 @@ extern "C" { * - unix_epoch: The year in which the UNIX Epoch starts. */ #ifndef _di_kt_remove_d_ - #define kt_remove_allocation_console_d 4 - #define kt_remove_allocation_large_d 2048 - #define kt_remove_allocation_small_d 128 - #define kt_remove_depth_max_d F_directory_max_recurse_depth_d #define kt_remove_signal_check_d 20000 @@ -66,19 +57,123 @@ extern "C" { #endif // _di_kt_remove_d_ /** - * Defines for bitwise flag enumeration combinations. + * The program allocation defines. * - * kt_remove_main_flag_empty_*_d: - * - all: All empty flag bits are combined. + * control_allocation_*_d: + * - console: An allocation step used for small buffers specifically for console parameter. + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - pipe: A buffer size used for processing piped data. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_kt_remove_allocation_d_ + #define kt_remove_allocation_console_d 4 + #define kt_remove_allocation_large_d 2048 + #define kt_remove_allocation_pipe_d 16384 + #define kt_remove_allocation_small_d 8 +#endif // _di_kt_remove_allocation_d_ + +/** + * A set of flags used internally in the convert process. + * + * These are generally used during parsing of Time and EpochTime strings. * - * kt_remove_main_flag_prompt_*_d: - * - all: All prompt flag bits are combined. + * kt_remove_flag_convert_*_d: + * - colon: Either single or double colon. + * - colon_single: Single colon detected. + * - colon_double: Double colon detected. + * - match: Matched either part. + * - match_first: Matched first (left) part. + * - match_second: Matched second (right) part. */ -#ifndef _di_kt_remove_main_flag_d_ - #define kt_remove_main_flag_empty_all_d (kt_remove_main_flag_empty_only_e | kt_remove_main_flag_empty_only_fail_e | kt_remove_main_flag_empty_not_e | kt_remove_main_flag_empty_not_fail_e) +#ifndef _di_kt_remove_flag_convert_d_ + #define kt_remove_flag_convert_none_d 0x0 + #define kt_remove_flag_convert_colon_d 0x3 + #define kt_remove_flag_convert_colon_single_d 0x1 + #define kt_remove_flag_convert_colon_double_d 0x2 + #define kt_remove_flag_convert_match_d 0xc + #define kt_remove_flag_convert_match_first_d 0x4 + #define kt_remove_flag_convert_match_second_d 0x8 +#endif // _di_kt_remove_flag_convert_d_ - #define kt_remove_main_flag_prompt_all_d (kt_remove_main_flag_prompt_all_e | kt_remove_main_flag_prompt_follow_e | kt_remove_main_flag_prompt_never_e | kt_remove_main_flag_prompt_once_e) -#endif // _di_kt_remove_main_flag_d_ +/** + * Flags associated with a datetime. + * + * kt_remove_flag_date_*_d: + * - none: No flags set. + * - equal: Perform equal to on date, '==' or 'equal'. + * - less: Perform less than on date, '<' or 'less'. + * - less_equal: Perform less than or equal to on date, '<=' or 'less_equal'. + * - more: Perform greater than on date, '>' or 'more'. + * - more_equal: Perform greater than or equal to on date, '>=' or 'more_equal'. + * - not: Perform not equal to on date. '<>' or 'not' + * + * - year: Date has a year. + * - now: Date is relative to 'now'. + * - string: Date is processed via the string date functions (such as via strftime_r() or getdate_r()). + * - time: Date is based off of Time format. + * - time_epoch: Date is based off of EpochTime format. + * - today: Date is relative to 'today'. + * - tomorrow: Date is relative to 'tomorrow'. + * - unix: Date is based off of Unix Epoch format. + * - yesterday: Date is relative to 'yesterday'. + */ +#ifndef _di_kt_remove_flag_date_d_ + #define kt_remove_flag_date_none_d 0x0 + + // Used for comparisons. + #define kt_remove_flag_date_equal_d 0x1 + #define kt_remove_flag_date_less_d 0x2 + #define kt_remove_flag_date_less_equal_d 0x4 + #define kt_remove_flag_date_more_d 0x8 + #define kt_remove_flag_date_more_equal_d 0x10 + #define kt_remove_flag_date_not_d 0x20 + + // Used for processing and converting. + #define kt_remove_flag_date_now_d 0x1 + #define kt_remove_flag_date_string_d 0x2 + #define kt_remove_flag_date_time_d 0x4 + #define kt_remove_flag_date_time_epoch_d 0x8 + #define kt_remove_flag_date_today_d 0x10 + #define kt_remove_flag_date_tomorrow_d 0x20 + #define kt_remove_flag_date_unix_d 0x40 + #define kt_remove_flag_date_yesterday_d 0x80 +#endif // _di_kt_remove_flag_date_d_ + +/** + * Flags associated with performing an operation on a file. + * + * kt_remove_flag_file_operate_*_d: + * - none: No flags set. + * - directory: Is a directory. + * - follow: Follow the symbolic link. + * - recurse: Perform recursively (only on directories). + * - remove: Perform remove. + */ +#ifndef _di_kt_remove_flag_file_operate_d_ + #define kt_remove_flag_file_operate_none_d 0x0 + #define kt_remove_flag_file_operate_directory_d 0x1 + #define kt_remove_flag_file_operate_follow_d 0x2 + #define kt_remove_flag_file_operate_recurse_d 0x4 + #define kt_remove_flag_file_operate_remove_d 0x8 +#endif // _di_kt_remove_flag_file_operate_d_ + +/** + * Flags associated with a mode. + * + * kt_remove_flag_mode_*_e: + * - none: No flags set. + * - different: Remove by mode matching different parts ('~~' or 'different'). + * - same: Remove by exact mode match ('==' or 'same'). + * - similar: Remove by mode matching same parts ('~=' or 'similar'). + * - not: Remove by not exact mode match ('<>' or 'not'). + */ +#ifndef _di_kt_remove_flag_mode_d_ + #define kt_remove_flag_mode_none_d 0x0 + #define kt_remove_flag_mode_different_d 0x1 + #define kt_remove_flag_mode_same_d 0x2 + #define kt_remove_flag_mode_similar_d 0x4 + #define kt_remove_flag_mode_not_d 0x8 +#endif // _di_kt_remove_flag_mode_d_ /** * Defines for bitwise directory recurse flag enumeration combinations. @@ -90,6 +185,119 @@ extern "C" { #define kt_remove_flag_recurse_directory_not_d (f_directory_recurse_do_flag_block_e | f_directory_recurse_do_flag_character_e | f_directory_recurse_do_flag_fifo_e | f_directory_recurse_do_flag_link_e | f_directory_recurse_do_flag_path_e | f_directory_recurse_do_flag_regular_e | f_directory_recurse_do_flag_socket_e | f_directory_recurse_do_flag_unknown_e) #endif // _di_kt_remove_flag_recurse_d_ +/** + * Flags passed to the main function or program. + * + * kt_remove_main_flag_*_d: + * - none: No flags set. + * - accessed: Remove by last accessed datetime. + * - block: Remove by file type: block. + * - character: Remove by file type: character. + * - copyright: Print copyright. + * - changed: Remove by changed datetime. + * - different: Remove by user different from caller. + * - directory: Remove by file type: directory. + * - empty_all: All empty flag bits are combined. + * - empty_only: Remove empty directories. + * - empty_only_fail: Fail on empty directories. + * - empty_not: Remove not empty directories. + * - empty_not_fail: Fail on not empty directories. + * - fifo: Remove by file type: FIFO. + * - follow: Follow symbolic links for deleting the file being pointed to rather than the link itself (when not set the link itself is deleted). + * - force: Forcibly delete. + * - group: Remove by GID. + * - help: Print help. + * - isolate_all: Isolate to a single file system, error on all outside file system files (not implemented, requires /proc support). + * - isolate_ignore: Ignore rather than fail for anything on a different file system (not implemented, requires /proc support). + * - isolate_root: Isolate to a single file system, error on remove on '/' (not implemented, requires /proc support). + * - link: Remove by file type: link. + * - mode: Remove by mode. + * - option_used: This gets set when when certain options are specified to toggle the default match detection boolean during removal of each file. + * - prompt_all: All prompt flag bits are combined. + * - prompt_each: Operate in interactive mode, prompting for every file. + * - prompt_follow: Operate in interactive mode: prompting for every link that is being followed. + * - prompt_never: Do not operate in interactive mode. + * - prompt_once: Operate in interactive mode: prompting if removing 3 or more files. + * - recurse: Recurse directories. + * - regular: Remove by file type: regular. + * - same: Remove by same user as caller. + * - simulate: Do not actually perform deletes, instead print messages (when silent, should still return 0 or 1). + * - socket: Remove by file type: socket. + * - tree: Remove directory tree (parent directories) (remove a/b/c, removes a/b/c, then a/b/, then a). + * - updated: Remove by last updated datetime. + * - user: Remove by UID. + * - utc: Process dates in UTC mode. + * - version: Print version. + * - version_copyright_help: A helper flag representing version, copyright, and help flag bits being set. + */ +#ifndef _di_kt_remove_main_flag_d_ + #define kt_remove_main_flag_none_d 0x0 + #define kt_remove_main_flag_accessed_d 0x1 + #define kt_remove_main_flag_block_d 0x2 + #define kt_remove_main_flag_character_d 0x4 + #define kt_remove_main_flag_copyright_d 0x8 + #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_only_d 0x80 + #define kt_remove_main_flag_empty_only_fail_d 0x100 + #define kt_remove_main_flag_empty_not_d 0x200 + #define kt_remove_main_flag_empty_not_fail_d 0x400 + #define kt_remove_main_flag_fifo_d 0x800 + #define kt_remove_main_flag_follow_d 0x1000 + #define kt_remove_main_flag_force_d 0x2000 + #define kt_remove_main_flag_group_d 0x4000 + #define kt_remove_main_flag_help_d 0x8000 + #define kt_remove_main_flag_isolate_all_d 0x10000 + #define kt_remove_main_flag_isolate_ignore_d 0x20000 + #define kt_remove_main_flag_isolate_root_d 0x40000 + #define kt_remove_main_flag_link_d 0x80000 + #define kt_remove_main_flag_mode_d 0x100000 + #define kt_remove_main_flag_option_used_d 0x200000 + #define kt_remove_main_flag_prompt_each_d 0x400000 + #define kt_remove_main_flag_prompt_follow_d 0x800000 + #define kt_remove_main_flag_prompt_never_d 0x1000000 + #define kt_remove_main_flag_prompt_once_d 0x2000000 + #define kt_remove_main_flag_recurse_d 0x4000000 + #define kt_remove_main_flag_regular_d 0x8000000 + #define kt_remove_main_flag_same_d 0x10000000 + #define kt_remove_main_flag_simulate_d 0x20000000 + #define kt_remove_main_flag_socket_d 0x40000000 + #define kt_remove_main_flag_tree_d 0x80000000 + #define kt_remove_main_flag_updated_d 0x100000000 + #define kt_remove_main_flag_user_d 0x200000000 + #define kt_remove_main_flag_utc_d 0x400000000 + #define kt_remove_main_flag_version_d 0x800000000 + #define kt_remove_main_flag_version_copyright_help_d 0x800008008 + + #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_ + +/** + * Flags for fine-tuned print control. + * + * kt_remove_print_flag_*_d: + * - none: No flags set. + * - debug: Stream is for debug printing. + * - error: Stream is for error printing. + * - file: Stream is associated with a file. + * - in: Stream is a source file. + * - message: Stream is for message printing. + * - out: Stream is a destination file. + * - warning: Stream is for warning printing. + */ +#ifndef _di_kt_remove_print_flag_d_ + #define kt_remove_print_flag_none_d 0x0 + #define kt_remove_print_flag_debug_d 0x1 + #define kt_remove_print_flag_error_d 0x2 + #define kt_remove_print_flag_file_d 0x4 + #define kt_remove_print_flag_in_d 0x8 + #define kt_remove_print_flag_message_d 0x10 + #define kt_remove_print_flag_out_d 0x20 + #define kt_remove_print_flag_warning_d 0x40 +#endif // _di_kt_remove_print_flag_d_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/sources/c/remove/main/common/enumeration.h b/sources/c/remove/main/common/enumeration.h index e95a23c..8675622 100644 --- a/sources/c/remove/main/common/enumeration.h +++ b/sources/c/remove/main/common/enumeration.h @@ -17,203 +17,6 @@ extern "C" { #endif /** - * Flags passed to the main function or program. - * - * kt_remove_main_flag_*_e: - * - none: No flags set. - * - accessed: Remove by last accessed datetime. - * - block: Remove by file type: block. - * - character: Remove by file type: character. - * - copyright: Print copyright. - * - changed: Remove by changed datetime. - * - different: Remove by user different from caller. - * - directory: Remove by file type: directory. - * - empty_only: Remove empty directories. - * - empty_only_fail: Fail on empty directories. - * - empty_not: Remove not empty directories. - * - empty_not_fail: Fail on not empty directories. - * - fifo: Remove by file type: FIFO. - * - follow: Follow symbolic links for deleting the file being pointed to rather than the link itself (when not set the link itself is deleted). - * - force: Forcibly delete. - * - group: Remove by GID. - * - help: Print help. - * - isolate_all: Isolate to a single file system, error on all outside file system files (not implemented, requires /proc support). - * - isolate_ignore: Ignore rather than fail for anything on a different file system (not implemented, requires /proc support). - * - isolate_root: Isolate to a single file system, error on remove on '/' (not implemented, requires /proc support). - * - link: Remove by file type: link. - * - mode: Remove by mode. - * - option_used: This gets set when when certain options are specified to toggle the default match detection boolean during removal of each file. - * - prompt_all: Operate in interactive mode, prompting for every file. - * - prompt_follow: Operate in interactive mode: prompting for every link that is being followed. - * - prompt_never: Do not operate in interactive mode. - * - prompt_once: Operate in interactive mode: prompting if removing 3 or more files. - * - recurse: Recurse directories. - * - regular: Remove by file type: regular. - * - same: Remove by same user as caller. - * - simulate: Do not actually perform deletes, instead print messages (when silent, should still return 0 or 1). - * - socket: Remove by file type: socket. - * - tree: Remove directory tree (parent directories) (remove a/b/c, removes a/b/c, then a/b/, then a). - * - updated: Remove by last updated datetime. - * - user: Remove by UID. - * - utc: Process dates in UTC mode. - * - version: Print version. - * - version_copyright_help: A helper flag representing version, copyright, and help flag bits being set. - */ -#ifndef _di_kt_remove_flag_e_ - enum { - kt_remove_main_flag_none_e = 0x0, - kt_remove_main_flag_accessed_e = 0x1, - kt_remove_main_flag_block_e = 0x2, - kt_remove_main_flag_character_e = 0x4, - kt_remove_main_flag_copyright_e = 0x8, - kt_remove_main_flag_changed_e = 0x10, - kt_remove_main_flag_different_e = 0x20, - kt_remove_main_flag_directory_e = 0x40, - kt_remove_main_flag_empty_only_e = 0x80, - kt_remove_main_flag_empty_only_fail_e = 0x100, - kt_remove_main_flag_empty_not_e = 0x200, - kt_remove_main_flag_empty_not_fail_e = 0x400, - kt_remove_main_flag_fifo_e = 0x800, - kt_remove_main_flag_follow_e = 0x1000, - kt_remove_main_flag_force_e = 0x2000, - kt_remove_main_flag_group_e = 0x4000, - kt_remove_main_flag_help_e = 0x8000, - kt_remove_main_flag_isolate_all_e = 0x10000, - kt_remove_main_flag_isolate_ignore_e = 0x20000, - kt_remove_main_flag_isolate_root_e = 0x40000, - kt_remove_main_flag_link_e = 0x80000, - kt_remove_main_flag_mode_e = 0x100000, - kt_remove_main_flag_option_used_e = 0x200000, - kt_remove_main_flag_prompt_all_e = 0x400000, - kt_remove_main_flag_prompt_follow_e = 0x800000, - kt_remove_main_flag_prompt_never_e = 0x1000000, - kt_remove_main_flag_prompt_once_e = 0x2000000, - kt_remove_main_flag_recurse_e = 0x4000000, - kt_remove_main_flag_regular_e = 0x8000000, - kt_remove_main_flag_same_e = 0x10000000, - kt_remove_main_flag_simulate_e = 0x20000000, - kt_remove_main_flag_socket_e = 0x40000000, - kt_remove_main_flag_tree_e = 0x80000000, - kt_remove_main_flag_updated_e = 0x100000000, - kt_remove_main_flag_user_e = 0x200000000, - kt_remove_main_flag_utc_e = 0x400000000, - kt_remove_main_flag_version_e = 0x800000000, - kt_remove_main_flag_version_copyright_help_e = 0x800008008, - }; // enum -#endif // _di_kt_remove_flag_e_ - -/** - * A set of flags used internally in the convert process. - * - * These are generally used during parsing of Time and EpochTime strings. - * - * kt_remove_flag_convert_*_e: - * - colon: Either single or double colon. - * - colon_single: Single colon detected. - * - colon_double: Double colon detected. - * - match: Matched either part. - * - match_first: Matched first (left) part. - * - match_second: Matched second (right) part. - */ -#ifndef _di_kt_remove_flag_convert_e_ - enum { - kt_remove_flag_convert_none_e = 0x0, - kt_remove_flag_convert_colon_e = 0x3, - kt_remove_flag_convert_colon_single_e = 0x1, - kt_remove_flag_convert_colon_double_e = 0x2, - kt_remove_flag_convert_match_e = 0xc, - kt_remove_flag_convert_match_first_e = 0x4, - kt_remove_flag_convert_match_second_e = 0x8, - }; // enum -#endif // _di_kt_remove_flag_convert_e_ - -/** - * Flags associated with a datetime. - * - * kt_remove_flag_date_*_e: - * - none: No flags set. - * - equal: Perform equal to on date, '==' or 'equal'. - * - less: Perform less than on date, '<' or 'less'. - * - less_equal: Perform less than or equal to on date, '<=' or 'less_equal'. - * - more: Perform greater than on date, '>' or 'more'. - * - more_equal: Perform greater than or equal to on date, '>=' or 'more_equal'. - * - not: Perform not equal to on date. '<>' or 'not' - * - * - year: Date has a year. - * - now: Date is relative to 'now'. - * - string: Date is processed via the string date functions (such as via strftime_r() or getdate_r()). - * - time: Date is based off of Time format. - * - time_epoch: Date is based off of EpochTime format. - * - today: Date is relative to 'today'. - * - tomorrow: Date is relative to 'tomorrow'. - * - unix: Date is based off of Unix Epoch format. - * - yesterday: Date is relative to 'yesterday'. - */ -#ifndef _di_kt_remove_flag_date_e_ - enum { - kt_remove_flag_date_none_e = 0x0, - - // Used for comparisons. - kt_remove_flag_date_equal_e = 0x1, - kt_remove_flag_date_less_e = 0x2, - kt_remove_flag_date_less_equal_e = 0x4, - kt_remove_flag_date_more_e = 0x8, - kt_remove_flag_date_more_equal_e = 0x10, - kt_remove_flag_date_not_e = 0x20, - - // Used for processing and converting. - kt_remove_flag_date_now_e = 0x1, - kt_remove_flag_date_string_e = 0x2, - kt_remove_flag_date_time_e = 0x4, - kt_remove_flag_date_time_epoch_e = 0x8, - kt_remove_flag_date_today_e = 0x10, - kt_remove_flag_date_tomorrow_e = 0x20, - kt_remove_flag_date_unix_e = 0x40, - kt_remove_flag_date_yesterday_e = 0x80, - }; // enum -#endif // _di_kt_remove_flag_date_e_ - -/** - * Flags associated with a mode. - * - * kt_remove_flag_mode_*_e: - * - none: No flags set. - * - different: Remove by mode matching different parts. - * - same: Remove by exact mode match. - * - similar: Remove by mode matching same parts. - * - not: Remove by not exact mode match. - */ -#ifndef _di_kt_remove_flag_mode_e_ - enum { - kt_remove_flag_mode_none_e = 0x0, - kt_remove_flag_mode_different_e = 0x1, // '~~' or 'different' - kt_remove_flag_mode_same_e = 0x2, // '==' or 'same' - kt_remove_flag_mode_similar_e = 0x4, // '~=' or 'similar' - kt_remove_flag_mode_not_e = 0x8, // '<>' or 'not' - }; // enum -#endif // _di_kt_remove_flag_mode_e_ - -/** - * Flags associated with performing an operation on a file. - * - * kt_remove_flag_file_operate_*_e: - * - none: No flags set. - * - directory: Is a directory. - * - follow: Follow the symbolic link. - * - recurse: Perform recursively (only on directories). - * - remove: Perform remove. - */ -#ifndef _di_kt_remove_flag_file_operate_e_ - enum { - kt_remove_flag_file_operate_none_e = 0x0, - kt_remove_flag_file_operate_directory_e = 0x1, - kt_remove_flag_file_operate_follow_e = 0x2, - kt_remove_flag_file_operate_recurse_e = 0x4, - kt_remove_flag_file_operate_remove_e = 0x8, - }; // enum -#endif // _di_kt_remove_flag_file_operate_e_ - -/** * The main program parameters. */ #ifndef _di_kt_remove_parameter_e_ @@ -292,32 +95,6 @@ extern "C" { #define kt_remove_total_parameters_d (f_console_parameter_state_type_total_d + 25) #endif // _di_kt_remove_parameter_e_ -/** - * Flags for fine-tuned print control. - * - * kt_remove_print_flag_*_e: - * - none: No flags set. - * - debug: Stream is for debug printing. - * - error: Stream is for error printing. - * - file: Stream is associated with a file. - * - in: Stream is a source file. - * - message: Stream is for message printing. - * - out: Stream is a destination file. - * - warning: Stream is for warning printing. - */ -#ifndef _di_kt_remove_print_flag_e_ - enum { - kt_remove_print_flag_none_e = 0x0, - kt_remove_print_flag_debug_e = 0x1, - kt_remove_print_flag_error_e = 0x2, - kt_remove_print_flag_file_e = 0x4, - kt_remove_print_flag_in_e = 0x8, - kt_remove_print_flag_message_e = 0x10, - kt_remove_print_flag_out_e = 0x20, - kt_remove_print_flag_warning_e = 0x40, - }; // enum -#endif // _di_kt_remove_print_flag_e_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/sources/c/remove/main/common/type.h b/sources/c/remove/main/common/type.h index 981963d..bb9eb76 100644 --- a/sources/c/remove/main/common/type.h +++ b/sources/c/remove/main/common/type.h @@ -185,7 +185,7 @@ extern "C" { #define kt_remove_setting_t_initialize \ { \ - kt_remove_main_flag_none_e, \ + kt_remove_main_flag_none_d, \ F_okay, \ macro_f_state_t_initialize_1(kt_remove_allocation_large_d, kt_remove_allocation_small_d, F_okay, 0, 0, &fll_program_standard_signal_handle, 0, 0, 0, 0), \ f_string_dynamic_t_initialize, \ diff --git a/sources/c/remove/main/convert.c b/sources/c/remove/main/convert.c index 68a4b39..88f3e55 100644 --- a/sources/c/remove/main/convert.c +++ b/sources/c/remove/main/convert.c @@ -22,10 +22,10 @@ extern "C" { }; uint16_t enumerations[] = { - kt_remove_flag_date_now_e, - kt_remove_flag_date_today_e, - kt_remove_flag_date_tomorrow_e, - kt_remove_flag_date_yesterday_e, + kt_remove_flag_date_now_d, + kt_remove_flag_date_today_d, + kt_remove_flag_date_tomorrow_d, + kt_remove_flag_date_yesterday_d, }; for (uint8_t i = 0; i < 4; ++i) { @@ -66,7 +66,7 @@ extern "C" { width = macro_f_utf_byte_width(buffer.string[range.start]); - if (matches & kt_remove_flag_convert_match_second_e) { + if (matches & kt_remove_flag_convert_match_second_d) { main->setting.state.status = f_utf_is_digit(buffer.string + range.start, width_max, 0); if (F_status_is_error(main->setting.state.status)) { @@ -87,19 +87,19 @@ extern "C" { break; } - if (matches & kt_remove_flag_convert_colon_e) { + if (matches & kt_remove_flag_convert_colon_d) { // Search until a colon or a digit is found. if (f_compare_dynamic_string(buffer.string + range.start, f_string_ascii_colon_s, width) == F_equal_to) { // A third colon is not valid. - if (matches & kt_remove_flag_convert_colon_double_e) { + if (matches & kt_remove_flag_convert_colon_double_d) { matches = 0; break; } - matches |= kt_remove_flag_convert_colon_double_e; + matches |= kt_remove_flag_convert_colon_double_d; continue; } @@ -113,7 +113,7 @@ extern "C" { } if (main->setting.state.status == F_true) { - matches |= kt_remove_flag_convert_match_second_e; + matches |= kt_remove_flag_convert_match_second_d; range_second.start = range.start; range_second.stop = range.start; } @@ -121,10 +121,10 @@ extern "C" { continue; } - if (matches & kt_remove_flag_convert_match_first_e) { + if (matches & kt_remove_flag_convert_match_first_d) { if (f_compare_dynamic_string(buffer.string + range.start, f_string_ascii_colon_s, width) == F_equal_to) { - matches |= kt_remove_flag_convert_colon_single_e; + matches |= kt_remove_flag_convert_colon_single_d; continue; } @@ -160,7 +160,7 @@ extern "C" { if (main->setting.state.status == F_true) continue; if (f_compare_dynamic_string(buffer.string + range.start, f_string_ascii_colon_s, width) == F_equal_to) { - matches |= kt_remove_flag_convert_colon_single_e; + matches |= kt_remove_flag_convert_colon_single_d; continue; } @@ -174,7 +174,7 @@ extern "C" { } if (main->setting.state.status == F_true) { - matches |= kt_remove_flag_convert_match_first_e; + matches |= kt_remove_flag_convert_match_first_d; range_first.start = range.start; range_first.stop = range.start; } @@ -189,7 +189,7 @@ extern "C" { } // If the first and possibly the second digit matches. - if (matches & kt_remove_flag_convert_match_e) { + if (matches & kt_remove_flag_convert_match_d) { fl_conversion_data_t conversion_data = fl_conversion_data_base_10_c; date->start_year = 0; @@ -201,7 +201,7 @@ extern "C" { date->type = 0; // Process the first character. - if (matches & kt_remove_flag_convert_match_first_e) { + if (matches & kt_remove_flag_convert_match_first_d) { main->setting.state.status = fl_conversion_dynamic_partial_to_unsigned_detect(conversion_data, buffer, range_first, &date->start_year); if (F_status_is_error(main->setting.state.status)) { @@ -211,11 +211,11 @@ extern "C" { } } else { - if (matches & kt_remove_flag_convert_colon_double_e) { + if (matches & kt_remove_flag_convert_colon_double_d) { // The Unix Epoch is used for double colons when no year is specified. date->start_year = kt_remove_time_year_unix_epoch_d; - date->type |= kt_remove_flag_date_time_epoch_e; + date->type |= kt_remove_flag_date_time_epoch_d; } else { struct timespec now; @@ -246,12 +246,12 @@ extern "C" { } date->start_year = now.tv_sec / kt_remove_time_seconds_in_year_d; - date->type |= kt_remove_flag_date_time_e; + date->type |= kt_remove_flag_date_time_d; } } // Process the second character. - if (matches & kt_remove_flag_convert_match_second_e) { + if (matches & kt_remove_flag_convert_match_second_d) { main->setting.state.status = fl_conversion_dynamic_partial_to_unsigned_detect(conversion_data, buffer, range_second, &date->start_second); if (F_status_is_error(main->setting.state.status)) { @@ -260,8 +260,8 @@ extern "C" { return; } - if (matches & kt_remove_flag_convert_colon_double_e) { - if (!(main->setting.flag & kt_remove_main_flag_utc_e)) { + if (matches & kt_remove_flag_convert_colon_double_d) { + if (!(main->setting.flag & kt_remove_main_flag_utc_d)) { kt_remove_convert_timezone(main, &date->start_year, &date->start_second); if (F_status_is_error(main->setting.state.status)) { @@ -275,7 +275,7 @@ extern "C" { date->start_nanosecond = date->start_second % kt_remove_time_seconds_in_nanosecond_d; date->start_second = (date->start_second / kt_remove_time_seconds_in_nanosecond_d); - if (!(main->setting.flag & kt_remove_main_flag_utc_e)) { + if (!(main->setting.flag & kt_remove_main_flag_utc_d)) { kt_remove_convert_timezone(main, &date->start_year, &date->start_second); if (F_status_is_error(main->setting.state.status)) { @@ -289,14 +289,14 @@ extern "C" { else { // A colon after the end without a digit following it is not valid (such as '1234:' or '1234::'). - if (matches & kt_remove_flag_convert_colon_e) { + if (matches & kt_remove_flag_convert_colon_d) { matches = 0; } else { // This is a UNIX timestamp by itself (has no colons). date->start_year = kt_remove_time_year_unix_epoch_d; - date->type = kt_remove_flag_date_unix_e; + date->type = kt_remove_flag_date_unix_d; main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(conversion_data, buffer, &date->start_second); @@ -350,7 +350,7 @@ extern "C" { date->stop_second = 0; date->stop_nanosecond = 0; date->stop_year = 0; - date->type = kt_remove_flag_date_string_e; + date->type = kt_remove_flag_date_string_d; date->start_second = time.tm_sec; date->start_second += time.tm_min * kt_remove_time_seconds_in_minute_d; @@ -411,10 +411,10 @@ extern "C" { date->stop_second = 0; date->stop_nanosecond = 0; - if (date->type == kt_remove_flag_date_now_e) { + if (date->type == kt_remove_flag_date_now_d) { date->start_nanosecond = now.tv_nsec; - if (!(main->setting.flag & kt_remove_main_flag_utc_e)) { + if (!(main->setting.flag & kt_remove_main_flag_utc_d)) { kt_remove_convert_timezone(main, &date->start_year, &date->start_second); if (F_status_is_error(main->setting.state.status)) return; } @@ -425,21 +425,21 @@ extern "C" { } // Determine start of day. - if (!(main->setting.flag & kt_remove_main_flag_utc_e)) { + if (!(main->setting.flag & kt_remove_main_flag_utc_d)) { kt_remove_convert_timezone(main, &date->start_year, &date->start_second); if (F_status_is_error(main->setting.state.status)) return; } date->start_second -= date->start_second % kt_remove_time_seconds_in_day_d; - if (date->type == kt_remove_flag_date_today_e) { + if (date->type == kt_remove_flag_date_today_d) { date->stop_second = date->start_second + kt_remove_time_seconds_in_day_d; // @fixme, check to see if this would overflow and if so increment year. } - else if (date->type == kt_remove_flag_date_tomorrow_e) { + else if (date->type == kt_remove_flag_date_tomorrow_d) { date->start_second += kt_remove_time_seconds_in_day_d; date->stop_second = date->start_second + kt_remove_time_seconds_in_day_d; // @fixme, check to see if this would overflow and if so increment year. } - else if (date->type == kt_remove_flag_date_yesterday_e) { + else if (date->type == kt_remove_flag_date_yesterday_d) { date->start_second -= kt_remove_time_seconds_in_day_d; date->stop_second = date->start_second; } diff --git a/sources/c/remove/main/main.c b/sources/c/remove/main/main.c index 896126e..52883dd 100644 --- a/sources/c/remove/main/main.c +++ b/sources/c/remove/main/main.c @@ -9,11 +9,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { kt_remove_main_t data = kt_remove_main_t_initialize; - data.program.debug.flag |= kt_remove_print_flag_debug_e | kt_remove_print_flag_out_e; - data.program.error.flag |= kt_remove_print_flag_error_e | kt_remove_print_flag_out_e; - data.program.message.flag |= kt_remove_print_flag_message_e | kt_remove_print_flag_out_e; - data.program.output.flag |= kt_remove_print_flag_out_e; - data.program.warning.flag |= kt_remove_print_flag_warning_e | kt_remove_print_flag_out_e; + data.program.debug.flag |= kt_remove_print_flag_debug_d | kt_remove_print_flag_out_d; + data.program.error.flag |= kt_remove_print_flag_error_d | kt_remove_print_flag_out_d; + data.program.message.flag |= kt_remove_print_flag_message_d | kt_remove_print_flag_out_d; + data.program.output.flag |= kt_remove_print_flag_out_d; + data.program.warning.flag |= kt_remove_print_flag_warning_d | kt_remove_print_flag_out_d; data.program.message.custom = (void *) &data; data.program.output.custom = (void *) &data; data.program.error.custom = (void *) &data; @@ -30,7 +30,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.recurse.depth_max = kt_remove_depth_max_d; #ifdef _en_kt_default_to_utc_ - data.setting.flag |= kt_remove_flag_utc_e; + data.setting.flag |= kt_remove_flag_utc_d; #endif // _en_kt_default_to_utc_ f_console_parameter_t parameters[] = kt_remove_console_parameter_t_initialize; diff --git a/sources/c/remove/main/operate.c b/sources/c/remove/main/operate.c index 7188d9d..0ad2474 100644 --- a/sources/c/remove/main/operate.c +++ b/sources/c/remove/main/operate.c @@ -20,8 +20,8 @@ extern "C" { const uint8_t flag = kt_remove_operate_file_simulate(main, path); if (F_status_is_error(main->setting.state.status)) return; - if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) { - if (flag & kt_remove_flag_file_operate_directory_e) { + 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; } @@ -38,7 +38,7 @@ extern "C" { #ifndef _di_kt_remove_operate_file_directory_ void kt_remove_operate_file_directory(kt_remove_main_t * const main, const f_string_static_t path, const uint8_t flag) { - if (!(flag & kt_remove_flag_file_operate_remove_e)) { + if (!(flag & kt_remove_flag_file_operate_remove_d)) { main->setting.state.status = F_no; return; @@ -49,7 +49,7 @@ extern "C" { main->setting.recurse.flag = f_directory_recurse_do_flag_list_e | f_directory_recurse_do_flag_after_e; // @todo consider this in recursion and maybe provide a new parameter follow_recurse for this. - /*if (flag & kt_remove_flag_file_operate_follow_e) { + /*if (flag & kt_remove_flag_file_operate_follow_d) { data.setting.recurse.flag |= f_directory_recurse_do_flag_dereference_e; }*/ @@ -80,13 +80,13 @@ extern "C" { if (flag == f_directory_recurse_do_flag_list_e) { // @todo check all listing to determine if any directory is to be recursed or not. if (recurse->listing.block.used || recurse->listing.character.used || recurse->listing.directory.used || recurse->listing.regular.used || recurse->listing.link.used || recurse->listing.fifo.used || recurse->listing.socket.used || recurse->listing.unknown.used) { - if (!(main->setting.recurse.state.code & kt_remove_flag_file_operate_recurse_e)) { + if (!(main->setting.recurse.state.code & kt_remove_flag_file_operate_recurse_d)) { // @todo error out on trying to remove non-empty directory without recursion. recurse->state.status = F_status_set_error(F_recurse_not); } } else { - if (main->setting.recurse.state.code & kt_remove_flag_file_operate_remove_e) { + if (main->setting.recurse.state.code & kt_remove_flag_file_operate_remove_d) { recurse->state.status = f_directory_remove(name, 0, F_false); if (F_status_is_error_not(recurse->state.status)) { @@ -110,8 +110,8 @@ extern "C" { // @todo needs empty check to see if directory contents are fully removed (because of removal conditions). - if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) { - if (flag & kt_remove_flag_file_operate_directory_e) { + 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, name, flag); if (F_status_is_error(main->setting.state.status)) return; } @@ -198,12 +198,12 @@ extern "C" { kt_remove_print_simulate_operate_file(&main->program.output, path); - main->setting.state.status = f_file_exists(path, main->setting.flag & kt_remove_main_flag_follow_e); + main->setting.state.status = f_file_exists(path, main->setting.flag & kt_remove_main_flag_follow_d); kt_remove_print_simulate_operate_file_exists(&main->program.output, path); if (main->setting.state.status == F_false) { - if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) { + if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) { remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_not_found_s); } @@ -211,7 +211,7 @@ extern "C" { } if (F_status_is_error(main->setting.state.status)) { - if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) { + if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) { remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_no_access_s); } @@ -227,74 +227,74 @@ extern "C" { if (main->program.signal_received) return 0; f_number_unsigned_t i = 0; - uint8_t flag = (main->setting.flag & kt_remove_main_flag_option_used_e) ? 0 : kt_remove_flag_file_operate_remove_e; + uint8_t flag = (main->setting.flag & kt_remove_main_flag_option_used_d) ? 0 : kt_remove_flag_file_operate_remove_d; - if (main->setting.flag & kt_remove_main_flag_follow_e) { - flag |= kt_remove_flag_file_operate_follow_e; + if (main->setting.flag & kt_remove_main_flag_follow_d) { + flag |= kt_remove_flag_file_operate_follow_d; } struct stat statistics; memset(&statistics, 0, sizeof(struct stat)); - main->setting.state.status = f_file_stat(path, main->setting.flag & kt_remove_main_flag_follow_e, &statistics); + main->setting.state.status = f_file_stat(path, main->setting.flag & kt_remove_main_flag_follow_d, &statistics); kt_remove_print_simulate_operate_file_stat(&main->program.output, statistics); if (F_status_is_error(main->setting.state.status)) { - if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) { + if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) { remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_stat_fail_s); } return flag; } - if (main->setting.flag & kt_remove_main_flag_block_e) { + if (main->setting.flag & kt_remove_main_flag_block_d) { if (macro_f_file_type_is_block(statistics.st_mode)) { - flag |= kt_remove_flag_file_operate_remove_e; + flag |= kt_remove_flag_file_operate_remove_d; } } - if (main->setting.flag & kt_remove_main_flag_character_e) { + if (main->setting.flag & kt_remove_main_flag_character_d) { if (macro_f_file_type_is_character(statistics.st_mode)) { - flag |= kt_remove_flag_file_operate_remove_e; + flag |= kt_remove_flag_file_operate_remove_d; } } if (macro_f_file_type_is_directory(statistics.st_mode)) { - flag |= kt_remove_flag_file_operate_directory_e; + flag |= kt_remove_flag_file_operate_directory_d; - if (main->setting.flag & kt_remove_main_flag_directory_e) { - flag |= kt_remove_flag_file_operate_remove_e; + if (main->setting.flag & kt_remove_main_flag_directory_d) { + flag |= kt_remove_flag_file_operate_remove_d; } } - if (main->setting.flag & kt_remove_main_flag_fifo_e) { + if (main->setting.flag & kt_remove_main_flag_fifo_d) { if (macro_f_file_type_is_fifo(statistics.st_mode)) { - flag |= kt_remove_flag_file_operate_remove_e; + flag |= kt_remove_flag_file_operate_remove_d; } } - if (main->setting.flag & kt_remove_main_flag_link_e) { + if (main->setting.flag & kt_remove_main_flag_link_d) { if (macro_f_file_type_is_link(statistics.st_mode)) { - flag |= kt_remove_flag_file_operate_remove_e; + flag |= kt_remove_flag_file_operate_remove_d; } } - if (main->setting.flag & kt_remove_main_flag_regular_e) { + if (main->setting.flag & kt_remove_main_flag_regular_d) { if (macro_f_file_type_is_regular(statistics.st_mode)) { - flag |= kt_remove_flag_file_operate_remove_e; + flag |= kt_remove_flag_file_operate_remove_d; } } - if (main->setting.flag & kt_remove_main_flag_socket_e) { + if (main->setting.flag & kt_remove_main_flag_socket_d) { if (macro_f_file_type_is_socket(statistics.st_mode)) { - flag |= kt_remove_flag_file_operate_remove_e; + flag |= kt_remove_flag_file_operate_remove_d; } } - if (main->setting.flag & kt_remove_main_flag_user_e) { + 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; @@ -302,23 +302,23 @@ extern "C" { } // for if (i < main->setting.users.used) { - flag |= kt_remove_flag_file_operate_remove_e; + flag |= kt_remove_flag_file_operate_remove_d; } } - if (main->setting.flag & kt_remove_main_flag_same_e) { + if (main->setting.flag & kt_remove_main_flag_same_d) { if (statistics.st_uid != geteuid()) { - flag |= kt_remove_flag_file_operate_remove_e; + flag |= kt_remove_flag_file_operate_remove_d; } } - if (main->setting.flag & kt_remove_main_flag_different_e) { + if (main->setting.flag & kt_remove_main_flag_different_d) { if (statistics.st_uid == geteuid()) { - flag |= kt_remove_flag_file_operate_remove_e; + flag |= kt_remove_flag_file_operate_remove_d; } } - if (main->setting.flag & kt_remove_main_flag_group_e) { + 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; @@ -326,41 +326,41 @@ extern "C" { } // for if (i < main->setting.groups.used) { - flag |= kt_remove_flag_file_operate_remove_e; + flag |= kt_remove_flag_file_operate_remove_d; } } - if (main->setting.flag & kt_remove_main_flag_mode_e) { + if (main->setting.flag & kt_remove_main_flag_mode_d) { const mode_t mode = statistics.st_mode & F_file_mode_all_d; for (i = 0; i < main->setting.modes.used; ++i) { if (main->program.signal_received) return flag; - if (main->setting.modes.array[i].type == kt_remove_flag_mode_different_e) { + if (main->setting.modes.array[i].type == kt_remove_flag_mode_different_d) { if (main->setting.modes.array[i].mode & ~mode) break; } - else if (main->setting.modes.array[i].type == kt_remove_flag_mode_same_e) { + else if (main->setting.modes.array[i].type == kt_remove_flag_mode_same_d) { if (main->setting.modes.array[i].mode == mode) break; } - else if (main->setting.modes.array[i].type == kt_remove_flag_mode_similar_e) { + else if (main->setting.modes.array[i].type == kt_remove_flag_mode_similar_d) { if (main->setting.modes.array[i].mode & mode) break; } - else if (main->setting.modes.array[i].type == kt_remove_flag_mode_not_e) { + else if (main->setting.modes.array[i].type == kt_remove_flag_mode_not_d) { if (main->setting.modes.array[i].mode != mode) break; } } // for if (i < main->setting.modes.used) { - flag |= kt_remove_flag_file_operate_remove_e; + flag |= kt_remove_flag_file_operate_remove_d; } - if (main->setting.flag & kt_remove_main_flag_recurse_e) { - flag |= kt_remove_flag_file_operate_recurse_e; + if (main->setting.flag & kt_remove_main_flag_recurse_d) { + flag |= kt_remove_flag_file_operate_recurse_d; } - if (main->setting.flag & kt_remove_main_flag_force_e) { - flag |= kt_remove_flag_file_operate_remove_e; + if (main->setting.flag & kt_remove_main_flag_force_d) { + flag |= kt_remove_flag_file_operate_remove_d; } // Trigger the callback to make any modifications before simulating or performing the removal. @@ -380,36 +380,36 @@ extern "C" { main->setting.state.status = F_okay; } - if (main->setting.flag & kt_remove_main_flag_force_e) { + if (main->setting.flag & kt_remove_main_flag_force_d) { kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_force_s, F_true); } - if (flag & kt_remove_flag_file_operate_directory_e) { - kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_recurse_s, flag & kt_remove_flag_file_operate_recurse_e); + if (flag & kt_remove_flag_file_operate_directory_d) { + kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_recurse_s, flag & kt_remove_flag_file_operate_recurse_d); } - if (flag & kt_remove_flag_file_operate_directory_e) { + if (flag & kt_remove_flag_file_operate_directory_d) { if (main->setting.flag & kt_remove_main_flag_empty_all_d) { // @todo handle simulate for this. } // Recurse effectively forces tree. - if (main->setting.flag & kt_remove_main_flag_recurse_e) { + if (main->setting.flag & kt_remove_main_flag_recurse_d) { // @todo handle simulate for this. // @todo consider not following "rm" and having recurse not act like "--force" is specified. } - else if (main->setting.flag & kt_remove_main_flag_tree_e) { + else if (main->setting.flag & kt_remove_main_flag_tree_d) { // @todo handle simulate for this. } // @todo call a similate fl_directory_do() or move this into the kt_remove_operate_file_directory() process. } - if (main->setting.flag & kt_remove_main_flag_prompt_all_d) { + if (main->setting.flag & kt_remove_main_flag_prompt_each_d) { // @todo handle simulate for this. } - kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_remove_s, flag & kt_remove_flag_file_operate_remove_e); + kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_remove_s, flag & kt_remove_flag_file_operate_remove_d); main->setting.state.status = F_okay; @@ -420,14 +420,14 @@ extern "C" { #ifndef _di_kt_remove_operate_file_normal_ void kt_remove_operate_file_normal(kt_remove_main_t * const main, const f_string_static_t path, const uint8_t flag) { - if (!(flag & kt_remove_flag_file_operate_remove_e)) { + if (!(flag & kt_remove_flag_file_operate_remove_d)) { main->setting.state.status = F_no; return; } // @todo consider providing a "follow deep" parameter for recursively following until a non-link is reached. - if (flag & kt_remove_flag_file_operate_follow_e) { + if (flag & kt_remove_flag_file_operate_follow_d) { main->setting.buffer.used = 0; main->setting.state.status = f_file_link_read(path, F_false, &main->setting.buffer); diff --git a/sources/c/remove/main/print/simulate.c b/sources/c/remove/main/print/simulate.c index f275509..1433377 100644 --- a/sources/c/remove/main/print/simulate.c +++ b/sources/c/remove/main/print/simulate.c @@ -11,7 +11,7 @@ extern "C" { kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; - if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) return; + if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) return; f_file_stream_lock(print->to); @@ -34,7 +34,7 @@ extern "C" { kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; - if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) return; + if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) return; fll_print_format("%[Remove '%Q'%]:%r", main->program.output.to, main->program.output.set->notable, path, main->program.output.set->notable, f_string_eol_s); } @@ -47,7 +47,7 @@ extern "C" { kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; - if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) return; + if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) return; if (F_status_is_error(main->setting.state.status)) { fl_print_format(" file_access_failure %ui%r", main->program.output.to, F_status_set_fine(main->setting.state.status), f_string_eol_s); @@ -77,7 +77,7 @@ extern "C" { f_file_stream_lock(main->program.output.to); - fl_print_format(" follow %r%r", main->program.output.to, (main->setting.flag & kt_remove_main_flag_follow_e) ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); + fl_print_format(" follow %r%r", main->program.output.to, (main->setting.flag & kt_remove_main_flag_follow_d) ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); fl_print_format(" to '%Q'%r", main->program.output.to, main->setting.buffer, f_string_eol_s); f_file_stream_unlock(main->program.output.to); @@ -94,39 +94,39 @@ extern "C" { kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; - if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) return; + if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) return; - if (main->setting.flag & kt_remove_main_flag_block_e) { + if (main->setting.flag & kt_remove_main_flag_block_d) { fll_print_format(" block %r%r", main->program.output.to, (macro_f_file_type_get(statistics.st_mode) == F_file_type_block_d) ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); } - if (main->setting.flag & kt_remove_main_flag_character_e) { + if (main->setting.flag & kt_remove_main_flag_character_d) { fll_print_format(" character %r%r", main->program.output.to, (macro_f_file_type_get(statistics.st_mode) == F_file_type_character_d) ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); } - if (main->setting.flag & kt_remove_main_flag_directory_e) { + if (main->setting.flag & kt_remove_main_flag_directory_d) { fll_print_format(" directory %r%r", main->program.output.to, (macro_f_file_type_get(statistics.st_mode) == F_file_type_directory_d) ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); } - if (main->setting.flag & kt_remove_main_flag_fifo_e) { + if (main->setting.flag & kt_remove_main_flag_fifo_d) { fll_print_format(" fifo %r%r", main->program.output.to, (macro_f_file_type_get(statistics.st_mode) == F_file_type_fifo_d) ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); } - if (main->setting.flag & kt_remove_main_flag_link_e) { + if (main->setting.flag & kt_remove_main_flag_link_d) { fll_print_format(" link %r%r", main->program.output.to, (macro_f_file_type_get(statistics.st_mode) == F_file_type_link_d) ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); } - if (main->setting.flag & kt_remove_main_flag_regular_e) { + if (main->setting.flag & kt_remove_main_flag_regular_d) { fll_print_format(" regular %r%r", main->program.output.to, (macro_f_file_type_get(statistics.st_mode) == F_file_type_regular_d) ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); } - if (main->setting.flag & kt_remove_main_flag_socket_e) { + if (main->setting.flag & kt_remove_main_flag_socket_d) { fll_print_format(" socket %r%r", main->program.output.to, (macro_f_file_type_get(statistics.st_mode) == F_file_type_socket_d) ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); } f_number_unsigned_t i = 0; - if (main->setting.flag & kt_remove_main_flag_user_e) { + if (main->setting.flag & kt_remove_main_flag_user_d) { for (; i < main->setting.users.used; ++i) { if (statistics.st_uid == (uid_t) main->setting.users.array[i]) break; } // for @@ -139,15 +139,15 @@ extern "C" { } } - if (main->setting.flag & kt_remove_main_flag_same_e) { + if (main->setting.flag & kt_remove_main_flag_same_d) { fll_print_format(" same %r%r", main->program.output.to, (statistics.st_uid == geteuid()) ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); } - if (main->setting.flag & kt_remove_main_flag_different_e) { + if (main->setting.flag & kt_remove_main_flag_different_d) { fll_print_format(" different %r%r", main->program.output.to, (statistics.st_uid == geteuid()) ? kt_remove_no_s : kt_remove_yes_s, f_string_eol_s); } - if (main->setting.flag & kt_remove_main_flag_group_e) { + if (main->setting.flag & kt_remove_main_flag_group_d) { for (i = 0; i < main->setting.groups.used; ++i) { if (statistics.st_gid == (gid_t) main->setting.groups.array[i]) break; } // for @@ -160,33 +160,33 @@ extern "C" { } } - if (main->setting.flag & kt_remove_main_flag_mode_e) { + if (main->setting.flag & kt_remove_main_flag_mode_d) { const mode_t mode = statistics.st_mode & F_file_mode_all_d; fll_print_format(" mode %@03un%r", main->program.output.to, (f_number_unsigned_t) mode, f_string_eol_s); for (i = 0; i < main->setting.modes.used; ++i) { - if (main->setting.modes.array[i].type == kt_remove_flag_mode_different_e) { + if (main->setting.modes.array[i].type == kt_remove_flag_mode_different_d) { if (main->setting.modes.array[i].mode & ~mode) break; } - else if (main->setting.modes.array[i].type == kt_remove_flag_mode_same_e) { + else if (main->setting.modes.array[i].type == kt_remove_flag_mode_same_d) { if (main->setting.modes.array[i].mode == mode) break; } - else if (main->setting.modes.array[i].type == kt_remove_flag_mode_similar_e) { + else if (main->setting.modes.array[i].type == kt_remove_flag_mode_similar_d) { if (main->setting.modes.array[i].mode & mode) break; } - else if (main->setting.modes.array[i].type == kt_remove_flag_mode_not_e) { + else if (main->setting.modes.array[i].type == kt_remove_flag_mode_not_d) { if (main->setting.modes.array[i].mode != mode) break; } } // for if (i < main->setting.modes.used) { uint8_t types[] = { - kt_remove_flag_mode_different_e, - kt_remove_flag_mode_same_e, - kt_remove_flag_mode_similar_e, - kt_remove_flag_mode_not_e, + kt_remove_flag_mode_different_d, + kt_remove_flag_mode_same_d, + kt_remove_flag_mode_similar_d, + kt_remove_flag_mode_not_d, }; f_string_static_t strings[] = { @@ -251,11 +251,11 @@ extern "C" { name_type = f_string_empty_s; result = F_okay; - if (dates[p]->array[i].type == kt_remove_flag_date_today_e || dates[p]->array[i].type == kt_remove_flag_date_tomorrow_e || dates[p]->array[i].type == kt_remove_flag_date_yesterday_e) { + if (dates[p]->array[i].type == kt_remove_flag_date_today_d || dates[p]->array[i].type == kt_remove_flag_date_tomorrow_d || dates[p]->array[i].type == kt_remove_flag_date_yesterday_d) { stop_year = dates[p]->array[i].stop_year + (dates[p]->array[i].stop_second / kt_remove_time_seconds_in_year_d); stop_second = dates[p]->array[i].stop_second % kt_remove_time_seconds_in_year_d; - if (dates[p]->array[i].operation == kt_remove_flag_date_equal_e) { + if (dates[p]->array[i].operation == kt_remove_flag_date_equal_d) { name_type = kt_remove_date_symbol_equal_s; result = F_false; @@ -268,7 +268,7 @@ extern "C" { } } } - else if (dates[p]->array[i].operation == kt_remove_flag_date_less_e) { + else if (dates[p]->array[i].operation == kt_remove_flag_date_less_d) { name_type = kt_remove_date_symbol_less_s; result = F_false; @@ -284,7 +284,7 @@ extern "C" { } } } - else if (dates[p]->array[i].operation == kt_remove_flag_date_less_equal_e) { + else if (dates[p]->array[i].operation == kt_remove_flag_date_less_equal_d) { name_type = kt_remove_date_symbol_less_equal_s; result = F_false; @@ -300,7 +300,7 @@ extern "C" { } } } - else if (dates[p]->array[i].operation == kt_remove_flag_date_more_e) { + else if (dates[p]->array[i].operation == kt_remove_flag_date_more_d) { name_type = kt_remove_date_symbol_more_s; result = F_false; @@ -316,7 +316,7 @@ extern "C" { } } } - else if (dates[p]->array[i].operation == kt_remove_flag_date_more_equal_e) { + else if (dates[p]->array[i].operation == kt_remove_flag_date_more_equal_d) { name_type = kt_remove_date_symbol_more_equal_s; result = F_false; @@ -332,7 +332,7 @@ extern "C" { } } } - else if (dates[p]->array[i].operation == kt_remove_flag_date_not_e) { + else if (dates[p]->array[i].operation == kt_remove_flag_date_not_d) { name_type = kt_remove_date_symbol_not_s; result = F_true; @@ -346,7 +346,7 @@ extern "C" { } } } - else if (dates[p]->array[i].operation == kt_remove_flag_date_equal_e) { + else if (dates[p]->array[i].operation == kt_remove_flag_date_equal_d) { name_type = kt_remove_date_symbol_equal_s; if (match_year == start_year && match_second == start_second && times[p].tv_nsec == dates[p]->array[i].start_nanosecond) { @@ -356,7 +356,7 @@ extern "C" { result = F_false; } } - else if (dates[p]->array[i].operation == kt_remove_flag_date_less_e) { + else if (dates[p]->array[i].operation == kt_remove_flag_date_less_d) { name_type = kt_remove_date_symbol_less_s; result = F_false; @@ -372,7 +372,7 @@ extern "C" { } } } - else if (dates[p]->array[i].operation == kt_remove_flag_date_less_equal_e) { + else if (dates[p]->array[i].operation == kt_remove_flag_date_less_equal_d) { name_type = kt_remove_date_symbol_less_equal_s; result = F_false; @@ -388,7 +388,7 @@ extern "C" { } } } - else if (dates[p]->array[i].operation == kt_remove_flag_date_more_e) { + else if (dates[p]->array[i].operation == kt_remove_flag_date_more_d) { name_type = kt_remove_date_symbol_more_s; result = F_false; @@ -404,7 +404,7 @@ extern "C" { } } } - else if (dates[p]->array[i].operation == kt_remove_flag_date_more_equal_e) { + else if (dates[p]->array[i].operation == kt_remove_flag_date_more_equal_d) { name_type = kt_remove_date_symbol_more_equal_s; result = F_false; @@ -420,7 +420,7 @@ extern "C" { } } } - else if (dates[p]->array[i].operation == kt_remove_flag_date_not_e) { + else if (dates[p]->array[i].operation == kt_remove_flag_date_not_d) { name_type = kt_remove_date_symbol_not_s; if (match_year != start_year || match_second != start_second || times[p].tv_nsec != dates[p]->array[i].start_nanosecond) { @@ -451,7 +451,7 @@ extern "C" { kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; - if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) return; + if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) return; fll_print_format(" %r %r%r", main->program.output.to, name, yes ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); } diff --git a/sources/c/remove/main/print/simulate.h b/sources/c/remove/main/print/simulate.h index 014f867..b329f5c 100644 --- a/sources/c/remove/main/print/simulate.h +++ b/sources/c/remove/main/print/simulate.h @@ -19,7 +19,7 @@ extern "C" { /** * Simulate operate. * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. + * This does nothing if the simulate flag (kt_remove_flag_simulate_d) is not set. * * @param print * The output structure to print to. @@ -35,7 +35,7 @@ extern "C" { /** * Simulate operate on a single file. * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. + * This does nothing if the simulate flag (kt_remove_flag_simulate_d) is not set. * * @param print * The output structure to print to. @@ -53,7 +53,7 @@ extern "C" { /** * Simulate operate on a single file, processing file existence. * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. + * This does nothing if the simulate flag (kt_remove_flag_simulate_d) is not set. * * @param print * The output structure to print to. @@ -71,7 +71,7 @@ extern "C" { /** * Simulate operate on a single file, processing file statistics. * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. + * This does nothing if the simulate flag (kt_remove_flag_simulate_d) is not set. * * @param print * The output structure to print to. @@ -89,7 +89,7 @@ extern "C" { /** * Print a boolean message for some named parameter regarding the simulation. * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. + * This does nothing if the simulate flag (kt_remove_flag_simulate_d) is not set. * * @param print * The output structure to print to. diff --git a/sources/c/remove/main/print/warning.c b/sources/c/remove/main/print/warning.c index cb01137..b12d226 100644 --- a/sources/c/remove/main/print/warning.c +++ b/sources/c/remove/main/print/warning.c @@ -11,7 +11,7 @@ extern "C" { kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; - if (print->verbosity < f_console_verbosity_verbose_e && !(main->setting.flag & kt_remove_main_flag_force_e)) return F_output_not; + if (print->verbosity < f_console_verbosity_verbose_e && !(main->setting.flag & kt_remove_main_flag_force_d)) return F_output_not; f_file_stream_lock(print->to); diff --git a/sources/c/remove/main/print/warning.h b/sources/c/remove/main/print/warning.h index 7317250..9dc4cf8 100644 --- a/sources/c/remove/main/print/warning.h +++ b/sources/c/remove/main/print/warning.h @@ -19,9 +19,9 @@ extern "C" { /** * Print warning message about file not being found. * - * This is only printed when verbosity is less than verbose and kt_remove_flag_print_warning_e is not set. - * This is not printed when verbosity is set to quiet even when kt_remove_flag_print_warning_e is set. - * This is not printed when kt_remove_flag_force_e is set. + * This is only printed when verbosity is less than verbose and kt_remove_flag_print_warning_d is not set. + * This is not printed when verbosity is set to quiet even when kt_remove_flag_print_warning_d is set. + * This is not printed when kt_remove_flag_force_d is set. * * This uses the following: * - print.set->warning: For the warning context. diff --git a/sources/c/remove/main/remove.c b/sources/c/remove/main/remove.c index 1cc00e5..4be11dd 100644 --- a/sources/c/remove/main/remove.c +++ b/sources/c/remove/main/remove.c @@ -11,16 +11,16 @@ extern "C" { main->setting.state.status = F_okay; - if (main->setting.flag & kt_remove_main_flag_version_copyright_help_e) { - if (main->setting.flag & kt_remove_main_flag_help_e) { + if (main->setting.flag & kt_remove_main_flag_version_copyright_help_d) { + if (main->setting.flag & kt_remove_main_flag_help_d) { if (main->setting.process_help) { main->setting.process_help((void *) main); } } - else if (main->setting.flag & kt_remove_main_flag_version_e) { + else if (main->setting.flag & kt_remove_main_flag_version_d) { fll_program_print_version(&main->program.message, kt_remove_program_version_s); } - else if (main->setting.flag & kt_remove_main_flag_copyright_e) { + else if (main->setting.flag & kt_remove_main_flag_copyright_d) { fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } @@ -86,7 +86,7 @@ extern "C" { kt_remove_operate_file(main, main->setting.files.array[i]); - if ((main->setting.flag & kt_remove_main_flag_simulate_e) && i + 1 < main->setting.files.used && (F_status_is_error_not(main->setting.state.status) || F_status_set_fine(main->setting.state.status) == F_interrupt)) { + if ((main->setting.flag & kt_remove_main_flag_simulate_d) && i + 1 < main->setting.files.used && (F_status_is_error_not(main->setting.state.status) || F_status_set_fine(main->setting.state.status) == F_interrupt)) { f_print_dynamic(f_string_eol_s, main->program.output.to); } diff --git a/sources/c/tacocat/main/common.c b/sources/c/tacocat/main/common.c index 3f3df3e..87b82b5 100644 --- a/sources/c/tacocat/main/common.c +++ b/sources/c/tacocat/main/common.c @@ -62,24 +62,24 @@ extern "C" { f_number_unsigned_t index = 0; if (main->program.parameters.array[kt_tacocat_parameter_help_e].result & f_console_result_found_e) { - main->setting.flag |= kt_tacocat_main_flag_help_e; + main->setting.flag |= kt_tacocat_main_flag_help_d; } else { - main->setting.flag &= ~kt_tacocat_main_flag_help_e; + main->setting.flag &= ~kt_tacocat_main_flag_help_d; } if (main->program.parameters.array[kt_tacocat_parameter_version_e].result & f_console_result_found_e) { - main->setting.flag |= kt_tacocat_main_flag_version_e; + main->setting.flag |= kt_tacocat_main_flag_version_d; } else { - main->setting.flag &= ~kt_tacocat_main_flag_version_e; + main->setting.flag &= ~kt_tacocat_main_flag_version_d; } if (main->program.parameters.array[kt_tacocat_parameter_copyright_e].result & f_console_result_found_e) { - main->setting.flag |= kt_tacocat_main_flag_copyright_e; + main->setting.flag |= kt_tacocat_main_flag_copyright_d; } else { - main->setting.flag &= ~kt_tacocat_main_flag_copyright_e; + main->setting.flag &= ~kt_tacocat_main_flag_copyright_d; } if (main->program.parameters.array[kt_tacocat_parameter_resolve_e].result & f_console_result_found_e) { @@ -91,12 +91,12 @@ extern "C" { index = main->program.parameters.array[kt_tacocat_parameter_resolve_e].values.array[main->program.parameters.array[kt_tacocat_parameter_resolve_e].values.used - 1]; if (f_compare_dynamic(main->program.parameters.arguments.array[index], kt_tacocat_classic_s) == F_equal_to) { - main->setting.flag &= ~kt_tacocat_main_flag_resolve_kevux_e; - main->setting.flag |= kt_tacocat_main_flag_resolve_classic_e; + main->setting.flag &= ~kt_tacocat_main_flag_resolve_kevux_d; + main->setting.flag |= kt_tacocat_main_flag_resolve_classic_d; } else if (f_compare_dynamic(main->program.parameters.arguments.array[index], kt_tacocat_kevux_s) == F_equal_to) { - main->setting.flag &= ~kt_tacocat_main_flag_resolve_classic_e; - main->setting.flag |= kt_tacocat_main_flag_resolve_kevux_e; + main->setting.flag &= ~kt_tacocat_main_flag_resolve_classic_d; + main->setting.flag |= kt_tacocat_main_flag_resolve_kevux_d; } else { main->setting.state.status = F_status_set_error(F_parameter); @@ -106,11 +106,11 @@ extern "C" { } else { #ifdef _kt_resolve_default_kevux_ - main->setting.flag &= ~kt_tacocat_main_flag_resolve_classic_e; - main->setting.flag |= kt_tacocat_main_flag_resolve_kevux_e; + main->setting.flag &= ~kt_tacocat_main_flag_resolve_classic_d; + main->setting.flag |= kt_tacocat_main_flag_resolve_kevux_d; #else - main->setting.flag &= ~kt_tacocat_main_flag_resolve_kevux_e; - main->setting.flag |= kt_tacocat_main_flag_resolve_classic_e; + main->setting.flag &= ~kt_tacocat_main_flag_resolve_kevux_d; + main->setting.flag |= kt_tacocat_main_flag_resolve_classic_d; #endif // _kt_resolve_default_kevux_ } @@ -166,12 +166,12 @@ extern "C" { kt_tacocat_print_warning_parameter_integer_less_than(&main->program.warning, f_console_symbol_long_normal_s, kt_tacocat_long_max_buffer_s, main->program.parameters.arguments.array[index]); main->setting.max_buffer = 0; - main->setting.flag |= kt_tacocat_main_flag_max_buffer_e; + main->setting.flag |= kt_tacocat_main_flag_max_buffer_d; } else if (main->setting.state.status == F_number_negative) { if (number == 1) { main->setting.max_buffer = 0; - main->setting.flag &= ~kt_tacocat_main_flag_max_buffer_e; + main->setting.flag &= ~kt_tacocat_main_flag_max_buffer_d; } else { main->setting.state.status = F_status_set_error(F_parameter); @@ -183,7 +183,7 @@ extern "C" { } else { main->setting.max_buffer = number; - main->setting.flag |= kt_tacocat_main_flag_max_buffer_e; + main->setting.flag |= kt_tacocat_main_flag_max_buffer_d; } } else if (main->program.parameters.array[kt_tacocat_parameter_max_buffer_e].result & f_console_result_found_e) { @@ -195,7 +195,7 @@ extern "C" { } // Only process these when needed to avoid unnecessary operations. - if (main->callback.setting_load_send_receive && !(main->setting.flag & (kt_tacocat_main_flag_copyright_e | kt_tacocat_main_flag_version_e |kt_tacocat_main_flag_help_e))) { + if (main->callback.setting_load_send_receive && !(main->setting.flag & (kt_tacocat_main_flag_copyright_d | kt_tacocat_main_flag_version_d |kt_tacocat_main_flag_help_d))) { main->callback.setting_load_send_receive(arguments, (void *) main); } @@ -218,8 +218,8 @@ extern "C" { }; const uint64_t flags[] = { - kt_tacocat_main_flag_receive_e, - kt_tacocat_main_flag_send_e, + kt_tacocat_main_flag_receive_d, + kt_tacocat_main_flag_send_d, }; const f_string_static_t longs[] = { @@ -354,7 +354,7 @@ extern "C" { sets[i]->array[j].socket.type = f_socket_type_stream_e; sets[i]->array[j].socket.name = sets[i]->array[j].network; } - else if (main->setting.flag & kt_tacocat_main_flag_resolve_classic_e) { + else if (main->setting.flag & kt_tacocat_main_flag_resolve_classic_d) { memset(&host, 0, sizeof(struct hostent)); memset(&family, 0, sizeof(f_network_family_ip_t)); diff --git a/sources/c/tacocat/main/common/define.h b/sources/c/tacocat/main/common/define.h index 97365a1..5a71168 100644 --- a/sources/c/tacocat/main/common/define.h +++ b/sources/c/tacocat/main/common/define.h @@ -19,11 +19,6 @@ extern "C" { /** * The program defines. * - * kt_tacocat_allocation_*_d: - * - console: An allocation step used for small buffers specifically for console parameter. - * - large: An allocation step used for buffers that are anticipated to have large buffers. - * - small: An allocation step used for buffers that are anticipated to have small buffers. - * * kt_tacocat_block_*_d: * - size: The block size in bytes to use for either sending or receiving. * - size_receive: The block size in bytes to use when sending packets. @@ -64,10 +59,6 @@ extern "C" { * - delay_nanosecond: The delay in nanoseconds to wait if the first non-blocking random seed setup fails. */ #ifndef _di_kt_tacocat_d_ - #define kt_tacocat_allocation_console_d 0x4 - #define kt_tacocat_allocation_large_d 0x800 - #define kt_tacocat_allocation_small_d 0x80 - #define kt_tacocat_block_size_d 0xffff #define kt_tacocat_block_size_receive_d kt_tacocat_block_size_d #define kt_tacocat_block_size_send_d kt_tacocat_block_size_d @@ -101,6 +92,22 @@ extern "C" { #endif // _di_kt_tacocat_d_ /** + * The program allocation defines. + * + * control_allocation_*_d: + * - console: An allocation step used for small buffers specifically for console parameter. + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - pipe: A buffer size used for processing piped data. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_kt_tacocat_allocation_d_ + #define kt_tacocat_allocation_console_d 4 + #define kt_tacocat_allocation_large_d 2048 + #define kt_tacocat_allocation_pipe_d 16384 + #define kt_tacocat_allocation_small_d 8 +#endif // _di_kt_tacocat_allocation_d_ + +/** * The program macros. * * macro_setting_load_handle_send_receive_error_continue_1: @@ -201,6 +208,110 @@ extern "C" { } #endif // _di_kt_tacocat_macro_d_ +/** + * Flags passed to the main function or program. + * + * kt_tacocat_main_flag_*_d: + * - none: No flags set. + * - copyright: Print copyright. + * - max_buffer: When set, a maximum buffer on receive is enforced. + * - receive: The address or socket to receive from is specified. + * - resolve_classic: Follow the classic Domain Name Resolution method. + * - resolve_kevux: Follow the Kevux Domain Name Resolution method. + * - send: The address or socket send to is specified. + * - help: Print help. + * - version: Print version. + * - version_copyright_help: A helper flag representing version, copyright, and help flag bits being set. + * + * For resolve_classic and resolve_kevux flags: + * The classic method utilizes the /etc/resolv.conf traditional method. + * Under classic, the http://, https://, etc.. act as normal. + * + * The Kevux method utilizes /etc/resolution/ method. + * Under Kevux, the web:// represents the traditional DNS, but kevux:// might represent Kevux network. + * For example web://www.google.com:443/ would be the same as https://www.google.com/, following DNS via /etc/resolution/dns/web.conf or /etc/resolution/host/web.conf. + * For example kevux://www.google.com:443/ would be a different server than google, following DNS via /etc/resolution/dns/kevux.conf or /etc/resolution/host/kevux.conf. + * The Kevux method also supports local DNS entries ie (~/.resolution/dns/kevux.conf or ~/.resolution/host/kevux.conf). + * @todo The Kevux method will be implemented in a library (project resolution and libresolution), re-introducing and expanding on the Turtle Kevux resolv.conf extensions that Kevin hacked into uClibc several years back. + */ +#ifndef _di_kt_tacocat_main_flag_d_ + #define kt_tacocat_main_flag_none_d 0x0 + #define kt_tacocat_main_flag_copyright_d 0x1 + #define kt_tacocat_main_flag_help_d 0x2 + #define kt_tacocat_main_flag_max_buffer_d 0x4 + #define kt_tacocat_main_flag_receive_d 0x8 + #define kt_tacocat_main_flag_resolve_classic_d 0x10 + #define kt_tacocat_main_flag_resolve_kevux_d 0x20 + #define kt_tacocat_main_flag_resolve_d 0x40 + #define kt_tacocat_main_flag_send_d 0x80 + #define kt_tacocat_main_flag_version_d 0x100 + #define kt_tacocat_main_flag_version_copyright_help_d 0x103 +#endif // _di_kt_tacocat_main_flag_d_ + +/** + * Types of packets. + * + * kt_tacocat_packet_type_*_d: + * - none: No type is set. + * - abort: The packet is designates that the connection is to be aborted. + * - done: The package acknowledges the receipt of a packet. + * - file: The packet is a file. + * - next: The packet is a request for the next file. + * - resend: The packet is a request to resend the given part number. + */ +#ifndef _di_kt_tacocat_packet_type_d_ + #define kt_tacocat_packet_type_none_d 0x0 + #define kt_tacocat_packet_type_abort_d 0x1 + #define kt_tacocat_packet_type_done_d 0x2 + #define kt_tacocat_packet_type_file_d 0x4 + #define kt_tacocat_packet_type_next_d 0x8 + #define kt_tacocat_packet_type_resend_d 0x10 +#endif // _di_kt_tacocat_packet_type_d_ + +/** + * Flags for fine-tuned print control. + * + * kt_tacocat_print_flag_*_d: + * - none: No flags set. + * - debug: Stream is for debug printing. + * - error: Stream is for error printing. + * - file: Stream is associated with a file. + * - in: Stream is a source file. + * - message: Stream is for message printing. + * - out: Stream is a destination file. + * - warning: Stream is for warning printing. + */ +#ifndef _di_kt_tacocat_print_flag_d_ + #define kt_tacocat_print_flag_none_d 0x0 + #define kt_tacocat_print_flag_debug_d 0x1 + #define kt_tacocat_print_flag_error_d 0x2 + #define kt_tacocat_print_flag_file_d 0x4 + #define kt_tacocat_print_flag_in_d 0x8 + #define kt_tacocat_print_flag_message_d 0x10 + #define kt_tacocat_print_flag_out_d 0x20 + #define kt_tacocat_print_flag_warning_d 0x40 +#endif // _di_kt_tacocat_print_flag_d_ + +/** + * Socket related flags, such as designating handling of error packet. + * + * kt_tacocat_socket_flag_*_d: + * - none: No flags set. + * - abort: Abort connection. + * - done: Send packet confirming that everything is done. + * - listen: Listen for a response to a previously sent connection. + * - next: Request or Send next packet for existing connection. + * - resend: Send packet for requesting a re-send of the previous packet. + */ +#ifndef _di_kt_tacocat_socket_flag_e_ + #define kt_tacocat_socket_flag_none_e 0x0 + #define kt_tacocat_socket_flag_abort_e 0x1 + #define kt_tacocat_socket_flag_done_e 0x2 + #define kt_tacocat_socket_flag_listen_e 0x4 + #define kt_tacocat_socket_flag_next_e 0x8 + #define kt_tacocat_socket_flag_resend_e 0x10 +#endif // _di_kt_tacocat_socket_flag_e_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/sources/c/tacocat/main/common/enumeration.h b/sources/c/tacocat/main/common/enumeration.h index ed9c2e6..ce59693 100644 --- a/sources/c/tacocat/main/common/enumeration.h +++ b/sources/c/tacocat/main/common/enumeration.h @@ -17,48 +17,6 @@ extern "C" { #endif /** - * Flags passed to the main function or program. - * - * kt_tacocat_main_flag_*_e: - * - none: No flags set. - * - copyright: Print copyright. - * - max_buffer: When set, a maximum buffer on receive is enforced. - * - receive: The address or socket to receive from is specified. - * - resolve_classic: Follow the classic Domain Name Resolution method. - * - resolve_kevux: Follow the Kevux Domain Name Resolution method. - * - send: The address or socket send to is specified. - * - help: Print help. - * - version: Print version. - * - version_copyright_help: A helper flag representing version, copyright, and help flag bits being set. - * - * For resolve_classic and resolve_kevux flags: - * The classic method utilizes the /etc/resolv.conf traditional method. - * Under classic, the http://, https://, etc.. act as normal. - * - * The Kevux method utilizes /etc/resolution/ method. - * Under Kevux, the web:// represents the traditional DNS, but kevux:// might represent Kevux network. - * For example web://www.google.com:443/ would be the same as https://www.google.com/, following DNS via /etc/resolution/dns/web.conf or /etc/resolution/host/web.conf. - * For example kevux://www.google.com:443/ would be a different server than google, following DNS via /etc/resolution/dns/kevux.conf or /etc/resolution/host/kevux.conf. - * The Kevux method also supports local DNS entries ie (~/.resolution/dns/kevux.conf or ~/.resolution/host/kevux.conf). - * @todo The Kevux method will be implemented in a library (project resolution and libresolution), re-introducing and expanding on the Turtle Kevux resolv.conf extensions that Kevin hacked into uClibc several years back. - */ -#ifndef _di_kt_tacocat_main_flag_e_ - enum { - kt_tacocat_main_flag_none_e = 0x0, - kt_tacocat_main_flag_copyright_e = 0x1, - kt_tacocat_main_flag_help_e = 0x2, - kt_tacocat_main_flag_max_buffer_e = 0x4, - kt_tacocat_main_flag_receive_e = 0x8, - kt_tacocat_main_flag_resolve_classic_e = 0x10, - kt_tacocat_main_flag_resolve_kevux_e = 0x20, - kt_tacocat_main_flag_resolve_e = 0x40, - kt_tacocat_main_flag_send_e = 0x80, - kt_tacocat_main_flag_version_e = 0x100, - kt_tacocat_main_flag_version_copyright_help_e = 0x103, - }; // enum -#endif // _di_kt_tacocat_main_flag_e_ - -/** * The main program parameters. */ #ifndef _di_kt_tacocat_parameter_e_ @@ -97,76 +55,6 @@ extern "C" { #endif // _di_kt_tacocat_parameter_e_ /** - * Types of packets. - * - * kt_tacocat_packet_type_*_e: - * - none: No type is set. - * - abort: The packet is designates that the connection is to be aborted. - * - done: The package acknowledges the receipt of a packet. - * - file: The packet is a file. - * - next: The packet is a request for the next file. - * - resend: The packet is a request to resend the given part number. - */ -#ifndef _di_kt_tacocat_packet_type_e_ - enum { - kt_tacocat_packet_type_none_e = 0x0, - kt_tacocat_packet_type_abort_e = 0x1, - kt_tacocat_packet_type_done_e = 0x2, - kt_tacocat_packet_type_file_e = 0x4, - kt_tacocat_packet_type_next_e = 0x8, - kt_tacocat_packet_type_resend_e = 0x10, - }; // enum -#endif // _di_kt_tacocat_packet_type_e_ - -/** - * Flags for fine-tuned print control. - * - * kt_tacocat_print_flag_*_e: - * - none: No flags set. - * - debug: Stream is for debug printing. - * - error: Stream is for error printing. - * - file: Stream is associated with a file. - * - in: Stream is a source file. - * - message: Stream is for message printing. - * - out: Stream is a destination file. - * - warning: Stream is for warning printing. - */ -#ifndef _di_kt_tacocat_print_flag_e_ - enum { - kt_tacocat_print_flag_none_e = 0x0, - kt_tacocat_print_flag_debug_e = 0x1, - kt_tacocat_print_flag_error_e = 0x2, - kt_tacocat_print_flag_file_e = 0x4, - kt_tacocat_print_flag_in_e = 0x8, - kt_tacocat_print_flag_message_e = 0x10, - kt_tacocat_print_flag_out_e = 0x20, - kt_tacocat_print_flag_warning_e = 0x40, - }; // enum -#endif // _di_kt_tacocat_print_flag_e_ - -/** - * Socket related flags, such as designating handling of error packet. - * - * kt_tacocat_socket_flag_*_e: - * - none: No flags set. - * - abort: Abort connection. - * - done: Send packet confirming that everything is done. - * - listen: Listen for a response to a previously sent connection. - * - next: Request or Send next packet for existing connection. - * - resend: Send packet for requesting a re-send of the previous packet. - */ -#ifndef _di_kt_tacocat_socket_flag_e_ - enum { - kt_tacocat_socket_flag_none_e = 0, - kt_tacocat_socket_flag_abort_e = 0x1, - kt_tacocat_socket_flag_done_e = 0x2, - kt_tacocat_socket_flag_listen_e = 0x4, - kt_tacocat_socket_flag_next_e = 0x8, - kt_tacocat_socket_flag_resend_e = 0x10, - }; // enum -#endif // _di_kt_tacocat_socket_flag_e_ - -/** * Individual socket-specific steps for receiving. * * kt_tacocat_socket_step_receive_*_e: diff --git a/sources/c/tacocat/main/common/type.h b/sources/c/tacocat/main/common/type.h index e21397c..5f390e3 100644 --- a/sources/c/tacocat/main/common/type.h +++ b/sources/c/tacocat/main/common/type.h @@ -318,7 +318,7 @@ extern "C" { #define kt_tacocat_setting_t_initialize \ { \ - kt_tacocat_main_flag_max_buffer_e, \ + kt_tacocat_main_flag_max_buffer_d, \ kt_tacocat_interval_poll_d, \ kt_tacocat_interval_poll_fast_d, \ kt_tacocat_max_buffer_d, \ diff --git a/sources/c/tacocat/main/main.c b/sources/c/tacocat/main/main.c index eccc190..4f9ac28 100644 --- a/sources/c/tacocat/main/main.c +++ b/sources/c/tacocat/main/main.c @@ -9,11 +9,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { kt_tacocat_main_t data = kt_tacocat_main_t_initialize; - data.program.debug.flag |= kt_tacocat_print_flag_debug_e | kt_tacocat_print_flag_out_e; - data.program.error.flag |= kt_tacocat_print_flag_error_e | kt_tacocat_print_flag_out_e; - data.program.message.flag |= kt_tacocat_print_flag_message_e | kt_tacocat_print_flag_out_e; - data.program.output.flag |= kt_tacocat_print_flag_out_e; - data.program.warning.flag |= kt_tacocat_print_flag_warning_e | kt_tacocat_print_flag_out_e; + data.program.debug.flag |= kt_tacocat_print_flag_debug_d | kt_tacocat_print_flag_out_d; + data.program.error.flag |= kt_tacocat_print_flag_error_d | kt_tacocat_print_flag_out_d; + data.program.message.flag |= kt_tacocat_print_flag_message_d | kt_tacocat_print_flag_out_d; + data.program.output.flag |= kt_tacocat_print_flag_out_d; + data.program.warning.flag |= kt_tacocat_print_flag_warning_d | kt_tacocat_print_flag_out_d; data.program.message.custom = (void *) &data; data.program.output.custom = (void *) &data; data.program.error.custom = (void *) &data; diff --git a/sources/c/tacocat/main/packet.c b/sources/c/tacocat/main/packet.c index d52180c..bfab262 100644 --- a/sources/c/tacocat/main/packet.c +++ b/sources/c/tacocat/main/packet.c @@ -163,19 +163,19 @@ extern "C" { if (set->abstruses.array[1].value.type) { if (f_compare_dynamic_partial_string(kt_tacocat_file_s.string, set->buffer, kt_tacocat_file_s.used, set->abstruses.array[1].value.is.a_range) == F_equal_to) { set->abstruses.array[1].value.type = f_abstruse_unsigned_e; - set->abstruses.array[1].value.is.a_unsigned = (f_number_unsigned_t) kt_tacocat_packet_type_file_e; + set->abstruses.array[1].value.is.a_unsigned = (f_number_unsigned_t) kt_tacocat_packet_type_file_d; } else if (f_compare_dynamic_partial_string(kt_tacocat_done_s.string, set->buffer, kt_tacocat_done_s.used, set->abstruses.array[1].value.is.a_range) == F_equal_to) { set->abstruses.array[1].value.type = f_abstruse_unsigned_e; - set->abstruses.array[1].value.is.a_unsigned = (f_number_unsigned_t) kt_tacocat_packet_type_done_e; + set->abstruses.array[1].value.is.a_unsigned = (f_number_unsigned_t) kt_tacocat_packet_type_done_d; } else if (f_compare_dynamic_partial_string(kt_tacocat_next_s.string, set->buffer, kt_tacocat_next_s.used, set->abstruses.array[1].value.is.a_range) == F_equal_to) { set->abstruses.array[1].value.type = f_abstruse_unsigned_e; - set->abstruses.array[1].value.is.a_unsigned = (f_number_unsigned_t) kt_tacocat_packet_type_next_e; + set->abstruses.array[1].value.is.a_unsigned = (f_number_unsigned_t) kt_tacocat_packet_type_next_d; } else if (f_compare_dynamic_partial_string(kt_tacocat_resend_s.string, set->buffer, kt_tacocat_resend_s.used, set->abstruses.array[1].value.is.a_range) == F_equal_to) { set->abstruses.array[1].value.type = f_abstruse_unsigned_e; - set->abstruses.array[1].value.is.a_unsigned = (f_number_unsigned_t) kt_tacocat_packet_type_resend_e; + set->abstruses.array[1].value.is.a_unsigned = (f_number_unsigned_t) kt_tacocat_packet_type_resend_d; } else { set->status = F_status_set_error(F_found_not); diff --git a/sources/c/tacocat/main/process.c b/sources/c/tacocat/main/process.c index f496b52..dcfbe3d 100644 --- a/sources/c/tacocat/main/process.c +++ b/sources/c/tacocat/main/process.c @@ -15,19 +15,19 @@ extern "C" { // @todo implement fork and wait for both receive and send. #else { - if (main->setting.flag & kt_tacocat_main_flag_receive_e) { + if (main->setting.flag & kt_tacocat_main_flag_receive_d) { memset(&main->thread.id_receive, 0, sizeof(f_thread_id_t)); main->setting.state.status = f_thread_create(0, &main->thread.id_receive, kt_tacocat_receive, (void *) main); } if (F_status_is_error_not(main->setting.state.status)) { - if (main->setting.flag & kt_tacocat_main_flag_send_e) { + if (main->setting.flag & kt_tacocat_main_flag_send_d) { memset(&main->thread.id_send, 0, sizeof(f_thread_id_t)); main->setting.state.status = f_thread_create(0, &main->thread.id_send, kt_tacocat_send, (void *) main); - if (F_status_is_error(main->setting.state.status) && (main->setting.flag & kt_tacocat_main_flag_receive_e)) { + if (F_status_is_error(main->setting.state.status) && (main->setting.flag & kt_tacocat_main_flag_receive_d)) { f_thread_cancel(main->thread.id_receive); } } @@ -38,7 +38,7 @@ extern "C" { } } - if (main->setting.flag & kt_tacocat_main_flag_receive_e) { + if (main->setting.flag & kt_tacocat_main_flag_receive_d) { f_thread_join(main->thread.id_receive, 0); if (F_status_is_error(main->setting.status_receive)) { @@ -46,7 +46,7 @@ extern "C" { } } - if (main->setting.flag & kt_tacocat_main_flag_send_e) { + if (main->setting.flag & kt_tacocat_main_flag_send_d) { f_thread_join(main->thread.id_send, 0); if (F_status_is_error(main->setting.status_send) && F_status_is_error_not(main->setting.state.status)) { diff --git a/sources/c/tacocat/main/receive.c b/sources/c/tacocat/main/receive.c index 67b9c0a..ad58d5c 100644 --- a/sources/c/tacocat/main/receive.c +++ b/sources/c/tacocat/main/receive.c @@ -277,7 +277,7 @@ extern "C" { else { // The packet should only be a 'file' type for the first packet. - if (set->abstruses.array[1].value.type != f_abstruse_unsigned_e || set->abstruses.array[1].value.is.a_unsigned != kt_tacocat_packet_type_file_e) { + if (set->abstruses.array[1].value.type != f_abstruse_unsigned_e || set->abstruses.array[1].value.is.a_unsigned != kt_tacocat_packet_type_file_d) { macro_kt_receive_process_invalid_packet_exit_1(main, set->network, set->name, set->step, set->socket.id_data); } diff --git a/sources/c/tacocat/main/tacocat.c b/sources/c/tacocat/main/tacocat.c index ce2bb0f..6f9d524 100644 --- a/sources/c/tacocat/main/tacocat.c +++ b/sources/c/tacocat/main/tacocat.c @@ -13,14 +13,14 @@ extern "C" { main->setting.state.status = F_okay; - if (main->setting.flag & kt_tacocat_main_flag_version_copyright_help_e) { - if (main->setting.flag & kt_tacocat_main_flag_help_e) { + if (main->setting.flag & kt_tacocat_main_flag_version_copyright_help_d) { + if (main->setting.flag & kt_tacocat_main_flag_help_d) { kt_tacocat_print_message_help(&main->program.output, main->program.context); } - else if (main->setting.flag & kt_tacocat_main_flag_version_e) { + else if (main->setting.flag & kt_tacocat_main_flag_version_d) { fll_program_print_version(&main->program.message, kt_tacocat_program_version_s); } - else if (main->setting.flag & kt_tacocat_main_flag_copyright_e) { + else if (main->setting.flag & kt_tacocat_main_flag_copyright_d) { fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } -- 1.8.3.1