]> Kevux Git Server - kevux-tools/commitdiff
Progress: Add -I/--interval parameter to TacocaT.
authorKevin Day <kevin@kevux.org>
Fri, 14 Jul 2023 03:52:16 +0000 (22:52 -0500)
committerKevin Day <kevin@kevux.org>
Fri, 14 Jul 2023 03:52:16 +0000 (22:52 -0500)
sources/c/tacocat/main/common.c
sources/c/tacocat/main/common/enumeration.h
sources/c/tacocat/main/common/print.c
sources/c/tacocat/main/common/print.h
sources/c/tacocat/main/common/string.c
sources/c/tacocat/main/common/string.h
sources/c/tacocat/main/common/type.h
sources/c/tacocat/main/print/message.c
sources/c/tacocat/main/receive.c

index 9fee6f0e89adcae491c4e4afb261c9c2e7ad20d0..0331b1ba68b5a10f9ef020fc46de85f684a59d99 100644 (file)
@@ -139,6 +139,40 @@ extern "C" {
       #endif // _kt_resolve_default_kevux_
     }
 
+    if (main->program.parameters.array[kt_tacocat_parameter_interval_e].result & f_console_result_value_e) {
+      index = main->program.parameters.array[kt_tacocat_parameter_interval_e].values.array[main->program.parameters.array[kt_tacocat_parameter_interval_e].values.used - 1];
+
+      f_number_unsigned_t number = 0;
+
+      main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &number);
+
+      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(fl_conversion_dynamic_to_unsigned_detect));
+
+        return;
+      }
+
+      if (number == 0 || main->setting.state.status == F_number_negative) {
+        main->setting.state.status = F_status_set_error(F_parameter);
+
+        fll_program_print_error_parameter_integer_less_than(&main->program.error, f_console_symbol_long_normal_s, kt_tacocat_long_interval_s, main->program.parameters.arguments.array[index], f_string_ascii_1_s);
+
+        return;
+      }
+
+      main->setting.interval = number;
+    }
+    else if (main->program.parameters.array[kt_tacocat_parameter_interval_e].result & f_console_result_found_e) {
+      main->setting.state.status = F_status_set_error(F_parameter);
+
+      macro_setting_load_print_first();
+
+      fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, kt_tacocat_long_interval_s);
+
+      return;
+    }
+
     // Only process these when needed to avoid unnecessary operations.
     if (main->callback.setting_load_send_receive && !(main->setting.flag & (kt_tacocat_main_flag_copyright_e | kt_tacocat_main_flag_version_e |kt_tacocat_main_flag_help_e))) {
       main->callback.setting_load_send_receive(arguments, (void *) main);
index 7935e7f046133a3db0b5ab7ca8e055e0fe030c83..a37d6324a28c482fb5e528c74dca8732c017fd75 100644 (file)
@@ -77,6 +77,7 @@ extern "C" {
     kt_tacocat_parameter_line_first_no_e,
     kt_tacocat_parameter_line_last_no_e,
 
+    kt_tacocat_parameter_interval_e,
     kt_tacocat_parameter_receive_e,
     kt_tacocat_parameter_resolve_e,
     kt_tacocat_parameter_send_e,
@@ -86,12 +87,13 @@ extern "C" {
     { \
       macro_fll_program_console_parameter_standard_initialize, \
       \
+      macro_f_console_parameter_t_initialize_3(kt_tacocat_short_interval_s, kt_tacocat_long_interval_s, 1, f_console_flag_normal_e), \
       macro_f_console_parameter_t_initialize_3(kt_tacocat_short_receive_s, kt_tacocat_long_receive_s, 2, f_console_flag_normal_e), \
       macro_f_console_parameter_t_initialize_3(kt_tacocat_short_resolve_s, kt_tacocat_long_resolve_s, 1, f_console_flag_normal_e), \
       macro_f_console_parameter_t_initialize_3(kt_tacocat_short_send_s, kt_tacocat_long_send_s, 2, f_console_flag_normal_e), \
     }
 
-  #define kt_tacocat_parameter_total_d 16
+  #define kt_tacocat_parameter_total_d 17
 #endif // _di_kt_tacocat_parameter_e_
 
 /**
index ff8f56b8ed724e51fe1840bbfa992bed8d704771..bb5cb1008201853b4e4230bef64fffe2256f462f 100644 (file)
@@ -27,6 +27,7 @@ extern "C" {
     "f_string_dynamic_increase_by",
     "f_string_dynamics_increase_by",
     "f_thread_create",
+    "fl_conversion_dynamic_to_unsigned_detect",
     "fll_program_parameter_process_context",
     "fll_program_parameter_process_verbosity",
     "kt_tacocat_process_socket_set_error_has",
index d8dfe2d4747752a7fca623dbf535831ef4a60733..c4448fed640d1558e8b6d59ecbfc80911ee5561d 100644 (file)
@@ -60,6 +60,7 @@ extern "C" {
     kt_tacocat_f_f_string_dynamic_increase_by_e,
     kt_tacocat_f_f_string_dynamics_increase_by_e,
     kt_tacocat_f_f_thread_create_e,
+    kt_tacocat_f_fl_conversion_dynamic_to_unsigned_detect_e,
     kt_tacocat_f_fll_program_parameter_process_context_e,
     kt_tacocat_f_fll_program_parameter_process_verbosity_e,
     kt_tacocat_f_kt_tacocat_process_socket_set_error_has_e,
index 3969de95cb12d6a75d43431b8c68509b8511f7d6..98158710a9d7a1e513450d9121f7f7d378440c80 100644 (file)
@@ -29,10 +29,12 @@ extern "C" {
 #endif // _di_kt_tacocat_s_
 
 #ifndef _di_kt_tacocat_parameter_s_
+  const f_string_static_t kt_tacocat_short_interval_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_short_interval_s, 0, KT_TACOCAT_short_interval_s_length);
   const f_string_static_t kt_tacocat_short_receive_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_short_receive_s, 0, KT_TACOCAT_short_receive_s_length);
   const f_string_static_t kt_tacocat_short_resolve_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_short_resolve_s, 0, KT_TACOCAT_short_resolve_s_length);
   const f_string_static_t kt_tacocat_short_send_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_short_send_s, 0, KT_TACOCAT_short_send_s_length);
 
+  const f_string_static_t kt_tacocat_long_interval_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_long_interval_s, 0, KT_TACOCAT_long_interval_s_length);
   const f_string_static_t kt_tacocat_long_receive_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_long_receive_s, 0, KT_TACOCAT_long_receive_s_length);
   const f_string_static_t kt_tacocat_long_resolve_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_long_resolve_s, 0, KT_TACOCAT_long_resolve_s_length);
   const f_string_static_t kt_tacocat_long_send_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_long_send_s, 0, KT_TACOCAT_long_send_s_length);
index 308ea812165febf205fb7efd7ee03e28f11da1aa..148eafe5957dacd119d3f3e855fc58558293340c 100644 (file)
@@ -104,26 +104,32 @@ extern "C" {
  * The main program parameters.
  */
 #ifndef _di_kt_tacocat_parameter_s_
-  #define KT_TACOCAT_short_receive_s "r"
-  #define KT_TACOCAT_short_resolve_s "R"
-  #define KT_TACOCAT_short_send_s    "s"
-
-  #define KT_TACOCAT_long_receive_s "receive"
-  #define KT_TACOCAT_long_resolve_s "resolve"
-  #define KT_TACOCAT_long_send_s    "send"
-
-  #define KT_TACOCAT_short_receive_s_length 1
-  #define KT_TACOCAT_short_resolve_s_length 1
-  #define KT_TACOCAT_short_send_s_length    1
-
-  #define KT_TACOCAT_long_receive_s_length 7
-  #define KT_TACOCAT_long_resolve_s_length 7
-  #define KT_TACOCAT_long_send_s_length    4
-
+  #define KT_TACOCAT_short_interval_s "I"
+  #define KT_TACOCAT_short_receive_s  "r"
+  #define KT_TACOCAT_short_resolve_s  "R"
+  #define KT_TACOCAT_short_send_s     "s"
+
+  #define KT_TACOCAT_long_interval_s "interval"
+  #define KT_TACOCAT_long_receive_s  "receive"
+  #define KT_TACOCAT_long_resolve_s  "resolve"
+  #define KT_TACOCAT_long_send_s     "send"
+
+  #define KT_TACOCAT_short_interval_s_length 1
+  #define KT_TACOCAT_short_receive_s_length  1
+  #define KT_TACOCAT_short_resolve_s_length  1
+  #define KT_TACOCAT_short_send_s_length     1
+
+  #define KT_TACOCAT_long_interval_s_length 8
+  #define KT_TACOCAT_long_receive_s_length  7
+  #define KT_TACOCAT_long_resolve_s_length  7
+  #define KT_TACOCAT_long_send_s_length     4
+
+  extern const f_string_static_t kt_tacocat_short_interval_s;
   extern const f_string_static_t kt_tacocat_short_receive_s;
   extern const f_string_static_t kt_tacocat_short_resolve_s;
   extern const f_string_static_t kt_tacocat_short_send_s;
 
+  extern const f_string_static_t kt_tacocat_long_interval_s;
   extern const f_string_static_t kt_tacocat_long_receive_s;
   extern const f_string_static_t kt_tacocat_long_resolve_s;
   extern const f_string_static_t kt_tacocat_long_send_s;
index f91767de717cce1d2fb0c7cf11ad9df1804552ed..631e25ada9db42cf6cd7444ebe12b01c358893a2 100644 (file)
@@ -71,7 +71,8 @@ extern "C" {
  * 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.
+ * flag:     Flags passed to the main function.
+ * interval: The poll interval to use.
  *
  * status_receive: A status used eclusively by the receive thread.
  * status_send:    A status used eclusively by the send thread.
@@ -87,6 +88,7 @@ extern "C" {
 #ifndef _di_kt_tacocat_setting_t_
   typedef struct {
     uint64_t flag;
+    uint64_t interval;
 
     f_status_t status_receive;
     f_status_t status_send;
@@ -103,6 +105,7 @@ extern "C" {
   #define kt_tacocat_setting_t_initialize \
     { \
       kt_tacocat_main_flag_none_e, \
+      kt_tacocat_interval_poll_d, \
       F_none, \
       F_none, \
       F_none, \
index a3159d64e1a1732fbab984c1c93b1e2843646ec2..d56bf3c3b76359c88cd5e0c360688230e517ee1b 100644 (file)
@@ -19,9 +19,10 @@ extern "C" {
 
     f_print_dynamic_raw(f_string_eol_s, print->to);
 
-    fll_program_print_help_option(print, kt_tacocat_short_receive_s, kt_tacocat_long_receive_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Specify an address or socket file to listen to and a file to write to.");
-    fll_program_print_help_option(print, kt_tacocat_short_resolve_s, kt_tacocat_long_resolve_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Specify a custom DNS resolution methodology.");
-    fll_program_print_help_option(print, kt_tacocat_short_send_s, kt_tacocat_long_send_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "   Specify an address or socket file send transmit to and a file to read from.");
+    fll_program_print_help_option(print, kt_tacocat_short_interval_s, kt_tacocat_long_interval_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Specify a custom poll interval in milliseconds to use.");
+    fll_program_print_help_option(print, kt_tacocat_short_receive_s, kt_tacocat_long_receive_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Specify an address or socket file to listen to and a file to write to.");
+    fll_program_print_help_option(print, kt_tacocat_short_resolve_s, kt_tacocat_long_resolve_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Specify a custom DNS resolution methodology.");
+    fll_program_print_help_option(print, kt_tacocat_short_send_s, kt_tacocat_long_send_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "    Specify an address or socket file send transmit to and a file to read from.");
 
     f_print_dynamic_raw(f_string_eol_s, print->to);
 
index 7300ec99dad181c329e3f2179e207e3b1639fd02..05db49ec49107e7d6d7b2d2d0baf7997773ea14d 100644 (file)
@@ -17,7 +17,7 @@ extern "C" {
 
     if (F_status_is_error_not(main->setting.status_receive)) {
       do {
-        main->setting.status_receive = f_file_poll(main->setting.receive.polls, kt_tacocat_interval_poll_d);
+        main->setting.status_receive = f_file_poll(main->setting.receive.polls, main->setting.interval);
 
         if (main->program.signal_received) {
           main->setting.status_receive = F_status_set_error(F_interrupt);