]> Kevux Git Server - kevux-tools/commitdiff
Progress: Work in tacocat, doing some cleanup and fixing things up.
authorKevin Day <kevin@kevux.org>
Thu, 29 Jun 2023 02:25:49 +0000 (21:25 -0500)
committerKevin Day <kevin@kevux.org>
Thu, 29 Jun 2023 02:25:49 +0000 (21:25 -0500)
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
data/build/tacocat/settings
documents/readme.tacocat.txt [new file with mode: 0644]
sources/c/tacocat/main/common.c
sources/c/tacocat/main/common/define.h
sources/c/tacocat/main/common/string.h
sources/c/tacocat/main/tacocat.c

index fdb3a148d1e4d29d94bcbcd2b2ce46f07328122e..6a0ace919bc1bef986a271d21d3bea9621541f3d 100644 (file)
@@ -9,6 +9,7 @@ f_utf
 f_color
 f_console
 f_conversion
+f_path
 f_pipe
 f_print
 f_signal
index ac00118e01c6fa9e8f8a874b3295ba29928f0b79..6ab16e581f065321b795bdffb5a0837382044bb5 100644 (file)
@@ -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 (file)
index 0000000..d329bd5
--- /dev/null
@@ -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.
index 45515f2dccddd19325c9fc58d91c29450ee1e70e..1753197f82045a4d7d9dedcd9a929f3acb5e2efe 100644 (file)
@@ -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]);
 
index ad41b9eb0344b960519d5e5ceef06d32f9d856f4..14f82fb59d1c5aec87cab48fc6f45fde577eb7c5 100644 (file)
@@ -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
index 00337da3c6bd354ceb1dda1c6b42d07d0939302d..958fff64e89717d8402cbc6505569efdbc5b7edc 100644 (file)
@@ -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
index 2308b023def9ed126b29c5ea7d5ce32fd26c0bbb..71be7818f4809781c41b2e8dcc30ae1098b8dbce 100644 (file)
@@ -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;