]> Kevux Git Server - kevux-tools/commitdiff
Update: Add support for printing headers on send or receive and other changes.
authorKevin Day <Kevin@kevux.org>
Tue, 25 Nov 2025 05:51:00 +0000 (23:51 -0600)
committerKevin Day <Kevin@kevux.org>
Tue, 25 Nov 2025 05:51:00 +0000 (23:51 -0600)
Store the numeric port on the set.

The received headers are not being fully printed yet.

Make sure file close warnings are printed on file close failure when receiving.

12 files changed:
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.h
sources/c/program/kevux/tools/tacocat/main/packet.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/receive/step/done.c
sources/c/program/kevux/tools/tacocat/main/send.c
sources/c/program/kevux/tools/tacocat/main/send/step/done.c

index 691a38f1bd50301fcff8b4049bbc103b0b6f4ada..672393ec27127d40ffde59e65927fc06a76a774f 100644 (file)
@@ -194,6 +194,13 @@ extern "C" {
       return;
     }
 
+    if (main->program.parameters.array[kt_tacocat_parameter_headers_e].result & f_console_result_found_d) {
+      main->setting.flag |= kt_tacocat_main_flag_headers_d;
+    }
+    else {
+      main->setting.flag &= ~kt_tacocat_main_flag_headers_d;
+    }
+
     // 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);
