]> Kevux Git Server - kevux-tools/commitdiff
Progress: Further work in TacocaT.
authorKevin Day <thekevinday@gmail.com>
Thu, 7 Dec 2023 03:08:49 +0000 (21:08 -0600)
committerKevin Day <thekevinday@gmail.com>
Thu, 7 Dec 2023 03:08:49 +0000 (21:08 -0600)
I need to resume the send logic but first I needed to make these minor fixes.

sources/c/tacocat/main/common.c
sources/c/tacocat/main/common.h
sources/c/tacocat/main/print/error.c
sources/c/tacocat/main/print/error.h

index 9225e8db947a8c7b05a9b0e521275bd4bbc47ddd..333827adbcb41a10341ea3483831b40f9d3b8ae9 100644 (file)
@@ -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;
index 4607ba61ed11d33d22c9ce8df31f3b8d583a2ea9..753b95f41225e79b0b447aff1ae2cbe561a08183 100644 (file)
@@ -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
index 82d81a0940b91e38ae539d312f0a293e818a18be..6c86946fad79a3c751278b36928dac4a5fb9cf79 100644 (file)
@@ -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);
 
index 4bc3a81f1d852dfb02d97c3d848188dd3d033051..a864cfabf8c0033770d65a762b7c4a43f666bbcb 100644 (file)
@@ -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_
 
 /**