This also removes accidentally committed debug code (accidentally committed in a previous, unrelated, commit).
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);
}
}
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);
}
}
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);
}
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()) {
#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);
#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.
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;
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);
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;
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_
#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;
}
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_
* 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;
* 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;
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) {
}
#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) {
}
#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) {
#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
#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
#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
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);
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);
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);
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);
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);
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);
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.");
}
// @todo process the data.
- fll_print_format("\nDEBUG: received packet: '%q'\n", stdout, control->input);
// @todo send any responses.
#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));
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);
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_
#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);
}
* 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_
/**
* 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_
/**
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;
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;
#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;
#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;
* @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_
/**
* @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_
/**
}
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;
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);
}
// 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;
#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;
#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;
* @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_
/**
* @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_
/**
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()) {
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);
}
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;
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) {
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) {
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);
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) {
} // 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;
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 {
#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;
* @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_
/**
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) {
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);
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.
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_