#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);
* @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_
/**
#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;
* @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_
/**
#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:
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;
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);
}
}
#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;
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);
}
#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;
#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;
}
#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;
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;
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;
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;
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);
}
}
}
* 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_
/**
* @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.
* @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_
/**
* 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_
/**
* 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.
* @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.
* @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.
*
* @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
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
#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;
* 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_
/**
* 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_
/**
* 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_
/**
* 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.
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* 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_
/**
* @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
#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_
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;
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;
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;
/**
* 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.
*