From: Kevin Day Date: Fri, 14 Jul 2023 03:52:16 +0000 (-0500) Subject: Progress: Add -I/--interval parameter to TacocaT. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=f9c15d22adc47148b1188110ae314576f3a0bfaf;p=kevux-tools Progress: Add -I/--interval parameter to TacocaT. --- diff --git a/sources/c/tacocat/main/common.c b/sources/c/tacocat/main/common.c index 9fee6f0..0331b1b 100644 --- a/sources/c/tacocat/main/common.c +++ b/sources/c/tacocat/main/common.c @@ -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); diff --git a/sources/c/tacocat/main/common/enumeration.h b/sources/c/tacocat/main/common/enumeration.h index 7935e7f..a37d632 100644 --- a/sources/c/tacocat/main/common/enumeration.h +++ b/sources/c/tacocat/main/common/enumeration.h @@ -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_ /** diff --git a/sources/c/tacocat/main/common/print.c b/sources/c/tacocat/main/common/print.c index ff8f56b..bb5cb10 100644 --- a/sources/c/tacocat/main/common/print.c +++ b/sources/c/tacocat/main/common/print.c @@ -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", diff --git a/sources/c/tacocat/main/common/print.h b/sources/c/tacocat/main/common/print.h index d8dfe2d..c4448fe 100644 --- a/sources/c/tacocat/main/common/print.h +++ b/sources/c/tacocat/main/common/print.h @@ -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, diff --git a/sources/c/tacocat/main/common/string.c b/sources/c/tacocat/main/common/string.c index 3969de9..9815871 100644 --- a/sources/c/tacocat/main/common/string.c +++ b/sources/c/tacocat/main/common/string.c @@ -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); diff --git a/sources/c/tacocat/main/common/string.h b/sources/c/tacocat/main/common/string.h index 308ea81..148eafe 100644 --- a/sources/c/tacocat/main/common/string.h +++ b/sources/c/tacocat/main/common/string.h @@ -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; diff --git a/sources/c/tacocat/main/common/type.h b/sources/c/tacocat/main/common/type.h index f91767d..631e25a 100644 --- a/sources/c/tacocat/main/common/type.h +++ b/sources/c/tacocat/main/common/type.h @@ -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, \ diff --git a/sources/c/tacocat/main/print/message.c b/sources/c/tacocat/main/print/message.c index a3159d6..d56bf3c 100644 --- a/sources/c/tacocat/main/print/message.c +++ b/sources/c/tacocat/main/print/message.c @@ -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); diff --git a/sources/c/tacocat/main/receive.c b/sources/c/tacocat/main/receive.c index 7300ec9..05db49e 100644 --- a/sources/c/tacocat/main/receive.c +++ b/sources/c/tacocat/main/receive.c @@ -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);