]> Kevux Git Server - kevux-tools/commitdiff
Update: Provide a way to use different file names for both send and receive as well...
authorKevin Day <Kevin@kevux.org>
Sun, 30 Nov 2025 01:53:51 +0000 (19:53 -0600)
committerKevin Day <Kevin@kevux.org>
Sun, 30 Nov 2025 02:09:53 +0000 (20:09 -0600)
Utilize the set flag for defining the state on whether or not to keep the senders file name when receiving.
Utilize the set flag for defining whether or not the send is a send set or a receive set.

Provide a `-a` or `--as` parameter for a sender to declare a custom name for some file being transferred.

Do not pre-check or pre-write to files when the file name will only be known once a packet is received.

The direction string no longer needs to be passed to functions now that the set flag defines what direction it is.

Consistently add new lines at the start of the message printing.

Do not reset the set flag on initialization (resetting).
Rename the initialization functions to use the word "reset" to avoid confusion with the real initialization process.

Print verbose log message declaring the name of the received file when keeping the senders file name and when headers are not printed.

Fix mistake where the `kt_tacocat_socket_step_receive_find_e` is incorrectly being compared against the set flag rather than the set step.

Fix problems preventing stand alone builds from compiling.

28 files changed:
data/build/stand_alone/configs/remove-config.h
data/build/stand_alone/configs/tacocat-config.h
data/build/stand_alone/settings/settings.tacocat
sources/c/program/kevux/tools/tacocat/main/common.c
sources/c/program/kevux/tools/tacocat/main/common/define.h
sources/c/program/kevux/tools/tacocat/main/common/enumeration.h
sources/c/program/kevux/tools/tacocat/main/common/string.c
sources/c/program/kevux/tools/tacocat/main/common/string.h
sources/c/program/kevux/tools/tacocat/main/common/type.c
sources/c/program/kevux/tools/tacocat/main/common/type.h
sources/c/program/kevux/tools/tacocat/main/packet.c
sources/c/program/kevux/tools/tacocat/main/packet.h
sources/c/program/kevux/tools/tacocat/main/print/error.c
sources/c/program/kevux/tools/tacocat/main/print/message.c
sources/c/program/kevux/tools/tacocat/main/print/message.h
sources/c/program/kevux/tools/tacocat/main/process.c
sources/c/program/kevux/tools/tacocat/main/receive.c
sources/c/program/kevux/tools/tacocat/main/receive.h
sources/c/program/kevux/tools/tacocat/main/receive/step/check.c
sources/c/program/kevux/tools/tacocat/main/receive/step/control.c
sources/c/program/kevux/tools/tacocat/main/receive/step/done.c
sources/c/program/kevux/tools/tacocat/main/receive/step/extract.c
sources/c/program/kevux/tools/tacocat/main/receive/step/packet.c
sources/c/program/kevux/tools/tacocat/main/receive/step/write.c
sources/c/program/kevux/tools/tacocat/main/send.c
sources/c/program/kevux/tools/tacocat/main/send.h
sources/c/program/kevux/tools/tacocat/main/send/step/done.c
sources/c/program/kevux/tools/tacocat/main/send/step/size.c

index 3dcb36224fcc79ba877a44a7466fa358daffbe91..884f0db90f2bcd7cf25e4cd097f1eef584c593a6 100644 (file)
 #define _di_fll_program_print_error_parameter_process_
 #define _di_fll_program_print_error_parameter_range_start_before_stop_
 //#define _di_fll_program_print_error_parameter_support_not_
+#define _di_fll_program_print_error_parameter_too_few_
+//#define _di_fll_program_print_error_parameter_too_many_
 #define _di_fll_program_print_error_parameter_value_too_long_
 #define _di_fll_program_print_error_pipe_invalid_form_feed_
 #define _di_fll_program_print_error_pipe_missing_content_
index f159de9ceee92afcb890567c7bf4db0af9de73e3..17b66b113caa04f1cc3af0c315a4f5ff231201de 100644 (file)
 #define _di_f_string_ascii_k_s_
 //#define _di_f_string_ascii_l_s_
 #define _di_f_string_ascii_m_s_
-#define _di_f_string_ascii_mark_question_s_
+//#define _di_f_string_ascii_mark_question_s_
 #define _di_f_string_ascii_medium_stop_s_
 //#define _di_f_string_ascii_minus_s_
 //#define _di_f_string_ascii_n_s_
 #define _di_f_string_dynamic_mash_nulless_
 #define _di_f_string_dynamic_mish_
 #define _di_f_string_dynamic_mish_nulless_
-#define _di_f_string_dynamic_partial_append_
+//#define _di_f_string_dynamic_partial_append_
 #define _di_f_string_dynamic_partial_append_assure_
 #define _di_f_string_dynamic_partial_append_assure_nulless_
 #define _di_f_string_dynamic_partial_append_nulless_
index d73d54b31e3a2844343d8ffa7ac71c36147e0c91..ded027d264c6ff17b7d22dfdc9f951936c95d920 100644 (file)
@@ -91,7 +91,7 @@ build_sources_program fll/level_2/program.c fll/level_2/program/common.c fll/lev
 build_sources_program program/kevux/tools/tacocat/main/common.c program/kevux/tools/tacocat/main/common/define.c program/kevux/tools/tacocat/main/common/enumeration.c program/kevux/tools/tacocat/main/common/string.c program/kevux/tools/tacocat/main/common/type.c
 build_sources_program program/kevux/tools/tacocat/main/print/error.c program/kevux/tools/tacocat/main/print/message.c program/kevux/tools/tacocat/main/print/verbose.c program/kevux/tools/tacocat/main/print/warning.c
 build_sources_program program/kevux/tools/tacocat/main/packet.c program/kevux/tools/tacocat/main/process.c program/kevux/tools/tacocat/main/receive.c program/kevux/tools/tacocat/main/send.c program/kevux/tools/tacocat/main/signal.c program/kevux/tools/tacocat/main/tacocat.c program/kevux/tools/tacocat/main/thread.c
-build_sources_program program/kevux/tools/tacocat/main/send/step/check.c program/kevux/tools/tacocat/main/send/step/control.c program/kevux/tools/tacocat/main/send/step/done.c program/kevux/tools/tacocat/main/send/step/extract.c program/kevux/tools/tacocat/main/send/step/find.c program/kevux/tools/tacocat/main/send/step/next.c program/kevux/tools/tacocat/main/send/step/packet.c program/kevux/tools/tacocat/main/send/step/write.c
+build_sources_program program/kevux/tools/tacocat/main/receive/step/check.c program/kevux/tools/tacocat/main/receive/step/control.c program/kevux/tools/tacocat/main/receive/step/done.c program/kevux/tools/tacocat/main/receive/step/extract.c program/kevux/tools/tacocat/main/receive/step/find.c program/kevux/tools/tacocat/main/receive/step/next.c program/kevux/tools/tacocat/main/receive/step/packet.c program/kevux/tools/tacocat/main/receive/step/write.c
 build_sources_program program/kevux/tools/tacocat/main/send/step/build.c program/kevux/tools/tacocat/main/send/step/check.c program/kevux/tools/tacocat/main/send/step/done.c program/kevux/tools/tacocat/main/send/step/encode.c program/kevux/tools/tacocat/main/send/step/file.c program/kevux/tools/tacocat/main/send/step/header.c program/kevux/tools/tacocat/main/send/step/packet.c program/kevux/tools/tacocat/main/send/step/size.c program/kevux/tools/tacocat/main/send/step/wait.c
 build_sources_program program/kevux/tools/tacocat/tacocat/config.c program/kevux/tools/tacocat/tacocat/tacocat.c program/kevux/tools/tacocat/tacocat/main.c program/kevux/tools/tacocat/tacocat/string.c
 
