From a82ae0d4cbe9d00569fa66d64d7d1acfe907bb59 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 29 Nov 2025 19:53:51 -0600 Subject: [PATCH] Update: Provide a way to use different file names for both send and receive as well as other changes. 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. --- data/build/stand_alone/configs/remove-config.h | 2 + data/build/stand_alone/configs/tacocat-config.h | 4 +- data/build/stand_alone/settings/settings.tacocat | 2 +- .../c/program/kevux/tools/tacocat/main/common.c | 83 +++++++++++++++------- .../kevux/tools/tacocat/main/common/define.h | 16 ++++- .../kevux/tools/tacocat/main/common/enumeration.h | 4 +- .../kevux/tools/tacocat/main/common/string.c | 2 + .../kevux/tools/tacocat/main/common/string.h | 8 ++- .../program/kevux/tools/tacocat/main/common/type.c | 4 ++ .../program/kevux/tools/tacocat/main/common/type.h | 19 +++-- .../c/program/kevux/tools/tacocat/main/packet.c | 55 +++++++------- .../c/program/kevux/tools/tacocat/main/packet.h | 15 +--- .../program/kevux/tools/tacocat/main/print/error.c | 2 +- .../kevux/tools/tacocat/main/print/message.c | 28 ++++++-- .../kevux/tools/tacocat/main/print/message.h | 26 +++++++ .../c/program/kevux/tools/tacocat/main/process.c | 4 +- .../c/program/kevux/tools/tacocat/main/receive.c | 19 +++-- .../c/program/kevux/tools/tacocat/main/receive.h | 10 +-- .../kevux/tools/tacocat/main/receive/step/check.c | 2 +- .../tools/tacocat/main/receive/step/control.c | 2 +- .../kevux/tools/tacocat/main/receive/step/done.c | 7 +- .../tools/tacocat/main/receive/step/extract.c | 2 +- .../kevux/tools/tacocat/main/receive/step/packet.c | 2 +- .../kevux/tools/tacocat/main/receive/step/write.c | 2 +- sources/c/program/kevux/tools/tacocat/main/send.c | 11 ++- sources/c/program/kevux/tools/tacocat/main/send.h | 12 ++-- .../kevux/tools/tacocat/main/send/step/done.c | 2 +- .../kevux/tools/tacocat/main/send/step/size.c | 2 +- 28 files changed, 231 insertions(+), 116 deletions(-) diff --git a/data/build/stand_alone/configs/remove-config.h b/data/build/stand_alone/configs/remove-config.h index 3dcb362..884f0db 100644 --- a/data/build/stand_alone/configs/remove-config.h +++ b/data/build/stand_alone/configs/remove-config.h @@ -1831,6 +1831,8 @@ #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_ diff --git a/data/build/stand_alone/configs/tacocat-config.h b/data/build/stand_alone/configs/tacocat-config.h index f159de9..17b66b1 100644 --- a/data/build/stand_alone/configs/tacocat-config.h +++ b/data/build/stand_alone/configs/tacocat-config.h @@ -1038,7 +1038,7 @@ #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_ @@ -1098,7 +1098,7 @@ #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_ diff --git a/data/build/stand_alone/settings/settings.tacocat b/data/build/stand_alone/settings/settings.tacocat index d73d54b..ded027d 100644 --- a/data/build/stand_alone/settings/settings.tacocat +++ b/data/build/stand_alone/settings/settings.tacocat @@ -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 diff --git a/sources/c/program/kevux/tools/tacocat/main/common.c b/sources/c/program/kevux/tools/tacocat/main/common.c index 672393e..810645c 100644 --- a/sources/c/program/kevux/tools/tacocat/main/common.c +++ b/sources/c/program/kevux/tools/tacocat/main/common.c @@ -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 } diff --git a/sources/c/program/kevux/tools/tacocat/main/common/define.h b/sources/c/program/kevux/tools/tacocat/main/common/define.h index 58b9a66..13a4e70 100644 --- a/sources/c/program/kevux/tools/tacocat/main/common/define.h +++ b/sources/c/program/kevux/tools/tacocat/main/common/define.h @@ -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_ diff --git a/sources/c/program/kevux/tools/tacocat/main/common/enumeration.h b/sources/c/program/kevux/tools/tacocat/main/common/enumeration.h index 6bbd734..6eeab9d 100644 --- a/sources/c/program/kevux/tools/tacocat/main/common/enumeration.h +++ b/sources/c/program/kevux/tools/tacocat/main/common/enumeration.h @@ -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_ /** diff --git a/sources/c/program/kevux/tools/tacocat/main/common/string.c b/sources/c/program/kevux/tools/tacocat/main/common/string.c index a914dab..fb1190f 100644 --- a/sources/c/program/kevux/tools/tacocat/main/common/string.c +++ b/sources/c/program/kevux/tools/tacocat/main/common/string.c @@ -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); diff --git a/sources/c/program/kevux/tools/tacocat/main/common/string.h b/sources/c/program/kevux/tools/tacocat/main/common/string.h index 2760e4a..f71c58d 100644 --- a/sources/c/program/kevux/tools/tacocat/main/common/string.h +++ b/sources/c/program/kevux/tools/tacocat/main/common/string.h @@ -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; diff --git a/sources/c/program/kevux/tools/tacocat/main/common/type.c b/sources/c/program/kevux/tools/tacocat/main/common/type.c index 516e20c..561d083 100644 --- a/sources/c/program/kevux/tools/tacocat/main/common/type.c +++ b/sources/c/program/kevux/tools/tacocat/main/common/type.c @@ -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); } diff --git a/sources/c/program/kevux/tools/tacocat/main/common/type.h b/sources/c/program/kevux/tools/tacocat/main/common/type.h index 2f79c4a..22f1034 100644 --- a/sources/c/program/kevux/tools/tacocat/main/common/type.h +++ b/sources/c/program/kevux/tools/tacocat/main/common/type.h @@ -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, \ diff --git a/sources/c/program/kevux/tools/tacocat/main/packet.c b/sources/c/program/kevux/tools/tacocat/main/packet.c index 3dd8ba3..8cd4352 100644 --- a/sources/c/program/kevux/tools/tacocat/main/packet.c +++ b/sources/c/program/kevux/tools/tacocat/main/packet.c @@ -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; } diff --git a/sources/c/program/kevux/tools/tacocat/main/packet.h b/sources/c/program/kevux/tools/tacocat/main/packet.h index 1f4d773..c360257 100644 --- a/sources/c/program/kevux/tools/tacocat/main/packet.h +++ b/sources/c/program/kevux/tools/tacocat/main/packet.h @@ -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 diff --git a/sources/c/program/kevux/tools/tacocat/main/print/error.c b/sources/c/program/kevux/tools/tacocat/main/print/error.c index 14f9d59..d11f5cf 100644 --- a/sources/c/program/kevux/tools/tacocat/main/print/error.c +++ b/sources/c/program/kevux/tools/tacocat/main/print/error.c @@ -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); } diff --git a/sources/c/program/kevux/tools/tacocat/main/print/message.c b/sources/c/program/kevux/tools/tacocat/main/print/message.c index ec24d94..d533aed 100644 --- a/sources/c/program/kevux/tools/tacocat/main/print/message.c +++ b/sources/c/program/kevux/tools/tacocat/main/print/message.c @@ -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 diff --git a/sources/c/program/kevux/tools/tacocat/main/print/message.h b/sources/c/program/kevux/tools/tacocat/main/print/message.h index a3288d8..bc722b2 100644 --- a/sources/c/program/kevux/tools/tacocat/main/print/message.h +++ b/sources/c/program/kevux/tools/tacocat/main/print/message.h @@ -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 diff --git a/sources/c/program/kevux/tools/tacocat/main/process.c b/sources/c/program/kevux/tools/tacocat/main/process.c index 36bea43..26939e1 100644 --- a/sources/c/program/kevux/tools/tacocat/main/process.c +++ b/sources/c/program/kevux/tools/tacocat/main/process.c @@ -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; diff --git a/sources/c/program/kevux/tools/tacocat/main/receive.c b/sources/c/program/kevux/tools/tacocat/main/receive.c index c0946dc..3a59f31 100644 --- a/sources/c/program/kevux/tools/tacocat/main/receive.c +++ b/sources/c/program/kevux/tools/tacocat/main/receive.c @@ -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" diff --git a/sources/c/program/kevux/tools/tacocat/main/receive.h b/sources/c/program/kevux/tools/tacocat/main/receive.h index 9fe80b4..d755854 100644 --- a/sources/c/program/kevux/tools/tacocat/main/receive.h +++ b/sources/c/program/kevux/tools/tacocat/main/receive.h @@ -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" diff --git a/sources/c/program/kevux/tools/tacocat/main/receive/step/check.c b/sources/c/program/kevux/tools/tacocat/main/receive/step/check.c index 070a256..140a97b 100644 --- a/sources/c/program/kevux/tools/tacocat/main/receive/step/check.c +++ b/sources/c/program/kevux/tools/tacocat/main/receive/step/check.c @@ -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; } diff --git a/sources/c/program/kevux/tools/tacocat/main/receive/step/control.c b/sources/c/program/kevux/tools/tacocat/main/receive/step/control.c index 5e76ce0..e9a7b0c 100644 --- a/sources/c/program/kevux/tools/tacocat/main/receive/step/control.c +++ b/sources/c/program/kevux/tools/tacocat/main/receive/step/control.c @@ -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; } diff --git a/sources/c/program/kevux/tools/tacocat/main/receive/step/done.c b/sources/c/program/kevux/tools/tacocat/main/receive/step/done.c index 249ede0..5b18ff9 100644 --- a/sources/c/program/kevux/tools/tacocat/main/receive/step/done.c +++ b/sources/c/program/kevux/tools/tacocat/main/receive/step/done.c @@ -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) { diff --git a/sources/c/program/kevux/tools/tacocat/main/receive/step/extract.c b/sources/c/program/kevux/tools/tacocat/main/receive/step/extract.c index ece6046..dbac95e 100644 --- a/sources/c/program/kevux/tools/tacocat/main/receive/step/extract.c +++ b/sources/c/program/kevux/tools/tacocat/main/receive/step/extract.c @@ -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; diff --git a/sources/c/program/kevux/tools/tacocat/main/receive/step/packet.c b/sources/c/program/kevux/tools/tacocat/main/receive/step/packet.c index 6fb424e..3709b6c 100644 --- a/sources/c/program/kevux/tools/tacocat/main/receive/step/packet.c +++ b/sources/c/program/kevux/tools/tacocat/main/receive/step/packet.c @@ -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; } diff --git a/sources/c/program/kevux/tools/tacocat/main/receive/step/write.c b/sources/c/program/kevux/tools/tacocat/main/receive/step/write.c index d340bdf..2b8065b 100644 --- a/sources/c/program/kevux/tools/tacocat/main/receive/step/write.c +++ b/sources/c/program/kevux/tools/tacocat/main/receive/step/write.c @@ -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); diff --git a/sources/c/program/kevux/tools/tacocat/main/send.c b/sources/c/program/kevux/tools/tacocat/main/send.c index 6bfa36f..6f95d41 100644 --- a/sources/c/program/kevux/tools/tacocat/main/send.c +++ b/sources/c/program/kevux/tools/tacocat/main/send.c @@ -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) { diff --git a/sources/c/program/kevux/tools/tacocat/main/send.h b/sources/c/program/kevux/tools/tacocat/main/send.h index 46fb283..b223033 100644 --- a/sources/c/program/kevux/tools/tacocat/main/send.h +++ b/sources/c/program/kevux/tools/tacocat/main/send.h @@ -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. diff --git a/sources/c/program/kevux/tools/tacocat/main/send/step/done.c b/sources/c/program/kevux/tools/tacocat/main/send/step/done.c index 854546a..b46e4a9 100644 --- a/sources/c/program/kevux/tools/tacocat/main/send/step/done.c +++ b/sources/c/program/kevux/tools/tacocat/main/send/step/done.c @@ -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; } diff --git a/sources/c/program/kevux/tools/tacocat/main/send/step/size.c b/sources/c/program/kevux/tools/tacocat/main/send/step/size.c index 3eb176f..88c1735 100644 --- a/sources/c/program/kevux/tools/tacocat/main/send/step/size.c +++ b/sources/c/program/kevux/tools/tacocat/main/send/step/size.c @@ -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. -- 1.8.3.1