From: Kevin Day Date: Sat, 25 Mar 2023 04:31:03 +0000 (-0500) Subject: Update: Change this project from using FLL 0.6.x to FLL 0.7.x/0.8.x. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=bd05f99d1f5fb7fa8efeb604cd075d7b7c9831e0;p=kevux-tools Update: Change this project from using FLL 0.6.x to FLL 0.7.x/0.8.x. Most, if not all, of the practices are now migrated. If I missed anything, I will likely eventually find out. Change the file and path structure to match recent design changes. Update the install.sh script to the latest version. --- diff --git a/data/build/remove/fakefile b/data/build/remove/fakefile index 46636be..c893f9b 100644 --- a/data/build/remove/fakefile +++ b/data/build/remove/fakefile @@ -2,9 +2,26 @@ settings: fail exit - modes individual level monolithic clang test + modes individual level monolithic clang test fanalyzer coverage threaded threadless environment PATH LD_LIBRARY_PATH + environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH main: build remove/settings + +install: + shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' + +help: + print + print context:'title'Fakefile Options for Kevux Tools Remove Software.context:'reset' + + print + print The following operations are available\: + print " - context:'notable'help:context:'reset' Perform the help operation, printing this message." + print " - context:'notable'install:context:'reset' A helper operation that simply calls the ./install.sh script with default settings." + print " - context:'notable'main:context:'reset' The default compilation using the build settings mode." + + print + print The context:'notable'install context:'reset'operation supports the context:'notable'work,context:'reset' context:'notable'verbosity,context:'reset' and context:'notable'color context:'reset'parameters. diff --git a/data/build/remove/settings b/data/build/remove/settings index 39e18e3..53be599 100644 --- a/data/build/remove/settings +++ b/data/build/remove/settings @@ -1,4 +1,7 @@ # fss-0001 +# +# Builds the main remove program of the project. +# build_name remove @@ -8,7 +11,7 @@ version_micro 0 version_file micro version_target minor -modes individual level monolithic clang test threaded threadless +modes individual individual level monolithic clang test fanalyzer coverage threaded threadless modes_default monolithic threaded build_compiler gcc @@ -22,11 +25,13 @@ build_libraries-individual -lfll_error -lfll_print -lfll_program -lfl_conversion build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_library common.c common-print.c convert.c operate.c print.c remove.c signal.c simulate.c thread.c +build_sources_library main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/string.c main/common/type.c main/convert.c main/operate.c main/print/error.c main/print/message.c main/print/simulate.c main/print/verbose.c main/print/warning.c main/remove.c main/signal.c main/thread.c -build_sources_program main.c +build_sources_headers main/common.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/string.h main/common/type.h main/convert.h main/operate.h main/print/error.h main/print/message.h main/print/simulate.h main/print/verbose.h main/print/warning.h main/remove.h main/signal.h main/thread.h -build_sources_headers common.h common-print.h convert.h operate.h print.h remove.h signal.h simulate.h thread.h +build_sources_program main/main.c + +build_sources_documentation man build_script yes build_shared yes @@ -42,7 +47,7 @@ path_object_static static path_program_script script path_program_shared shared path_program_static static -path_sources sources/c/remove/main +path_sources sources/c/remove has_path_standard no preserve_path_headers yes @@ -52,6 +57,7 @@ search_shared yes search_static yes environment PATH LD_LIBRARY_PATH +environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH #defines -D_di_libcap_ defines -D_libcap_legacy_only_ @@ -61,7 +67,9 @@ defines-threadless -D_di_thread_support_ flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces flags-clang -Wno-logical-op-parentheses flags-test -O0 -fstack-protector -Wall +flags-fanalyzer -fanalyzer flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ +flags-threaded -pthread flags_library -fPIC flags_object -fPIC diff --git a/install.sh b/install.sh index 0ba3be8..ade1e61 100755 --- a/install.sh +++ b/install.sh @@ -66,17 +66,19 @@ install_main() { local destination_libraries_shared= local destination_programs_static= local destination_programs_shared= + local destination_settings=etc/ local work= - local enable_documentation= - local enable_shared= - local enable_shared_programs= - local enable_shared_libraries= - local enable_static= - local enable_static_programs= - local enable_static_libraries= - local enable_includes=yes + local enable_documentation="yes" + local enable_settings="yes" + local enable_shared="yes" + local enable_shared_programs="yes" + local enable_shared_libraries="yes" + local enable_static="yes" + local enable_static_programs="yes" + local enable_static_libraries="yes" + local enable_includes="yes" if [[ $# -gt 0 ]] ; then t=$# @@ -127,6 +129,10 @@ install_main() { grab_next=prefix elif [[ $p == "-B" || $p == "--bindir" ]] ; then grab_next=bindir + elif [[ $p == "-D" || $p == "--docdir" ]] ; then + grab_next=docdir + elif [[ $p == "-E" || $p == "--etcdir" ]] ; then + grab_next=etcdir elif [[ $p == "-I" || $p == "--includedir" ]] ; then grab_next=includedir elif [[ $p == "-L" || $p == "--libdir" ]] ; then @@ -137,6 +143,10 @@ install_main() { enable_documentation="yes" elif [[ $p == "--disable-doc" ]] ; then enable_documentation="no" + elif [[ $p == "--enable-settings" ]] ; then + enable_settings="yes" + elif [[ $p == "--disable-settings" ]] ; then + enable_settings="no" elif [[ $p == "--enable-shared" ]] ; then enable_shared="yes" elif [[ $p == "--disable-shared" ]] ; then @@ -157,8 +167,6 @@ install_main() { enable_includes="yes" elif [[ $p == "--disable-includes" ]] ; then enable_includes="no" - elif [[ $p == "--documentation" ]] ; then - grab_next="destination_documentation" elif [[ $p == "--libraries-static" ]] ; then grab_next="destination_libraries_static" elif [[ $p == "--libraries-shared" ]] ; then @@ -178,14 +186,16 @@ install_main() { destination_prefix=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') elif [[ $grab_next == "bindir" ]] ; then destination_programs=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') + elif [[ $grab_next == "docdir" ]] ; then + destination_documentation=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') + elif [[ $grab_next == "etcdir" ]] ; then + destination_settings=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') elif [[ $grab_next == "includedir" ]] ; then destination_includes=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') elif [[ $grab_next == "libdir" ]] ; then destination_libraries=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') elif [[ $grab_next == "work" ]] ; then work=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') - elif [[ $grab_next == "destination_documentation" ]] ; then - destination_documentation=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') elif [[ $grab_next == "destination_libraries_static" ]] ; then destination_libraries_static=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') elif [[ $grab_next == "destination_libraries_shared" ]] ; then @@ -258,6 +268,10 @@ install_main() { if [[ $(echo $destination_libraries | grep -o '^/') == "" ]] ; then destination_libraries="$destination_prefix$destination_libraries" fi + + if [[ $(echo $destination_settings | grep -o '^/') == "" ]] ; then + destination_settings="$destination_prefix$destination_settings" + fi fi if [[ $destination_libraries_static != "" ]] ; then @@ -302,7 +316,7 @@ install_main() { return 1 fi - if [[ $work == "" && ! -d $destination_programs ]] ; then + if [[ $work == "" && -e $destination_programs && ! -d $destination_programs ]] ; then if [[ $verbosity != "quiet" ]] ; then echo -e "${c_error}ERROR: The destination bindir ${c_notice}$destination_programs${c_error} is not a valid directory.${c_reset}" fi @@ -312,7 +326,7 @@ install_main() { return 1 fi - if [[ $work == "" && ! -d $destination_programs_static ]] ; then + if [[ $work == "" && -e $destination_programs_static && ! -d $destination_programs_static ]] ; then if [[ $verbosity != "quiet" ]] ; then echo -e "${c_error}ERROR: The destination (${c_notice}static${c_error}) bindir ${c_notice}$destination_programs_static${c_error} is not a valid directory.${c_reset}" fi @@ -322,7 +336,7 @@ install_main() { return 1 fi - if [[ $work == "" && ! -d $destination_programs_shared ]] ; then + if [[ $work == "" && -e $destination_programs_shared && ! -d $destination_programs_shared ]] ; then if [[ $verbosity != "quiet" ]] ; then echo -e "${c_error}ERROR: The destination (${c_notice}shared${c_error}) bindir ${c_notice}$destination_programs_shared${c_error} is not a valid directory.${c_reset}" fi @@ -332,7 +346,7 @@ install_main() { return 1 fi - if [[ $work == "" && ! -d $destination_includes ]] ; then + if [[ $work == "" && -e $destination_includes && ! -d $destination_includes ]] ; then if [[ $verbosity != "quiet" ]] ; then echo -e "${c_error}ERROR: The destination incluedir ${c_notice}$destination_includes${c_error} is not a valid directory.${c_reset}" fi @@ -342,7 +356,7 @@ install_main() { return 1 fi - if [[ $work == "" && ! -d $destination_libraries_static ]] ; then + if [[ $work == "" && -e $destination_libraries_static && ! -d $destination_libraries_static ]] ; then if [[ $verbosity != "quiet" ]] ; then echo -e "${c_error}ERROR: The destination (${c_notice}static${c_error}) libdir ${c_notice}$destination_libraries_static${c_error} is not a valid directory.${c_reset}" fi @@ -352,7 +366,7 @@ install_main() { return 1 fi - if [[ $work == "" && ! -d $destination_libraries_shared ]] ; then + if [[ $work == "" && -e $destination_libraries_shared && ! -d $destination_libraries_shared ]] ; then if [[ $verbosity != "quiet" ]] ; then echo -e "${c_error}ERROR: The destination (${c_notice}shared${c_error}) libdir ${c_notice}$destination_libraries_shared${c_error} is not a valid directory.${c_reset}" fi @@ -414,13 +428,17 @@ install_help() { echo -e " -${c_important}b${c_reset}, --${c_important}build${c_reset} Custom build directory." echo -e " -${c_important}P${c_reset}, --${c_important}prefix${c_reset} Custom destination prefix." echo -e " -${c_important}B${c_reset}, --${c_important}bindir${c_reset} Custom destination bin/ directory." + echo -e " -${c_important}D${c_reset}, --${c_important}docdir${c_reset} Custom destination share/ directory (documentation directory)." + echo -e " -${c_important}E${c_reset}, --${c_important}etcdir${c_reset} Custom destination etc/ directory (settings directory)." echo -e " -${c_important}I${c_reset}, --${c_important}includedir${c_reset} Custom destination include/ directory." echo -e " -${c_important}L${c_reset}, --${c_important}libdir${c_reset} Custom destination lib/ directory." - echo -e " -${c_important}w${c_reset}, --${c_important}work${c_reset} Install to this directory instead of system." + echo -e " -${c_important}w${c_reset}, --${c_important}work${c_reset} Install to this work directory using a 'working' directory structure." echo echo -e "${c_highlight}Special Options:${c_reset}" echo -e " --${c_important}enable-doc${c_reset} Forcibly do install documentation files." echo -e " --${c_important}disable-doc${c_reset} Forcibly do not install documentation files." + echo -e " --${c_important}enable-settings${c_reset} Forcibly do install settings files." + echo -e " --${c_important}disable-settings${c_reset} Forcibly do not install settings files." echo -e " --${c_important}enable-shared${c_reset} Forcibly do install shared files." echo -e " --${c_important}disable-shared${c_reset} Forcibly do not install shared files." echo -e " --${c_important}disable-shared-programs${c_reset} Forcibly do not install shared programs." @@ -431,7 +449,6 @@ install_help() { echo -e " --${c_important}disable-static-libraries${c_reset} Forcibly do not install shared libraries." echo -e " --${c_important}enable-includes${c_reset} Forcibly do not install include files." echo -e " --${c_important}disable-includes${c_reset} Forcibly do not install include files." - echo -e " --${c_important}documentation${c_reset} Custom destination for documentation files." echo -e " --${c_important}libraries-static${c_reset} Custom destination for static libraries." echo -e " --${c_important}libraries-shared${c_reset} Custom destination for shared libraries." echo -e " --${c_important}programs-static${c_reset} Custom destination for static programs." @@ -444,136 +461,161 @@ install_perform_install() { local i= local path= local failure= + local message= - if [[ $enable_documentation == "" ]] ; then - enable_documentation="yes" + if [[ $enable_shared == "no" ]] ; then + enable_shared_programs="no" + enable_shared_libraries="no" fi - if [[ $enable_shared == "" ]] ; then - enable_shared="yes" + if [[ $enable_static == "no" ]] ; then + enable_static_programs="no" + enable_static_libraries="no" fi - if [[ $enable_shared_programs == "" ]] ; then - enable_shared_programs="yes" - fi - - if [[ $enable_shared_libraries == "" ]] ; then - enable_shared_libraries="yes" - fi + if [[ $work == "" ]] ; then + message="install destination directory" + else + message="work directory" + destination_prefix=${work} + destination_documentation=${work}documentation/ + destination_programs=${work}programs/ + destination_programs_static=${destination_programs}static/ + destination_programs_shared=${destination_programs}shared/ + destination_includes=${work}includes/ + destination_libraries=${work}libraries/ + destination_libraries_static=${destination_libraries}static/ + destination_libraries_shared=${destination_libraries}shared/ + destination_settings=${work}settings/ + fi + + if [[ ! -d ${destination_prefix} ]] ; then + mkdir $verbose_common ${destination_prefix} + + if [[ $? -ne 0 ]] ; then + if [[ $verbosity != "quiet" ]] ; then + echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_prefix}${c_error}.${c_reset}" + fi - if [[ $enable_static == "" ]] ; then - enable_static="yes" + failure=1 + fi fi - if [[ $enable_static_programs == "" ]] ; then - enable_static_programs="yes" - fi + if [[ $enable_shared_programs == "yes" || $enable_static_programs == "yes" ]] ; then + if [[ -d ${path_build}${path_programs} && ! -d ${destination_programs} ]] ; then + mkdir $verbose_common ${destination_programs} - if [[ $enable_static_libraries == "" ]] ; then - enable_static_libraries="yes" - fi + if [[ $? -ne 0 ]] ; then + if [[ $verbosity != "quiet" ]] ; then + echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_programs}${c_error}.${c_reset}" + fi - if [[ $work != "" ]] ; then - if [[ $enable_shared_programs == "yes" || $enable_static_programs == "yes" ]] ; then - if [[ ! -d ${work}programs ]] ; then - mkdir $verbose_common ${work}programs + failure=1 + fi + fi - if [[ $? -ne 0 ]] ; then - if [[ $verbosity != "quiet" ]] ; then - echo -e "${c_error}ERROR: Failed to create work directories ${c_notice}${work}programs${c_error}.${c_reset}" - fi + if [[ $enable_shared_programs == "yes" && -d ${path_build}${path_programs}${path_shared} && ! -d ${destination_programs_shared} ]] ; then + mkdir $verbose_common ${destination_programs_shared} - failure=1 + if [[ $? -ne 0 ]] ; then + if [[ $verbosity != "quiet" ]] ; then + echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_programs_shared}${c_error}.${c_reset}" fi - fi - if [[ $enable_shared_programs == "yes" && -d ${path_build}${path_programs}${path_shared} && ! -d ${work}programs/shared ]] ; then - mkdir $verbose_common ${work}programs/shared + failure=1 + fi + fi - if [[ $? -ne 0 ]] ; then - if [[ $verbosity != "quiet" ]] ; then - echo -e "${c_error}ERROR: Failed to create work directories ${c_notice}${work}programs/shared${c_error}.${c_reset}" - fi + if [[ $enable_static_programs == "yes" && -d ${path_build}${path_programs}${path_static} && ! -d ${destination_programs_static} ]] ; then + mkdir $verbose_common ${destination_programs_static} - failure=1 + if [[ $? -ne 0 ]] ; then + if [[ $verbosity != "quiet" ]] ; then + echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_programs_static}${c_error}.${c_reset}" fi + + failure=1 fi + fi + fi - if [[ $enable_static_programs == "yes" && -d ${path_build}${path_programs}${path_static} && ! -d ${work}programs/static ]] ; then - mkdir $verbose_common ${work}programs/static + if [[ $enable_shared_libraries == "yes" || $enable_static_libraries == "yes" ]] ; then + if [[ -d ${path_build}${path_libraries} && ! -d ${destination_libraries} ]] ; then + mkdir $verbose_common ${destination_libraries} - if [[ $? -ne 0 ]] ; then - if [[ $verbosity != "quiet" ]] ; then - echo -e "${c_error}ERROR: Failed to create work directories ${c_notice}${work}programs/static${c_error}.${c_reset}" - fi - - failure=1 + if [[ $? -ne 0 ]] ; then + if [[ $verbosity != "quiet" ]] ; then + echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_libraries}${c_error}.${c_reset}" fi + + failure=1 fi fi - if [[ $enable_shared_libraries == "yes" || $enable_static_libraries == "yes" ]] ; then - if [[ ! -d ${work}libraries ]] ; then - mkdir $verbose_common ${work}libraries + if [[ $enable_shared_libraries == "yes" && -d ${path_build}${path_libraries}${path_shared} && ! -d ${destination_libraries_shared} ]] ; then + mkdir $verbose_common ${destination_libraries_shared} - if [[ $? -ne 0 ]] ; then - if [[ $verbosity != "quiet" ]] ; then - echo -e "${c_error}ERROR: Failed to create work directories ${c_notice}${work}libraries${c_error}.${c_reset}" - fi - - failure=1 + if [[ $? -ne 0 ]] ; then + if [[ $verbosity != "quiet" ]] ; then + echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_libraries_shared}${c_error}.${c_reset}" fi - fi - if [[ $enable_shared_libraries == "yes" && -d ${path_build}${path_libraries}${path_shared} && ! -d ${work}libraries/shared ]] ; then - mkdir $verbose_common ${work}libraries/shared + failure=1 + fi + fi - if [[ $? -ne 0 ]] ; then - if [[ $verbosity != "quiet" ]] ; then - echo -e "${c_error}ERROR: Failed to create work directories ${c_notice}${work}libraries/shared${c_error}.${c_reset}" - fi + if [[ $enable_static_libraries == "yes" && -d ${path_build}${path_libraries}${path_static} && ! -d ${destination_libraries_static} ]] ; then + mkdir $verbose_common ${destination_libraries_static} - failure=1 + if [[ $? -ne 0 ]] ; then + if [[ $verbosity != "quiet" ]] ; then + echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_libraries_static}${c_error}.${c_reset}" fi - fi - if [[ $enable_static_libraries == "yes" && -d ${path_build}${path_libraries}${path_static} && ! -d ${work}libraries/static ]] ; then - mkdir $verbose_common ${work}libraries/static + failure=1 + fi + fi + fi - if [[ $? -ne 0 ]] ; then - if [[ $verbosity != "quiet" ]] ; then - echo -e "${c_error}ERROR: Failed to create work directories ${c_notice}${work}libraries/static${c_error}.${c_reset}" - fi + if [[ $enable_includes == "yes" ]] ; then + if [[ -d ${path_build}${path_includes} && ! -d ${destination_includes} ]] ; then + mkdir $verbose_common ${destination_includes} - failure=1 + if [[ $? -ne 0 ]] ; then + if [[ $verbosity != "quiet" ]] ; then + echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_includes}${c_error}.${c_reset}" fi + + failure=1 fi fi + fi - if [[ $enable_includes == "yes" ]] ; then - if [[ ! -d ${work}includes ]] ; then - mkdir $verbose_common ${work}includes + if [[ $enable_documentation == "yes" ]] ; then + if [[ -d ${path_build}${path_documentation} && ! -d ${destination_documentation} ]] ; then + mkdir $verbose_common ${destination_documentation} - if [[ $? -ne 0 ]] ; then - if [[ $verbosity != "quiet" ]] ; then - echo -e "${c_error}ERROR: Failed to create work directories ${c_notice}${work}includes${c_error}.${c_reset}" - fi - - failure=1 + if [[ $? -ne 0 ]] ; then + if [[ $verbosity != "quiet" ]] ; then + echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_documentation}${c_error}.${c_reset}" fi + + failure=1 fi fi + fi + + if [[ $enable_settings == "yes" ]] ; then + if [[ -d ${path_build}${path_settings} && ! -d ${destination_settings} ]] ; then + mkdir $verbose_common ${destination_settings} + + if [[ $? -ne 0 ]] ; then + if [[ $verbosity != "quiet" ]] ; then + echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_settings}${c_error}.${c_reset}" + fi - if [[ $failure == "" ]] ; then - destination_prefix=${work} - destination_documentation=${work}documentation/ - destination_programs=${work}programs/ - destination_programs_static=${destination_programs}static/ - destination_programs_shared=${destination_programs}shared/ - destination_includes=${work}includes/ - destination_libraries=${work}libraries/ - destination_libraries_static=${destination_libraries}static/ - destination_libraries_shared=${destination_libraries}shared/ + failure=1 + fi fi fi @@ -744,8 +786,20 @@ install_perform_install() { fi if [[ $file != "" ]] ; then - echo - echo -e "${c_warning}Settings Files Detected, see: ${c_reset}${c_notice}${path_build}${path_settings}${c_reset}${c_warning}.${c_reset}" + if [[ $verbosity != "quiet" ]] ; then + echo + echo -e "${c_highlight}Installing Documentation to: ${c_reset}${c_notice}${destination_settings}${c_reset}${c_highlight}.${c_reset}" + fi + + cp $verbose_common -R ${path_build}${path_settings}* ${destination_settings} + + if [[ $? -ne 0 ]] ; then + if [[ $verbosity != "quiet" ]] ; then + echo -e "${c_error}ERROR: failed to copy documentation files from ${c_notice}${path_build}${path_programs}${path_static}${c_error} to ${c_notice}${destination_settings}${c_error}.${c_reset}" + fi + + failure=1 + fi fi fi diff --git a/sources/c/remove/main/common.c b/sources/c/remove/main/common.c index ebd6be8..d197c49 100644 --- a/sources/c/remove/main/common.c +++ b/sources/c/remove/main/common.c @@ -4,155 +4,6 @@ extern "C" { #endif -#ifndef _di_kt_remove_program_version_s_ - const f_string_static_t kt_remove_program_version_s = macro_f_string_static_t_initialize(KT_REMOVE_program_version_s, 0, KT_REMOVE_program_version_s_length); -#endif // _di_kt_remove_program_version_s_ - -#ifndef _di_kt_remove_program_name_s_ - const f_string_static_t kt_remove_program_name_s = macro_f_string_static_t_initialize(KT_REMOVE_program_name_s, 0, KT_REMOVE_program_name_s_length); - const f_string_static_t kt_remove_program_name_long_s = macro_f_string_static_t_initialize(KT_REMOVE_program_name_long_s, 0, KT_REMOVE_program_name_long_s_length); -#endif // _di_kt_remove_program_name_s_ - -#ifndef kt_remove_program_help_parameters_s_ - const f_string_static_t kt_remove_program_help_parameters_s = macro_f_string_static_t_initialize(KT_REMOVE_program_help_parameters_s, 0, KT_REMOVE_program_help_parameters_s_length); -#endif // _di_utf8_program_help_parameters_s_ - -#ifndef _di_kt_remove_date_s_ - const f_string_static_t kt_remove_date_format_00_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_00_s, 0, KT_REMOVE_date_format_00_s_length); - const f_string_static_t kt_remove_date_format_01_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_01_s, 0, KT_REMOVE_date_format_01_s_length); - const f_string_static_t kt_remove_date_format_02_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_02_s, 0, KT_REMOVE_date_format_02_s_length); - const f_string_static_t kt_remove_date_format_03_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_03_s, 0, KT_REMOVE_date_format_03_s_length); - const f_string_static_t kt_remove_date_format_04_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_04_s, 0, KT_REMOVE_date_format_04_s_length); - const f_string_static_t kt_remove_date_format_05_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_05_s, 0, KT_REMOVE_date_format_05_s_length); - const f_string_static_t kt_remove_date_format_06_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_06_s, 0, KT_REMOVE_date_format_06_s_length); - const f_string_static_t kt_remove_date_format_07_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_07_s, 0, KT_REMOVE_date_format_07_s_length); - const f_string_static_t kt_remove_date_format_08_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_08_s, 0, KT_REMOVE_date_format_08_s_length); - const f_string_static_t kt_remove_date_format_09_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_09_s, 0, KT_REMOVE_date_format_09_s_length); - const f_string_static_t kt_remove_date_format_10_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_10_s, 0, KT_REMOVE_date_format_10_s_length); - const f_string_static_t kt_remove_date_format_11_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_11_s, 0, KT_REMOVE_date_format_11_s_length); - const f_string_static_t kt_remove_date_format_12_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_12_s, 0, KT_REMOVE_date_format_12_s_length); - const f_string_static_t kt_remove_date_format_13_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_13_s, 0, KT_REMOVE_date_format_13_s_length); - const f_string_static_t kt_remove_date_format_14_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_14_s, 0, KT_REMOVE_date_format_14_s_length); - - const f_string_static_t kt_remove_date_format_example_00_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_00_s, 0, KT_REMOVE_date_format_example_00_s_length); - const f_string_static_t kt_remove_date_format_example_01_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_01_s, 0, KT_REMOVE_date_format_example_01_s_length); - const f_string_static_t kt_remove_date_format_example_02_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_02_s, 0, KT_REMOVE_date_format_example_02_s_length); - const f_string_static_t kt_remove_date_format_example_03_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_03_s, 0, KT_REMOVE_date_format_example_03_s_length); - const f_string_static_t kt_remove_date_format_example_04_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_04_s, 0, KT_REMOVE_date_format_example_04_s_length); - const f_string_static_t kt_remove_date_format_example_05_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_05_s, 0, KT_REMOVE_date_format_example_05_s_length); - const f_string_static_t kt_remove_date_format_example_06_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_06_s, 0, KT_REMOVE_date_format_example_06_s_length); - const f_string_static_t kt_remove_date_format_example_07_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_07_s, 0, KT_REMOVE_date_format_example_07_s_length); - const f_string_static_t kt_remove_date_format_example_08_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_08_s, 0, KT_REMOVE_date_format_example_08_s_length); - const f_string_static_t kt_remove_date_format_example_09_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_09_s, 0, KT_REMOVE_date_format_example_09_s_length); - const f_string_static_t kt_remove_date_format_example_10_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_10_s, 0, KT_REMOVE_date_format_example_10_s_length); - const f_string_static_t kt_remove_date_format_example_11_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_11_s, 0, KT_REMOVE_date_format_example_11_s_length); - const f_string_static_t kt_remove_date_format_example_12_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_12_s, 0, KT_REMOVE_date_format_example_12_s_length); - const f_string_static_t kt_remove_date_format_example_13_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_13_s, 0, KT_REMOVE_date_format_example_13_s_length); - const f_string_static_t kt_remove_date_format_example_14_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_14_s, 0, KT_REMOVE_date_format_example_14_s_length); - - const f_string_static_t kt_remove_date_symbol_equal_s = macro_f_string_static_t_initialize(KT_REMOVE_date_symbol_equal_s, 0, KT_REMOVE_date_symbol_equal_s_length); - const f_string_static_t kt_remove_date_symbol_less_s = macro_f_string_static_t_initialize(KT_REMOVE_date_symbol_less_s, 0, KT_REMOVE_date_symbol_less_s_length); - const f_string_static_t kt_remove_date_symbol_less_equal_s = macro_f_string_static_t_initialize(KT_REMOVE_date_symbol_less_equal_s, 0, KT_REMOVE_date_symbol_less_equal_s_length); - const f_string_static_t kt_remove_date_symbol_more_s = macro_f_string_static_t_initialize(KT_REMOVE_date_symbol_more_s, 0, KT_REMOVE_date_symbol_more_s_length); - const f_string_static_t kt_remove_date_symbol_more_equal_s = macro_f_string_static_t_initialize(KT_REMOVE_date_symbol_more_equal_s, 0, KT_REMOVE_date_symbol_more_equal_s_length); - const f_string_static_t kt_remove_date_symbol_not_s = macro_f_string_static_t_initialize(KT_REMOVE_date_symbol_not_s, 0, KT_REMOVE_date_symbol_not_s_length); - - const f_string_static_t kt_remove_date_word_equal_s = macro_f_string_static_t_initialize(KT_REMOVE_date_word_equal_s, 0, KT_REMOVE_date_word_equal_s_length); - const f_string_static_t kt_remove_date_word_less_s = macro_f_string_static_t_initialize(KT_REMOVE_date_word_less_s, 0, KT_REMOVE_date_word_less_s_length); - const f_string_static_t kt_remove_date_word_less_equal_s = macro_f_string_static_t_initialize(KT_REMOVE_date_word_less_equal_s, 0, KT_REMOVE_date_word_less_equal_s_length); - const f_string_static_t kt_remove_date_word_more_s = macro_f_string_static_t_initialize(KT_REMOVE_date_word_more_s, 0, KT_REMOVE_date_word_more_s_length); - const f_string_static_t kt_remove_date_word_more_equal_s = macro_f_string_static_t_initialize(KT_REMOVE_date_word_more_equal_s, 0, KT_REMOVE_date_word_more_equal_s_length); - const f_string_static_t kt_remove_date_word_not_s = macro_f_string_static_t_initialize(KT_REMOVE_date_word_not_s, 0, KT_REMOVE_date_word_not_s_length); -#endif // _di_kt_remove_date_s_ - -/** - * Strings associated with the mode parameters. - */ -#ifndef _di_kt_remove_mode_s_ - const f_string_static_t kt_remove_mode_symbol_different_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_symbol_different_s, 0, KT_REMOVE_mode_symbol_different_s_length); - const f_string_static_t kt_remove_mode_symbol_same_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_symbol_same_s, 0, KT_REMOVE_mode_symbol_same_s_length); - const f_string_static_t kt_remove_mode_symbol_similar_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_symbol_similar_s, 0, KT_REMOVE_mode_symbol_similar_s_length); - const f_string_static_t kt_remove_mode_symbol_not_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_symbol_not_s, 0, KT_REMOVE_mode_symbol_not_s_length); - - const f_string_static_t kt_remove_mode_word_different_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_word_different_s, 0, KT_REMOVE_mode_word_different_s_length); - const f_string_static_t kt_remove_mode_word_same_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_word_same_s, 0, KT_REMOVE_mode_word_same_s_length); - const f_string_static_t kt_remove_mode_word_similar_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_word_similar_s, 0, KT_REMOVE_mode_word_similar_s_length); - const f_string_static_t kt_remove_mode_word_not_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_word_not_s, 0, KT_REMOVE_mode_word_not_s_length); -#endif // _di_kt_remove_mode_s_ - -#ifndef _di_kt_remove_s_ - const f_string_static_t kt_remove_all_s = macro_f_string_static_t_initialize(KT_REMOVE_all_s, 0, KT_REMOVE_all_s_length); - const f_string_static_t kt_remove_follow_s = macro_f_string_static_t_initialize(KT_REMOVE_follow_s, 0, KT_REMOVE_follow_s_length); - const f_string_static_t kt_remove_ignore_s = macro_f_string_static_t_initialize(KT_REMOVE_ignore_s, 0, KT_REMOVE_ignore_s_length); - const f_string_static_t kt_remove_never_s = macro_f_string_static_t_initialize(KT_REMOVE_never_s, 0, KT_REMOVE_never_s_length); - const f_string_static_t kt_remove_no_s = macro_f_string_static_t_initialize(KT_REMOVE_no_s, 0, KT_REMOVE_no_s_length); - const f_string_static_t kt_remove_not_s = macro_f_string_static_t_initialize(KT_REMOVE_not_s, 0, KT_REMOVE_not_s_length); - const f_string_static_t kt_remove_not_fail_s = macro_f_string_static_t_initialize(KT_REMOVE_not_fail_s, 0, KT_REMOVE_not_fail_s_length); - const f_string_static_t kt_remove_now_s = macro_f_string_static_t_initialize(KT_REMOVE_now_s, 0, KT_REMOVE_now_s_length); - const f_string_static_t kt_remove_once_s = macro_f_string_static_t_initialize(KT_REMOVE_once_s, 0, KT_REMOVE_once_s_length); - const f_string_static_t kt_remove_only_s = macro_f_string_static_t_initialize(KT_REMOVE_only_s, 0, KT_REMOVE_only_s_length); - const f_string_static_t kt_remove_only_fail_s = macro_f_string_static_t_initialize(KT_REMOVE_only_fail_s, 0, KT_REMOVE_only_fail_s_length); - const f_string_static_t kt_remove_root_s = macro_f_string_static_t_initialize(KT_REMOVE_root_s, 0, KT_REMOVE_root_s_length); - const f_string_static_t kt_remove_today_s = macro_f_string_static_t_initialize(KT_REMOVE_today_s, 0, KT_REMOVE_today_s_length); - const f_string_static_t kt_remove_tomorrow_s = macro_f_string_static_t_initialize(KT_REMOVE_tomorrow_s, 0, KT_REMOVE_tomorrow_s_length); - const f_string_static_t kt_remove_yes_s = macro_f_string_static_t_initialize(KT_REMOVE_yes_s, 0, KT_REMOVE_yes_s_length); - const f_string_static_t kt_remove_yesterday_s = macro_f_string_static_t_initialize(KT_REMOVE_yesterday_s, 0, KT_REMOVE_yesterday_s_length); -#endif // _di_kt_remove_s_ - -#ifndef _di_kt_remove_parameter_d_ - const f_string_static_t kt_remove_short_accessed_s = macro_f_string_static_t_initialize(KT_REMOVE_short_accessed_s, 0, KT_REMOVE_short_accessed_s_length); - const f_string_static_t kt_remove_short_block_s = macro_f_string_static_t_initialize(KT_REMOVE_short_block_s, 0, KT_REMOVE_short_block_s_length); - const f_string_static_t kt_remove_short_character_s = macro_f_string_static_t_initialize(KT_REMOVE_short_character_s, 0, KT_REMOVE_short_character_s_length); - const f_string_static_t kt_remove_short_created_s = macro_f_string_static_t_initialize(KT_REMOVE_short_created_s, 0, KT_REMOVE_short_created_s_length); - const f_string_static_t kt_remove_short_different_s = macro_f_string_static_t_initialize(KT_REMOVE_short_different_s, 0, KT_REMOVE_short_different_s_length); - const f_string_static_t kt_remove_short_directory_s = macro_f_string_static_t_initialize(KT_REMOVE_short_directory_s, 0, KT_REMOVE_short_directory_s_length); - const f_string_static_t kt_remove_short_empty_s = macro_f_string_static_t_initialize(KT_REMOVE_short_empty_s, 0, KT_REMOVE_short_empty_s_length); - const f_string_static_t kt_remove_short_fifo_s = macro_f_string_static_t_initialize(KT_REMOVE_short_fifo_s, 0, KT_REMOVE_short_fifo_s_length); - const f_string_static_t kt_remove_short_follow_s = macro_f_string_static_t_initialize(KT_REMOVE_short_follow_s, 0, KT_REMOVE_short_follow_s_length); - const f_string_static_t kt_remove_short_force_s = macro_f_string_static_t_initialize(KT_REMOVE_short_force_s, 0, KT_REMOVE_short_force_s_length); - const f_string_static_t kt_remove_short_group_s = macro_f_string_static_t_initialize(KT_REMOVE_short_group_s, 0, KT_REMOVE_short_group_s_length); - const f_string_static_t kt_remove_short_isolate_s = macro_f_string_static_t_initialize(KT_REMOVE_short_isolate_s, 0, KT_REMOVE_short_isolate_s_length); - const f_string_static_t kt_remove_short_link_s = macro_f_string_static_t_initialize(KT_REMOVE_short_link_s, 0, KT_REMOVE_short_link_s_length); - const f_string_static_t kt_remove_short_mode_s = macro_f_string_static_t_initialize(KT_REMOVE_short_mode_s, 0, KT_REMOVE_short_mode_s_length); - const f_string_static_t kt_remove_short_prompt_s = macro_f_string_static_t_initialize(KT_REMOVE_short_prompt_s, 0, KT_REMOVE_short_prompt_s_length); - const f_string_static_t kt_remove_short_recurse_s = macro_f_string_static_t_initialize(KT_REMOVE_short_recurse_s, 0, KT_REMOVE_short_recurse_s_length); - const f_string_static_t kt_remove_short_regular_s = macro_f_string_static_t_initialize(KT_REMOVE_short_regular_s, 0, KT_REMOVE_short_regular_s_length); - const f_string_static_t kt_remove_short_same_s = macro_f_string_static_t_initialize(KT_REMOVE_short_same_s, 0, KT_REMOVE_short_same_s_length); - const f_string_static_t kt_remove_short_simulate_s = macro_f_string_static_t_initialize(KT_REMOVE_short_simulate_s, 0, KT_REMOVE_short_simulate_s_length); - const f_string_static_t kt_remove_short_socket_s = macro_f_string_static_t_initialize(KT_REMOVE_short_socket_s, 0, KT_REMOVE_short_socket_s_length); - const f_string_static_t kt_remove_short_stay_s = macro_f_string_static_t_initialize(KT_REMOVE_short_stay_s, 0, KT_REMOVE_short_stay_s_length); - const f_string_static_t kt_remove_short_tree_s = macro_f_string_static_t_initialize(KT_REMOVE_short_tree_s, 0, KT_REMOVE_short_tree_s_length); - const f_string_static_t kt_remove_short_updated_s = macro_f_string_static_t_initialize(KT_REMOVE_short_updated_s, 0, KT_REMOVE_short_updated_s_length); - const f_string_static_t kt_remove_short_user_s = macro_f_string_static_t_initialize(KT_REMOVE_short_user_s, 0, KT_REMOVE_short_user_s_length); - - const f_string_static_t kt_remove_long_accessed_s = macro_f_string_static_t_initialize(KT_REMOVE_long_accessed_s, 0, KT_REMOVE_long_accessed_s_length); - const f_string_static_t kt_remove_long_block_s = macro_f_string_static_t_initialize(KT_REMOVE_long_block_s, 0, KT_REMOVE_long_block_s_length); - const f_string_static_t kt_remove_long_character_s = macro_f_string_static_t_initialize(KT_REMOVE_long_character_s, 0, KT_REMOVE_long_character_s_length); - const f_string_static_t kt_remove_long_created_s = macro_f_string_static_t_initialize(KT_REMOVE_long_created_s, 0, KT_REMOVE_long_created_s_length); - const f_string_static_t kt_remove_long_different_s = macro_f_string_static_t_initialize(KT_REMOVE_long_different_s, 0, KT_REMOVE_long_different_s_length); - const f_string_static_t kt_remove_long_directory_s = macro_f_string_static_t_initialize(KT_REMOVE_long_directory_s, 0, KT_REMOVE_long_directory_s_length); - const f_string_static_t kt_remove_long_empty_s = macro_f_string_static_t_initialize(KT_REMOVE_long_empty_s, 0, KT_REMOVE_long_empty_s_length); - const f_string_static_t kt_remove_long_fifo_s = macro_f_string_static_t_initialize(KT_REMOVE_long_fifo_s, 0, KT_REMOVE_long_fifo_s_length); - const f_string_static_t kt_remove_long_follow_s = macro_f_string_static_t_initialize(KT_REMOVE_long_follow_s, 0, KT_REMOVE_long_follow_s_length); - const f_string_static_t kt_remove_long_force_s = macro_f_string_static_t_initialize(KT_REMOVE_long_force_s, 0, KT_REMOVE_long_force_s_length); - const f_string_static_t kt_remove_long_group_s = macro_f_string_static_t_initialize(KT_REMOVE_long_group_s, 0, KT_REMOVE_long_group_s_length); - const f_string_static_t kt_remove_long_isolate_s = macro_f_string_static_t_initialize(KT_REMOVE_long_isolate_s, 0, KT_REMOVE_long_isolate_s_length); - const f_string_static_t kt_remove_long_link_s = macro_f_string_static_t_initialize(KT_REMOVE_long_link_s, 0, KT_REMOVE_long_link_s_length); - const f_string_static_t kt_remove_long_local_s = macro_f_string_static_t_initialize(KT_REMOVE_long_local_s, 0, KT_REMOVE_long_local_s_length); - const f_string_static_t kt_remove_long_mode_s = macro_f_string_static_t_initialize(KT_REMOVE_long_mode_s, 0, KT_REMOVE_long_mode_s_length); - const f_string_static_t kt_remove_long_prompt_s = macro_f_string_static_t_initialize(KT_REMOVE_long_prompt_s, 0, KT_REMOVE_long_prompt_s_length); - const f_string_static_t kt_remove_long_recurse_s = macro_f_string_static_t_initialize(KT_REMOVE_long_recurse_s, 0, KT_REMOVE_long_recurse_s_length); - const f_string_static_t kt_remove_long_regular_s = macro_f_string_static_t_initialize(KT_REMOVE_long_regular_s, 0, KT_REMOVE_long_regular_s_length); - const f_string_static_t kt_remove_long_same_s = macro_f_string_static_t_initialize(KT_REMOVE_long_same_s, 0, KT_REMOVE_long_same_s_length); - const f_string_static_t kt_remove_long_simulate_s = macro_f_string_static_t_initialize(KT_REMOVE_long_simulate_s, 0, KT_REMOVE_long_simulate_s_length); - const f_string_static_t kt_remove_long_socket_s = macro_f_string_static_t_initialize(KT_REMOVE_long_socket_s, 0, KT_REMOVE_long_socket_s_length); - const f_string_static_t kt_remove_long_stay_s = macro_f_string_static_t_initialize(KT_REMOVE_long_stay_s, 0, KT_REMOVE_long_stay_s_length); - const f_string_static_t kt_remove_long_tree_s = macro_f_string_static_t_initialize(KT_REMOVE_long_tree_s, 0, KT_REMOVE_long_tree_s_length); - const f_string_static_t kt_remove_long_updated_s = macro_f_string_static_t_initialize(KT_REMOVE_long_updated_s, 0, KT_REMOVE_long_updated_s_length); - const f_string_static_t kt_remove_long_user_s = macro_f_string_static_t_initialize(KT_REMOVE_long_user_s, 0, KT_REMOVE_long_user_s_length); - const f_string_static_t kt_remove_long_utc_s = macro_f_string_static_t_initialize(KT_REMOVE_long_utc_s, 0, KT_REMOVE_long_utc_s_length); -#endif // _di_kt_remove_parameter_d_ - #ifndef _di_kt_remove_dates_resize_ f_status_t kt_remove_dates_resize(const f_array_length_t length, kt_remove_dates_t * const dates) { @@ -214,91 +65,90 @@ extern "C" { #endif // _di_kt_remove_setting_delete_ #ifndef _di_kt_remove_setting_load_ - void kt_remove_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, kt_remove_setting_t * const setting) { + void kt_remove_setting_load(const f_console_arguments_t arguments, kt_remove_main_t * const main) { - if (!main || !setting) return; + if (!main) return; - setting->flag -= setting->flag & kt_remove_flag_option_used_e; + main->setting.flag -= main->setting.flag & kt_remove_main_flag_option_used_e; - // Identify priority of color parameters. - { - f_console_parameter_id_t ids[3] = { kt_remove_parameter_no_color_e, kt_remove_parameter_light_e, kt_remove_parameter_dark_e }; - const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 3); + main->setting.state.step_small = kt_remove_allocation_console_d; - setting->status = fll_program_parameter_process(arguments, &main->parameters, choices, F_true, &main->context); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - main->output.set = &main->context.set; - main->error.set = &main->context.set; - main->warning.set = &main->context.set; + main->setting.state.step_small = kt_remove_allocation_small_d; - if (main->context.set.error.before) { - main->output.context = f_color_set_empty_s; - main->output.notable = main->context.set.notable; - main->error.context = main->context.set.error; - main->error.notable = main->context.set.notable; + // Identify and pocess first/last parameters. + if (main->program.parameters.array[kt_remove_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & kt_remove_main_flag_print_first_e; + } + else { + main->setting.flag |= kt_remove_main_flag_print_first_e; + } - main->warning.context = main->context.set.warning; - main->warning.notable = main->context.set.notable; - } - else { - f_color_set_t *sets[] = { &main->output.context, &main->output.notable, &main->error.context, &main->error.notable, &main->warning.context, &main->warning.notable, 0 }; + if (main->program.parameters.array[kt_remove_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & kt_remove_main_flag_print_last_e; + } + else { + main->setting.flag |= kt_remove_main_flag_print_last_e; + } - fll_program_parameter_process_empty(&main->context, sets); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & kt_remove_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(fll_program_parameter_process_empty)); + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_console_parameter_process)); - return; - } + return; } - // Identify priority of verbosity related parameters. - { - f_console_parameter_id_t ids[5] = { kt_remove_parameter_verbosity_quiet_e, kt_remove_parameter_verbosity_error_e, kt_remove_parameter_verbosity_normal_e, kt_remove_parameter_verbosity_verbose_e, kt_remove_parameter_verbosity_debug_e }; - f_console_parameter_id_t choice = 0; - const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 5); + { + f_uint16s_t choices = f_uint16s_t_initialize; - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); + // Identify and prioritize "color context" parameters. + { + uint16_t choices_array[3] = { kt_remove_parameter_no_color_e, kt_remove_parameter_light_e, kt_remove_parameter_dark_e }; + choices.array = choices_array; + choices.used = 3; - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(f_console_parameter_prioritize_right)); + const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - return; - } + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (choice == kt_remove_parameter_verbosity_quiet_e) { - main->output.verbosity = f_console_verbosity_quiet_e; - main->error.verbosity = f_console_verbosity_quiet_e; - main->warning.verbosity = f_console_verbosity_quiet_e; - } - else if (choice == kt_remove_parameter_verbosity_error_e) { - main->output.verbosity = f_console_verbosity_error_e; - main->error.verbosity = f_console_verbosity_error_e; - main->warning.verbosity = f_console_verbosity_error_e; - } - else if (choice == kt_remove_parameter_verbosity_normal_e) { - main->output.verbosity = f_console_verbosity_normal_e; - main->error.verbosity = f_console_verbosity_normal_e; - main->warning.verbosity = f_console_verbosity_normal_e; - } - else if (choice == kt_remove_parameter_verbosity_verbose_e) { - main->output.verbosity = f_console_verbosity_verbose_e; - main->error.verbosity = f_console_verbosity_verbose_e; - main->warning.verbosity = f_console_verbosity_verbose_e; + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & kt_remove_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + kt_remove_print_error(&main->program.error, macro_kt_remove_f(fll_program_parameter_process_context)); + + return; + } } - else if (choice == kt_remove_parameter_verbosity_debug_e) { - main->output.verbosity = f_console_verbosity_debug_e; - main->error.verbosity = f_console_verbosity_debug_e; - main->warning.verbosity = f_console_verbosity_debug_e; + + // Identify and prioritize "verbosity" parameters. + { + uint16_t choices_array[5] = { kt_remove_parameter_verbosity_quiet_e, kt_remove_parameter_verbosity_error_e, kt_remove_parameter_verbosity_verbose_e, kt_remove_parameter_verbosity_debug_e, kt_remove_parameter_verbosity_normal_e }; + choices.array = choices_array; + choices.used = 5; + + const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; + + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & kt_remove_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + kt_remove_print_error(&main->program.error, macro_kt_remove_f(fll_program_parameter_process_verbosity)); + + return; + } } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - f_array_length_t i = 0; f_array_length_t index = 0; f_array_length_t index2 = 0; @@ -307,135 +157,135 @@ extern "C" { uint8_t j = 0; - if (main->parameters.array[kt_remove_parameter_help_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_help_e; + 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; } - if (main->parameters.array[kt_remove_parameter_version_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_version_e; + 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; } - if (main->parameters.array[kt_remove_parameter_block_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_block_e; - setting->flag |= kt_remove_flag_option_used_e; + if (main->program.parameters.array[kt_remove_parameter_copyright_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; } - if (main->parameters.array[kt_remove_parameter_character_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_character_e; - setting->flag |= kt_remove_flag_option_used_e; + 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; } - if (main->parameters.array[kt_remove_parameter_different_e].result == f_console_result_found_e) { - if (main->parameters.array[kt_remove_parameter_same_e].result == f_console_result_found_e) { - index = main->parameters.array[kt_remove_parameter_different_e].locations.used; - index2 = main->parameters.array[kt_remove_parameter_same_e].locations.used; + if (main->program.parameters.array[kt_remove_parameter_different_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_same_e].result & f_console_result_found_e) { + index = main->program.parameters.array[kt_remove_parameter_different_e].locations.used; + index2 = main->program.parameters.array[kt_remove_parameter_same_e].locations.used; - if (main->parameters.array[kt_remove_parameter_different_e].locations.array[index] > main->parameters.array[kt_remove_parameter_same_e].locations.array[index2]) { - setting->flag |= kt_remove_flag_different_e; + 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; - if (setting->flag & kt_remove_flag_same_e) { - setting->flag -= kt_remove_flag_same_e; + if (main->setting.flag & kt_remove_main_flag_same_e) { + main->setting.flag -= kt_remove_main_flag_same_e; } } else { - setting->flag |= kt_remove_flag_same_e; + main->setting.flag |= kt_remove_main_flag_same_e; - if (setting->flag & kt_remove_flag_different_e) { - setting->flag -= kt_remove_flag_different_e; + if (main->setting.flag & kt_remove_main_flag_different_e) { + main->setting.flag -= kt_remove_main_flag_different_e; } } } else { - setting->flag |= kt_remove_flag_different_e; + main->setting.flag |= kt_remove_main_flag_different_e; - if (setting->flag & kt_remove_flag_same_e) { - setting->flag -= kt_remove_flag_same_e; + if (main->setting.flag & kt_remove_main_flag_same_e) { + main->setting.flag -= kt_remove_main_flag_same_e; } } - setting->flag |= kt_remove_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_option_used_e; } - else if (main->parameters.array[kt_remove_parameter_same_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_same_e; + 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; - if (setting->flag & kt_remove_flag_different_e) { - setting->flag -= kt_remove_flag_different_e; + if (main->setting.flag & kt_remove_main_flag_different_e) { + main->setting.flag -= kt_remove_main_flag_different_e; } - setting->flag |= kt_remove_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_option_used_e; } - if (main->parameters.array[kt_remove_parameter_fifo_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_fifo_e; - setting->flag |= kt_remove_flag_option_used_e; + 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; } - if (main->parameters.array[kt_remove_parameter_follow_e].result == f_console_result_found_e) { - if (main->parameters.array[kt_remove_parameter_stay_e].result == f_console_result_found_e) { - index = main->parameters.array[kt_remove_parameter_follow_e].locations.used; - index2 = main->parameters.array[kt_remove_parameter_stay_e].locations.used; + if (main->program.parameters.array[kt_remove_parameter_follow_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_stay_e].result & f_console_result_found_e) { + index = main->program.parameters.array[kt_remove_parameter_follow_e].locations.used; + index2 = main->program.parameters.array[kt_remove_parameter_stay_e].locations.used; - if (main->parameters.array[kt_remove_parameter_follow_e].locations.array[index] > main->parameters.array[kt_remove_parameter_stay_e].locations.array[index2]) { - setting->flag |= kt_remove_flag_follow_e; + 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; } else { - if (setting->flag & kt_remove_flag_follow_e) { - setting->flag -= kt_remove_flag_follow_e; + if (main->setting.flag & kt_remove_main_flag_follow_e) { + main->setting.flag -= kt_remove_main_flag_follow_e; } } } else { - setting->flag |= kt_remove_flag_follow_e; + main->setting.flag |= kt_remove_main_flag_follow_e; } } - else if (main->parameters.array[kt_remove_parameter_stay_e].result == f_console_result_found_e) { - if (setting->flag & kt_remove_flag_follow_e) { - setting->flag -= kt_remove_flag_follow_e; + 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->parameters.array[kt_remove_parameter_force_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_force_e; + 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; } - if (main->parameters.array[kt_remove_parameter_link_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_link_e; - setting->flag |= kt_remove_flag_option_used_e; + 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; } - if (main->parameters.array[kt_remove_parameter_recurse_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_recurse_e; + 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; } - if (main->parameters.array[kt_remove_parameter_regular_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_regular_e; - setting->flag |= kt_remove_flag_option_used_e; + 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; } - if (main->parameters.array[kt_remove_parameter_simulate_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_simulate_e; + 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; } - if (main->parameters.array[kt_remove_parameter_socket_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_socket_e; - setting->flag |= kt_remove_flag_option_used_e; + 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; } - if (main->parameters.array[kt_remove_parameter_tree_e].result == f_console_result_found_e) { - setting->flag |= kt_remove_flag_tree_e; + 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; } { f_console_parameter_t * const parameters[] = { - &main->parameters.array[kt_remove_parameter_accessed_e], - &main->parameters.array[kt_remove_parameter_created_e], - &main->parameters.array[kt_remove_parameter_updated_e], + &main->program.parameters.array[kt_remove_parameter_accessed_e], + &main->program.parameters.array[kt_remove_parameter_created_e], + &main->program.parameters.array[kt_remove_parameter_updated_e], }; kt_remove_dates_t * const dates[] = { - &setting->accessed, - &setting->created, - &setting->updated, + &main->setting.accessed, + &main->setting.created, + &main->setting.updated, }; const f_string_static_t longs[] = { @@ -447,31 +297,31 @@ extern "C" { for (uint8_t p = 0; p < 3; ++p) { // kt_remove_parameter_accessed_e, kt_remove_parameter_created_e, kt_remove_parameter_updated_e, needs additional parameters, ==, <, <=, >, >=, <>. - if (parameters[p]->result == f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + if (parameters[p]->result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, longs[p], 2); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, longs[p], 2); return; } - if (parameters[p]->result == f_console_result_additional_e) { + if (parameters[p]->result & f_console_result_value_e) { total_locations = parameters[p]->locations.used; total_arguments = parameters[p]->values.used; if (total_locations * 2 != total_arguments) { - setting->status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, longs[p], 2); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, longs[p], 2); return; } if (dates[p]->used + total_locations > dates[p]->size) { - setting->status = kt_remove_dates_resize(dates[p]->size + (total_locations - dates[p]->size), dates[p]); + main->setting.state.status = kt_remove_dates_resize(dates[p]->size + (total_locations - dates[p]->size), dates[p]); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(kt_remove_dates_resize)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(kt_remove_dates_resize)); return; } @@ -507,7 +357,7 @@ extern "C" { kt_remove_date_word_not_s, }; - setting->status = F_known_not; + main->setting.state.status = F_known_not; { for (i = 0; i < total_arguments; i += 2) { @@ -518,13 +368,13 @@ extern "C" { for (j = 0; j < 12; ++j) { - if (fl_string_dynamic_compare(main->parameters.arguments.array[index], strings[j]) == F_equal_to) { + if (fl_string_dynamic_compare(main->program.parameters.arguments.array[index], strings[j]) == F_equal_to) { dates[p]->array[dates[p]->used].operation = enumerations[j]; index2 = parameters[p]->values.array[i + 1]; - kt_remove_convert_date(main, setting, main->parameters.arguments.array[index2], &dates[p]->array[dates[p]->used]); - if (F_status_is_error(setting->status)) return; + kt_remove_convert_date(main, main->program.parameters.arguments.array[index2], &dates[p]->array[dates[p]->used]); + if (F_status_is_error(main->setting.state.status)) return; ++dates[p]->used; @@ -535,250 +385,250 @@ extern "C" { } // for if (j == 12) { - setting->status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_unknown_value(main->error, f_console_symbol_long_enable_s, longs[p], main->parameters.arguments.array[index]); + kt_remove_print_error_parameter_unknown_value(&main->program.error, f_console_symbol_long_normal_s, longs[p], main->program.parameters.arguments.array[index]); return; } } // for } - setting->flag |= kt_remove_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_option_used_e; } // for } } // kt_remove_parameter_group_e, needs additional parameters (group). - if (main->parameters.array[kt_remove_parameter_empty_e].result == f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + if (main->program.parameters.array[kt_remove_parameter_empty_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, kt_remove_long_empty_s, 1); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_empty_s, 1); return; } - if (main->parameters.array[kt_remove_parameter_empty_e].result == f_console_result_additional_e) { - total_arguments = main->parameters.array[kt_remove_parameter_empty_e].values.used; + if (main->program.parameters.array[kt_remove_parameter_empty_e].result & f_console_result_value_e) { + total_arguments = main->program.parameters.array[kt_remove_parameter_empty_e].values.used; - if (main->parameters.array[kt_remove_parameter_empty_e].locations.used != total_arguments) { - setting->status = F_status_set_error(F_parameter); + if (main->program.parameters.array[kt_remove_parameter_empty_e].locations.used != total_arguments) { + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, kt_remove_long_empty_s, 1); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_empty_s, 1); return; } - index = main->parameters.array[kt_remove_parameter_empty_e].values.array[total_arguments - 1]; + index = main->program.parameters.array[kt_remove_parameter_empty_e].values.array[total_arguments - 1]; - if (fl_string_dynamic_compare(kt_remove_not_s, main->parameters.arguments.array[index]) == F_equal_to) { - setting->flag |= kt_remove_flag_empty_not_e; + if (fl_string_dynamic_compare(kt_remove_not_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + main->setting.flag |= kt_remove_main_flag_empty_not_e; - if (setting->flag & kt_remove_flag_empty_not_fail_e) { - setting->flag -= kt_remove_flag_empty_not_fail_e; + if (main->setting.flag & kt_remove_main_flag_empty_not_fail_e) { + main->setting.flag -= kt_remove_main_flag_empty_not_fail_e; } - if (setting->flag & kt_remove_flag_empty_only_e) { - setting->flag -= kt_remove_flag_empty_only_e; + if (main->setting.flag & kt_remove_main_flag_empty_only_e) { + main->setting.flag -= kt_remove_main_flag_empty_only_e; } - if (setting->flag & kt_remove_flag_empty_only_fail_e) { - setting->flag -= kt_remove_flag_empty_only_fail_e; + if (main->setting.flag & kt_remove_main_flag_empty_only_fail_e) { + main->setting.flag -= kt_remove_main_flag_empty_only_fail_e; } } - else if (fl_string_dynamic_compare(kt_remove_not_fail_s, main->parameters.arguments.array[index]) == F_equal_to) { - setting->flag |= kt_remove_flag_empty_not_fail_e; + else if (fl_string_dynamic_compare(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; - if (setting->flag & kt_remove_flag_empty_not_e) { - setting->flag -= kt_remove_flag_empty_not_e; + if (main->setting.flag & kt_remove_main_flag_empty_not_e) { + main->setting.flag -= kt_remove_main_flag_empty_not_e; } - if (setting->flag & kt_remove_flag_empty_only_e) { - setting->flag -= kt_remove_flag_empty_only_e; + if (main->setting.flag & kt_remove_main_flag_empty_only_e) { + main->setting.flag -= kt_remove_main_flag_empty_only_e; } - if (setting->flag & kt_remove_flag_empty_only_fail_e) { - setting->flag -= kt_remove_flag_empty_only_fail_e; + if (main->setting.flag & kt_remove_main_flag_empty_only_fail_e) { + main->setting.flag -= kt_remove_main_flag_empty_only_fail_e; } } - else if (fl_string_dynamic_compare(kt_remove_only_s, main->parameters.arguments.array[index]) == F_equal_to) { - setting->flag |= kt_remove_flag_empty_only_e; + else if (fl_string_dynamic_compare(kt_remove_only_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + main->setting.flag |= kt_remove_main_flag_empty_only_e; - if (setting->flag & kt_remove_flag_empty_not_e) { - setting->flag -= kt_remove_flag_empty_not_e; + if (main->setting.flag & kt_remove_main_flag_empty_not_e) { + main->setting.flag -= kt_remove_main_flag_empty_not_e; } - if (setting->flag & kt_remove_flag_empty_not_fail_e) { - setting->flag -= kt_remove_flag_empty_not_fail_e; + if (main->setting.flag & kt_remove_main_flag_empty_not_fail_e) { + main->setting.flag -= kt_remove_main_flag_empty_not_fail_e; } - if (setting->flag & kt_remove_flag_empty_only_fail_e) { - setting->flag -= kt_remove_flag_empty_only_fail_e; + if (main->setting.flag & kt_remove_main_flag_empty_only_fail_e) { + main->setting.flag -= kt_remove_main_flag_empty_only_fail_e; } } - else if (fl_string_dynamic_compare(kt_remove_only_fail_s, main->parameters.arguments.array[index]) == F_equal_to) { - setting->flag |= kt_remove_flag_empty_only_fail_e; + else if (fl_string_dynamic_compare(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; - if (setting->flag & kt_remove_flag_empty_not_e) { - setting->flag -= kt_remove_flag_empty_not_e; + if (main->setting.flag & kt_remove_main_flag_empty_not_e) { + main->setting.flag -= kt_remove_main_flag_empty_not_e; } - if (setting->flag & kt_remove_flag_empty_not_fail_e) { - setting->flag -= kt_remove_flag_empty_not_fail_e; + if (main->setting.flag & kt_remove_main_flag_empty_not_fail_e) { + main->setting.flag -= kt_remove_main_flag_empty_not_fail_e; } - if (setting->flag & kt_remove_flag_empty_only_e) { - setting->flag -= kt_remove_flag_empty_only_e; + if (main->setting.flag & kt_remove_main_flag_empty_only_e) { + main->setting.flag -= kt_remove_main_flag_empty_only_e; } } else { - setting->status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_unknown_value(main->error, f_console_symbol_long_enable_s, kt_remove_long_empty_s, main->parameters.arguments.array[index]); + kt_remove_print_error_parameter_unknown_value(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_empty_s, main->program.parameters.arguments.array[index]); return; } - setting->flag |= kt_remove_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_option_used_e; } // kt_remove_parameter_group_e, needs additional parameters (gid). - if (main->parameters.array[kt_remove_parameter_group_e].result == f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + if (main->program.parameters.array[kt_remove_parameter_group_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, kt_remove_long_group_s, 1); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_group_s, 1); return; } - if (main->parameters.array[kt_remove_parameter_group_e].result == f_console_result_additional_e) { - total_arguments = main->parameters.array[kt_remove_parameter_group_e].values.used; + if (main->program.parameters.array[kt_remove_parameter_group_e].result & f_console_result_value_e) { + total_arguments = main->program.parameters.array[kt_remove_parameter_group_e].values.used; - if (main->parameters.array[kt_remove_parameter_group_e].locations.used != total_arguments) { - setting->status = F_status_set_error(F_parameter); + if (main->program.parameters.array[kt_remove_parameter_group_e].locations.used != total_arguments) { + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, kt_remove_long_group_s, 1); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_group_s, 1); return; } - setting->status = f_uint32s_increase_by(total_arguments, &setting->groups); + main->setting.state.status = f_uint32s_increase_by(total_arguments, &main->setting.groups); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(f_uint32s_increase_by)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_uint32s_increase_by)); return; } for (i = 0; i < total_arguments; ++i) { - index = main->parameters.array[kt_remove_parameter_group_e].values.array[i]; + index = main->program.parameters.array[kt_remove_parameter_group_e].values.array[i]; - setting->groups.array[setting->groups.used] = kt_remove_get_id_group(setting, main->parameters.arguments.array[index]); + main->setting.groups.array[main->setting.groups.used] = kt_remove_get_id_group(main, main->program.parameters.arguments.array[index]); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(kt_remove_get_id_group)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(kt_remove_get_id_group)); return; } - ++setting->groups.used; + ++main->setting.groups.used; } // for - setting->flag |= kt_remove_flag_group_e; - setting->flag |= kt_remove_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_group_e; + main->setting.flag |= kt_remove_main_flag_option_used_e; } // kt_remove_parameter_isolate_e, needs additional parameters (all, ignore, or root). - if (main->parameters.array[kt_remove_parameter_isolate_e].result == f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + if (main->program.parameters.array[kt_remove_parameter_isolate_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, kt_remove_long_isolate_s, 1); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_isolate_s, 1); return; } - if (main->parameters.array[kt_remove_parameter_isolate_e].result == f_console_result_additional_e) { - total_arguments = main->parameters.array[kt_remove_parameter_isolate_e].values.used; + if (main->program.parameters.array[kt_remove_parameter_isolate_e].result & f_console_result_value_e) { + total_arguments = main->program.parameters.array[kt_remove_parameter_isolate_e].values.used; - if (main->parameters.array[kt_remove_parameter_isolate_e].locations.used != total_arguments) { - setting->status = F_status_set_error(F_parameter); + if (main->program.parameters.array[kt_remove_parameter_isolate_e].locations.used != total_arguments) { + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, kt_remove_long_isolate_s, 1); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_isolate_s, 1); return; } - index = main->parameters.array[kt_remove_parameter_isolate_e].values.array[total_arguments - 1]; + index = main->program.parameters.array[kt_remove_parameter_isolate_e].values.array[total_arguments - 1]; - if (fl_string_dynamic_compare(kt_remove_all_s, main->parameters.arguments.array[index]) == F_equal_to) { - setting->flag |= kt_remove_flag_isolate_all_e; + if (fl_string_dynamic_compare(kt_remove_all_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + main->setting.flag |= kt_remove_main_flag_isolate_all_e; - if (setting->flag & kt_remove_flag_isolate_ignore_e) { - setting->flag -= kt_remove_flag_isolate_ignore_e; + if (main->setting.flag & kt_remove_main_flag_isolate_ignore_e) { + main->setting.flag -= kt_remove_main_flag_isolate_ignore_e; } - if (setting->flag & kt_remove_flag_isolate_root_e) { - setting->flag -= kt_remove_flag_isolate_root_e; + if (main->setting.flag & kt_remove_main_flag_isolate_root_e) { + main->setting.flag -= kt_remove_main_flag_isolate_root_e; } } - else if (fl_string_dynamic_compare(kt_remove_ignore_s, main->parameters.arguments.array[index]) == F_equal_to) { - setting->flag |= kt_remove_flag_isolate_ignore_e; + else if (fl_string_dynamic_compare(kt_remove_ignore_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + main->setting.flag |= kt_remove_main_flag_isolate_ignore_e; - if (setting->flag & kt_remove_flag_isolate_all_e) { - setting->flag -= kt_remove_flag_isolate_all_e; + if (main->setting.flag & kt_remove_main_flag_isolate_all_e) { + main->setting.flag -= kt_remove_main_flag_isolate_all_e; } - if (setting->flag & kt_remove_flag_isolate_root_e) { - setting->flag -= kt_remove_flag_isolate_root_e; + if (main->setting.flag & kt_remove_main_flag_isolate_root_e) { + main->setting.flag -= kt_remove_main_flag_isolate_root_e; } } - else if (fl_string_dynamic_compare(kt_remove_root_s, main->parameters.arguments.array[index]) == F_equal_to) { - setting->flag |= kt_remove_flag_isolate_root_e; + else if (fl_string_dynamic_compare(kt_remove_root_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + main->setting.flag |= kt_remove_main_flag_isolate_root_e; - if (setting->flag & kt_remove_flag_isolate_all_e) { - setting->flag -= kt_remove_flag_isolate_all_e; + if (main->setting.flag & kt_remove_main_flag_isolate_all_e) { + main->setting.flag -= kt_remove_main_flag_isolate_all_e; } - if (setting->flag & kt_remove_flag_isolate_ignore_e) { - setting->flag -= kt_remove_flag_isolate_ignore_e; + if (main->setting.flag & kt_remove_main_flag_isolate_ignore_e) { + main->setting.flag -= kt_remove_main_flag_isolate_ignore_e; } } else { - setting->status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_unknown_value(main->error, f_console_symbol_long_enable_s, kt_remove_long_isolate_s, main->parameters.arguments.array[index]); + kt_remove_print_error_parameter_unknown_value(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_isolate_s, main->program.parameters.arguments.array[index]); return; } } // kt_remove_parameter_mode_e, needs additional parameters (modes, match parameters). - if (main->parameters.array[kt_remove_parameter_mode_e].result == f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + if (main->program.parameters.array[kt_remove_parameter_mode_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, kt_remove_long_mode_s, 2); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_mode_s, 2); return; } - if (main->parameters.array[kt_remove_parameter_mode_e].result == f_console_result_additional_e) { - total_locations = main->parameters.array[kt_remove_parameter_mode_e].locations.used; - total_arguments = main->parameters.array[kt_remove_parameter_mode_e].values.used; + if (main->program.parameters.array[kt_remove_parameter_mode_e].result & f_console_result_value_e) { + total_locations = main->program.parameters.array[kt_remove_parameter_mode_e].locations.used; + total_arguments = main->program.parameters.array[kt_remove_parameter_mode_e].values.used; if (total_locations * 2 != total_arguments) { - setting->status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, kt_remove_long_mode_s, 2); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_mode_s, 2); return; } - if (setting->modes.used + total_locations > setting->modes.size) { - setting->status = kt_remove_modes_resize(setting->modes.size + (total_locations - setting->modes.size), &setting->modes); + if (main->setting.modes.used + total_locations > main->setting.modes.size) { + main->setting.state.status = kt_remove_modes_resize(main->setting.modes.size + (total_locations - main->setting.modes.size), &main->setting.modes); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(kt_remove_modes_resize)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(kt_remove_modes_resize)); return; } @@ -808,231 +658,231 @@ extern "C" { for (i = 0; i < total_locations; i += 2) { - index = main->parameters.array[kt_remove_parameter_mode_e].values.array[i]; + index = main->program.parameters.array[kt_remove_parameter_mode_e].values.array[i]; - setting->modes.array[setting->modes.used].type = 0; + main->setting.modes.array[main->setting.modes.used].type = 0; for (j = 0; j < 8; ++j) { - if (fl_string_dynamic_compare(main->parameters.arguments.array[index], strings[j]) == F_equal_to) { - setting->modes.array[setting->modes.used].type = enumerations[j]; + if (fl_string_dynamic_compare(main->program.parameters.arguments.array[index], strings[j]) == F_equal_to) { + main->setting.modes.array[main->setting.modes.used].type = enumerations[j]; - index2 = main->parameters.array[kt_remove_parameter_mode_e].values.array[i + 1]; + index2 = main->program.parameters.array[kt_remove_parameter_mode_e].values.array[i + 1]; - setting->modes.array[setting->modes.used].mode = kt_remove_get_mode(main, setting, main->parameters.arguments.array[index2]); - if (F_status_is_error(setting->status)) return; + main->setting.modes.array[main->setting.modes.used].mode = kt_remove_get_mode(main, main->program.parameters.arguments.array[index2]); + if (F_status_is_error(main->setting.state.status)) return; - ++setting->modes.used; + ++main->setting.modes.used; break; } } // for if (j == 8) { - setting->status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_unknown_value(main->error, f_console_symbol_long_enable_s, kt_remove_long_mode_s, main->parameters.arguments.array[index]); + kt_remove_print_error_parameter_unknown_value(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_mode_s, main->program.parameters.arguments.array[index]); return; } } // for - setting->flag |= kt_remove_flag_mode_e; - setting->flag |= kt_remove_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_mode_e; + main->setting.flag |= kt_remove_main_flag_option_used_e; } // kt_remove_parameter_user_e, needs additional parameters. - if (main->parameters.array[kt_remove_parameter_user_e].result == f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + if (main->program.parameters.array[kt_remove_parameter_user_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, kt_remove_long_user_s, 1); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_user_s, 1); return; } - if (main->parameters.array[kt_remove_parameter_user_e].result == f_console_result_additional_e) { - total_arguments = main->parameters.array[kt_remove_parameter_user_e].values.used; + if (main->program.parameters.array[kt_remove_parameter_user_e].result & f_console_result_value_e) { + total_arguments = main->program.parameters.array[kt_remove_parameter_user_e].values.used; - if (main->parameters.array[kt_remove_parameter_user_e].locations.used != total_arguments) { - setting->status = F_status_set_error(F_parameter); + if (main->program.parameters.array[kt_remove_parameter_user_e].locations.used != total_arguments) { + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, kt_remove_long_user_s, 1); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_user_s, 1); return; } - setting->status = f_uint32s_increase_by(total_arguments, &setting->users); + main->setting.state.status = f_uint32s_increase_by(total_arguments, &main->setting.users); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(f_uint32s_increase_by)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_uint32s_increase_by)); return; } for (i = 0; i < total_arguments; ++i) { - index = main->parameters.array[kt_remove_parameter_user_e].values.array[i]; + index = main->program.parameters.array[kt_remove_parameter_user_e].values.array[i]; - setting->users.array[setting->users.used] = kt_remove_get_id_user(setting, main->parameters.arguments.array[index]); + main->setting.users.array[main->setting.users.used] = kt_remove_get_id_user(main, main->program.parameters.arguments.array[index]); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(kt_remove_get_id_user)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(kt_remove_get_id_user)); return; } - ++setting->users.used; + ++main->setting.users.used; } // for - setting->flag |= kt_remove_flag_user_e; - setting->flag |= kt_remove_flag_option_used_e; + main->setting.flag |= kt_remove_main_flag_user_e; + main->setting.flag |= kt_remove_main_flag_option_used_e; } // kt_remove_parameter_prompt_e, needs additional parameters (all, follow, once). - if (main->parameters.array[kt_remove_parameter_prompt_e].result == f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + if (main->program.parameters.array[kt_remove_parameter_prompt_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, kt_remove_long_prompt_s, 1); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_prompt_s, 1); return; } - if (main->parameters.array[kt_remove_parameter_prompt_e].result == f_console_result_additional_e) { - total_arguments = main->parameters.array[kt_remove_parameter_prompt_e].values.used; + if (main->program.parameters.array[kt_remove_parameter_prompt_e].result & f_console_result_value_e) { + total_arguments = main->program.parameters.array[kt_remove_parameter_prompt_e].values.used; - if (main->parameters.array[kt_remove_parameter_prompt_e].locations.used != total_arguments) { - setting->status = F_status_set_error(F_parameter); + if (main->program.parameters.array[kt_remove_parameter_prompt_e].locations.used != total_arguments) { + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_enable_s, kt_remove_long_prompt_s, 1); + kt_remove_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_prompt_s, 1); return; } - index = main->parameters.array[kt_remove_parameter_prompt_e].values.array[total_arguments - 1]; + index = main->program.parameters.array[kt_remove_parameter_prompt_e].values.array[total_arguments - 1]; - if (fl_string_dynamic_compare(kt_remove_all_s, main->parameters.arguments.array[index]) == F_equal_to) { - setting->flag |= kt_remove_flag_prompt_all_e; + if (fl_string_dynamic_compare(kt_remove_all_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + main->setting.flag |= kt_remove_main_flag_prompt_all_e; - if (setting->flag & kt_remove_flag_prompt_follow_e) { - setting->flag -= kt_remove_flag_prompt_follow_e; + if (main->setting.flag & kt_remove_main_flag_prompt_follow_e) { + main->setting.flag -= kt_remove_main_flag_prompt_follow_e; } - if (setting->flag & kt_remove_flag_prompt_once_e) { - setting->flag -= kt_remove_flag_prompt_once_e; + if (main->setting.flag & kt_remove_main_flag_prompt_once_e) { + main->setting.flag -= kt_remove_main_flag_prompt_once_e; } - if (setting->flag & kt_remove_flag_prompt_never_e) { - setting->flag -= kt_remove_flag_prompt_never_e; + if (main->setting.flag & kt_remove_main_flag_prompt_never_e) { + main->setting.flag -= kt_remove_main_flag_prompt_never_e; } } - else if (fl_string_dynamic_compare(kt_remove_follow_s, main->parameters.arguments.array[index]) == F_equal_to) { - setting->flag |= kt_remove_flag_prompt_follow_e; + else if (fl_string_dynamic_compare(kt_remove_follow_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + main->setting.flag |= kt_remove_main_flag_prompt_follow_e; - if (setting->flag & kt_remove_flag_prompt_all_e) { - setting->flag -= kt_remove_flag_prompt_all_e; + if (main->setting.flag & kt_remove_main_flag_prompt_all_e) { + main->setting.flag -= kt_remove_main_flag_prompt_all_e; } - if (setting->flag & kt_remove_flag_prompt_once_e) { - setting->flag -= kt_remove_flag_prompt_once_e; + if (main->setting.flag & kt_remove_main_flag_prompt_once_e) { + main->setting.flag -= kt_remove_main_flag_prompt_once_e; } - if (setting->flag & kt_remove_flag_prompt_never_e) { - setting->flag -= kt_remove_flag_prompt_never_e; + if (main->setting.flag & kt_remove_main_flag_prompt_never_e) { + main->setting.flag -= kt_remove_main_flag_prompt_never_e; } } - else if (fl_string_dynamic_compare(kt_remove_once_s, main->parameters.arguments.array[index]) == F_equal_to) { - setting->flag |= kt_remove_flag_prompt_once_e; + else if (fl_string_dynamic_compare(kt_remove_once_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + main->setting.flag |= kt_remove_main_flag_prompt_once_e; - if (setting->flag & kt_remove_flag_prompt_all_e) { - setting->flag -= kt_remove_flag_prompt_all_e; + if (main->setting.flag & kt_remove_main_flag_prompt_all_e) { + main->setting.flag -= kt_remove_main_flag_prompt_all_e; } - if (setting->flag & kt_remove_flag_prompt_follow_e) { - setting->flag -= kt_remove_flag_prompt_follow_e; + if (main->setting.flag & kt_remove_main_flag_prompt_follow_e) { + main->setting.flag -= kt_remove_main_flag_prompt_follow_e; } - if (setting->flag & kt_remove_flag_prompt_never_e) { - setting->flag -= kt_remove_flag_prompt_never_e; + if (main->setting.flag & kt_remove_main_flag_prompt_never_e) { + main->setting.flag -= kt_remove_main_flag_prompt_never_e; } } - else if (fl_string_dynamic_compare(kt_remove_never_s, main->parameters.arguments.array[index]) == F_equal_to) { - setting->flag |= kt_remove_flag_prompt_never_e; + else if (fl_string_dynamic_compare(kt_remove_never_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + main->setting.flag |= kt_remove_main_flag_prompt_never_e; - if (setting->flag & kt_remove_flag_prompt_all_e) { - setting->flag -= kt_remove_flag_prompt_all_e; + if (main->setting.flag & kt_remove_main_flag_prompt_all_e) { + main->setting.flag -= kt_remove_main_flag_prompt_all_e; } - if (setting->flag & kt_remove_flag_prompt_follow_e) { - setting->flag -= kt_remove_flag_prompt_follow_e; + if (main->setting.flag & kt_remove_main_flag_prompt_follow_e) { + main->setting.flag -= kt_remove_main_flag_prompt_follow_e; } - if (setting->flag & kt_remove_flag_prompt_once_e) { - setting->flag -= kt_remove_flag_prompt_once_e; + if (main->setting.flag & kt_remove_main_flag_prompt_once_e) { + main->setting.flag -= kt_remove_main_flag_prompt_once_e; } } else { - setting->status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - kt_remove_print_error_parameter_unknown_value(main->error, f_console_symbol_long_enable_s, kt_remove_long_prompt_s, main->parameters.arguments.array[index]); + kt_remove_print_error_parameter_unknown_value(&main->program.error, f_console_symbol_long_normal_s, kt_remove_long_prompt_s, main->program.parameters.arguments.array[index]); return; } } - if (main->parameters.array[kt_remove_parameter_utc_e].result == f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_utc_e].result & f_console_result_found_e) { // Use the right most parameter when both --utc and --local are passed. - if (main->parameters.array[kt_remove_parameter_local_e].result == f_console_result_found_e) { - const f_array_length_t last_local = main->parameters.array[kt_remove_parameter_local_e].locations.array[main->parameters.array[kt_remove_parameter_local_e].locations.used]; - const f_array_length_t last_utc = main->parameters.array[kt_remove_parameter_utc_e].locations.array[main->parameters.array[kt_remove_parameter_utc_e].locations.used]; + if (main->program.parameters.array[kt_remove_parameter_local_e].result & f_console_result_found_e) { + const f_array_length_t last_local = main->program.parameters.array[kt_remove_parameter_local_e].locations.array[main->program.parameters.array[kt_remove_parameter_local_e].locations.used]; + const f_array_length_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 (setting->flag & kt_remove_flag_utc_e) { - setting->flag -= kt_remove_flag_utc_e; + if (main->setting.flag & kt_remove_main_flag_utc_e) { + main->setting.flag -= kt_remove_main_flag_utc_e; } } else { - setting->flag |= kt_remove_flag_utc_e; + main->setting.flag |= kt_remove_main_flag_utc_e; } } else { - setting->flag |= kt_remove_flag_utc_e; + main->setting.flag |= kt_remove_main_flag_utc_e; } } - else if (main->parameters.array[kt_remove_parameter_local_e].result == f_console_result_found_e) { - if (setting->flag & kt_remove_flag_utc_e) { - setting->flag -= kt_remove_flag_utc_e; + 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; } } // Load all remaining files as static strings (setting size to 0). - if (main->parameters.remaining.used) { - setting->status = f_string_dynamics_increase_by(main->parameters.remaining.used, &setting->files); + if (main->program.parameters.remaining.used) { + main->setting.state.status = f_string_dynamics_increase_by(main->program.parameters.remaining.used, &main->setting.files); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(f_string_dynamics_increase_by)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_string_dynamics_increase_by)); return; } - for (i = 0; i < main->parameters.remaining.used; ++i) { + for (i = 0; i < main->program.parameters.remaining.used; ++i) { - index = main->parameters.remaining.array[i]; + index = main->program.parameters.remaining.array[i]; - setting->files.array[setting->files.used].string = main->parameters.arguments.array[index].string; - setting->files.array[setting->files.used].used = main->parameters.arguments.array[index].used; - setting->files.array[setting->files.used++].size = 0; + main->setting.files.array[main->setting.files.used].string = main->program.parameters.arguments.array[index].string; + main->setting.files.array[main->setting.files.used].used = main->program.parameters.arguments.array[index].used; + main->setting.files.array[main->setting.files.used++].size = 0; } // for } } #endif // _di_kt_remove_setting_load_ #ifndef _di_kt_remove_setting_unload_ - f_status_t kt_remove_setting_unload(fll_program_data_t * const main, kt_remove_setting_t * const setting) { + f_status_t kt_remove_setting_unload(kt_remove_main_t * const main) { - if (!main || !setting) return F_status_set_error(F_parameter); + if (!main) return F_status_set_error(F_parameter); - kt_remove_setting_delete(setting); + kt_remove_setting_delete(&main->setting); return F_none; } diff --git a/sources/c/remove/main/common.h b/sources/c/remove/main/common.h index b8f9aa7..2452b8f 100644 --- a/sources/c/remove/main/common.h +++ b/sources/c/remove/main/common.h @@ -17,1027 +17,6 @@ extern "C" { #endif /** - * The program version. - */ -#ifndef _di_kt_remove_program_version_s_ - #define KT_REMOVE_program_version_major_s F_string_ascii_0_s - #define KT_REMOVE_program_version_minor_s F_string_ascii_5_s - #define KT_REMOVE_program_version_micro_s F_string_ascii_0_s - - #define KT_REMOVE_program_version_major_s_length F_string_ascii_0_s_length - #define KT_REMOVE_program_version_minor_s_length F_string_ascii_5_s_length - #define KT_REMOVE_program_version_micro_s_length F_string_ascii_0_s_length - - #if !(defined(KT_REMOVE_program_version_nano_prefix_s) && defined(KT_REMOVE_program_version_nano_prefix_s_length)) - #define KT_REMOVE_program_version_nano_prefix_s - #define KT_REMOVE_program_version_nano_prefix_s_length 0 - #endif // !(defined(KT_REMOVE_program_version_nano_prefix_s) && defined(KT_REMOVE_program_version_nano_prefix_s_length)) - - #if !(defined(KT_REMOVE_program_version_nano_s) && defined(KT_REMOVE_program_version_nano_s_length)) - #define KT_REMOVE_program_version_nano_s - #define KT_REMOVE_program_version_nano_s_length 0 - #endif // !(defined(KT_REMOVE_program_version_nano_s) && defined(KT_REMOVE_program_version_nano_s_length)) - - #define KT_REMOVE_program_version_s KT_REMOVE_program_version_major_s F_string_ascii_period_s KT_REMOVE_program_version_minor_s F_string_ascii_period_s KT_REMOVE_program_version_micro_s KT_REMOVE_program_version_nano_prefix_s KT_REMOVE_program_version_nano_s - - #define KT_REMOVE_program_version_s_length KT_REMOVE_program_version_major_s_length + F_string_ascii_period_s_length + KT_REMOVE_program_version_minor_s_length + F_string_ascii_period_s_length + KT_REMOVE_program_version_micro_s_length + KT_REMOVE_program_version_nano_prefix_s_length + KT_REMOVE_program_version_nano_s_length - - extern const f_string_static_t kt_remove_program_version_s; -#endif // _di_kt_remove_program_version_s_ - -/** - * The program name. - */ -#ifndef _di_kt_remove_program_name_s_ - #define KT_REMOVE_program_name_s "remove" - #define KT_REMOVE_program_name_long_s "Remove" - - #define KT_REMOVE_program_name_s_length 6 - #define KT_REMOVE_program_name_long_s_length 6 - - extern const f_string_static_t kt_remove_program_name_s; - extern const f_string_static_t kt_remove_program_name_long_s; -#endif // _di_kt_remove_program_name_s_ - -/** - * The program help related data. - */ -#ifndef kt_remove_program_help_parameters_s_ - #define KT_REMOVE_program_help_parameters_s "file(s)" - #define KT_REMOVE_program_help_parameters_s_length 7 - - extern const f_string_static_t kt_remove_program_help_parameters_s; -#endif // _di_utf8_program_help_parameters_s_ - -/** - * The program default defines. - * - * kt_remove_default_allocation_*: - * - 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. - */ -#ifndef _di_kt_remove_default_d_ - #define kt_remove_default_allocation_large_d 2048 - #define kt_remove_default_allocation_small_d 128 -#endif // _di_kt_remove_default_d_ - -/** - * The program defines. - * - * Leap Year: - * - If can be evenly divided by 4, then this is a leap year. - * - * kt_remove_signal_*_d: - * - check: When not using threads, this is how often to perform the check (lower numbers incur more kernel I/O). - * - check_failsafe: When using threads, how many consecutive failures to check signal before aborting (as a recursion failsafe). - * - * kt_remove_time_seconds_in_*_d: - * - day: Number of seconds in a day. - * - hour: Number of seconds in a hour. - * - minute: Number of seconds in a minute. - * - nanosecond: Number of seconds in a nanosecond. - * - week: Number of seconds in a week. - * - year: Number of seconds in a year (does not include leap years). - * - * kt_remove_time_year_*_d: - * - unix_epoch: The year in which the UNIX Epoch starts. - */ -#ifndef _di_kt_remove_d_ - #define kt_remove_signal_check_d 20000 - #define kt_remove_signal_check_failsafe_d 20000 - - #define kt_remove_time_seconds_in_day_d 86400 - #define kt_remove_time_seconds_in_hour_d 3600 - #define kt_remove_time_seconds_in_minute_d 60 - #define kt_remove_time_seconds_in_nanosecond_d 1000000000 - #define kt_remove_time_seconds_in_week_d 604800 - #define kt_remove_time_seconds_in_year_d 31536000 - - #define kt_remove_time_year_unix_epoch_d 1970 -#endif // _di_kt_remove_d_ - -/** - * Strings associated with the date parameters. - * - * kt_remove_date_format_*_s: - * - 00: The string "YYYY/MM/DD hh:ii:ss a +0000". - * - 01: The string "YYYY/MM/DD HH:ii:ss +0000". - * - 02: The string "YYYY/MM/DD hh:ii a +0000". - * - 03: The string "YYYY/MM/DD HH:ii +0000". - * - 04: The string "YYYY/MM/DD hh a +0000". - * - 05: The string "YYYY/MM/DD HH +0000". - * - 06: The string "YYYY/MM/DD hh:ii:ss a". - * - 07: The string "YYYY/MM/DD HH:ii:ss". - * - 08: The string "YYYY/MM/DD hh:ii a". - * - 09: The string "YYYY/MM/DD HH:ii". - * - 10: The string "YYYY/MM/DD hh a". - * - 11: The string "YYYY/MM/DD HH". - * - 12: The string "YYYY/MM/DD". - * - 13: The string "YYYY/MM". - * - 14: The string "YYYY/". - * - * kt_remove_date_symbol_*_s: - * - equal: Equal to operator. - * - less: Less than operator. - * - less_equal: Less than or equal to operator. - * - more: Greater than operator. - * - more_equal: Greater than or equal to operator. - * - not: Not equal to operator. - * - * kt_remove_date_word_*_s: - * - equal: Equal to words. - * - less: Less than words. - * - less_equal: Less than or equal to words. - * - more: Greater than words. - * - more_equal: Greater than or equal to words. - * - not: Not equal to words. - */ -#ifndef _di_kt_remove_date_s_ - #define KT_REMOVE_date_format_00_s "%Y/%m/%d %I:%M:%S %p %z" - #define KT_REMOVE_date_format_01_s "%Y/%m/%d %H:%M:%S %z" - #define KT_REMOVE_date_format_02_s "%Y/%m/%d %I:%M %p %z" - #define KT_REMOVE_date_format_03_s "%Y/%m/%d %H:%M %z" - #define KT_REMOVE_date_format_04_s "%Y/%m/%d %I %p %z" - #define KT_REMOVE_date_format_05_s "%Y/%m/%d %H %z" - #define KT_REMOVE_date_format_06_s "%Y/%m/%d %I:%M:%S %p" - #define KT_REMOVE_date_format_07_s "%Y/%m/%d %H:%M:%S" - #define KT_REMOVE_date_format_08_s "%Y/%m/%d %I:%M %p" - #define KT_REMOVE_date_format_09_s "%Y/%m/%d %H:%M" - #define KT_REMOVE_date_format_10_s "%Y/%m/%d %I %p" - #define KT_REMOVE_date_format_11_s "%Y/%m/%d %H" - #define KT_REMOVE_date_format_12_s "%Y/%m/%d" - #define KT_REMOVE_date_format_13_s "%Y/%m" - #define KT_REMOVE_date_format_14_s "%Y/" - - #define KT_REMOVE_date_format_00_s_length 23 - #define KT_REMOVE_date_format_01_s_length 20 - #define KT_REMOVE_date_format_02_s_length 20 - #define KT_REMOVE_date_format_03_s_length 17 - #define KT_REMOVE_date_format_04_s_length 17 - #define KT_REMOVE_date_format_05_s_length 14 - #define KT_REMOVE_date_format_06_s_length 20 - #define KT_REMOVE_date_format_07_s_length 17 - #define KT_REMOVE_date_format_08_s_length 17 - #define KT_REMOVE_date_format_09_s_length 14 - #define KT_REMOVE_date_format_10_s_length 14 - #define KT_REMOVE_date_format_11_s_length 11 - #define KT_REMOVE_date_format_12_s_length 8 - #define KT_REMOVE_date_format_13_s_length 5 - #define KT_REMOVE_date_format_14_s_length 3 - - extern const f_string_static_t kt_remove_date_format_00_s; - extern const f_string_static_t kt_remove_date_format_01_s; - extern const f_string_static_t kt_remove_date_format_02_s; - extern const f_string_static_t kt_remove_date_format_03_s; - extern const f_string_static_t kt_remove_date_format_04_s; - extern const f_string_static_t kt_remove_date_format_05_s; - extern const f_string_static_t kt_remove_date_format_06_s; - extern const f_string_static_t kt_remove_date_format_07_s; - extern const f_string_static_t kt_remove_date_format_08_s; - extern const f_string_static_t kt_remove_date_format_09_s; - extern const f_string_static_t kt_remove_date_format_10_s; - extern const f_string_static_t kt_remove_date_format_11_s; - extern const f_string_static_t kt_remove_date_format_12_s; - extern const f_string_static_t kt_remove_date_format_13_s; - extern const f_string_static_t kt_remove_date_format_14_s; - - #define KT_REMOVE_date_format_example_00_s "2022/12/30 1:45:02 pm +0600" - #define KT_REMOVE_date_format_example_01_s "2022/12/30 13:45:02 +0600" - #define KT_REMOVE_date_format_example_02_s "2022/12/30 1:45 pm +0600" - #define KT_REMOVE_date_format_example_03_s "2022/12/30 13:45 +0600" - #define KT_REMOVE_date_format_example_04_s "2022/12/30 1 pm +0600" - #define KT_REMOVE_date_format_example_05_s "2022/12/30 13 +0600" - #define KT_REMOVE_date_format_example_06_s "2022/12/30 1:45:02 pm" - #define KT_REMOVE_date_format_example_07_s "2022/12/30 13:45:02" - #define KT_REMOVE_date_format_example_08_s "2022/12/30 1:45 pm" - #define KT_REMOVE_date_format_example_09_s "2022/12/30 13:45" - #define KT_REMOVE_date_format_example_10_s "2022/12/30 1 pm" - #define KT_REMOVE_date_format_example_11_s "2022/12/30 13" - #define KT_REMOVE_date_format_example_12_s "2022/12/30" - #define KT_REMOVE_date_format_example_13_s "2022/12" - #define KT_REMOVE_date_format_example_14_s "2022/" - - #define KT_REMOVE_date_format_example_00_s_length 27 - #define KT_REMOVE_date_format_example_01_s_length 25 - #define KT_REMOVE_date_format_example_02_s_length 24 - #define KT_REMOVE_date_format_example_03_s_length 22 - #define KT_REMOVE_date_format_example_04_s_length 21 - #define KT_REMOVE_date_format_example_05_s_length 19 - #define KT_REMOVE_date_format_example_06_s_length 21 - #define KT_REMOVE_date_format_example_07_s_length 19 - #define KT_REMOVE_date_format_example_08_s_length 18 - #define KT_REMOVE_date_format_example_09_s_length 16 - #define KT_REMOVE_date_format_example_10_s_length 15 - #define KT_REMOVE_date_format_example_11_s_length 13 - #define KT_REMOVE_date_format_example_12_s_length 10 - #define KT_REMOVE_date_format_example_13_s_length 9 - #define KT_REMOVE_date_format_example_14_s_length 5 - - extern const f_string_static_t kt_remove_date_format_example_00_s; - extern const f_string_static_t kt_remove_date_format_example_01_s; - extern const f_string_static_t kt_remove_date_format_example_02_s; - extern const f_string_static_t kt_remove_date_format_example_03_s; - extern const f_string_static_t kt_remove_date_format_example_04_s; - extern const f_string_static_t kt_remove_date_format_example_05_s; - extern const f_string_static_t kt_remove_date_format_example_06_s; - extern const f_string_static_t kt_remove_date_format_example_07_s; - extern const f_string_static_t kt_remove_date_format_example_08_s; - extern const f_string_static_t kt_remove_date_format_example_09_s; - extern const f_string_static_t kt_remove_date_format_example_10_s; - extern const f_string_static_t kt_remove_date_format_example_11_s; - extern const f_string_static_t kt_remove_date_format_example_12_s; - extern const f_string_static_t kt_remove_date_format_example_13_s; - extern const f_string_static_t kt_remove_date_format_example_14_s; - - #define KT_REMOVE_date_symbol_equal_s "==" - #define KT_REMOVE_date_symbol_less_s "<" - #define KT_REMOVE_date_symbol_less_equal_s "<=" - #define KT_REMOVE_date_symbol_more_s ">" - #define KT_REMOVE_date_symbol_more_equal_s ">=" - #define KT_REMOVE_date_symbol_not_s "<>" - - #define KT_REMOVE_date_symbol_equal_s_length 2 - #define KT_REMOVE_date_symbol_less_s_length 1 - #define KT_REMOVE_date_symbol_less_equal_s_length 2 - #define KT_REMOVE_date_symbol_more_s_length 1 - #define KT_REMOVE_date_symbol_more_equal_s_length 2 - #define KT_REMOVE_date_symbol_not_s_length 2 - - extern const f_string_static_t kt_remove_date_symbol_equal_s; - extern const f_string_static_t kt_remove_date_symbol_less_s; - extern const f_string_static_t kt_remove_date_symbol_less_equal_s; - extern const f_string_static_t kt_remove_date_symbol_more_s; - extern const f_string_static_t kt_remove_date_symbol_more_equal_s; - extern const f_string_static_t kt_remove_date_symbol_not_s; - - #define KT_REMOVE_date_word_equal_s "equal" - #define KT_REMOVE_date_word_less_s "less" - #define KT_REMOVE_date_word_less_equal_s "less_equal" - #define KT_REMOVE_date_word_more_s "more" - #define KT_REMOVE_date_word_more_equal_s "more_equal" - #define KT_REMOVE_date_word_not_s "not" - - #define KT_REMOVE_date_word_equal_s_length 5 - #define KT_REMOVE_date_word_less_s_length 4 - #define KT_REMOVE_date_word_less_equal_s_length 10 - #define KT_REMOVE_date_word_more_s_length 4 - #define KT_REMOVE_date_word_more_equal_s_length 10 - #define KT_REMOVE_date_word_not_s_length 3 - - extern const f_string_static_t kt_remove_date_word_equal_s; - extern const f_string_static_t kt_remove_date_word_less_s; - extern const f_string_static_t kt_remove_date_word_less_equal_s; - extern const f_string_static_t kt_remove_date_word_more_s; - extern const f_string_static_t kt_remove_date_word_more_equal_s; - extern const f_string_static_t kt_remove_date_word_not_s; -#endif // _di_kt_remove_date_s_ - -/** - * Strings associated with the mode parameters. - * - * kt_remove_mode_symbol_*_s: - * - different: The not similar to operator. - * - same: The same as operator. - * - similar: The similar to operator. - * - not: The not same as operator. - * - * kt_remove_mode_word_*_s: - * - different: The not similar to words. - * - same: The same as words. - * - similar: The similar to words. - * - not: The not same as words. - */ -#ifndef _di_kt_remove_mode_s_ - #define KT_REMOVE_mode_symbol_different_s "~~" - #define KT_REMOVE_mode_symbol_same_s "==" - #define KT_REMOVE_mode_symbol_similar_s "~=" - #define KT_REMOVE_mode_symbol_not_s "<>" - - #define KT_REMOVE_mode_symbol_different_s_length 2 - #define KT_REMOVE_mode_symbol_same_s_length 2 - #define KT_REMOVE_mode_symbol_similar_s_length 2 - #define KT_REMOVE_mode_symbol_not_s_length 2 - - extern const f_string_static_t kt_remove_mode_symbol_different_s; - extern const f_string_static_t kt_remove_mode_symbol_same_s; - extern const f_string_static_t kt_remove_mode_symbol_similar_s; - extern const f_string_static_t kt_remove_mode_symbol_not_s; - - #define KT_REMOVE_mode_word_different_s "different" - #define KT_REMOVE_mode_word_same_s "same" - #define KT_REMOVE_mode_word_similar_s "similar" - #define KT_REMOVE_mode_word_not_s "not" - - #define KT_REMOVE_mode_word_different_s_length 9 - #define KT_REMOVE_mode_word_same_s_length 4 - #define KT_REMOVE_mode_word_similar_s_length 7 - #define KT_REMOVE_mode_word_not_s_length 3 - - extern const f_string_static_t kt_remove_mode_word_different_s; - extern const f_string_static_t kt_remove_mode_word_same_s; - extern const f_string_static_t kt_remove_mode_word_similar_s; - extern const f_string_static_t kt_remove_mode_word_not_s; -#endif // _di_kt_remove_mode_s_ - -/** - * Additional strings used for various purposes. - * - * kt_remove_*_s: Arbitrary strings. - */ -#ifndef _di_kt_remove_s_ - #define KT_REMOVE_all_s "all" - #define KT_REMOVE_follow_s "follow" - #define KT_REMOVE_ignore_s "ignore" - #define KT_REMOVE_never_s "never" - #define KT_REMOVE_no_s "no" - #define KT_REMOVE_not_s "not" - #define KT_REMOVE_not_fail_s "not_fail" - #define KT_REMOVE_now_s "now" - #define KT_REMOVE_once_s "once" - #define KT_REMOVE_only_s "only" - #define KT_REMOVE_only_fail_s "only_fail" - #define KT_REMOVE_root_s "root" - #define KT_REMOVE_today_s "today" - #define KT_REMOVE_tomorrow_s "tomorrow" - #define KT_REMOVE_yes_s "yes" - #define KT_REMOVE_yesterday_s "yesterday" - - #define KT_REMOVE_all_s_length 3 - #define KT_REMOVE_follow_s_length 6 - #define KT_REMOVE_ignore_s_length 6 - #define KT_REMOVE_never_s_length 5 - #define KT_REMOVE_no_s_length 2 - #define KT_REMOVE_not_s_length 3 - #define KT_REMOVE_not_fail_s_length 8 - #define KT_REMOVE_now_s_length 3 - #define KT_REMOVE_once_s_length 4 - #define KT_REMOVE_only_s_length 4 - #define KT_REMOVE_only_fail_s_length 9 - #define KT_REMOVE_root_s_length 4 - #define KT_REMOVE_today_s_length 5 - #define KT_REMOVE_tomorrow_s_length 8 - #define KT_REMOVE_yes_s_length 3 - #define KT_REMOVE_yesterday_s_length 9 - - extern const f_string_static_t kt_remove_all_s; - extern const f_string_static_t kt_remove_follow_s; - extern const f_string_static_t kt_remove_ignore_s; - extern const f_string_static_t kt_remove_never_s; - extern const f_string_static_t kt_remove_no_s; - extern const f_string_static_t kt_remove_not_s; - extern const f_string_static_t kt_remove_not_fail_s; - extern const f_string_static_t kt_remove_now_s; - extern const f_string_static_t kt_remove_once_s; - extern const f_string_static_t kt_remove_only_s; - extern const f_string_static_t kt_remove_only_fail_s; - extern const f_string_static_t kt_remove_root_s; - extern const f_string_static_t kt_remove_today_s; - extern const f_string_static_t kt_remove_tomorrow_s; - extern const f_string_static_t kt_remove_yes_s; - extern const f_string_static_t kt_remove_yesterday_s; -#endif // _di_kt_remove_s_ - -/** - * A processed Date parameter. - * - * The start is inclusive and the stop is exclusive just like with f_string_range_t. - * - * operation: The comparison operation. - * type: The date type. - * - * start_year: The year in which the seconds is relative to (is only processed when - * start_second: The entire date value in seconds for the date or the start of a date range. - * start_nanosecond: The remaining nanosecond not represented in the seconds for the date or the start of a date range. - * stop_second: The entire date value in seconds for the stop of a date range (not used for non-range dates). - * stop_nanosecond: The remaining nanosecond not represented in the seconds for the stop of a date range (not used for non-range dates). - */ -#ifndef _di_kt_remove_date_t_ - typedef struct { - uint8_t operation; - uint8_t type; - - f_number_unsigned_t start_year; - f_number_unsigned_t start_second; - f_number_unsigned_t start_nanosecond; - - f_number_unsigned_t stop_year; - f_number_unsigned_t stop_second; - f_number_unsigned_t stop_nanosecond; - } kt_remove_date_t; - - #define kt_remove_date_t_initialize { \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - } -#endif // _di_kt_remove_date_t_ - -/** - * Date parameters. - * - * array: An array of data parameters. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_kt_remove_dates_t_ - typedef struct { - kt_remove_date_t *array; - - f_array_length_t size; - f_array_length_t used; - } kt_remove_dates_t; - - #define kt_remove_dates_t_initialize { \ - 0, \ - 0, \ - 0, \ - } - - #define macro_kt_remove_dates_t_clear(dates) \ - dates.array = 0; \ - dates.size = 0; \ - dates.used = 0; -#endif // _di_kt_remove_dates_t_ - -/** - * A processed mode parameter. - * - * type: The mode type. - * mode: The right side date value. - */ -#ifndef _di_kt_remove_mode_t_ - typedef struct { - uint8_t type; - mode_t mode; - } kt_remove_mode_t; - - #define kt_remove_mode_t_initialize { \ - 0, \ - 0, \ - } -#endif // _di_kt_remove_mode_t_ - -/** - * Mode parameters. - * - * array: An array of mode parameters. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_kt_remove_modes_t_ - typedef struct { - kt_remove_mode_t *array; - - f_array_length_t size; - f_array_length_t used; - } kt_remove_modes_t; - - #define kt_remove_modes_t_initialize { \ - 0, \ - 0, \ - 0, \ - } - - #define macro_kt_remove_modes_t_clear(dates) \ - dates.array = 0; \ - dates.size = 0; \ - dates.used = 0; -#endif // _di_kt_remove_modes_t_ - -/** - * Flags passed to the main function or program. - * - * @todo /proc needs to be implemented, but before that try to understand how --one-file-system, --no-preserve-root, and --preserve-root work in coreutils rm command. - * - * kt_remove_flag_*_e: - * - none: No flags set. - * - block: Remove by file type: block. - * - character: Remove by file type: character. - * - date: Remove by date (separate flag for <, <=, ==, >=, and >). - * - 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 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 (@todo requires /proc support). - * - isolate_ignore: Ignore rather than fail for anything on a different file system (@todo requires /proc support). - * - isolate_root: Isolate to a single file system, error on remove on '/' (@todo 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. - * - print_warning: When specified, warnings are still printed even when verbosity is less than verbose. - * - 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). - * - user: Remove by UID. - * - utc: Process dates in UTC mode. - * - version: Print version. - */ -#ifndef _di_kt_remove_flag_e_ - enum { - kt_remove_flag_none_e = 0x0, - kt_remove_flag_accessed_e = 0x1, - kt_remove_flag_block_e = 0x2, - kt_remove_flag_character_e = 0x4, - kt_remove_flag_created_e = 0x8, - kt_remove_flag_different_e = 0x10, - kt_remove_flag_directory_e = 0x20, - kt_remove_flag_empty_only_e = 0x40, - kt_remove_flag_empty_only_fail_e = 0x80, - kt_remove_flag_empty_not_e = 0x100, - kt_remove_flag_empty_not_fail_e = 0x200, - kt_remove_flag_fifo_e = 0x400, - kt_remove_flag_follow_e = 0x800, - kt_remove_flag_force_e = 0x1000, - kt_remove_flag_group_e = 0x2000, - kt_remove_flag_help_e = 0x4000, - kt_remove_flag_isolate_all_e = 0x8000, - kt_remove_flag_isolate_ignore_e = 0x10000, - kt_remove_flag_isolate_root_e = 0x20000, - kt_remove_flag_link_e = 0x40000, - kt_remove_flag_mode_e = 0x80000, - kt_remove_flag_option_used_e = 0x100000, - kt_remove_flag_print_warning_e = 0x200000, - kt_remove_flag_prompt_all_e = 0x400000, - kt_remove_flag_prompt_follow_e = 0x800000, - kt_remove_flag_prompt_never_e = 0x1000000, - kt_remove_flag_prompt_once_e = 0x2000000, - kt_remove_flag_recurse_e = 0x4000000, - kt_remove_flag_regular_e = 0x8000000, - kt_remove_flag_same_e = 0x10000000, - kt_remove_flag_simulate_e = 0x20000000, - kt_remove_flag_socket_e = 0x40000000, - kt_remove_flag_tree_e = 0x80000000, - kt_remove_flag_updated_e = 0x100000000, - kt_remove_flag_user_e = 0x200000000, - kt_remove_flag_utc_e = 0x400000000, - kt_remove_flag_version_e = 0x800000000, - }; // 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 date. - * - * 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_ - -/** - * The main program settings. - * - * This is passed to the program-specific main entry point to designate program settings. - * These program settings are often processed from the program arguments (often called the command line arguments). - * - * flag: Flags passed to the main function. - * - * status: The main status code, generally used by the load settings and main functions. - * status_thread: A status used eclusively by the threaded signal handler. - * state: The state data used when processing data. - * - * program_name: The short name of the program. - * program_name_long: The human friendly name of the program. - * - * buffer: A string buffer used for caching purposes. - * files: An array of file names (full paths to the files) to remove. - * - * accessed: An array of last accessed dates used for comparison. - * created: An array of created on dates used for comparison. - * updated: An array of last updated dates used for comparison. - * modes: An array of modes used for comparison. - * groups: An array of Group IDs (gid_t) represented via an unsigned 32-bit integer. - * users: An array of Group IDs (uid_t) represented via an unsigned 32-bit integer. - * - * process_help: Process help (generally printing help). - * process_normal: Process normally (data from parameters and files). - * - * macro_kt_remove_setting: - * - Used to represent a cast to ((kt_remove_setting_t *) setting). - * - Simplifies the number of parenthesis used to make code slightly cleaner. - * - Is wrapped in a parenthesis and not a block. - */ -#ifndef _di_kt_remove_setting_t_ - typedef struct { - uint64_t flag; - - f_status_t status; - f_status_t status_thread; - f_state_t state; - - f_string_dynamic_t buffer; - f_string_dynamics_t files; - - kt_remove_dates_t accessed; - kt_remove_dates_t created; - kt_remove_dates_t updated; - kt_remove_modes_t modes; - f_uint32s_t groups; - f_uint32s_t users; - - const f_string_static_t *program_name; - const f_string_static_t *program_name_long; - - f_status_t (*process_help)(fll_program_data_t * const main, void * const setting); - void (*process_normal)(fll_program_data_t * const main, void * const setting); - } kt_remove_setting_t; - - #define kt_remove_setting_t_initialize \ - { \ - kt_remove_flag_none_e, \ - F_none, \ - F_none, \ - macro_f_state_t_initialize(kt_remove_default_allocation_large_d, kt_remove_default_allocation_small_d, 0, 0, &fll_program_standard_signal_state, 0, 0, 0), \ - f_string_dynamic_t_initialize, \ - f_string_dynamics_t_initialize, \ - kt_remove_dates_t_initialize, \ - kt_remove_dates_t_initialize, \ - kt_remove_dates_t_initialize, \ - kt_remove_modes_t_initialize, \ - f_uint32s_t_initialize, \ - f_uint32s_t_initialize, \ - 0, \ - 0, \ - 0, \ - 0, \ - } - - #define macro_kt_remove_setting(setting) ((kt_remove_setting_t *) setting) -#endif // _di_kt_remove_setting_t_ -/** - * An arguments array for passing the standard variables to a thread callback. - * - * main: The main program data. - * setting: The main program settings. - * - * macro_kt_remove_arguments: - * - Used to represent a cast to ((kt_remove_setting_t *) setting). - * - Simplifies the number of parenthesis used to make code slightly cleaner. - * - Is wrapped in a parenthesis and not a block. - */ -#ifndef _di_kt_remove_arguments_t_ - typedef struct { - fll_program_data_t *main; - kt_remove_setting_t *setting; - } kt_remove_arguments_t; - - #define kt_remove_arguments_t_initialize { \ - 0, \ - 0, \ - } - - #define macro_kt_remove_arguments_t_initialize(main, setting) { \ - main, \ - setting, \ - } - - #define macro_kt_remove_arguments(arguments) ((kt_remove_arguments_t *) arguments) -#endif // _di_kt_remove_arguments_t_ - -/** - * The main program parameters. - */ -#ifndef _di_kt_remove_parameter_d_ - #define KT_REMOVE_short_accessed_s "A" - #define KT_REMOVE_short_block_s "b" - #define KT_REMOVE_short_character_s "c" - #define KT_REMOVE_short_created_s "C" - #define KT_REMOVE_short_different_s "O" - #define KT_REMOVE_short_directory_s "d" - #define KT_REMOVE_short_empty_s "e" - #define KT_REMOVE_short_fifo_s "o" - #define KT_REMOVE_short_follow_s "F" - #define KT_REMOVE_short_force_s "f" - #define KT_REMOVE_short_group_s "g" - #define KT_REMOVE_short_isolate_s "i" - #define KT_REMOVE_short_link_s "l" - #define KT_REMOVE_short_mode_s "m" - #define KT_REMOVE_short_prompt_s "p" - #define KT_REMOVE_short_recurse_s "r" - #define KT_REMOVE_short_regular_s "R" - #define KT_REMOVE_short_same_s "s" - #define KT_REMOVE_short_simulate_s "S" - #define KT_REMOVE_short_socket_s "k" - #define KT_REMOVE_short_stay_s "Y" - #define KT_REMOVE_short_tree_s "t" - #define KT_REMOVE_short_updated_s "U" - #define KT_REMOVE_short_user_s "u" - - #define KT_REMOVE_long_accessed_s "accessed" - #define KT_REMOVE_long_block_s "block" - #define KT_REMOVE_long_character_s "character" - #define KT_REMOVE_long_created_s "created" - #define KT_REMOVE_long_different_s "different" - #define KT_REMOVE_long_directory_s "directory" - #define KT_REMOVE_long_empty_s "empty" - #define KT_REMOVE_long_fifo_s "fifo" - #define KT_REMOVE_long_follow_s "follow" - #define KT_REMOVE_long_force_s "force" - #define KT_REMOVE_long_group_s "group" - #define KT_REMOVE_long_isolate_s "isolate" - #define KT_REMOVE_long_link_s "link" - #define KT_REMOVE_long_local_s "local" - #define KT_REMOVE_long_mode_s "mode" - #define KT_REMOVE_long_prompt_s "prompt" - #define KT_REMOVE_long_recurse_s "recurse" - #define KT_REMOVE_long_regular_s "regular" - #define KT_REMOVE_long_same_s "same" - #define KT_REMOVE_long_simulate_s "simulate" - #define KT_REMOVE_long_socket_s "socket" - #define KT_REMOVE_long_stay_s "stay" - #define KT_REMOVE_long_tree_s "tree" - #define KT_REMOVE_long_updated_s "updated" - #define KT_REMOVE_long_user_s "user" - #define KT_REMOVE_long_utc_s "utc" - - #define KT_REMOVE_short_accessed_s_length 1 - #define KT_REMOVE_short_block_s_length 1 - #define KT_REMOVE_short_character_s_length 1 - #define KT_REMOVE_short_created_s_length 1 - #define KT_REMOVE_short_different_s_length 1 - #define KT_REMOVE_short_directory_s_length 1 - #define KT_REMOVE_short_empty_s_length 1 - #define KT_REMOVE_short_fifo_s_length 1 - #define KT_REMOVE_short_follow_s_length 1 - #define KT_REMOVE_short_force_s_length 1 - #define KT_REMOVE_short_group_s_length 1 - #define KT_REMOVE_short_isolate_s_length 1 - #define KT_REMOVE_short_link_s_length 1 - #define KT_REMOVE_short_mode_s_length 1 - #define KT_REMOVE_short_prompt_s_length 1 - #define KT_REMOVE_short_recurse_s_length 1 - #define KT_REMOVE_short_regular_s_length 1 - #define KT_REMOVE_short_same_s_length 1 - #define KT_REMOVE_short_simulate_s_length 1 - #define KT_REMOVE_short_socket_s_length 1 - #define KT_REMOVE_short_stay_s_length 1 - #define KT_REMOVE_short_tree_s_length 1 - #define KT_REMOVE_short_updated_s_length 1 - #define KT_REMOVE_short_user_s_length 1 - - #define KT_REMOVE_long_accessed_s_length 8 - #define KT_REMOVE_long_block_s_length 6 - #define KT_REMOVE_long_character_s_length 9 - #define KT_REMOVE_long_created_s_length 7 - #define KT_REMOVE_long_different_s_length 9 - #define KT_REMOVE_long_directory_s_length 9 - #define KT_REMOVE_long_empty_s_length 5 - #define KT_REMOVE_long_fifo_s_length 4 - #define KT_REMOVE_long_follow_s_length 6 - #define KT_REMOVE_long_force_s_length 5 - #define KT_REMOVE_long_group_s_length 5 - #define KT_REMOVE_long_isolate_s_length 7 - #define KT_REMOVE_long_link_s_length 4 - #define KT_REMOVE_long_local_s_length 5 - #define KT_REMOVE_long_mode_s_length 4 - #define KT_REMOVE_long_prompt_s_length 6 - #define KT_REMOVE_long_recurse_s_length 7 - #define KT_REMOVE_long_regular_s_length 7 - #define KT_REMOVE_long_same_s_length 4 - #define KT_REMOVE_long_simulate_s_length 8 - #define KT_REMOVE_long_socket_s_length 6 - #define KT_REMOVE_long_stay_s_length 4 - #define KT_REMOVE_long_tree_s_length 4 - #define KT_REMOVE_long_updated_s_length 7 - #define KT_REMOVE_long_user_s_length 4 - #define KT_REMOVE_long_utc_s_length 3 - - extern const f_string_static_t kt_remove_short_accessed_s; - extern const f_string_static_t kt_remove_short_block_s; - extern const f_string_static_t kt_remove_short_character_s; - extern const f_string_static_t kt_remove_short_created_s; - extern const f_string_static_t kt_remove_short_different_s; - extern const f_string_static_t kt_remove_short_directory_s; - extern const f_string_static_t kt_remove_short_empty_s; - extern const f_string_static_t kt_remove_short_fifo_s; - extern const f_string_static_t kt_remove_short_follow_s; - extern const f_string_static_t kt_remove_short_force_s; - extern const f_string_static_t kt_remove_short_group_s; - extern const f_string_static_t kt_remove_short_isolate_s; - extern const f_string_static_t kt_remove_short_link_s; - extern const f_string_static_t kt_remove_short_mode_s; - extern const f_string_static_t kt_remove_short_prompt_s; - extern const f_string_static_t kt_remove_short_recurse_s; - extern const f_string_static_t kt_remove_short_regular_s; - extern const f_string_static_t kt_remove_short_same_s; - extern const f_string_static_t kt_remove_short_simulate_s; - extern const f_string_static_t kt_remove_short_socket_s; - extern const f_string_static_t kt_remove_short_stay_s; - extern const f_string_static_t kt_remove_short_tree_s; - extern const f_string_static_t kt_remove_short_updated_s; - extern const f_string_static_t kt_remove_short_user_s; - - extern const f_string_static_t kt_remove_long_accessed_s; - extern const f_string_static_t kt_remove_long_block_s; - extern const f_string_static_t kt_remove_long_character_s; - extern const f_string_static_t kt_remove_long_created_s; - extern const f_string_static_t kt_remove_long_different_s; - extern const f_string_static_t kt_remove_long_directory_s; - extern const f_string_static_t kt_remove_long_empty_s; - extern const f_string_static_t kt_remove_long_fifo_s; - extern const f_string_static_t kt_remove_long_follow_s; - extern const f_string_static_t kt_remove_long_force_s; - extern const f_string_static_t kt_remove_long_group_s; - extern const f_string_static_t kt_remove_long_isolate_s; - extern const f_string_static_t kt_remove_long_link_s; - extern const f_string_static_t kt_remove_long_local_s; - extern const f_string_static_t kt_remove_long_mode_s; - extern const f_string_static_t kt_remove_long_prompt_s; - extern const f_string_static_t kt_remove_long_recurse_s; - extern const f_string_static_t kt_remove_long_regular_s; - extern const f_string_static_t kt_remove_long_same_s; - extern const f_string_static_t kt_remove_long_simulate_s; - extern const f_string_static_t kt_remove_long_socket_s; - extern const f_string_static_t kt_remove_long_stay_s; - extern const f_string_static_t kt_remove_long_tree_s; - extern const f_string_static_t kt_remove_long_updated_s; - extern const f_string_static_t kt_remove_long_user_s; - extern const f_string_static_t kt_remove_long_utc_s; - - enum { - kt_remove_parameter_help_e, - kt_remove_parameter_light_e, - kt_remove_parameter_dark_e, - kt_remove_parameter_no_color_e, - kt_remove_parameter_verbosity_quiet_e, - kt_remove_parameter_verbosity_error_e, - kt_remove_parameter_verbosity_normal_e, - kt_remove_parameter_verbosity_verbose_e, - kt_remove_parameter_verbosity_debug_e, - kt_remove_parameter_version_e, - kt_remove_parameter_accessed_e, - kt_remove_parameter_block_e, - kt_remove_parameter_character_e, - kt_remove_parameter_created_e, - kt_remove_parameter_different_e, - kt_remove_parameter_directory_e, - kt_remove_parameter_empty_e, - kt_remove_parameter_fifo_e, - kt_remove_parameter_follow_e, - kt_remove_parameter_force_e, - kt_remove_parameter_group_e, - kt_remove_parameter_isolate_e, - kt_remove_parameter_link_e, - kt_remove_parameter_local_e, - kt_remove_parameter_mode_e, - kt_remove_parameter_prompt_e, - kt_remove_parameter_recurse_e, - kt_remove_parameter_regular_e, - kt_remove_parameter_same_e, - kt_remove_parameter_simulate_e, - kt_remove_parameter_socket_e, - kt_remove_parameter_stay_e, - kt_remove_parameter_tree_e, - kt_remove_parameter_updated_e, - kt_remove_parameter_user_e, - kt_remove_parameter_utc_e, - }; // enum - - #define kt_remove_console_parameter_t_initialize \ - { \ - macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ - macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ - macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ - macro_f_console_parameter_t_initialize(f_console_standard_short_quiet_s.string, f_console_standard_long_quiet_s.string, 0, 0, f_console_type_inverse_e), \ - macro_f_console_parameter_t_initialize(f_console_standard_short_error_s.string, f_console_standard_long_error_s.string, 0, 0, f_console_type_inverse_e), \ - macro_f_console_parameter_t_initialize(f_console_standard_short_normal_s.string, f_console_standard_long_normal_s.string, 0, 0, f_console_type_inverse_e), \ - macro_f_console_parameter_t_initialize(f_console_standard_short_verbose_s.string, f_console_standard_long_verbose_s.string, 0, 0, f_console_type_inverse_e), \ - macro_f_console_parameter_t_initialize(f_console_standard_short_debug_s.string, f_console_standard_long_debug_s.string, 0, 0, f_console_type_inverse_e), \ - macro_f_console_parameter_t_initialize(f_console_standard_short_version_s.string, f_console_standard_long_version_s.string, 0, 0, f_console_type_inverse_e), \ - \ - macro_f_console_parameter_t_initialize(kt_remove_short_accessed_s.string, kt_remove_long_accessed_s.string, 0, 2, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_block_s.string, kt_remove_long_block_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_character_s.string, kt_remove_long_character_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_created_s.string, kt_remove_long_created_s.string, 0, 2, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_different_s.string, kt_remove_long_different_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_directory_s.string, kt_remove_long_directory_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_empty_s.string, kt_remove_long_empty_s.string, 0, 1, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_fifo_s.string, kt_remove_long_fifo_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_follow_s.string, kt_remove_long_follow_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_force_s.string, kt_remove_long_force_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_group_s.string, kt_remove_long_group_s.string, 0, 1, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_isolate_s.string, kt_remove_long_isolate_s.string, 0, 1, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_link_s.string, kt_remove_long_link_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(0, kt_remove_long_local_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_mode_s.string, kt_remove_long_mode_s.string, 0, 2, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_prompt_s.string, kt_remove_long_prompt_s.string, 0, 1, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_recurse_s.string, kt_remove_long_recurse_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_regular_s.string, kt_remove_long_regular_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_same_s.string, kt_remove_long_same_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_simulate_s.string, kt_remove_long_simulate_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_socket_s.string, kt_remove_long_socket_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_stay_s.string, kt_remove_long_stay_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_tree_s.string, kt_remove_long_tree_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_updated_s.string, kt_remove_long_updated_s.string, 0, 2, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(kt_remove_short_user_s.string, kt_remove_long_user_s.string, 0, 1, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(0, kt_remove_long_utc_s.string, 0, 0, f_console_type_normal_e), \ - } - - #define kt_remove_total_parameters_d 36 -#endif // _di_kt_remove_parameter_d_ - -/** * Resize a date array. * * @param length @@ -1083,7 +62,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter main.setting.state.status. * * @return * F_none on success. @@ -1104,9 +83,7 @@ extern "C" { * @param arguments * The parameters passed to the process (often referred to as command line arguments). * @param main - * The main program data. - * @param setting - * The main program settings. + * The main program and settings data. * * The setting.flag has kt_remove_flag_option_used_e forcibly cleared on the start of this function. * @@ -1125,16 +102,15 @@ extern "C" { * @see f_string_dynamics_resize() */ #ifndef _di_kt_remove_setting_load_ - extern void kt_remove_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, kt_remove_setting_t * const setting); + extern void kt_remove_setting_load(const f_console_arguments_t arguments, kt_remove_main_t * const main); #endif // _di_kt_remove_setting_load_ /** * Perform the standard program setting unload process. * * @param main - * The main program data. - * @param setting - * The main program settings. + * The main program and settings data. + * * All buffers are deallocated. * * This does not alter setting.status. @@ -1144,12 +120,12 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: utf8_setting_delete(). + * Errors (with error bit) from: kt_remove_setting_delete(). * - * @see utf8_setting_delete() + * @see kt_remove_setting_delete() */ #ifndef _di_kt_remove_setting_unload_ - extern f_status_t kt_remove_setting_unload(fll_program_data_t * const main, kt_remove_setting_t * const setting); + extern f_status_t kt_remove_setting_unload(kt_remove_main_t * const main); #endif // _di_kt_remove_setting_unload_ #ifdef __cplusplus diff --git a/sources/c/remove/main/common/define.c b/sources/c/remove/main/common/define.c new file mode 100644 index 0000000..7a21078 --- /dev/null +++ b/sources/c/remove/main/common/define.c @@ -0,0 +1,9 @@ +#include "../remove.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/remove/main/common/define.h b/sources/c/remove/main/common/define.h new file mode 100644 index 0000000..5c6772a --- /dev/null +++ b/sources/c/remove/main/common/define.h @@ -0,0 +1,67 @@ +/** + * Kevux Tools - Remove + * + * Project: Kevux Tools + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Provides the common define types. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _kt_remove_common_define_h +#define _kt_remove_common_define_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The program defines. + * + * Leap Year: + * - If can be evenly divided by 4, then this is a leap year. + * + * kt_remove_signal_*_d: + * + * kt_remove_*_d: + * - allocation_console: An allocation step used for small buffers specifically for console parameter. + * - allocation_large: An allocation step used for buffers that are anticipated to have large buffers. + * - allocation_small: An allocation step used for buffers that are anticipated to have small buffers. + * - signal_check: When not using threads, this is how often to perform the check (lower numbers incur more kernel I/O). + * - signal_check_failsafe: When using threads, how many consecutive failures to check signal before aborting (as a recursion failsafe). + * + * kt_remove_time_seconds_in_*_d: + * - day: Number of seconds in a day. + * - hour: Number of seconds in a hour. + * - minute: Number of seconds in a minute. + * - nanosecond: Number of seconds in a nanosecond. + * - week: Number of seconds in a week. + * - year: Number of seconds in a year (does not include leap years). + * + * kt_remove_time_year_*_d: + * - 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_signal_check_d 20000 + #define kt_remove_signal_check_failsafe_d 20000 + + #define kt_remove_time_seconds_in_day_d 86400 + #define kt_remove_time_seconds_in_hour_d 3600 + #define kt_remove_time_seconds_in_minute_d 60 + #define kt_remove_time_seconds_in_nanosecond_d 1000000000 + #define kt_remove_time_seconds_in_week_d 604800 + #define kt_remove_time_seconds_in_year_d 31536000 + + #define kt_remove_time_year_unix_epoch_d 1970 +#endif // _di_kt_remove_d_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _kt_remove_common_define_h diff --git a/sources/c/remove/main/common/enumeration.c b/sources/c/remove/main/common/enumeration.c new file mode 100644 index 0000000..7a21078 --- /dev/null +++ b/sources/c/remove/main/common/enumeration.c @@ -0,0 +1,9 @@ +#include "../remove.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/remove/main/common/enumeration.h b/sources/c/remove/main/common/enumeration.h new file mode 100644 index 0000000..a156238 --- /dev/null +++ b/sources/c/remove/main/common/enumeration.h @@ -0,0 +1,322 @@ +/** + * Kevux Tools - Remove + * + * Project: Kevux Tools + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Provides the common enumeration types. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _kt_remove_common_enumeration_h +#define _kt_remove_common_enumeration_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Flags passed to the main function or program. + * + * kt_remove_main_flag_*_e: + * - none: No flags set. + * - accessed: @todo + * - block: Remove by file type: block. + * - character: Remove by file type: character. + * - copyright: Print copyright. + * - created: @todo + * - 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 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 (@todo requires /proc support). + * - isolate_ignore: Ignore rather than fail for anything on a different file system (@todo requires /proc support). + * - isolate_root: Isolate to a single file system, error on remove on '/' (@todo 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. + * - print_first: When set, print new line to message output on program begin after loading settings. + * - print_last: When set, print new line to message output on program end. + * - 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). + * - user: Remove by UID. + * - utc: Process dates in UTC mode. + * - version: Print version. + */ +#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_created_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_print_first_e = 0x400000, + kt_remove_main_flag_print_last_e = 0x800000, + kt_remove_main_flag_prompt_all_e = 0x1000000, + kt_remove_main_flag_prompt_follow_e = 0x2000000, + kt_remove_main_flag_prompt_never_e = 0x4000000, + kt_remove_main_flag_prompt_once_e = 0x8000000, + kt_remove_main_flag_recurse_e = 0x10000000, + kt_remove_main_flag_regular_e = 0x20000000, + kt_remove_main_flag_same_e = 0x40000000, + kt_remove_main_flag_simulate_e = 0x80000000, + kt_remove_main_flag_socket_e = 0x100000000, + kt_remove_main_flag_tree_e = 0x200000000, + kt_remove_main_flag_updated_e = 0x400000000, + kt_remove_main_flag_user_e = 0x800000000, + kt_remove_main_flag_utc_e = 0x1000000000, + kt_remove_main_flag_version_e = 0x2000000000, + }; // 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 date. + * + * 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_ + +/** + * The main program parameters. + */ +#ifndef _di_kt_remove_parameter_e_ + enum { + kt_remove_parameter_help_e, + kt_remove_parameter_copyright_e, + kt_remove_parameter_light_e, + kt_remove_parameter_dark_e, + kt_remove_parameter_no_color_e, + kt_remove_parameter_verbosity_quiet_e, + kt_remove_parameter_verbosity_error_e, + kt_remove_parameter_verbosity_normal_e, + kt_remove_parameter_verbosity_verbose_e, + kt_remove_parameter_verbosity_debug_e, + kt_remove_parameter_version_e, + kt_remove_parameter_line_first_no_e, + kt_remove_parameter_line_last_no_e, + + kt_remove_parameter_accessed_e, + kt_remove_parameter_block_e, + kt_remove_parameter_character_e, + kt_remove_parameter_created_e, + kt_remove_parameter_different_e, + kt_remove_parameter_directory_e, + kt_remove_parameter_empty_e, + kt_remove_parameter_fifo_e, + kt_remove_parameter_follow_e, + kt_remove_parameter_force_e, + kt_remove_parameter_group_e, + kt_remove_parameter_isolate_e, + kt_remove_parameter_link_e, + kt_remove_parameter_local_e, + kt_remove_parameter_mode_e, + kt_remove_parameter_prompt_e, + kt_remove_parameter_recurse_e, + kt_remove_parameter_regular_e, + kt_remove_parameter_same_e, + kt_remove_parameter_simulate_e, + kt_remove_parameter_socket_e, + kt_remove_parameter_stay_e, + kt_remove_parameter_tree_e, + kt_remove_parameter_updated_e, + kt_remove_parameter_user_e, + kt_remove_parameter_utc_e, + }; // enum + + #define kt_remove_console_parameter_t_initialize \ + { \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_help_s, f_console_standard_long_help_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_light_s, f_console_standard_long_light_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_dark_s, f_console_standard_long_dark_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_error_s, f_console_standard_long_error_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_normal_s, f_console_standard_long_normal_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_debug_s, f_console_standard_long_debug_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_first_no_s, f_console_standard_long_line_first_no_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_last_no_s, f_console_standard_long_line_last_no_s, 0, f_console_flag_inverse_e), \ + \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_accessed_s, kt_remove_long_accessed_s, 2, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_block_s, kt_remove_long_block_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_character_s, kt_remove_long_character_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_created_s, kt_remove_long_created_s, 2, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_different_s, kt_remove_long_different_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_directory_s, kt_remove_long_directory_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_empty_s, kt_remove_long_empty_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_fifo_s, kt_remove_long_fifo_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_follow_s, kt_remove_long_follow_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_force_s, kt_remove_long_force_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_group_s, kt_remove_long_group_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_isolate_s, kt_remove_long_isolate_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_link_s, kt_remove_long_link_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_5( kt_remove_long_local_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_mode_s, kt_remove_long_mode_s, 2, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_prompt_s, kt_remove_long_prompt_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_recurse_s, kt_remove_long_recurse_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_regular_s, kt_remove_long_regular_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_same_s, kt_remove_long_same_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_simulate_s, kt_remove_long_simulate_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_socket_s, kt_remove_long_socket_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_stay_s, kt_remove_long_stay_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_tree_s, kt_remove_long_tree_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_updated_s, kt_remove_long_updated_s, 2, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_user_s, kt_remove_long_user_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_5( kt_remove_long_utc_s, 0, f_console_flag_normal_e), \ + } + + #define kt_remove_total_parameters_d 39 +#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 + +#endif // _kt_remove_common_enumeration_h diff --git a/sources/c/remove/main/common-print.c b/sources/c/remove/main/common/print.c similarity index 54% rename from sources/c/remove/main/common-print.c rename to sources/c/remove/main/common/print.c index 7d9a60b..54d7e31 100644 --- a/sources/c/remove/main/common-print.c +++ b/sources/c/remove/main/common/print.c @@ -1,4 +1,4 @@ -#include "remove.h" +#include "../remove.h" #ifdef __cplusplus extern "C" { @@ -7,16 +7,19 @@ extern "C" { #ifndef _di_kt_remove_f_a_ const f_string_t kt_remove_f_a[] = { "f_console_parameter_prioritize_right", + "f_console_parameter_process", "f_file_mode_from_string", "f_file_mode_to_mode", "f_string_dynamics_increase_by", "f_thread_create", - "f_utf_is_digit", "f_uint32s_increase_by", + "f_utf_is_digit", "f_utf_is_whitespace", "fl_conversion_dynamic_partial_to_unsigned_detect", "fl_conversion_dynamic_to_unsigned_detect", + "fll_program_parameter_process_context", "fll_program_parameter_process_empty", + "fll_program_parameter_process_verbosity", "kt_remove_convert_date_relative", "kt_remove_convert_timezone", "kt_remove_dates_resize", @@ -26,12 +29,6 @@ extern "C" { }; #endif // _di_kt_remove_f_a_ -#ifndef _di_kt_remove_print_reason_s_ - const f_string_static_t kt_remove_print_reason_no_access_s = macro_f_string_static_t_initialize(KT_REMOVE_print_reason_no_access_s, 0, KT_REMOVE_print_reason_no_access_s_length); - const f_string_static_t kt_remove_print_reason_not_found_s = macro_f_string_static_t_initialize(KT_REMOVE_print_reason_not_found_s, 0, KT_REMOVE_print_reason_not_found_s_length); - const f_string_static_t kt_remove_print_reason_stat_fail_s = macro_f_string_static_t_initialize(KT_REMOVE_print_reason_stat_fail_s, 0, KT_REMOVE_print_reason_stat_fail_s_length); -#endif // _di_kt_remove_date_s_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/sources/c/remove/main/common-print.h b/sources/c/remove/main/common/print.h similarity index 70% rename from sources/c/remove/main/common-print.h rename to sources/c/remove/main/common/print.h index 38ee95a..8f6c053 100644 --- a/sources/c/remove/main/common-print.h +++ b/sources/c/remove/main/common/print.h @@ -5,7 +5,7 @@ * API Version: 0.5 * Licenses: lgpl-2.1-or-later * - * Provides the common data structures. + * Provides the common print functionality. * * This is auto-included and should not need to be explicitly included. */ @@ -40,6 +40,7 @@ extern "C" { #ifndef _di_kt_remove_f_e_ enum { kt_remove_f_f_console_parameter_prioritize_right_e, + kt_remove_f_f_console_parameter_process_e, kt_remove_f_f_file_mode_from_string_e, kt_remove_f_f_file_mode_to_mode_e, kt_remove_f_f_string_dynamics_increase_by_e, @@ -49,7 +50,9 @@ extern "C" { kt_remove_f_f_utf_is_whitespace_e, kt_remove_f_fl_conversion_dynamic_partial_to_unsigned_detect_e, kt_remove_f_fl_conversion_dynamic_to_unsigned_detect_e, + kt_remove_f_fll_program_parameter_process_context_e, kt_remove_f_fll_program_parameter_process_empty_e, + kt_remove_f_fll_program_parameter_process_verbosity_e, kt_remove_f_kt_remove_convert_date_relative_e, kt_remove_f_kt_remove_convert_timezone_e, kt_remove_f_kt_remove_dates_resize_e, @@ -59,23 +62,6 @@ extern "C" { }; // enum #endif // _di_kt_remove_f_e_ -/** - * Strings used printing the reason why a removal failed. - */ -#ifndef _di_kt_remove_print_reason_s_ - #define KT_REMOVE_print_reason_no_access_s "file be accessed" - #define KT_REMOVE_print_reason_not_found_s "file cannot be found" - #define KT_REMOVE_print_reason_stat_fail_s "cannot read file statistics" - - #define KT_REMOVE_print_reason_no_access_s_length 16 - #define KT_REMOVE_print_reason_not_found_s_length 20 - #define KT_REMOVE_print_reason_stat_fail_s_length 27 - - extern const f_string_static_t kt_remove_print_reason_no_access_s; - extern const f_string_static_t kt_remove_print_reason_not_found_s; - extern const f_string_static_t kt_remove_print_reason_stat_fail_s; -#endif // _di_kt_remove_print_reason_s_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/sources/c/remove/main/common/string.c b/sources/c/remove/main/common/string.c new file mode 100644 index 0000000..1abf0e8 --- /dev/null +++ b/sources/c/remove/main/common/string.c @@ -0,0 +1,163 @@ +#include "../remove.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_kt_remove_program_version_s_ + const f_string_static_t kt_remove_program_version_s = macro_f_string_static_t_initialize(KT_REMOVE_program_version_s, 0, KT_REMOVE_program_version_s_length); +#endif // _di_kt_remove_program_version_s_ + +#ifndef _di_kt_remove_program_name_s_ + const f_string_static_t kt_remove_program_name_s = macro_f_string_static_t_initialize(KT_REMOVE_program_name_s, 0, KT_REMOVE_program_name_s_length); + const f_string_static_t kt_remove_program_name_long_s = macro_f_string_static_t_initialize(KT_REMOVE_program_name_long_s, 0, KT_REMOVE_program_name_long_s_length); +#endif // _di_kt_remove_program_name_s_ + +#ifndef kt_remove_program_help_parameters_s_ + const f_string_static_t kt_remove_program_help_parameters_s = macro_f_string_static_t_initialize(KT_REMOVE_program_help_parameters_s, 0, KT_REMOVE_program_help_parameters_s_length); +#endif // _di_utf8_program_help_parameters_s_ + +#ifndef _di_kt_remove_s_ + const f_string_static_t kt_remove_all_s = macro_f_string_static_t_initialize(KT_REMOVE_all_s, 0, KT_REMOVE_all_s_length); + const f_string_static_t kt_remove_follow_s = macro_f_string_static_t_initialize(KT_REMOVE_follow_s, 0, KT_REMOVE_follow_s_length); + const f_string_static_t kt_remove_force_s = macro_f_string_static_t_initialize(KT_REMOVE_force_s, 0, KT_REMOVE_force_s_length); + const f_string_static_t kt_remove_ignore_s = macro_f_string_static_t_initialize(KT_REMOVE_ignore_s, 0, KT_REMOVE_ignore_s_length); + const f_string_static_t kt_remove_never_s = macro_f_string_static_t_initialize(KT_REMOVE_never_s, 0, KT_REMOVE_never_s_length); + const f_string_static_t kt_remove_no_s = macro_f_string_static_t_initialize(KT_REMOVE_no_s, 0, KT_REMOVE_no_s_length); + const f_string_static_t kt_remove_not_s = macro_f_string_static_t_initialize(KT_REMOVE_not_s, 0, KT_REMOVE_not_s_length); + const f_string_static_t kt_remove_not_fail_s = macro_f_string_static_t_initialize(KT_REMOVE_not_fail_s, 0, KT_REMOVE_not_fail_s_length); + const f_string_static_t kt_remove_now_s = macro_f_string_static_t_initialize(KT_REMOVE_now_s, 0, KT_REMOVE_now_s_length); + const f_string_static_t kt_remove_once_s = macro_f_string_static_t_initialize(KT_REMOVE_once_s, 0, KT_REMOVE_once_s_length); + const f_string_static_t kt_remove_only_s = macro_f_string_static_t_initialize(KT_REMOVE_only_s, 0, KT_REMOVE_only_s_length); + const f_string_static_t kt_remove_only_fail_s = macro_f_string_static_t_initialize(KT_REMOVE_only_fail_s, 0, KT_REMOVE_only_fail_s_length); + const f_string_static_t kt_remove_remove_s = macro_f_string_static_t_initialize(KT_REMOVE_remove_s, 0, KT_REMOVE_remove_s_length); + const f_string_static_t kt_remove_root_s = macro_f_string_static_t_initialize(KT_REMOVE_root_s, 0, KT_REMOVE_root_s_length); + const f_string_static_t kt_remove_today_s = macro_f_string_static_t_initialize(KT_REMOVE_today_s, 0, KT_REMOVE_today_s_length); + const f_string_static_t kt_remove_tomorrow_s = macro_f_string_static_t_initialize(KT_REMOVE_tomorrow_s, 0, KT_REMOVE_tomorrow_s_length); + const f_string_static_t kt_remove_yes_s = macro_f_string_static_t_initialize(KT_REMOVE_yes_s, 0, KT_REMOVE_yes_s_length); + const f_string_static_t kt_remove_yesterday_s = macro_f_string_static_t_initialize(KT_REMOVE_yesterday_s, 0, KT_REMOVE_yesterday_s_length); +#endif // _di_kt_remove_s_ + +#ifndef _di_kt_remove_date_s_ + const f_string_static_t kt_remove_date_format_00_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_00_s, 0, KT_REMOVE_date_format_00_s_length); + const f_string_static_t kt_remove_date_format_01_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_01_s, 0, KT_REMOVE_date_format_01_s_length); + const f_string_static_t kt_remove_date_format_02_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_02_s, 0, KT_REMOVE_date_format_02_s_length); + const f_string_static_t kt_remove_date_format_03_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_03_s, 0, KT_REMOVE_date_format_03_s_length); + const f_string_static_t kt_remove_date_format_04_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_04_s, 0, KT_REMOVE_date_format_04_s_length); + const f_string_static_t kt_remove_date_format_05_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_05_s, 0, KT_REMOVE_date_format_05_s_length); + const f_string_static_t kt_remove_date_format_06_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_06_s, 0, KT_REMOVE_date_format_06_s_length); + const f_string_static_t kt_remove_date_format_07_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_07_s, 0, KT_REMOVE_date_format_07_s_length); + const f_string_static_t kt_remove_date_format_08_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_08_s, 0, KT_REMOVE_date_format_08_s_length); + const f_string_static_t kt_remove_date_format_09_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_09_s, 0, KT_REMOVE_date_format_09_s_length); + const f_string_static_t kt_remove_date_format_10_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_10_s, 0, KT_REMOVE_date_format_10_s_length); + const f_string_static_t kt_remove_date_format_11_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_11_s, 0, KT_REMOVE_date_format_11_s_length); + const f_string_static_t kt_remove_date_format_12_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_12_s, 0, KT_REMOVE_date_format_12_s_length); + const f_string_static_t kt_remove_date_format_13_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_13_s, 0, KT_REMOVE_date_format_13_s_length); + const f_string_static_t kt_remove_date_format_14_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_14_s, 0, KT_REMOVE_date_format_14_s_length); + + const f_string_static_t kt_remove_date_format_example_00_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_00_s, 0, KT_REMOVE_date_format_example_00_s_length); + const f_string_static_t kt_remove_date_format_example_01_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_01_s, 0, KT_REMOVE_date_format_example_01_s_length); + const f_string_static_t kt_remove_date_format_example_02_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_02_s, 0, KT_REMOVE_date_format_example_02_s_length); + const f_string_static_t kt_remove_date_format_example_03_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_03_s, 0, KT_REMOVE_date_format_example_03_s_length); + const f_string_static_t kt_remove_date_format_example_04_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_04_s, 0, KT_REMOVE_date_format_example_04_s_length); + const f_string_static_t kt_remove_date_format_example_05_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_05_s, 0, KT_REMOVE_date_format_example_05_s_length); + const f_string_static_t kt_remove_date_format_example_06_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_06_s, 0, KT_REMOVE_date_format_example_06_s_length); + const f_string_static_t kt_remove_date_format_example_07_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_07_s, 0, KT_REMOVE_date_format_example_07_s_length); + const f_string_static_t kt_remove_date_format_example_08_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_08_s, 0, KT_REMOVE_date_format_example_08_s_length); + const f_string_static_t kt_remove_date_format_example_09_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_09_s, 0, KT_REMOVE_date_format_example_09_s_length); + const f_string_static_t kt_remove_date_format_example_10_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_10_s, 0, KT_REMOVE_date_format_example_10_s_length); + const f_string_static_t kt_remove_date_format_example_11_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_11_s, 0, KT_REMOVE_date_format_example_11_s_length); + const f_string_static_t kt_remove_date_format_example_12_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_12_s, 0, KT_REMOVE_date_format_example_12_s_length); + const f_string_static_t kt_remove_date_format_example_13_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_13_s, 0, KT_REMOVE_date_format_example_13_s_length); + const f_string_static_t kt_remove_date_format_example_14_s = macro_f_string_static_t_initialize(KT_REMOVE_date_format_example_14_s, 0, KT_REMOVE_date_format_example_14_s_length); + + const f_string_static_t kt_remove_date_symbol_equal_s = macro_f_string_static_t_initialize(KT_REMOVE_date_symbol_equal_s, 0, KT_REMOVE_date_symbol_equal_s_length); + const f_string_static_t kt_remove_date_symbol_less_s = macro_f_string_static_t_initialize(KT_REMOVE_date_symbol_less_s, 0, KT_REMOVE_date_symbol_less_s_length); + const f_string_static_t kt_remove_date_symbol_less_equal_s = macro_f_string_static_t_initialize(KT_REMOVE_date_symbol_less_equal_s, 0, KT_REMOVE_date_symbol_less_equal_s_length); + const f_string_static_t kt_remove_date_symbol_more_s = macro_f_string_static_t_initialize(KT_REMOVE_date_symbol_more_s, 0, KT_REMOVE_date_symbol_more_s_length); + const f_string_static_t kt_remove_date_symbol_more_equal_s = macro_f_string_static_t_initialize(KT_REMOVE_date_symbol_more_equal_s, 0, KT_REMOVE_date_symbol_more_equal_s_length); + const f_string_static_t kt_remove_date_symbol_not_s = macro_f_string_static_t_initialize(KT_REMOVE_date_symbol_not_s, 0, KT_REMOVE_date_symbol_not_s_length); + + const f_string_static_t kt_remove_date_word_equal_s = macro_f_string_static_t_initialize(KT_REMOVE_date_word_equal_s, 0, KT_REMOVE_date_word_equal_s_length); + const f_string_static_t kt_remove_date_word_less_s = macro_f_string_static_t_initialize(KT_REMOVE_date_word_less_s, 0, KT_REMOVE_date_word_less_s_length); + const f_string_static_t kt_remove_date_word_less_equal_s = macro_f_string_static_t_initialize(KT_REMOVE_date_word_less_equal_s, 0, KT_REMOVE_date_word_less_equal_s_length); + const f_string_static_t kt_remove_date_word_more_s = macro_f_string_static_t_initialize(KT_REMOVE_date_word_more_s, 0, KT_REMOVE_date_word_more_s_length); + const f_string_static_t kt_remove_date_word_more_equal_s = macro_f_string_static_t_initialize(KT_REMOVE_date_word_more_equal_s, 0, KT_REMOVE_date_word_more_equal_s_length); + const f_string_static_t kt_remove_date_word_not_s = macro_f_string_static_t_initialize(KT_REMOVE_date_word_not_s, 0, KT_REMOVE_date_word_not_s_length); +#endif // _di_kt_remove_date_s_ + +#ifndef _di_kt_remove_mode_s_ + const f_string_static_t kt_remove_mode_symbol_different_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_symbol_different_s, 0, KT_REMOVE_mode_symbol_different_s_length); + const f_string_static_t kt_remove_mode_symbol_same_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_symbol_same_s, 0, KT_REMOVE_mode_symbol_same_s_length); + const f_string_static_t kt_remove_mode_symbol_similar_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_symbol_similar_s, 0, KT_REMOVE_mode_symbol_similar_s_length); + const f_string_static_t kt_remove_mode_symbol_not_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_symbol_not_s, 0, KT_REMOVE_mode_symbol_not_s_length); + + const f_string_static_t kt_remove_mode_word_different_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_word_different_s, 0, KT_REMOVE_mode_word_different_s_length); + const f_string_static_t kt_remove_mode_word_same_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_word_same_s, 0, KT_REMOVE_mode_word_same_s_length); + const f_string_static_t kt_remove_mode_word_similar_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_word_similar_s, 0, KT_REMOVE_mode_word_similar_s_length); + const f_string_static_t kt_remove_mode_word_not_s = macro_f_string_static_t_initialize(KT_REMOVE_mode_word_not_s, 0, KT_REMOVE_mode_word_not_s_length); +#endif // _di_kt_remove_mode_s_ + +#ifndef _di_kt_remove_parameter_s_ + const f_string_static_t kt_remove_short_accessed_s = macro_f_string_static_t_initialize(KT_REMOVE_short_accessed_s, 0, KT_REMOVE_short_accessed_s_length); + const f_string_static_t kt_remove_short_block_s = macro_f_string_static_t_initialize(KT_REMOVE_short_block_s, 0, KT_REMOVE_short_block_s_length); + const f_string_static_t kt_remove_short_character_s = macro_f_string_static_t_initialize(KT_REMOVE_short_character_s, 0, KT_REMOVE_short_character_s_length); + const f_string_static_t kt_remove_short_created_s = macro_f_string_static_t_initialize(KT_REMOVE_short_created_s, 0, KT_REMOVE_short_created_s_length); + const f_string_static_t kt_remove_short_different_s = macro_f_string_static_t_initialize(KT_REMOVE_short_different_s, 0, KT_REMOVE_short_different_s_length); + const f_string_static_t kt_remove_short_directory_s = macro_f_string_static_t_initialize(KT_REMOVE_short_directory_s, 0, KT_REMOVE_short_directory_s_length); + const f_string_static_t kt_remove_short_empty_s = macro_f_string_static_t_initialize(KT_REMOVE_short_empty_s, 0, KT_REMOVE_short_empty_s_length); + const f_string_static_t kt_remove_short_fifo_s = macro_f_string_static_t_initialize(KT_REMOVE_short_fifo_s, 0, KT_REMOVE_short_fifo_s_length); + const f_string_static_t kt_remove_short_follow_s = macro_f_string_static_t_initialize(KT_REMOVE_short_follow_s, 0, KT_REMOVE_short_follow_s_length); + const f_string_static_t kt_remove_short_force_s = macro_f_string_static_t_initialize(KT_REMOVE_short_force_s, 0, KT_REMOVE_short_force_s_length); + const f_string_static_t kt_remove_short_group_s = macro_f_string_static_t_initialize(KT_REMOVE_short_group_s, 0, KT_REMOVE_short_group_s_length); + const f_string_static_t kt_remove_short_isolate_s = macro_f_string_static_t_initialize(KT_REMOVE_short_isolate_s, 0, KT_REMOVE_short_isolate_s_length); + const f_string_static_t kt_remove_short_link_s = macro_f_string_static_t_initialize(KT_REMOVE_short_link_s, 0, KT_REMOVE_short_link_s_length); + const f_string_static_t kt_remove_short_mode_s = macro_f_string_static_t_initialize(KT_REMOVE_short_mode_s, 0, KT_REMOVE_short_mode_s_length); + const f_string_static_t kt_remove_short_prompt_s = macro_f_string_static_t_initialize(KT_REMOVE_short_prompt_s, 0, KT_REMOVE_short_prompt_s_length); + const f_string_static_t kt_remove_short_recurse_s = macro_f_string_static_t_initialize(KT_REMOVE_short_recurse_s, 0, KT_REMOVE_short_recurse_s_length); + const f_string_static_t kt_remove_short_regular_s = macro_f_string_static_t_initialize(KT_REMOVE_short_regular_s, 0, KT_REMOVE_short_regular_s_length); + const f_string_static_t kt_remove_short_same_s = macro_f_string_static_t_initialize(KT_REMOVE_short_same_s, 0, KT_REMOVE_short_same_s_length); + const f_string_static_t kt_remove_short_simulate_s = macro_f_string_static_t_initialize(KT_REMOVE_short_simulate_s, 0, KT_REMOVE_short_simulate_s_length); + const f_string_static_t kt_remove_short_socket_s = macro_f_string_static_t_initialize(KT_REMOVE_short_socket_s, 0, KT_REMOVE_short_socket_s_length); + const f_string_static_t kt_remove_short_stay_s = macro_f_string_static_t_initialize(KT_REMOVE_short_stay_s, 0, KT_REMOVE_short_stay_s_length); + const f_string_static_t kt_remove_short_tree_s = macro_f_string_static_t_initialize(KT_REMOVE_short_tree_s, 0, KT_REMOVE_short_tree_s_length); + const f_string_static_t kt_remove_short_updated_s = macro_f_string_static_t_initialize(KT_REMOVE_short_updated_s, 0, KT_REMOVE_short_updated_s_length); + const f_string_static_t kt_remove_short_user_s = macro_f_string_static_t_initialize(KT_REMOVE_short_user_s, 0, KT_REMOVE_short_user_s_length); + + const f_string_static_t kt_remove_long_accessed_s = macro_f_string_static_t_initialize(KT_REMOVE_long_accessed_s, 0, KT_REMOVE_long_accessed_s_length); + const f_string_static_t kt_remove_long_block_s = macro_f_string_static_t_initialize(KT_REMOVE_long_block_s, 0, KT_REMOVE_long_block_s_length); + const f_string_static_t kt_remove_long_character_s = macro_f_string_static_t_initialize(KT_REMOVE_long_character_s, 0, KT_REMOVE_long_character_s_length); + const f_string_static_t kt_remove_long_created_s = macro_f_string_static_t_initialize(KT_REMOVE_long_created_s, 0, KT_REMOVE_long_created_s_length); + const f_string_static_t kt_remove_long_different_s = macro_f_string_static_t_initialize(KT_REMOVE_long_different_s, 0, KT_REMOVE_long_different_s_length); + const f_string_static_t kt_remove_long_directory_s = macro_f_string_static_t_initialize(KT_REMOVE_long_directory_s, 0, KT_REMOVE_long_directory_s_length); + const f_string_static_t kt_remove_long_empty_s = macro_f_string_static_t_initialize(KT_REMOVE_long_empty_s, 0, KT_REMOVE_long_empty_s_length); + const f_string_static_t kt_remove_long_fifo_s = macro_f_string_static_t_initialize(KT_REMOVE_long_fifo_s, 0, KT_REMOVE_long_fifo_s_length); + const f_string_static_t kt_remove_long_follow_s = macro_f_string_static_t_initialize(KT_REMOVE_long_follow_s, 0, KT_REMOVE_long_follow_s_length); + const f_string_static_t kt_remove_long_force_s = macro_f_string_static_t_initialize(KT_REMOVE_long_force_s, 0, KT_REMOVE_long_force_s_length); + const f_string_static_t kt_remove_long_group_s = macro_f_string_static_t_initialize(KT_REMOVE_long_group_s, 0, KT_REMOVE_long_group_s_length); + const f_string_static_t kt_remove_long_isolate_s = macro_f_string_static_t_initialize(KT_REMOVE_long_isolate_s, 0, KT_REMOVE_long_isolate_s_length); + const f_string_static_t kt_remove_long_link_s = macro_f_string_static_t_initialize(KT_REMOVE_long_link_s, 0, KT_REMOVE_long_link_s_length); + const f_string_static_t kt_remove_long_local_s = macro_f_string_static_t_initialize(KT_REMOVE_long_local_s, 0, KT_REMOVE_long_local_s_length); + const f_string_static_t kt_remove_long_mode_s = macro_f_string_static_t_initialize(KT_REMOVE_long_mode_s, 0, KT_REMOVE_long_mode_s_length); + const f_string_static_t kt_remove_long_prompt_s = macro_f_string_static_t_initialize(KT_REMOVE_long_prompt_s, 0, KT_REMOVE_long_prompt_s_length); + const f_string_static_t kt_remove_long_recurse_s = macro_f_string_static_t_initialize(KT_REMOVE_long_recurse_s, 0, KT_REMOVE_long_recurse_s_length); + const f_string_static_t kt_remove_long_regular_s = macro_f_string_static_t_initialize(KT_REMOVE_long_regular_s, 0, KT_REMOVE_long_regular_s_length); + const f_string_static_t kt_remove_long_same_s = macro_f_string_static_t_initialize(KT_REMOVE_long_same_s, 0, KT_REMOVE_long_same_s_length); + const f_string_static_t kt_remove_long_simulate_s = macro_f_string_static_t_initialize(KT_REMOVE_long_simulate_s, 0, KT_REMOVE_long_simulate_s_length); + const f_string_static_t kt_remove_long_socket_s = macro_f_string_static_t_initialize(KT_REMOVE_long_socket_s, 0, KT_REMOVE_long_socket_s_length); + const f_string_static_t kt_remove_long_stay_s = macro_f_string_static_t_initialize(KT_REMOVE_long_stay_s, 0, KT_REMOVE_long_stay_s_length); + const f_string_static_t kt_remove_long_tree_s = macro_f_string_static_t_initialize(KT_REMOVE_long_tree_s, 0, KT_REMOVE_long_tree_s_length); + const f_string_static_t kt_remove_long_updated_s = macro_f_string_static_t_initialize(KT_REMOVE_long_updated_s, 0, KT_REMOVE_long_updated_s_length); + const f_string_static_t kt_remove_long_user_s = macro_f_string_static_t_initialize(KT_REMOVE_long_user_s, 0, KT_REMOVE_long_user_s_length); + const f_string_static_t kt_remove_long_utc_s = macro_f_string_static_t_initialize(KT_REMOVE_long_utc_s, 0, KT_REMOVE_long_utc_s_length); +#endif // _di_kt_remove_parameter_s_ + +#ifndef _di_kt_remove_print_reason_s_ + const f_string_static_t kt_remove_print_reason_no_access_s = macro_f_string_static_t_initialize(KT_REMOVE_print_reason_no_access_s, 0, KT_REMOVE_print_reason_no_access_s_length); + const f_string_static_t kt_remove_print_reason_not_found_s = macro_f_string_static_t_initialize(KT_REMOVE_print_reason_not_found_s, 0, KT_REMOVE_print_reason_not_found_s_length); + const f_string_static_t kt_remove_print_reason_stat_fail_s = macro_f_string_static_t_initialize(KT_REMOVE_print_reason_stat_fail_s, 0, KT_REMOVE_print_reason_stat_fail_s_length); +#endif // _di_kt_remove_print_reason_s_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/remove/main/common/string.h b/sources/c/remove/main/common/string.h new file mode 100644 index 0000000..275e590 --- /dev/null +++ b/sources/c/remove/main/common/string.h @@ -0,0 +1,541 @@ +/** + * Kevux Tools - Remove + * + * Project: Kevux Tools + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Provides the common string structures. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _kt_remove_common_string_h +#define _kt_remove_common_string_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The program version. + */ +#ifndef _di_kt_remove_program_version_s_ + #define KT_REMOVE_program_version_major_s F_string_ascii_0_s + #define KT_REMOVE_program_version_minor_s F_string_ascii_5_s + #define KT_REMOVE_program_version_micro_s F_string_ascii_0_s + + #define KT_REMOVE_program_version_major_s_length F_string_ascii_0_s_length + #define KT_REMOVE_program_version_minor_s_length F_string_ascii_5_s_length + #define KT_REMOVE_program_version_micro_s_length F_string_ascii_0_s_length + + #if !(defined(KT_REMOVE_program_version_nano_prefix_s) && defined(KT_REMOVE_program_version_nano_prefix_s_length)) + #define KT_REMOVE_program_version_nano_prefix_s + #define KT_REMOVE_program_version_nano_prefix_s_length 0 + #endif // !(defined(KT_REMOVE_program_version_nano_prefix_s) && defined(KT_REMOVE_program_version_nano_prefix_s_length)) + + #if !(defined(KT_REMOVE_program_version_nano_s) && defined(KT_REMOVE_program_version_nano_s_length)) + #define KT_REMOVE_program_version_nano_s + #define KT_REMOVE_program_version_nano_s_length 0 + #endif // !(defined(KT_REMOVE_program_version_nano_s) && defined(KT_REMOVE_program_version_nano_s_length)) + + #define KT_REMOVE_program_version_s KT_REMOVE_program_version_major_s F_string_ascii_period_s KT_REMOVE_program_version_minor_s F_string_ascii_period_s KT_REMOVE_program_version_micro_s KT_REMOVE_program_version_nano_prefix_s KT_REMOVE_program_version_nano_s + + #define KT_REMOVE_program_version_s_length KT_REMOVE_program_version_major_s_length + F_string_ascii_period_s_length + KT_REMOVE_program_version_minor_s_length + F_string_ascii_period_s_length + KT_REMOVE_program_version_micro_s_length + KT_REMOVE_program_version_nano_prefix_s_length + KT_REMOVE_program_version_nano_s_length + + extern const f_string_static_t kt_remove_program_version_s; +#endif // _di_kt_remove_program_version_s_ + +/** + * The program name. + */ +#ifndef _di_kt_remove_program_name_s_ + #define KT_REMOVE_program_name_s "remove" + #define KT_REMOVE_program_name_long_s "Remove" + + #define KT_REMOVE_program_name_s_length 6 + #define KT_REMOVE_program_name_long_s_length 6 + + extern const f_string_static_t kt_remove_program_name_s; + extern const f_string_static_t kt_remove_program_name_long_s; +#endif // _di_kt_remove_program_name_s_ + +/** + * The program help related data. + */ +#ifndef kt_remove_program_help_parameters_s_ + #define KT_REMOVE_program_help_parameters_s "file(s)" + #define KT_REMOVE_program_help_parameters_s_length 7 + + extern const f_string_static_t kt_remove_program_help_parameters_s; +#endif // _di_utf8_program_help_parameters_s_ + +/** + * Additional strings used for various purposes. + * + * kt_remove_*_s: Arbitrary strings. + */ +#ifndef _di_kt_remove_s_ + #define KT_REMOVE_all_s "all" + #define KT_REMOVE_follow_s "follow" + #define KT_REMOVE_force_s "force" + #define KT_REMOVE_ignore_s "ignore" + #define KT_REMOVE_never_s "never" + #define KT_REMOVE_no_s "no" + #define KT_REMOVE_not_s "not" + #define KT_REMOVE_not_fail_s "not_fail" + #define KT_REMOVE_now_s "now" + #define KT_REMOVE_once_s "once" + #define KT_REMOVE_only_s "only" + #define KT_REMOVE_only_fail_s "only_fail" + #define KT_REMOVE_remove_s "remove" + #define KT_REMOVE_root_s "root" + #define KT_REMOVE_today_s "today" + #define KT_REMOVE_tomorrow_s "tomorrow" + #define KT_REMOVE_yes_s "yes" + #define KT_REMOVE_yesterday_s "yesterday" + + #define KT_REMOVE_all_s_length 3 + #define KT_REMOVE_follow_s_length 6 + #define KT_REMOVE_force_s_length 5 + #define KT_REMOVE_ignore_s_length 6 + #define KT_REMOVE_never_s_length 5 + #define KT_REMOVE_no_s_length 2 + #define KT_REMOVE_not_s_length 3 + #define KT_REMOVE_not_fail_s_length 8 + #define KT_REMOVE_now_s_length 3 + #define KT_REMOVE_once_s_length 4 + #define KT_REMOVE_only_s_length 4 + #define KT_REMOVE_only_fail_s_length 9 + #define KT_REMOVE_remove_s_length 6 + #define KT_REMOVE_root_s_length 4 + #define KT_REMOVE_today_s_length 5 + #define KT_REMOVE_tomorrow_s_length 8 + #define KT_REMOVE_yes_s_length 3 + #define KT_REMOVE_yesterday_s_length 9 + + extern const f_string_static_t kt_remove_all_s; + extern const f_string_static_t kt_remove_follow_s; + extern const f_string_static_t kt_remove_force_s; + extern const f_string_static_t kt_remove_ignore_s; + extern const f_string_static_t kt_remove_never_s; + extern const f_string_static_t kt_remove_no_s; + extern const f_string_static_t kt_remove_not_s; + extern const f_string_static_t kt_remove_not_fail_s; + extern const f_string_static_t kt_remove_now_s; + extern const f_string_static_t kt_remove_once_s; + extern const f_string_static_t kt_remove_only_s; + extern const f_string_static_t kt_remove_only_fail_s; + extern const f_string_static_t kt_remove_remove_s; + extern const f_string_static_t kt_remove_root_s; + extern const f_string_static_t kt_remove_today_s; + extern const f_string_static_t kt_remove_tomorrow_s; + extern const f_string_static_t kt_remove_yes_s; + extern const f_string_static_t kt_remove_yesterday_s; +#endif // _di_kt_remove_s_ + +/** + * Strings associated with the date parameters. + * + * kt_remove_date_format_*_s: + * - 00: The string "YYYY/MM/DD hh:ii:ss a +0000". + * - 01: The string "YYYY/MM/DD HH:ii:ss +0000". + * - 02: The string "YYYY/MM/DD hh:ii a +0000". + * - 03: The string "YYYY/MM/DD HH:ii +0000". + * - 04: The string "YYYY/MM/DD hh a +0000". + * - 05: The string "YYYY/MM/DD HH +0000". + * - 06: The string "YYYY/MM/DD hh:ii:ss a". + * - 07: The string "YYYY/MM/DD HH:ii:ss". + * - 08: The string "YYYY/MM/DD hh:ii a". + * - 09: The string "YYYY/MM/DD HH:ii". + * - 10: The string "YYYY/MM/DD hh a". + * - 11: The string "YYYY/MM/DD HH". + * - 12: The string "YYYY/MM/DD". + * - 13: The string "YYYY/MM". + * - 14: The string "YYYY/". + * + * kt_remove_date_symbol_*_s: + * - equal: Equal to operator. + * - less: Less than operator. + * - less_equal: Less than or equal to operator. + * - more: Greater than operator. + * - more_equal: Greater than or equal to operator. + * - not: Not equal to operator. + * + * kt_remove_date_word_*_s: + * - equal: Equal to words. + * - less: Less than words. + * - less_equal: Less than or equal to words. + * - more: Greater than words. + * - more_equal: Greater than or equal to words. + * - not: Not equal to words. + */ +#ifndef _di_kt_remove_date_s_ + #define KT_REMOVE_date_format_00_s "%Y/%m/%d %I:%M:%S %p %z" + #define KT_REMOVE_date_format_01_s "%Y/%m/%d %H:%M:%S %z" + #define KT_REMOVE_date_format_02_s "%Y/%m/%d %I:%M %p %z" + #define KT_REMOVE_date_format_03_s "%Y/%m/%d %H:%M %z" + #define KT_REMOVE_date_format_04_s "%Y/%m/%d %I %p %z" + #define KT_REMOVE_date_format_05_s "%Y/%m/%d %H %z" + #define KT_REMOVE_date_format_06_s "%Y/%m/%d %I:%M:%S %p" + #define KT_REMOVE_date_format_07_s "%Y/%m/%d %H:%M:%S" + #define KT_REMOVE_date_format_08_s "%Y/%m/%d %I:%M %p" + #define KT_REMOVE_date_format_09_s "%Y/%m/%d %H:%M" + #define KT_REMOVE_date_format_10_s "%Y/%m/%d %I %p" + #define KT_REMOVE_date_format_11_s "%Y/%m/%d %H" + #define KT_REMOVE_date_format_12_s "%Y/%m/%d" + #define KT_REMOVE_date_format_13_s "%Y/%m" + #define KT_REMOVE_date_format_14_s "%Y/" + + #define KT_REMOVE_date_format_00_s_length 23 + #define KT_REMOVE_date_format_01_s_length 20 + #define KT_REMOVE_date_format_02_s_length 20 + #define KT_REMOVE_date_format_03_s_length 17 + #define KT_REMOVE_date_format_04_s_length 17 + #define KT_REMOVE_date_format_05_s_length 14 + #define KT_REMOVE_date_format_06_s_length 20 + #define KT_REMOVE_date_format_07_s_length 17 + #define KT_REMOVE_date_format_08_s_length 17 + #define KT_REMOVE_date_format_09_s_length 14 + #define KT_REMOVE_date_format_10_s_length 14 + #define KT_REMOVE_date_format_11_s_length 11 + #define KT_REMOVE_date_format_12_s_length 8 + #define KT_REMOVE_date_format_13_s_length 5 + #define KT_REMOVE_date_format_14_s_length 3 + + extern const f_string_static_t kt_remove_date_format_00_s; + extern const f_string_static_t kt_remove_date_format_01_s; + extern const f_string_static_t kt_remove_date_format_02_s; + extern const f_string_static_t kt_remove_date_format_03_s; + extern const f_string_static_t kt_remove_date_format_04_s; + extern const f_string_static_t kt_remove_date_format_05_s; + extern const f_string_static_t kt_remove_date_format_06_s; + extern const f_string_static_t kt_remove_date_format_07_s; + extern const f_string_static_t kt_remove_date_format_08_s; + extern const f_string_static_t kt_remove_date_format_09_s; + extern const f_string_static_t kt_remove_date_format_10_s; + extern const f_string_static_t kt_remove_date_format_11_s; + extern const f_string_static_t kt_remove_date_format_12_s; + extern const f_string_static_t kt_remove_date_format_13_s; + extern const f_string_static_t kt_remove_date_format_14_s; + + #define KT_REMOVE_date_format_example_00_s "2022/12/30 1:45:02 pm +0600" + #define KT_REMOVE_date_format_example_01_s "2022/12/30 13:45:02 +0600" + #define KT_REMOVE_date_format_example_02_s "2022/12/30 1:45 pm +0600" + #define KT_REMOVE_date_format_example_03_s "2022/12/30 13:45 +0600" + #define KT_REMOVE_date_format_example_04_s "2022/12/30 1 pm +0600" + #define KT_REMOVE_date_format_example_05_s "2022/12/30 13 +0600" + #define KT_REMOVE_date_format_example_06_s "2022/12/30 1:45:02 pm" + #define KT_REMOVE_date_format_example_07_s "2022/12/30 13:45:02" + #define KT_REMOVE_date_format_example_08_s "2022/12/30 1:45 pm" + #define KT_REMOVE_date_format_example_09_s "2022/12/30 13:45" + #define KT_REMOVE_date_format_example_10_s "2022/12/30 1 pm" + #define KT_REMOVE_date_format_example_11_s "2022/12/30 13" + #define KT_REMOVE_date_format_example_12_s "2022/12/30" + #define KT_REMOVE_date_format_example_13_s "2022/12" + #define KT_REMOVE_date_format_example_14_s "2022/" + + #define KT_REMOVE_date_format_example_00_s_length 27 + #define KT_REMOVE_date_format_example_01_s_length 25 + #define KT_REMOVE_date_format_example_02_s_length 24 + #define KT_REMOVE_date_format_example_03_s_length 22 + #define KT_REMOVE_date_format_example_04_s_length 21 + #define KT_REMOVE_date_format_example_05_s_length 19 + #define KT_REMOVE_date_format_example_06_s_length 21 + #define KT_REMOVE_date_format_example_07_s_length 19 + #define KT_REMOVE_date_format_example_08_s_length 18 + #define KT_REMOVE_date_format_example_09_s_length 16 + #define KT_REMOVE_date_format_example_10_s_length 15 + #define KT_REMOVE_date_format_example_11_s_length 13 + #define KT_REMOVE_date_format_example_12_s_length 10 + #define KT_REMOVE_date_format_example_13_s_length 9 + #define KT_REMOVE_date_format_example_14_s_length 5 + + extern const f_string_static_t kt_remove_date_format_example_00_s; + extern const f_string_static_t kt_remove_date_format_example_01_s; + extern const f_string_static_t kt_remove_date_format_example_02_s; + extern const f_string_static_t kt_remove_date_format_example_03_s; + extern const f_string_static_t kt_remove_date_format_example_04_s; + extern const f_string_static_t kt_remove_date_format_example_05_s; + extern const f_string_static_t kt_remove_date_format_example_06_s; + extern const f_string_static_t kt_remove_date_format_example_07_s; + extern const f_string_static_t kt_remove_date_format_example_08_s; + extern const f_string_static_t kt_remove_date_format_example_09_s; + extern const f_string_static_t kt_remove_date_format_example_10_s; + extern const f_string_static_t kt_remove_date_format_example_11_s; + extern const f_string_static_t kt_remove_date_format_example_12_s; + extern const f_string_static_t kt_remove_date_format_example_13_s; + extern const f_string_static_t kt_remove_date_format_example_14_s; + + #define KT_REMOVE_date_symbol_equal_s "==" + #define KT_REMOVE_date_symbol_less_s "<" + #define KT_REMOVE_date_symbol_less_equal_s "<=" + #define KT_REMOVE_date_symbol_more_s ">" + #define KT_REMOVE_date_symbol_more_equal_s ">=" + #define KT_REMOVE_date_symbol_not_s "<>" + + #define KT_REMOVE_date_symbol_equal_s_length 2 + #define KT_REMOVE_date_symbol_less_s_length 1 + #define KT_REMOVE_date_symbol_less_equal_s_length 2 + #define KT_REMOVE_date_symbol_more_s_length 1 + #define KT_REMOVE_date_symbol_more_equal_s_length 2 + #define KT_REMOVE_date_symbol_not_s_length 2 + + extern const f_string_static_t kt_remove_date_symbol_equal_s; + extern const f_string_static_t kt_remove_date_symbol_less_s; + extern const f_string_static_t kt_remove_date_symbol_less_equal_s; + extern const f_string_static_t kt_remove_date_symbol_more_s; + extern const f_string_static_t kt_remove_date_symbol_more_equal_s; + extern const f_string_static_t kt_remove_date_symbol_not_s; + + #define KT_REMOVE_date_word_equal_s "equal" + #define KT_REMOVE_date_word_less_s "less" + #define KT_REMOVE_date_word_less_equal_s "less_equal" + #define KT_REMOVE_date_word_more_s "more" + #define KT_REMOVE_date_word_more_equal_s "more_equal" + #define KT_REMOVE_date_word_not_s "not" + + #define KT_REMOVE_date_word_equal_s_length 5 + #define KT_REMOVE_date_word_less_s_length 4 + #define KT_REMOVE_date_word_less_equal_s_length 10 + #define KT_REMOVE_date_word_more_s_length 4 + #define KT_REMOVE_date_word_more_equal_s_length 10 + #define KT_REMOVE_date_word_not_s_length 3 + + extern const f_string_static_t kt_remove_date_word_equal_s; + extern const f_string_static_t kt_remove_date_word_less_s; + extern const f_string_static_t kt_remove_date_word_less_equal_s; + extern const f_string_static_t kt_remove_date_word_more_s; + extern const f_string_static_t kt_remove_date_word_more_equal_s; + extern const f_string_static_t kt_remove_date_word_not_s; +#endif // _di_kt_remove_date_s_ + +/** + * Strings associated with the mode parameters. + * + * kt_remove_mode_symbol_*_s: + * - different: The not similar to operator. + * - same: The same as operator. + * - similar: The similar to operator. + * - not: The not same as operator. + * + * kt_remove_mode_word_*_s: + * - different: The not similar to words. + * - same: The same as words. + * - similar: The similar to words. + * - not: The not same as words. + */ +#ifndef _di_kt_remove_mode_s_ + #define KT_REMOVE_mode_symbol_different_s "~~" + #define KT_REMOVE_mode_symbol_same_s "==" + #define KT_REMOVE_mode_symbol_similar_s "~=" + #define KT_REMOVE_mode_symbol_not_s "<>" + + #define KT_REMOVE_mode_symbol_different_s_length 2 + #define KT_REMOVE_mode_symbol_same_s_length 2 + #define KT_REMOVE_mode_symbol_similar_s_length 2 + #define KT_REMOVE_mode_symbol_not_s_length 2 + + extern const f_string_static_t kt_remove_mode_symbol_different_s; + extern const f_string_static_t kt_remove_mode_symbol_same_s; + extern const f_string_static_t kt_remove_mode_symbol_similar_s; + extern const f_string_static_t kt_remove_mode_symbol_not_s; + + #define KT_REMOVE_mode_word_different_s "different" + #define KT_REMOVE_mode_word_same_s "same" + #define KT_REMOVE_mode_word_similar_s "similar" + #define KT_REMOVE_mode_word_not_s "not" + + #define KT_REMOVE_mode_word_different_s_length 9 + #define KT_REMOVE_mode_word_same_s_length 4 + #define KT_REMOVE_mode_word_similar_s_length 7 + #define KT_REMOVE_mode_word_not_s_length 3 + + extern const f_string_static_t kt_remove_mode_word_different_s; + extern const f_string_static_t kt_remove_mode_word_same_s; + extern const f_string_static_t kt_remove_mode_word_similar_s; + extern const f_string_static_t kt_remove_mode_word_not_s; +#endif // _di_kt_remove_mode_s_ + +/** + * The main program parameters. + */ +#ifndef _di_kt_remove_parameter_s_ + #define KT_REMOVE_short_accessed_s "A" + #define KT_REMOVE_short_block_s "b" + #define KT_REMOVE_short_character_s "c" + #define KT_REMOVE_short_created_s "C" + #define KT_REMOVE_short_different_s "O" + #define KT_REMOVE_short_directory_s "d" + #define KT_REMOVE_short_empty_s "e" + #define KT_REMOVE_short_fifo_s "o" + #define KT_REMOVE_short_follow_s "F" + #define KT_REMOVE_short_force_s "f" + #define KT_REMOVE_short_group_s "g" + #define KT_REMOVE_short_isolate_s "i" + #define KT_REMOVE_short_link_s "l" + #define KT_REMOVE_short_mode_s "m" + #define KT_REMOVE_short_prompt_s "p" + #define KT_REMOVE_short_recurse_s "r" + #define KT_REMOVE_short_regular_s "R" + #define KT_REMOVE_short_same_s "s" + #define KT_REMOVE_short_simulate_s "S" + #define KT_REMOVE_short_socket_s "k" + #define KT_REMOVE_short_stay_s "Y" + #define KT_REMOVE_short_tree_s "t" + #define KT_REMOVE_short_updated_s "U" + #define KT_REMOVE_short_user_s "u" + + #define KT_REMOVE_long_accessed_s "accessed" + #define KT_REMOVE_long_block_s "block" + #define KT_REMOVE_long_character_s "character" + #define KT_REMOVE_long_created_s "created" + #define KT_REMOVE_long_different_s "different" + #define KT_REMOVE_long_directory_s "directory" + #define KT_REMOVE_long_empty_s "empty" + #define KT_REMOVE_long_fifo_s "fifo" + #define KT_REMOVE_long_follow_s "follow" + #define KT_REMOVE_long_force_s "force" + #define KT_REMOVE_long_group_s "group" + #define KT_REMOVE_long_isolate_s "isolate" + #define KT_REMOVE_long_link_s "link" + #define KT_REMOVE_long_local_s "local" + #define KT_REMOVE_long_mode_s "mode" + #define KT_REMOVE_long_prompt_s "prompt" + #define KT_REMOVE_long_recurse_s "recurse" + #define KT_REMOVE_long_regular_s "regular" + #define KT_REMOVE_long_same_s "same" + #define KT_REMOVE_long_simulate_s "simulate" + #define KT_REMOVE_long_socket_s "socket" + #define KT_REMOVE_long_stay_s "stay" + #define KT_REMOVE_long_tree_s "tree" + #define KT_REMOVE_long_updated_s "updated" + #define KT_REMOVE_long_user_s "user" + #define KT_REMOVE_long_utc_s "utc" + + #define KT_REMOVE_short_accessed_s_length 1 + #define KT_REMOVE_short_block_s_length 1 + #define KT_REMOVE_short_character_s_length 1 + #define KT_REMOVE_short_created_s_length 1 + #define KT_REMOVE_short_different_s_length 1 + #define KT_REMOVE_short_directory_s_length 1 + #define KT_REMOVE_short_empty_s_length 1 + #define KT_REMOVE_short_fifo_s_length 1 + #define KT_REMOVE_short_follow_s_length 1 + #define KT_REMOVE_short_force_s_length 1 + #define KT_REMOVE_short_group_s_length 1 + #define KT_REMOVE_short_isolate_s_length 1 + #define KT_REMOVE_short_link_s_length 1 + #define KT_REMOVE_short_mode_s_length 1 + #define KT_REMOVE_short_prompt_s_length 1 + #define KT_REMOVE_short_recurse_s_length 1 + #define KT_REMOVE_short_regular_s_length 1 + #define KT_REMOVE_short_same_s_length 1 + #define KT_REMOVE_short_simulate_s_length 1 + #define KT_REMOVE_short_socket_s_length 1 + #define KT_REMOVE_short_stay_s_length 1 + #define KT_REMOVE_short_tree_s_length 1 + #define KT_REMOVE_short_updated_s_length 1 + #define KT_REMOVE_short_user_s_length 1 + + #define KT_REMOVE_long_accessed_s_length 8 + #define KT_REMOVE_long_block_s_length 6 + #define KT_REMOVE_long_character_s_length 9 + #define KT_REMOVE_long_created_s_length 7 + #define KT_REMOVE_long_different_s_length 9 + #define KT_REMOVE_long_directory_s_length 9 + #define KT_REMOVE_long_empty_s_length 5 + #define KT_REMOVE_long_fifo_s_length 4 + #define KT_REMOVE_long_follow_s_length 6 + #define KT_REMOVE_long_force_s_length 5 + #define KT_REMOVE_long_group_s_length 5 + #define KT_REMOVE_long_isolate_s_length 7 + #define KT_REMOVE_long_link_s_length 4 + #define KT_REMOVE_long_local_s_length 5 + #define KT_REMOVE_long_mode_s_length 4 + #define KT_REMOVE_long_prompt_s_length 6 + #define KT_REMOVE_long_recurse_s_length 7 + #define KT_REMOVE_long_regular_s_length 7 + #define KT_REMOVE_long_same_s_length 4 + #define KT_REMOVE_long_simulate_s_length 8 + #define KT_REMOVE_long_socket_s_length 6 + #define KT_REMOVE_long_stay_s_length 4 + #define KT_REMOVE_long_tree_s_length 4 + #define KT_REMOVE_long_updated_s_length 7 + #define KT_REMOVE_long_user_s_length 4 + #define KT_REMOVE_long_utc_s_length 3 + + extern const f_string_static_t kt_remove_short_accessed_s; + extern const f_string_static_t kt_remove_short_block_s; + extern const f_string_static_t kt_remove_short_character_s; + extern const f_string_static_t kt_remove_short_created_s; + extern const f_string_static_t kt_remove_short_different_s; + extern const f_string_static_t kt_remove_short_directory_s; + extern const f_string_static_t kt_remove_short_empty_s; + extern const f_string_static_t kt_remove_short_fifo_s; + extern const f_string_static_t kt_remove_short_follow_s; + extern const f_string_static_t kt_remove_short_force_s; + extern const f_string_static_t kt_remove_short_group_s; + extern const f_string_static_t kt_remove_short_isolate_s; + extern const f_string_static_t kt_remove_short_link_s; + extern const f_string_static_t kt_remove_short_mode_s; + extern const f_string_static_t kt_remove_short_prompt_s; + extern const f_string_static_t kt_remove_short_recurse_s; + extern const f_string_static_t kt_remove_short_regular_s; + extern const f_string_static_t kt_remove_short_same_s; + extern const f_string_static_t kt_remove_short_simulate_s; + extern const f_string_static_t kt_remove_short_socket_s; + extern const f_string_static_t kt_remove_short_stay_s; + extern const f_string_static_t kt_remove_short_tree_s; + extern const f_string_static_t kt_remove_short_updated_s; + extern const f_string_static_t kt_remove_short_user_s; + + extern const f_string_static_t kt_remove_long_accessed_s; + extern const f_string_static_t kt_remove_long_block_s; + extern const f_string_static_t kt_remove_long_character_s; + extern const f_string_static_t kt_remove_long_created_s; + extern const f_string_static_t kt_remove_long_different_s; + extern const f_string_static_t kt_remove_long_directory_s; + extern const f_string_static_t kt_remove_long_empty_s; + extern const f_string_static_t kt_remove_long_fifo_s; + extern const f_string_static_t kt_remove_long_follow_s; + extern const f_string_static_t kt_remove_long_force_s; + extern const f_string_static_t kt_remove_long_group_s; + extern const f_string_static_t kt_remove_long_isolate_s; + extern const f_string_static_t kt_remove_long_link_s; + extern const f_string_static_t kt_remove_long_local_s; + extern const f_string_static_t kt_remove_long_mode_s; + extern const f_string_static_t kt_remove_long_prompt_s; + extern const f_string_static_t kt_remove_long_recurse_s; + extern const f_string_static_t kt_remove_long_regular_s; + extern const f_string_static_t kt_remove_long_same_s; + extern const f_string_static_t kt_remove_long_simulate_s; + extern const f_string_static_t kt_remove_long_socket_s; + extern const f_string_static_t kt_remove_long_stay_s; + extern const f_string_static_t kt_remove_long_tree_s; + extern const f_string_static_t kt_remove_long_updated_s; + extern const f_string_static_t kt_remove_long_user_s; + extern const f_string_static_t kt_remove_long_utc_s; +#endif // _di_kt_remove_parameter_s_ + +/** + * Strings used printing the reason why a removal failed. + */ +#ifndef _di_kt_remove_print_reason_s_ + #define KT_REMOVE_print_reason_no_access_s "file be accessed" + #define KT_REMOVE_print_reason_not_found_s "file cannot be found" + #define KT_REMOVE_print_reason_stat_fail_s "cannot read file statistics" + + #define KT_REMOVE_print_reason_no_access_s_length 16 + #define KT_REMOVE_print_reason_not_found_s_length 20 + #define KT_REMOVE_print_reason_stat_fail_s_length 27 + + extern const f_string_static_t kt_remove_print_reason_no_access_s; + extern const f_string_static_t kt_remove_print_reason_not_found_s; + extern const f_string_static_t kt_remove_print_reason_stat_fail_s; +#endif // _di_kt_remove_print_reason_s_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _kt_remove_common_string_h diff --git a/sources/c/remove/main/common/type.c b/sources/c/remove/main/common/type.c new file mode 100644 index 0000000..7a21078 --- /dev/null +++ b/sources/c/remove/main/common/type.c @@ -0,0 +1,9 @@ +#include "../remove.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/remove/main/common/type.h b/sources/c/remove/main/common/type.h new file mode 100644 index 0000000..f761ff3 --- /dev/null +++ b/sources/c/remove/main/common/type.h @@ -0,0 +1,225 @@ +/** + * Kevux Tools - Remove + * + * Project: Kevux Tools + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Provides the common type structures. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _kt_remove_common_type_h +#define _kt_remove_common_type_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A processed Date parameter. + * + * The start is inclusive and the stop is exclusive just like with f_string_range_t. + * + * operation: The comparison operation. + * type: The date type. + * + * start_year: The year in which the seconds is relative to (is only processed when + * start_second: The entire date value in seconds for the date or the start of a date range. + * start_nanosecond: The remaining nanosecond not represented in the seconds for the date or the start of a date range. + * stop_second: The entire date value in seconds for the stop of a date range (not used for non-range dates). + * stop_nanosecond: The remaining nanosecond not represented in the seconds for the stop of a date range (not used for non-range dates). + */ +#ifndef _di_kt_remove_date_t_ + typedef struct { + uint8_t operation; + uint8_t type; + + f_number_unsigned_t start_year; + f_number_unsigned_t start_second; + f_number_unsigned_t start_nanosecond; + + f_number_unsigned_t stop_year; + f_number_unsigned_t stop_second; + f_number_unsigned_t stop_nanosecond; + } kt_remove_date_t; + + #define kt_remove_date_t_initialize { \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + } +#endif // _di_kt_remove_date_t_ + +/** + * Date parameters. + * + * array: An array of data parameters. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_kt_remove_dates_t_ + typedef struct { + kt_remove_date_t *array; + + f_array_length_t size; + f_array_length_t used; + } kt_remove_dates_t; + + #define kt_remove_dates_t_initialize { \ + 0, \ + 0, \ + 0, \ + } + + #define macro_kt_remove_dates_t_clear(dates) \ + dates.array = 0; \ + dates.size = 0; \ + dates.used = 0; +#endif // _di_kt_remove_dates_t_ + +/** + * A processed mode parameter. + * + * type: The mode type. + * mode: The right side date value. + */ +#ifndef _di_kt_remove_mode_t_ + typedef struct { + uint8_t type; + mode_t mode; + } kt_remove_mode_t; + + #define kt_remove_mode_t_initialize { \ + 0, \ + 0, \ + } +#endif // _di_kt_remove_mode_t_ + +/** + * Mode parameters. + * + * array: An array of mode parameters. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_kt_remove_modes_t_ + typedef struct { + kt_remove_mode_t *array; + + f_array_length_t size; + f_array_length_t used; + } kt_remove_modes_t; + + #define kt_remove_modes_t_initialize { \ + 0, \ + 0, \ + 0, \ + } + + #define macro_kt_remove_modes_t_clear(dates) \ + dates.array = 0; \ + dates.size = 0; \ + dates.used = 0; +#endif // _di_kt_remove_modes_t_ + +/** + * The main program settings. + * + * This is passed to the program-specific main entry point to designate program settings. + * These program settings are often processed from the program arguments (often called the command line arguments). + * + * flag: Flags passed to the main function. + * + * status_thread: A status used eclusively by the threaded signal handler. + * state: The state data used when processing data. + * + * program_name: The short name of the program. + * program_name_long: The human friendly name of the program. + * + * buffer: A string buffer used for caching purposes. + * files: An array of file names (full paths to the files) to remove. + * + * accessed: An array of last accessed dates used for comparison. + * created: An array of created on dates used for comparison. + * updated: An array of last updated dates used for comparison. + * modes: An array of modes used for comparison. + * groups: An array of Group IDs (gid_t) represented via an unsigned 32-bit integer. + * users: An array of Group IDs (uid_t) represented via an unsigned 32-bit integer. + * + * process_help: Process help (generally printing help). + * process_normal: Process normally (data from parameters and files). + */ +#ifndef _di_kt_remove_setting_t_ + typedef struct { + uint64_t flag; + + f_status_t status_thread; + f_state_t state; + + f_string_dynamic_t buffer; + f_string_dynamics_t files; + + kt_remove_dates_t accessed; + kt_remove_dates_t created; + kt_remove_dates_t updated; + kt_remove_modes_t modes; + f_uint32s_t groups; + f_uint32s_t users; + + const f_string_static_t *program_name; + const f_string_static_t *program_name_long; + + f_status_t (*process_help)(void * const main); + void (*process_normal)(void * const main); + } kt_remove_setting_t; + + #define kt_remove_setting_t_initialize \ + { \ + kt_remove_main_flag_none_e, \ + F_none, \ + macro_f_state_t_initialize_1(kt_remove_allocation_large_d, kt_remove_allocation_small_d, F_none, 0, 0, &fll_program_standard_signal_handle, 0, 0, 0), \ + f_string_dynamic_t_initialize, \ + f_string_dynamics_t_initialize, \ + kt_remove_dates_t_initialize, \ + kt_remove_dates_t_initialize, \ + kt_remove_dates_t_initialize, \ + kt_remove_modes_t_initialize, \ + f_uint32s_t_initialize, \ + f_uint32s_t_initialize, \ + 0, \ + 0, \ + 0, \ + 0, \ + } +#endif // _di_kt_remove_setting_t_ + +/** + * The main program data as a single structure. + * + * program: The main program data. + * setting: The settings data. + */ +#ifndef _di_kt_remove_main_t_ + typedef struct { + fll_program_data_t program; + kt_remove_setting_t setting; + } kt_remove_main_t; + + #define kt_remove_main_t_initialize \ + { \ + fll_program_data_t_initialize, \ + kt_remove_setting_t_initialize, \ + } +#endif // _di_kt_remove_main_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _kt_remove_common_type_h diff --git a/sources/c/remove/main/convert.c b/sources/c/remove/main/convert.c index 7374960..9dd12c7 100644 --- a/sources/c/remove/main/convert.c +++ b/sources/c/remove/main/convert.c @@ -5,10 +5,10 @@ extern "C" { #endif #ifndef _di_kt_remove_convert_date_ - void kt_remove_convert_date(fll_program_data_t * const main, kt_remove_setting_t * const setting, const f_string_static_t buffer, kt_remove_date_t * const date) { + void kt_remove_convert_date(kt_remove_main_t * const main, const f_string_static_t buffer, kt_remove_date_t * const date) { - if (!setting || !buffer.used || !date) { - if (setting) setting->status = F_data_not; + if (!main || !buffer.used || !date) { + if (main) main->setting.state.status = F_data_not; return; } @@ -33,10 +33,10 @@ extern "C" { if (fl_string_dynamic_compare(buffer, strings[i]) == F_equal_to) { date->type = enumerations[i]; - kt_remove_convert_date_relative(setting, date); + kt_remove_convert_date_relative(main, date); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(kt_remove_convert_date_relative)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(kt_remove_convert_date_relative)); } return; @@ -67,15 +67,15 @@ extern "C" { width = macro_f_utf_byte_width(buffer.string[range.start]); if (matches & kt_remove_flag_convert_match_second_e) { - setting->status = f_utf_is_digit(buffer.string + range.start, width_max, 0); + main->setting.state.status = f_utf_is_digit(buffer.string + range.start, width_max, 0); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(f_utf_is_digit)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_utf_is_digit)); return; } - if (setting->status == F_true) { + if (main->setting.state.status == F_true) { range_second.stop = range.start; continue; @@ -104,15 +104,15 @@ extern "C" { continue; } - setting->status = f_utf_is_digit(buffer.string + range.start, width_max, 0); + main->setting.state.status = f_utf_is_digit(buffer.string + range.start, width_max, 0); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(f_utf_is_digit)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_utf_is_digit)); return; } - if (setting->status == F_true) { + if (main->setting.state.status == F_true) { matches |= kt_remove_flag_convert_match_second_e; range_second.start = range.start; range_second.stop = range.start; @@ -129,15 +129,15 @@ extern "C" { continue; } - setting->status = f_utf_is_digit(buffer.string + range.start, width_max, 0); + main->setting.state.status = f_utf_is_digit(buffer.string + range.start, width_max, 0); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(f_utf_is_digit)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_utf_is_digit)); return; } - if (setting->status == F_true) { + if (main->setting.state.status == F_true) { range_first.stop = range.start; } else { @@ -149,15 +149,15 @@ extern "C" { continue; } - setting->status = f_utf_is_whitespace(buffer.string + range.start, width_max, F_false); + main->setting.state.status = f_utf_is_whitespace(buffer.string + range.start, width_max, F_false); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(f_utf_is_whitespace)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_utf_is_whitespace)); return; } - if (setting->status == F_true) continue; + if (main->setting.state.status == F_true) continue; if (fl_string_dynamic_compare_string(buffer.string + range.start, f_string_ascii_colon_s, width) == F_equal_to) { matches |= kt_remove_flag_convert_colon_single_e; @@ -165,15 +165,15 @@ extern "C" { continue; } - setting->status = f_utf_is_digit(buffer.string + range.start, width_max, 0); + main->setting.state.status = f_utf_is_digit(buffer.string + range.start, width_max, 0); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(f_utf_is_digit)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_utf_is_digit)); return; } - if (setting->status == F_true) { + if (main->setting.state.status == F_true) { matches |= kt_remove_flag_convert_match_first_e; range_first.start = range.start; range_first.stop = range.start; @@ -185,7 +185,7 @@ extern "C" { } } // for - setting->status = F_none; + main->setting.state.status = F_none; } // If the first and possibly the second digit matches. @@ -202,10 +202,10 @@ extern "C" { // Process the first character. if (matches & kt_remove_flag_convert_match_first_e) { - setting->status = fl_conversion_dynamic_partial_to_unsigned_detect(conversion_data, buffer, range_first, &date->start_year); + main->setting.state.status = fl_conversion_dynamic_partial_to_unsigned_detect(conversion_data, buffer, range_first, &date->start_year); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(fl_conversion_dynamic_partial_to_unsigned_detect)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(fl_conversion_dynamic_partial_to_unsigned_detect)); return; } @@ -229,16 +229,16 @@ extern "C" { if (!result) { if (result == EFAULT) { - setting->status = F_status_set_error(F_buffer); + main->setting.state.status = F_status_set_error(F_buffer); } else if (result == EINVAL) { - setting->status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); } else if (result == EPERM) { - setting->status = F_status_set_error(F_prohibited); + main->setting.state.status = F_status_set_error(F_prohibited); } else { - setting->status = F_status_set_error(F_failure); + main->setting.state.status = F_status_set_error(F_failure); } return; @@ -252,20 +252,20 @@ extern "C" { // Process the second character. if (matches & kt_remove_flag_convert_match_second_e) { - setting->status = fl_conversion_dynamic_partial_to_unsigned_detect(conversion_data, buffer, range_second, &date->start_second); + main->setting.state.status = fl_conversion_dynamic_partial_to_unsigned_detect(conversion_data, buffer, range_second, &date->start_second); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(fl_conversion_dynamic_partial_to_unsigned_detect)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(fl_conversion_dynamic_partial_to_unsigned_detect)); return; } if (matches & kt_remove_flag_convert_colon_double_e) { - if (!(setting->flag & kt_remove_flag_utc_e)) { - kt_remove_convert_timezone(setting, &date->start_year, &date->start_second); + if (!(main->setting.flag & kt_remove_main_flag_utc_e)) { + kt_remove_convert_timezone(main, &date->start_year, &date->start_second); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(kt_remove_convert_timezone)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(kt_remove_convert_timezone)); return; } @@ -275,11 +275,11 @@ 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 (!(setting->flag & kt_remove_flag_utc_e)) { - kt_remove_convert_timezone(setting, &date->start_year, &date->start_second); + if (!(main->setting.flag & kt_remove_main_flag_utc_e)) { + kt_remove_convert_timezone(main, &date->start_year, &date->start_second); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(kt_remove_convert_timezone)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(kt_remove_convert_timezone)); return; } @@ -298,18 +298,18 @@ extern "C" { date->start_year = kt_remove_time_year_unix_epoch_d; date->type = kt_remove_flag_date_unix_e; - setting->status = fl_conversion_dynamic_to_unsigned_detect(conversion_data, buffer, &date->start_second); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(conversion_data, buffer, &date->start_second); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(fl_conversion_dynamic_to_unsigned_detect)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(fl_conversion_dynamic_to_unsigned_detect)); return; } - kt_remove_convert_timezone(setting, &date->start_year, &date->start_second); + kt_remove_convert_timezone(main, &date->start_year, &date->start_second); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(kt_remove_convert_timezone)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(kt_remove_convert_timezone)); return; } @@ -366,15 +366,15 @@ extern "C" { } // for } - setting->status = matches ? F_none : F_status_set_error(F_known_not); + main->setting.state.status = matches ? F_none : F_status_set_error(F_known_not); } #endif // _di_kt_remove_convert_date_ #ifndef _di_kt_remove_convert_date_relative_ - void kt_remove_convert_date_relative(kt_remove_setting_t * const setting, kt_remove_date_t * const date) { + void kt_remove_convert_date_relative(kt_remove_main_t * const main, kt_remove_date_t * const date) { - if (!setting || !date) { - if (setting) setting->status = F_status_set_error(F_parameter); + if (!main || !date) { + if (main) main->setting.state.status = F_status_set_error(F_parameter); return; } @@ -388,16 +388,16 @@ extern "C" { if (result) { if (errno == EFAULT) { - setting->status = F_status_set_error(F_buffer); + main->setting.state.status = F_status_set_error(F_buffer); } else if (errno == EINVAL) { - setting->status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); } else if (errno == EPERM) { - setting->status = F_status_set_error(F_prohibited); + main->setting.state.status = F_status_set_error(F_prohibited); } else { - setting->status = F_status_set_error(F_failure); + main->setting.state.status = F_status_set_error(F_failure); } return; @@ -414,20 +414,20 @@ extern "C" { if (date->type == kt_remove_flag_date_now_e) { date->start_nanosecond = now.tv_nsec; - if (!(setting->flag & kt_remove_flag_utc_e)) { - kt_remove_convert_timezone(setting, &date->start_year, &date->start_second); - if (F_status_is_error(setting->status)) return; + if (!(main->setting.flag & kt_remove_main_flag_utc_e)) { + kt_remove_convert_timezone(main, &date->start_year, &date->start_second); + if (F_status_is_error(main->setting.state.status)) return; } - setting->status = F_none; + main->setting.state.status = F_none; return; } // Determine start of day. - if (!(setting->flag & kt_remove_flag_utc_e)) { - kt_remove_convert_timezone(setting, &date->start_year, &date->start_second); - if (F_status_is_error(setting->status)) return; + if (!(main->setting.flag & kt_remove_main_flag_utc_e)) { + 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; @@ -444,38 +444,38 @@ extern "C" { date->stop_second = date->start_second; } - setting->status = F_none; + main->setting.state.status = F_none; } #endif // _di_kt_remove_convert_date_relative_ #ifndef _di_kt_remove_get_id_group_ - uint32_t kt_remove_get_id_group(kt_remove_setting_t * const setting, const f_string_static_t buffer) { + uint32_t kt_remove_get_id_group(kt_remove_main_t * const main, const f_string_static_t buffer) { - if (!setting) return 0; + if (!main) return 0; f_number_unsigned_t number = 0; - setting->status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, buffer, &number); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, buffer, &number); - if (F_status_is_error(setting->status)) { - if (F_status_set_fine(setting->status) == F_number) { - setting->buffer.used = 0; + if (F_status_is_error(main->setting.state.status)) { + if (F_status_set_fine(main->setting.state.status) == F_number) { + main->setting.buffer.used = 0; - setting->status = fl_string_dynamic_rip_nulless(buffer, &setting->buffer); - if (F_status_is_error(setting->status)) return 0; + main->setting.state.status = fl_string_dynamic_rip_nulless(buffer, &main->setting.buffer); + if (F_status_is_error(main->setting.state.status)) return 0; gid_t gid = 0; - setting->status = f_account_group_id_by_name(setting->buffer, &gid); - if (F_status_is_error(setting->status)) return 0; + main->setting.state.status = f_account_group_id_by_name(main->setting.buffer, &gid); + if (F_status_is_error(main->setting.state.status)) return 0; - if (setting->status == F_exist_not) { - setting->status = F_status_set_error(F_exist_not); + if (main->setting.state.status == F_exist_not) { + main->setting.state.status = F_status_set_error(F_exist_not); return 0; } - setting->status = F_none; + main->setting.state.status = F_none; return (uint32_t) gid; } @@ -484,45 +484,45 @@ extern "C" { } if (number > F_type_size_32_unsigned_d) { - setting->status = F_status_set_error(F_number_too_large); + main->setting.state.status = F_status_set_error(F_number_too_large); return 0; } - setting->status = F_none; + main->setting.state.status = F_none; return (uint32_t) number; } #endif // _di_kt_remove_get_id_group_ #ifndef _di_kt_remove_get_id_user_ - uint32_t kt_remove_get_id_user(kt_remove_setting_t * const setting, const f_string_static_t buffer) { + uint32_t kt_remove_get_id_user(kt_remove_main_t * const main, const f_string_static_t buffer) { - if (!setting) return 0; + if (!main) return 0; f_number_unsigned_t number = 0; - setting->status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, buffer, &number); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, buffer, &number); - if (F_status_is_error(setting->status)) { - if (F_status_set_fine(setting->status) == F_number) { - setting->buffer.used = 0; + if (F_status_is_error(main->setting.state.status)) { + if (F_status_set_fine(main->setting.state.status) == F_number) { + main->setting.buffer.used = 0; - setting->status = fl_string_dynamic_rip_nulless(buffer, &setting->buffer); - if (F_status_is_error(setting->status)) return 0; + main->setting.state.status = fl_string_dynamic_rip_nulless(buffer, &main->setting.buffer); + if (F_status_is_error(main->setting.state.status)) return 0; uid_t uid = 0; - setting->status = f_account_id_by_name(setting->buffer, &uid); - if (F_status_is_error(setting->status)) return 0; + main->setting.state.status = f_account_id_by_name(main->setting.buffer, &uid); + if (F_status_is_error(main->setting.state.status)) return 0; - if (setting->status == F_exist_not) { - setting->status = F_status_set_error(F_exist_not); + if (main->setting.state.status == F_exist_not) { + main->setting.state.status = F_status_set_error(F_exist_not); return 0; } - setting->status = F_none; + main->setting.state.status = F_none; return (uint32_t) uid; } @@ -531,54 +531,54 @@ extern "C" { } if (number > F_type_size_32_unsigned_d) { - setting->status = F_status_set_error(F_number_too_large); + main->setting.state.status = F_status_set_error(F_number_too_large); return 0; } - setting->status = F_none; + main->setting.state.status = F_none; return (uint32_t) number; } #endif // _di_kt_remove_get_id_user_ #ifndef _di_kt_remove_get_mode_ - mode_t kt_remove_get_mode(fll_program_data_t * const main, kt_remove_setting_t * const setting, const f_string_static_t buffer) { + mode_t kt_remove_get_mode(kt_remove_main_t * const main, const f_string_static_t buffer) { - if (!setting) return 0; + if (!main) return 0; f_file_mode_t mode_file = f_file_mode_t_initialize; uint8_t mode_replace = 0; - setting->status = f_file_mode_from_string(buffer, main->umask, &mode_file, &mode_replace); + main->setting.state.status = f_file_mode_from_string(buffer, main->program.umask, &mode_file, &mode_replace); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(f_file_mode_from_string)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_file_mode_from_string)); return 0; } mode_t mode = 0; - setting->status = f_file_mode_to_mode(mode_file, &mode); + main->setting.state.status = f_file_mode_to_mode(mode_file, &mode); - if (F_status_is_error(setting->status)) { - kt_remove_print_error(setting, main->error, macro_kt_remove_f(f_file_mode_to_mode)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_file_mode_to_mode)); return 0; } - setting->status = F_none; + main->setting.state.status = F_none; return mode; } #endif // _di_kt_remove_get_mode_ #ifndef _di_kt_remove_convert_timezone_ - void kt_remove_convert_timezone(kt_remove_setting_t * const setting, f_number_unsigned_t * const year, f_number_unsigned_t * const seconds) { + void kt_remove_convert_timezone(kt_remove_main_t * const main, f_number_unsigned_t * const year, f_number_unsigned_t * const seconds) { - if (!setting || !year || !seconds) { - if (setting) setting->status = F_status_set_error(F_parameter); + if (!main || !year || !seconds) { + if (main) main->setting.state.status = F_status_set_error(F_parameter); return; } @@ -590,7 +590,7 @@ extern "C" { *seconds -= kt_remove_time_seconds_in_year_d + timezone; } else { - setting->status = F_status_set_error(F_number_overflow); + main->setting.state.status = F_status_set_error(F_number_overflow); return; } @@ -606,7 +606,7 @@ extern "C" { *seconds = kt_remove_time_seconds_in_year_d - (timezone - *seconds); } else { - setting->status = F_status_set_error(F_number_underflow); + main->setting.state.status = F_status_set_error(F_number_underflow); return; } @@ -616,7 +616,7 @@ extern "C" { } } - setting->status = F_none; + main->setting.state.status = F_none; } #endif // _di_kt_remove_convert_timezone_ diff --git a/sources/c/remove/main/convert.h b/sources/c/remove/main/convert.h index 8fc1287..62b1eb8 100644 --- a/sources/c/remove/main/convert.h +++ b/sources/c/remove/main/convert.h @@ -30,11 +30,9 @@ extern "C" { * More 'time' string values will likely be implemented in a not yet existent 'f_time' project in FLL 0.7 or greater (possibly including fl_time and fll_time). * * @param main - * The main program data. - * @param setting - * The main program settings. + * The main program and settings data. * - * This alters setting.status: + * This alters main.setting.state.status: * F_none on success. * F_data_not on success, but buffer is empty and there is no data to process. * @@ -63,7 +61,7 @@ extern "C" { * @see kt_remove_get_date_relative() */ #ifndef _di_kt_remove_convert_date_ - extern void kt_remove_convert_date(fll_program_data_t * const main, kt_remove_setting_t * const setting, const f_string_static_t buffer, kt_remove_date_t * const date); + extern void kt_remove_convert_date(kt_remove_main_t * const main, const f_string_static_t buffer, kt_remove_date_t * const date); #endif // _di_kt_remove_convert_date_ /** @@ -80,10 +78,10 @@ extern "C" { * Only a limited set of 'time' string values are implemented in this project. * More 'time' string values will likely be implemented in a not yet existent 'f_time' project in FLL 0.7 or greater (possibly including fl_time and fll_time). * - * @param setting - * The main program settings. + * @param main + * The main program and settings data. * - * This alters setting.status: + * This alters main.setting.state.status: * F_none on success. * F_data_not on success, but buffer is empty or there is no data to process. * @@ -103,16 +101,16 @@ extern "C" { * @see kt_remove_get_date_relative() */ #ifndef _di_kt_remove_convert_date_relative_ - extern void kt_remove_convert_date_relative(kt_remove_setting_t * const setting, kt_remove_date_t * const date); + extern void kt_remove_convert_date_relative(kt_remove_main_t * const main, kt_remove_date_t * const date); #endif // _di_kt_remove_convert_date_relative_ /** * Convert the string from a string representation of an ID or a group name into the numeric representation of that ID or group name. * - * @param setting - * The main program settings. + * @param main + * The main program and settings data. * - * This alters setting.status: + * This alters main.setting.state.status: * F_none on success. * * F_number_too_large (with error bit) if the given ID is too large. @@ -128,16 +126,16 @@ extern "C" { * @see fl_string_dynamic_rip_nulless() */ #ifndef _di_kt_remove_get_id_group_ - extern uint32_t kt_remove_get_id_group(kt_remove_setting_t * const setting, const f_string_static_t buffer); + extern uint32_t kt_remove_get_id_group(kt_remove_main_t * const main, const f_string_static_t buffer); #endif // _di_kt_remove_get_id_group_ /** * Convert the string from a string representation of an ID or a user name into the numeric representation of that ID or user name. * - * @param setting - * The main program settings. + * @param main + * The main program and settings data. * - * This alters setting.status: + * This alters main.setting.state.status: * F_none on success. * * F_number_too_large (with error bit) if the given ID is too large. @@ -153,16 +151,16 @@ extern "C" { * @see fl_string_dynamic_rip_nulless() */ #ifndef _di_kt_remove_get_id_user_ - extern uint32_t kt_remove_get_id_user(kt_remove_setting_t * const setting, const f_string_static_t buffer); + extern uint32_t kt_remove_get_id_user(kt_remove_main_t * const main, const f_string_static_t buffer); #endif // _di_kt_remove_get_id_user_ /** * Convert the string from a string representation of a mode into the numeric representation of that mode. * - * @param setting - * The main program settings. + * @param main + * The main program and settings data. * - * This alters setting.status: + * This alters main.setting.state.status: * F_none on success. * * Errors (with error bit) from: f_file_mode_from_string(). @@ -174,7 +172,7 @@ extern "C" { * @see f_file_mode_to_mode() */ #ifndef _di_kt_remove_get_mode_ - extern mode_t kt_remove_get_mode(fll_program_data_t * const main, kt_remove_setting_t * const setting, const f_string_static_t buffer); + extern mode_t kt_remove_get_mode(kt_remove_main_t * const main, const f_string_static_t buffer); #endif // _di_kt_remove_get_mode_ /** @@ -183,10 +181,10 @@ extern "C" { * This does not check the flags to see if UTC is in used. * The caller must assure this is appropriate. * - * @param setting - * The main program settings. + * @param main + * The main program and settings data. * - * This alters setting.status: + * This alters main.setting.state.status: * F_none on success. * * F_number_overflow (with error bit) if the date after applying the timezone is too large. @@ -201,7 +199,7 @@ extern "C" { * This is updated based on the global timezone variable. */ #ifndef _di_kt_remove_convert_timezone_ - extern void kt_remove_convert_timezone(kt_remove_setting_t * const setting, f_number_unsigned_t * const year, f_number_unsigned_t * const seconds); + extern void kt_remove_convert_timezone(kt_remove_main_t * const main, f_number_unsigned_t * const year, f_number_unsigned_t * const seconds); #endif // _di_kt_remove_convert_timezone_ #ifdef __cplusplus diff --git a/sources/c/remove/main/main.c b/sources/c/remove/main/main.c index 9fdf62c..6be3958 100644 --- a/sources/c/remove/main/main.c +++ b/sources/c/remove/main/main.c @@ -3,44 +3,60 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - fll_program_data_t data = fll_program_data_t_initialize; - kt_remove_setting_t setting = kt_remove_setting_t_initialize; - setting.state.data = (void *) &data; - setting.program_name = &kt_remove_program_name_s; - setting.program_name_long = &kt_remove_program_name_long_s; - setting.process_help = &kt_remove_process_help; - setting.process_normal = &kt_remove_process_normal; + 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.message.custom = (void *) &data; + data.program.output.custom = (void *) &data; + data.program.error.custom = (void *) &data; + data.program.warning.custom = (void *) &data; + data.program.debug.custom = (void *) &data; + + data.setting.state.data = (void *) &data; + data.setting.program_name = &kt_remove_program_name_s; + data.setting.program_name_long = &kt_remove_program_name_long_s; + data.setting.process_help = &kt_remove_process_help; + data.setting.process_normal = &kt_remove_process_normal; #ifdef _en_kt_default_to_utc_ - setting.flag |= kt_remove_flag_utc_e; + data.setting.flag |= kt_remove_flag_utc_e; #endif // _en_kt_default_to_utc_ f_console_parameter_t parameters[] = kt_remove_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = kt_remove_total_parameters_d; - fll_program_standard_setup(&data.signal); + data.program.parameters.array = parameters; + data.program.parameters.used = kt_remove_total_parameters_d; + data.program.environment = envp; + + if (f_pipe_input_exists()) { + data.program.pipe = fll_program_data_pipe_input_e; + } + + fll_program_standard_set_up(&data.program); { f_thread_id_t id_signal; - kt_remove_arguments_t signal_arguments = macro_kt_remove_arguments_t_initialize(&data, &setting); memset(&id_signal, 0, sizeof(f_thread_id_t)); - setting.status = f_thread_create(0, &id_signal, &kt_remove_thread_signal, (void *) &signal_arguments); + data.setting.state.status = f_thread_create(0, &id_signal, &kt_remove_thread_signal, (void *) &data); - if (F_status_is_error(setting.status)) { - kt_remove_print_error(&setting, data.error, macro_kt_remove_f(f_thread_create)); + if (F_status_is_error(data.setting.state.status)) { + kt_remove_print_error(&data.program.error, macro_kt_remove_f(f_thread_create)); } else { { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - kt_remove_setting_load(arguments, &data, &setting); + kt_remove_setting_load(arguments, &data); } if (!kt_remove_signal_check(&data)) { - kt_remove_main(&data, &setting); + kt_remove_main(&data); } f_thread_cancel(id_signal); @@ -48,11 +64,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { } } - kt_remove_setting_unload(&data, &setting); + kt_remove_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_setdown(&data.signal); + fll_program_standard_set_down(&data.program); - return F_status_is_error(setting.status) ? 1 : 0; + return (F_status_is_error(data.setting.state.status) || data.setting.state.status == F_false) ? 1 : 0; } diff --git a/sources/c/remove/main/main.h b/sources/c/remove/main/main.h index 4063e30..f57355f 100644 --- a/sources/c/remove/main/main.h +++ b/sources/c/remove/main/main.h @@ -8,8 +8,8 @@ * This file is only ever included by main.c and should not normally be included anywhere else. * Anything that wants to include this should be providing the "remove" program functionality in some manner. */ -#ifndef _kt_remove_h -#define _kt_remove_h +#ifndef _kt_remove_main_h +#define _kt_remove_main_h #ifdef __cplusplus extern "C" { @@ -35,4 +35,4 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); } // extern "C" #endif -#endif // _kt_remove_h +#endif // _kt_remove_main_h diff --git a/sources/c/remove/main/operate.c b/sources/c/remove/main/operate.c index 10f280e..ec729b3 100644 --- a/sources/c/remove/main/operate.c +++ b/sources/c/remove/main/operate.c @@ -5,192 +5,182 @@ extern "C" { #endif #ifndef _di_kt_remove_operate_file_ - void kt_remove_operate_file(fll_program_data_t * const main, kt_remove_setting_t * const setting, const f_string_static_t path) { + void kt_remove_operate_file(kt_remove_main_t * const main, const f_string_static_t path) { - if (!main || !setting) return; + if (!main) return; if (!path.used) { - setting->status = F_data_not; + main->setting.state.status = F_data_not; return; } - if (main->signal_received) return; + if (main->program.signal_received) return; - kt_remove_simulate_operate_file(main, setting, path); + kt_remove_print_simulate_operate_file(&main->program.output, path); - setting->status = f_file_exists(path, setting->flag & kt_remove_flag_follow_e); + main->setting.state.status = f_file_exists(path, main->setting.flag & kt_remove_main_flag_follow_e); - kt_remove_simulate_operate_file_exists(main, setting, path); + kt_remove_print_simulate_operate_file_exists(&main->program.output, path); - if (setting->status == F_false) { - if (!(setting->flag & kt_remove_flag_simulate_e)) { - remove_print_warning_file_reason(setting, main->warning, path, kt_remove_print_reason_not_found_s); + if (main->setting.state.status == F_false) { + if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) { + remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_not_found_s); } return; } - if (F_status_is_error(setting->status)) { - if (!(setting->flag & kt_remove_flag_simulate_e)) { - remove_print_warning_file_reason(setting, main->warning, path, kt_remove_print_reason_no_access_s); + if (F_status_is_error(main->setting.state.status)) { + if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) { + remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_no_access_s); } return; } - if (setting->status == F_false) { - kt_remove_simulate_operate_remove_no(main, setting); + if (main->setting.state.status == F_false) { + kt_remove_print_simulate_operate_remove(&main->program.output, F_false, F_false); return; } - if (main->signal_received) return; + if (main->program.signal_received) return; f_array_length_t i = 0; - f_status_t remove = (setting->flag & kt_remove_flag_option_used_e) ? F_false : F_true; + f_status_t remove = (main->setting.flag & kt_remove_main_flag_option_used_e) ? F_false : F_true; struct stat statistics; memset(&statistics, 0, sizeof(struct stat)); - setting->status = f_file_stat(path, setting->flag & kt_remove_flag_follow_e, &statistics); + main->setting.state.status = f_file_stat(path, main->setting.flag & kt_remove_main_flag_follow_e, &statistics); - kt_remove_simulate_operate_file_stat(main, setting, statistics); + kt_remove_print_simulate_operate_file_stat(&main->program.output, statistics); - if (F_status_is_error(setting->status)) { - if (!(setting->flag & kt_remove_flag_simulate_e)) { - remove_print_warning_file_reason(setting, main->warning, path, kt_remove_print_reason_stat_fail_s); + if (F_status_is_error(main->setting.state.status)) { + if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) { + remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_stat_fail_s); } return; } - if (setting->flag & kt_remove_flag_block_e) { + if (main->setting.flag & kt_remove_main_flag_block_e) { if (macro_f_file_type_get(statistics.st_mode) == F_file_type_block_d) { remove = F_true; } } - if (setting->flag & kt_remove_flag_character_e) { + if (main->setting.flag & kt_remove_main_flag_character_e) { if (macro_f_file_type_get(statistics.st_mode) == F_file_type_character_d) { remove = F_true; } } - if (setting->flag & kt_remove_flag_directory_e) { + if (main->setting.flag & kt_remove_main_flag_directory_e) { if (macro_f_file_type_get(statistics.st_mode) == F_file_type_directory_d) { remove = F_true; } } - if (setting->flag & kt_remove_flag_fifo_e) { + if (main->setting.flag & kt_remove_main_flag_fifo_e) { if (macro_f_file_type_get(statistics.st_mode) == F_file_type_fifo_d) { remove = F_true; } } - if (setting->flag & kt_remove_flag_link_e) { + if (main->setting.flag & kt_remove_main_flag_link_e) { if (macro_f_file_type_get(statistics.st_mode) == F_file_type_link_d) { remove = F_true; } } - if (setting->flag & kt_remove_flag_regular_e) { + if (main->setting.flag & kt_remove_main_flag_regular_e) { if (macro_f_file_type_get(statistics.st_mode) == F_file_type_regular_d) { remove = F_true; } } - if (setting->flag & kt_remove_flag_socket_e) { + if (main->setting.flag & kt_remove_main_flag_socket_e) { if (macro_f_file_type_get(statistics.st_mode) == F_file_type_socket_d) { remove = F_true; } } - if (main->signal_received) return; + if (main->program.signal_received) return; - if (setting->flag & kt_remove_flag_user_e) { - for (i = 0; i < setting->users.used; ++i) { - if (statistics.st_uid == (uid_t) setting->users.array[i]) break; + if (main->setting.flag & kt_remove_main_flag_user_e) { + for (i = 0; i < main->setting.users.used; ++i) { + if (statistics.st_uid == (uid_t) main->setting.users.array[i]) break; } // for - if (i < setting->users.used) { + if (i < main->setting.users.used) { remove = F_true; } } - if (setting->flag & kt_remove_flag_same_e) { + if (main->setting.flag & kt_remove_main_flag_same_e) { if (statistics.st_uid != geteuid()) { remove = F_true; } } - if (setting->flag & kt_remove_flag_different_e) { + if (main->setting.flag & kt_remove_main_flag_different_e) { if (statistics.st_uid == geteuid()) { remove = F_true; } } - if (setting->flag & kt_remove_flag_group_e) { - for (i = 0; i < setting->groups.used; ++i) { - if (statistics.st_gid == (gid_t) setting->groups.array[i]) break; + if (main->setting.flag & kt_remove_main_flag_group_e) { + for (i = 0; i < main->setting.groups.used; ++i) { + if (statistics.st_gid == (gid_t) main->setting.groups.array[i]) break; } // for - if (i < setting->groups.used) { + if (i < main->setting.groups.used) { remove = F_true; } } - if (setting->flag & kt_remove_flag_mode_e) { + if (main->setting.flag & kt_remove_main_flag_mode_e) { const mode_t mode = statistics.st_mode & F_file_mode_all_d; - for (i = 0; i < setting->modes.used; ++i) { + for (i = 0; i < main->setting.modes.used; ++i) { - if (setting->modes.array[i].type == kt_remove_flag_mode_different_e) { - if (setting->modes.array[i].mode & ~mode) break; + if (main->setting.modes.array[i].type == kt_remove_flag_mode_different_e) { + if (main->setting.modes.array[i].mode & ~mode) break; } - else if (setting->modes.array[i].type == kt_remove_flag_mode_same_e) { - if (setting->modes.array[i].mode == mode) break; + else if (main->setting.modes.array[i].type == kt_remove_flag_mode_same_e) { + if (main->setting.modes.array[i].mode == mode) break; } - else if (setting->modes.array[i].type == kt_remove_flag_mode_similar_e) { - if (setting->modes.array[i].mode & mode) break; + else if (main->setting.modes.array[i].type == kt_remove_flag_mode_similar_e) { + if (main->setting.modes.array[i].mode & mode) break; } - else if (setting->modes.array[i].type == kt_remove_flag_mode_not_e) { - if (setting->modes.array[i].mode != mode) break; + else if (main->setting.modes.array[i].type == kt_remove_flag_mode_not_e) { + if (main->setting.modes.array[i].mode != mode) break; } } // for - if (i < setting->modes.used) { + if (i < main->setting.modes.used) { remove = F_true; } } - if (main->signal_received) return; + if (main->program.signal_received) return; - setting->status = F_none; + main->setting.state.status = F_none; - if (setting->flag & kt_remove_flag_force_e) { - if (remove == F_false) { - kt_remove_simulate_operate_remove_force_yes(main, setting); + if (main->setting.flag & kt_remove_main_flag_force_e) { + remove = F_true; - remove = F_true; - } - else { - kt_remove_simulate_operate_remove_force_no(main, setting); - } + kt_remove_print_simulate_operate_remove(&main->program.output, remove, F_true); } // @todo add check here to see if file is a directory, apply any appropriate restrictions (such as not removing non-empty directories without force or recursive). // @todo - if (remove == F_true) { - kt_remove_simulate_operate_remove_yes(main, setting); - } - else { - kt_remove_simulate_operate_remove_no(main, setting); - } + kt_remove_print_simulate_operate_remove(&main->program.output, remove, F_false); // @todo do actual removal. // @todo be sure too handle all of the remaining flags, such as tree, force, recurse, etc... diff --git a/sources/c/remove/main/operate.h b/sources/c/remove/main/operate.h index bebbf08..c609166 100644 --- a/sources/c/remove/main/operate.h +++ b/sources/c/remove/main/operate.h @@ -16,12 +16,9 @@ extern "C" { * Operate on a single file. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (kt_remove_setting_t *). + * The main program and settings data. * - * This alters setting.status: + * This alters main.setting.state.status: * F_none on success. * F_data_not on success but file is an empty string. * @@ -30,7 +27,7 @@ extern "C" { * The path to the file to operate on. */ #ifndef _di_kt_remove_operate_file_ - extern void kt_remove_operate_file(fll_program_data_t * const main, kt_remove_setting_t * const setting, const f_string_static_t path); + extern void kt_remove_operate_file(kt_remove_main_t * const main, const f_string_static_t path); #endif // _di_kt_remove_operate_file_ #ifdef __cplusplus diff --git a/sources/c/remove/main/print.c b/sources/c/remove/main/print.c deleted file mode 100644 index c7ab947..0000000 --- a/sources/c/remove/main/print.c +++ /dev/null @@ -1,267 +0,0 @@ -#include "remove.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_kt_remove_print_error_ - f_status_t kt_remove_print_error(kt_remove_setting_t * const setting, const fl_print_t print, const f_string_t function) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - fll_error_print(print, F_status_set_fine(setting->status), function, F_true); - - return F_none; - } -#endif // _di_kt_remove_print_error_ - -#ifndef _di_kt_remove_print_error_file_ - f_status_t kt_remove_print_error_file(kt_remove_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - fll_error_file_print(print, F_status_set_fine(setting->status), function, F_true, name, operation, type); - - return F_none; - } -#endif // _di_kt_remove_print_error_file_ - -#ifndef _di_kt_remove_print_error_parameter_missing_value_requires_amount_ - f_status_t kt_remove_print_error_parameter_missing_value_requires_amount(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter, const f_number_unsigned_t amount) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - flockfile(print.to.stream); - - fl_print_format("%[%QThe parameter%] ", print.to.stream, print.set->error, print.prefix, print.set->error); - fl_print_format("%[%Q%Q%]", print.to.stream, print.set->notable, symbol, parameter, print.set->notable); - fl_print_format("%[ is specified, but%] ", print.to.stream, print.set->error, print.set->error); - fl_print_format("%[%un%]", print.to.stream, print.set->notable, amount, print.set->notable); - fl_print_format(" %[values are not given.%]%r", print.to.stream, print.set->error, print.set->error, f_string_eol_s); - - funlockfile(print.to.stream); - - return F_none; - } -#endif // _di_kt_remove_print_error_parameter_missing_value_requires_amount_ - -#ifndef _di_kt_remove_print_error_parameter_no_files_ - f_status_t kt_remove_print_error_parameter_no_files(const fl_print_t print) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - fll_print_format("%[%QNo files have been specified to be removed.%]%r", print.to.stream, print.set->error, print.prefix, print.set->error, f_string_eol_s); - - return F_none; - } -#endif // _di_kt_remove_print_error_parameter_no_files_ - -#ifndef _di_kt_remove_print_error_parameter_unknown_value_ - f_status_t kt_remove_print_error_parameter_unknown_value(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter, const f_string_static_t value) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - flockfile(print.to.stream); - - fl_print_format("%[%QThe parameter%] ", print.to.stream, print.set->error, print.prefix, print.set->error); - fl_print_format("%[%Q%Q%]", print.to.stream, print.set->notable, symbol, parameter, print.set->notable); - fl_print_format("%[ is passed an unknown value '%]", print.to.stream, print.set->error, print.set->error); - fl_print_format("%[%Q%]", print.to.stream, print.set->notable, value, print.set->notable); - fl_print_format("%['.%]%r", print.to.stream, print.set->error, print.set->error, f_string_eol_s); - - funlockfile(print.to.stream); - - return F_none; - } -#endif // _di_kt_remove_print_error_parameter_unknown_value_ - -#ifndef _di_kt_remove_print_help_ - f_status_t kt_remove_print_help(kt_remove_setting_t * const setting, const fl_print_t print, const f_color_context_t context) { - - if (!setting) return F_output_not; - - flockfile(print.to.stream); - - fll_program_print_help_header(print.to, context, *setting->program_name_long, kt_remove_program_version_s); - - fll_program_print_help_option(print.to, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(print.to, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(print.to, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(print.to, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print.to using color."); - fll_program_print_help_option(print.to, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(print.to, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(print.to, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(print.to, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(print.to, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(print.to, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); - - f_print_dynamic_raw(f_string_eol_s, print.to.stream); - - fll_program_print_help_option(print.to, context, kt_remove_short_accessed_s, kt_remove_long_accessed_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove by file last accessed date and time."); - fll_program_print_help_option(print.to, context, kt_remove_short_block_s, kt_remove_long_block_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove by file type of block."); - fll_program_print_help_option(print.to, context, kt_remove_short_character_s, kt_remove_long_character_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Remove by file type of character."); - fll_program_print_help_option(print.to, context, kt_remove_short_created_s, kt_remove_long_created_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove by file created on date and time."); - fll_program_print_help_option(print.to, context, kt_remove_short_different_s, kt_remove_long_different_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Remove by file owner by a user different from the current calling user."); - fll_program_print_help_option(print.to, context, kt_remove_short_directory_s, kt_remove_long_directory_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Remove by file type of directory."); - fll_program_print_help_option(print.to, context, kt_remove_short_empty_s, kt_remove_long_empty_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove directory by a specific empty or not empty state."); - fll_program_print_help_option(print.to, context, kt_remove_short_fifo_s, kt_remove_long_fifo_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove by file type of FIFO."); - fll_program_print_help_option(print.to, context, kt_remove_short_follow_s, kt_remove_long_follow_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove the file being pointed to rather than the symbolic link itself."); - fll_program_print_help_option(print.to, context, kt_remove_short_force_s, kt_remove_long_force_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Forcibly perform remove."); - fll_program_print_help_option(print.to, context, kt_remove_short_group_s, kt_remove_long_group_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove by file group ID or name."); - fll_program_print_help_option(print.to, context, kt_remove_short_isolate_s, kt_remove_long_isolate_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Isolate remove based on filesystem."); - fll_program_print_help_option(print.to, context, kt_remove_short_link_s, kt_remove_long_link_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove by file type of link."); - fll_program_print_help_option(print.to, context, kt_remove_short_mode_s, kt_remove_long_mode_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove by file mode."); - fll_program_print_help_option(print.to, context, kt_remove_short_prompt_s, kt_remove_long_prompt_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Prompt before removing."); - fll_program_print_help_option(print.to, context, kt_remove_short_recurse_s, kt_remove_long_recurse_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Traverse into sub-directories when removing."); - fll_program_print_help_option(print.to, context, kt_remove_short_regular_s, kt_remove_long_regular_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove by file type of regular."); - fll_program_print_help_option(print.to, context, kt_remove_short_same_s, kt_remove_long_same_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove by file owner by the current calling user."); - fll_program_print_help_option(print.to, context, kt_remove_short_simulate_s, kt_remove_long_simulate_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Simulate removal rather than actually removing."); - fll_program_print_help_option(print.to, context, kt_remove_short_socket_s, kt_remove_long_socket_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove by file type of socket."); - fll_program_print_help_option(print.to, context, kt_remove_short_stay_s, kt_remove_long_stay_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove the symbolic link itself rather than the file being pointed to."); - fll_program_print_help_option(print.to, context, kt_remove_short_tree_s, kt_remove_long_tree_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove entire specified directory tree."); - fll_program_print_help_option(print.to, context, kt_remove_short_updated_s, kt_remove_long_updated_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove by file last updated date and time."); - fll_program_print_help_option(print.to, context, kt_remove_short_user_s, kt_remove_long_user_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Remove by file user ID or name."); - - f_print_dynamic_raw(f_string_eol_s, print.to.stream); - - fll_program_print_help_option_long(print.to, context, kt_remove_long_local_s, f_console_symbol_long_enable_s, "Designate dates are in local time, unless time zone is specified."); - fll_program_print_help_option_long(print.to, context, kt_remove_long_utc_s, f_console_symbol_long_enable_s, " Designate dates are in UTC, unless time zone is specified."); - - fll_program_print_help_usage(print.to, context, kt_remove_program_name_s, kt_remove_program_help_parameters_s); - - fl_print_format(" The parameters '%[%r%r%]', ", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_accessed_s, context.set.notable); - fl_print_format("'%[%r%r%]', ", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_created_s, context.set.notable); - fl_print_format("'%[%r%r%]', ", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_group_s, context.set.notable); - fl_print_format("'%[%r%r%]', ", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_mode_s, context.set.notable); - fl_print_format("'%[%r%r%]', and ", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_updated_s, context.set.notable); - fl_print_format("'%[%r%r%]' may be specified multiple times.%r%r", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_user_s, context.set.notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The value passed to the parameter '%[%r%r%]' may either be a ", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_group_s, context.set.notable, f_string_eol_s); - fl_print_format("%[GID%]", print.to.stream, context.set.notable, context.set.notable); - fl_print_format(" or a %[group name%].%r%r", print.to.stream, context.set.notable, context.set.notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The value passed to the parameter '%[%r%r%]' may either be a ", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_user_s, context.set.notable, f_string_eol_s); - fl_print_format("%[UID%]", print.to.stream, context.set.notable, context.set.notable); - fl_print_format(" or a %[user name%].%r%r", print.to.stream, context.set.notable, context.set.notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter '%[%r%r%]' supports the following values:%r", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_empty_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Remove directories that are not empty.%r", print.to.stream, context.set.notable, kt_remove_not_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Fail when attempting to remove directories that are not empty.%r", print.to.stream, context.set.notable, kt_remove_not_fail_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Remove directories that are empty.%r", print.to.stream, context.set.notable, kt_remove_only_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Fail when removing directoies that are empty.%r%r", print.to.stream, context.set.notable, kt_remove_only_fail_s, context.set.notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter '%[%r%r%]' supports the following values:%r", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_isolate_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Isolate to a single file system, error on all files outside of the file system.%r", print.to.stream, context.set.notable, kt_remove_all_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Ignore rather than erroring on problems outside the file system.%r", print.to.stream, context.set.notable, kt_remove_ignore_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Isolate to a single file system, error on '/'.%r%r", print.to.stream, context.set.notable, kt_remove_root_s, context.set.notable, f_string_eol_s, f_string_eol_s); - - // @todo "isolate" needs to optionally pass, ignoring when /proc is not available or fail when /proc is not available. - // @todo "/proc" needs to be configurable define macro and use that string here. - - fl_print_format(" The parameter '%[%r%r%]' supports the following values:%r", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_prompt_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Operate in interactive mode, prompting for every file.%r", print.to.stream, context.set.notable, kt_remove_all_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Operate in interactive mode, prompting for every link that is being followed.%r", print.to.stream, context.set.notable, kt_remove_follow_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Do not operate in interactive mode.%r", print.to.stream, context.set.notable, kt_remove_never_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Operate in interactive mode: prompting if removing 3 or more files.%r%r", print.to.stream, context.set.notable, kt_remove_once_s, context.set.notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The first value to the parameter '%[%r%r%]' must be any of:%r", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_mode_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]'", print.to.stream, context.set.notable, kt_remove_mode_symbol_different_s, context.set.notable); - fl_print_format(" or '%[%r%]': Mode matches different parts.%r", print.to.stream, context.set.notable, kt_remove_mode_word_different_s, context.set.notable, f_string_eol_s); - - fl_print_format(" - '%[%r%]'", print.to.stream, context.set.notable, kt_remove_mode_symbol_same_s, context.set.notable); - fl_print_format(" or '%[%r%]': Mode matches exactly.%r", print.to.stream, context.set.notable, kt_remove_mode_word_same_s, context.set.notable, f_string_eol_s); - - fl_print_format(" - '%[%r%]'", print.to.stream, context.set.notable, kt_remove_mode_symbol_similar_s, context.set.notable); - fl_print_format(" or '%[%r%]': Mode matches the same parts.%r", print.to.stream, context.set.notable, kt_remove_mode_word_similar_s, context.set.notable, f_string_eol_s); - - fl_print_format(" - '%[%r%]'", print.to.stream, context.set.notable, kt_remove_mode_symbol_not_s, context.set.notable); - fl_print_format(" or '%[%r%]': Mode does not match exactly.%r%r", print.to.stream, context.set.notable, kt_remove_mode_word_not_s, context.set.notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The second value to the parameter '%[%r%r%]' may be either a mode octal or a mode string, such as: ", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_mode_s, context.set.notable); - fl_print_format("'%[0751%]'", print.to.stream, context.set.notable, context.set.notable); - fl_print_format(" or '%[u+rwX,g+r%]'.%r%r", print.to.stream, context.set.notable, context.set.notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The date related parameters are: '%[%r%r%]', ", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_accessed_s, context.set.notable); - fl_print_format("'%[%r%r%]', and ", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_created_s, context.set.notable); - fl_print_format("'%[%r%r%]'.%r%r", print.to.stream, context.set.notable, f_console_symbol_long_enable_s, kt_remove_long_updated_s, context.set.notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The first value to the date related parameters must be any of the following comparison operators:%r", print.to.stream, f_string_eol_s); - fl_print_format(" - '%[%r%]'", print.to.stream, context.set.notable, kt_remove_date_symbol_equal_s, context.set.notable); - fl_print_format(" or '%[%r%]': Date match using an equal to operation.%r", print.to.stream, context.set.notable, kt_remove_date_word_equal_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]'", print.to.stream, context.set.notable, kt_remove_date_symbol_less_s, context.set.notable); - fl_print_format(" or '%[%r%]': Date match using a less than operation.%r", print.to.stream, context.set.notable, kt_remove_date_word_less_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]'", print.to.stream, context.set.notable, kt_remove_date_symbol_less_equal_s, context.set.notable); - fl_print_format(" or '%[%r%]': Date match using a less than or equal to operation.%r", print.to.stream, context.set.notable, kt_remove_date_word_less_equal_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]'", print.to.stream, context.set.notable, kt_remove_date_symbol_more_s, context.set.notable); - fl_print_format(" or '%[%r%]': Date match using a more than operation.%r", print.to.stream, context.set.notable, kt_remove_date_word_more_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]'", print.to.stream, context.set.notable, kt_remove_date_symbol_more_equal_s, context.set.notable); - fl_print_format(" or '%[%r%]': Date match using a more than or equal to operation.%r", print.to.stream, context.set.notable, kt_remove_date_word_more_equal_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]'", print.to.stream, context.set.notable, kt_remove_date_symbol_not_s, context.set.notable); - fl_print_format(" or '%[%r%]': Date match using a not equal to operation.%r%r", print.to.stream, context.set.notable, kt_remove_date_word_not_s, context.set.notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When the second value to the date related parameters must be a date.%r%r", print.to.stream, f_string_eol_s, f_string_eol_s); - - fl_print_format(" Valid dates for the date related parameters must be any of the following:%r", print.to.stream, f_string_eol_s); - fl_print_format(" - '%[%r%]': Use the current day and time.%r", print.to.stream, context.set.notable, kt_remove_now_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[Time%]': Use the Time format, such as ", print.to.stream, context.set.notable, context.set.notable); - fl_print_format("'%[1234:5678%]'.%r", print.to.stream, context.set.notable, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[EpochTime%]': Use the EpochTime format, such as ", print.to.stream, context.set.notable, context.set.notable); - fl_print_format("'%[1234::5678%]'.%r", print.to.stream, context.set.notable, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Use the current day.%r", print.to.stream, context.set.notable, kt_remove_today_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Use the next day.%r", print.to.stream, context.set.notable, kt_remove_tomorrow_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[Unix Epoch%]': Use the EpochTime format, such as ", print.to.stream, context.set.notable, context.set.notable); - fl_print_format("'%[1672639985%]'.%r", print.to.stream, context.set.notable, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': Use the previous day.%r%r", print.to.stream, context.set.notable, kt_remove_yesterday_s, context.set.notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" Valid formats for the date related parameters must be any of the following:%r", print.to.stream, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_00_s, context.set.notable, context.set.notable, kt_remove_date_format_example_00_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_01_s, context.set.notable, context.set.notable, kt_remove_date_format_example_01_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_02_s, context.set.notable, context.set.notable, kt_remove_date_format_example_02_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_03_s, context.set.notable, context.set.notable, kt_remove_date_format_example_03_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_04_s, context.set.notable, context.set.notable, kt_remove_date_format_example_04_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_05_s, context.set.notable, context.set.notable, kt_remove_date_format_example_05_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_06_s, context.set.notable, context.set.notable, kt_remove_date_format_example_06_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_07_s, context.set.notable, context.set.notable, kt_remove_date_format_example_07_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_08_s, context.set.notable, context.set.notable, kt_remove_date_format_example_08_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_09_s, context.set.notable, context.set.notable, kt_remove_date_format_example_09_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_10_s, context.set.notable, context.set.notable, kt_remove_date_format_example_10_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_11_s, context.set.notable, context.set.notable, kt_remove_date_format_example_11_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_12_s, context.set.notable, context.set.notable, kt_remove_date_format_example_12_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print.to.stream, context.set.notable, kt_remove_date_format_13_s, context.set.notable, context.set.notable, kt_remove_date_format_example_13_s, context.set.notable, f_string_eol_s); - fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r%r", print.to.stream, context.set.notable, kt_remove_date_format_14_s, context.set.notable, context.set.notable, kt_remove_date_format_example_14_s, context.set.notable, f_string_eol_s, f_string_eol_s); - - fflush(print.to.stream); - funlockfile(print.to.stream); - - return F_none; - } -#endif // _di_kt_remove_print_help_ - -#ifndef _di_kt_remove_print_warning_file_reason_ - f_status_t remove_print_warning_file_reason(kt_remove_setting_t * const setting, const fl_print_t print, const f_string_static_t path, const f_string_static_t reason) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - if (print.verbosity < f_console_verbosity_verbose_e && !(setting->flag & kt_remove_flag_force_e)) { - if (setting) { - if (!(setting->flag & kt_remove_flag_print_warning_e)) return F_output_not; - } - else { - return F_output_not; - } - } - - flockfile(print.to.stream); - - fl_print_format("%[%QUnable to remove file '%]", print.to.stream, print.set->warning, print.prefix, print.set->warning); - fl_print_format("%[%Q%]", print.to.stream, print.set->notable, path, print.set->notable); - fl_print_format("%[', %Q.%]%r", print.to.stream, print.set->warning, reason, print.set->warning, f_string_eol_s); - - funlockfile(print.to.stream); - - return F_none; - } -#endif // _di_kt_remove_print_warning_file_reason_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/sources/c/remove/main/print/error.c b/sources/c/remove/main/print/error.c new file mode 100644 index 0000000..ebcdbc9 --- /dev/null +++ b/sources/c/remove/main/print/error.c @@ -0,0 +1,85 @@ +#include "../remove.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_kt_remove_print_error_ + f_status_t kt_remove_print_error(fl_print_t * const print, const f_string_t function) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + fll_error_print(print, F_status_set_fine(((kt_remove_main_t *) print->custom)->setting.state.status), function, F_true); + + return F_none; + } +#endif // _di_kt_remove_print_error_ + +#ifndef _di_kt_remove_print_error_file_ + f_status_t kt_remove_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + fll_error_file_print(print, F_status_set_fine(((kt_remove_main_t *) print->custom)->setting.state.status), function, F_true, name, operation, type); + + return F_none; + } +#endif // _di_kt_remove_print_error_file_ + +#ifndef _di_kt_remove_print_error_parameter_missing_value_requires_amount_ + f_status_t kt_remove_print_error_parameter_missing_value_requires_amount(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t parameter, const f_number_unsigned_t amount) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe parameter%] ", print->to, print->set->error, print->prefix, print->set->error); + fl_print_format("%[%Q%Q%]", print->to, print->set->notable, symbol, parameter, print->set->notable); + fl_print_format("%[ is specified, but%] ", print->to, print->set->error, print->set->error); + fl_print_format("%[%un%]", print->to, print->set->notable, amount, print->set->notable); + fl_print_format(" %[values are not given.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_kt_remove_print_error_parameter_missing_value_requires_amount_ + +#ifndef _di_kt_remove_print_error_parameter_no_files_ + f_status_t kt_remove_print_error_parameter_no_files(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + fll_print_format("%[%QNo files have been specified to be removed.%]%r", print->to, print->set->error, print->prefix, print->set->error, f_string_eol_s); + + return F_none; + } +#endif // _di_kt_remove_print_error_parameter_no_files_ + +#ifndef _di_kt_remove_print_error_parameter_unknown_value_ + f_status_t kt_remove_print_error_parameter_unknown_value(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t parameter, const f_string_static_t value) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe parameter%] ", print->to, print->set->error, print->prefix, print->set->error); + fl_print_format("%[%Q%Q%]", print->to, print->set->notable, symbol, parameter, print->set->notable); + fl_print_format("%[ is passed an unknown value '%]", print->to, print->set->error, print->set->error); + fl_print_format("%[%Q%]", print->to, print->set->notable, value, print->set->notable); + fl_print_format("%['.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_kt_remove_print_error_parameter_unknown_value_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/remove/main/print.h b/sources/c/remove/main/print/error.h similarity index 51% rename from sources/c/remove/main/print.h rename to sources/c/remove/main/print/error.h index 5a30653..81591fa 100644 --- a/sources/c/remove/main/print.h +++ b/sources/c/remove/main/print/error.h @@ -4,9 +4,13 @@ * Project: Kevux Tools * API Version: 0.5 * Licenses: lgpl-2.1-or-later + * + * Provides the print error functionality. + * + * This is auto-included and should not need to be explicitly included. */ -#ifndef _kt_remove_print_h -#define _kt_remove_print_h +#ifndef _kt_remove_print_error_h +#define _kt_remove_print_error_h #ifdef __cplusplus extern "C" { @@ -15,32 +19,30 @@ extern "C" { /** * Print generic error message regarding a function failing in some way. * - * @param setting - * The main program settings. - * - * This does not alter setting.status. * @param print - * Designates the how and where to print. + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * + * F_output_not (with error bit) if setting is NULL. + * * @see fll_error_print() */ #ifndef _di_kt_remove_print_error_ - extern f_status_t kt_remove_print_error(kt_remove_setting_t * const setting, const fl_print_t print, const f_string_t function); + extern f_status_t kt_remove_print_error(fl_print_t * const print, const f_string_t function); #endif // _di_kt_remove_print_error_ /** * Print file related error or warning messages. * - * @param setting - * The main program settings. - * - * This does not alter setting.status. * @param print - * Designates how printing is to be performed. + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. * @param function * The name of the function where the error happened. * Set to 0 to disable. @@ -55,10 +57,12 @@ extern "C" { * F_none on success. * F_output_not on success, but no printing is performed. * + * F_output_not (with error bit) if setting is NULL. + * * @see fll_error_file_print() */ #ifndef _di_kt_remove_print_error_file_ - extern f_status_t kt_remove_print_error_file(kt_remove_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type); + extern f_status_t kt_remove_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type); #endif // _di_kt_remove_print_error_file_ /** @@ -67,17 +71,20 @@ extern "C" { * This is only printed when verbosity is not set to quiet. * * This uses the following: - * - print.set->error: For the error context. - * - print.set->strong: For the highlighting context + * - print.set.error: For the error context. + * - print.set.strong: For the highlighting context * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). * * @param print - * The output structure. + * The output structure to print to. + * * This locks, uses, and unlocks the file stream. + * + * This does not alter print.custom.setting.state.status. * @param symbol * The symbol string prepended to both parameters. * This locks, uses, and unlocks the file stream. - * This is usually f_console_symbol_long_enable_s. + * This is usually f_console_symbol_long_normal_s. * @param parameter * The parameter name. * @param amount @@ -86,9 +93,15 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see f_file_stream_lock() + * @see f_file_stream_unlock() + * @see fl_print_format() */ #ifndef _di_kt_remove_print_error_parameter_missing_value_requires_amount_ - extern f_status_t kt_remove_print_error_parameter_missing_value_requires_amount(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter, const f_number_unsigned_t amount); + extern f_status_t kt_remove_print_error_parameter_missing_value_requires_amount(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t parameter, const f_number_unsigned_t amount); #endif // _di_kt_remove_print_error_parameter_missing_value_requires_amount_ /** @@ -97,20 +110,27 @@ extern "C" { * This is only printed when verbosity is not set to quiet. * * This uses the following: - * - print.set->error: For the error context. - * - print.set->strong: For the highlighting context + * - print.set.error: For the error context. + * - print.set.strong: For the highlighting context * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). * * @param print - * The output structure. + * The output structure to print to. + * * This locks, uses, and unlocks the file stream. * + * This does not alter print.custom.setting.state.status. + * * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_print_format() */ #ifndef _di_kt_remove_print_error_parameter_no_files_ - extern f_status_t kt_remove_print_error_parameter_no_files(const fl_print_t print); + extern f_status_t kt_remove_print_error_parameter_no_files(fl_print_t * const print); #endif // _di_kt_remove_print_error_parameter_no_files_ /** @@ -119,17 +139,20 @@ extern "C" { * This is only printed when verbosity is not set to quiet. * * This uses the following: - * - print.set->error: For the error context. - * - print.set->strong: For the highlighting context + * - print.set.error: For the error context. + * - print.set.strong: For the highlighting context * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). * * @param print - * The output structure. + * The output structure to print to. + * * This locks, uses, and unlocks the file stream. + * + * This does not alter print.custom.setting.state.status. * @param symbol * The symbol string prepended to both parameters. * This locks, uses, and unlocks the file stream. - * This is usually f_console_symbol_long_enable_s. + * This is usually f_console_symbol_long_normal_s. * @param parameter * The parameter name. * @param value @@ -138,60 +161,19 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. - */ -#ifndef _di_kt_remove_print_error_parameter_unknown_value_ - extern f_status_t kt_remove_print_error_parameter_unknown_value(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter, const f_string_static_t value); -#endif // _di_kt_remove_print_error_parameter_unknown_value_ - -/** - * Print help. - * - * @param setting - * The main program settings. * - * This does not alter setting.status. - * @param print - * Designates how printing is to be performed. - * @param context - * The color context settings. + * F_output_not (with error bit) if setting is NULL. * - * @return - * F_none on success. + * @see f_file_stream_lock() + * @see f_file_stream_unlock() + * @see fl_print_format() */ -#ifndef _di_kt_remove_print_help_ - extern f_status_t kt_remove_print_help(kt_remove_setting_t * const setting, const fl_print_t print, const f_color_context_t context); -#endif // _di_kt_remove_print_help_ - -/** - * 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 uses the following: - * - print.set->warning: For the warning context. - * - print.set->strong: For the highlighting context - * - print.prefix: For the prefixing a string to the message (such as "WARNING:"). - * - * @param print - * The output structure. - * This locks, uses, and unlocks the file stream. - * @param path - * The path to the file. - * @param reason - * The reason for the failure. - * - * @return - * F_none on success. - * F_output_not on success, but no printing is performed. - */ -#ifndef _di_kt_remove_print_warning_file_reason_ - extern f_status_t remove_print_warning_file_reason(kt_remove_setting_t * const setting, const fl_print_t print, const f_string_static_t path, const f_string_static_t reason); -#endif // _di_kt_remove_print_warning_file_reason_ +#ifndef _di_kt_remove_print_error_parameter_unknown_value_ + extern f_status_t kt_remove_print_error_parameter_unknown_value(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t parameter, const f_string_static_t value); +#endif // _di_kt_remove_print_error_parameter_unknown_value_ #ifdef __cplusplus } // extern "C" #endif -#endif // _kt_remove_print_h +#endif // _kt_remove_print_error_h diff --git a/sources/c/remove/main/print/message.c b/sources/c/remove/main/print/message.c new file mode 100644 index 0000000..10bbdab --- /dev/null +++ b/sources/c/remove/main/print/message.c @@ -0,0 +1,178 @@ +#include "../remove.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_kt_remove_print_message_help_ + f_status_t kt_remove_print_message_help(fl_print_t * const print, const f_color_context_t context) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; + + f_file_stream_lock(print->to); + + fll_program_print_help_header( + print, + main->setting.program_name_long + ? *main->setting.program_name_long + : kt_remove_program_name_long_s, + kt_remove_program_version_s + ); + + fll_program_print_help_option_standard(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_option(print, kt_remove_short_accessed_s, kt_remove_long_accessed_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove by file last accessed date and time."); + fll_program_print_help_option(print, kt_remove_short_block_s, kt_remove_long_block_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove by file type of block."); + fll_program_print_help_option(print, kt_remove_short_character_s, kt_remove_long_character_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Remove by file type of character."); + fll_program_print_help_option(print, kt_remove_short_created_s, kt_remove_long_created_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove by file created on date and time."); + fll_program_print_help_option(print, kt_remove_short_different_s, kt_remove_long_different_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Remove by file owner by a user different from the current calling user."); + fll_program_print_help_option(print, kt_remove_short_directory_s, kt_remove_long_directory_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Remove by file type of directory."); + fll_program_print_help_option(print, kt_remove_short_empty_s, kt_remove_long_empty_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove directory by a specific empty or not empty state."); + fll_program_print_help_option(print, kt_remove_short_fifo_s, kt_remove_long_fifo_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove by file type of FIFO."); + fll_program_print_help_option(print, kt_remove_short_follow_s, kt_remove_long_follow_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove the file being pointed to rather than the symbolic link itself."); + fll_program_print_help_option(print, kt_remove_short_force_s, kt_remove_long_force_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Forcibly perform remove."); + fll_program_print_help_option(print, kt_remove_short_group_s, kt_remove_long_group_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove by file group ID or name."); + fll_program_print_help_option(print, kt_remove_short_isolate_s, kt_remove_long_isolate_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Isolate remove based on filesystem."); + fll_program_print_help_option(print, kt_remove_short_link_s, kt_remove_long_link_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove by file type of link."); + fll_program_print_help_option(print, kt_remove_short_mode_s, kt_remove_long_mode_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove by file mode."); + fll_program_print_help_option(print, kt_remove_short_prompt_s, kt_remove_long_prompt_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Prompt before removing."); + fll_program_print_help_option(print, kt_remove_short_recurse_s, kt_remove_long_recurse_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Traverse into sub-directories when removing."); + fll_program_print_help_option(print, kt_remove_short_regular_s, kt_remove_long_regular_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove by file type of regular."); + fll_program_print_help_option(print, kt_remove_short_same_s, kt_remove_long_same_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove by file owner by the current calling user."); + fll_program_print_help_option(print, kt_remove_short_simulate_s, kt_remove_long_simulate_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Simulate removal rather than actually removing."); + fll_program_print_help_option(print, kt_remove_short_socket_s, kt_remove_long_socket_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove by file type of socket."); + fll_program_print_help_option(print, kt_remove_short_stay_s, kt_remove_long_stay_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove the symbolic link itself rather than the file being pointed to."); + fll_program_print_help_option(print, kt_remove_short_tree_s, kt_remove_long_tree_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove entire specified directory tree."); + fll_program_print_help_option(print, kt_remove_short_updated_s, kt_remove_long_updated_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove by file last updated date and time."); + fll_program_print_help_option(print, kt_remove_short_user_s, kt_remove_long_user_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Remove by file user ID or name."); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_option_long(print, kt_remove_long_local_s, f_console_symbol_long_normal_s, "Designate dates are in local time, unless time zone is specified."); + fll_program_print_help_option_long(print, kt_remove_long_utc_s, f_console_symbol_long_normal_s, " Designate dates are in UTC, unless time zone is specified."); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage( + print, + main->setting.program_name + ? *main->setting.program_name + : kt_remove_program_name_s, + kt_remove_program_help_parameters_s + ); + + fl_print_format(" The parameters '%[%r%r%]', ", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_accessed_s, context.set.notable); + fl_print_format("'%[%r%r%]', ", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_created_s, context.set.notable); + fl_print_format("'%[%r%r%]', ", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_group_s, context.set.notable); + fl_print_format("'%[%r%r%]', ", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_mode_s, context.set.notable); + fl_print_format("'%[%r%r%]', and ", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_updated_s, context.set.notable); + fl_print_format("'%[%r%r%]' may be specified multiple times.%r%r", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_user_s, context.set.notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The value passed to the parameter '%[%r%r%]' may either be a ", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_group_s, context.set.notable, f_string_eol_s); + fl_print_format("%[GID%]", print->to, context.set.notable, context.set.notable); + fl_print_format(" or a %[group name%].%r%r", print->to, context.set.notable, context.set.notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The value passed to the parameter '%[%r%r%]' may either be a ", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_user_s, context.set.notable, f_string_eol_s); + fl_print_format("%[UID%]", print->to, context.set.notable, context.set.notable); + fl_print_format(" or a %[user name%].%r%r", print->to, context.set.notable, context.set.notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The parameter '%[%r%r%]' supports the following values:%r", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_empty_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Remove directories that are not empty.%r", print->to, context.set.notable, kt_remove_not_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Fail when attempting to remove directories that are not empty.%r", print->to, context.set.notable, kt_remove_not_fail_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Remove directories that are empty.%r", print->to, context.set.notable, kt_remove_only_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Fail when removing directoies that are empty.%r%r", print->to, context.set.notable, kt_remove_only_fail_s, context.set.notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The parameter '%[%r%r%]' supports the following values:%r", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_isolate_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Isolate to a single file system, error on all files outside of the file system.%r", print->to, context.set.notable, kt_remove_all_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Ignore rather than erroring on problems outside the file system.%r", print->to, context.set.notable, kt_remove_ignore_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Isolate to a single file system, error on '/'.%r%r", print->to, context.set.notable, kt_remove_root_s, context.set.notable, f_string_eol_s, f_string_eol_s); + + // @todo "isolate" needs to optionally pass, ignoring when /proc is not available or fail when /proc is not available. + // @todo "/proc" needs to be configurable define macro and use that string here. + + fl_print_format(" The parameter '%[%r%r%]' supports the following values:%r", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_prompt_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Operate in interactive mode, prompting for every file.%r", print->to, context.set.notable, kt_remove_all_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Operate in interactive mode, prompting for every link that is being followed.%r", print->to, context.set.notable, kt_remove_follow_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Do not operate in interactive mode.%r", print->to, context.set.notable, kt_remove_never_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Operate in interactive mode: prompting if removing 3 or more files.%r%r", print->to, context.set.notable, kt_remove_once_s, context.set.notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The first value to the parameter '%[%r%r%]' must be any of:%r", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_mode_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]'", print->to, context.set.notable, kt_remove_mode_symbol_different_s, context.set.notable); + fl_print_format(" or '%[%r%]': Mode matches different parts.%r", print->to, context.set.notable, kt_remove_mode_word_different_s, context.set.notable, f_string_eol_s); + + fl_print_format(" - '%[%r%]'", print->to, context.set.notable, kt_remove_mode_symbol_same_s, context.set.notable); + fl_print_format(" or '%[%r%]': Mode matches exactly.%r", print->to, context.set.notable, kt_remove_mode_word_same_s, context.set.notable, f_string_eol_s); + + fl_print_format(" - '%[%r%]'", print->to, context.set.notable, kt_remove_mode_symbol_similar_s, context.set.notable); + fl_print_format(" or '%[%r%]': Mode matches the same parts.%r", print->to, context.set.notable, kt_remove_mode_word_similar_s, context.set.notable, f_string_eol_s); + + fl_print_format(" - '%[%r%]'", print->to, context.set.notable, kt_remove_mode_symbol_not_s, context.set.notable); + fl_print_format(" or '%[%r%]': Mode does not match exactly.%r%r", print->to, context.set.notable, kt_remove_mode_word_not_s, context.set.notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The second value to the parameter '%[%r%r%]' may be either a mode octal or a mode string, such as: ", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_mode_s, context.set.notable); + fl_print_format("'%[0751%]'", print->to, context.set.notable, context.set.notable); + fl_print_format(" or '%[u+rwX,g+r%]'.%r%r", print->to, context.set.notable, context.set.notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The date related parameters are: '%[%r%r%]', ", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_accessed_s, context.set.notable); + fl_print_format("'%[%r%r%]', and ", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_created_s, context.set.notable); + fl_print_format("'%[%r%r%]'.%r%r", print->to, context.set.notable, f_console_symbol_long_normal_s, kt_remove_long_updated_s, context.set.notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The first value to the date related parameters must be any of the following comparison operators:%r", print->to, f_string_eol_s); + fl_print_format(" - '%[%r%]'", print->to, context.set.notable, kt_remove_date_symbol_equal_s, context.set.notable); + fl_print_format(" or '%[%r%]': Date match using an equal to operation.%r", print->to, context.set.notable, kt_remove_date_word_equal_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]'", print->to, context.set.notable, kt_remove_date_symbol_less_s, context.set.notable); + fl_print_format(" or '%[%r%]': Date match using a less than operation.%r", print->to, context.set.notable, kt_remove_date_word_less_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]'", print->to, context.set.notable, kt_remove_date_symbol_less_equal_s, context.set.notable); + fl_print_format(" or '%[%r%]': Date match using a less than or equal to operation.%r", print->to, context.set.notable, kt_remove_date_word_less_equal_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]'", print->to, context.set.notable, kt_remove_date_symbol_more_s, context.set.notable); + fl_print_format(" or '%[%r%]': Date match using a more than operation.%r", print->to, context.set.notable, kt_remove_date_word_more_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]'", print->to, context.set.notable, kt_remove_date_symbol_more_equal_s, context.set.notable); + fl_print_format(" or '%[%r%]': Date match using a more than or equal to operation.%r", print->to, context.set.notable, kt_remove_date_word_more_equal_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]'", print->to, context.set.notable, kt_remove_date_symbol_not_s, context.set.notable); + fl_print_format(" or '%[%r%]': Date match using a not equal to operation.%r%r", print->to, context.set.notable, kt_remove_date_word_not_s, context.set.notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" When the second value to the date related parameters must be a date.%r%r", print->to, f_string_eol_s, f_string_eol_s); + + fl_print_format(" Valid dates for the date related parameters must be any of the following:%r", print->to, f_string_eol_s); + fl_print_format(" - '%[%r%]': Use the current day and time.%r", print->to, context.set.notable, kt_remove_now_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[Time%]': Use the Time format, such as ", print->to, context.set.notable, context.set.notable); + fl_print_format("'%[1234:5678%]'.%r", print->to, context.set.notable, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[EpochTime%]': Use the EpochTime format, such as ", print->to, context.set.notable, context.set.notable); + fl_print_format("'%[1234::5678%]'.%r", print->to, context.set.notable, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Use the current day.%r", print->to, context.set.notable, kt_remove_today_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Use the next day.%r", print->to, context.set.notable, kt_remove_tomorrow_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[Unix Epoch%]': Use the EpochTime format, such as ", print->to, context.set.notable, context.set.notable); + fl_print_format("'%[1672639985%]'.%r", print->to, context.set.notable, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': Use the previous day.%r%r", print->to, context.set.notable, kt_remove_yesterday_s, context.set.notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" Valid formats for the date related parameters must be any of the following:%r", print->to, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_00_s, context.set.notable, context.set.notable, kt_remove_date_format_example_00_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_01_s, context.set.notable, context.set.notable, kt_remove_date_format_example_01_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_02_s, context.set.notable, context.set.notable, kt_remove_date_format_example_02_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_03_s, context.set.notable, context.set.notable, kt_remove_date_format_example_03_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_04_s, context.set.notable, context.set.notable, kt_remove_date_format_example_04_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_05_s, context.set.notable, context.set.notable, kt_remove_date_format_example_05_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_06_s, context.set.notable, context.set.notable, kt_remove_date_format_example_06_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_07_s, context.set.notable, context.set.notable, kt_remove_date_format_example_07_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_08_s, context.set.notable, context.set.notable, kt_remove_date_format_example_08_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_09_s, context.set.notable, context.set.notable, kt_remove_date_format_example_09_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_10_s, context.set.notable, context.set.notable, kt_remove_date_format_example_10_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_11_s, context.set.notable, context.set.notable, kt_remove_date_format_example_11_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_12_s, context.set.notable, context.set.notable, kt_remove_date_format_example_12_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_13_s, context.set.notable, context.set.notable, kt_remove_date_format_example_13_s, context.set.notable, f_string_eol_s); + fl_print_format(" - '%[%r%]': A date like '%[%r%]'.%r", print->to, context.set.notable, kt_remove_date_format_14_s, context.set.notable, context.set.notable, kt_remove_date_format_example_14_s, context.set.notable, f_string_eol_s); + + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_kt_remove_print_message_help_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/remove/main/print/message.h b/sources/c/remove/main/print/message.h new file mode 100644 index 0000000..e4bc8ea --- /dev/null +++ b/sources/c/remove/main/print/message.h @@ -0,0 +1,54 @@ +/** + * Kevux Tools - Remove + * + * Project: Kevux Tools + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Provides the print message functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _kt_remove_print_message_h +#define _kt_remove_print_message_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print help. + * + * @param print + * The output structure to print to. + * + * This locks, uses, and unlocks the file stream. + * + * This does not alter print.custom.setting.state.status. + * @param context + * The color context settings. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see f_file_stream_flush() + * @see f_file_stream_lock() + * @see f_file_stream_unlock() + * @see f_print_dynamic_raw() + * @see fl_print_format() + * @see fll_program_print_help_header() + * @see fll_program_print_help_option() + * @see fll_program_print_help_option_long() + */ +#ifndef _di_kt_remove_print_message_help_ + extern f_status_t kt_remove_print_message_help(fl_print_t * const print, const f_color_context_t context); +#endif // _di_kt_remove_print_message_help_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _kt_remove_print_message_h diff --git a/sources/c/remove/main/simulate.c b/sources/c/remove/main/print/simulate.c similarity index 53% rename from sources/c/remove/main/simulate.c rename to sources/c/remove/main/print/simulate.c index 8c99117..659e6e6 100644 --- a/sources/c/remove/main/simulate.c +++ b/sources/c/remove/main/print/simulate.c @@ -1,47 +1,56 @@ -#include "remove.h" +#include "../remove.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_kt_remove_simulate_operate_ - void kt_remove_simulate_operate(fll_program_data_t * const main, kt_remove_setting_t * const setting) { +#ifndef _di_kt_remove_print_simulate_operate_ + void kt_remove_print_simulate_operate(fl_print_t * const print) { - if (!main || !setting) return; - if (!(setting->flag & kt_remove_flag_simulate_e)) return; + if (!print || !print->custom) return; - flockfile(main->output.to.stream); + kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; - fl_print_format("%r%[Files to Remove%]:%r", main->output.to.stream, f_string_eol_s, main->output.set->title, main->output.set->title, f_string_eol_s); + if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) return; - for (f_array_length_t i = 0; i < setting->files.used; ++i) { - fl_print_format(" %Q%r", main->output.to.stream, setting->files.array[i], f_string_eol_s); + f_file_stream_lock(print->to); + + fl_print_format("%r%[Files to Remove%]:%r", print->to, f_string_eol_s, print->set->title, print->set->title, f_string_eol_s); + + for (f_array_length_t i = 0; i < main->setting.files.used; ++i) { + fl_print_format(" %Q%r", print->to, main->setting.files.array[i], f_string_eol_s); } // for - f_print_dynamic(f_string_eol_s, main->output.to.stream); + f_print_dynamic(f_string_eol_s, print->to); - funlockfile(main->output.to.stream); + f_file_stream_unlock(main->program.output.to); } -#endif // _di_kt_remove_simulate_operate_ +#endif // _di_kt_remove_print_simulate_operate_ + +#ifndef _di_kt_remove_print_simulate_operate_file_ + void kt_remove_print_simulate_operate_file(fl_print_t * const print, const f_string_static_t path) { -#ifndef _di_kt_remove_simulate_operate_file_ - void kt_remove_simulate_operate_file(fll_program_data_t * const main, kt_remove_setting_t * const setting, const f_string_static_t path) { + if (!print || !print->custom) return; - if (!main || !setting) return; - if (!(setting->flag & kt_remove_flag_simulate_e)) return; + kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; - fll_print_format("%[Remove '%Q'%]:%r", main->output.to.stream, main->output.set->notable, path, main->output.set->notable, f_string_eol_s); + if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) 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); } -#endif // _di_kt_remove_simulate_operate_file_ +#endif // _di_kt_remove_print_simulate_operate_file_ + +#ifndef _di_kt_remove_print_simulate_operate_file_exists_ + void kt_remove_print_simulate_operate_file_exists(fl_print_t * const print, const f_string_static_t path) { -#ifndef _di_kt_remove_simulate_operate_file_exists_ - void kt_remove_simulate_operate_file_exists(fll_program_data_t * const main, kt_remove_setting_t * const setting, const f_string_static_t path) { + if (!print || !print->custom) return; - if (!main || !setting) return; - if (!(setting->flag & kt_remove_flag_simulate_e)) return; + kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; - if (F_status_is_error(setting->status)) { - fl_print_format(" file_access_failure %ui%r", main->output.to.stream, F_status_set_fine(setting->status), f_string_eol_s); + if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) 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); return; } @@ -50,126 +59,129 @@ extern "C" { if (F_status_is_error(status) && F_status_set_fine(status) != F_file_found_not) { - fl_print_format(" file_read_failure %ui%r", main->output.to.stream, F_status_set_fine(status), f_string_eol_s); + fl_print_format(" file_read_failure %ui%r", main->program.output.to, F_status_set_fine(status), f_string_eol_s); return; } if (status == F_true) { - setting->buffer.used = 0; + main->setting.buffer.used = 0; - status = f_file_link_read(path, F_false, &setting->buffer); + status = f_file_link_read(path, F_false, &main->setting.buffer); if (F_status_is_error(status)) { - fl_print_format(" link_read_failure %ui%r", main->output.to.stream, F_status_set_fine(status), f_string_eol_s); + fl_print_format(" link_read_failure %ui%r", main->program.output.to, F_status_set_fine(status), f_string_eol_s); return; } - flockfile(main->output.to.stream); + f_file_stream_lock(main->program.output.to); - fl_print_format(" follow %Q%r", main->output.to.stream, (setting->flag & kt_remove_flag_follow_e) ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); - fl_print_format(" to '%Q'%r", main->output.to.stream, setting->buffer, f_string_eol_s); + 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(" to '%Q'%r", main->program.output.to, main->setting.buffer, f_string_eol_s); - funlockfile(main->output.to.stream); + f_file_stream_unlock(main->program.output.to); } - fll_print_format(" exists %Q%r", main->output.to.stream, setting->status == F_true ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); + fll_print_format(" exists %r%r", main->program.output.to, main->setting.state.status == F_true ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); } -#endif // _di_kt_remove_simulate_operate_file_exists_ +#endif // _di_kt_remove_print_simulate_operate_file_exists_ + +#ifndef _di_kt_remove_print_simulate_operate_file_stat_ + void kt_remove_print_simulate_operate_file_stat(fl_print_t * const print, struct stat statistics) { -#ifndef _di_kt_remove_simulate_operate_file_stat_ - void kt_remove_simulate_operate_file_stat(fll_program_data_t * const main, kt_remove_setting_t * const setting, struct stat statistics) { + if (!print || !print->custom) return; - if (!main || !setting) return; - if (!(setting->flag & kt_remove_flag_simulate_e)) return; + kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; - if (setting->flag & kt_remove_flag_block_e) { - fll_print_format(" block %Q%r", main->output.to.stream, (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_simulate_e)) return; + + if (main->setting.flag & kt_remove_main_flag_block_e) { + 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 (setting->flag & kt_remove_flag_character_e) { - fll_print_format(" character %Q%r", main->output.to.stream, (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_character_e) { + 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 (setting->flag & kt_remove_flag_directory_e) { - fll_print_format(" directory %Q%r", main->output.to.stream, (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_directory_e) { + 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 (setting->flag & kt_remove_flag_fifo_e) { - fll_print_format(" fifo %Q%r", main->output.to.stream, (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_fifo_e) { + 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 (setting->flag & kt_remove_flag_link_e) { - fll_print_format(" link %Q%r", main->output.to.stream, (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_link_e) { + 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 (setting->flag & kt_remove_flag_regular_e) { - fll_print_format(" regular %Q%r", main->output.to.stream, (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_regular_e) { + 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 (setting->flag & kt_remove_flag_socket_e) { - fll_print_format(" socket %Q%r", main->output.to.stream, (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); + if (main->setting.flag & kt_remove_main_flag_socket_e) { + 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_array_length_t i = 0; - if (setting->flag & kt_remove_flag_user_e) { - for (; i < setting->users.used; ++i) { - if (statistics.st_uid == (uid_t) setting->users.array[i]) break; + if (main->setting.flag & kt_remove_main_flag_user_e) { + for (; i < main->setting.users.used; ++i) { + if (statistics.st_uid == (uid_t) main->setting.users.array[i]) break; } // for - if (i == setting->users.used) { - fll_print_format(" user%r", main->output.to.stream, f_string_eol_s); + if (i == main->setting.users.used) { + fll_print_format(" user%r", main->program.output.to, f_string_eol_s); } else { - fll_print_format(" user %un%r", main->output.to.stream, (f_number_unsigned_t) statistics.st_uid, f_string_eol_s); + fll_print_format(" user %un%r", main->program.output.to, (f_number_unsigned_t) statistics.st_uid, f_string_eol_s); } } - if (setting->flag & kt_remove_flag_same_e) { - fll_print_format(" same %Q%r", main->output.to.stream, (statistics.st_uid == geteuid()) ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); + if (main->setting.flag & kt_remove_main_flag_same_e) { + 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 (setting->flag & kt_remove_flag_different_e) { - fll_print_format(" different %Q%r", main->output.to.stream, (statistics.st_uid == geteuid()) ? kt_remove_no_s : kt_remove_yes_s, f_string_eol_s); + if (main->setting.flag & kt_remove_main_flag_different_e) { + 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 (setting->flag & kt_remove_flag_group_e) { - for (i = 0; i < setting->groups.used; ++i) { - if (statistics.st_gid == (gid_t) setting->groups.array[i]) break; + if (main->setting.flag & kt_remove_main_flag_group_e) { + for (i = 0; i < main->setting.groups.used; ++i) { + if (statistics.st_gid == (gid_t) main->setting.groups.array[i]) break; } // for - if (i == setting->groups.used) { - fll_print_format(" group%r", main->output.to.stream, f_string_eol_s); + if (i == main->setting.groups.used) { + fll_print_format(" group%r", main->program.output.to, f_string_eol_s); } else { - fll_print_format(" group %un%r", main->output.to.stream, (f_number_unsigned_t) statistics.st_gid, f_string_eol_s); + fll_print_format(" group %un%r", main->program.output.to, (f_number_unsigned_t) statistics.st_gid, f_string_eol_s); } } - if (setting->flag & kt_remove_flag_mode_e) { + if (main->setting.flag & kt_remove_main_flag_mode_e) { const mode_t mode = statistics.st_mode & F_file_mode_all_d; - fll_print_format(" mode %@03un%r", main->output.to.stream, (f_number_unsigned_t) mode, f_string_eol_s); + fll_print_format(" mode %@03un%r", main->program.output.to, (f_number_unsigned_t) mode, f_string_eol_s); - for (i = 0; i < setting->modes.used; ++i) { + for (i = 0; i < main->setting.modes.used; ++i) { - if (setting->modes.array[i].type == kt_remove_flag_mode_different_e) { - if (setting->modes.array[i].mode & ~mode) break; + if (main->setting.modes.array[i].type == kt_remove_flag_mode_different_e) { + if (main->setting.modes.array[i].mode & ~mode) break; } - else if (setting->modes.array[i].type == kt_remove_flag_mode_same_e) { - if (setting->modes.array[i].mode == mode) break; + else if (main->setting.modes.array[i].type == kt_remove_flag_mode_same_e) { + if (main->setting.modes.array[i].mode == mode) break; } - else if (setting->modes.array[i].type == kt_remove_flag_mode_similar_e) { - if (setting->modes.array[i].mode & mode) break; + else if (main->setting.modes.array[i].type == kt_remove_flag_mode_similar_e) { + if (main->setting.modes.array[i].mode & mode) break; } - else if (setting->modes.array[i].type == kt_remove_flag_mode_not_e) { - if (setting->modes.array[i].mode != mode) break; + else if (main->setting.modes.array[i].type == kt_remove_flag_mode_not_e) { + if (main->setting.modes.array[i].mode != mode) break; } } // for - if (i < setting->modes.used) { + if (i < main->setting.modes.used) { uint8_t types[] = { kt_remove_flag_mode_different_e, kt_remove_flag_mode_same_e, @@ -186,8 +198,8 @@ extern "C" { for (uint8_t j = 0; j < 4; ++j) { - if (setting->modes.array[i].type == types[j]) { - fll_print_format(" mode_matched %Q %@03un%r", main->output.to.stream, strings[j], (f_number_unsigned_t) setting->modes.array[i].mode, f_string_eol_s); + if (main->setting.modes.array[i].type == types[j]) { + fll_print_format(" mode_matched %Q %@03un%r", main->program.output.to, strings[j], (f_number_unsigned_t) main->setting.modes.array[i].mode, f_string_eol_s); break; } @@ -197,9 +209,9 @@ extern "C" { { kt_remove_dates_t * const dates[] = { - &setting->accessed, - &setting->created, - &setting->updated, + &main->setting.accessed, + &main->setting.created, + &main->setting.updated, }; struct timespec times[] = { @@ -420,9 +432,9 @@ extern "C" { } if (name_type.used) { - fll_print_format(" %Q %Q ", main->output.to.stream, *names[p], result ? kt_remove_yes_s : kt_remove_no_s); - fll_print_format("%u::%un 0:%un %Q ", main->output.to.stream, match_year, (f_number_unsigned_t) times[p].tv_sec, (f_number_unsigned_t) times[p].tv_nsec, name_type); - fll_print_format("%u::%un 0:%un%r", main->output.to.stream, dates[p]->array[i].start_year, dates[p]->array[i].start_second, dates[p]->array[i].start_nanosecond, f_string_eol_s); + fll_print_format(" %Q %Q ", main->program.output.to, *names[p], result ? kt_remove_yes_s : kt_remove_no_s); + fll_print_format("%u::%un 0:%un %Q ", main->program.output.to, match_year, (f_number_unsigned_t) times[p].tv_sec, (f_number_unsigned_t) times[p].tv_nsec, name_type); + fll_print_format("%u::%un 0:%un%r", main->program.output.to, dates[p]->array[i].start_year, dates[p]->array[i].start_second, dates[p]->array[i].start_nanosecond, f_string_eol_s); break; } @@ -430,43 +442,20 @@ extern "C" { } // for } } -#endif // _di_kt_remove_simulate_operate_file_stat_ - -#ifndef _di_kt_remove_simulate_operate_remove_force_yes_ - void kt_remove_simulate_operate_remove_force_yes(fll_program_data_t * const main, kt_remove_setting_t * const setting) { - - if (!(setting->flag & kt_remove_flag_simulate_e)) return; - - fll_print_format(" force yes%r", main->output.to.stream, f_string_eol_s); - } -#endif // _di_kt_remove_simulate_operate_remove_force_yes_ +#endif // _di_kt_remove_print_simulate_operate_file_stat_ -#ifndef _di_kt_remove_simulate_operate_remove_force_no_ - void kt_remove_simulate_operate_remove_force_no(fll_program_data_t * const main, kt_remove_setting_t * const setting) { +#ifndef _di_kt_remove_print_simulate_operate_remove_ + void kt_remove_print_simulate_operate_remove(fl_print_t * const print, const bool yes, const bool force) { - if (!(setting->flag & kt_remove_flag_simulate_e)) return; - - fll_print_format(" force no%r", main->output.to.stream, f_string_eol_s); - } -#endif // _di_kt_remove_simulate_operate_remove_force_no_ - -#ifndef _di_kt_remove_simulate_operate_remove_yes_ - void kt_remove_simulate_operate_remove_yes(fll_program_data_t * const main, kt_remove_setting_t * const setting) { - - if (!(setting->flag & kt_remove_flag_simulate_e)) return; - - fll_print_format(" remove yes%r", main->output.to.stream, f_string_eol_s); - } -#endif // _di_kt_remove_simulate_operate_remove_yes_ + if (!print || !print->custom) return; -#ifndef _di_kt_remove_simulate_operate_remove_no_ - void kt_remove_simulate_operate_remove_no(fll_program_data_t * const main, kt_remove_setting_t * const setting) { + kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; - if (!(setting->flag & kt_remove_flag_simulate_e)) return; + if (!(main->setting.flag & kt_remove_main_flag_simulate_e)) return; - fll_print_format(" remove no%r", main->output.to.stream, f_string_eol_s); + fll_print_format(" %r %r%r", main->program.output.to, force ? kt_remove_force_s : kt_remove_remove_s, yes ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); } -#endif // _di_kt_remove_simulate_operate_remove_no_ +#endif // _di_kt_remove_print_simulate_operate_remove_ #ifdef __cplusplus } // extern "C" diff --git a/sources/c/remove/main/print/simulate.h b/sources/c/remove/main/print/simulate.h new file mode 100644 index 0000000..43bf79b --- /dev/null +++ b/sources/c/remove/main/print/simulate.h @@ -0,0 +1,115 @@ +/** + * Kevux Tools - Remove + * + * Project: Kevux Tools + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Provides the print simulate functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _kt_remove_print_simulate_h +#define _kt_remove_print_simulate_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Simulate operate. + * + * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. + * + * @param print + * The output structure to print to. + * + * This locks, uses, and unlocks the file stream. + * + * This does not alter print.custom.setting.state.status. + */ +#ifndef _di_kt_remove_print_simulate_operate_ + extern void kt_remove_print_simulate_operate(fl_print_t * const print); +#endif // _di_kt_remove_print_simulate_operate_ + +/** + * Simulate operate on a single file. + * + * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. + * + * @param print + * The output structure to print to. + * + * This locks, uses, and unlocks the file stream. + * + * This does not alter print.custom.setting.state.status. + * @param path + * The path to the file to operate on. + */ +#ifndef _di_kt_remove_print_simulate_operate_file_ + extern void kt_remove_print_simulate_operate_file(fl_print_t * const print, const f_string_static_t path); +#endif // _di_kt_remove_print_simulate_operate_file_ + +/** + * Simulate operate on a single file, processing file existence. + * + * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. + * + * @param print + * The output structure to print to. + * + * This locks, uses, and unlocks the file stream. + * + * This does not alter print.custom.setting.state.status. + * @param path + * The path to the file to operate on. + */ +#ifndef _di_kt_remove_print_simulate_operate_file_exists_ + extern void kt_remove_print_simulate_operate_file_exists(fl_print_t * const print, const f_string_static_t path); +#endif // _di_kt_remove_print_simulate_operate_file_exists_ + +/** + * Simulate operate on a single file, processing file statistics. + * + * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. + * + * @param print + * The output structure to print to. + * + * This locks, uses, and unlocks the file stream. + * + * This does not alter print.custom.setting.state.status. + * @param statistics + * The file statistics. + */ +#ifndef _di_kt_remove_print_simulate_operate_file_stat_ + extern void kt_remove_print_simulate_operate_file_stat(fl_print_t * const print, struct stat statistics); +#endif // _di_kt_remove_print_simulate_operate_file_stat_ + +/** + * Simulate operate on a single file, designate that file is to be removed or not removed (forcibly or otherwise). + * + * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. + * + * @param print + * The output structure to print to. + * + * This locks, uses, and unlocks the file stream. + * + * This does not alter print.custom.setting.state.status. + * @param yes + * If TRUE, then this is to be removed. + * If FALSE, then this is not to be removed. + * @param force + * If TRUE, then this prints a message about being forced. + * If FALSE, then this prints a message about being removed. + */ +#ifndef _di_kt_remove_print_simulate_operate_remove_ + extern void kt_remove_print_simulate_operate_remove(fl_print_t * const print, const bool yes, const bool force); +#endif // _di_kt_remove_print_simulate_operate_remove_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _kt_remove_print_simulate_h diff --git a/sources/c/remove/main/print/verbose.c b/sources/c/remove/main/print/verbose.c new file mode 100644 index 0000000..7a21078 --- /dev/null +++ b/sources/c/remove/main/print/verbose.c @@ -0,0 +1,9 @@ +#include "../remove.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/remove/main/print/verbose.h b/sources/c/remove/main/print/verbose.h new file mode 100644 index 0000000..8fb3661 --- /dev/null +++ b/sources/c/remove/main/print/verbose.h @@ -0,0 +1,23 @@ +/** + * Kevux Tools - Remove + * + * Project: Kevux Tools + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Provides the print verbose functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _kt_remove_print_verbose_h +#define _kt_remove_print_verbose_h + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _kt_remove_print_verbose_h diff --git a/sources/c/remove/main/print/warning.c b/sources/c/remove/main/print/warning.c new file mode 100644 index 0000000..38cea8e --- /dev/null +++ b/sources/c/remove/main/print/warning.c @@ -0,0 +1,30 @@ +#include "../remove.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_kt_remove_print_warning_file_reason_ + f_status_t remove_print_warning_file_reason(fl_print_t * const print, const f_string_static_t path, const f_string_static_t reason) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + 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; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QUnable to remove file '%]", print->to, print->set->warning, print->prefix, print->set->warning); + fl_print_format("%[%Q%]", print->to, print->set->notable, path, print->set->notable); + fl_print_format("%[', %Q.%]%r", print->to, print->set->warning, reason, print->set->warning, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_kt_remove_print_warning_file_reason_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/remove/main/print/warning.h b/sources/c/remove/main/print/warning.h new file mode 100644 index 0000000..cbfa299 --- /dev/null +++ b/sources/c/remove/main/print/warning.h @@ -0,0 +1,54 @@ +/** + * Kevux Tools - Remove + * + * Project: Kevux Tools + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Provides the print warning functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _kt_remove_print_warning_h +#define _kt_remove_print_warning_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * 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 uses the following: + * - print.set->warning: For the warning context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "WARNING:"). + * + * @param print + * The output structure to print to. + * + * This locks, uses, and unlocks the file stream. + * + * This does not alter print.custom.setting.state.status. + * @param path + * The path to the file. + * @param reason + * The reason for the failure. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_kt_remove_print_warning_file_reason_ + extern f_status_t remove_print_warning_file_reason(fl_print_t * const print, const f_string_static_t path, const f_string_static_t reason); +#endif // _di_kt_remove_print_warning_file_reason_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _kt_remove_print_warning_h diff --git a/sources/c/remove/main/remove.c b/sources/c/remove/main/remove.c index 44ed445..5cfa766 100644 --- a/sources/c/remove/main/remove.c +++ b/sources/c/remove/main/remove.c @@ -5,62 +5,82 @@ extern "C" { #endif #ifndef _di_kt_remove_main_ - void kt_remove_main(fll_program_data_t * const main, kt_remove_setting_t * const setting) { + void kt_remove_main(kt_remove_main_t * const main) { - if (!main || !setting || F_status_is_error(setting->status)) return; + if (!main) return; - setting->status = F_none; - - if (setting->flag & kt_remove_flag_help_e) { - if (setting->process_help) { - setting->process_help(main, (void *) setting); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & kt_remove_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } return; } - if (setting->flag & kt_remove_flag_version_e) { - fll_print_format("%r%r", main->output.to.stream, kt_remove_program_version_s, f_string_eol_s); + if ((main->setting.flag & kt_remove_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + main->setting.state.status = F_none; + + if (main->setting.flag & (kt_remove_main_flag_help_e | kt_remove_main_flag_version_e | kt_remove_main_flag_copyright_e)) { + if (main->setting.flag & kt_remove_main_flag_help_e) { + if (main->setting.process_help) { + main->setting.process_help((void *) main); + } + } + else if (main->setting.flag & kt_remove_main_flag_version_e) { + fll_program_print_version(&main->program.message, kt_remove_program_version_s); + } + else if (main->setting.flag & kt_remove_main_flag_copyright_e) { + fll_program_print_copyright(&main->program.message); + } + + if ((main->setting.flag & kt_remove_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } return; } - // This program ignores the input pipe. - if (setting->process_normal) { - setting->process_normal(main, (void *) setting); - if (F_status_is_error(setting->status)) return; + if (main->setting.process_normal) { + main->setting.process_normal((void *) main); + if (F_status_is_error(main->setting.state.status)) return; + } + + if (main->program.signal_received) { + main->setting.state.status = F_interrupt; } - // Ensure a new line is always put at the end of the program execution. - f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); + if (main->setting.state.status == F_status_set_error(F_interrupt)) { + fll_program_print_signal_received(&main->program.warning, main->program.signal_received); + } - if (main->signal_received) { - setting->status = F_interrupt; + if ((main->setting.flag & kt_remove_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } } #endif // _di_kt_remove_main_ #ifndef _di_kt_remove_process_help_ - f_status_t kt_remove_process_help(fll_program_data_t * const main, void * const void_setting) { + f_status_t kt_remove_process_help(void * const main) { - if (!main || !void_setting) return F_output_not; + if (!main) return F_output_not; - return kt_remove_print_help(macro_kt_remove_setting(void_setting), main->output, main->context); + return kt_remove_print_message_help(&((kt_remove_main_t *) main)->program.output, ((kt_remove_main_t *) main)->program.context); } #endif // _di_kt_remove_process_help_ #ifndef _di_kt_remove_process_normal_ - void kt_remove_process_normal(fll_program_data_t * const main, void * const void_setting) { - - if (!main || !void_setting) return; + void kt_remove_process_normal(void * const main) { - kt_remove_arguments_t arguments = macro_kt_remove_arguments_t_initialize(main, macro_kt_remove_setting(void_setting)); + if (!main) return; f_thread_id_t id_signal; memset(&id_signal, 0, sizeof(f_thread_id_t)); - kt_remove_process_normal_operate(main, macro_kt_remove_setting(void_setting)); + kt_remove_process_normal_operate(((kt_remove_main_t *) main)); f_thread_cancel(id_signal); f_thread_join(id_signal, 0); @@ -68,30 +88,30 @@ extern "C" { #endif // _di_kt_remove_process_normal_ #ifndef _di_kt_remove_process_normal_operate_ - void kt_remove_process_normal_operate(fll_program_data_t * const main, kt_remove_setting_t * const setting) { + void kt_remove_process_normal_operate(kt_remove_main_t * const main) { - if (!main || !setting) return; + if (!main) return; - if (!setting->files.used) { - kt_remove_print_error_parameter_no_files(main->error); + if (!main->setting.files.used) { + kt_remove_print_error_parameter_no_files(&main->program.error); return; } - kt_remove_simulate_operate(main, setting); + kt_remove_print_simulate_operate(&main->program.output); - setting->status = F_none; + main->setting.state.status = F_none; - for (f_array_length_t i = 0; i < setting->files.used; ++i) { + for (f_array_length_t i = 0; i < main->setting.files.used; ++i) { - kt_remove_operate_file(main, setting, setting->files.array[i]); - if (F_status_is_error(setting->status)) break; + kt_remove_operate_file(main, main->setting.files.array[i]); + if (F_status_is_error(main->setting.state.status)) break; - if ((setting->flag & kt_remove_flag_simulate_e) && i + 1 < setting->files.used) { - f_print_dynamic(f_string_eol_s, main->output.to.stream); + if ((main->setting.flag & kt_remove_main_flag_simulate_e) && i + 1 < main->setting.files.used) { + f_print_dynamic(f_string_eol_s, main->program.output.to); } - if (setting->status == F_interrupt) break; + if (main->setting.state.status == F_interrupt) break; } // for } #endif // _di_kt_remove_process_normal_operate_ diff --git a/sources/c/remove/main/remove.h b/sources/c/remove/main/remove.h index 2a00494..4f36d4c 100644 --- a/sources/c/remove/main/remove.h +++ b/sources/c/remove/main/remove.h @@ -45,14 +45,21 @@ #include // Kevux Tools includes. -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -70,11 +77,9 @@ extern "C" { * - F_signal_termination * * @param main - * The main program data. - * @param setting - * The main program settings. + * The main program and settings data. * - * This alters setting.status: + * This alters main.setting.state.status: * F_none on success. * F_true on success when performing verification and verify passed. * F_false on success when performing verification and verify failed. @@ -83,38 +88,36 @@ extern "C" { * F_parameter (with error bit) if main is NULL or setting is NULL. */ #ifndef _di_kt_remove_main_ - extern void kt_remove_main(fll_program_data_t * const main, kt_remove_setting_t * const setting); + extern void kt_remove_main(kt_remove_main_t * const main); #endif // _di_kt_remove_main_ /** * Process printing help. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (kt_remove_setting_t *). + * The main program and settings data. * - * This does not alter setting.status. + * This must be of type kt_remove_main_t. + * + * This does not alter main.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. */ #ifndef _di_kt_remove_process_help_ - extern f_status_t kt_remove_process_help(fll_program_data_t * const main, void * const setting); + extern f_status_t kt_remove_process_help(void * const main); #endif // _di_kt_remove_process_help_ /** * Process normally, writing to the output. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (kt_remove_setting_t *). + * The main program and settings data. + * + * This must be of type kt_remove_main_t. * - * This alters setting.status: + * This alters main.setting.state.status: * F_none on success. * * F_parameter (with error bit) if main is NULL or setting is NULL. @@ -124,25 +127,22 @@ extern "C" { * @see kt_remove_process_normal_operate() */ #ifndef _di_kt_remove_process_normal_ - extern void kt_remove_process_normal(fll_program_data_t * const main, void * const setting); + extern void kt_remove_process_normal(void * const main); #endif // _di_kt_remove_process_normal_ /** * Perform the normal processing. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (kt_remove_setting_t *). + * The main program and settings data. * - * This alters setting.status: + * This alters main.setting.state.status: * F_none on success. * * F_parameter (with error bit) if main is NULL or setting is NULL. */ #ifndef _di_kt_remove_process_normal_operate_ - extern void kt_remove_process_normal_operate(fll_program_data_t * const main, kt_remove_setting_t * const setting); + extern void kt_remove_process_normal_operate(kt_remove_main_t * const main); #endif // _di_kt_remove_process_normal_operate_ #ifdef __cplusplus diff --git a/sources/c/remove/main/signal.c b/sources/c/remove/main/signal.c index 2c8f6df..c1b0847 100644 --- a/sources/c/remove/main/signal.c +++ b/sources/c/remove/main/signal.c @@ -5,14 +5,15 @@ extern "C" { #endif #if !defined(_di_kt_remove_signal_check_) && defined(_di_thread_support_) - f_status_t kt_remove_signal_check(fll_program_data_t * const main) { + f_status_t kt_remove_signal_check(kt_remove_main_t * const main) { - if (main->signal.id == -1) return F_false; + if (!main) return F_false; + if (main->program.signal.id == -1) return F_false; - if (!((++main->signal_check) % kt_remove_signal_check_d)) { - if (fll_program_standard_signal_received(main)) return F_true; + if (!((++main->program.signal_check) % kt_remove_signal_check_d)) { + if (fll_program_standard_signal_received(&main->program)) return F_true; - data->main->signal_check = 0; + data->main->program.signal_check = 0; } return F_false; @@ -20,40 +21,41 @@ extern "C" { #endif // !defined(_di_kt_remove_signal_check_) && defined(_di_thread_support_) #if !defined(_di_kt_remove_signal_check_) && !defined(_di_thread_support_) - f_status_t kt_remove_signal_check(fll_program_data_t * const main) { + f_status_t kt_remove_signal_check(kt_remove_main_t * const main) { - if (main->signal.id == -1) return F_false; - if (main->signal_received) return F_true; + if (!main) return F_false; + if (main->program.signal.id == -1) return F_false; + if (main->program.signal_received) return F_true; return F_false; } #endif // !defined(_di_kt_remove_signal_check_) && !defined(_di_thread_support_) #if !defined(_di_kt_remove_signal_handler_) && !defined(_di_thread_support_) - void kt_remove_signal_handler(fll_program_data_t * const main, kt_remove_setting_t * const setting) { + void kt_remove_signal_handler(kt_remove_main_t * const main) { - if (!main || !setting) return; + if (!main) return; siginfo_t information; f_array_length_t failsafe = 0; memset(&information, 0, sizeof(siginfo_t)); - main->signal_received = 0; + main->program.signal_received = 0; - f_signal_set_empty(&main->signal.set); - f_signal_set_add(F_signal_abort, &main->signal.set); - f_signal_set_add(F_signal_broken_pipe, &main->signal.set); - f_signal_set_add(F_signal_hangup, &main->signal.set); - f_signal_set_add(F_signal_interrupt, &main->signal.set); - f_signal_set_add(F_signal_quit, &main->signal.set); - f_signal_set_add(F_signal_termination, &main->signal.set); + f_signal_set_empty(&main->program.signal.set); + f_signal_set_add(F_signal_abort, &main->program.signal.set); + f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set); + f_signal_set_add(F_signal_hangup, &main->program.signal.set); + f_signal_set_add(F_signal_interrupt, &main->program.signal.set); + f_signal_set_add(F_signal_quit, &main->program.signal.set); + f_signal_set_add(F_signal_termination, &main->program.signal.set); - if (main->signal.id == -1) { - setting->status_thread = f_signal_open(&main->signal); + if (main->program.signal.id == -1) { + main->setting.status_thread = f_signal_open(&main->program.signal); - if (F_status_is_error(setting->status_thread)) { - main->signal_received = F_signal_abort; + if (F_status_is_error(main->setting.status_thread)) { + main->program.signal_received = F_signal_abort; return; } @@ -62,9 +64,9 @@ extern "C" { do { memset(&information, 0, sizeof(siginfo_t)); - setting->status_thread = f_signal_wait(&main->signal.set, &information); + main->setting.status_thread = f_signal_wait(&main->program.signal.set, &information); - if (F_status_is_error(setting->status_thread) && F_status_set_fine(setting->status_thread) != F_interrupt) { + if (F_status_is_error(main->setting.status_thread) && F_status_set_fine(main->setting.status_thread) != F_interrupt) { if (++failsafe >= kt_remove_signal_check_failsafe_d) break; } @@ -75,20 +77,20 @@ extern "C" { case F_signal_interrupt: case F_signal_quit: case F_signal_termination: - main->signal_received = information.si_signo; + main->program.signal_received = information.si_signo; break; } failsafe = 0; - setting->status_thread = F_none; + main->setting.status_thread = F_none; - } while (!main->signal_received); + } while (!main->program.signal_received); - f_signal_close(&main->signal); + f_signal_close(&main->program.signal); - if (F_status_is_error(setting->status_thread)) { - main->signal_received = F_signal_abort; + if (F_status_is_error(main->setting.status_thread)) { + main->program.signal_received = F_signal_abort; } } #endif // !defined(_di_kt_remove_signal_handler_) && !defined(_di_thread_support_) diff --git a/sources/c/remove/main/signal.h b/sources/c/remove/main/signal.h index 3022f5d..1726994 100644 --- a/sources/c/remove/main/signal.h +++ b/sources/c/remove/main/signal.h @@ -28,7 +28,9 @@ extern "C" { * The threaded version checks the flag state which is set by a separate thread that is blocking until signal is received. * * @param main - * The main program data. + * The main program and settings data. + * + * This does not alter main.setting.state.status. * * @return * F_true on signal received. @@ -39,7 +41,7 @@ extern "C" { * @see fll_program_standard_signal_received() */ #ifndef _di_kt_remove_signal_check_ - extern f_status_t kt_remove_signal_check(fll_program_data_t * const main); + extern f_status_t kt_remove_signal_check(kt_remove_main_t * const main); #endif // _di_kt_remove_signal_check_ /** @@ -57,11 +59,9 @@ extern "C" { * - F_signal_termination * * @param main - * The main program data. - * @param setting - * The main program settings. + * The main program and settings data. * - * This alters setting.signal_received, setting it to a received signal. + * This alters main.program.signal_received, setting it to a received signal. * * This alters setting.status: * Errors with (error bit set) from: f_signal_open() @@ -72,7 +72,7 @@ extern "C" { * @see f_signal_wait() */ #if !defined(_di_kt_remove_signal_handler_) && !defined(_di_thread_support_) - extern void kt_remove_signal_handler(fll_program_data_t * const main, kt_remove_setting_t * const setting); + extern void kt_remove_signal_handler(kt_remove_main_t * const main); #endif // !defined(_di_kt_remove_signal_handler_) && !defined(_di_thread_support_) #ifdef __cplusplus diff --git a/sources/c/remove/main/simulate.h b/sources/c/remove/main/simulate.h deleted file mode 100644 index dda0536..0000000 --- a/sources/c/remove/main/simulate.h +++ /dev/null @@ -1,153 +0,0 @@ -/** - * Kevux Tools - Remove - * - * Project: Kevux Tools - * API Version: 0.5 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _kt_remove_simulate_h -#define _kt_remove_simulate_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Simulate operate. - * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This does not alter setting.status. - */ -#ifndef _di_kt_remove_simulate_operate_ - extern void kt_remove_simulate_operate(fll_program_data_t * const main, kt_remove_setting_t * const setting); -#endif // _di_kt_remove_simulate_operate_ - -/** - * Simulate operate on a single file. - * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This does not alter setting.status. - * @param path - * The path to the file to operate on. - */ -#ifndef _di_kt_remove_simulate_operate_file_ - extern void kt_remove_simulate_operate_file(fll_program_data_t * const main, kt_remove_setting_t * const setting, const f_string_static_t path); -#endif // _di_kt_remove_simulate_operate_file_ - -/** - * Simulate operate on a single file, processing file existence. - * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This does not alter setting.status. - * @param path - * The path to the file to operate on. - */ -#ifndef _di_kt_remove_simulate_operate_file_exists_ - extern void kt_remove_simulate_operate_file_exists(fll_program_data_t * const main, kt_remove_setting_t * const setting, const f_string_static_t path); -#endif // _di_kt_remove_simulate_operate_file_exists_ - -/** - * Simulate operate on a single file, processing file statistics. - * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This does not alter setting.status. - * @param statistics - * The file statistics. - */ -#ifndef _di_kt_remove_simulate_operate_file_stat_ - extern void kt_remove_simulate_operate_file_stat(fll_program_data_t * const main, kt_remove_setting_t * const setting, struct stat statistics); -#endif // _di_kt_remove_simulate_operate_file_stat_ - -/** - * Simulate operate on a single file, designate that file is forcibly to be removed. - * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This does not alter setting.status. - */ -#ifndef _di_kt_remove_simulate_operate_remove_force_yes_ - extern void kt_remove_simulate_operate_remove_force_yes(fll_program_data_t * const main, kt_remove_setting_t * const setting); -#endif // _di_kt_remove_simulate_operate_remove_force_yes_ - -/** - * Simulate operate on a single file, designate that file is not forcibly to be removed. - * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This does not alter setting.status. - */ -#ifndef _di_kt_remove_simulate_operate_remove_force_no_ - extern void kt_remove_simulate_operate_remove_force_no(fll_program_data_t * const main, kt_remove_setting_t * const setting); -#endif // _di_kt_remove_simulate_operate_remove_force_no_ - -/** - * Simulate operate on a single file, designate that file is to be removed. - * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This does not alter setting.status. - */ -#ifndef _di_kt_remove_simulate_operate_remove_yes_ - extern void kt_remove_simulate_operate_remove_yes(fll_program_data_t * const main, kt_remove_setting_t * const setting); -#endif // _di_kt_remove_simulate_operate_remove_yes_ - -/** - * Simulate operate on a single file, designate that file is not to be removed. - * - * This does nothing if the simulate flag (kt_remove_flag_simulate_e) is not set. - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This does not alter setting.status. - */ -#ifndef _di_kt_remove_simulate_operate_remove_no_ - extern void kt_remove_simulate_operate_remove_no(fll_program_data_t * const main, kt_remove_setting_t * const setting); -#endif // _di_kt_remove_simulate_operate_remove_no_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _kt_remove_simulate_h diff --git a/sources/c/remove/main/thread.c b/sources/c/remove/main/thread.c index c228294..702c011 100644 --- a/sources/c/remove/main/thread.c +++ b/sources/c/remove/main/thread.c @@ -5,11 +5,13 @@ extern "C" { #endif #ifndef _di_kt_remove_thread_signal_ - void * kt_remove_thread_signal(void * const arguments) { + void * kt_remove_thread_signal(void * const main) { f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0); - kt_remove_signal_handler(macro_kt_remove_arguments(arguments)->main, macro_kt_remove_arguments(arguments)->setting); + if (main) { + kt_remove_signal_handler((kt_remove_main_t *) main); + } return 0; } diff --git a/sources/c/remove/main/thread.h b/sources/c/remove/main/thread.h index 6038e90..24ded36 100644 --- a/sources/c/remove/main/thread.h +++ b/sources/c/remove/main/thread.h @@ -23,18 +23,20 @@ extern "C" { * - F_signal_quit * - F_signal_termination * - * @param arguments - * The thread arguments. - * Must be of type kt_remove_arguments_t. + * @param main + * The program and settings data. + * + * Must be of type kt_remove_main_t. * * @return * 0, always. * - * @see f_signal_mask() - * @see f_signal_wait() + * @see f_thread_cancel_state_set() + * + * @see kt_remove_signal_handler() */ #if !defined(_di_kt_remove_thread_signal_) && !defined(_di_thread_support_) - extern void * kt_remove_thread_signal(void * const arguments); + extern void * kt_remove_thread_signal(void * const main); #endif // !defined(_di_kt_remove_thread_signal_) && !defined(_di_thread_support_) #ifdef __cplusplus