]> Kevux Git Server - fll/commitdiff
Progress: Control and Controller sockets.
authorKevin Day <thekevinday@gmail.com>
Wed, 9 Mar 2022 05:03:46 +0000 (23:03 -0600)
committerKevin Day <thekevinday@gmail.com>
Wed, 9 Mar 2022 05:03:46 +0000 (23:03 -0600)
This also removes accidentally committed debug code (accidentally committed in a previous, unrelated, commit).

21 files changed:
level_3/control/c/control.c
level_3/control/c/main.c
level_3/control/c/private-common.c
level_3/control/c/private-common.h
level_3/control/c/private-control.c
level_3/control/c/private-control.h
level_3/control/c/private-print.c
level_3/control/c/private-print.h
level_3/controller/c/control/private-control.c
level_3/controller/c/control/private-control.h
level_3/controller/c/controller/private-controller.c
level_3/controller/c/controller/private-controller_print.c
level_3/controller/c/controller/private-controller_print.h
level_3/controller/c/entry/private-entry.c
level_3/controller/c/entry/private-entry_print.c
level_3/controller/c/entry/private-entry_print.h
level_3/controller/c/main.c
level_3/controller/c/rule/private-rule.c
level_3/controller/c/rule/private-rule_print.c
level_3/controller/c/rule/private-rule_print.h
level_3/controller/c/thread/private-thread_control.c

index 475b1c82c52b6f0418c61d8440f1b87856ed0f43..7c9feaf669f1b631ff0d1882f37d1012027470c6 100644 (file)
@@ -217,7 +217,13 @@ extern "C" {
             status = control_payload_build(main, &data);
 
             if (F_status_is_error(status)) {
-              fll_error_print(main->error, F_status_set_fine(status), "control_payload_build", F_true);
+              if (F_status_set_fine(status) == F_too_large) {
+                control_print_error_request_packet_too_large(main);
+              }
+              else {
+                fll_error_print(main->error, F_status_set_fine(status), "control_payload_build", F_true);
+              }
+
               fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream);
             }
           }
@@ -235,7 +241,13 @@ extern "C" {
             status = control_payload_receive(main, &data);
 
             if (F_status_is_error(status)) {
-              fll_error_print(main->error, F_status_set_fine(status), "control_payload_receive", F_true);
+              if (F_status_set_fine(status) == F_too_large) {
+                control_print_error_response_packet_valid_not(main);
+              }
+              else {
+                fll_error_print(main->error, F_status_set_fine(status), "control_payload_receive", F_true);
+              }
+
               fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream);
             }
           }
@@ -248,7 +260,7 @@ extern "C" {
         control_data_delete(&data);
       }
       else {
-        control_print_error_commands_none(main);
+        control_print_error_parameter_commands_none(main);
 
         status = F_status_set_error(F_data_not);
       }
index 850fd4626786c7e1c84046f64831a57530659746..d71ff3b539410ba1a57ed6e546afdd9562d9425d 100644 (file)
@@ -2,7 +2,7 @@
 
 int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
-  const f_console_arguments_t arguments = { argc, argv, envp };
+  const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp);
   fll_program_data_t data = fll_program_data_t_initialize;
 
   if (f_pipe_input_exists()) {
index 505b2130245c6654ab079b5470fef22bf82122f8..f619a2942632fa8c29e00afc14d8cf1452022f8e 100644 (file)
@@ -16,16 +16,16 @@ extern "C" {
 #ifndef _di_control_strings_s_
   const f_string_static_t control_path_settings_s = macro_f_string_static_t_initialize(CONTROL_path_settings_s, 0, CONTROL_path_settings_s_length);
 
-  const f_string_static_t control_action_s = macro_f_string_static_t_initialize(CONTROLLER_action_s, 0, CONTROLLER_action_s_length);
+  const f_string_static_t control_action_s = macro_f_string_static_t_initialize(CONTROL_action_s, 0, CONTROL_action_s_length);
   const f_string_static_t control_command_s = macro_f_string_static_t_initialize(CONTROL_command_s, 0, CONTROL_command_s_length);
   const f_string_static_t control_default_s = macro_f_string_static_t_initialize(CONTROL_default_s, 0, CONTROL_default_s_length);
-  const f_string_static_t control_length_s = macro_f_string_static_t_initialize(CONTROLLER_length_s, 0, CONTROLLER_length_s_length);
+  const f_string_static_t control_length_s = macro_f_string_static_t_initialize(CONTROL_length_s, 0, CONTROL_length_s_length);
   const f_string_static_t control_name_socket_s = macro_f_string_static_t_initialize(CONTROL_name_socket_s, 0, CONTROL_name_socket_s_length);
   const f_string_static_t control_path_socket_s = macro_f_string_static_t_initialize(CONTROL_path_socket_s, 0, CONTROL_path_socket_s_length);
   const f_string_static_t control_path_socket_prefix_s = macro_f_string_static_t_initialize(CONTROL_path_socket_prefix_s, 0, CONTROL_path_socket_prefix_s_length);
   const f_string_static_t control_path_socket_suffix_s = macro_f_string_static_t_initialize(CONTROL_path_socket_suffix_s, 0, CONTROL_path_socket_suffix_s_length);
-  const f_string_static_t control_status_s = macro_f_string_static_t_initialize(CONTROLLER_status_s, 0, CONTROLLER_status_s_length);
-  const f_string_static_t control_type_s = macro_f_string_static_t_initialize(CONTROLLER_type_s, 0, CONTROLLER_type_s_length);
+  const f_string_static_t control_status_s = macro_f_string_static_t_initialize(CONTROL_status_s, 0, CONTROL_status_s_length);
+  const f_string_static_t control_type_s = macro_f_string_static_t_initialize(CONTROL_type_s, 0, CONTROL_type_s_length);
 
   const f_string_static_t control_error_s = macro_f_string_static_t_initialize(CONTROL_error_s, 0, CONTROL_error_s_length);
   const f_string_static_t control_freeze_s = macro_f_string_static_t_initialize(CONTROL_freeze_s, 0, CONTROL_freeze_s_length);
index 8888cc9cf1b97e31ae58b85372b42bf24398f4bb..765fe41f3ec4403fd380ed8bb4f2181e869fd3e0 100644 (file)
@@ -37,6 +37,18 @@ extern "C" {
 #endif // _di_control_defines_s_
 
 /**
+ * A codes repesent different flags associated with a packet.
+ *
+ * control_packet_flag_*:
+ *   - binary:     Designate that the packet is in binary mode (when not set then packet is in string mode).
+ *   - endian_big: Designate that the packet is in big endian order (when not set then packet is in little endian order).
+ */
+#ifndef _di_control_packet_flag_
+  #define control_packet_flag_binary_d     0x10000000
+  #define control_packet_flag_endian_big_d 0x01000000
+#endif // _di_control_packet_flag_
+
+/**
  * Controller defines that the control program utilizes.
  *
  * These are intended to exactly match the relevant controller string defines.
index 96ff167ffc47ce0745b94f8780a85aabb178a62d..57fecc27bd9d49740ee3edad4c96a3600bd558c7 100644 (file)
@@ -153,31 +153,51 @@ extern "C" {
     data->cache.small.used = 0;
 
     f_array_length_t i = 0;
-    f_array_length_t length = f_fss_string_header_s.used + f_fss_string_payload_s.used + control_action_s.used + control_type_s.used;
+    f_array_length_t length = 5 + f_fss_string_header_s.used + f_fss_string_payload_s.used + control_action_s.used + control_type_s.used;
     length += f_fss_payload_list_open_s.used * 2;
-    length += f_fss_payload_list_close_s.used * 4
+    length += f_fss_payload_list_close_s.used * 4;
     length += f_string_ascii_0_s.used;
 
     for (; i < main->parameters.remaining.used; ++i) {
       length += f_fss_payload_header_open_s.used + data->argv[main->parameters.remaining.array[i]].used + f_fss_payload_header_close_s.used;
     } // for
 
-    status = f_string_dynamic_resize(length + 11, &data->cache.large);
+    if (length > 0xffffffff) {
+      return F_status_set_error(F_too_large);
+    }
+
+    f_status_t status = f_string_dynamic_resize(length, &data->cache.large);
     if (F_status_is_error(status)) return status;
 
-    // @todo append the string bit and the length bits.
+    // The Packet Control Block.
+    {
+      f_char_t block_control = (f_char_t) control_packet_flag_binary_d;
+
+      #ifdef _is_F_endian_big
+        block_control |= (f_char_t) control_packet_flag_endian_big_d;
+      #endif // _is_F_endian_big
+
+      status = f_string_append(&block_control, 1, &data->cache.large);
+      if (F_status_is_error(status)) return status;
+    }
 
-    // The "header:" line.
+    // The Packet Size Block.
+    {
+      status = f_string_append((f_char_t *) &length, 1, &data->cache.large);
+      if (F_status_is_error(status)) return status;
+    }
+
+    // The Payload "header:" line.
     status = f_string_dynamic_append(f_fss_string_header_s, &data->cache.large);
     if (F_status_is_error(status)) return status;
 
     status = f_string_dynamic_append(f_fss_payload_list_open_s, &data->cache.large);
     if (F_status_is_error(status)) return status;
 
-    status = f_string_dynamic_append(f_fss_payload_list_close_sa, &data->cache.large);
+    status = f_string_dynamic_append(f_fss_payload_list_close_s, &data->cache.large);
     if (F_status_is_error(status)) return status;
 
-    // The "type ..." line.
+    // The Payload "type ..." line.
     status = f_string_dynamic_append(control_type_s, &data->cache.large);
     if (F_status_is_error(status)) return status;
 
@@ -190,7 +210,7 @@ extern "C" {
     status = f_string_dynamic_append(f_fss_payload_header_close_s, &data->cache.large);
     if (F_status_is_error(status)) return status;
 
-    // Each "action ..." line.
+    // Each Payload "action ..." line.
     for (i = 1; i < main->parameters.remaining.used; ++i) {
 
       status = f_string_dynamic_append(control_action_s, &data->cache.large);
@@ -206,7 +226,7 @@ extern "C" {
       if (F_status_is_error(status)) return status;
     } // for
 
-    // The "length 0" line.
+    // The Payload "length 0" line.
     status = f_string_dynamic_append(control_length_s, &data->cache.large);
     if (F_status_is_error(status)) return status;
 
@@ -219,16 +239,18 @@ extern "C" {
     status = f_string_dynamic_append(f_fss_payload_header_close_s, &data->cache.large);
     if (F_status_is_error(status)) return status;
 
-    // The "payload:" line.
+    // The Payload "payload:" line.
     status = f_string_dynamic_append(f_fss_string_payload_s, &data->cache.large);
     if (F_status_is_error(status)) return status;
 
     status = f_string_dynamic_append(f_fss_payload_list_open_s, &data->cache.large);
     if (F_status_is_error(status)) return status;
 
-    status = f_string_dynamic_append(f_fss_payload_list_close_sa, &data->cache.large);
+    status = f_string_dynamic_append(f_fss_payload_list_open_end_s, &data->cache.large);
     if (F_status_is_error(status)) return status;
 
+    // The Payload "payload:" Content is empty.
+
     return F_none;
   }
 #endif // _di_control_payload_build_
@@ -236,6 +258,23 @@ extern "C" {
 #ifndef _di_control_payload_receive_
   f_status_t control_payload_receive(fll_program_data_t * const main, control_data_t * const data) {
 
+    data->cache.large.used = 0;
+    data->cache.small.used = 0;
+
+    uint8_t control = 0;
+
+    {
+      f_array_length_t length = 5;
+
+      f_char_t head[length];
+
+      memset(head, 0, sizeof(f_char_t) * length);
+
+      f_status_t status = f_socket_read(&data->socket, 0, (void *) head, &length);
+      if (F_status_is_error(status)) return status;
+      if (length < 5) return F_status_set_error(F_packet_not);
+    }
+
     // @todo
     return F_none;
   }
@@ -245,6 +284,10 @@ extern "C" {
   f_status_t control_payload_send(fll_program_data_t * const main, control_data_t * const data) {
 
     // @todo
+    f_array_length_t length = 0;
+
+    //F_status_t status = f_socket_write(&data->socket, 0, data->cache.large, &length);
+
     return F_none;
   }
 #endif // _di_control_payload_send_
index 0ee4988c0af6727b5b51db30ffa6ebe5d94d751e..50c0798b91af71970f88c9b676d9d8a842972dc8 100644 (file)
@@ -50,6 +50,19 @@ extern "C" {
  *   The main program data.
  * @param data
  *   The control data.
+ *
+ * @return
+ *   F_none on success.
+ *
+ *   F_too_large (with error bit) If the message is too large for the packet format to transmit.
+ *
+ *   Errors (with error bit) from: f_string_append().
+ *   Errors (with error bit) from: f_string_dynamic_append().
+ *   Errors (with error bit) from: f_string_dynamic_resize().
+ *
+ * @see f_string_append()
+ * @see f_string_dynamic_append()
+ * @see f_string_dynamic_resize()
  */
 #ifndef _di_control_payload_build_
   extern f_status_t control_payload_build(fll_program_data_t * const main, control_data_t * const data) F_attribute_visibility_internal_d;
@@ -62,6 +75,17 @@ extern "C" {
  *   The main program data.
  * @param data
  *   The control data.
+ *
+ * @return
+ *   F_none on success.
+ *
+ *   F_packet_not (with error bit) If the received packet is not a valid packet.
+ *
+ *   Errors (with error bit) from: f_string_dynamic_append().
+ *   Errors (with error bit) from: f_string_dynamic_resize().
+ *
+ * @see f_string_dynamic_append()
+ * @see f_string_dynamic_resize()
  */
 #ifndef _di_control_payload_receive_
   extern f_status_t control_payload_receive(fll_program_data_t * const main, control_data_t * const data) F_attribute_visibility_internal_d;
index 8288b99eb97f7ea98d9ab71c9b2f9a2159dc00bf..e5fa830e2f7eb314f7f73547854694f83c4da3bd 100644 (file)
@@ -6,6 +6,15 @@
 extern "C" {
 #endif
 
+#ifndef _di_control_print_error_parameter_commands_none_
+  void control_print_error_parameter_commands_none(fll_program_data_t * const main) {
+
+    if (main->error.verbosity == f_console_verbosity_quiet_e) return;
+
+    fll_print_format("%r%[%QNo commands provided.%]%r", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error, f_string_eol_s);
+  }
+#endif // _di_control_print_error_parameter_commands_none_
+
 #ifndef _di_control_print_error_parameter_command_not_
   void control_print_error_parameter_command_not(fll_program_data_t * const main, const f_string_static_t command) {
 
@@ -96,15 +105,6 @@ extern "C" {
   }
 #endif // _di_control_print_error_parameter_command_rule_too_many_
 
-#ifndef _di_control_print_error_commands_none_
-  void control_print_error_commands_none(fll_program_data_t * const main) {
-
-    if (main->error.verbosity == f_console_verbosity_quiet_e) return;
-
-    fll_print_format("%r%[%QNo commands provided.%]%r", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error, f_string_eol_s);
-  }
-#endif // _di_control_print_error_commands_none_
-
 #ifndef _di_control_print_error_parameter_value_empty_
   void control_print_error_parameter_value_empty(fll_program_data_t * const main, const f_string_static_t parameter) {
 
@@ -144,6 +144,24 @@ extern "C" {
   }
 #endif // _di_control_print_error_pipe_supported_not_
 
+#ifndef _di_control_print_error_response_packet_valid_not_
+  void control_print_error_response_packet_valid_not(fll_program_data_t * const main) {
+
+    if (main->error.verbosity == f_console_verbosity_quiet_e) return;
+
+    fll_print_format("%r%[%QThe received response is not a valid or supported packet.'%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error);
+  }
+#endif // _di_control_print_error_response_packet_valid_not_
+
+#ifndef _di_control_print_error_request_packet_too_large_
+  void control_print_error_request_packet_too_large(fll_program_data_t * const main) {
+
+    if (main->error.verbosity == f_console_verbosity_quiet_e) return;
+
+    fll_print_format("%r%[%QThe generated packet is too large, cannot send packet.'%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error);
+  }
+#endif // _di_control_print_error_request_packet_too_large_
+
 #ifndef _di_control_print_error_socket_file_failed_
   void control_print_error_socket_file_failed(fll_program_data_t * const main, const f_string_static_t path_socket) {
 
index ddba1f4c8d5e698ae8ecd8f42755500a8f0a0e4f..1d98b8f1aaa1465c7527faad0e1edff4b7757add 100644 (file)
@@ -13,6 +13,16 @@ extern "C" {
 #endif
 
 /**
+ * Print an error message about no commands being provided.
+ *
+ * @param main
+ *   The main program data.
+ */
+#ifndef _di_control_print_error_parameter_commands_none_
+  extern void control_print_error_parameter_commands_none(fll_program_data_t * const main) F_attribute_visibility_internal_d;
+#endif // _di_control_print_error_parameter_commands_none_
+
+/**
  * Print an error message about the given parameter not matching the known set of controller commands.
  *
  * @param main
@@ -85,16 +95,6 @@ extern "C" {
 #endif // _di_control_print_error_parameter_command_rule_too_many_
 
 /**
- * Print an error message about no commands being provided.
- *
- * @param main
- *   The main program data.
- */
-#ifndef _di_control_print_error_commands_none_
-  extern void control_print_error_commands_none(fll_program_data_t * const main) F_attribute_visibility_internal_d;
-#endif // _di_control_print_error_commands_none_
-
-/**
  * Print an error message about the parameter's associated value being an empty string.
  *
  * @param main
@@ -129,6 +129,26 @@ extern "C" {
 #endif // _di_control_print_error_pipe_supported_not_
 
 /**
+ * Print an error message about the response packet format either being invalid or not supported.
+ *
+ * @param main
+ *   The main program data.
+ */
+#ifndef _di_control_print_error_response_packet_valid_not_
+  extern void control_print_error_response_packet_valid_not(fll_program_data_t * const main) F_attribute_visibility_internal_d;
+#endif // _di_control_print_error_response_packet_valid_not_
+
+/**
+ * Print an error message about the request packet being too large.
+ *
+ * @param main
+ *   The main program data.
+ */
+#ifndef _di_control_print_error_request_packet_too_large_
+  void extern control_print_error_request_packet_too_large(fll_program_data_t * const main) F_attribute_visibility_internal_d;
+#endif // _di_control_print_error_request_packet_too_large_
+
+/**
  * Print an error message about failure to connect to the socket file.
  *
  * @param main
index f362fc86ea133caff1a8ff1adec2329fa2db9634..37aa9ddffaa8efe282701d9db69f138daa6a6ab4 100644 (file)
@@ -16,11 +16,7 @@ extern "C" {
       control->client.id = -1;
     }*/
 
-    printf("\nDEBUG: begin client accept, addr=%ul, server id = %i, client id = %i\n", control->client, control->server.id, control->client.id);
-    fll_print_format("\nDEBUG: begin client accept, addr=%ul, server id = %i, client id = %i\n", stdout, control->client, control->server.id, control->client.id);
-
     f_status_t status = f_socket_accept(&control->client, control->server.id);
-    printf("\nDEBUG: client accept, at 1, status = %d\n", F_status_set_fine(status));
 
     if (F_status_is_error(status)) {
       f_socket_disconnect(&control->client, f_socket_close_fast_e);
@@ -35,15 +31,14 @@ extern "C" {
     control->input.used = 0;
     control->output.used = 0;
 
-    unsigned char buffer[controller_control_default_socket_buffer_d + 1];
+    f_char_t buffer[controller_control_default_socket_buffer_d + 1];
     size_t length = 0;
 
-    memset(buffer, 0, sizeof(unsigned char) * (controller_control_default_socket_buffer_d + 1));
+    memset(buffer, 0, sizeof(f_char_t) * (controller_control_default_socket_buffer_d + 1));
 
     // Pre-process the packet header.
     control->client.size_read = controller_control_default_socket_header_d;
     status = f_socket_read(&control->client, f_socket_flag_peek_d, buffer, &length);
-    printf("\nDEBUG: client accept, at 2, status = %d\n", F_status_set_fine(status));
 
     if (F_status_is_error(status)) {
       f_socket_disconnect(&control->client, f_socket_close_fast_e);
@@ -55,7 +50,6 @@ extern "C" {
 
     if (!length) {
       status = controller_control_respond_error_string(global, control, F_empty, "Received packet is empty.");
-      printf("\nDEBUG: client accept, at 3, status = %d\n", F_status_set_fine(status));
 
       f_socket_disconnect(&control->client, f_socket_close_fast_e);
 
@@ -66,7 +60,6 @@ extern "C" {
 
     if (length < controller_control_default_socket_header_d) {
       status = controller_control_respond_error_string(global, control, F_too_large, "Received packet is too small.");
-      printf("\nDEBUG: client accept, at 4, status = %d\n", F_status_set_fine(status));
 
       f_socket_disconnect(&control->client, f_socket_close_fast_e);
 
@@ -77,7 +70,6 @@ extern "C" {
 
     if (length > controller_control_default_socket_buffer_max_d) {
       status = controller_control_respond_error_string(global, control, F_too_large, "Received packet is too large.");
-      printf("\nDEBUG: client accept, at 5, status = %d\n", F_status_set_fine(status));
 
       f_socket_disconnect(&control->client, f_socket_close_fast_e);
 
@@ -92,7 +84,6 @@ extern "C" {
 
     if (packet_flag & controller_control_packet_flag_binary_d) {
       status = controller_control_respond_error_string(global, control, F_supported_not, "Binary is not a currently supported packet mode.");
-      printf("\nDEBUG: client accept, at 6, status = %d\n", F_status_set_fine(status));
 
       f_socket_disconnect(&control->client, f_socket_close_fast_e);
 
@@ -121,7 +112,6 @@ extern "C" {
 
       do {
         status = f_socket_read(&control->client, 0, &control->input, &total);
-      printf("\nDEBUG: client accept, at 7, status = %d\n", F_status_set_fine(status));
 
         if (F_status_is_error(status)) {
           controller_control_respond_error_string(global, control, F_status_set_fine(status), "Failure while reading from control->client socket.");
@@ -143,7 +133,6 @@ extern "C" {
     }
 
     // @todo process the data.
-    fll_print_format("\nDEBUG: received packet: '%q'\n", stdout, control->input);
 
     // @todo send any responses.
 
@@ -212,13 +201,13 @@ extern "C" {
 #endif // _di_controller_control_configure_server_
 
 #ifndef _di_controller_control_packet_header_flag_
-  uint8_t controller_control_packet_header_flag(const unsigned char buffer[]) {
+  uint8_t controller_control_packet_header_flag(const f_char_t buffer[]) {
     return (uint8_t) (((buffer[0] & 0x8) ? controller_control_packet_flag_binary_d : 0) | ((buffer[0] & 0x4) ? controller_control_packet_flag_endian_big_d : 0));
   }
 #endif // _di_controller_control_packet_header_flag_
 
 #ifndef _di_controller_control_packet_header_length_
-  uint32_t controller_control_packet_header_length(const bool is_big, const unsigned char buffer[]) {
+  uint32_t controller_control_packet_header_length(const bool is_big, const f_char_t buffer[]) {
 
     register uint32_t length = (((buffer[0] & 0x3f) << 26) | (buffer[1] << 18) | (buffer[2] << 10) | (buffer[3] << 2) | ((buffer[4] & 0xc0) >> 6));
 
@@ -304,7 +293,6 @@ extern "C" {
 
     control->output.used = 0;
     control->cache_3.used = 0;
-    printf("\nDEBUG: controller_control_respond_error(), at start\n");
 
     {
       const f_conversion_data_t data_conversion = macro_f_conversion_data_t_initialize(10, 0, 1);
@@ -323,8 +311,6 @@ extern "C" {
       if (F_status_is_error(status2)) return status2;
     }
 
-    printf("\nDEBUG: controller_control_respond_error(), before write\n");
-
     return f_socket_write(&control->client, 0, control->output.string, 0);
   }
 #endif // _di_controller_control_respond_error_
@@ -332,7 +318,7 @@ extern "C" {
 #ifndef _di_controller_control_respond_error_string_
   f_status_t controller_control_respond_error_string(const controller_global_t * const global, controller_control_t * const control, const f_status_t status, const f_string_t message) {
 
-    const f_string_static_t string = macro_f_string_static_t_initialize2(message, strlen(message));
+    const f_string_static_t string = macro_f_string_static_t_initialize2(message, strlen((const char *) message));
 
     return controller_control_respond_error(global, control, status, string);
   }
index 6d029c34581caf5f6f1b16b2152a216aef9021ae..509afd19d4757f89b5aa5cbb7145ae3a2265e936 100644 (file)
@@ -82,7 +82,7 @@ extern "C" {
  *   The 8-bit number representing the flags.
  */
 #ifndef _di_controller_control_packet_header_flag_
-  extern uint8_t controller_control_packet_header_flag(const unsigned char buffer[]) F_attribute_visibility_internal_d;
+  extern uint8_t controller_control_packet_header_flag(const f_char_t buffer[]) F_attribute_visibility_internal_d;
 #endif // _di_controller_control_packet_header_flag_
 
 /**
@@ -100,7 +100,7 @@ extern "C" {
  *   The 32-bit number representing the length.
  */
 #ifndef _di_controller_control_packet_header_length_
-  extern uint32_t controller_control_packet_header_length(const bool is_big, const unsigned char buffer[]) F_attribute_visibility_internal_d;
+  extern uint32_t controller_control_packet_header_length(const bool is_big, const f_char_t buffer[]) F_attribute_visibility_internal_d;
 #endif // _di_controller_control_packet_header_length_
 
 /**
index 631d05e49ce70629732b68ec2d3cddee28bf4df9..7e815054071516831d4e4447e4a966d4102bb012 100644 (file)
@@ -74,17 +74,17 @@ extern "C" {
       path.used = cache->action.name_file.used;
     }
 
-    unsigned char path_string[path.used + 1];
+    f_char_t path_string[path.used + 1];
     path.string = path_string;
 
     if (global.setting->path_setting.used) {
-      memcpy(path_string, global.setting->path_setting.string, sizeof(unsigned char) * global.setting->path_setting.used);
-      memcpy(path_string + global.setting->path_setting.used + F_path_separator_s_length, cache->action.name_file.string, sizeof(unsigned char) * cache->action.name_file.used);
+      memcpy(path_string, global.setting->path_setting.string, sizeof(f_char_t) * global.setting->path_setting.used);
+      memcpy(path_string + global.setting->path_setting.used + F_path_separator_s_length, cache->action.name_file.string, sizeof(f_char_t) * cache->action.name_file.used);
 
       path_string[global.setting->path_setting.used] = f_path_separator_s.string[0];
     }
     else {
-      memcpy(path_string, cache->action.name_file.string, sizeof(unsigned char) * cache->action.name_file.used);
+      memcpy(path_string, cache->action.name_file.string, sizeof(f_char_t) * cache->action.name_file.used);
     }
 
     path_string[path.used] = 0;
@@ -368,11 +368,11 @@ extern "C" {
         f_array_length_t length = destination->used - setting->path_current.used;
 
         if (length) {
-          unsigned char temporary[--length];
+          f_char_t temporary[--length];
           temporary[length] = 0;
 
-          memcpy(temporary, destination->string + setting->path_current.used + 1, sizeof(unsigned char) * length);
-          memcpy(destination->string, temporary, sizeof(unsigned char) * length);
+          memcpy(temporary, destination->string + setting->path_current.used + 1, sizeof(f_char_t) * length);
+          memcpy(destination->string, temporary, sizeof(f_char_t) * length);
 
           destination->string[length] = 0;
           destination->used = length;
index fd5e6d6036887fd3b22e9ad47faea9ed35d934d1..da77117be00b3fdf7be8043339bafb8034d847f2 100644 (file)
@@ -8,7 +8,7 @@ extern "C" {
 #endif
 
 #ifndef _di_controller_print_error_
-  void controller_print_error(controller_thread_t * const thread, const fl_print_t print, const f_status_t status, const f_string_t function, const bool fallback) {
+  void controller_print_error(controller_thread_t * const thread, const fl_print_t print, const f_status_t status, const char *function, const bool fallback) {
 
     if (print.verbosity == f_console_verbosity_quiet_e) return;
     if (status == F_interrupt) return;
@@ -27,7 +27,7 @@ extern "C" {
 #endif // _di_controller_print_error_
 
 #ifndef _di_controller_print_error_file_
-  void controller_print_error_file(controller_thread_t * const thread, const fl_print_t print, const f_status_t status, const f_string_t function, const bool fallback, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) {
+  void controller_print_error_file(controller_thread_t * const thread, const fl_print_t print, const f_status_t status, const char *function, const bool fallback, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) {
 
     if (print.verbosity == f_console_verbosity_quiet_e) return;
     if (status == F_interrupt) return;
index d32959d3cf5f307f2640afb17b1225ea8beac121..83cea47270cc3fe8275d0d3e6b5ff10c28b3d0d1 100644 (file)
@@ -32,7 +32,7 @@ extern "C" {
  * @see fll_error_print()
  */
 #ifndef _di_controller_print_error_
-  extern void controller_print_error(controller_thread_t * const thread, const fl_print_t print, const f_status_t status, const f_string_t function, const bool fallback) F_attribute_visibility_internal_d;
+  extern void controller_print_error(controller_thread_t * const thread, const fl_print_t print, const f_status_t status, const char *function, const bool fallback) F_attribute_visibility_internal_d;
 #endif // _di_controller_print_error_
 
 /**
@@ -61,7 +61,7 @@ extern "C" {
  * @see fll_error_file_print()
  */
 #ifndef _di_controller_print_error_file_
-  extern void controller_print_error_file(controller_thread_t * const thread, const fl_print_t print, const f_status_t status, const f_string_t function, const bool fallback, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) F_attribute_visibility_internal_d;
+  extern void controller_print_error_file(controller_thread_t * const thread, const fl_print_t print, const f_status_t status, const char *function, const bool fallback, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) F_attribute_visibility_internal_d;
 #endif // _di_controller_print_error_file_
 
 /**
index 8dbc021538b3397f7f6ff78cce870b2c4549c6a6..6b98acd87c32124566e48aa3d1404f7e6fb48d95 100644 (file)
@@ -1192,11 +1192,11 @@ extern "C" {
           }
 
           const f_array_length_t id_rule_length = entry_action->parameters.array[0].used + entry_action->parameters.array[1].used + 1;
-          unsigned char id_rule_name[id_rule_length + 1];
+          f_char_t id_rule_name[id_rule_length + 1];
           const f_string_static_t alias_rule = macro_f_string_static_t_initialize2(id_rule_name, id_rule_length);
 
-          memcpy(id_rule_name, entry_action->parameters.array[0].string, sizeof(unsigned char) * entry_action->parameters.array[0].used);
-          memcpy(id_rule_name + entry_action->parameters.array[0].used + 1, entry_action->parameters.array[1].string, sizeof(unsigned char) * entry_action->parameters.array[1].used);
+          memcpy(id_rule_name, entry_action->parameters.array[0].string, sizeof(f_char_t) * entry_action->parameters.array[0].used);
+          memcpy(id_rule_name + entry_action->parameters.array[0].used + 1, entry_action->parameters.array[1].string, sizeof(f_char_t) * entry_action->parameters.array[1].used);
 
           id_rule_name[entry_action->parameters.array[0].used] = f_path_separator_s.string[0];
           id_rule_name[id_rule_length] = 0;
@@ -1251,13 +1251,13 @@ extern "C" {
             const f_array_length_t cache_name_item_used = cache->action.name_item.used;
             const f_array_length_t cache_name_file_used = cache->action.name_file.used;
 
-            unsigned char cache_name_action[cache_name_action_used];
-            unsigned char cache_name_item[cache_name_item_used];
-            unsigned char cache_name_file[cache_name_file_used];
+            f_char_t cache_name_action[cache_name_action_used];
+            f_char_t cache_name_item[cache_name_item_used];
+            f_char_t cache_name_file[cache_name_file_used];
 
-            memcpy(cache_name_action, cache->action.name_action.string, sizeof(unsigned char) * cache->action.name_action.used);
-            memcpy(cache_name_item, cache->action.name_item.string, sizeof(unsigned char) * cache->action.name_item.used);
-            memcpy(cache_name_file, cache->action.name_file.string, sizeof(unsigned char) * cache->action.name_file.used);
+            memcpy(cache_name_action, cache->action.name_action.string, sizeof(f_char_t) * cache->action.name_action.used);
+            memcpy(cache_name_item, cache->action.name_item.string, sizeof(f_char_t) * cache->action.name_item.used);
+            memcpy(cache_name_file, cache->action.name_file.string, sizeof(f_char_t) * cache->action.name_file.used);
 
             status_lock = controller_lock_write(is_entry, global->thread, &global->thread->lock.rule);
 
@@ -1266,9 +1266,9 @@ extern "C" {
             }
 
             // Restore cache.
-            memcpy(cache->action.name_action.string, cache_name_action, sizeof(unsigned char) * cache_name_action_used);
-            memcpy(cache->action.name_item.string, cache_name_item, sizeof(unsigned char) * cache_name_item_used);
-            memcpy(cache->action.name_file.string, cache_name_file, sizeof(unsigned char) * cache_name_file_used);
+            memcpy(cache->action.name_action.string, cache_name_action, sizeof(f_char_t) * cache_name_action_used);
+            memcpy(cache->action.name_item.string, cache_name_item, sizeof(f_char_t) * cache_name_item_used);
+            memcpy(cache->action.name_file.string, cache_name_file, sizeof(f_char_t) * cache_name_file_used);
 
             cache->action.name_action.string[cache_name_action_used] = 0;
             cache->action.name_item.string[cache_name_item_used] = 0;
index 4b041aa18326a9307954a475be653ca70203e17c..461fbaac5c985ecb737cf302841393e120057fdc 100644 (file)
@@ -59,7 +59,7 @@ extern "C" {
 #endif // _di_controller_entry_preprocess_print_simulate_setting_value_
 
 #ifndef _di_controller_entry_print_error_
-  void controller_entry_print_error(const bool is_entry, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, controller_thread_t *thread) {
+  void controller_entry_print_error(const bool is_entry, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const char *function, const bool fallback, controller_thread_t *thread) {
 
     if (print.verbosity == f_console_verbosity_quiet_e) return;
     if (status == F_interrupt) return;
@@ -108,7 +108,7 @@ extern "C" {
 #endif // _di_controller_entry_print_error_cache_
 
 #ifndef _di_controller_entry_print_error_file_
-  void controller_entry_print_error_file(const bool is_entry, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const f_string_static_t name, const f_string_static_t operation, const uint8_t type, controller_thread_t *thread) {
+  void controller_entry_print_error_file(const bool is_entry, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const char *function, const bool fallback, const f_string_static_t name, const f_string_static_t operation, const uint8_t type, controller_thread_t *thread) {
 
     if (print.verbosity == f_console_verbosity_quiet_e) return;
     if (status == F_interrupt) return;
index 270316e450b4cc2493bb2171839152ac51f7e2ba..209d0bf3eb0ec7d00d9ef57bbca4172a109792d4 100644 (file)
@@ -91,7 +91,7 @@ extern "C" {
  * @see controller_entry_print_error_cache()
  */
 #ifndef _di_controller_entry_print_error_
-  extern void controller_entry_print_error(const bool is_entry, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, controller_thread_t *thread) F_attribute_visibility_internal_d;
+  extern void controller_entry_print_error(const bool is_entry, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const char *function, const bool fallback, controller_thread_t *thread) F_attribute_visibility_internal_d;
 #endif // _di_controller_entry_print_error_
 
 /**
@@ -147,7 +147,7 @@ extern "C" {
  * @see controller_entry_print_error_cache()
  */
 #ifndef _di_controller_entry_print_error_file_
-  extern void controller_entry_print_error_file(const bool is_entry, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const f_string_static_t name, const f_string_static_t operation, const uint8_t type, controller_thread_t *thread) F_attribute_visibility_internal_d;
+  extern void controller_entry_print_error_file(const bool is_entry, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const char *function, const bool fallback, const f_string_static_t name, const f_string_static_t operation, const uint8_t type, controller_thread_t *thread) F_attribute_visibility_internal_d;
 #endif // _di_controller_entry_print_error_file_
 
 /**
index 4c46e0ef239449600a612916af6f4135109be1de..376f31b770d840dd5ab86dcf0df2718d55f41629 100644 (file)
@@ -2,7 +2,7 @@
 
 int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
-  const f_console_arguments_t arguments = { argc, argv, envp };
+  const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp);
   controller_main_t data = controller_main_t_initialize;
 
   if (f_pipe_input_exists()) {
index 13f4ce14fcfe0491cef04c460ab9f70fad5ccc55..33155949c5d761505b216644a09f61feb3e53b4d 100644 (file)
@@ -1895,19 +1895,14 @@ extern "C" {
           controller_lock_print(main->output.to, thread);
 
           fl_print_format("%rRe-running '", main->output.to.stream, f_string_eol_s);
-          fl_print_format("%[%r%]", main->output.to.stream, main->context.set.title, process->rule.alias, main->context.set.title);
-          f_print_terminated("' '", main->output.to.stream);
-          fl_print_format("%[%r%]", main->output.to.stream, main->context.set.notable, controller_rule_action_type_execute_name(action), main->context.set.notable);
-          f_print_terminated("' with a ", main->output.to.stream);
-          fl_print_format("%[%r%]", main->output.to.stream, main->context.set.notable, controller_delay_s, main->context.set.notable);
-          f_print_terminated(" of ", main->output.to.stream);
+          fl_print_format("%[%r%]' '", main->output.to.stream, main->context.set.title, process->rule.alias, main->context.set.title);
+          fl_print_format("%[%r%]' with a ", main->output.to.stream, main->context.set.notable, controller_rule_action_type_execute_name(action), main->context.set.notable);
+          fl_print_format("%[%r%] of ", main->output.to.stream, main->context.set.notable, controller_delay_s, main->context.set.notable);
           fl_print_format("%[%ul%] MegaTime", main->output.to.stream, main->context.set.notable, rerun_item->delay, main->context.set.notable);
 
           if (rerun_item->max) {
-            f_print_terminated(" for ", main->output.to.stream);
-            fl_print_format("%[%ul%]", main->output.to.stream, main->context.set.notable, rerun_item->count, main->context.set.notable);
-            f_print_terminated(" of ", main->output.to.stream);
-            fl_print_format("%[%r%] ", main->output.to.stream, main->context.set.notable, controller_max_s, main->context.set.notable);
+            fl_print_format(" for %[%ul%]", main->output.to.stream, main->context.set.notable, rerun_item->count, main->context.set.notable);
+            fl_print_format(" of %[%r%] ", main->output.to.stream, main->context.set.notable, controller_max_s, main->context.set.notable);
             fl_print_format("%[%ul%]", main->output.to.stream, main->context.set.notable, rerun_item->max, main->context.set.notable);
             fl_print_format(".%r", main->output.to.stream, f_string_eol_s);
           }
@@ -2059,9 +2054,9 @@ extern "C" {
         f_string_static_t buffer = f_string_static_t_initialize;
         buffer.used = (content.stop - content.start) + 1;
 
-        unsigned char buffer_string[buffer.used + 1];
+        f_char_t buffer_string[buffer.used + 1];
 
-        memcpy(buffer_string, source.string + content.start, sizeof(unsigned char) * buffer.used);
+        memcpy(buffer_string, source.string + content.start, sizeof(f_char_t) * buffer.used);
         buffer_string[buffer.used] = 0;
         buffer.string = buffer_string;
         process->cache.action.generic.used = 0;
@@ -2243,11 +2238,11 @@ extern "C" {
           f_string_static_t buffer = f_string_static_t_initialize;
           buffer.used = options[i].used + controller_parameter_map_option_s.used;
 
-          unsigned char buffer_string[buffer.used];
+          f_char_t buffer_string[buffer.used];
           buffer.string = buffer_string;
 
-          memcpy(buffer_string, options[i].string, sizeof(unsigned char) * options[i].used);
-          memcpy(buffer_string + options[i].used, controller_parameter_map_option_s.string, sizeof(unsigned char) * controller_parameter_map_option_s.used);
+          memcpy(buffer_string, options[i].string, sizeof(f_char_t) * options[i].used);
+          memcpy(buffer_string + options[i].used, controller_parameter_map_option_s.string, sizeof(f_char_t) * controller_parameter_map_option_s.used);
 
           if (fl_string_dynamic_partial_compare_string(buffer.string, source, buffer.used, content) == F_equal_to) {
             if (values[i] && parameters->array[codes[i]].result == f_console_result_additional_e || !values[i] && parameters->array[codes[i]].result == f_console_result_found_e) {
@@ -2269,11 +2264,11 @@ extern "C" {
           f_string_static_t buffer = f_string_static_t_initialize;
           buffer.used = options[i].used + controller_parameter_map_value_s.used;
 
-          unsigned char buffer_string[buffer.used];
+          f_char_t buffer_string[buffer.used];
           buffer.string = buffer_string;
 
-          memcpy(buffer_string, options[i].string, sizeof(unsigned char) * options[i].used);
-          memcpy(buffer_string + options[i].used, controller_parameter_map_value_s.string, sizeof(unsigned char) * controller_parameter_map_value_s.used);
+          memcpy(buffer_string, options[i].string, sizeof(f_char_t) * options[i].used);
+          memcpy(buffer_string + options[i].used, controller_parameter_map_value_s.string, sizeof(f_char_t) * controller_parameter_map_value_s.used);
 
           if (fl_string_dynamic_partial_compare_string(buffer.string, source, buffer.used, content) == F_equal_to) {
             if (parameters->array[codes[i]].result == f_console_result_additional_e) {
@@ -2881,10 +2876,10 @@ extern "C" {
             f_string_static_t alias_other_buffer = f_string_static_t_initialize;
             alias_other_buffer.used = global.setting->rules.array[id_rule].alias.used;
 
-            unsigned char alias_other_buffer_string[alias_other_buffer.used + 1];
+            f_char_t alias_other_buffer_string[alias_other_buffer.used + 1];
             alias_other_buffer.string = alias_other_buffer_string;
 
-            memcpy(alias_other_buffer_string, global.setting->rules.array[id_rule].alias.string, sizeof(unsigned char) * alias_other_buffer.used);
+            memcpy(alias_other_buffer_string, global.setting->rules.array[id_rule].alias.string, sizeof(f_char_t) * alias_other_buffer.used);
             alias_other_buffer_string[alias_other_buffer.used] = 0;
 
             f_thread_unlock(&global.thread->lock.rule);
@@ -4004,10 +3999,10 @@ extern "C" {
     const f_array_length_t line_item = cache->action.line_item;
     const f_array_length_t length_name_item = cache->action.name_item.used;
 
-    unsigned char name_item[length_name_item];
+    f_char_t name_item[length_name_item];
     name_item[length_name_item] = 0;
 
-    memcpy(name_item, cache->action.name_item.string, sizeof(unsigned char) * length_name_item);
+    memcpy(name_item, cache->action.name_item.string, sizeof(f_char_t) * length_name_item);
 
     for (; i < cache->content_actions.used; ++i, type = 0) {
 
@@ -5700,7 +5695,7 @@ extern "C" {
     } // for
 
     // Restore the current name item and line number, which there should already be enough allocated space for.
-    memcpy(cache->action.name_item.string, name_item, sizeof(unsigned char) * length_name_item);
+    memcpy(cache->action.name_item.string, name_item, sizeof(f_char_t) * length_name_item);
 
     cache->action.name_item.string[length_name_item] = 0;
     cache->action.name_item.used = length_name_item;
@@ -6073,8 +6068,7 @@ extern "C" {
 
                   if (action->parameters.array[0].string[k] == f_fss_eol_s.string[0]) {
                     if (k + 1 < action->parameters.array[0].used) {
-                      f_print_dynamic_raw(f_string_eol_s, main->output.to.stream);
-                      f_print_terminated("        ", main->output.to.stream);
+                      fl_print_format("%r        ", main->output.to.stream, f_string_eol_s);
                     }
                   }
                   else {
index 1c4369ec7c429a9e22fcd42a2264db4c11445d32..a8a90884cbd522c38cc4c93b5bc254adfd4e1f28 100644 (file)
@@ -11,7 +11,7 @@ extern "C" {
 #endif // _di_controller_rule_print_string_s_
 
 #ifndef _di_controller_rule_print_error_
-  void controller_rule_print_error(controller_thread_t * const thread, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item) {
+  void controller_rule_print_error(controller_thread_t * const thread, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const char *function, const bool fallback, const bool item) {
 
     if (print.verbosity == f_console_verbosity_quiet_e) return;
     if (status == F_interrupt) return;
index 148068d0bbb888cac3b591d2b395acd08506f1e0..656dbc4792eca7912ef30f5928e52f107d431400 100644 (file)
@@ -49,7 +49,7 @@ extern "C" {
  * @see controller_rule_print_error_cache()
  */
 #ifndef _di_controller_rule_print_error_
-  extern void controller_rule_print_error(controller_thread_t * const thread, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item) F_attribute_visibility_internal_d;
+  extern void controller_rule_print_error(controller_thread_t * const thread, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const char *function, const bool fallback, const bool item) F_attribute_visibility_internal_d;
 #endif // _di_controller_rule_print_error_
 
 /**
index 284a66f1ad6f40dadf10480773fac35a9a1765a4..8a2098a85454e06645f7c9995062e68d948f50b4 100644 (file)
@@ -24,7 +24,6 @@ extern "C" {
     controller_control_t *control = &global->setting->control;
 
     do {
-      fll_print_format("\nDEBUG: Control Thread Main Loop, server id = %il.\n", stdout, control->server.id);
 
       // Remove any overly large buffers.
       if (control->cache_1.size > controller_control_default_socket_cache_d) {
@@ -55,8 +54,6 @@ extern "C" {
 
       status = f_socket_listen(&control->server, controller_control_default_socket_backlog_d);
 
-      fll_print_format("\nDEBUG: Listen returned, status = %ui.\n", stdout, status);
-
       if (F_status_is_error(status)) {
         controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_socket_listen", F_true);
 
@@ -73,20 +70,14 @@ extern "C" {
       status = controller_control_accept(global, control);
       if (status == F_child) break;
 
-      fll_print_format("\nDEBUG: Accept returned, status = %ui.\n", stdout, F_status_set_fine(status));
-
       if (F_status_is_error(status)) {
         controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "controller_control_accept", F_true);
       }
 
       status = F_none;
 
-      fll_print_format("\nDEBUG: End of loop.\n", stdout);
-
     } while (global->thread->enabled == controller_thread_enabled_e);
 
-    fll_print_format("\nDEBUG: Out of loop.\n", stdout);
-
     if (status == F_child) {
 
       // A forked child process should deallocate memory on exit.
@@ -95,12 +86,8 @@ extern "C" {
       controller_thread_delete_simple(global->thread);
       controller_setting_delete_simple(global->setting);
       controller_main_delete(global->main);
-
-      fll_print_format("\nDEBUG: child exit, all data should be deleted.\n", stdout);
     }
 
-    fll_print_format("\nDEBUG: cache should be deleted, final exit.\n", stdout);
-
     return 0;
   }
 #endif // _di_controller_thread_control_