From 2ec403f0121f2243099f33b81d27706b862b0633 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 28 Jun 2023 21:25:49 -0500 Subject: [PATCH] Progress: Work in tacocat, doing some cleanup and fixing things up. This is done before I realized that I needed more functions in f_network project in FLL. I did a small amount of work and then shifted my time and effort back to f_network project. This adds the missing readme.tacocat.txt file. --- data/build/tacocat/dependencies | 1 + data/build/tacocat/settings | 2 +- documents/readme.tacocat.txt | 27 +++++++++++++++ sources/c/tacocat/main/common.c | 63 +++++++++++++++++----------------- sources/c/tacocat/main/common/define.h | 12 +++++++ sources/c/tacocat/main/common/string.h | 2 +- sources/c/tacocat/main/tacocat.c | 4 +-- 7 files changed, 75 insertions(+), 36 deletions(-) create mode 100644 documents/readme.tacocat.txt diff --git a/data/build/tacocat/dependencies b/data/build/tacocat/dependencies index fdb3a14..6a0ace9 100644 --- a/data/build/tacocat/dependencies +++ b/data/build/tacocat/dependencies @@ -9,6 +9,7 @@ f_utf f_color f_console f_conversion +f_path f_pipe f_print f_signal diff --git a/data/build/tacocat/settings b/data/build/tacocat/settings index ac00118..6ab16e5 100644 --- a/data/build/tacocat/settings +++ b/data/build/tacocat/settings @@ -32,7 +32,7 @@ build_indexer_arguments rcs build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_print -lfll_program -lfl_conversion -lfl_print -lf_color -lf_console -lf_conversion -lf_memory -lf_pipe -lf_print -lf_signal -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_print -lfll_program -lfl_conversion -lfl_print -lf_color -lf_console -lf_conversion -lf_memory -lf_path -lf_pipe -lf_print -lf_signal -lf_string -lf_type_array -lf_utf build_libraries-individual_thread -lf_thread build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll diff --git a/documents/readme.tacocat.txt b/documents/readme.tacocat.txt new file mode 100644 index 0000000..d329bd5 --- /dev/null +++ b/documents/readme.tacocat.txt @@ -0,0 +1,27 @@ +# fss-0002 iki-0000 +# +# license: cc-by-sa-4.0 +# +# This file (assumed to be named readme.remove.txt) can be more easily read using the following iki_read commands: +# iki_read readme.tacocate.txt +Q -w -rrr FLL FLL PID PID DNS DNS -WW character "'" "'" code '"' '"' +# +# To read the "Remove Readme Documentation" section of this file, use this command sequence: +# fss_basic_list_read readme.tacocate.txt +Q -cn "TacocaT Readme Documentation" | iki_read +Q -w -rrr FLL FLL PID PID DNS DNS -WW character "'" "'" code '"' '"' +# + +TacocaT Readme Documentation: + The bold:"tacocat" is a program for sending and receiving files, mainly for testing purposes. + + This program is similar to code:"netcat" or code:"nc". + + The primary use for this is to test bold:"Featureless Linux Library" and bold:"Kevux Tools" network functionality. + + The bold:"tacocat" program has the following arguments\: + + The code:"--background" (code:"-b") causes this program to run in the background. + The code:"--from" (code:"-f") parameter is an address or socket file to listen to. + The code:"--pid" (code:"-p") causes this program to create a PID:"Process Identifier" file. + The code:"--pid_name" (code:"-N") parameter designates a custom PID:"Process Identifier" file name without the '.pid' extension or the directory path. + The code:"--pid_path" (code:"-P") parameter designates a custom PID:"Process Identifier" directory path.\ + The code:"--resolve" (code:"-R") parameter designates a DNS:"Domain Name Resolver" mode, such as code:"classic" or code:"kevux". + The code:"--to" (code:"-t") parameter is an address or socket file to transmit to. diff --git a/sources/c/tacocat/main/common.c b/sources/c/tacocat/main/common.c index 45515f2..1753197 100644 --- a/sources/c/tacocat/main/common.c +++ b/sources/c/tacocat/main/common.c @@ -32,10 +32,7 @@ extern "C" { } if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & kt_tacocat_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); - } - + macro_setting_load_print_first(); kt_tacocat_print_error(&main->program.error, macro_kt_tacocat_f(f_console_parameter_process)); return; @@ -55,9 +52,7 @@ extern "C" { main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & kt_tacocat_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); - } + macro_setting_load_print_first(); kt_tacocat_print_error(&main->program.error, macro_kt_tacocat_f(fll_program_parameter_process_context)); @@ -76,9 +71,7 @@ extern "C" { 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_tacocat_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); - } + macro_setting_load_print_first(); kt_tacocat_print_error(&main->program.error, macro_kt_tacocat_f(fll_program_parameter_process_verbosity)); @@ -152,9 +145,7 @@ extern "C" { main->setting.state.status = f_string_dynamic_append_nulless(main->program.parameters.arguments.array[index], strings[i]); if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & kt_tacocat_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); - } + macro_setting_load_print_first(); kt_tacocat_print_error(&main->program.error, macro_kt_tacocat_f(f_string_dynamic_append_nulless)); @@ -164,9 +155,7 @@ extern "C" { else { main->setting.state.status = F_status_set_error(F_parameter); - if ((main->setting.flag & kt_tacocat_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); - } + macro_setting_load_print_first(); fll_program_print_error_parameter_empty_value(&main->program.error, f_console_symbol_long_normal_s, longs[i]); @@ -176,9 +165,7 @@ extern "C" { else if (main->program.parameters.array[parameters[i]].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); - if ((main->setting.flag & kt_tacocat_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); - } + macro_setting_load_print_first(); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, longs[i]); @@ -203,6 +190,11 @@ extern "C" { &main->setting.tos, }; + const bool const exists[] = { + F_true, + F_false, + }; + f_number_unsigned_t j = 0; for (i = 0; i < 2; ++i) { @@ -213,9 +205,7 @@ extern "C" { main->setting.state.status = f_string_dynamics_increase_by(main->program.parameters.array[parameters[i]].values.used, strings[i]); if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & kt_tacocat_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); - } + macro_setting_load_print_first(); kt_tacocat_print_error(&main->program.error, macro_kt_tacocat_f(f_string_dynamics_increase_by)); @@ -232,21 +222,34 @@ extern "C" { main->setting.state.status = f_string_dynamic_append_nulless(main->program.parameters.arguments.array[index], &strings[i]->array[j]); if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & kt_tacocat_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); - } + macro_setting_load_print_first(); kt_tacocat_print_error(&main->program.error, macro_kt_tacocat_f(f_string_dynamic_append_nulless)); return; } + + if (f_path_is_absolute(strings[i]->array[j]) == F_true || f_path_is_relative_current(strings[i]->array[j]) == F_true) { + if (exists[i]) { + main->setting.state.status = f_file_exists(strings[i]->array[j], F_true); + + if (F_status_is_error(main->setting.state.status)) { + macro_setting_load_print_first(); + + kt_tacocat_print_error(&main->program.error, macro_kt_tacocat_f(f_string_dynamic_append_nulless)); + + return; + } + } + } + else { + // @todo is network address, do validation. + } } else { main->setting.state.status = F_status_set_error(F_parameter); - if ((main->setting.flag & kt_tacocat_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); - } + macro_setting_load_print_first(); fll_program_print_error_parameter_empty_value(&main->program.error, f_console_symbol_long_normal_s, longs[i]); @@ -257,9 +260,7 @@ extern "C" { else if (main->program.parameters.array[parameters[i]].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); - if ((main->setting.flag & kt_tacocat_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); - } + macro_setting_load_print_first(); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, longs[i]); diff --git a/sources/c/tacocat/main/common/define.h b/sources/c/tacocat/main/common/define.h index ad41b9e..14f82fb 100644 --- a/sources/c/tacocat/main/common/define.h +++ b/sources/c/tacocat/main/common/define.h @@ -37,6 +37,18 @@ extern "C" { #define kt_tacocat_signal_check_failsafe_d 20000 #endif // _di_kt_tacocat_d_ +/** + * The program macros. + * + * macro_setting_load_print_first: Intended to be used to simplify the code in kt_tacocat_setting_load() and make it more readable. + */ +#ifndef _di_kt_tacocat_macros_d_ + #define macro_setting_load_print_first() \ + if ((main->setting.flag & kt_tacocat_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); \ + } +#endif // _di_kt_tacocat_macro_d_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/sources/c/tacocat/main/common/string.h b/sources/c/tacocat/main/common/string.h index 00337da..958fff6 100644 --- a/sources/c/tacocat/main/common/string.h +++ b/sources/c/tacocat/main/common/string.h @@ -50,7 +50,7 @@ extern "C" { */ #ifndef _di_kt_tacocat_program_name_s_ #define KT_TACOCAT_program_name_s "tacocat" - #define KT_TACOCAT_program_name_long_s "tacocat" + #define KT_TACOCAT_program_name_long_s "TacocaT" #define KT_TACOCAT_program_name_s_length 7 #define KT_TACOCAT_program_name_long_s_length 7 diff --git a/sources/c/tacocat/main/tacocat.c b/sources/c/tacocat/main/tacocat.c index 2308b02..71be781 100644 --- a/sources/c/tacocat/main/tacocat.c +++ b/sources/c/tacocat/main/tacocat.c @@ -17,9 +17,7 @@ extern "C" { return; } - if ((main->setting.flag & kt_tacocat_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); - } + macro_setting_load_print_first(); main->setting.state.status = F_none; -- 1.8.3.1