From 3b8928b605335b6bbd120ff4a28a3960a5a08163 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 6 Dec 2023 21:08:49 -0600 Subject: [PATCH] Progress: Further work in TacocaT. I need to resume the send logic but first I needed to make these minor fixes. --- sources/c/tacocat/main/common.c | 19 +++++++++---------- sources/c/tacocat/main/common.h | 2 +- sources/c/tacocat/main/print/error.c | 4 ++-- sources/c/tacocat/main/print/error.h | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/sources/c/tacocat/main/common.c b/sources/c/tacocat/main/common.c index 9225e8d..333827a 100644 --- a/sources/c/tacocat/main/common.c +++ b/sources/c/tacocat/main/common.c @@ -354,7 +354,7 @@ extern "C" { if (main->program.parameters.arguments.array[index].used) { if (f_path_is_absolute(main->program.parameters.arguments.array[index]) == F_true || f_path_is_relative_current(main->program.parameters.arguments.array[index]) == F_true) { - main->setting.state.status = f_memory_array_increase_by(main->program.parameters.arguments.array[index].used + 2, sizeof(f_char_t), (void **) &sets[i]->array[j].network.string, &sets[i]->array[j].network.used, &sets[i]->array[j].network.size); + main->setting.state.status = f_memory_array_increase_by(main->program.parameters.arguments.array[index].used + 1, sizeof(f_char_t), (void **) &sets[i]->array[j].network.string, &sets[i]->array[j].network.used, &sets[i]->array[j].network.size); macro_setting_load_handle_send_receive_error_continue_2(f_memory_array_increase_by); @@ -362,9 +362,7 @@ extern "C" { macro_setting_load_handle_send_receive_error_continue_2(f_string_dynamic_append_nulless); - // Designate this as a socket file by appending after the terminating NULL, past the used length. sets[i]->array[j].network.string[sets[i]->array[j].network.used] = 0; - sets[i]->array[j].network.string[sets[i]->array[j].network.used + 1] = f_string_ascii_slash_forward_s.string[0]; if (is_receive[i]) { main->setting.state.status = f_file_exists(sets[i]->array[j].network, F_true); @@ -383,11 +381,12 @@ extern "C" { memset(&family, 0, sizeof(f_network_family_ip_t)); address = main->program.parameters.arguments.array[index]; - f_char_t address_string[address.used]; - f_string_range_double_t range_ip = f_string_range_double_t_initialize; + f_char_t address_string[address.used + 1]; + f_range_double_t range_ip = f_range_double_t_initialize; memcpy(address_string, address.string, address.used); address.string = address_string; + address.string[address.used] = 0; f_network_is_ip_address(address, &range_ip, &main->setting.state); @@ -626,7 +625,7 @@ extern "C" { #endif // _di_kt_tacocat_setting_load_send_receive_ #ifndef _di_kt_tacocat_setting_load_address_port_extract_ - void kt_tacocat_setting_load_address_port_extract(kt_tacocat_main_t * const main, const f_string_range_double_t range_ip, f_string_static_t * const address, f_number_unsigned_t * const port) { + void kt_tacocat_setting_load_address_port_extract(kt_tacocat_main_t * const main, const f_range_double_t range_ip, f_string_static_t * const address, f_number_unsigned_t * const port) { if (!main) return; @@ -647,7 +646,9 @@ extern "C" { *port = 0; { - const f_string_static_t adjusted = macro_f_string_static_t_initialize_1(address->string + range_ip.start_2, 0, (range_ip.start_2 - range_ip.stop_2) + 1); + char adjusted_string[(range_ip.stop_2 - range_ip.start_2) + 1]; + const f_string_static_t adjusted = macro_f_string_static_t_initialize_1(adjusted_string, 0, (range_ip.stop_2 - range_ip.start_2) + 1); + memcpy(adjusted_string, address->string + range_ip.start_2, adjusted.used); main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, adjusted, port); if (F_status_is_error(main->setting.state.status)) return; @@ -659,9 +660,7 @@ extern "C" { while (address->used && address->string[address->used] != f_string_ascii_colon_s.string[0]) --address->used; // Be sure to also remove the colon. - if (address->used) { - address->string[address->used--] = 0; - } + address->string[address->used] = 0; } main->setting.state.status = F_okay; diff --git a/sources/c/tacocat/main/common.h b/sources/c/tacocat/main/common.h index 4607ba6..753b95f 100644 --- a/sources/c/tacocat/main/common.h +++ b/sources/c/tacocat/main/common.h @@ -132,7 +132,7 @@ extern "C" { * @see fl_conversion_dynamic_to_unsigned_detect() */ #ifndef _di_kt_tacocat_setting_load_address_port_extract_ - extern void kt_tacocat_setting_load_address_port_extract(kt_tacocat_main_t * const main, const f_string_range_double_t range_ip, f_string_static_t * const address, f_number_unsigned_t * const port); + extern void kt_tacocat_setting_load_address_port_extract(kt_tacocat_main_t * const main, const f_range_double_t range_ip, f_string_static_t * const address, f_number_unsigned_t * const port); #endif // _di_kt_tacocat_setting_load_address_port_extract_ #ifdef __cplusplus diff --git a/sources/c/tacocat/main/print/error.c b/sources/c/tacocat/main/print/error.c index 82d81a0..6c86946 100644 --- a/sources/c/tacocat/main/print/error.c +++ b/sources/c/tacocat/main/print/error.c @@ -249,14 +249,14 @@ extern "C" { #endif // _di_kt_tacocat_print_error_parameter_value_resolve_unknown_ #ifndef _di_kt_tacocat_print_error_port_number_invalid_ - f_status_t kt_tacocat_print_error_port_number_invalid(fl_print_t * const print, const f_string_static_t address, const f_string_range_double_t range_ip) { + f_status_t kt_tacocat_print_error_port_number_invalid(fl_print_t * const print, const f_string_static_t address, const f_range_double_t range_ip) { if (!print || !print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; kt_tacocat_main_t * const main = (kt_tacocat_main_t *) print->custom; - const f_string_range_t range = macro_f_string_range_t_initialize_1(range_ip.start_2, range_ip.stop_2); + const f_range_t range = macro_f_range_t_initialize_1(range_ip.start_2, range_ip.stop_2); f_file_stream_lock(print->to); diff --git a/sources/c/tacocat/main/print/error.h b/sources/c/tacocat/main/print/error.h index 4bc3a81..a864cfa 100644 --- a/sources/c/tacocat/main/print/error.h +++ b/sources/c/tacocat/main/print/error.h @@ -373,7 +373,7 @@ extern "C" { * @see fll_error_file_print() */ #ifndef _di_kt_tacocat_print_error_port_number_invalid_ - extern f_status_t kt_tacocat_print_error_port_number_invalid(fl_print_t * const print, const f_string_static_t address, const f_string_range_double_t range_ip); + extern f_status_t kt_tacocat_print_error_port_number_invalid(fl_print_t * const print, const f_string_static_t address, const f_range_double_t range_ip); #endif // _di_kt_tacocat_print_error_port_number_invalid_ /** -- 1.8.3.1