@@ -259,7 +266,6 @@ extern "C" {
     f_status_t failed = F_okay;
     struct hostent host;
     f_network_family_ip_t family = f_network_family_ip_t_initialize;
-    f_number_unsigned_t port = 0;
     f_string_static_t address = f_string_static_t_initialize;
 
     for (uint8_t i = 0; i < 2; ++i) {
@@ -311,6 +317,7 @@ extern "C" {
           sets[i]->array[j].packet.size = 0;
           sets[i]->array[j].packet.payload.start = 1;
           sets[i]->array[j].packet.payload.stop = 0;
+          sets[i]->array[j].port = 0;
           sets[i]->array[j].retry = 0;
           sets[i]->array[j].status = F_okay;
           sets[i]->array[j].range.start = 1;
@@ -386,7 +393,7 @@ extern "C" {
                 sets[i]->array[j].socket.form = f_socket_address_form_generic_e;
               }
 
-              kt_tacocat_setting_load_address_port_extract(main, range_ip, &address, &port);
+              kt_tacocat_setting_load_address_port_extract(main, range_ip, &address, &sets[i]->array[j].port);
 
               if (F_status_is_error(main->setting.state.status)) {
                 if (F_status_set_fine(main->setting.state.status) == F_parameter) {
@@ -406,10 +413,10 @@ extern "C" {
               }
 
               // Fail forward if port number is not supported by the system.
-              if (port != (in_port_t) port) {
-                kt_tacocat_print_warning_port_number_overflow(&main->program.warning, main->program.parameters.arguments.array[index], port);
+              if (sets[i]->array[j].port != (in_port_t) sets[i]->array[j].port) {
+                kt_tacocat_print_warning_port_number_overflow(&main->program.warning, main->program.parameters.arguments.array[index], sets[i]->array[j].port);
 
-                port = 0;
+                sets[i]->array[j].port = 0;
               }
 
               if (host.h_addrtype) {
@@ -420,6 +427,8 @@ extern "C" {
                 main->setting.state.status = f_network_from_ip_string(address, &family);
 
                 macro_kt_tacocat_handle_load_send_receive_error_continue_2();
+
+                // @todo port here.
               }
               else {
                 main->setting.state.status = f_network_from_ip_name(address, &host);
@@ -487,13 +496,13 @@ extern "C" {
               if (host.h_addrtype == f_socket_address_family_inet4_e) {
                 sets[i]->array[j].socket.domain = f_socket_protocol_family_inet4_e;
                 sets[i]->array[j].socket.address.inet4.sin_family = f_socket_address_family_inet4_e;
-                sets[i]->array[j].socket.address.inet4.sin_port = htons((in_port_t) port);
+                sets[i]->array[j].socket.address.inet4.sin_port = htons((in_port_t) sets[i]->array[j].port);
                 sets[i]->array[j].socket.address.inet4.sin_addr.s_addr = family.address.v4.s_addr;
               }
               else if (host.h_addrtype == f_socket_address_family_inet6_e) {
                 sets[i]->array[j].socket.domain = f_socket_protocol_family_inet6_e;
                 sets[i]->array[j].socket.address.inet4.sin_family = f_socket_address_family_inet6_e;
-                sets[i]->array[j].socket.address.inet6.sin6_port = htons((in_port_t) port);
+                sets[i]->array[j].socket.address.inet6.sin6_port = htons((in_port_t) sets[i]->array[j].port);
                 sets[i]->array[j].socket.address.inet6.sin6_addr = family.address.v6;
               }
             }
index 8f608a7ba62f3136c2bec750059a019b9b5dd8fd..58b9a663b57dedef6ab68dbaf387b1cb079d9c44 100644 (file)
@@ -174,12 +174,13 @@ extern "C" {
  * kt_tacocat_main_flag_*_d:
  *   - none:                   No flags set.
  *   - copyright:              Print copyright.
+ *   - headers:                Print headers on send or receive.
+ *   - help:                   Print help.
  *   - max_buffer:             When set, a maximum buffer on receive is enforced.
  *   - receive:                The address or socket to receive from is specified.
  *   - resolve_classic:        Follow the classic Domain Name Resolution method.
  *   - resolve_kevux:          Follow the Kevux Domain Name Resolution method.
  *   - send:                   The address or socket send to is specified.
- *   - help:                   Print help.
  *   - version:                Print version.
  *   - version_copyright_help: A helper flag representing version, copyright, and help flag bits being set.
  *
@@ -197,15 +198,15 @@ extern "C" {
 #ifndef _di_kt_tacocat_main_flag_d_
   #define kt_tacocat_main_flag_none_d                   0x0
   #define kt_tacocat_main_flag_copyright_d              0x1
-  #define kt_tacocat_main_flag_help_d                   0x2
-  #define kt_tacocat_main_flag_max_buffer_d             0x4
-  #define kt_tacocat_main_flag_receive_d                0x8
-  #define kt_tacocat_main_flag_resolve_classic_d        0x10
-  #define kt_tacocat_main_flag_resolve_kevux_d          0x20
-  #define kt_tacocat_main_flag_resolve_d                0x40
+  #define kt_tacocat_main_flag_headers_d                0x2
+  #define kt_tacocat_main_flag_help_d                   0x4
+  #define kt_tacocat_main_flag_max_buffer_d             0x8
+  #define kt_tacocat_main_flag_receive_d                0x10
+  #define kt_tacocat_main_flag_resolve_classic_d        0x20
+  #define kt_tacocat_main_flag_resolve_kevux_d          0x40
   #define kt_tacocat_main_flag_send_d                   0x80
   #define kt_tacocat_main_flag_version_d                0x100
-  #define kt_tacocat_main_flag_version_copyright_help_d 0x103
+  #define kt_tacocat_main_flag_version_copyright_help_d 0x105
 #endif // _di_kt_tacocat_main_flag_d_
 
 /**
index 8723db34e333ea74606fb844644e73498916ba99..6bbd7345e1aae0ca7ef3e4199ddb19a5a77f0ec0 100644 (file)
@@ -33,6 +33,7 @@ extern "C" {
     kt_tacocat_parameter_verbosity_debug_e,
     kt_tacocat_parameter_version_e,
 
+    kt_tacocat_parameter_headers_e,
     kt_tacocat_parameter_interval_e,
     kt_tacocat_parameter_max_buffer_e,
     kt_tacocat_parameter_receive_e,
@@ -44,14 +45,15 @@ extern "C" {
     { \
       macro_fll_program_console_parameter_standard_initialize, \
       \
-      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_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), \
-      macro_f_console_parameter_t_initialize_3(kt_tacocat_short_receive_s, kt_tacocat_long_receive_s, 2, f_console_flag_normal_d), \
-      macro_f_console_parameter_t_initialize_3(kt_tacocat_short_resolve_s, kt_tacocat_long_resolve_s, 1, f_console_flag_normal_d), \
-      macro_f_console_parameter_t_initialize_3(kt_tacocat_short_send_s, kt_tacocat_long_send_s, 2, f_console_flag_normal_d), \
+      macro_f_console_parameter_t_initialize_3(kt_tacocat_short_receive_s,    kt_tacocat_long_receive_s,    2, f_console_flag_normal_d), \
+      macro_f_console_parameter_t_initialize_3(kt_tacocat_short_resolve_s,    kt_tacocat_long_resolve_s,    1, f_console_flag_normal_d), \
+      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 + 5)
+  #define kt_tacocat_parameter_total_d (f_console_parameter_state_type_total_d + 6)
 #endif // _di_kt_tacocat_parameter_e_
 
 /**
index 868d0aaf7fe775488cbd2425596bc5f9177319f8..a914dab26e754d5bf6647ae45b9f41d78895638f 100644 (file)
@@ -23,6 +23,7 @@ extern "C" {
   const f_string_static_t kt_tacocat_network_or_socket_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_network_or_socket_s, 0, KT_TACOCAT_network_or_socket_s_length);
   const f_string_static_t kt_tacocat_next_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_next_s, 0, KT_TACOCAT_next_s_length);
   const f_string_static_t kt_tacocat_receive_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_receive_s, 0, KT_TACOCAT_receive_s_length);
+  const f_string_static_t kt_tacocat_receive_done_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_receive_done_s, 0, KT_TACOCAT_receive_done_s_length);
   const f_string_static_t kt_tacocat_resend_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_resend_s, 0, KT_TACOCAT_resend_s_length);
   const f_string_static_t kt_tacocat_send_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_send_s, 0, KT_TACOCAT_send_s_length);
   const f_string_static_t kt_tacocat_send_build_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_send_build_s, 0, KT_TACOCAT_send_build_s_length);
@@ -41,12 +42,14 @@ extern "C" {
 #endif // _di_kt_tacocat_s_
 
 #ifndef _di_kt_tacocat_parameter_s_
+  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);
   const f_string_static_t kt_tacocat_short_receive_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_short_receive_s, 0, KT_TACOCAT_short_receive_s_length);
   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_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);
   const f_string_static_t kt_tacocat_long_receive_s = macro_f_string_static_t_initialize_1(KT_TACOCAT_long_receive_s, 0, KT_TACOCAT_long_receive_s_length);
index 69cf24c437906cb0d4d6273690ad7edf2a1dee13..2760e4a73fdae8b7aa63a52cec93576491ac5b68 100644 (file)
@@ -76,6 +76,7 @@ extern "C" {
   #define KT_TACOCAT_network_or_socket_s  "network / socket"
   #define KT_TACOCAT_next_s               "next"
   #define KT_TACOCAT_receive_s            "receive"
+  #define KT_TACOCAT_receive_done_s       "receive done"
   #define KT_TACOCAT_resend_s             "resend"
   #define KT_TACOCAT_send_s               "send"
   #define KT_TACOCAT_send_build_s         "send build"
@@ -102,6 +103,7 @@ extern "C" {
   #define KT_TACOCAT_network_or_socket_s_length  16
   #define KT_TACOCAT_next_s_length               4
   #define KT_TACOCAT_receive_s_length            7
+  #define KT_TACOCAT_receive_done_s_length       12
   #define KT_TACOCAT_resend_s_length             6
   #define KT_TACOCAT_send_s_length               4
   #define KT_TACOCAT_send_build_s_length         19
@@ -128,6 +130,7 @@ extern "C" {
   extern const f_string_static_t kt_tacocat_network_or_socket_s;
   extern const f_string_static_t kt_tacocat_next_s;
   extern const f_string_static_t kt_tacocat_receive_s;
+  extern const f_string_static_t kt_tacocat_receive_done_s;
   extern const f_string_static_t kt_tacocat_resend_s;
   extern const f_string_static_t kt_tacocat_send_s;
   extern const f_string_static_t kt_tacocat_send_build_s;
@@ -149,36 +152,42 @@ extern "C" {
  * The main program parameters.
  */
 #ifndef _di_kt_tacocat_parameter_s_
+  #define KT_TACOCAT_short_headers_s    "H"
   #define KT_TACOCAT_short_interval_s   "I"
   #define KT_TACOCAT_short_max_buffer_s "M"
   #define KT_TACOCAT_short_receive_s    "r"
   #define KT_TACOCAT_short_resolve_s    "R"
   #define KT_TACOCAT_short_send_s       "s"
 
+  #define KT_TACOCAT_long_headers_s    "headers"
   #define KT_TACOCAT_long_interval_s   "interval"
   #define KT_TACOCAT_long_max_buffer_s "max_buffer"
   #define KT_TACOCAT_long_receive_s    "receive"
   #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_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_headers_s_length    7
   #define KT_TACOCAT_long_interval_s_length   8
   #define KT_TACOCAT_long_max_buffer_s_length 10
   #define KT_TACOCAT_long_receive_s_length    7
   #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_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;
   extern const f_string_static_t kt_tacocat_short_receive_s;
   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_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;
   extern const f_string_static_t kt_tacocat_long_receive_s;
index 92efadce8b669ed3821fe5fc979df1d7be5802fb..2f79c4afb98147be164af58790a1e7f833d3c1fa 100644 (file)
@@ -34,6 +34,7 @@ extern "C" {
  * step:  The current step the socket set is operating under.
  * retry: The current number of retries performed.
  * part:  The current active part number.
+ * port:  The current port number for the socket.
  *
  * file:   The file structure.
  * socket: Socket structure.
@@ -83,6 +84,7 @@ extern "C" {
     uint16_t step;
     uint16_t retry;
     f_number_unsigned_t part;
+    f_number_unsigned_t port;
 
     f_file_t file;
     f_socket_t socket;
@@ -131,6 +133,7 @@ extern "C" {
       0, \
       0, \
       0, \
+      0, \
       f_file_t_initialize, \
       f_socket_t_initialize, \
       f_status_t_initialize, \
@@ -173,6 +176,7 @@ extern "C" {
       0, \
       0, \
       0, \
+      0, \
       f_file_t_initialize, \
       f_poll_t_initialize, \
       f_socket_t_initialize, \
@@ -216,6 +220,7 @@ extern "C" {
       0, \
       0, \
       0, \
+      0, \
       f_file_t_initialize, \
       f_poll_t_initialize, \
       f_socket_t_initialize, \
index ed9d3d90493140320ad6d8da8683bc0ce8f3b80f..5b06d6169bba7930eaa3d824413f87b694c28036 100644 (file)
@@ -72,15 +72,25 @@ extern "C" {
       return;
     }
 
+    set->abstruses.used = 0;
+
+    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);
+
+      return;
+    }
+
     set->range = set->contents.array[at].array[0];
 
     fll_fss_extended_read(set->buffer, &set->range, &set->objects_header, &set->contents_header, &set->objects_quoted_header, &set->contents_quoted_header, &set->objects_delimits_header, &set->contents_delimits_header, &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);
-
       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);
+
       return;
     }
 
@@ -115,17 +125,32 @@ extern "C" {
 
       for (; i < set->objects_header.used; ++i) {
 
-        for (j = 0; j < 9; ++j) {
+        for (j = 0; j < kt_tacocat_packet_headers_d; ++j) {
 
           if (f_compare_dynamic_partial_string(headers[j].string, set->buffer, headers[j].used, set->objects_header.array[i]) == F_equal_to) {
 
             // Require Content to exist.
             if (!set->contents_header.array[i].used) {
+              if (set->abstruses.array[j].value.type == f_abstruse_dynamic_e) {
+              }
+
               set->abstruses.array[j].value.type = f_abstruse_none_e;
 
-              break;
+              continue;
             }
 
+            // @todo All of these need to be stored in another location so that re-assignments doesn't cause problems with dynamic allocation. Allocate these and make them available.
+            /*set->abstruses.array[i].value.type = f_abstruse_dynamic_e;
+            set->abstruses.array[i].value.is.a_dynamic.used = 0;
+
+            set->status = f_string_dynamic_partial_append(set->buffer, range, &set->abstruses.array[i].value.is.a_dynamic);
+
+            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);
+
+              return;
+            }*/
+
             set->abstruses.array[j].value.type = f_abstruse_range_e;
             set->abstruses.array[j].value.is.a_range = set->contents_header.array[i].array[0];
           }
index 2aad982a4091174a6a9f81903462ad0df4ca658e..ec24d9440218914c2a594bb453a18c94b2acc465 100644 (file)
@@ -4,6 +4,39 @@
 extern "C" {
 #endif
 
+#ifndef _di_kt_tacocat_print_message_headers_
+  f_status_t kt_tacocat_print_message_headers(fl_print_t * const print, const kt_tacocat_socket_set_t set, const uint8_t sent) {
+
+    if (!print) return F_status_set_error(F_output_not);
+    if (print->verbosity < f_console_verbosity_normal_e) return F_output_not;
+
+    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(f_string_format_Q_single_s.string, print->to, print->set->notable, set.network, print->set->notable);
+
+    if (set.port) {
+      fl_print_format(" (port %[%ul%])", print->to, print->set->notable, set.port, print->set->notable);
+    }
+
+    fl_print_format(":%r", print->to, f_string_eol_s);
+
+    for (f_number_unsigned_t i = 0; i < set.abstruses.used; ++i) {
+
+      if (set.abstruses.array[i].value.type == f_abstruse_unsigned_e) {
+        fl_print_format("  - %Q: %ul%r", print->to, set.abstruses.array[i].key, set.abstruses.array[i].value.is.a_unsigned, f_string_eol_s);
+      }
+      else if (set.abstruses.array[i].value.type == f_abstruse_dynamic_e) {
+        fl_print_format("  - %Q: %Q%r", print->to, set.abstruses.array[i].key, set.abstruses.array[i].value.is.a_dynamic, f_string_eol_s);
+      }
+    } // for
+
+    fl_print_format("%r", print->to, f_string_eol_s);
+
+    f_file_stream_unlock(print->to);
+  }
+#endif // _di_kt_tacocat_print_message_headers_
+
 #ifndef _di_kt_tacocat_print_message_help_
   f_status_t kt_tacocat_print_message_help(fl_print_t * const print, const f_color_context_t context) {
 
@@ -19,6 +52,7 @@ extern "C" {
 
     f_print_dynamic_raw(f_string_eol_s, print->to);
 
+    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.");
     fll_program_print_help_option(print, kt_tacocat_short_receive_s, kt_tacocat_long_receive_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "   Specify an address or socket file to listen to and a file to write to.");
index 280c9645267c317c1513cd6d170c45c411fefc52..a3288d8f06ecddbea371396aa472075059309e5c 100644 (file)
@@ -17,6 +17,33 @@ extern "C" {
 #endif
 
 /**
+ * Print message showing the sent or received headers.
+ *
+ * @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.
+ * @param sent
+ *   If TRUE, then these are sent headers.
+ *   If FALSE, then these are received headers.
+ *
+ * @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_headers_
+  extern f_status_t kt_tacocat_print_message_headers(fl_print_t * const print, const kt_tacocat_socket_set_t set, const uint8_t sent);
+#endif // _di_kt_tacocat_print_message_headers_
+
+/**
  * Print help.
  *
  * @param print
index 4d579dba634a19c272ff62b1ecceab91bca0bea2..f78b1cc183c4bb4f9da8f568f8f67ee529bfee79 100644 (file)
@@ -11,7 +11,15 @@ extern "C" {
 
     kt_tacocat_print_message_receive_operation_complete(&main->program.message, *set);
 
-    f_file_close(&set->file);
+    if (main->setting.flag & kt_tacocat_main_flag_headers_d) {
+      kt_tacocat_print_message_headers(&main->program.message, *set, F_false);
+    }
+
+    set->status = f_file_close(&set->file);
+
+    if (F_status_is_error(set->status)) {
+      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->status = F_okay;
index c2fa1988d6eded2bb5d11a55f6862c06a85a7ba2..6bfa36f76217d5c3b5b5ed791658321ea7830b29 100644 (file)
@@ -199,6 +199,7 @@ extern "C" {
     set->packet.payload.stop = 0;
     set->part = 0;
     set->parts.used = 0;
+    set->port = 0;
     set->flag = 0;
 
     // For writes, the id_data is the same as the id.
index b324444b14304b8babacb0413741b7ca77faa3b6..854546acfb6d15a0a204175837476f12786e1308 100644 (file)
@@ -11,6 +11,10 @@ extern "C" {
 
     //@todo send done packet.
 
+    if (main->setting.flag & kt_tacocat_main_flag_headers_d) {
+      kt_tacocat_print_message_headers(&main->program.message, *set, F_true);
+    }
+
     set->status = f_file_close(&set->file);
 
     if (F_status_is_error(set->status)) {