]> Kevux Git Server - kevux-tools/commitdiff
Progress: Further work in TacocaT.
authorKevin Day <kevin@kevux.org>
Sat, 15 Jul 2023 03:10:42 +0000 (22:10 -0500)
committerKevin Day <kevin@kevux.org>
Sat, 15 Jul 2023 03:10:42 +0000 (22:10 -0500)
Begin working on actually processing the packet from the socket file.

sources/c/tacocat/main/common.c
sources/c/tacocat/main/common/enumeration.h
sources/c/tacocat/main/common/print.c
sources/c/tacocat/main/common/print.h
sources/c/tacocat/main/common/type.c
sources/c/tacocat/main/common/type.h
sources/c/tacocat/main/receive.c
sources/c/tacocat/main/receive.h

index 0331b1ba68b5a10f9ef020fc46de85f684a59d99..d064b65c1bfe91059df1090a1c859f57b78d6c82 100644 (file)
@@ -247,10 +247,15 @@ extern "C" {
           continue;
         }
 
+        sets[i]->flags.used = 0;
         sets[i]->names.used = 0;
         sets[i]->buffers.used = 0;
         sets[i]->polls.used = 0;
 
+        main->setting.state.status = f_uint16s_increase_by(main->program.parameters.array[parameters[i]].values.used / 2, &sets[i]->flags);
+
+        macro_setting_load_handle_send_receive_error_continue_1(f_uint16s_increase_by);
+
         main->setting.state.status = f_string_dynamics_increase_by(main->program.parameters.array[parameters[i]].values.used / 2, &sets[i]->names);
 
         macro_setting_load_handle_send_receive_error_continue_1(f_string_dynamics_increase_by);