index 672393ec27127d40ffde59e65927fc06a76a774f..810645cf2f6d0bde9af82c8cb0edce75d05dee28 100644 (file)
@@ -201,6 +201,25 @@ extern "C" {
       main->setting.flag &= ~kt_tacocat_main_flag_headers_d;
     }
 
+    if (main->program.parameters.array[kt_tacocat_parameter_as_e].result & f_console_result_found_d) {
+      if (main->program.parameters.array[kt_tacocat_parameter_as_e].result & f_console_result_value_d) {
+        if (main->program.parameters.array[kt_tacocat_parameter_as_e].values.used > (main->program.parameters.array[kt_tacocat_parameter_send_e].values.used / 2)) {
+          main->setting.state.status = F_status_set_error(F_parameter);
+
+          fll_program_print_error_parameter_too_many(&main->program.error, f_console_symbol_long_normal_s, kt_tacocat_long_as_s, main->program.parameters.array[kt_tacocat_parameter_as_e].values.used - (main->program.parameters.array[kt_tacocat_parameter_send_e].values.used / 2));
+
+          return;
+        }
+      }
+      else {
+        main->setting.state.status = F_status_set_error(F_parameter);
+
+        fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, kt_tacocat_long_as_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_d | kt_tacocat_main_flag_version_d |kt_tacocat_main_flag_help_d))) {
       main->callback.setting_load_send_receive(arguments, main);
@@ -257,10 +276,12 @@ extern "C" {
       F_file_mode_all_r_d,
     };
 
+    f_number_unsigned_t as = 0;
     f_number_unsigned_t j = 0;
     f_number_unsigned_t k = 0;
     f_number_unsigned_t p = 0;
     f_number_unsigned_t index = 0;
+    f_number_unsigned_t index_as = 0;
     f_number_unsigned_t length = 0;
     f_number_unsigned_t total = 0;
     f_status_t failed = F_okay;
@@ -306,11 +327,12 @@ extern "C" {
 
           sets[i]->array[j].size_block = default_block_size[i];
           sets[i]->array[j].abstruses.used = 0;
+          sets[i]->array[j].as.used = 0;
           sets[i]->array[j].buffer.used = 0;
           sets[i]->array[j].cache.used = 0;
           sets[i]->array[j].client.used = 0;
           sets[i]->array[j].header.used = 0;
-          sets[i]->array[j].flag = 0;
+          sets[i]->array[j].flag = is_receive[i] ? kt_tacocat_socket_step_flag_none_d : kt_tacocat_socket_step_flag_send_d;
           sets[i]->array[j].name.used = 0;
           sets[i]->array[j].network.used = 0;
           sets[i]->array[j].packet.control = 0;
@@ -539,41 +561,50 @@ extern "C" {
             sets[i]->array[j].file.size_read = sets[i]->array[j].size_block;
             sets[i]->array[j].file.size_write = sets[i]->array[j].size_block;
 
+            if (is_receive[i]) {
+              if (f_compare_dynamic(main->program.parameters.arguments.array[index], f_string_ascii_mark_question_s) == F_equal_to) {
+                sets[i]->array[j].flag |= kt_tacocat_socket_step_flag_keep_d;
+              }
+            }
+            else {
+              if (main->program.parameters.array[kt_tacocat_parameter_as_e].result & f_console_result_value_d) {
+                if (as < main->program.parameters.array[kt_tacocat_parameter_as_e].values.used) {
+                  index_as = main->program.parameters.array[kt_tacocat_parameter_as_e].values.array[as];
+
+                  // Associate "--as" value via a static string.
+                  sets[i]->array[j].as.string = main->program.parameters.arguments.array[index_as].string;
+                  sets[i]->array[j].as.used = main->program.parameters.arguments.array[index_as].used;
+                  sets[i]->array[j].as.size = 0;
+
+                  ++as;
+                }
+              }
+            }
+
             // Associate file name via a static string.
             sets[i]->array[j].name.string = main->program.parameters.arguments.array[index].string;
             sets[i]->array[j].name.used = main->program.parameters.arguments.array[index].used;
             sets[i]->array[j].name.size = 0;
 
-            // Make sure the file exists and can be read and/or can be written to, then close when done.
-            main->setting.state.status = f_file_open(sets[i]->array[j].name, file_modes[i], &sets[i]->array[j].file);
-
-            if (F_status_is_error(main->setting.state.status)) {
-              macro_kt_tacocat_handle_load_send_receive_error_file_continue_1(sets[i]->array[j].name, f_file_operation_open_s, fll_error_file_type_file_e);
+            // Make sure the file exists and can be read and/or can be written to, then close when done (if possible).
+            if (!is_receive[i] || !(sets[i]->array[j].flag & kt_tacocat_socket_step_flag_keep_d)) {
+              main->setting.state.status = f_file_open(sets[i]->array[j].name, file_modes[i], &sets[i]->array[j].file);
 
-              if (F_status_is_error_not(failed)) {
-                failed = main->setting.state.status;
-              }
-
-              sets[i]->array[j].status = main->setting.state.status;
-            }
-            else {
-              main->setting.state.status = f_file_close(&sets[i]->array[j].file);
+              if (F_status_is_error(main->setting.state.status)) {
+                macro_kt_tacocat_handle_load_send_receive_error_file_continue_1(sets[i]->array[j].name, f_file_operation_open_s, fll_error_file_type_file_e);
 
-              macro_kt_tacocat_handle_load_send_receive_error_file_continue_1(sets[i]->array[j].name, f_file_operation_close_s, fll_error_file_type_file_e);
-            }
-          }
-          else {
-            main->setting.state.status = F_status_set_error(F_parameter);
+                if (F_status_is_error_not(failed)) {
+                  failed = main->setting.state.status;
+                }
 
-            fll_program_print_error_parameter_empty_value(&main->program.error, f_console_symbol_long_normal_s, longs[i]);
+                sets[i]->array[j].status = main->setting.state.status;
+              }
+              else {
+                main->setting.state.status = f_file_close(&sets[i]->array[j].file);
 
-            if (F_status_is_error_not(failed)) {
-              failed = main->setting.state.status;
+                macro_kt_tacocat_handle_load_send_receive_error_file_continue_1(sets[i]->array[j].name, f_file_operation_close_s, fll_error_file_type_file_e);
+              }
             }
-
-            sets[i]->array[j].status = main->setting.state.status;
-
-            continue;
           }
         } // for
       }
index 58b9a663b57dedef6ab68dbaf387b1cb079d9c44..13a4e70044e1fbac283f3321dd61f300dfcf3fd9 100644 (file)
@@ -162,7 +162,7 @@ extern "C" {
     if (F_status_is_error(status)) { \
       kt_tacocat_print_error_on(&main->program.error, F_status_debug_source_d, kt_tacocat_receive_s, network, status, name); \
       \
-      step = 0; \
+      step = kt_tacocat_socket_step_receive_none_e; \
       \
       return; \
     }
@@ -274,6 +274,20 @@ extern "C" {
 #endif // _di_kt_tacocat_socket_flag_d_
 
 /**
+ * Flags related to the socket step.
+ *
+ * kt_tacocat_socket_step_flag_*_d:
+ *   - none: No flags set.
+ *   - send: Designate that the socket step is a send rather than a receive (when this is not set, the socket step is a receive).
+ *   - keep: This (receive) socket is to keep the file name provided by the sender.
+ */
+#ifndef _di_kt_tacocat_socket_step_flag_d_
+  #define kt_tacocat_socket_step_flag_none_d 0x0
+  #define kt_tacocat_socket_step_flag_send_d 0x1
+  #define kt_tacocat_socket_step_flag_keep_d 0x2
+#endif // _di_kt_tacocat_socket_step_flag_d_
+
+/**
  * A macro wrapping the appropriate signal check function based on threaded/non-threaded support.
  */
 #ifndef _di_kt_tacocat_signal_check_d_
index 6bbd7345e1aae0ca7ef3e4199ddb19a5a77f0ec0..6eeab9dc2f4ebc3bc21d76a20723f8662acf756f 100644 (file)
@@ -33,6 +33,7 @@ extern "C" {
     kt_tacocat_parameter_verbosity_debug_e,
     kt_tacocat_parameter_version_e,
 
+    kt_tacocat_parameter_as_e,
     kt_tacocat_parameter_headers_e,
     kt_tacocat_parameter_interval_e,
     kt_tacocat_parameter_max_buffer_e,
@@ -45,6 +46,7 @@ extern "C" {
     { \
       macro_fll_program_console_parameter_standard_initialize, \
       \
+      macro_f_console_parameter_t_initialize_3(kt_tacocat_short_as_s,         kt_tacocat_long_as_s,         1, f_console_flag_normal_d), \
       macro_f_console_parameter_t_initialize_3(kt_tacocat_short_headers_s,    kt_tacocat_long_headers_s,    0, f_console_flag_normal_d), \
       macro_f_console_parameter_t_initialize_3(kt_tacocat_short_interval_s,   kt_tacocat_long_interval_s,   1, f_console_flag_normal_d), \
       macro_f_console_parameter_t_initialize_3(kt_tacocat_short_max_buffer_s, kt_tacocat_long_max_buffer_s, 1, f_console_flag_normal_d), \
@@ -53,7 +55,7 @@ extern "C" {
       macro_f_console_parameter_t_initialize_3(kt_tacocat_short_send_s,       kt_tacocat_long_send_s,       2, f_console_flag_normal_d), \
     }
 
-  #define kt_tacocat_parameter_total_d (f_console_parameter_state_type_total_d + 6)
+  #define kt_tacocat_parameter_total_d (f_console_parameter_state_type_total_d + 7)
 #endif // _di_kt_tacocat_parameter_e_
 
 /**
index a914dab26e754d5bf6647ae45b9f41d78895638f..fb1190fbaa9a33fff1a3793b72e31c454a51b82a 100644 (file)
@@ -42,6 +42,7 @@ extern "C" {
 #endif // _di_kt_tacocat_s_
 
 #ifndef _di_kt_tacocat_parameter_s_
+  const f_string_static_t kt_tacocat_short_as_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_short_as_s, 0, KT_TACOCAT_short_as_s_length);
   const f_string_static_t kt_tacocat_short_headers_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_short_headers_s, 0, KT_TACOCAT_short_headers_s_length);
   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_max_buffer_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_short_max_buffer_s, 0, KT_TACOCAT_short_max_buffer_s_length);
@@ -49,6 +50,7 @@ extern "C" {
   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_as_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_long_as_s, 0, KT_TACOCAT_long_as_s_length);
   const f_string_static_t kt_tacocat_long_headers_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_long_headers_s, 0, KT_TACOCAT_long_headers_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_max_buffer_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_long_max_buffer_s, 0, KT_TACOCAT_long_max_buffer_s_length);
index 2760e4a73fdae8b7aa63a52cec93576491ac5b68..f71c58df5172b4e8f003d1c2b10d8b2caa983f9d 100644 (file)
@@ -152,6 +152,7 @@ extern "C" {
  * The main program parameters.
  */
 #ifndef _di_kt_tacocat_parameter_s_
+  #define KT_TACOCAT_short_as_s         "a"
   #define KT_TACOCAT_short_headers_s    "H"
   #define KT_TACOCAT_short_interval_s   "I"
   #define KT_TACOCAT_short_max_buffer_s "M"
@@ -159,6 +160,7 @@ extern "C" {
   #define KT_TACOCAT_short_resolve_s    "R"
   #define KT_TACOCAT_short_send_s       "s"
 
+  #define KT_TACOCAT_long_as_s         "as"
   #define KT_TACOCAT_long_headers_s    "headers"
   #define KT_TACOCAT_long_interval_s   "interval"
   #define KT_TACOCAT_long_max_buffer_s "max_buffer"
@@ -166,13 +168,15 @@ extern "C" {
   #define KT_TACOCAT_long_resolve_s    "resolve"
   #define KT_TACOCAT_long_send_s       "send"
 
-  #define KT_TACOCAT_short_headers_s_length   1
+  #define KT_TACOCAT_short_as_s_length         1
+  #define KT_TACOCAT_short_headers_s_length    1
   #define KT_TACOCAT_short_interval_s_length   1
   #define KT_TACOCAT_short_max_buffer_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_as_s_length         2
   #define KT_TACOCAT_long_headers_s_length    7
   #define KT_TACOCAT_long_interval_s_length   8
   #define KT_TACOCAT_long_max_buffer_s_length 10
@@ -180,6 +184,7 @@ extern "C" {
   #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_as_s;
   extern const f_string_static_t kt_tacocat_short_headers_s;
   extern const f_string_static_t kt_tacocat_short_interval_s;
   extern const f_string_static_t kt_tacocat_short_max_buffer_s;
@@ -187,6 +192,7 @@ extern "C" {
   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_as_s;
   extern const f_string_static_t kt_tacocat_long_headers_s;
   extern const f_string_static_t kt_tacocat_long_interval_s;
   extern const f_string_static_t kt_tacocat_long_max_buffer_s;
index 516e20c2de90fb438e74d0b9ad7d0de71b61d7fe..561d08385108d0f418690773da570fd6e8fda3ce 100644 (file)
@@ -122,6 +122,10 @@ extern "C" {
           f_memory_array_resize(0, sizeof(f_range_t), (void **) &array[i].comments.array, &array[i].comments.used, &array[i].comments.size);
         }
 
+        if (array[i].as.size) {
+          f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].as.string, &array[i].as.used, &array[i].as.size);
+        }
+
         if (array[i].buffer.size) {
           f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].buffer.string, &array[i].buffer.used, &array[i].buffer.size);
         }
index 2f79c4afb98147be164af58790a1e7f833d3c1fa..22f1034aad572715d13a468388479e156df73776 100644 (file)
@@ -31,7 +31,7 @@ extern "C" {
  * size_total: The size in bytes tht represent the entire size to be processed (size_done should eventually equal this).
  *
  * flag:  A set of flags.
- * step:  The current step the socket set is operating under.
+ * step:  The current step the socket set is operating under (this is either a send or receive step define depending on whether or not flag has the send bit set).
  * retry: The current number of retries performed.
  * part:  The current active part number.
  * port:  The current port number for the socket.
@@ -61,6 +61,7 @@ extern "C" {
  * comments:                    An array of FSS comments.
  * state:                       Basic state information, usually passed to the FSS functions.
  *
+ * as:          A custom name to use for the file rather than the actual file name.
  * buffer:      A buffer for sending or receiving data between clients.
  * cache:       A cache used for various purposes, but primarily for the building of the send packet.
  * client:      A single client address for some network connection.
@@ -111,6 +112,7 @@ extern "C" {
     f_ranges_t comments;
     f_state_t state;
 
+    f_string_dynamic_t as;
     f_string_dynamic_t buffer;
     f_string_dynamic_t cache;
     f_string_dynamic_t client;
@@ -131,8 +133,8 @@ extern "C" {
       kt_tacocat_block_size_d, \
       0, \
       0, \
-      0, \
-      0, \
+      kt_tacocat_socket_step_flag_none_d, \
+      kt_tacocat_socket_step_receive_none_e, \
       0, \
       f_file_t_initialize, \
       f_socket_t_initialize, \
@@ -163,6 +165,7 @@ extern "C" {
       f_string_dynamic_t_initialize, \
       f_string_dynamic_t_initialize, \
       f_string_dynamic_t_initialize, \
+      f_string_dynamic_t_initialize, \
       f_fss_simple_packet_range_t_initialize, \
       fl_fss_payload_header_state_t_initialize, \
       f_abstruse_maps_t_initialize, \
@@ -174,8 +177,8 @@ extern "C" {
       size_block, \
       0, \
       0, \
-      0, \
-      0, \
+      kt_tacocat_socket_step_flag_none_d, \
+      kt_tacocat_socket_step_receive_none_e, \
       0, \
       f_file_t_initialize, \
       f_poll_t_initialize, \
@@ -207,6 +210,7 @@ extern "C" {
       f_string_dynamic_t_initialize, \
       f_string_dynamic_t_initialize, \
       f_string_dynamic_t_initialize, \
+      f_string_dynamic_t_initialize, \
       f_fss_simple_packet_range_t_initialize, \
       fl_fss_payload_header_state_t_initialize, \
       f_abstruse_maps_t_initialize, \
@@ -218,8 +222,8 @@ extern "C" {
       size_block, \
       0, \
       0, \
-      0, \
-      0, \
+      kt_tacocat_socket_step_flag_none_d, \
+      kt_tacocat_socket_step_receive_none_e, \
       0, \
       f_file_t_initialize, \
       f_poll_t_initialize, \
@@ -251,6 +255,7 @@ extern "C" {
       f_string_dynamic_t_initialize, \
       f_string_dynamic_t_initialize, \
       f_string_dynamic_t_initialize, \
+      f_string_dynamic_t_initialize, \
       f_fss_simple_packet_range_t_initialize, \
       write_state, \
       f_abstruse_maps_t_initialize, \
index 3dd8ba342af9949895ed96766b4fd880b1b79b53..8cd4352220d1cd2b27795d16fbfa4c3a3d0a5375 100644 (file)
@@ -5,20 +5,20 @@ extern "C" {
 #endif
 
 #ifndef _di_kt_tacocat_packet_extract_
-  void kt_tacocat_packet_extract(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set, const f_string_static_t direction) {
+  void kt_tacocat_packet_extract(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set) {
 
     if (!main || !set) return;
 
     kt_tacocat_process_abstruse_initialize(main, set);
 
     if (F_status_is_error(set->status)) {
-      kt_tacocat_print_error_on(&main->program.error, F_status_debug_source_d, direction, set->network, set->status, set->name);
+      kt_tacocat_print_error_on(&main->program.error, F_status_debug_source_d, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, set->status, set->name);
 
       if (set->socket.id_data != -1) {
         f_file_close_id(&set->socket.id_data);
       }
 
-      set->step = 0;
+      set->step = kt_tacocat_socket_step_receive_none_e;
 
       return;
     }
@@ -29,7 +29,7 @@ extern "C" {
     for (f_number_unsigned_t i = 0; i < set->objects.used; ++i) {
 
       if (f_compare_dynamic_partial_string(f_fss_payload_object_header_s.string, set->buffer, f_fss_payload_object_header_s.used, set->objects.array[i]) == F_equal_to) {
-        kt_tacocat_packet_extract_header(main, set, i, direction);
+        kt_tacocat_packet_extract_header(main, set, i);
 
         if (F_status_is_error(set->status)) {
           // @todo handle F_packet error, setup the sending of an invalid packet response (things similar to this needs to be done in multiple places).
@@ -41,7 +41,7 @@ extern "C" {
         found_not &= ~0x2;
       }
       else if (f_compare_dynamic_partial_string(f_fss_payload_object_signature_s.string, set->buffer, f_fss_payload_object_signature_s.used, set->objects.array[i]) == F_equal_to) {
-        kt_tacocat_packet_extract_signature(main, set, i, direction);
+        kt_tacocat_packet_extract_signature(main, set, i);
 
         if (F_status_is_error(set->status)) {
           ++set->retry;
@@ -62,7 +62,7 @@ extern "C" {
 #endif // _di_kt_tacocat_packet_extract_
 
 #ifndef _di_kt_tacocat_packet_extract_header_
-  void kt_tacocat_packet_extract_header(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set, const f_number_unsigned_t at, const f_string_static_t direction) {
+  void kt_tacocat_packet_extract_header(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set, const f_number_unsigned_t at) {
 
     if (!main || !set) return;
 
@@ -77,7 +77,7 @@ extern "C" {
     set->status = f_memory_array_increase_by(kt_tacocat_packet_headers_d, sizeof(f_abstruse_map_t), (void **) &set->abstruses.array, &set->abstruses.used, &set->abstruses.size);
 
     if (F_status_is_error(set->status)) {
-      kt_tacocat_print_error_on(&main->program.error, F_status_debug_source_d, direction, set->network, set->status, set->name);
+      kt_tacocat_print_error_on(&main->program.error, F_status_debug_source_d, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, set->status, set->name);
 
       return;
     }
@@ -89,7 +89,7 @@ extern "C" {
     if (F_status_is_error(set->state.status)) {
       set->status = set->state.status;
 
-      kt_tacocat_print_error_on(&main->program.error, F_status_debug_source_d, direction, set->network, set->status, set->name);
+      kt_tacocat_print_error_on(&main->program.error, F_status_debug_source_d, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, set->status, set->name);
 
       return;
     }
@@ -160,7 +160,7 @@ extern "C" {
     // Convert the status code.
     if (set->abstruses.array[0].value.type) {
       if (ranges[0].start > ranges[0].stop) {
-        kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, direction, set->network, F_found_not, set->name, set->buffer, set->objects.array[at], ranges[0]);
+        kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, F_found_not, set->name, set->buffer, set->objects.array[at], ranges[0]);
 
         set->abstruses.array[0].value.type = f_abstruse_none_e;
         set->abstruses.array[0].value.is.a_unsigned = 0;
@@ -183,7 +183,7 @@ extern "C" {
           set->abstruses.array[0].value.is.a_unsigned = (f_number_unsigned_t) code;
         }
         else {
-          kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, direction, set->network, F_status_is_error(status) ? status : F_found_not, set->name, set->buffer, set->objects.array[at], ranges[0]);
+          kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, F_status_is_error(status) ? status : F_found_not, set->name, set->buffer, set->objects.array[at], ranges[0]);
 
           set->abstruses.array[0].value.type = f_abstruse_none_e;
           set->abstruses.array[0].value.is.a_unsigned = 0;
@@ -197,7 +197,7 @@ extern "C" {
     if (set->abstruses.array[1].value.type) {
       if (ranges[1].start > ranges[1].stop) {
 
-        kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, direction, set->network, F_packet, set->name, set->buffer, set->objects.array[at], ranges[1]);
+        kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, F_packet, set->name, set->buffer, set->objects.array[at], ranges[1]);
 
         set->abstruses.array[1].value.type = f_abstruse_none_e;
         set->abstruses.array[1].value.is.a_unsigned = 0;
@@ -222,7 +222,7 @@ extern "C" {
           set->abstruses.array[1].value.is.a_unsigned = (f_number_unsigned_t) kt_tacocat_packet_type_resend_d;
         }
         else {
-          kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, direction, set->network, F_found_not, set->name, set->buffer, set->objects.array[at], ranges[1]);
+          kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, F_found_not, set->name, set->buffer, set->objects.array[at], ranges[1]);
 
           set->abstruses.array[1].value.type = f_abstruse_none_e;
           set->abstruses.array[1].value.is.a_unsigned = 0;
@@ -232,10 +232,11 @@ extern "C" {
       }
     }
 
-    // Convert the name.
+    // Convert the name, storing the extracted name in set.as for managing allocation and de-allocation.
+    // @todo this abstruse should only exist for the main receive packet for the main receive packet type; review this and handle accordingly.
     if (set->abstruses.array[5].value.type) {
       if (ranges[5].start > ranges[5].stop) {
-        kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, direction, set->network, F_found_not, set->name, set->buffer, set->objects.array[at], ranges[5]);
+        kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, F_found_not, set->name, set->buffer, set->objects.array[at], ranges[5]);
 
         set->abstruses.array[5].value.type = f_abstruse_none_e;
         set->abstruses.array[5].value.is.a_unsigned = 0;
@@ -243,12 +244,12 @@ extern "C" {
         set->status = F_status_set_error(F_packet);
       }
       else {
-        set->name.used = 0;
+        set->as.used = 0;
 
-        status = f_string_dynamic_partial_append(set->buffer, ranges[5], &set->name);
+        status = f_string_dynamic_partial_append(set->buffer, ranges[5], &set->as);
 
         if (F_status_is_error(status)) {
-          kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, direction, set->network, status, set->name, set->buffer, set->objects.array[at], ranges[5]);
+          kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, status, set->name, set->buffer, set->objects.array[at], ranges[5]);
 
           set->abstruses.array[5].value.type = f_abstruse_none_e;
           set->abstruses.array[5].value.is.a_unsigned = 0;
@@ -257,7 +258,7 @@ extern "C" {
         }
         else {
           set->abstruses.array[5].value.type = f_abstruse_dynamic_e;
-          set->abstruses.array[5].value.is.a_dynamic = set->name;
+          set->abstruses.array[5].value.is.a_dynamic = set->as;
           set->abstruses.array[5].value.is.a_dynamic.size = 0;
         }
       }
@@ -266,7 +267,7 @@ extern "C" {
     // Convert the id.
     if (set->abstruses.array[7].value.type && ranges[7].start <= ranges[7].stop) {
       if (ranges[7].start > ranges[7].stop) {
-        kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, direction, set->network, F_found_not, set->name, set->buffer, set->objects.array[at], ranges[7]);
+        kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, F_found_not, set->name, set->buffer, set->objects.array[at], ranges[7]);
 
         set->abstruses.array[7].value.type = f_abstruse_none_e;
         set->abstruses.array[7].value.is.a_unsigned = 0;
@@ -279,7 +280,7 @@ extern "C" {
         status = f_string_dynamic_partial_append(set->buffer, ranges[7], &set->id);
 
         if (F_status_is_error(status)) {
-          kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, direction, set->network, status, set->id, set->buffer, set->objects.array[at], ranges[7]);
+          kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, status, set->id, set->buffer, set->objects.array[at], ranges[7]);
 
           set->abstruses.array[7].value.type = f_abstruse_none_e;
           set->abstruses.array[7].value.is.a_unsigned = 0;
@@ -297,7 +298,7 @@ extern "C" {
     // Convert the time.
     if (set->abstruses.array[8].value.type) {
       if (ranges[8].start > ranges[8].stop) {
-        kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, direction, set->network, F_found_not, set->name, set->buffer, set->objects.array[at], ranges[8]);
+        kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, F_found_not, set->name, set->buffer, set->objects.array[at], ranges[8]);
 
         set->abstruses.array[8].value.type = f_abstruse_none_e;
         set->abstruses.array[8].value.is.a_unsigned = 0;
@@ -310,7 +311,7 @@ extern "C" {
         status = f_string_dynamic_partial_append(set->buffer, ranges[8], &set->time);
 
         if (F_status_is_error(status)) {
-          kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, direction, set->network, status, set->time, set->buffer, set->objects.array[at], ranges[8]);
+          kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, status, set->time, set->buffer, set->objects.array[at], ranges[8]);
 
           set->abstruses.array[8].value.type = f_abstruse_none_e;
           set->abstruses.array[8].value.is.a_unsigned = 0;
@@ -340,7 +341,7 @@ extern "C" {
           set->abstruses.array[i].value.is.a_unsigned = number;
         }
         else {
-          kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, direction, set->network, status, set->name, set->buffer, set->objects.array[at], ranges[i]);
+          kt_tacocat_print_error_on_packet_header_value_invalid(&main->program.error, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, status, set->name, set->buffer, set->objects.array[at], ranges[i]);
 
           set->abstruses.array[i].value.type = f_abstruse_none_e;
           set->abstruses.array[i].value.is.a_unsigned = 0;
@@ -352,12 +353,14 @@ extern "C" {
       } // for
     }
 
+    // @todo index 9 is the signature.
+
     set->abstruses.used = kt_tacocat_packet_headers_d;
   }
 #endif // _di_kt_tacocat_packet_extract_header_
 
 #ifndef _di_kt_tacocat_packet_extract_signature_
-  void kt_tacocat_packet_extract_signature(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set, const f_number_unsigned_t at, const f_string_static_t direction) {
+  void kt_tacocat_packet_extract_signature(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set, const f_number_unsigned_t at) {
 
     if (!main || !set) return;
 
@@ -372,14 +375,14 @@ extern "C" {
     fll_fss_extended_read(set->buffer, &set->range, &set->objects_signature, &set->contents_signature, &set->objects_quoted_header, &set->contents_quoted_header, &set->objects_delimits_signature, &set->contents_delimits_signature, &set->state);
 
     if (F_status_is_error(set->state.status)) {
-      kt_tacocat_print_error_on(&main->program.error, F_status_debug_source_d, direction, set->network, set->status, set->name);
+      kt_tacocat_print_error_on(&main->program.error, F_status_debug_source_d, (set->flag & kt_tacocat_socket_step_flag_send_d) ? kt_tacocat_send_s : kt_tacocat_receive_s, set->network, set->status, set->name);
 
       set->status = set->state.status;
 
       return;
     }
 
-    // @todo maybe index 8 and beyond in the abstruse shall represent signatures?
+    // @todo index 9 in the abstruse shall represent signatures.
 
     set->status = F_okay;
   }
index 1f4d773998db166d0d56489c31e2cbdcecef4b7f..c36025787f90c5fd8c359c41c44212cfbd998f68 100644 (file)
@@ -37,16 +37,13 @@ extern "C" {
  *     Errors (with error bit) from: f_memory_array_increase_by().
  *     Errors (with error bit) from: kt_tacocat_packet_extract_header().
  *     Errors (with error bit) from: kt_tacocat_packet_extract_signature().
- * @param direction
- *   The string representing the direction and is used for error handling.
- *   This is generally either kt_tacocat_receive_s or kt_tacocat_send_s.
  *
  * @see f_memory_array_increase_by()
  * @see kt_tacocat_packet_extract_header()
  * @see kt_tacocat_packet_extract_signature()
  */
 #ifndef _di_kt_tacocat_packet_extract_
-  extern void kt_tacocat_packet_extract(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set, const f_string_static_t direction);
+  extern void kt_tacocat_packet_extract(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set);
 #endif // _di_kt_tacocat_packet_extract_
 
 /**
@@ -84,14 +81,11 @@ extern "C" {
  *     Errors (with error bit) from: fll_fss_extended_read().
  * @param at
  *   The index position representing which Object and Contents set to use.
- * @param direction
- *   The string representing the direction and is used for error handling.
- *   This is generally either kt_tacocat_receive_s or kt_tacocat_send_s.
  *
  * @see fll_fss_extended_read()
  */
 #ifndef _di_kt_tacocat_packet_extract_header_
-  extern void kt_tacocat_packet_extract_header(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set, const f_number_unsigned_t at, const f_string_static_t direction);
+  extern void kt_tacocat_packet_extract_header(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set, const f_number_unsigned_t at);
 #endif // _di_kt_tacocat_packet_extract_header_
 
 /**
@@ -110,14 +104,11 @@ extern "C" {
  *
  *   This alters set.status:
  *     F_okay on success.
- * @param direction
- *   The string representing the direction and is used for error handling.
- *   This is generally either kt_tacocat_receive_s or kt_tacocat_send_s.
  * @param at
  *   The index position representing which Object and Contents set to use.
  */
 #ifndef _di_kt_tacocat_packet_extract_signature_
-  extern void kt_tacocat_packet_extract_signature(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set, const f_number_unsigned_t at, const f_string_static_t direction);
+  extern void kt_tacocat_packet_extract_signature(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set, const f_number_unsigned_t at);
 #endif // _di_kt_tacocat_packet_extract_signature_
 
 #ifdef __cplusplus
index 14f9d59970bc1e04bd3f414b60fe0788c63e3529..d11f5cf6cd130952554c6d63d9a051dee67b8cad 100644 (file)
@@ -224,7 +224,7 @@ extern "C" {
     fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, set->name, print->set->notable);
     fl_print_format("%['", print->to, print->set->error);
 
-    if (set->flag == kt_tacocat_socket_step_receive_find_e) {
+    if (set->step == kt_tacocat_socket_step_receive_find_e) {
       fl_print_format(" while trying to process the Packet headers", print->to);
     }
 
index ec24d9440218914c2a594bb453a18c94b2acc465..d533aed95c6b6f59c3dbaafc697a0a1c19d4557d 100644 (file)
@@ -12,7 +12,7 @@ extern "C" {
 
     f_file_stream_lock(print->to);
 
-    fl_print_format(sent ? "Headers Sent to " : "Headers Received from ", print->to, f_string_eol_s);
+    fl_print_format(sent ? "%rHeaders Sent to " : "%rHeaders Received from ", print->to, f_string_eol_s);
     fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, set.network, print->set->notable);
 
     if (set.port) {
@@ -52,6 +52,7 @@ extern "C" {
 
     f_print_dynamic_raw(f_string_eol_s, print->to);
 
+    fll_program_print_help_option(print, kt_tacocat_short_as_s, kt_tacocat_long_as_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "        Designate a different name to send the file as.");
     fll_program_print_help_option(print, kt_tacocat_short_headers_s, kt_tacocat_long_headers_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "   Print the headers on send or on receive.");
     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_max_buffer_s, kt_tacocat_long_max_buffer_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Specify a maximum buffer size to allow (in bytes) when receiving packets.");
@@ -78,6 +79,9 @@ extern "C" {
     fl_print_format("    %[%r%]: The network address or the socket file to use.%r", print->to, print->set->notable, kt_tacocat_network_or_socket_s, print->set->notable, f_string_eol_s);
     fl_print_format("    %[%r%]: The local file to use to read from or to write to.%r%r", print->to, print->set->notable, kt_tacocat_file_s, print->set->notable, f_string_eol_s, f_string_eol_s);
 
+    fl_print_format("  Specify a question mark '%[?%]' (%[U+003F%]) ", print->to, context.set.notable, context.set.notable, context.set.notable, context.set.notable);
+    fl_print_format("as the receive file name to use the file name provided by the sender.%r%r", print->to, context.set.notable, context.set.notable, f_string_eol_s, f_string_eol_s);
+
     fl_print_format("  A local socket file must begin with an absolute path like '%[/var/www.example.com%]' and ", print->to, context.set.notable, context.set.notable);
     fl_print_format("'%[/var/example.socket%]', or it must begin with a relative absolute path, like ", print->to, context.set.notable, context.set.notable);
     fl_print_format("'%[./www.example.com%]' and %[./example.socket%].%r%r", print->to, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s, f_string_eol_s);
@@ -101,7 +105,7 @@ extern "C" {
 
     f_file_stream_lock(print->to);
 
-    fl_print_format("Packet from ", print->to);
+    fl_print_format("%rPacket from ", print->to, f_string_eol_s);
     fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, set.network, print->set->notable);
     fl_print_format(" is complete.%r", print->to, f_string_eol_s);
 
@@ -117,7 +121,7 @@ extern "C" {
 
     f_file_stream_lock(print->to);
 
-    fl_print_format("Packet from ", print->to);
+    fl_print_format("%rPacket from ", print->to, f_string_eol_s);
     fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, set.network, print->set->notable);
     fl_print_format(" is %[%ul%] Bytes.%r", print->to, print->set->notable, set.packet.size, print->set->notable, f_string_eol_s);
 
@@ -142,12 +146,28 @@ extern "C" {
       fl_print_format("')", print->to);
     }
 
-    fl_print_format(".%r", print->to, f_string_eol_s);
+    fl_print_format(f_string_format_sentence_end_s.string, print->to, f_string_eol_s);
 
     f_file_stream_unlock(print->to);
   }
 #endif // _di_kt_tacocat_print_message_receive_operation_received_
 
+#ifndef _di_kt_tacocat_print_message_receive_operation_determined_name_
+  f_status_t kt_tacocat_print_message_receive_operation_determined_name(fl_print_t * const print, const kt_tacocat_socket_set_t set) {
+
+    if (!print) return F_status_set_error(F_output_not);
+    if (print->verbosity < f_console_verbosity_verbose_e) return F_output_not;
+
+    f_file_stream_lock(print->to);
+
+    fl_print_format("%rDetermined the received file name to be ", print->to, f_string_eol_s);
+    fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, set.as, print->set->notable);
+    fl_print_format(f_string_format_sentence_end_s.string, print->to, f_string_eol_s);
+
+    f_file_stream_unlock(print->to);
+  }
+#endif // _di_kt_tacocat_print_message_receive_operation_determined_name_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index a3288d8f06ecddbea371396aa472075059309e5c..bc722b2c28b749a6807b5b0f5d73e352ea9fb9be 100644 (file)
@@ -141,6 +141,32 @@ extern "C" {
   extern f_status_t kt_tacocat_print_message_receive_operation_received(fl_print_t * const print, const kt_tacocat_socket_set_t set);
 #endif // _di_kt_tacocat_print_message_receive_operation_received_
 
+/**
+ * Print message about receive operation packet name being determined.
+ *
+ * This prints the name from the set.as string.
+ *
+ * @param print
+ *   The output structure to print to.
+ *
+ *   This locks, uses, and unlocks the file stream.
+ *
+ *   Must not be NULL.
+ *
+ *   This does not alter print.custom.setting.state.status.
+ * @param set
+ *   The socket set relating to the message.
+ *
+ * @return
+ *   F_okay on success.
+ *   F_output_not on success, but no printing is performed.
+ *
+ *   F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_kt_tacocat_print_message_receive_operation_determined_name_
+  extern f_status_t kt_tacocat_print_message_receive_operation_determined_name(fl_print_t * const print, const kt_tacocat_socket_set_t set);
+#endif // _di_kt_tacocat_print_message_receive_operation_determined_name_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 36bea43848883d3749b298091d6806d2195bbffb..26939e1535a708f275be92fd9fb3a5a8e9580c55 100644 (file)
@@ -96,7 +96,7 @@ extern "C" {
     // Index 5 is the name.
     set->abstruses.array[5].key = f_fss_payload_object_name_s;
     set->abstruses.array[5].value.type = f_abstruse_dynamic_e;
-    set->abstruses.array[5].value.is.a_dynamic = set->name;
+    set->abstruses.array[5].value.is.a_dynamic = (set->flag & kt_tacocat_socket_step_flag_send_d) && set->as.used ? set->as : set->name;
     set->abstruses.array[5].value.is.a_dynamic.size = 0;
 
     // Index 6 is the salt.
@@ -115,6 +115,8 @@ extern "C" {
     set->abstruses.array[8].value.is.a_dynamic = set->time;
     set->abstruses.array[8].value.is.a_dynamic.size = 0;
 
+    // Index 9 is the signature.
+
     {
       long salt = 0;
 
index c0946dc063d87dac2cbbeb0761fb69d88c66d0db..3a59f310cdf1c3f6986706228dff1cfd253f5fb9 100644 (file)
@@ -47,7 +47,7 @@ extern "C" {
                     set->status = F_status_set_error(F_done);
 
                     if (set->step) {
-                      set->step = 0;
+                      set->step = kt_tacocat_socket_step_receive_none_e;
 
                       if (main->setting.active_receive) {
                         --main->setting.active_receive;
@@ -72,7 +72,7 @@ extern "C" {
                     set->status = F_status_set_error(F_done);
 
                     if (set->step) {
-                      set->step = 0;
+                      set->step = kt_tacocat_socket_step_receive_none_e;
 
                       if (main->setting.active_receive) {
                         --main->setting.active_receive;
@@ -113,7 +113,7 @@ extern "C" {
     if (!(set->step)) {
       kt_tacocat_print_message_receive_operation_received(&main->program.message, *set);
 
-      kt_tacocat_receive_process_initialize(main, set);
+      kt_tacocat_receive_process_reset(main, set);
 
       ++main->setting.active_receive;
     }
@@ -123,7 +123,7 @@ extern "C" {
 
       // Keep error bit but set state to done to designate that nothing else is to be done.
       set->status = F_status_set_error(F_done);
-      set->step = 0;
+      set->step = kt_tacocat_socket_step_receive_none_e;
 
       if (main->setting.active_receive) {
         --main->setting.active_receive;
@@ -232,7 +232,7 @@ extern "C" {
         // Connection is closed when length is 0.
         kt_tacocat_print_warning_on_client_closed(&main->program.warning, kt_tacocat_receive_s, set->network);
 
-        set->step = 0;
+        set->step = kt_tacocat_socket_step_receive_none_e;
         set->status = F_status_set_error(F_packet_too_small);
 
         return;
@@ -258,7 +258,7 @@ extern "C" {
         }
       }
 
-      set->step = 0;
+      set->step = kt_tacocat_socket_step_receive_none_e;
 
       if (set->status == F_packet_too_small || set->packet.size < kt_tacocat_packet_minimum_d) {
         set->status = F_status_set_error(F_packet_too_small);
@@ -276,8 +276,8 @@ extern "C" {
   }
 #endif // _di_kt_tacocat_receive_process_control_
 
-#ifndef _di_kt_tacocat_receive_process_initialize_
-  void kt_tacocat_receive_process_initialize(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set) {
+#ifndef _di_kt_tacocat_receive_process_reset_
+  void kt_tacocat_receive_process_reset(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set) {
 
     if (!main || !set) return;
 
@@ -308,9 +308,8 @@ extern "C" {
     set->part = 0;
     set->parts.used = 0;
     set->step = kt_tacocat_socket_step_receive_control_e;
-    set->flag = 0;
   }
-#endif // _di_kt_tacocat_receive_process_initialize_
+#endif // _di_kt_tacocat_receive_process_reset_
 
 #ifdef __cplusplus
 } // extern "C"
index 9fe80b49c6419e03266acbc03fa2906db73e5ee1..d75585475f8a496cf948ef798108295977c4a061 100644 (file)
@@ -129,7 +129,9 @@ extern "C" {
 #endif // _di_kt_tacocat_receive_process_control_
 
 /**
- * Process the network socket, performing the initialization step such as when step == 0.
+ * Process the network socket, resetting the data during the initialization step, such as when step == 0.
+ *
+ * This does not and must not alter the socket step flags.
  *
  * @param main
  *   The main program and settings data.
@@ -144,9 +146,9 @@ extern "C" {
  *
  *   This does not alter set.status.
  */
-#ifndef _di_kt_tacocat_receive_process_initialize_
-  extern void kt_tacocat_receive_process_initialize(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set);
-#endif // _di_kt_tacocat_receive_process_initialize_
+#ifndef _di_kt_tacocat_receive_process_reset_
+  extern void kt_tacocat_receive_process_reset(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set);
+#endif // _di_kt_tacocat_receive_process_reset_
 
 #ifdef __cplusplus
 } // extern "C"
index 070a256ad6f0df84d2534182fe4724b20ffd47c1..140a97b8f94ceb544383161538472823100f5cc9 100644 (file)
@@ -71,7 +71,7 @@ extern "C" {
         f_file_close_id(&set->socket.id_data);
       }
 
-      set->step = 0;
+      set->step = kt_tacocat_socket_step_receive_none_e;
 
       return;
     }
index 5e76ce002b91a0f88e8005e102a3353728adfb08..e9a7b0cd14ae6dcd9bb3a2129c5eac8df2fd881f 100644 (file)
@@ -33,7 +33,7 @@ extern "C" {
         f_file_close_id(&set->socket.id_data);
       }
 
-      set->step = 0;
+      set->step = kt_tacocat_socket_step_receive_none_e;
 
       return F_complete_not;
     }
index 249ede0af02fe94a1ee165d8cf7228ff383e5292..5b18ff9d216257daa00308dfa7018ea3d1434e9c 100644 (file)
@@ -14,6 +14,11 @@ extern "C" {
     if (main->setting.flag & kt_tacocat_main_flag_headers_d) {
       kt_tacocat_print_message_headers(&main->program.message, *set, F_false);
     }
+    else {
+      if (!(set->flag & kt_tacocat_socket_step_flag_send_d) && (set->flag & kt_tacocat_socket_step_flag_keep_d)) {
+        kt_tacocat_print_message_receive_operation_determined_name(&main->program.message, *set);
+      }
+    }
 
     set->status = f_file_close(&set->file);
 
@@ -21,7 +26,7 @@ extern "C" {
       kt_tacocat_print_warning_on_file(&main->program.warning, F_status_debug_source_d, kt_tacocat_receive_done_s, set->network, set->status, set->name, f_file_operation_close_s);
     }
 
-    set->step = 0;
+    set->step = kt_tacocat_socket_step_receive_none_e;
     set->status = F_okay;
 
     if (main->setting.active_receive) {
index ece604600ffc3ef544859bfaf381240968e68207..dbac95e97de942868e3e872e6963da413f0a63d5 100644 (file)
@@ -9,7 +9,7 @@ extern "C" {
 
     if (!main || !set || F_status_is_error(set->status)) return;
 
-    kt_tacocat_packet_extract(main, set, kt_tacocat_receive_s);
+    kt_tacocat_packet_extract(main, set);
     if (F_status_is_error(set->status)) return;
 
     set->step = kt_tacocat_socket_step_receive_check_e;
index 6fb424ee10ffdb472ea1b40e99e33f5709f7ebc5..3709b6c141cbb211ea9ff829fced4fdce417f0f8 100644 (file)
@@ -21,7 +21,7 @@ extern "C" {
         f_file_close_id(&set->socket.id_data);
       }
 
-      set->step = 0;
+      set->step = kt_tacocat_socket_step_receive_none_e;
 
       return F_complete_not;
     }
index d340bdfc3e4bbb0c88a2567d8078631557df7a98..2b8065b37da49a4455de06ace7718f7af38ba2d8 100644 (file)
@@ -9,7 +9,7 @@ extern "C" {
 
     if (!main || !set || F_status_is_error(set->status)) return;
 
-    set->status = f_file_open(set->name, F_file_mode_all_rw_d, &set->file);
+    set->status = f_file_open((set->flag & kt_tacocat_socket_step_flag_keep_d) && set->as.used ? set->as : set->name, F_file_mode_all_rw_d, &set->file);
 
     if (F_status_is_error(set->status)) {
       kt_tacocat_print_error_on_file_receive(&main->program.error, F_status_debug_source_d, kt_tacocat_receive_s, set->network, set->status, set->name, f_file_operation_open_s);
index 6bfa36f76217d5c3b5b5ed791658321ea7830b29..6f95d41a7ae7f488a569c12d2299c06e6e19365f 100644 (file)
@@ -94,7 +94,7 @@ extern "C" {
     if (!main || !set) return F_status_set_error(F_parameter);
 
     if (!set->step) {
-      kt_tacocat_send_process_initialize(main, set);
+      kt_tacocat_send_process_reset(main, set);
 
       if (F_status_is_error(set->status)) {
         kt_tacocat_print_error_on(&main->program.error, F_status_debug_source_d, kt_tacocat_send_s, set->network, set->status, set->name);
@@ -109,7 +109,7 @@ extern "C" {
       f_file_close(&set->file);
       f_socket_disconnect(&set->socket, f_socket_close_fast_e);
 
-      set->step = 0;
+      set->step = kt_tacocat_socket_step_send_none_e;
       set->socket.id_data = -1;
 
       // Keep error bit but set state to done to designate that nothing else is to be done.
@@ -166,8 +166,8 @@ extern "C" {
   }
 #endif // _di_kt_tacocat_send_process_
 
-#ifndef _di_kt_tacocat_send_process_initialize_
-  void kt_tacocat_send_process_initialize(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set) {
+#ifndef _di_kt_tacocat_send_process_reset_
+  void kt_tacocat_send_process_reset(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set) {
 
     if (!main || !set) return;
 
@@ -200,7 +200,6 @@ extern "C" {
     set->part = 0;
     set->parts.used = 0;
     set->port = 0;
-    set->flag = 0;
 
     // For writes, the id_data is the same as the id.
     set->socket.id_data = set->socket.id;
@@ -274,7 +273,7 @@ extern "C" {
       set->status = F_okay;
     }
   }
-#endif // _di_kt_tacocat_send_process_initialize_
+#endif // _di_kt_tacocat_send_process_reset_
 
 #ifndef _di_kt_tacocat_send_process_time_now_
   void kt_tacocat_send_process_time_now(kt_tacocat_socket_set_t * const set) {
index 46fb28365403d10aea0aeb5f0783b84519484b35..b22303361943ce4aabe053bbcd17eff20de083eb 100644 (file)
@@ -71,14 +71,16 @@ extern "C" {
  *   F_parameter (with error bit) on invalid parameter.
  *
  * @see f_socket_read_stream()
- * @see kt_tacocat_send_process_initialize()
+ * @see kt_tacocat_send_process_reset()
  */
 #ifndef _di_kt_tacocat_send_process_
   extern f_status_t kt_tacocat_send_process(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set);
 #endif // _di_kt_tacocat_send_process_
 
 /**
- * Process the network socket, performing the initialization step such as when step == 0.
+ * Process the network socket, resetting the data during the initialization step, such as when step == 0.
+ *
+ * This does not and must not alter the socket step flags.
  *
  * @param main
  *   The main program and settings data.
@@ -106,9 +108,9 @@ extern "C" {
  * @see kt_tacocat_process_abstruse_initialize()
  * @see kt_tacocat_send_process_time_now()
  */
-#ifndef _di_kt_tacocat_send_process_initialize_
-  extern void kt_tacocat_send_process_initialize(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set);
-#endif // _di_kt_tacocat_send_process_initialize_
+#ifndef _di_kt_tacocat_send_process_reset_
+  extern void kt_tacocat_send_process_reset(kt_tacocat_main_t * const main, kt_tacocat_socket_set_t * const set);
+#endif // _di_kt_tacocat_send_process_reset_
 
 /**
  * Build a string containing the current time.
index 854546acfb6d15a0a204175837476f12786e1308..b46e4a9ad5da1371eaaa51f11edb622d1eb48753 100644 (file)
@@ -27,7 +27,7 @@ extern "C" {
       kt_tacocat_print_warning_on_file(&main->program.warning, F_status_debug_source_d, kt_tacocat_send_done_s, set->network, set->status, set->name, f_file_operation_close_s);
     }
 
-    set->step = 0;
+    set->step = kt_tacocat_socket_step_send_none_e;
     set->socket.id_data = -1;
     set->status = F_okay;
   }
index 3eb176f27b2341314609884272159e0560ecb90a..88c1735185dc878c920e458eaeb8daebdd645022 100644 (file)
@@ -71,7 +71,7 @@ extern "C" {
       f_file_close(&set->file);
       f_socket_disconnect(&set->socket, f_socket_close_fast_e);
 
-      set->step = 0;
+      set->step = kt_tacocat_socket_step_send_none_e;
       set->socket.id_data = -1;
 
       // Keep error bit but set state to done to designate that nothing else is to be done.