From: Kevin Day Date: Wed, 15 Nov 2023 00:02:30 +0000 (-0600) Subject: Progress: Further work in TacocaT. X-Git-Tag: 0.7.1~109 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=9b599c9265e4d00f39a88ad5a17513ee905a946a;p=kevux-tools Progress: Further work in TacocaT. --- diff --git a/sources/c/tacocat/main/common/enumeration.h b/sources/c/tacocat/main/common/enumeration.h index e6ad73f..808e2ed 100644 --- a/sources/c/tacocat/main/common/enumeration.h +++ b/sources/c/tacocat/main/common/enumeration.h @@ -150,6 +150,7 @@ extern "C" { * - size: Determine the file size. * - file: Buffer the file. * - build: Build the header information. + * - combine: Combine the built header information into a single buffer. * - connect: Connect to the remote address. * - header: Send the header information. * - payload: Send the payload information. @@ -161,10 +162,11 @@ extern "C" { kt_tacocat_socket_flag_send_size_e = 0x1, kt_tacocat_socket_flag_send_file_e = 0x2, kt_tacocat_socket_flag_send_build_e = 0x4, - kt_tacocat_socket_flag_send_connect_e = 0x8, - kt_tacocat_socket_flag_send_header_e = 0x10, - kt_tacocat_socket_flag_send_payload_e = 0x20, - kt_tacocat_socket_flag_send_done_e = 0x40, + kt_tacocat_socket_flag_send_combine_e = 0x8, + kt_tacocat_socket_flag_send_connect_e = 0x10, + kt_tacocat_socket_flag_send_header_e = 0x20, + kt_tacocat_socket_flag_send_payload_e = 0x40, + kt_tacocat_socket_flag_send_done_e = 0x80, }; // enum #endif // _di_kt_tacocat_socket_flag_send_e_ diff --git a/sources/c/tacocat/main/common/print.c b/sources/c/tacocat/main/common/print.c index 1bd7f46..747c257 100644 --- a/sources/c/tacocat/main/common/print.c +++ b/sources/c/tacocat/main/common/print.c @@ -37,6 +37,7 @@ extern "C" { "f_thread_create", "fl_conversion_dynamic_partial_to_unsigned_detect", "fl_conversion_dynamic_to_unsigned_detect", + "fl_fss_payload_header_map", "fll_program_parameter_process_context", "fll_program_parameter_process_verbosity", "kt_tacocat_process_socket_set_error_has", diff --git a/sources/c/tacocat/main/common/print.h b/sources/c/tacocat/main/common/print.h index 47098a6..e3d57be 100644 --- a/sources/c/tacocat/main/common/print.h +++ b/sources/c/tacocat/main/common/print.h @@ -46,7 +46,7 @@ extern "C" { kt_tacocat_f_f_file_read_block_e, kt_tacocat_f_f_file_size_by_id_e, kt_tacocat_f_f_file_write_e, - kt_tacocat_f_f_fss_payload_extract_range_e, + kt_tacocat_f_f_fss_simple_packet_extract_range_e, kt_tacocat_f_f_memory_array_increase_by_e, kt_tacocat_f_f_memory_array_resize_e, kt_tacocat_f_f_network_from_ip_name_e, @@ -70,6 +70,7 @@ extern "C" { kt_tacocat_f_f_thread_create_e, kt_tacocat_f_fl_conversion_dynamic_partial_to_unsigned_detect_e, kt_tacocat_f_fl_conversion_dynamic_to_unsigned_detect_e, + kt_tacocat_f_fl_fss_payload_header_map_e, kt_tacocat_f_fll_program_parameter_process_context_e, kt_tacocat_f_fll_program_parameter_process_verbosity_e, kt_tacocat_f_kt_tacocat_process_socket_set_error_has_e, diff --git a/sources/c/tacocat/main/receive.c b/sources/c/tacocat/main/receive.c index 3a0fd38..a75e1a2 100644 --- a/sources/c/tacocat/main/receive.c +++ b/sources/c/tacocat/main/receive.c @@ -222,8 +222,8 @@ extern "C" { return; } - set->status = f_fss_payload_extract_range(set->buffer, &set->packet); - macro_kt_receive_process_begin_handle_error_exit_1(main, f_fss_payload_extract_range, set->network, set->status, set->flag); + set->status = f_fss_simple_packet_extract_range(set->buffer, &set->packet); + macro_kt_receive_process_begin_handle_error_exit_1(main, f_fss_simple_packet_extract_range, set->network, set->status, set->flag); if (set->status == F_packet_too_small || set->packet.size < kt_tacocat_packet_minimum_d) { kt_tacocat_print_error_on_packet_too_small(&main->program.error, kt_tacocat_receive_s, set->network, kt_tacocat_packet_peek_d, set->buffer.used); diff --git a/sources/c/tacocat/main/send.c b/sources/c/tacocat/main/send.c index 7cf24aa..00dfade 100644 --- a/sources/c/tacocat/main/send.c +++ b/sources/c/tacocat/main/send.c @@ -35,12 +35,15 @@ extern "C" { } } else { + // @todo the kt_tacocat_receive_process() and kt_tacocat_send_process() have different return designs, figure out which design to use and be consistent. + // @todo in all cases error or success, when done be sure set->file is closed. if (kt_tacocat_send_process(main, &main->setting.send.array[i]) == F_done) { if (ready != F_done_not) { ready = F_done; } } else { + // @todo on error during partial transfer either attempt to resend, attempt to send failure packet, or abandon. ready = F_done_not; } } @@ -85,8 +88,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); macro_kt_send_process_handle_error_exit_1(main, f_memory_array_increase_by, set->network, set->status, set->flag); - // Make sure the buffer is large enough for the file block reads (including a space for a terminating NULL). - set->status = f_memory_array_increase_by(set->file.size_read + f_fss_payload_object_payload_s.used + f_fss_payload_object_end_s.used + 2, sizeof(f_char_t), (void **) &set->buffer.string, &set->buffer.used, &set->buffer.size); + set->status = f_memory_array_increase_by(set->file.size_read + f_fss_payload_object_payload_s.used + f_fss_payload_object_end_s.used + 1, sizeof(f_char_t), (void **) &set->buffer.string, &set->buffer.used, &set->buffer.size); macro_kt_send_process_handle_error_exit_1(main, f_memory_array_increase_by, set->network, set->status, set->flag); // Index 0 is the status. @@ -109,7 +111,7 @@ extern "C" { set->abstruses.array[3].value.type = f_abstruse_unsigned_e; set->abstruses.array[3].value.is.a_unsigned = 0; - // Index 4 is the total (size of file). + // Index 4 is the total number of packets (based on block size). set->abstruses.array[4].key = f_fss_payload_object_total_s; set->abstruses.array[4].value.type = f_abstruse_unsigned_e; set->abstruses.array[4].value.is.a_unsigned = 0; @@ -151,7 +153,19 @@ extern "C" { return F_done_not; } - set->abstruses.array[4].value.is.a_unsigned = (f_number_unsigned_t) total; + set->abstruses.array[3].value.is.a_unsigned = 0; + + if (total) { + set->abstruses.array[4].value.is.a_unsigned = ((f_number_unsigned_t) total) / set->file.size_read; + + if (set->abstruses.array[4].value.is.a_unsigned % set->file.size_read) { + ++set->abstruses.array[4].value.is.a_unsigned; + } + } + else { + set->abstruses.array[4].value.is.a_unsigned = 1; + } + set->flag = kt_tacocat_socket_flag_send_file_e; } @@ -164,54 +178,46 @@ extern "C" { set->status = f_string_dynamic_append(f_fss_payload_object_end_s, &set->buffer); macro_kt_send_process_handle_error_exit_1(main, f_file_read_block, set->network, set->status, set->flag); - // Each block is sent one at a time. set->status = f_file_read_block(set->file, &set->buffer); macro_kt_send_process_handle_error_exit_1(main, f_file_read_block, set->network, set->status, set->flag); + set->abstruses.array[2].value.is.a_unsigned = set->buffer.used - f_fss_payload_object_payload_s.used - f_fss_payload_object_end_s.used; set->buffer.string[set->buffer.used] = 0; set->flag = kt_tacocat_socket_flag_send_build_e; } - // @todo The build process needs to be broken up into multiple parts that can fit in a FSS Packet (2^32 - 6). if (set->flag == kt_tacocat_socket_flag_send_build_e) { - set->header.used = 0; + set->cache.used = 0; - if (set->header.used) { + { f_state_t state_local = main->setting.state; state_local.data = &set->write_state; - // @todo build the header and add to the header buffer and also add the "\npayload:\n". (resume programming here) - // The entire structure: - // f_fss_payload_comment_header_begin_s.used + f_fss_payload_comment_header_s.used + f_fss_payload_comment_header_end_s.used - // f_fss_payload_object_header_s.used + f_fss_payload_object_end_s - // set->header.used - // f_fss_payload_object_payload_s.used + f_fss_payload_object_end_s - // set->buffer.used + fl_fss_payload_header_map(set->abstruses, &set->headers, &state_local); + macro_kt_send_process_handle_error_exit_1(main, fl_fss_payload_header_map, set->network, state_local.status, set->flag); - // @todo create the following headers: - // 1) type file (or string, and if file, then name is filesize and size is filesize, otherwise name is unused and size is string length.) - // 1) name "example.csv" - // 2) size 1234 - // 3) status F_okay (f_status_okay_s) + set->flag = kt_tacocat_socket_flag_send_combine_e; + } + } + + if (set->flag == kt_tacocat_socket_flag_send_combine_e) { + set->header.used = 0; + + { + set->status = f_string_dynamic_append(f_fss_payload_comment_header_s, &set->header); + macro_kt_send_process_handle_error_exit_1(main, f_string_dynamic_append, set->network, set->status, set->flag); - // @todo - // 1) Build abstruse headers map of data. - // 2) Call this: fl_fss_payload_header_map(set->headers, f_string_maps_t * const destinations, f_state_t * const state) - // 3) append maps to buffer. + set->status = f_string_dynamic_append(f_fss_payload_comment_header_end_s, &set->header); + macro_kt_send_process_handle_error_exit_1(main, f_string_dynamic_append, set->network, set->status, set->flag); - // @todo needs to be kt_tacocat_socket_flag_send_build_e equivalent for sending the structures, like the header structure. + // @todo walk through the header map. set->header.string[set->header.used] = 0; set->flag = kt_tacocat_socket_flag_send_build_e; } - else { - - // File is empty, nothing left to send. - set->flag = kt_tacocat_socket_flag_send_done_e; - } } - // @todo all below is not updated to flag enumeration changes. + // @todo all below is not updated to flag enumeration changes (need to connect, send header, send payload, and close (done)). // @todo don't send just yet, need to build the payload header (then send that first, followed by the payload itself).. // probably should send the header data separately first to avoid additional allocations of merging the buffer with the header.