@@ -280,6 +285,7 @@ extern "C" {
           // First parameter value represents the network address or the socket file path.
           index = main->program.parameters.array[parameters[i]].values.array[j];
           sets[i]->statuss.array[j] = F_none;
+          sets[i]->flags.array[j] = kt_tacocat_socket_flag_none_e;
           sets[i]->names.array[j].used = 0;
           sets[i]->buffers.array[j].used = 0;
 
index a37d6324a28c482fb5e528c74dca8732c017fd75..88e8858b3263309f27a49e2448898f4ae386caf1 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  *   The Kevux method also supports local DNS entries ie (~/.resolution/dns/kevux.conf or ~/.resolution/host/kevux.conf).
  *   @todo The Kevux method will be implemented in a library (project resolution and libresolution), re-introducing and expanding on the Turtle Kevux resolv.conf extensions that Kevin hacked into uClibc several years back.
  */
-#ifndef _di_kt_tacocat_flag_e_
+#ifndef _di_kt_tacocat_main_flag_e_
   enum {
     kt_tacocat_main_flag_none_e            = 0x0,
     kt_tacocat_main_flag_copyright_e       = 0x1,
@@ -56,7 +56,7 @@ extern "C" {
     kt_tacocat_main_flag_send_e            = 0x100,
     kt_tacocat_main_flag_version_e         = 0x200,
   }; // enum
-#endif // _di_kt_tacocat_flag_e_
+#endif // _di_kt_tacocat_main_flag_e_
 
 /**
  * The main program parameters.
@@ -122,6 +122,22 @@ extern "C" {
   }; // enum
 #endif // _di_kt_tacocat_print_flag_e_
 
+/**
+ * Individual socket-specific flags.
+ *
+ * kt_tacocat_socket_flag_*_e:
+ *   - none:          No flags set.
+ *   - block_control: The control block is fully read.
+ *   - block_payload: The payload block is fully read.
+ */
+#ifndef _di_kt_tacocat_socket_flag_e_
+  enum {
+    kt_tacocat_socket_flag_none_e          = 0x0,
+    kt_tacocat_socket_flag_block_control_e = 0x1,
+    kt_tacocat_socket_flag_block_payload_e = 0x2,
+  }; // enum
+#endif // _di_kt_tacocat_socket_flag_e_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index bb5cb1008201853b4e4230bef64fffe2256f462f..8d11fa9d38753c3720f717fd598176e3c48b6f77 100644 (file)
@@ -27,6 +27,7 @@ extern "C" {
     "f_string_dynamic_increase_by",
     "f_string_dynamics_increase_by",
     "f_thread_create",
+    "f_uint16s_increase_by",
     "fl_conversion_dynamic_to_unsigned_detect",
     "fll_program_parameter_process_context",
     "fll_program_parameter_process_verbosity",
index c4448fed640d1558e8b6d59ecbfc80911ee5561d..f0e28e3f82bd6cc4b289d7238352ed15b3dd1f3c 100644 (file)
@@ -60,6 +60,7 @@ extern "C" {
     kt_tacocat_f_f_string_dynamic_increase_by_e,
     kt_tacocat_f_f_string_dynamics_increase_by_e,
     kt_tacocat_f_f_thread_create_e,
+    kt_tacocat_f_f_uint16s_increase_by_e,
     kt_tacocat_f_fl_conversion_dynamic_to_unsigned_detect_e,
     kt_tacocat_f_fll_program_parameter_process_context_e,
     kt_tacocat_f_fll_program_parameter_process_verbosity_e,
index df227fc158ba2f2114a8fb30e323ef2d2200f8dc..3917e0f7757052b9c2155207820cb261c1d56c3c 100644 (file)
@@ -38,6 +38,7 @@ extern "C" {
           f_socket_disconnect(&sets[i]->sockets.array[j], program.signal_received ? f_socket_close_fast_e : f_socket_close_read_write_e);
         } // for
 
+        f_uint16s_resize(0, &sets[i]->flags);
         f_files_resize(0, &sets[i]->files);
         f_polls_resize(0, &sets[i]->polls);
         f_sockets_resize(0, &sets[i]->sockets);
index 631e25ada9db42cf6cd7444ebe12b01c358893a2..7abeb8eabbd7027636923523f6024e691da4d206 100644 (file)
@@ -21,8 +21,9 @@ extern "C" {
  *
  * block_size: The size in bytes to used to represent a block when sending or receiving packets.
  *
+ * flags:   An array of flags for each socket.
  * files:   An array of files for each socket.
- * polls:  An array of sockets to poll, specifically for passing to f_file_poll().
+ * polls:   An array of sockets to poll, specifically for passing to f_file_poll().
  * sockets: An array of the network sockets.
  * statuss: An array of statuses for each socket.
  *
@@ -33,6 +34,7 @@ extern "C" {
   typedef struct {
     f_number_unsigned_t block_size;
 
+    f_uint16s_t flags;
     f_files_t files;
     f_polls_t polls;
     f_sockets_t sockets;
@@ -45,6 +47,7 @@ extern "C" {
   #define kt_tacocat_socket_set_t_initialize \
     { \
       kt_tacocat_block_size_d, \
+      f_uint16s_t_initialize, \
       f_files_t_initialize, \
       f_polls_t_initialize, \
       f_sockets_t_initialize, \
@@ -56,6 +59,7 @@ extern "C" {
   #define macro_kt_tacocat_setting_t_initialize_1(block_size) \
     { \
       block_size, \
+      f_uint16s_t_initialize, \
       f_files_t_initialize, \
       f_polls_t_initialize, \
       f_sockets_t_initialize, \
@@ -74,9 +78,9 @@ extern "C" {
  * flag:     Flags passed to the main function.
  * interval: The poll interval to use.
  *
- * status_receive: A status used eclusively by the receive thread.
- * status_send:    A status used eclusively by the send thread.
- * status_signal:  A status used eclusively by the threaded signal handler.
+ * status_receive: A status used exclusively by the receive thread.
+ * status_send:    A status used exclusively by the send thread.
+ * status_signal:  A status used exclusively by the threaded signal handler.
  *
  * state: The state data used when processing data.
  *
index 05db49ec49107e7d6d7b2d2d0baf7997773ea14d..d3304e102a217385f048d323aa5e202fd9723a9b 100644 (file)
@@ -12,6 +12,7 @@ extern "C" {
     if (!void_main) return 0;
 
     kt_tacocat_main_t * const main = (kt_tacocat_main_t *) void_main;
+    f_number_unsigned_t i = 0;
 
     kt_tacocat_process_socket_set_receive(main);
 
@@ -25,6 +26,23 @@ extern "C" {
           return 0;
         }
 
+        for (i = 0; i < main->setting.receive.polls.used; ++i) {
+
+          if (main->setting.receive.polls.array[i].fd == -1) continue;
+
+          // @todo figure out what f_poll_urgent_e can be.
+          if (main->setting.receive.polls.array[i].revents & (f_poll_read_e | f_poll_urgent_e)) {
+            // @todo call receive
+            kt_tacocat_receive_process(main, i);
+
+            if (F_status_is_error(main->setting.state.status)) {
+              // @todo print error.
+
+              continue;
+            }
+          }
+        } // for
+
         // @todo handle errors
 
       } while (F_status_is_error_not(main->setting.status_receive));
@@ -42,6 +60,21 @@ extern "C" {
   }
 #endif // _di_kt_tacocat_receive_
 
+#ifndef _di_kt_tacocat_receive_process_
+  void kt_tacocat_receive_process(kt_tacocat_main_t * const main, const f_number_unsigned_t index) {
+
+    f_socket_t * const socket = &main->setting.receive.sockets.array[index];
+    f_poll_t * const poll = &main->setting.receive.polls.array[index];
+
+    if (poll->revents & f_poll_urgent_e) {
+      // @todo then handle out of band, via f_socket_flag_out_of_band_e.
+    }
+
+    // f_socket_flag_peek_e,
+    //f_socket_read_stream
+  }
+#endif // _di_kt_tacocat_receive_process_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 702a93f75811eebe3e91dd0cea77643487f4575a..7662b110eb11e7c1983f739d1040035d238fb7f1 100644 (file)
@@ -31,6 +31,23 @@ extern "C" {
   extern void * kt_tacocat_receive(void * const main);
 #endif // _di_kt_tacocat_receive_
 
+/**
+ * Process the buffer, retrieving the data and writing to the file.
+ *
+ * @param main
+ *   The main program and settings data.
+ *
+ *   This alters main.setting.state.status:
+ *     F_none on success.
+ * @param index
+ *   The position within the receive arrays to process.
+ *
+ * @see f_socket_read_stream()
+ */
+#ifndef _di_kt_tacocat_receive_process_
+  extern void kt_tacocat_receive_process(kt_tacocat_main_t * const main, const f_number_unsigned_t index);
+#endif // _di_kt_tacocat_receive_process_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif