]> Kevux Git Server - fll/commitdiff
Progress: Controller and Control sockets.
authorKevin Day <thekevinday@gmail.com>
Sun, 27 Mar 2022 03:14:28 +0000 (22:14 -0500)
committerKevin Day <thekevinday@gmail.com>
Sun, 27 Mar 2022 03:14:28 +0000 (22:14 -0500)
level_3/control/c/control.c
level_3/control/c/control.h
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

index fd39fb7dd0160fcca45002896941b2c092ba406b..4dde4e5e684cf12160e8786f30dffc5c52c1fb70 100644 (file)
@@ -8,7 +8,7 @@ extern "C" {
 #endif
 
 #ifndef _di_control_print_help_
-  f_status_t control_print_help(fll_program_data_t * const main) {
+  f_status_t control_print_help(const fll_program_data_t * const main) {
 
     flockfile(main->output.to.stream);
 
index e0df4dad4d1e978e30631d47b0e3f834254c5055..e36c237e5b3e5cd0186f9fceca7964dc72661970 100644 (file)
@@ -69,7 +69,7 @@ extern "C" {
  * @see control_main()
  */
 #ifndef _di_control_print_help_
-  extern f_status_t control_print_help(fll_program_data_t * const main);
+  extern f_status_t control_print_help(const fll_program_data_t * const main);
 #endif // _di_control_print_help_
 
 /**
index c93d0bc3c60c5355a4287ae4776d6394f6877aa0..9051a2599917b67c1395781c609aeca3ab6bf526 100644 (file)
@@ -62,7 +62,7 @@ extern "C" {
 #endif // _di_control_data_delete_
 
 #ifndef _di_control_signal_received_
-  f_status_t control_signal_received(fll_program_data_t * const main) {
+  f_status_t control_signal_received(const fll_program_data_t * const main) {
 
     if (main->signal.id == -1) {
       return F_false;
index 1256fb27983aa8a612eacf90ccff7d691b1bf049..bd47084d18f3b42f4675d84f975c37d11d7e2860 100644 (file)
@@ -334,7 +334,7 @@ extern "C" {
  * @see f_signal_read()
  */
 #ifndef _di_control_signal_received_
-  extern f_status_t control_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d;
+  extern f_status_t control_signal_received(const fll_program_data_t * const main) F_attribute_visibility_internal_d;
 #endif // _di_control_signal_received_
 
 /**
index 7d50e40174a26ae59d945907fa3543f8ab64d9af..7078f279ef1402216a3c654ba2563668eaf741ec 100644 (file)
@@ -8,7 +8,7 @@ extern "C" {
 #endif
 
 #ifndef _di_control_action_verify_
-  f_status_t control_action_verify(fll_program_data_t * const main, control_data_t * const data) {
+  f_status_t control_action_verify(const fll_program_data_t * const main, control_data_t * const data) {
 
     switch (data->action) {
       case control_action_type_freeze_e:
@@ -54,21 +54,14 @@ extern "C" {
         return F_none;
     }
 
+    // Handle "kexec", "reboot", and "shutdown".
     // @todo the reboot and shutdown need to support date and time actions: "now", "in (a time)", and "at (a time)".
-    if (data->action == control_action_type_reboot_e) {
-      // @todo (also needs to support kexec calls or kexec needs its own action, which will likely be in the controller program.)
-    }
-
-    if (data->action == control_action_type_shutdown_e) {
-      // @todo
-    }
-
-    return F_none;
+    return F_status_set_error(F_supported_not);
   }
 #endif // _di_control_action_verify_
 
 #ifndef _di_control_packet_build_
-  f_status_t control_packet_build(fll_program_data_t * const main, control_data_t * const data) {
+  f_status_t control_packet_build(const fll_program_data_t * const main, control_data_t * const data) {
 
     data->cache.large.used = 0;
     data->cache.small.used = 0;
@@ -83,7 +76,7 @@ extern "C" {
       length += f_fss_payload_header_open_s.used + data->argv[main->parameters.remaining.array[i]].used + f_fss_payload_header_close_s.used;
     } // for
 
-    if (length > 0xffffffff) {
+    if (length > 0xffffffffu) {
       return F_status_set_error(F_too_large);
     }
 
@@ -176,8 +169,31 @@ extern "C" {
   }
 #endif // _di_control_packet_build_
 
+#ifndef _di_control_packet_header_flag_
+  uint8_t control_packet_header_flag(const uint8_t buffer[]) {
+    return (uint8_t) (((buffer[0] & 0x8u) ? control_packet_flag_binary_d : 0) | ((buffer[0] & 0x4u) ? control_packet_flag_endian_big_d : 0));
+  }
+#endif // _di_control_packet_header_flag_
+
+#ifndef _di_control_packet_header_length_
+  uint32_t control_packet_header_length(const bool is_big, const f_char_t buffer[]) {
+
+    #ifdef _is_F_endian_big
+      if (is_big) {
+        return (buffer[1] << 24u) | (buffer[2] << 16u) | (buffer[3] << 8u) | buffer[4];
+      }
+    #else
+      if (!is_big) {
+        return (buffer[1] << 24u) | (buffer[2] << 16u) | (buffer[3] << 8u) | buffer[4];
+      }
+    #endif // _is_F_endian_big
+
+    return (buffer[4] << 24u) | (buffer[3] << 16u) | (buffer[2] << 8u) | buffer[1];
+  }
+#endif // _di_control_packet_header_length_
+
 #ifndef _di_control_packet_receive_
-  f_status_t control_packet_receive(fll_program_data_t * const main, control_data_t * const data, control_payload_header_t * const header) {
+  f_status_t control_packet_receive(const fll_program_data_t * const main, control_data_t * const data, control_payload_header_t * const header) {
 
     data->cache.large.used = 0;
     data->cache.small.used = 0;
@@ -208,42 +224,16 @@ extern "C" {
       if (F_status_is_error(status)) return status;
       if (length < 5) return F_status_set_error(F_packet_not);
 
-      uint8_t control = head[0] & (control_packet_flag_binary_d | control_packet_flag_endian_big_d);
+      uint8_t contol = control_packet_header_flag(head);
 
       // Only the first two bits of the 8 Control bits are allowed to be set to 1 for this Packet.
       if (head[0] & (~(control_packet_flag_binary_d | control_packet_flag_endian_big_d))) {
         return F_status_set_error(F_packet_not);
       }
 
-      #ifdef _is_F_endian_big
-        if (control & control_packet_flag_endian_big_d) {
-          length = ((uint8_t) head[1]) << 24;
-          length |= ((uint8_t) head[2]) << 16;
-          length |= ((uint8_t) head[3]) << 8;
-          length |= (uint8_t) head[4];
-        }
-        else {
-          length = ((uint8_t) head[1]);
-          length |= ((uint8_t) head[2]) >> 8;
-          length |= ((uint8_t) head[3]) >> 16;
-          length |= (uint8_t) head[4] >> 24;
-        }
-      #else
-        if (control & control_packet_flag_endian_big_d) {
-          length = ((uint8_t) head[1]);
-          length |= ((uint8_t) head[2]) >> 8;
-          length |= ((uint8_t) head[3]) >> 16;
-          length |= (uint8_t) head[4] >> 24;
-        }
-        else {
-          length = ((uint8_t) head[1]) << 24;
-          length |= ((uint8_t) head[2]) << 16;
-          length |= ((uint8_t) head[3]) << 8;
-          length |= (uint8_t) head[4];
-        }
-      #endif // #ifdef _is_F_endian_big
+      length = control_packet_header_length(head[0] & control_packet_flag_endian_big_d, head);
 
-      if (length > 0xffffffff) {
+      if (length > 0xffffffffu) {
         return F_status_set_error(F_too_large);
       }
 
@@ -500,7 +490,7 @@ extern "C" {
 #endif // _di_control_packet_receive_
 
 #ifndef _di_control_packet_process_
-  f_status_t control_packet_process(fll_program_data_t * const main, control_data_t * const data, control_payload_header_t * const header) {
+  f_status_t control_packet_process(const fll_program_data_t * const main, control_data_t * const data, control_payload_header_t * const header) {
 
     f_string_static_t string_status = f_string_static_t_initialize;
 
@@ -538,17 +528,37 @@ extern "C" {
 #endif // _di_control_packet_process_
 
 #ifndef _di_control_packet_send_
-  f_status_t control_packet_send(fll_program_data_t * const main, control_data_t * const data) {
+  f_status_t control_packet_send(const fll_program_data_t * const main, control_data_t * const data) {
 
-    f_array_length_t length = 0;
+    {
+      f_status_t status = F_none;
+      f_string_dynamic_t payload = f_string_dynamic_t_initialize;
+
+      switch (data->action) {
+        case control_action_type_freeze_e:
+        case control_action_type_kill_e:
+        case control_action_type_pause_e:
+        case control_action_type_reload_e:
+        case control_action_type_rerun_e:
+        case control_action_type_restart_e:
+        case control_action_type_resume_e:
+        case control_action_type_start_e:
+        case control_action_type_stop_e:
+        case control_action_type_thaw_e:
+          payload = data->argv[main->parameters.remaining.array[1]];
+          break;
+
+        default:
+          // @todo construct message for kexec, reboot, and shutdown.
+          break;
+      }
 
-    f_status_t status = control_packet_send_build_header(main, data, control_action_type_name(data->action), f_string_empty_s, length);
-    if (F_status_is_error(status)) return status;
+      status = control_packet_send_build(main, data, control_controller_s, control_action_type_name(data->action), f_string_empty_s, payload);
 
-    const f_state_t state = f_state_t_initialize;
+      f_string_dynamic_resize(0, &payload);
 
-    status = fll_fss_payload_write_string(f_fss_string_payload_s, f_string_empty_s, F_false, 0, state, &data->cache.packet);
-    if (F_status_is_error(status)) return status;
+      if (F_status_is_error(status)) return status;
+    }
 
     data->socket.size_write = data->cache.packet.used;
 
@@ -556,8 +566,8 @@ extern "C" {
   }
 #endif // _di_control_packet_send_
 
-#ifndef _di_control_packet_send_build_header_
-  f_status_t control_packet_send_build_header(fll_program_data_t * const main, control_data_t * const data, const f_string_static_t type, const f_string_static_t status, const f_array_length_t length) {
+#ifndef _di_control_packet_send_build_
+  f_status_t control_packet_send_build(const fll_program_data_t * const main, control_data_t * const data, const f_string_static_t type, const f_string_static_t action, const f_string_static_t status, const f_string_static_t payload) {
 
     f_status_t status2 = F_none;
 
@@ -568,13 +578,40 @@ extern "C" {
     f_string_static_t contents[1];
     content.array = contents;
     content.used = 1;
-    content.size = 1;
 
     data->cache.large.used = 0;
     data->cache.small.used = 0;
     data->cache.packet.used = 0;
 
-    // Header: type.
+    // Reserve space in data->cache.packet.size for the packet header as well as other parts.
+    {
+      // 5 for packet header and 2 for ':\n" for both 'header' and 'payload'.
+      f_array_length_t total = 9 + f_fss_string_header_s.used + f_fss_string_payload_s.used + control_length_s.used + payload.used;
+
+      if (type.used) {
+        total += control_type_s.used + type.used + 2;
+      }
+
+      if (action.used) {
+        total += control_action_s.used + action.used + 2;
+      }
+
+      if (status.used) {
+        total += control_status_s.used + status.used + 2;
+      }
+
+      status2 = f_string_dynamic_increase_by(total, &data->cache.packet);
+    }
+
+    #ifdef _is_F_endian_big
+      data->cache.packet.string[0] = control_packet_flag_endian_big_d;
+    #else
+      data->cache.packet.string[0] = 0;
+    #endif // _is_F_endian_big
+
+    data->cache.packet.used = 5;
+
+    // Payload Header: type.
     if (type.used) {
       contents[0] = type;
 
@@ -582,18 +619,24 @@ extern "C" {
       if (F_status_is_error(status2)) return status2;
     }
 
-    // Header: status.
+    // Payload Header: action.
+    if (action.used) {
+      contents[0] = action;
+
+      status2 = fll_fss_extended_write_string(control_action_s, content, 0, state, &data->cache.large);
+      if (F_status_is_error(status2)) return status2;
+    }
+
+    // Payload Header: status.
     if (status.used) {
       contents[0] = status;
 
       status2 = fll_fss_extended_write_string(control_status_s, content, 0, state, &data->cache.large);
       if (F_status_is_error(status2)) return status2;
-
-      data->cache.small.used = 0;
     }
 
-    // Header: length.
-    status2 = f_conversion_number_unsigned_to_string(length, data_conversion, &data->cache.small);
+    // Payload Header: length.
+    status2 = f_conversion_number_unsigned_to_string(payload.used, data_conversion, &data->cache.small);
     if (F_status_is_error(status2)) return status2;
 
     contents[0] = data->cache.small;
@@ -601,20 +644,33 @@ extern "C" {
     status2 = fll_fss_extended_write_string(control_length_s, content, 0, state, &data->cache.large);
     if (F_status_is_error(status2)) return status2;
 
-    // Prepend the identifier comment to the output.
-    status2 = f_string_dynamic_append(control_type_s, &data->cache.packet);
+    // Payload Packet: Header.
+    status2 = fll_fss_payload_write_string(f_fss_string_header_s, data->cache.large, F_false, 0, state, &data->cache.packet);
     if (F_status_is_error(status2)) return status2;
 
-    // Append entire header block to the output.
-    status2 = fll_fss_payload_write_string(f_fss_string_header_s, data->cache.large, F_false, 0, state, &data->cache.packet);
+    // Payload Packet: Payload.
+    status2 = fll_fss_payload_write_string(f_fss_string_payload_s, payload, F_false, 0, state, &data->cache.packet);
     if (F_status_is_error(status2)) return status2;
 
+    // Construct packet size.
+    #ifdef _is_F_endian_big
+      data->cache.packet.string[1] = data->cache.packet.used & 0xffu;
+      data->cache.packet.string[2] = data->cache.packet.used & 0xff00u;
+      data->cache.packet.string[3] = data->cache.packet.used & 0xff0000u;
+      data->cache.packet.string[4] = data->cache.packet.used & 0xff000000u;
+    #else
+      data->cache.packet.string[1] = data->cache.packet.used & 0xff000000u;
+      data->cache.packet.string[2] = data->cache.packet.used & 0xff0000u;
+      data->cache.packet.string[3] = data->cache.packet.used & 0xff00u;
+      data->cache.packet.string[4] = data->cache.packet.used & 0xffu;
+    #endif // _is_F_endian_big
+
     return F_none;
   }
-#endif // _di_control_packet_send_build_header_
+#endif // _di_control_packet_send_build_
 
 #ifndef _di_control_settings_load_
-  f_status_t control_settings_load(fll_program_data_t * const main, control_data_t * const data) {
+  f_status_t control_settings_load(const fll_program_data_t * const main, control_data_t * const data) {
 
     f_status_t status = F_none;
 
@@ -817,42 +873,34 @@ extern "C" {
               status = F_status_set_error(F_socket_not);
             }
           }
+        }
+      }
 
-          if (F_status_is_error_not(status)) {
-            if (f_file_is(data->cache.small, F_file_type_socket_d, F_true) == F_false) {
-              control_print_error_socket_file_not(main, data->cache.small);
-
-              status = F_status_set_error(F_socket_not);
-            }
-          }
-
-          if (F_status_is_error_not(status)) {
-            status = f_socket_create(&data->socket);
+      if (F_status_is_error_not(status)) {
+        if (f_file_is(data->cache.small, F_file_type_socket_d, F_true) == F_false) {
+          control_print_error_socket_file_not(main, data->cache.small);
 
-            if (F_status_is_error(status)) {
-              fll_error_print(main->error, F_status_set_fine(status), "f_socket_create", F_true);
+          status = F_status_set_error(F_socket_not);
+        }
+      }
 
-              if (main->error.verbosity != f_console_verbosity_quiet_e) {
-                fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream);
-              }
+      if (F_status_is_error_not(status)) {
+        status = f_socket_create(&data->socket);
 
-              control_print_error_socket_file_failed(main, data->cache.small);
-            }
-          }
+        if (F_status_is_error(status)) {
+          fll_error_print(main->error, F_status_set_fine(status), "f_socket_create", F_true);
 
-          if (F_status_is_error_not(status)) {
-            status = f_socket_connect(data->socket);
+          control_print_error_socket_file_failed(main, data->cache.small);
+        }
+      }
 
-            if (F_status_is_error(status)) {
-              fll_error_print(main->error, F_status_set_fine(status), "f_socket_connect", F_true);
+      if (F_status_is_error_not(status)) {
+        status = f_socket_connect(data->socket);
 
-              if (main->error.verbosity != f_console_verbosity_quiet_e) {
-                fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream);
-              }
+        if (F_status_is_error(status)) {
+          fll_error_print(main->error, F_status_set_fine(status), "f_socket_connect", F_true);
 
-              control_print_error_socket_file_failed(main, data->cache.small);
-            }
-          }
+          control_print_error_socket_file_failed(main, data->cache.small);
         }
       }
     }
index 7dc6a7e28f76f91a3ac53ee3fc0391b09e4dbd6a..7a303f42c4cf8f49a1e31cfd44a5d38dbc39b6cc 100644 (file)
@@ -21,7 +21,7 @@ extern "C" {
  *   The control data.
  */
 #ifndef _di_control_action_verify_
-  extern f_status_t control_action_verify(fll_program_data_t * const main, control_data_t * const data) F_attribute_visibility_internal_d;
+  extern f_status_t control_action_verify(const fll_program_data_t * const main, control_data_t * const data) F_attribute_visibility_internal_d;
 #endif // _di_control_action_verify_
 
 /**
@@ -46,10 +46,41 @@ extern "C" {
  * @see f_string_dynamic_resize()
  */
 #ifndef _di_control_packet_build_
-  extern f_status_t control_packet_build(fll_program_data_t * const main, control_data_t * const data) F_attribute_visibility_internal_d;
+  extern f_status_t control_packet_build(const fll_program_data_t * const main, control_data_t * const data) F_attribute_visibility_internal_d;
 #endif // _di_control_packet_build_
 
 /**
+ * Given the header buffer, get the flag bits.
+ *
+ * @param buffer
+ *   The buffer to read the length of and get the
+ *
+ * @return
+ *   The 8-bit number representing the flags.
+ */
+#ifndef _di_control_packet_header_flag_
+  extern uint8_t control_packet_header_flag(const uint8_t buffer[]) F_attribute_visibility_internal_d;
+#endif // _di_control_packet_header_flag_
+
+/**
+ * Given the header buffer, get the length bits.
+ *
+ * The endianness is automatically detected and swapped by this function to guarantee host order bytes.
+ *
+ * @param is_big
+ *   If TRUE, then the length in the buffer is in big endian format.
+ *   If FALSE, then the length in the buffer is in little endian format.
+ * @param buffer
+ *   The buffer to read the length of and get the
+ *
+ * @return
+ *   The 32-bit number representing the length.
+ */
+#ifndef _di_control_packet_header_length_
+  extern uint32_t control_packet_header_length(const bool is_big, const f_char_t buffer[]) F_attribute_visibility_internal_d;
+#endif // _di_control_packet_header_length_
+
+/**
  * Receive the response from the remote socket, storing it in the large cache.
  *
  * @todo consider returning F_header (with error bit) fo most header processing errors rather than individual status codes.
@@ -86,7 +117,7 @@ extern "C" {
  * @see fll_status_string_from()
  */
 #ifndef _di_control_packet_receive_
-  extern f_status_t control_packet_receive(fll_program_data_t * const main, control_data_t * const data, control_payload_header_t * const header) F_attribute_visibility_internal_d;
+  extern f_status_t control_packet_receive(const fll_program_data_t * const main, control_data_t * const data, control_payload_header_t * const header) F_attribute_visibility_internal_d;
 #endif // _di_control_packet_receive_
 
 /**
@@ -108,7 +139,7 @@ extern "C" {
  *   Any error (with error bit) on failure where the error is defined by the controller service.
  */
 #ifndef _di_control_packet_process_
-  extern f_status_t control_packet_process(fll_program_data_t * const main, control_data_t * const data, control_payload_header_t * const header) F_attribute_visibility_internal_d;
+  extern f_status_t control_packet_process(const fll_program_data_t * const main, control_data_t * const data, control_payload_header_t * const header) F_attribute_visibility_internal_d;
 #endif // _di_control_packet_process_
 
 /**
@@ -120,13 +151,11 @@ extern "C" {
  *   The control data.
  */
 #ifndef _di_control_packet_send_
-  extern f_status_t control_packet_send(fll_program_data_t * const main, control_data_t * const data) F_attribute_visibility_internal_d;
+  extern f_status_t control_packet_send(const fll_program_data_t * const main, control_data_t * const data) F_attribute_visibility_internal_d;
 #endif // _di_control_packet_send_
 
 /**
- * Construct the header portion of the payload.
- *
- * This also prepends the FSS identifier comment.
+ * Construct the entire payload.
  *
  * This resets and uses data->cache.small, data->cache.large, and data->cache.packet.
  * Do not use any of these for passing strings to this function.
@@ -140,12 +169,14 @@ extern "C" {
  * @param type
  *   The packet type.
  *   Set type.used to 0 to not add to the header.
+ * @param action
+ *   The action code.
+ *   Set action.used to 0 to not add to the header.
  * @param status
  *   The status code.
  *   Set status.used to 0 to not add to the header.
- * @param length
- *   The length of the payload Content.
- *   This is always added to the header.
+ * @param payload
+ *   The payload Content.
  *
  * @return
  *   F_none on success.
@@ -160,9 +191,9 @@ extern "C" {
  * @see fll_fss_extended_write_string()
  * @see fll_fss_payload_write_string()
  */
-#ifndef _di_control_packet_send_build_header_
-  extern f_status_t control_packet_send_build_header(fll_program_data_t * const main, control_data_t * const data, const f_string_static_t type, const f_string_static_t status, const f_array_length_t length) F_attribute_visibility_internal_d;
-#endif // _di_control_packet_send_build_header_
+#ifndef _di_control_packet_send_build_
+  extern f_status_t control_packet_send_build(const fll_program_data_t * const main, control_data_t * const data, const f_string_static_t type, const f_string_static_t action, const f_string_static_t status, const f_string_static_t payload) F_attribute_visibility_internal_d;
+#endif // _di_control_packet_send_build_
 /**
  * Load and process the control settings file.
  *
@@ -206,7 +237,7 @@ extern "C" {
  * @see fll_fss_extended_read()
  */
 #ifndef _di_control_settings_load_
-  extern f_status_t control_settings_load(fll_program_data_t * const main, control_data_t * const data) F_attribute_visibility_internal_d;
+  extern f_status_t control_settings_load(const fll_program_data_t * const main, control_data_t * const data) F_attribute_visibility_internal_d;
 #endif // _di_control_settings_load_
 
 #ifdef __cplusplus
index 476aa032f62ca4ee6e83cebba32f78882fb4172c..5b031dcf3d14f8af327ecc68cb79404f03f42f40 100644 (file)
@@ -8,7 +8,7 @@ extern "C" {
 #endif
 
 #ifndef _di_control_print_controller_packet_response_
-  void control_print_controller_packet_response(fll_program_data_t * const main, control_data_t * const data, const control_payload_header_t header, const f_string_static_t string_status) {
+  void control_print_controller_packet_response(const fll_program_data_t * const main, control_data_t * const data, const control_payload_header_t header, const f_string_static_t string_status) {
 
     if (header.status == F_failure) {
       if (main->error.verbosity == f_console_verbosity_quiet_e) return;
@@ -74,7 +74,7 @@ extern "C" {
 #endif // _di_control_print_controller_packet_response_
 
 #ifndef _di_control_print_debug_packet_header_object_and_content_
-  void control_print_debug_packet_header_object_and_content(fll_program_data_t * const main, const f_string_static_t object, const f_string_static_t content, const f_string_range_t content_range) {
+  void control_print_debug_packet_header_object_and_content(const fll_program_data_t * const main, const f_string_static_t object, const f_string_static_t content, const f_string_range_t content_range) {
 
     if (main->output.verbosity == f_console_verbosity_debug_e) return;
 
@@ -88,7 +88,7 @@ extern "C" {
 #endif // _di_control_print_debug_packet_header_object_and_content_
 
 #ifndef _di_control_print_debug_packet_message_
-  void control_print_debug_packet_message(fll_program_data_t * const main, const f_string_t message, const f_string_static_t *buffer, const f_string_range_t *range, const f_status_t *status) {
+  void control_print_debug_packet_message(const fll_program_data_t * const main, const f_string_t message, const f_string_static_t *buffer, const f_string_range_t *range, const f_status_t *status) {
 
     if (main->output.verbosity == f_console_verbosity_debug_e) return;
 
@@ -116,7 +116,7 @@ extern "C" {
 #endif // _di_control_print_debug_packet_message_
 
 #ifndef _di_control_print_error_packet_response_
-  void control_print_error_packet_response(fll_program_data_t * const main, control_data_t * const data, const control_payload_header_t header, const f_string_static_t string_status) {
+  void control_print_error_packet_response(const fll_program_data_t * const main, control_data_t * const data, const control_payload_header_t header, const f_string_static_t string_status) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -141,7 +141,7 @@ extern "C" {
 #endif // _di_control_print_error_packet_response_
 
 #ifndef _di_control_print_error_parameter_actions_none_
-  void control_print_error_parameter_actions_none(fll_program_data_t * const main) {
+  void control_print_error_parameter_actions_none(const fll_program_data_t * const main) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -150,7 +150,7 @@ extern "C" {
 #endif // _di_control_print_error_parameter_actions_none_
 
 #ifndef _di_control_print_error_parameter_action_not_
-  void control_print_error_parameter_action_not(fll_program_data_t * const main, const f_string_static_t action) {
+  void control_print_error_parameter_action_not(const fll_program_data_t * const main, const f_string_static_t action) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -165,7 +165,7 @@ extern "C" {
 #endif // _di_control_print_error_parameter_action_not_
 
 #ifndef _di_control_print_error_parameter_action_rule_basename_empty_
-  void control_print_error_parameter_action_rule_basename_empty(fll_program_data_t * const main, const f_string_static_t action) {
+  void control_print_error_parameter_action_rule_basename_empty(const fll_program_data_t * const main, const f_string_static_t action) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -180,7 +180,7 @@ extern "C" {
 #endif // _di_control_print_error_parameter_action_rule_basename_empty_
 
 #ifndef _di_control_print_error_parameter_action_rule_directory_empty_
-  void control_print_error_parameter_action_rule_directory_empty(fll_program_data_t * const main, const f_string_static_t action) {
+  void control_print_error_parameter_action_rule_directory_empty(const fll_program_data_t * const main, const f_string_static_t action) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -195,7 +195,7 @@ extern "C" {
 #endif // _di_control_print_error_parameter_action_rule_directory_empty_
 
 #ifndef _di_control_print_error_parameter_action_rule_empty_
-  void control_print_error_parameter_action_rule_empty(fll_program_data_t * const main, const f_string_static_t action) {
+  void control_print_error_parameter_action_rule_empty(const fll_program_data_t * const main, const f_string_static_t action) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -210,7 +210,7 @@ extern "C" {
 #endif // _di_control_print_error_parameter_action_rule_empty_
 
 #ifndef _di_control_print_error_parameter_action_rule_not_
-  void control_print_error_parameter_action_rule_not(fll_program_data_t * const main, const f_string_static_t action) {
+  void control_print_error_parameter_action_rule_not(const fll_program_data_t * const main, const f_string_static_t action) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -225,7 +225,7 @@ extern "C" {
 #endif // _di_control_print_error_parameter_action_rule_not_
 
 #ifndef _di_control_print_error_parameter_action_rule_too_many_
-  void control_print_error_parameter_action_rule_too_many(fll_program_data_t * const main, const f_string_static_t action) {
+  void control_print_error_parameter_action_rule_too_many(const fll_program_data_t * const main, const f_string_static_t action) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -240,7 +240,7 @@ extern "C" {
 #endif // _di_control_print_error_parameter_action_rule_too_many_
 
 #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) {
+  void control_print_error_parameter_value_empty(const fll_program_data_t * const main, const f_string_static_t parameter) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -255,7 +255,7 @@ extern "C" {
 #endif // _di_control_print_error_parameter_value_empty_
 
 #ifndef _di_control_print_error_parameter_value_not_
-  void control_print_error_parameter_value_not(fll_program_data_t * const main, const f_string_static_t parameter) {
+  void control_print_error_parameter_value_not(const fll_program_data_t * const main, const f_string_static_t parameter) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -270,7 +270,7 @@ extern "C" {
 #endif // _di_control_print_error_parameter_value_not_
 
 #ifndef _di_control_print_error_pipe_supported_not_
-  void control_print_error_pipe_supported_not(fll_program_data_t * const main) {
+  void control_print_error_pipe_supported_not(const fll_program_data_t * const main) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -279,7 +279,7 @@ 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) {
+  void control_print_error_response_packet_valid_not(const fll_program_data_t * const main) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -288,7 +288,7 @@ extern "C" {
 #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) {
+  void control_print_error_request_packet_too_large(const fll_program_data_t * const main) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -297,7 +297,7 @@ extern "C" {
 #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) {
+  void control_print_error_socket_file_failed(const fll_program_data_t * const main, const f_string_static_t path_socket) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -312,7 +312,7 @@ extern "C" {
 #endif // _di_control_print_error_socket_file_failed_
 
 #ifndef _di_control_print_error_socket_file_missing_
-  void control_print_error_socket_file_missing(fll_program_data_t * const main, const f_string_static_t path_socket) {
+  void control_print_error_socket_file_missing(const fll_program_data_t * const main, const f_string_static_t path_socket) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -327,7 +327,7 @@ extern "C" {
 #endif // _di_control_print_error_socket_file_missing_
 
 #ifndef _di_control_print_error_socket_file_not_
-  void control_print_error_socket_file_not(fll_program_data_t * const main, const f_string_static_t path_socket) {
+  void control_print_error_socket_file_not(const fll_program_data_t * const main, const f_string_static_t path_socket) {
 
     if (main->error.verbosity == f_console_verbosity_quiet_e) return;
 
@@ -342,7 +342,7 @@ extern "C" {
 #endif // _di_control_print_error_socket_file_not_
 
 #ifndef _di_control_print_signal_received_
-  void control_print_signal_received(fll_program_data_t * const main, const f_status_t signal) {
+  void control_print_signal_received(const fll_program_data_t * const main, const f_status_t signal) {
 
     if (main->warning.verbosity != f_console_verbosity_verbose_e) return;
 
@@ -360,7 +360,7 @@ extern "C" {
 #endif // _di_control_print_signal_received_
 
 #ifndef _di_control_print_warning_packet_header_duplicate_object_
-  void control_print_warning_packet_header_duplicate_object(fll_program_data_t * const main, const f_string_static_t response_header) {
+  void control_print_warning_packet_header_duplicate_object(const fll_program_data_t * const main, const f_string_static_t response_header) {
 
     if (main->warning.verbosity == f_console_verbosity_debug_e) return;
 
@@ -375,7 +375,7 @@ extern "C" {
 #endif // _di_control_print_warning_packet_header_duplicate_object_
 
 #ifndef _di_control_print_warning_packet_process_string_to_failed_
-  void control_print_warning_packet_process_string_to_failed(fll_program_data_t * const main, const f_status_t status_of, const f_status_t status_error) {
+  void control_print_warning_packet_process_string_to_failed(const fll_program_data_t * const main, const f_status_t status_of, const f_status_t status_error) {
 
     if (main->warning.verbosity == f_console_verbosity_debug_e) return;
 
index d0edb56201e287cbefe11713ebc13212368ce7f8..23f3d2ede38c3d6a5d615318403e8141de0feabd 100644 (file)
@@ -25,7 +25,7 @@ extern "C" {
  *   A string representing the name of the status code from header.status.
  */
 #ifndef _di_control_print_controller_packet_response_
-  extern void control_print_controller_packet_response(fll_program_data_t * const main, control_data_t * const data, const control_payload_header_t header, const f_string_static_t string_status) F_attribute_visibility_internal_d;
+  extern void control_print_controller_packet_response(const fll_program_data_t * const main, control_data_t * const data, const control_payload_header_t header, const f_string_static_t string_status) F_attribute_visibility_internal_d;
 #endif // _di_control_print_controller_packet_response_
 
 /**
@@ -41,7 +41,7 @@ extern "C" {
  *   The range representing the content where the content is found within the content string.
  */
 #ifndef _di_control_print_debug_packet_header_object_and_content_
-  extern void control_print_debug_packet_header_object_and_content(fll_program_data_t * const main, const f_string_static_t object, const f_string_static_t content, const f_string_range_t content_range) F_attribute_visibility_internal_d;
+  extern void control_print_debug_packet_header_object_and_content(const fll_program_data_t * const main, const f_string_static_t object, const f_string_static_t content, const f_string_range_t content_range) F_attribute_visibility_internal_d;
 #endif // _di_control_print_debug_packet_header_object_and_content_
 
 /**
@@ -65,7 +65,7 @@ extern "C" {
  *   Set to NULL to not use.
  */
 #ifndef _di_control_print_debug_packet_message_
-  extern void control_print_debug_packet_message(fll_program_data_t * const main, const f_string_t message, const f_string_static_t *buffer, const f_string_range_t *range, const f_status_t *status) F_attribute_visibility_internal_d;
+  extern void control_print_debug_packet_message(const fll_program_data_t * const main, const f_string_t message, const f_string_static_t *buffer, const f_string_range_t *range, const f_status_t *status) F_attribute_visibility_internal_d;
 #endif // _di_control_print_debug_packet_message_
 
 /**
@@ -81,7 +81,7 @@ extern "C" {
  *   A string representing the name of the status code from header.status.
  */
 #ifndef _di_control_print_error_packet_response_
-  extern void control_print_error_packet_response(fll_program_data_t * const main, control_data_t * const data, const control_payload_header_t header, const f_string_static_t status) F_attribute_visibility_internal_d;
+  extern void control_print_error_packet_response(const fll_program_data_t * const main, control_data_t * const data, const control_payload_header_t header, const f_string_static_t status) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_packet_response_
 /**
  * Print an error message about no actions being provided.
@@ -90,7 +90,7 @@ extern "C" {
  *   The main program data.
  */
 #ifndef _di_control_print_error_parameter_actions_none_
-  extern void control_print_error_parameter_actions_none(fll_program_data_t * const main) F_attribute_visibility_internal_d;
+  extern void control_print_error_parameter_actions_none(const fll_program_data_t * const main) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_parameter_actions_none_
 
 /**
@@ -102,7 +102,7 @@ extern "C" {
  *   The parameter representing a action.
  */
 #ifndef _di_control_print_error_parameter_action_not_
-  extern void control_print_error_parameter_action_not(fll_program_data_t * const main, const f_string_static_t action) F_attribute_visibility_internal_d;
+  extern void control_print_error_parameter_action_not(const fll_program_data_t * const main, const f_string_static_t action) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_parameter_action_not_
 
 /**
@@ -114,7 +114,7 @@ extern "C" {
  *   The parameter representing a action.
  */
 #ifndef _di_control_print_error_parameter_action_rule_basename_empty_
-  extern void control_print_error_parameter_action_rule_basename_empty(fll_program_data_t * const main, const f_string_static_t action) F_attribute_visibility_internal_d;
+  extern void control_print_error_parameter_action_rule_basename_empty(const fll_program_data_t * const main, const f_string_static_t action) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_parameter_action_rule_basename_empty_
 
 /**
@@ -126,7 +126,7 @@ extern "C" {
  *   The parameter representing a action.
  */
 #ifndef _di_control_print_error_parameter_action_rule_directory_empty_
-  extern void control_print_error_parameter_action_rule_directory_empty(fll_program_data_t * const main, const f_string_static_t action) F_attribute_visibility_internal_d;
+  extern void control_print_error_parameter_action_rule_directory_empty(const fll_program_data_t * const main, const f_string_static_t action) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_parameter_action_rule_directory_empty_
 
 /**
@@ -138,7 +138,7 @@ extern "C" {
  *   The parameter representing a action.
  */
 #ifndef _di_control_print_error_parameter_action_rule_empty_
-  extern void control_print_error_parameter_action_rule_empty(fll_program_data_t * const main, const f_string_static_t action) F_attribute_visibility_internal_d;
+  extern void control_print_error_parameter_action_rule_empty(const fll_program_data_t * const main, const f_string_static_t action) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_parameter_action_rule_empty_
 
 /**
@@ -150,7 +150,7 @@ extern "C" {
  *   The parameter representing a action.
  */
 #ifndef _di_control_print_error_parameter_action_rule_not_
-  extern void control_print_error_parameter_action_rule_not(fll_program_data_t * const main, const f_string_static_t action) F_attribute_visibility_internal_d;
+  extern void control_print_error_parameter_action_rule_not(const fll_program_data_t * const main, const f_string_static_t action) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_parameter_action_rule_not_
 
 /**
@@ -162,7 +162,7 @@ extern "C" {
  *   The parameter representing a action.
  */
 #ifndef _di_control_print_error_parameter_action_rule_too_many_
-  extern void control_print_error_parameter_action_rule_too_many(fll_program_data_t * const main, const f_string_static_t action) F_attribute_visibility_internal_d;
+  extern void control_print_error_parameter_action_rule_too_many(const fll_program_data_t * const main, const f_string_static_t action) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_parameter_action_rule_too_many_
 
 /**
@@ -174,7 +174,7 @@ extern "C" {
  *   The parameter name.
  */
 #ifndef _di_control_print_error_parameter_value_empty_
-  extern void control_print_error_parameter_value_empty(fll_program_data_t * const main, const f_string_static_t parameter) F_attribute_visibility_internal_d;
+  extern void control_print_error_parameter_value_empty(const fll_program_data_t * const main, const f_string_static_t parameter) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_parameter_value_empty_
 
 /**
@@ -186,7 +186,7 @@ extern "C" {
  *   The parameter name.
  */
 #ifndef _di_control_print_error_parameter_value_not_
-  extern void control_print_error_parameter_value_not(fll_program_data_t * const main, const f_string_static_t parameter) F_attribute_visibility_internal_d;
+  extern void control_print_error_parameter_value_not(const fll_program_data_t * const main, const f_string_static_t parameter) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_parameter_value_not_
 
 /**
@@ -196,7 +196,7 @@ extern "C" {
  *   The main program data.
  */
 #ifndef _di_control_print_error_pipe_supported_not_
-  extern void control_print_error_pipe_supported_not(fll_program_data_t * const main) F_attribute_visibility_internal_d;
+  extern void control_print_error_pipe_supported_not(const fll_program_data_t * const main) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_pipe_supported_not_
 
 /**
@@ -206,7 +206,7 @@ extern "C" {
  *   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;
+  extern void control_print_error_response_packet_valid_not(const fll_program_data_t * const main) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_response_packet_valid_not_
 
 /**
@@ -216,7 +216,7 @@ extern "C" {
  *   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;
+  void extern control_print_error_request_packet_too_large(const fll_program_data_t * const main) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_request_packet_too_large_
 
 /**
@@ -228,7 +228,7 @@ extern "C" {
  *   The socket file path.
  */
 #ifndef _di_control_print_error_socket_file_failed_
-  extern void control_print_error_socket_file_failed(fll_program_data_t * const main, const f_string_static_t path_socket) F_attribute_visibility_internal_d;
+  extern void control_print_error_socket_file_failed(const fll_program_data_t * const main, const f_string_static_t path_socket) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_socket_file_failed_
 
 /**
@@ -240,7 +240,7 @@ extern "C" {
  *   The socket file path.
  */
 #ifndef _di_control_print_error_socket_file_missing_
-  extern void control_print_error_socket_file_missing(fll_program_data_t * const main, const f_string_static_t path_socket) F_attribute_visibility_internal_d;
+  extern void control_print_error_socket_file_missing(const fll_program_data_t * const main, const f_string_static_t path_socket) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_socket_file_missing_
 
 /**
@@ -252,7 +252,7 @@ extern "C" {
  *   The socket file path.
  */
 #ifndef _di_control_print_error_socket_file_not_
-  extern void control_print_error_socket_file_not(fll_program_data_t * const main, const f_string_static_t path_socket) F_attribute_visibility_internal_d;
+  extern void control_print_error_socket_file_not(const fll_program_data_t * const main, const f_string_static_t path_socket) F_attribute_visibility_internal_d;
 #endif // _di_control_print_error_socket_file_not_
 
 /**
@@ -264,7 +264,7 @@ extern "C" {
  *   The signal received.
  */
 #ifndef _di_control_print_signal_received_
-  extern void control_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d;
+  extern void control_print_signal_received(const fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d;
 #endif // _di_control_print_signal_received_
 
 /**
@@ -278,7 +278,7 @@ extern "C" {
  *   The repeated response header.
  */
 #ifndef _di_control_print_warning_packet_header_duplicate_object_
-  extern void control_print_warning_packet_header_duplicate_object(fll_program_data_t * const main, const f_string_static_t response_header) F_attribute_visibility_internal_d;
+  extern void control_print_warning_packet_header_duplicate_object(const fll_program_data_t * const main, const f_string_static_t response_header) F_attribute_visibility_internal_d;
 #endif // _di_control_print_warning_packet_header_duplicate_object_
 
 /**
@@ -294,7 +294,7 @@ extern "C" {
  * @see f_status_string_to()
  */
 #ifndef _di_control_print_warning_packet_process_string_to_failed_
-  extern void control_print_warning_packet_process_string_to_failed(fll_program_data_t * const main, const f_status_t status_of, const f_status_t status_error) F_attribute_visibility_internal_d;
+  extern void control_print_warning_packet_process_string_to_failed(const fll_program_data_t * const main, const f_status_t status_of, const f_status_t status_error) F_attribute_visibility_internal_d;
 #endif // _di_control_print_warning_packet_process_string_to_failed_
 
 #ifdef __cplusplus
index e8eff60e9bde87d40b354be078ffb686ec1b0645..a011d3281aa5efc3d221748cefb1a03e076577cf 100644 (file)
@@ -209,24 +209,17 @@ extern "C" {
 #ifndef _di_controller_control_packet_header_length_
   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));
-
     #ifdef _is_F_endian_big
       if (is_big) {
-        return length;
+        return (buffer[1] << 24u) | (buffer[2] << 16u) | (buffer[3] << 8u) | buffer[4];
       }
     #else
       if (!is_big) {
-        return length;
+        return (buffer[1] << 24u) | (buffer[2] << 16u) | (buffer[3] << 8u) | buffer[4];
       }
     #endif // _is_F_endian_big
 
-    length = (length & 0x55555555 << 1) | (length & 0x55555555 >> 1);
-    length = (length & 0x33333333 << 2) | (length & 0xcccccccc >> 2);
-    length = (length & 0x0f0f0f0f << 4) | (length & 0xf0f0f0f0 >> 4);
-    length = (length & 0x00ff00ff << 8) | (length & 0xff00ff00 >> 8);
-
-    return (length & 0x0000ffff << 16) | (length & 0xffff0000 >> 16);
+    return (buffer[4] << 24u) | (buffer[3] << 16u) | (buffer[2] << 8u) | buffer[1];
   }
 #endif // _di_controller_control_packet_header_length_
 
@@ -242,7 +235,6 @@ extern "C" {
     f_string_static_t contents[1];
     content.array = contents;
     content.used = 1;
-    content.size = 1;
 
     control->cache_1.used = 0;
     control->cache_2.used = 0;
@@ -274,10 +266,6 @@ extern "C" {
     status2 = fll_fss_extended_write_string(controller_length_s, content, 0, state, &control->cache_1);
     if (F_status_is_error(status2)) return status2;
 
-    // Prepend the identifier comment to the output.
-    status2 = f_string_dynamic_append(controller_payload_type_s, &control->output);
-    if (F_status_is_error(status2)) return status2;
-
     // Append entire header block to the output.
     status2 = fll_fss_payload_write_string(f_fss_string_header_s, control->cache_1, F_false, 0, state, &control->output);
     if (F_status_is_error(status2)) return status2;
@@ -299,7 +287,7 @@ extern "C" {
 
       status2 = f_conversion_number_unsigned_to_string(F_status_set_fine(status), data_conversion, &control->cache_3);
       if (F_status_is_error(status2)) return status2;
-    };
+    }
 
     status2 = controller_control_respond_build_header(global, control, controller_error_s, control->cache_3, message.used);
     if (F_status_is_error(status2)) return status2;
index f4854718b3120594fd8495d6f37f6b4934994d03..dacc1faa84446ef00ccf4864fb8ee8a0cc61e92a 100644 (file)
@@ -106,8 +106,6 @@ extern "C" {
 /**
  * Construct the header portion of the payload.
  *
- * This also prepends the FSS identifier comment.
- *
  * This resets and uses control.cache_1 and control.cache_2.
  * Do not use either of these for passing strings to this function.
  *