From 12ac4ad1b52f48bce0aa500cf98d09731de529c0 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 6 Jun 2024 23:34:24 -0500 Subject: [PATCH] Progress: Continue migrating the project. --- sources/c/main/common.c | 16 +- sources/c/main/common/enumeration.h | 14 +- sources/c/main/entry.c | 20 +- sources/c/main/entry/preprocess.c | 49 +-- sources/c/main/entry/process.c | 239 +++------------ sources/c/main/entry/setting.c | 34 +-- sources/c/main/entry/setting.h | 4 +- sources/c/main/perform.c | 4 +- sources/c/main/print/entry.c | 454 +++++++++++++++++++++++++--- sources/c/main/print/entry.h | 566 ++++++++++++++++++++++++++++++++--- sources/c/main/print/entry/setting.c | 12 +- sources/c/main/print/perform.c | 4 +- sources/c/main/print/rule/setting.c | 6 +- sources/c/main/rule/instance.c | 2 +- sources/c/main/rule/setting.c | 10 +- sources/c/main/thread/cleanup.c | 2 +- sources/c/main/thread/entry.c | 8 +- 17 files changed, 1061 insertions(+), 383 deletions(-) diff --git a/sources/c/main/common.c b/sources/c/main/common.c index c41c5ec..a0e44c8 100644 --- a/sources/c/main/common.c +++ b/sources/c/main/common.c @@ -129,21 +129,21 @@ extern "C" { { const uint8_t codes[] = { controller_parameter_cgroup_e, - controller_parameter_daemon_e, controller_parameter_pid_e, controller_parameter_settings_e, + controller_parameter_socket_e, }; const f_string_static_t strings[] = { controller_long_cgroup_s, - controller_long_daemon_s, controller_long_pid_s, controller_long_settings_s, + controller_long_socket_s, }; for (index = 0; index < 4; ++index) { - if (main->program.parameters.array[controller_parameter_settings_e].result & codes[index]) { + if (main->program.parameters.array[codes[index]].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, strings[index]); @@ -193,7 +193,11 @@ extern "C" { } } - if (!main->process.path_pid.used && !main->program.parameters.array[controller_parameter_pid_e].locations.used) { + if (main->program.parameters.array[controller_parameter_pid_e].result & f_console_result_value_e) { + main->setting.flag |= controller_main_flag_pid_e; + } + + if (!main->process.path_pid.used && !(main->setting.flag & controller_main_flag_pid_e)) { main->setting.state.status = f_string_dynamic_append(controller_default_path_pid_s, &main->process.path_pid); if (F_status_is_error_not(main->setting.state.status)) { @@ -286,6 +290,10 @@ extern "C" { main->setting.flag |= controller_main_flag_daemon_e; } + if (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) { + main->setting.flag |= controller_main_flag_simulate_e; + } + if (main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e) { main->setting.flag |= controller_main_flag_validate_e; } diff --git a/sources/c/main/common/enumeration.h b/sources/c/main/common/enumeration.h index 283b565..b2e1eb5 100644 --- a/sources/c/main/common/enumeration.h +++ b/sources/c/main/common/enumeration.h @@ -29,7 +29,9 @@ extern "C" { * - fine: Check if status is "fine". * - help: Print help. * - interruptible: The process is interruptible. + * - pid: Designate that a custom PID is specified. * - pipe: Use the input pipe. + * - simulate: Perform simulation of rules rather than execution. * - validate: Perform validation of rules rather than execution. * - version: Print version. * - version_copyright_help: A helper flag representing version, copyright, and help flag bits being set. @@ -44,11 +46,13 @@ extern "C" { controller_main_flag_fine_e = 0x8, controller_main_flag_help_e = 0x10, controller_main_flag_interruptible_e = 0x20, - controller_main_flag_pipe_e = 0x40, - controller_main_flag_validate_e = 0x80, - controller_main_flag_version_e = 0x100, - controller_main_flag_version_copyright_help_e = 0x111, - controller_main_flag_warning_e = 0x200, + controller_main_flag_pid_e = 0x40, + controller_main_flag_pipe_e = 0x80, + controller_main_flag_simulate_e = 0x100, + controller_main_flag_validate_e = 0x200, + controller_main_flag_version_e = 0x400, + controller_main_flag_version_copyright_help_e = 0x411, + controller_main_flag_warning_e = 0x800, }; // enum #endif // _di_controller_main_flag_e_ diff --git a/sources/c/main/entry.c b/sources/c/main/entry.c index ea4d9a2..c37e4f6 100644 --- a/sources/c/main/entry.c +++ b/sources/c/main/entry.c @@ -74,8 +74,7 @@ extern "C" { f_fss_apply_delimit(cache->delimits, &cache->buffer_file, &state); if (F_status_is_error(status)) { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), "f_fss_apply_delimit", F_true, &main->thread); - controller_print_error_status(&main->program.error, macro_controller_f(fll_fss_basic_list_read), F_status_set_fine(status)); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_fss_apply_delimit), F_true); } } } @@ -96,8 +95,7 @@ extern "C" { status = f_memory_array_increase_by(cache->object_items.used, &entry->items.array, &entry->items.used, &entry->items.size); if (F_status_is_error(status)) { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), "f_memory_array_increase_by", F_true, &main->thread); - controller_print_error_status(&main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status)); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_memory_array_increase_by), F_true); } else { @@ -140,7 +138,7 @@ extern "C" { status = controller_entry_items_increase_by(controller_common_allocation_small_d, &entry->items); if (F_status_is_error(status)) { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), "controller_entry_items_increase_by", F_true, &main->thread); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_entry_items_increase_by), F_true); break; } @@ -148,7 +146,7 @@ extern "C" { status = f_string_dynamic_partial_append(cache->buffer_file, cache->object_items.array[i], &cache->action.name_item); if (F_status_is_error(status)) { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append", F_true, &main->thread); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_string_dynamic_partial_append), F_true); break; } @@ -156,7 +154,7 @@ extern "C" { f_fss_count_lines(cache->buffer_file, cache->object_items.array[i].start, &cache->action.line_item, &main->setting.state); if (F_status_is_error(status)) { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), "f_fss_count_lines", F_true, &main->thread); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_fss_count_lines), F_true); break; } @@ -173,7 +171,7 @@ extern "C" { fl_print_format(f_string_format_Q_single_s.string, main->program.warning.to, main->program.warning.notable, cache->action.name_file, main->program.warning.notable); fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.warning.to, main->program.warning.context, main->program.warning.context, f_string_eol_s); - controller_entry_print_error_cache(is_entry, &main->program.warning, cache->action); + controller_print_entry_error_cache(is_entry, &main->program.warning, &cache->action); controller_unlock_print_flush(main->program.warning.to, &main->thread); } @@ -230,7 +228,7 @@ extern "C" { if (F_status_set_fine(status) != F_interrupt) { controller_lock_print(main->program.error.to, &main->thread); - controller_entry_print_error_cache(is_entry, &main->program.error, cache->action); + controller_print_entry_error_cache(is_entry, &main->program.error, &cache->action); controller_unlock_print_flush(main->program.error.to, &main->thread); } @@ -313,7 +311,7 @@ extern "C" { fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, action->parameters.array[0], main->program.error.notable); fl_print_format("%[' does not exist.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); - controller_entry_print_error_cache(is_entry, &main->program.error, cache->action); + controller_print_entry_error_cache(is_entry, &main->program.error, &cache->action); controller_unlock_print_flush(main->program.error.to, &main->thread); } @@ -337,7 +335,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) != F_interrupt) { - controller_entry_print_error_cache(is_entry, &main->program.error, cache->action); + controller_print_entry_error_cache(is_entry, &main->program.error, &cache->action); } entry->status = controller_status_simplify_error(F_status_set_fine(status)); diff --git a/sources/c/main/entry/preprocess.c b/sources/c/main/entry/preprocess.c index dc6e3ea..cecea12 100644 --- a/sources/c/main/entry/preprocess.c +++ b/sources/c/main/entry/preprocess.c @@ -35,7 +35,7 @@ extern "C" { status = f_memory_array_increase(controller_common_allocation_small_d, sizeof(f_number_unsigned_t), (void **) &cache->ats.array, &cache->ats.used, &cache->ats.size); if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_memory_array_increase), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_memory_array_increase), F_true); return status; } @@ -51,7 +51,7 @@ extern "C" { status = f_string_dynamic_append_nulless(entry->items.array[0].name, &cache->action.name_item); if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_string_dynamic_append_nulless), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_string_dynamic_append_nulless), F_true); return status; } @@ -68,25 +68,14 @@ extern "C" { status2 = f_string_dynamic_append_nulless(controller_entry_action_type_name(actions->array[cache->ats.array[at_j]].type), &cache->action.name_action); if (F_status_is_error(status2)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status2), macro_controller_f(f_string_dynamic_append_nulless), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status2), macro_controller_f(f_string_dynamic_append_nulless), F_true); return status2; } if (actions->array[cache->ats.array[at_j]].type == controller_entry_action_type_ready_e) { - if (main->setting.ready == controller_setting_ready_wait_e) { - if (main->program.warning.verbosity == f_console_verbosity_debug_e) { - controller_lock_print(main->program.warning.to, &main->thread); - - fl_print_format("%r%[%QMultiple '%]", main->program.warning.to, f_string_eol_s, main->program.warning.context, main->program.warning.prefix, main->program.warning.context); - fl_print_format(f_string_format_r_single_s.string, main->program.warning.to, main->program.warning.notable, controller_ready_s, main->program.warning.notable); - fl_print_format("%[' %r item actions detected; only the first will be used.%]%r", main->program.warning.to, main->program.warning.context, is_entry ? controller_entry_s : controller_exit_s, main->program.warning.context, f_string_eol_s); - - controller_entry_print_error_cache(is_entry, &main->program.warning, cache->action); - - controller_unlock_print_flush(main->program.warning.to, &main->thread); - } + controller_print_entry_warning_item_action_multiple(&main->program.warning, &cache->action, is_entry, controller_ready_s); } else { main->setting.ready = controller_setting_ready_wait_e; @@ -112,17 +101,7 @@ extern "C" { for (j = 2; j < cache->ats.used; j += 2) { if (cache->ats.array[j] == i) { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QThe %r item named '%]", main->program.error.to, f_string_eol_s, main->program.error.context, is_entry ? controller_entry_s : controller_exit_s, main->program.error.prefix, main->program.error.context); - fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, entry->items.array[i].name, main->program.error.notable); - fl_print_format("%[' cannot be executed because recursion is not allowed.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); - - controller_entry_print_error_cache(is_entry, &main->program.error, cache->action); - - controller_unlock_print_flush(main->program.error.to, &main->thread); - } + controller_print_entry_error_item_failure(&main->program.error, &cache->action, entry->items.array[i].name, "cannot be executed because recursion is not allowed"); if (F_status_is_error_not(status)) { status = F_status_set_error(F_recurse); @@ -139,7 +118,7 @@ extern "C" { status2 = f_memory_array_increase(controller_common_allocation_small_d, sizeof(f_number_unsigned_t), (void **) &cache->ats.array, &cache->ats.used, &cache->ats.size); if (F_status_is_error(status2)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status2), macro_controller_f(f_memory_array_increase), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status2), macro_controller_f(f_memory_array_increase), F_true); return status2; } @@ -164,7 +143,7 @@ extern "C" { status2 = f_string_dynamic_append_nulless(entry->items.array[i].name, &cache->action.name_item); if (F_status_is_error(status2)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status2), macro_controller_f(f_string_dynamic_append_nulless), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status2), macro_controller_f(f_string_dynamic_append_nulless), F_true); return status2; } @@ -175,17 +154,7 @@ extern "C" { if (error_has || i >= entry->items.used) { if (i >= entry->items.used) { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QThe %r item named '%]", main->program.error.to, f_string_eol_s, main->program.error.context, is_entry ? controller_entry_s : controller_exit_s, main->program.error.prefix, main->program.error.context); - fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, actions->array[cache->ats.array[at_j]].parameters.array[0], main->program.error.notable); - fl_print_format("%[' does not exist.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); - - controller_entry_print_error_cache(is_entry, &main->program.error, cache->action); - - controller_unlock_print_flush(main->program.error.to, &main->thread); - } + controller_print_entry_error_item_failure(&main->program.error, &cache->action, actions->array[cache->ats.array[at_j]].parameters.array[0], "does not exist"); if (F_status_is_error_not(status)) { status = F_status_set_error(F_valid_not); @@ -219,7 +188,7 @@ extern "C" { status2 = f_string_dynamic_append_nulless(entry->items.array[cache->ats.array[at_i]].name, &cache->action.name_item); if (F_status_is_error(status2)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status2), macro_controller_f(f_string_dynamic_append_nulless), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status2), macro_controller_f(f_string_dynamic_append_nulless), F_true); return status2; } diff --git a/sources/c/main/entry/process.c b/sources/c/main/entry/process.c index 164a36f..77d248a 100644 --- a/sources/c/main/entry/process.c +++ b/sources/c/main/entry/process.c @@ -35,7 +35,7 @@ extern "C" { status = f_memory_array_increase(controller_common_allocation_small_d, sizeof(f_number_unsigned_t), (void **) &cache->ats.array, &cache->ats.used, &cache->ats.size); if (F_status_is_error(status)) { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), macro_controller_f(f_memory_array_increase), F_true, &main->thread); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_memory_array_increase), F_true); return status; } @@ -51,20 +51,13 @@ extern "C" { status = f_string_dynamic_append_nulless(entry->items.array[cache->ats.array[0]].name, &cache->action.name_item); if (F_status_is_error(status)) { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), macro_controller_f(f_string_dynamic_append_nulless), F_true, &main->thread); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_string_dynamic_append_nulless), F_true); return status; } - if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) || main->program.error.verbosity == f_console_verbosity_verbose_e || main->program.error.verbosity == f_console_verbosity_debug_e) { - if ((main->program.error.verbosity > f_console_verbosity_error_e)) { - controller_lock_print(main->program.output.to, &main->thread); - - fl_print_format("%rProcessing %r%r item '", main->program.output.to, f_string_eol_s, failsafe ? controller_entry_print_failsafe_s : f_string_empty_s, is_entry ? controller_entry_s : controller_exit_s); - fl_print_format("%[%Q%]'.%r", main->program.output.to, main->program.context.set.title, cache->action.name_item, main->program.context.set.notable, f_string_eol_s); - - controller_unlock_print_flush(main->program.output.to, &main->thread); - } + if ((main->setting.flag & controller_main_flag_simulate_e) || main->program.message.verbosity > f_console_verbosity_normal_e) { + controller_print_entry_message_item_process(&main->program.message, is_entry, failsafe ? controller_print_entry_failsafe_s : f_string_empty_s, cache->action.name_item); } // The pre-process determines if ready is explicitly specified within the entry file and if it is not start as ready. @@ -87,33 +80,14 @@ extern "C" { status = f_string_dynamic_append_nulless(controller_entry_action_type_name(entry_action->type), &cache->action.name_action); if (F_status_is_error(status)) { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), macro_controller_f(f_string_dynamic_append_nulless), F_true, &main->thread); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_string_dynamic_append_nulless), F_true); return status; } if (F_status_is_error(entry_action->status)) { - if (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - controller_lock_print(main->program.output.to, &main->thread); - - fl_print_format("%rThe %r item action '", main->program.output.to, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); - fl_print_format(f_string_format_Q_single_s.string, main->program.output.to, main->program.context.set.title, cache->action.name_action, main->program.context.set.title); - - if (entry_action->parameters.used) { - fl_print_format(" %[", main->program.output.to, main->program.context.set.notable); - - controller_entry_action_parameters_print(&main->program.output, *entry_action); - - fl_print_format("%]", main->program.output.to, main->program.context.set.notable); - } - - fl_print_format("' is %[%r%] and is in a ", main->program.output.to, main->program.context.set.notable, entry_action->code & controller_entry_rule_code_require_d ? "required" : "optional", main->program.context.set.notable); - - fl_print_format("%[failed%] state, skipping.%r", main->program.output.to, main->program.context.set.notable, main->program.context.set.notable, main->program.context.set.notable, f_string_eol_s); - - controller_unlock_print_flush(main->program.output.to, &main->thread); - } + if (main->setting.flag & controller_main_flag_simulate_e) { + controller_print_entry_message_action_state_failed(&main->program.message, entry_action, is_entry, cache->action.name_action); } else { if ((entry_action->code & controller_entry_rule_code_require_d) && main->program.error.verbosity > f_console_verbosity_quiet_e || !(entry_action->code & controller_entry_rule_code_require_d) && (main->program.warning.verbosity == f_console_verbosity_verbose_e || main->program.warning.verbosity == f_console_verbosity_debug_e)) { @@ -127,39 +101,7 @@ extern "C" { } if (print) { - controller_lock_print(print->to, &main->thread); - - fl_print_format("%r%[%QThe %r item action '%]", print->to, f_string_eol_s, print->context, print->prefix, is_entry ? controller_entry_s : controller_exit_s, print->context); - fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, cache->action.name_action, print->notable); - - - if (entry_action->parameters.used) { - fl_print_format(" %[", print->to, main->program.context.set.notable); - - controller_entry_action_parameters_print(print, *entry_action); - - fl_print_format("%]", print->to, main->program.context.set.notable); - } - - if (entry_action->code & controller_entry_rule_code_require_d) { - fl_print_format("%[' is%] %[required%]", print->to, print->context, print->context, print->notable, print->notable); - } - else { - fl_print_format("%[' is%] %[optional%]", print->to, print->context, print->context, print->notable, print->notable); - } - - fl_print_format(" %[and is in a%] %[failed%]", print->to, print->context, print->context, print->notable, print->notable); - - if (entry_action->code & controller_entry_rule_code_require_d) { - fl_print_format(" %[state, aborting.%]%r", print->to, print->context, print->context, f_string_eol_s); - } - else { - fl_print_format(" %[state, skipping.%]%r", print->to, print->context, print->context, f_string_eol_s); - } - - controller_entry_print_error_cache(is_entry, print, cache->action); - - controller_unlock_print_flush(print->to, &main->thread); + controller_print_entry_message_action_state(print, &cache->action, entry_action, is_entry, cache->action.name_action); } } @@ -173,42 +115,24 @@ extern "C" { if (entry_action->type == controller_entry_action_type_ready_e) { if ((entry_action->code & controller_entry_rule_code_wait_d) || main->setting.ready == controller_setting_ready_wait_e) { - if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) || main->program.error.verbosity == f_console_verbosity_verbose_e || main->program.error.verbosity == f_console_verbosity_debug_e || entry->show == controller_entry_show_init_e) { - if (main->program.output.verbosity != f_console_verbosity_quiet_e && main->program.error.verbosity != f_console_verbosity_error_e) { - controller_lock_print(main->program.output.to, &main->thread); - - fl_print_format("%rWaiting before processing %r item action '", main->program.output.to, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); - fl_print_format(f_string_format_r_single_s.string, main->program.output.to, main->program.context.set.title, controller_ready_s, main->program.context.set.title); - fl_print_format("'.%r", main->program.output.to, f_string_eol_s); - - controller_unlock_print_flush(main->program.output.to, &main->thread); - } + if ((main->setting.flag & controller_main_flag_simulate_e) || main->program.error.verbosity == f_console_verbosity_verbose_e || main->program.error.verbosity == f_console_verbosity_debug_e || entry->show == controller_entry_show_init_e) { + controller_print_entry_message_item_action_wait(&main->program.output, is_entry, controller_ready_s); } - if (!(main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) { + if (!(main->setting.flag & controller_main_flag_validate_e)) { status = controller_rule_wait_all(main, is_entry, F_false); if (F_status_is_error(status)) return status; } } if (main->setting.ready == controller_setting_ready_yes_e) { - if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) || main->program.error.verbosity == f_console_verbosity_verbose_e || main->program.error.verbosity == f_console_verbosity_debug_e) { - if (main->program.output.verbosity != f_console_verbosity_quiet_e && main->program.error.verbosity != f_console_verbosity_error_e) { - controller_lock_print(main->program.output.to, &main->thread); - - fl_print_format("%rIgnoring %r item action '", main->program.output.to, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); - fl_print_format(f_string_format_r_single_s.string, main->program.output.to, main->program.context.set.title, controller_ready_s, main->program.context.set.title); - fl_print_format("', state already is ready.%r", main->program.output.to, f_string_eol_s); - - controller_unlock_print_flush(main->program.output.to, &main->thread); - } + if ((main->setting.flag & controller_main_flag_simulate_e) || main->program.error.verbosity == f_console_verbosity_verbose_e || main->program.error.verbosity == f_console_verbosity_debug_e) { + controller_print_entry_message_item_action_ready(&main->program.output, is_entry, controller_ready_s); } } else { - if (!failsafe && (main->program.error.verbosity == f_console_verbosity_verbose_e || entry->show == controller_entry_show_init_e) && !(main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e)) { - if (main->program.error.verbosity > f_console_verbosity_error_e) { - fl_print_format("%rState is now '%[%r%]'.%r", main->program.output.to, f_string_eol_s, main->program.context.set.notable, controller_ready_s, main->program.context.set.notable, f_string_eol_s); - } + if (!failsafe && (main->program.error.verbosity == f_console_verbosity_verbose_e || entry->show == controller_entry_show_init_e) && !(main->setting.flag & controller_main_flag_simulate_e)) { + controller_print_entry_message_state(&main->program.output, is_entry, controller_ready_s); } status = controller_perform_ready(main, is_entry); @@ -219,17 +143,7 @@ extern "C" { if (entry_action->number == 0 || entry_action->number >= entry->items.used || failsafe && entry_action->number == main->setting.failsafe_item_id) { // This should not happen if the pre-process is working as intended, but in case it doesn't, return a critical error to prevent infinite recursion and similar errors. - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[Invalid %r item index '%]", main->program.error.to, f_string_eol_s, main->program.error.context, is_entry ? controller_entry_s : controller_exit_s, main->program.error.context); - fl_print_format("%[%un%]", main->program.error.to, main->program.error.notable, entry_action->number, main->program.error.notable); - fl_print_format("%[' detected.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); - - controller_entry_print_error_cache(is_entry, &main->program.error, cache->action); - - controller_unlock_print_flush(main->program.error.to, &main->thread); - } + controller_print_entry_error_item_invalid(&main->program.error, &cache->action, is_entry, entry_action->number); return F_status_is_error(F_critical); } @@ -237,7 +151,7 @@ extern "C" { status = f_memory_array_increase(controller_common_allocation_small_d, sizeof(f_number_unsigned_t), (void **) &cache->ats.array, &cache->ats.used, &cache->ats.size); if (F_status_is_error(status)) { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), macro_controller_f(f_memory_array_increase), F_true, &main->thread); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_memory_array_increase), F_true); return status; } @@ -260,21 +174,13 @@ extern "C" { status = f_string_dynamic_append_nulless(entry->items.array[cache->ats.array[at_i]].name, &cache->action.name_item); if (F_status_is_error(status)) { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), macro_controller_f(f_string_dynamic_append_nulless), F_true, &main->thread); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_string_dynamic_append_nulless), F_true); return status; } - if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) || main->program.error.verbosity == f_console_verbosity_verbose_e || main->program.error.verbosity == f_console_verbosity_debug_e) { - if (main->program.output.verbosity != f_console_verbosity_quiet_e && main->program.error.verbosity != f_console_verbosity_error_e) { - controller_lock_print(main->program.output.to, &main->thread); - - fl_print_format("%rProcessing %r item '", main->program.output.to, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); - fl_print_format(f_string_format_Q_single_s.string, main->program.output.to, main->program.context.set.title, cache->action.name_item, main->program.context.set.title); - fl_print_format("'.%r", main->program.output.to, f_string_eol_s); - - controller_unlock_print_flush(main->program.output.to, &main->thread); - } + if ((main->setting.flag & controller_main_flag_simulate_e) || main->program.message.verbosity > f_console_verbosity_normal_e) { + controller_print_entry_message_item_process(&main->program.message, is_entry, f_string_empty_s, cache->action.name_item); } // Exit inner loop to force restarting and start processing the requested item. @@ -294,7 +200,7 @@ extern "C" { f_thread_unlock(&main->thread.lock.rule); if (F_status_is_error(status)) { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), macro_controller_f(controller_rules_increase), F_true, &main->thread); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_rules_increase), F_true); return status; } @@ -321,14 +227,14 @@ extern "C" { f_thread_unlock(&main->thread.lock.rule); - if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) || main->program.error.verbosity == f_console_verbosity_verbose_e || main->program.error.verbosity == f_console_verbosity_debug_e || (entry->show == controller_entry_show_init_e && entry_action->type != controller_entry_action_type_consider_e)) { + if ((main->setting.flag & controller_main_flag_simulate_e) || main->program.error.verbosity == f_console_verbosity_verbose_e || main->program.error.verbosity == f_console_verbosity_debug_e || (entry->show == controller_entry_show_init_e && entry_action->type != controller_entry_action_type_consider_e)) { if (main->program.output.verbosity != f_console_verbosity_quiet_e && main->program.error.verbosity != f_console_verbosity_error_e) { controller_lock_print(main->program.output.to, &main->thread); - fl_print_format("%r%r %r item rule ", main->program.output.to, f_string_eol_s, entry_action->type == controller_entry_action_type_consider_e ? controller_entry_print_considering_s : controller_entry_print_processing_s, is_entry ? controller_entry_s : controller_exit_s); + fl_print_format("%r%r %r item rule ", main->program.output.to, f_string_eol_s, entry_action->type == controller_entry_action_type_consider_e ? controller_print_entry_considering_s : controller_print_entry_processing_s, is_entry ? controller_entry_s : controller_exit_s); fl_print_format("'%[%Q%]'", main->program.output.to, main->program.context.set.title, alias_rule, main->program.context.set.title); - if (entry->show == controller_entry_show_init_e && !(main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e)) { + if (entry->show == controller_entry_show_init_e && !(main->setting.flag & controller_main_flag_simulate_e)) { fl_print_format(" [%[%r%]]", main->program.output.to, main->program.context.set.notable, entry_action->code == controller_entry_rule_code_asynchronous_d ? controller_asynchronous_s : controller_synchronous_s, main->program.context.set.notable); if (entry_action->code == controller_entry_rule_code_wait_d) { @@ -405,7 +311,7 @@ extern "C" { if (main->program.error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(main->program.error.to, &main->thread); - controller_entry_print_error_cache(is_entry, &main->program.error, cache->action); + controller_print_entry_error_cache(is_entry, &main->program.error, &cache->action); controller_unlock_print_flush(main->program.error.to, &main->thread); } @@ -413,7 +319,7 @@ extern "C" { // Designate the action as failed. entry_action->status = F_status_set_error(F_failure); - if (!(main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e)) { + if (!(main->setting.flag & controller_main_flag_simulate_e)) { f_thread_unlock(&main->thread.lock.rule); if (entry_action->code & controller_entry_rule_code_require_d) { @@ -436,7 +342,7 @@ extern "C" { options_force = 0; options_process = 0; - if (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) { + if (main->setting.flag & controller_main_flag_simulate_e) { options_process |= controller_process_option_simulate_d; } @@ -448,12 +354,12 @@ extern "C" { options_process |= controller_process_option_wait_d; } - if (main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e) { + if (main->setting.flag & controller_main_flag_validate_e) { options_process |= controller_process_option_validate_d; } if (entry_action->code & controller_entry_rule_code_asynchronous_d) { - if (!(main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) { + if (!(main->setting.flag & controller_main_flag_validate_e)) { options_force |= controller_process_option_asynchronous_d; } @@ -466,34 +372,17 @@ extern "C" { break; } - if (F_status_is_error(status) && !(main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) && (entry_action->code & controller_entry_rule_code_require_d)) { + if (F_status_is_error(status) && !(main->setting.flag & controller_main_flag_simulate_e) && (entry_action->code & controller_entry_rule_code_require_d)) { return F_status_set_error(F_require); } } } else if (entry_action->type == controller_entry_action_type_execute_e) { - if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) || main->program.error.verbosity == f_console_verbosity_verbose_e || main->program.error.verbosity == f_console_verbosity_debug_e || entry->show == controller_entry_show_init_e) { - if (main->program.output.verbosity != f_console_verbosity_quiet_e && main->program.error.verbosity != f_console_verbosity_error_e) { - controller_lock_print(main->program.output.to, &main->thread); - - fl_print_format("%r%Q is executing '", main->program.output.to, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); - - for (f_number_unsigned_t k = 0; k < entry_action->parameters.used; ++k) { - - fl_print_format(f_string_format_Q_single_s.string, main->program.output.to, main->program.context.set.title, entry_action->parameters.array[k], main->program.context.set.title); - - if (k + 1 < entry_action->parameters.used) { - f_print_dynamic_raw(f_string_space_s, main->program.output.to); - } - } // for - - fl_print_format("'.%r", main->program.output.to, f_string_eol_s); - - controller_unlock_print_flush(main->program.output.to, &main->thread); - } + if ((main->setting.flag & controller_main_flag_simulate_e) || main->program.message.verbosity > f_console_verbosity_normal_e || entry->show == controller_entry_show_init_e) { + controller_print_entry_message_item_executing(&main->program.message, is_entry, &entry_action->parameters); } - if (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) return F_execute; + if (main->setting.flag & controller_main_flag_simulate_e) return F_execute; controller_thread_process_cancel(main, is_entry, is_entry ? controller_thread_cancel_execute_e : controller_thread_cancel_exit_execute_e); @@ -508,36 +397,16 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_file_found_not) { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QExecution failed, unable to find program or script '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context); - fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, entry_action->parameters.array[0], main->program.error.notable); - fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); - - controller_entry_print_error_cache(is_entry, &main->program.error, cache->action); - - controller_unlock_print_flush(main->program.error.to, &main->thread); - } + controller_print_entry_error_item_action_execution_missing(&main->program.error, &cache->action, is_entry, entry_action->parameters.array[0]); } else { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), macro_controller_f(fll_execute_into), F_true, &main->thread); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(fll_execute_into), F_true); } return F_status_set_error(F_execute); } else if (result != 0) { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QExecution failed with return value of '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context); - fl_print_format("%[%i%]", main->program.error.to, main->program.error.notable, result, main->program.error.notable); - fl_print_format("$['.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); - - controller_entry_print_error_cache(is_entry, &main->program.error, cache->action); - - controller_unlock_print_flush(main->program.error.to, &main->thread); - } + controller_print_entry_error_item_action_execution_failure(&main->program.error, &cache->action, is_entry, result); return F_status_set_error(F_execute); } @@ -548,52 +417,34 @@ extern "C" { if (entry_action->code == controller_entry_timeout_code_exit_d) { entry->timeout_exit = entry_action->number; - controller_entry_preprocess_print_simulate_setting_value(main, is_entry, controller_timeout_s, controller_exit_s, entry->items.array[main->setting.failsafe_item_id].name, controller_entry_print_suffix_megatime_s); + controller_entry_preprocess_print_simulate_setting_value(main, is_entry, controller_timeout_s, controller_exit_s, entry->items.array[main->setting.failsafe_item_id].name, controller_print_entry_suffix_megatime_s); } else if (entry_action->code == controller_entry_timeout_code_kill_d) { entry->timeout_kill = entry_action->number; - controller_entry_preprocess_print_simulate_setting_value(main, is_entry, controller_timeout_s, controller_kill_s, entry->items.array[main->setting.failsafe_item_id].name, controller_entry_print_suffix_megatime_s); + controller_entry_preprocess_print_simulate_setting_value(main, is_entry, controller_timeout_s, controller_kill_s, entry->items.array[main->setting.failsafe_item_id].name, controller_print_entry_suffix_megatime_s); } else if (entry_action->code == controller_entry_timeout_code_start_d) { entry->timeout_start = entry_action->number; - controller_entry_preprocess_print_simulate_setting_value(main, is_entry, controller_timeout_s, controller_start_s, entry->items.array[main->setting.failsafe_item_id].name, controller_entry_print_suffix_megatime_s); + controller_entry_preprocess_print_simulate_setting_value(main, is_entry, controller_timeout_s, controller_start_s, entry->items.array[main->setting.failsafe_item_id].name, controller_print_entry_suffix_megatime_s); } else if (entry_action->code == controller_entry_timeout_code_stop_d) { entry->timeout_stop = entry_action->number; - controller_entry_preprocess_print_simulate_setting_value(main, is_entry, controller_timeout_s, controller_stop_s, entry->items.array[main->setting.failsafe_item_id].name, controller_entry_print_suffix_megatime_s); + controller_entry_preprocess_print_simulate_setting_value(main, is_entry, controller_timeout_s, controller_stop_s, entry->items.array[main->setting.failsafe_item_id].name, controller_print_entry_suffix_megatime_s); } } else if (entry_action->type == controller_entry_action_type_failsafe_e) { if (failsafe) { - if (main->program.warning.verbosity == f_console_verbosity_debug_e) { - controller_lock_print(main->program.warning.to, &main->thread); - - fl_print_format("%r%[%QFailsafe may not be specified when running in failsafe, ignoring.%]%r", main->program.warning.to, f_string_eol_s, main->program.warning.context, main->program.warning.prefix, main->program.warning.context, f_string_eol_s); - - controller_entry_print_error_cache(is_entry, &main->program.warning, cache->action); - - controller_unlock_print_flush(main->program.warning.to, &main->thread); - } + controller_print_entry_warning_item_action_failsafe_twice(&main->program.warning, &cache->action, is_entry); } else { if (entry_action->number == 0 || entry_action->number >= entry->items.used) { // This should not happen if the pre-process is working as designed, but in case it doesn't, return a critical error to prevent infinite recursion and similar errors. - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QInvalid %r item index '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, is_entry ? controller_entry_s : controller_exit_s, main->program.error.context); - fl_print_format("%[%un%]", main->program.error.to, main->program.error.notable, entry_action->number, main->program.error.notable); - fl_print_format("%[' detected.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); - - controller_entry_print_error_cache(is_entry, &main->program.error, cache->action); - - controller_unlock_print_flush(main->program.error.to, &main->thread); - } + controller_print_entry_error_item_invalid(&main->program.error, &cache->action, is_entry, entry_action->number); return F_status_is_error(F_critical); } @@ -636,7 +487,7 @@ extern "C" { status = f_string_dynamic_append_nulless(entry->items.array[cache->ats.array[at_i]].name, &cache->action.name_item); if (F_status_is_error(status)) { - controller_entry_print_error(is_entry, &main->program.error, cache->action, F_status_set_fine(status), macro_controller_f(f_string_dynamic_append_nulless), F_true, &main->thread); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_string_dynamic_append_nulless), F_true); break; } @@ -656,13 +507,13 @@ extern "C" { } // Check to see if any required processes failed, but do not do this if already operating in failsafe. - if (F_status_is_error_not(status) && !failsafe && !(main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e) && main->setting.mode != controller_setting_mode_helper_e) { + if (F_status_is_error_not(status) && !failsafe && !(main->setting.flag & controller_main_flag_validate_e) && main->setting.mode != controller_setting_mode_helper_e) { const f_status_t status_wait = controller_rule_wait_all(main, is_entry, F_true); if (F_status_is_error(status_wait)) return status_wait; if (status_wait == F_require) return F_status_set_error(F_require); } - if (((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) && main->program.error.verbosity > f_console_verbosity_quiet_e) && main->program.error.verbosity != f_console_verbosity_error_e || main->program.error.verbosity == f_console_verbosity_verbose_e) { + if (((main->setting.flag & controller_main_flag_simulate_e) && main->program.error.verbosity > f_console_verbosity_quiet_e) && main->program.error.verbosity != f_console_verbosity_error_e || main->program.error.verbosity == f_console_verbosity_verbose_e) { controller_lock_print(main->program.output.to, &main->thread); fl_print_format("%rDone processing %r item '", main->program.output.to, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); diff --git a/sources/c/main/entry/setting.c b/sources/c/main/entry/setting.c index 3ec0197..eb94a0f 100644 --- a/sources/c/main/entry/setting.c +++ b/sources/c/main/entry/setting.c @@ -18,7 +18,7 @@ extern "C" { } if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(fll_fss_extended_read), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(fll_fss_extended_read), F_true); return status; } @@ -30,7 +30,7 @@ extern "C" { } if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_fss_apply_delimit), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_fss_apply_delimit), F_true); return status; } @@ -49,7 +49,7 @@ extern "C" { f_fss_count_lines(cache->buffer_file, cache->object_actions.array[i].start, &cache->action.line_action, &main->setting.state); if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_fss_count_lines), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_fss_count_lines), F_true); break; } @@ -60,7 +60,7 @@ extern "C" { status = f_rip_dynamic_partial_nulless(cache->buffer_file, cache->object_actions.array[i], &cache->action.name_action); if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_rip_dynamic_partial_nulless), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_rip_dynamic_partial_nulless), F_true); break; } @@ -88,7 +88,7 @@ extern "C" { fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); - controller_entry_print_error_cache(is_entry, &main->program.error, cache->action); + controller_print_entry_error_cache(is_entry, &main->program.error, &cache->action); controller_unlock_print_flush(main->program.error.to, &main->thread); @@ -106,7 +106,7 @@ extern "C" { status = f_rip_dynamic_partial_nulless(cache->buffer_file, cache->content_actions.array[i].array[0], &cache->action.generic); if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_rip_dynamic_partial_nulless), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_rip_dynamic_partial_nulless), F_true); break; } @@ -116,7 +116,7 @@ extern "C" { status = controller_path_canonical_relative(main->setting, cache->action.generic, &main->setting.path_control); if (F_status_is_error(status)) { - controller_entry_print_error_file(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_path_canonical_relative), F_true, cache->action.generic, f_file_operation_analyze_s, fll_error_file_type_path_e); + controller_print_entry_error_file(&main->program.error, &cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_path_canonical_relative), F_true, cache->action.generic, f_file_operation_analyze_s, fll_error_file_type_path_e); continue; } @@ -139,7 +139,7 @@ extern "C" { controller_entry_setting_read_print_error_with_range(&main->program.error, cache, is_entry, " has an invalid group", cache->content_actions.array[i].array[0], ", because the given ID is not a valid supported number"); } else { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_convert_group_id), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_convert_group_id), F_true); } continue; @@ -158,7 +158,7 @@ extern "C" { status = f_rip_dynamic_partial_nulless(cache->buffer_file, cache->content_actions.array[i].array[0], &cache->action.generic); if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_rip_dynamic_partial_nulless), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_rip_dynamic_partial_nulless), F_true); break; } @@ -174,7 +174,7 @@ extern "C" { status = f_file_mode_to_mode(mode_file, &mode); if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_file_mode_to_mode), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_file_mode_to_mode), F_true); continue; } @@ -200,7 +200,7 @@ extern "C" { controller_entry_setting_read_print_error_with_range(&main->program.error, cache, is_entry, " has an invalid user", cache->content_actions.array[i].array[0], ", because the given ID is not a valid supported number"); } else { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_convert_user_id), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_convert_user_id), F_true); } continue; @@ -219,7 +219,7 @@ extern "C" { status = controller_entry_setting_read_map(cache->buffer_file, cache->content_actions.array[i], &entry->define); if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_entry_setting_read_map), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_entry_setting_read_map), F_true); continue; } @@ -256,7 +256,7 @@ extern "C" { status = controller_entry_setting_read_map(cache->buffer_file, cache->content_actions.array[i], &entry->parameter); if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_entry_setting_read_map), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_entry_setting_read_map), F_true); continue; } @@ -290,7 +290,7 @@ extern "C" { continue; } - if (main->program.parameters.array[controller_parameter_pid_e].result & f_console_result_value_e) { + if (main->setting.flag & controller_main_flag_pid_e) { controller_entry_setting_read_print_setting_ignored(main, is_entry, *cache, i); } else { @@ -299,7 +299,7 @@ extern "C" { status = f_rip_dynamic_partial_nulless(cache->buffer_file, cache->content_actions.array[i].array[0], &cache->action.generic); if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_rip_dynamic_partial_nulless), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(f_rip_dynamic_partial_nulless), F_true); continue; } @@ -309,7 +309,7 @@ extern "C" { status = controller_path_canonical_relative(main->setting, cache->action.generic, &main->setting.path_pid); if (F_status_is_error(status)) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_path_canonical_relative), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(controller_path_canonical_relative), F_true); continue; } @@ -416,7 +416,7 @@ extern "C" { *time = time_previous; if (F_status_set_fine(status) == F_memory_not) { - controller_entry_print_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(fl_conversion_dynamic_partial_to_unsigned_detect), F_true); + controller_print_entry_error(&main->program.error, cache->action, is_entry, F_status_set_fine(status), macro_controller_f(fl_conversion_dynamic_partial_to_unsigned_detect), F_true); continue; } diff --git a/sources/c/main/entry/setting.h b/sources/c/main/entry/setting.h index 17347e9..06f8abd 100644 --- a/sources/c/main/entry/setting.h +++ b/sources/c/main/entry/setting.h @@ -36,9 +36,9 @@ extern "C" { * @return * F_okay on success. * - * Errors (with error bit) from: controller_entry_print_error_file(). + * Errors (with error bit) from: controller_print_entry_error_file(). * - * @see controller_entry_print_error_file() + * @see controller_print_entry_error_file() */ #ifndef _di_controller_entry_setting_read_ extern f_status_t controller_entry_setting_read(controller_t * const main, controller_cache_t * const cache, const uint8_t is_entry, const f_range_t content_range); diff --git a/sources/c/main/perform.c b/sources/c/main/perform.c index 70d0538..f5b9257 100644 --- a/sources/c/main/perform.c +++ b/sources/c/main/perform.c @@ -10,8 +10,8 @@ extern "C" { if (!main) return F_status_set_error(F_parameter); if (!is_entry) return F_okay; - if (main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e) { - if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e)) { + if (main->setting.flag & controller_main_flag_validate_e) { + if ((main->setting.flag & controller_main_flag_simulate_e)) { controller_print_perform_debug_pid_file_control_socket(&main->program.debug); } diff --git a/sources/c/main/print/entry.c b/sources/c/main/print/entry.c index a7c42c3..9750dd2 100644 --- a/sources/c/main/print/entry.c +++ b/sources/c/main/print/entry.c @@ -4,11 +4,182 @@ extern "C" { #endif -#ifndef _di_controller_entry_action_parameters_print_ - f_status_t controller_entry_action_parameters_print(fl_print_t * const print, controller_entry_action_t * const action) { +#ifndef _di_controller_print_entry_error_ + f_status_t controller_print_entry_error(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_status_t status, const char * const function, const bool fallback) { if (!print || !print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + if (status == F_interrupt) return F_status_set_error(F_output_not); + + controller_t * const main = (controller_t *) print->custom; + + // fll_error_print() automatically locks, so manually handle only the mutex locking and flushing rather than calling controller_lock_print(). + f_thread_mutex_lock(&main->thread.lock.print); + + fll_error_print(print, status, function, fallback); + + f_file_stream_lock(print->to); + + controller_print_entry_error_cache(print, cache, is_entry); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_error_ + +#ifndef _di_controller_print_entry_error_cache_ + f_status_t controller_print_entry_error_cache(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + fl_print_format("%r%[%QWhile processing ", print->to.stream, f_string_eol_s, print->context, print->prefix); + + if (cache->name_action.used) { + fl_print_format("action '%]", print->to.stream, print->context); + fl_print_format("%[%Q%]", print->to.stream, print->notable, cache->name_action, print->notable); + fl_print_format("%[' on line%] ", print->to.stream, print->context, print->context); + fl_print_format("%[%un%]", print->to.stream, print->notable, cache->line_action, print->notable); + fl_print_format("%[ for ", print->to.stream, print->context); + } + + if (cache->name_item.used) { + fl_print_format("%r item '%]", print->to.stream, is_entry ? controller_entry_s : controller_exit_s, print->context); + fl_print_format("%[%Q%]", print->to.stream, print->notable, cache->name_item, print->notable); + fl_print_format("%[' on line%] ", print->to.stream, print->context, print->context); + fl_print_format("%[%un%]", print->to.stream, print->notable, cache->line_item, print->notable); + fl_print_format("%[ for ", print->to.stream, print->context); + } + + if (cache->name_file.used) { + fl_print_format("%r file '%]", print->to.stream, is_entry ? controller_entry_s : controller_exit_s, print->context); + fl_print_format("%[%Q%]%['", print->to.stream, print->notable, cache->name_file, print->notable, print->context); + } + + fl_print_format(".%]%r", print->to.stream, print->context, f_string_eol_s); + + return F_okay; + } +#endif // _di_controller_print_entry_error_cache_ + +#ifndef _di_controller_print_entry_error_file_ + f_status_t controller_print_entry_error_file(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_status_t status, const char * const function, const bool fallback, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + if (status == F_interrupt) return F_status_set_error(F_output_not); + + controller_t * const main = (controller_t *) print->custom; + + // fll_error_file_print() automatically locks, so manually handle only the mutex locking and flushing rather than calling controller_lock_print(). + f_thread_mutex_lock(&main->thread.lock.print); + + fll_error_file_print(print, status, function, fallback, name, operation, type); + + f_file_stream_lock(print->to); + + controller_print_entry_error_cache(print, cache, is_entry); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_error_file_ + +#ifndef _di_controller_print_entry_error_item_action_execution_failure_ + f_status_t controller_print_entry_error_item_action_execution_failure(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const int code) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%[%QExecution failed with return value of '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format(f_string_format_i_single_s.string, print->to, print->notable, code, print->notable); + fl_print_format("$['.%]%r", print->to, print->context, print->context, f_string_eol_s); + + controller_print_entry_error_cache(print, cache, is_entry); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_error_item_action_execution_failure_ + +#ifndef _di_controller_print_entry_error_item_action_execution_missing_ + f_status_t controller_print_entry_error_item_action_execution_missing(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_string_static_t name) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%[%QExecution failed, unable to find program or script '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, name, print->notable); + fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s); + + controller_print_entry_error_cache(print, cache, is_entry); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_error_item_action_execution_missing_ + +#ifndef _di_controller_print_entry_error_item_failure_ + f_status_t controller_print_entry_error_item_failure(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_string_static_t name, const f_string_static_t message) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%[%QThe %r item named '%]", print->to, f_string_eol_s, print->context, is_entry ? controller_entry_s : controller_exit_s, print->prefix, print->context); + fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, parameter, print->notable); + fl_print_format("%[' %S.%]%r", print->to, print->context, message, print->context, f_string_eol_s); + + controller_print_entry_error_cache(print, cache, is_entry); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_error_item_failure_ + +#ifndef _di_controller_print_entry_error_item_invalid_ + f_status_t controller_print_entry_error_item_invalid(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_number_unsigned_t number) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%[Invalid %r item index '%]", print->to, f_string_eol_s, print->context, is_entry ? controller_entry_s : controller_exit_s, print->context); + fl_print_format(f_string_format_un_single_s.string, print->to, print->notable, number, print->notable); + fl_print_format("%[' detected.%]%r", print->to, print->context, print->context, f_string_eol_s); + + controller_print_entry_error_cache(print, cache, is_entry); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_error_item_invalid_ + +#ifndef _di_controller_print_entry_message_action_parameters_ + f_status_t controller_print_entry_message_action_parameters(fl_print_t * const print, controller_entry_action_t * const action) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; for (f_array_length_t index = 0; ;) { @@ -23,94 +194,285 @@ extern "C" { return F_okay; } -#endif // _di_controller_entry_action_parameters_print_ +#endif // _di_controller_print_entry_message_action_parameters_ -#ifndef _di_controller_entry_print_error_ - f_status_t controller_entry_print_error(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_status_t status, const char *function, const bool fallback) { +#ifndef _di_controller_print_entry_message_action_state_ + f_status_t controller_print_entry_message_action_state(fl_print_t * const print, controller_cache_action_t * const cache, controller_entry_action_t * const action, const uint8_t is_entry, const f_string_static_t name) { if (!print || !print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; controller_t * const main = (controller_t *) print->custom; - if (print.verbosity == f_console_verbosity_quiet_e) return; - if (status == F_interrupt) return; + controller_lock_print(print->to, &main->thread); - // fll_error_print() automatically locks, so manually handle only the mutex locking and flushing rather than calling controller_lock_print(). - f_thread_mutex_lock(&main->thread.lock.print); + fl_print_format("%r%[%QThe %r item action '%]", print->to, f_string_eol_s, print->context, print->prefix, is_entry ? controller_entry_s : controller_exit_s, print->context); + fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, name, print->notable); - fll_error_print(print, status, function, fallback); - flockfile(print.to.stream); + if (action->parameters.used) { + fl_print_format(" %[", print->to, context->notable); + + controller_print_entry_message_action_parameters(print, action); + + fl_print_format("%]", print->to, context->notable); + } + + if (action->code & controller_entry_rule_code_require_d) { + fl_print_format("%[' is%] %[required%]", print->to, print->context, print->context, print->notable, print->notable); + } + else { + fl_print_format("%[' is%] %[optional%]", print->to, print->context, print->context, print->notable, print->notable); + } + + fl_print_format(" %[and is in a%] %[failed%]", print->to, print->context, print->context, print->notable, print->notable); - controller_entry_print_error_cache(is_entry, print, cache); + if (action->code & controller_entry_rule_code_require_d) { + fl_print_format(" %[state, aborting.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else { + fl_print_format(" %[state, skipping.%]%r", print->to, print->context, print->context, f_string_eol_s); + } - controller_unlock_print_flush(print.to, &main->thread); + controller_print_entry_error_cache(is_entry, print, &cache->action); + + controller_unlock_print_flush(print->to, &main->thread); return F_okay; } -#endif // _di_controller_entry_print_error_ +#endif // _di_controller_print_entry_message_action_state_ -#ifndef _di_controller_entry_print_error_cache_ - f_status_t controller_entry_print_error_cache(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry) { +#ifndef _di_controller_print_entry_message_action_state_failed_ + f_status_t controller_print_entry_message_action_state_failed(fl_print_t * const print, controller_entry_action_t * const action, const uint8_t is_entry, const f_string_static_t name) { if (!print || !print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - fl_print_format("%r%[%QWhile processing ", output.to.stream, f_string_eol_s, output.context, output.prefix); + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); - if (cache.name_action.used) { - fl_print_format("action '%]", output.to.stream, output.context); - fl_print_format("%[%Q%]", output.to.stream, output.notable, cache.name_action, output.notable); - fl_print_format("%[' on line%] ", output.to.stream, output.context, output.context); - fl_print_format("%[%un%]", output.to.stream, output.notable, cache.line_action, output.notable); - fl_print_format("%[ for ", output.to.stream, output.context); + fl_print_format("%rThe %r item action '", print->to, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); + fl_print_format(f_string_format_Q_single_s.string, print->to, context->set.title, name, context->set.title); + + if (action->parameters.used) { + fl_print_format(" %[", print->to, context->notable); + + controller_print_entry_message_action_parameters(print->to, action); + + fl_print_format("%]", print->to, context->notable); } - if (cache.name_item.used) { - fl_print_format("%r item '%]", output.to.stream, is_entry ? controller_entry_s : controller_exit_s, output.context); - fl_print_format("%[%Q%]", output.to.stream, output.notable, cache.name_item, output.notable); - fl_print_format("%[' on line%] ", output.to.stream, output.context, output.context); - fl_print_format("%[%un%]", output.to.stream, output.notable, cache.line_item, output.notable); - fl_print_format("%[ for ", output.to.stream, output.context); + fl_print_format("' is %[%r%] and is in a ", print->to, context->notable, action->code & controller_entry_rule_code_require_d ? "required" : "optional", context->notable); + + fl_print_format("%[failed%] state, skipping.%r", print->to, context->notable, context->notable, context->notable, f_string_eol_s); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_message_action_state_failed_ + +#ifndef _di_controller_print_entry_message_item_action_ready_ + f_status_t controller_print_entry_message_item_action_ready(fl_print_t * const print, const uint8_t is_entry, const f_string_static_t name) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_normal_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%rIgnoring %r item action '", print->to, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); + fl_print_format(f_string_format_r_single_s.string, print->to, print->set.title, name, print->set.title); + fl_print_format("', state already is ready.%r", print->to, f_string_eol_s); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_message_item_action_ready_ + +#ifndef _di_controller_print_entry_message_item_action_wait_ + f_status_t controller_print_entry_message_item_action_wait(fl_print_t * const print, const uint8_t is_entry, const f_string_static_t name) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_normal_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%rWaiting before processing %r item action '", print->to, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); + fl_print_format(f_string_format_r_single_s.string, print->to, print->set.title, name, print->set.title); + fl_print_format("'.%r", print->to, f_string_eol_s); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_message_item_action_wait_ + +#ifndef _di_controller_print_entry_message_item_executing_ + f_status_t controller_print_entry_message_item_executing(fl_print_t * const print, const uint8_t is_entry, f_string_dynamics_t * const parameters) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_normal_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%Q is executing '", print->to, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); + + for (f_number_unsigned_t k = 0; k < parameters.used; ++k) { + + fl_print_format(f_string_format_Q_single_s.string, print->to, print->set.title, parameters.array[k], print->set.title); + + if (k + 1 < parameters.used) { + f_print_dynamic_raw(f_string_space_s, print->to); + } + } // for + + fl_print_format("'.%r", print->to, f_string_eol_s); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_message_item_executing_ + +#ifndef _di_controller_print_entry_message_item_process_ + f_status_t controller_print_entry_message_item_process(fl_print_t * const print, const uint8_t is_entry, const f_string_static_t prepend, const f_string_static_t name) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_normal_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%rProcessing %r", print->to, f_string_eol_s, prepend); + + if (prepend.used) { + fl_print_format("%r ", print->to, prepend); } - if (cache.name_file.used) { - fl_print_format("%r file '%]", output.to.stream, is_entry ? controller_entry_s : controller_exit_s, output.context); - fl_print_format("%[%Q%]%['", output.to.stream, output.notable, cache.name_file, output.notable, output.context); + fl_print_format("%r item '%[%Q%]'.%r", print->to, is_entry ? controller_entry_s : controller_exit_s, print->title, name, print->title, f_string_eol_s); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_message_item_process_ + + if (((main->setting.flag & controller_main_flag_simulate_e) && main->program.error.verbosity > f_console_verbosity_quiet_e) && main->program.error.verbosity != f_console_verbosity_error_e || main->program.error.verbosity == f_console_verbosity_verbose_e) { + controller_lock_print(print->to, &main->thread); + + fl_print_format("%rDone processing %r item '", print->to, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); + fl_print_format(f_string_format_r_single_s.string, print->to, print->set.title, controller_main_s, print->set.title); + fl_print_format("'.%r", print->to, f_string_eol_s); + + // failsafe should not print the extra newline because the failure exit from controller_main should handle this. + if (!failsafe) { + f_print_dynamic_raw(f_string_eol_s, print->to); + } + + controller_unlock_print_flush(print->to, &main->thread); } - fl_print_format(".%]%r", output.to.stream, output.context, f_string_eol_s); +#ifndef _di_controller_print_entry_message_item_rule_ + f_status_t controller_print_entry_message_item_rule(fl_print_t * const print, const uint8_t is_entry, const f_string_static_t name) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_normal_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%r %r item rule ", print->to, f_string_eol_s, entry_action->type == controller_entry_action_type_consider_e ? controller_print_entry_considering_s : controller_print_entry_processing_s, is_entry ? controller_entry_s : controller_exit_s); + fl_print_format("'%[%Q%]'", print->to, print->set.title, alias_rule, print->set.title); + + if (entry->show == controller_entry_show_init_e && !(main->setting.flag & controller_main_flag_simulate_e)) { + fl_print_format(" [%[%r%]]", print->to, main->program.context.set.notable, entry_action->code == controller_entry_rule_code_asynchronous_d ? controller_asynchronous_s : controller_synchronous_s, main->program.context.set.notable); + + if (entry_action->code == controller_entry_rule_code_wait_d) { + fl_print_format(" [%[%r%]]", print->to, main->program.context.set.notable, controller_wait_s, main->program.context.set.notable); + } + + if (entry_action->code == controller_entry_rule_code_require_d) { + fl_print_format(" [%[%r%]]", print->to, main->program.context.set.notable, controller_required_s, main->program.context.set.notable); + } + } + + fl_print_format(".%r", print->to, f_string_eol_s); + + controller_unlock_print_flush(print->to, &main->thread); return F_okay; } -#endif // _di_controller_entry_print_error_cache_ +#endif // _di_controller_print_entry_message_item_rule_ -#ifndef _di_controller_entry_print_error_file_ - f_status_t controller_entry_print_error_file(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, 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) { +#ifndef _di_controller_print_entry_message_state_ + f_status_t controller_print_entry_message_state(fl_print_t * const print, const uint8_t is_entry, const f_string_static_t name) { if (!print || !print->custom) return F_status_set_error(F_output_not); - if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + if (print->verbosity < f_console_verbosity_normal_e) return F_output_not; controller_t * const main = (controller_t *) print->custom; - if (print.verbosity == f_console_verbosity_quiet_e) return; - if (status == F_interrupt) return; + controller_lock_print(print->to, &main->thread); - // fll_error_file_print() automatically locks, so manually handle only the mutex locking and flushing rather than calling controller_lock_print(). - f_thread_mutex_lock(&main->thread.lock.print); + fl_print_format("%rState is now '%[%r%]'.%r", print->to, f_string_eol_s, print->notable, name, print->notable, f_string_eol_s); - fll_error_file_print(print, status, function, fallback, name, operation, type); + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_message_state_ + +#ifndef _di_controller_print_entry_warning_item_action_failsafe_twice_ + f_status_t controller_print_entry_warning_item_action_failsafe_twice(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_debug_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%[%QFailsafe may not be specified when running in failsafe, ignoring.%]%r", print->to, f_string_eol_s, print->context, print->prefix, print->context, f_string_eol_s); + + controller_print_entry_error_cache(print, cache, is_entry); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_entry_warning_item_action_failsafe_twice_ + +#ifndef _di_controller_print_entry_warning_item_action_multiple_ + f_status_t controller_print_entry_warning_item_action_multiple(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_string_static_t name) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); - flockfile(print.to.stream); + fl_print_format("%r%[%QMultiple '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, name, print->notable); + fl_print_format("%[' %r item actions detected; only the first will be used.%]%r", print->to, print->context, is_entry ? controller_entry_s : controller_exit_s, print->context, f_string_eol_s); - controller_entry_print_error_cache(is_entry, print, cache); + controller_print_entry_error_cache(print, cache, is_entry); - controller_unlock_print_flush(print.to, &main->thread); + controller_unlock_print_flush(print->to, &main->thread); return F_okay; } -#endif // _di_controller_entry_print_error_file_ +#endif // _di_controller_print_entry_warning_item_action_multiple_ #ifdef __cplusplus } // extern "C" diff --git a/sources/c/main/print/entry.h b/sources/c/main/print/entry.h index 9a837d1..42e413d 100644 --- a/sources/c/main/print/entry.h +++ b/sources/c/main/print/entry.h @@ -17,38 +17,28 @@ extern "C" { #endif /** - * Print all parameters for some action, separated by a space. + * Print the entry related error. * - * @param stream - * The file stream to print to. - * @param action - * The entry action whose parameters will be printed. + * @param print + * The output structure to print to. * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. + * This requires print.custom to be controller_t. * - * F_output_not (with error bit) if setting is NULL. - */ -#ifndef _di_controller_entry_action_parameters_print_ - extern f_status_t controller_entry_action_parameters_print(fl_print_t * const print, controller_entry_action_t * const action); -#endif // _di_controller_entry_action_parameters_print_ - -/** - * Print the entry related error, locking the print mutex during the print. + * This does not alter print.custom.setting.state.status. * + * Must not be NULL. + * @param cache + * The action cache. + * + * Must not be NULL. * @param is_entry * If TRUE, then this loads as an entry. * If FALSE, then this loads as an exit. - * @param print - * Designates how printing is to be performed. - * @param cache - * The action cache. * @param status * The status code to process. * Make sure this has F_status_set_fine() called if the status code has any error or warning bits. * @param function - * The name of the function where the error happened. + * (optional) The name of the function where the error happened. * Set to 0 to disable. * @param fallback * Set to F_true to print the fallback error message for unknown errors. @@ -62,11 +52,11 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. * * @see fll_error_print() - * @see controller_entry_print_error_cache() + * @see controller_print_entry_error_cache() */ -#ifndef _di_controller_entry_print_error_ - extern f_status_t controller_entry_print_error(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_status_t status, const char *function, const bool fallback); -#endif // _di_controller_entry_print_error_ +#ifndef _di_controller_print_entry_error_ + extern f_status_t controller_print_entry_error(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_status_t status, const char * const function, const bool fallback); +#endif // _di_controller_print_entry_error_ /** * Print additional error/warning information in addition to existing error that is found within the cache. @@ -75,13 +65,21 @@ extern "C" { * * This neither locks the thread nor does it check to see if output is enabled or disabled. * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param cache + * The action cache. + * + * Must not be NULL. * @param is_entry * If TRUE, then this loads as an entry. * If FALSE, then this loads as an exit. - * @param output - * Designates how printing is to be performed. - * @param cache - * The action cache. * * @return * F_okay on success. @@ -92,25 +90,29 @@ extern "C" { * @see controller_entry_actions_read() * @see controller_entry_read() */ -#ifndef _di_controller_entry_print_error_cache_ - extern f_status_t controller_entry_print_error_cache(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry); -#endif // _di_controller_entry_print_error_cache_ +#ifndef _di_controller_print_entry_error_cache_ + extern f_status_t controller_print_entry_error_cache(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry); +#endif // _di_controller_print_entry_error_cache_ /** - * Print the entry related file error, locking the print mutex during the print. + * Print the entry related file error. + * + * @param print + * The output structure to print to. * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. * @param is_entry * If TRUE, then this loads as an entry. * If FALSE, then this loads as an exit. - * @param print - * Designates how printing is to be performed. * @param cache * The action cache. * @param status * The status code to process. * Make sure this has F_status_set_fine() called if the status code has any error or warning bits. * @param function - * The name of the function where the error happened. + * (optional) The name of the function where the error happened. * Set to 0 to disable. * @param fallback * Set to F_true to print the fallback error message for unknown errors. @@ -130,11 +132,495 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. * * @see fll_error_file_print() - * @see controller_entry_print_error_cache() + * @see controller_print_entry_error_cache() + */ +#ifndef _di_controller_print_entry_error_file_ + extern f_status_t controller_print_entry_error_file(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_status_t status, const char * const function, const bool fallback, const f_string_static_t name, const f_string_static_t operation, const uint8_t type); +#endif // _di_controller_print_entry_error_file_ + +/** + * Print an error about a entry item action program or script execution failure. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param cache + * The action cache. + * + * Must not be NULL. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * @param code + * The return code. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + * @see controller_print_entry_error_cache() + */ +#ifndef _di_controller_print_entry_error_item_action_execution_failure_ + extern f_status_t controller_print_entry_error_item_action_execution_failure(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const int code); +#endif // _di_controller_print_entry_error_item_action_execution_failure_ + +/** + * Print an error about a entry item action program or script not being found. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param cache + * The action cache. + * + * Must not be NULL. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * @param name + * The program or script name. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + * @see controller_print_entry_error_cache() + */ +#ifndef _di_controller_print_entry_error_item_action_execution_missing_ + extern f_status_t controller_print_entry_error_item_action_execution_missing(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_string_static_t name); +#endif // _di_controller_print_entry_error_item_action_execution_missing_ + +/** + * Print the entry item related error. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param cache + * The action cache. + * + * Must not be NULL. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * @param name + * The item name. + * @param message + * A short message describing the reason for the failure. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + * @see controller_print_entry_error_cache() + */ +#ifndef _di_controller_print_entry_error_item_failure_ + extern f_status_t controller_print_entry_error_item_failure(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_string_static_t name, const f_string_static_t message); +#endif // _di_controller_print_entry_error_item_failure_ + +/** + * Print an error message for an invalid entry item. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param cache + * The action cache. + * + * Must not be NULL. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * @param number + * The index position of the invalid item. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + * @see controller_print_entry_error_cache() + */ +#ifndef _di_controller_print_entry_error_item_invalid_ + extern f_status_t controller_print_entry_error_item_invalid(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_number_unsigned_t number); +#endif // _di_controller_print_entry_error_item_invalid_ + +/** + * Print all parameters for some action, separated by a space. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param action + * The entry action whose parameters will be printed. + * + * Must not be NULL. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_controller_print_entry_message_action_parameters_ + extern f_status_t controller_print_entry_message_action_parameters(fl_print_t * const print, controller_entry_action_t * const action); +#endif // _di_controller_print_entry_message_action_parameters_ + +/** + * Print message about entry action state. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param action + * The entry action whose parameters will be printed. + * + * Must not be NULL. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_controller_print_entry_message_action_state_ + extern f_status_t controller_print_entry_message_action_state(fl_print_t * const print, controller_entry_action_t * const action, const uint8_t is_entry, const f_string_static_t name); +#endif // _di_controller_print_entry_message_action_state_ + +/** + * Print message about entry action state having failed. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param action + * The entry action whose parameters will be printed. + * + * Must not be NULL. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * @param name + * The item name. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_controller_print_entry_message_action_state_failed_ + extern f_status_t controller_print_entry_message_action_state_failed(fl_print_t * const print, controller_entry_action_t * const action, const uint8_t is_entry, const f_string_static_t name) { +#ifndef _di_controller_print_entry_message_action_state_failed_ + +/** + * Print message about the specified entry item action being in the ready state. + * + * This generally only applies to the "ready" entry item action. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * @param name + * The item name. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + * @see controller_print_entry_error_cache() + */ +#ifndef _di_controller_print_entry_message_item_action_ready_ + extern f_status_t controller_print_entry_message_item_action_ready(fl_print_t * const print, const uint8_t is_entry, const f_string_static_t name); +#endif // _di_controller_print_entry_message_item_action_ready_ + +/** + * Print message about waiting for the specified entry item action. + * + * This generally only applies to the "ready" entry item action. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * @param name + * The item name. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + * @see controller_print_entry_error_cache() + */ +#ifndef _di_controller_print_entry_message_item_action_wait_ + extern f_status_t controller_print_entry_message_item_action_wait(fl_print_t * const print, const uint8_t is_entry, const f_string_static_t name); +#endif // _di_controller_print_entry_message_item_action_wait_ + +/** + * Print message about the entry item executing. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * @param parameters + * The array of parameters. + * + * Must not be NULL. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + * @see controller_print_entry_error_cache() + */ +#ifndef _di_controller_print_entry_message_item_executing_ + extern f_status_t controller_print_entry_message_item_executing(fl_print_t * const print, const uint8_t is_entry, f_string_dynamics_t * const parameters); +#endif // _di_controller_print_entry_message_item_executing_ + +/** + * Print message about processing an item. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * @param cache + * The action cache. + * + * Must not be NULL. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * @param prepend + * A string to prepend before entry string in the message. + * When prepend.used is not 0, then a space is also printed between entry string and the prepend string. + * Set prepend.used to 0 to disable. + * @param name + * The item name. + * This name is printed after the "item" and after any optonal append string. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + * @see controller_print_entry_error_cache() + */ +#ifndef _di_controller_print_entry_message_item_process_ + extern f_status_t controller_print_entry_message_item_process(fl_print_t * const print, const uint8_t is_entry, const f_string_static_t prepend, const f_string_static_t name); +#endif // _di_controller_print_entry_message_item_process_ + +/** + * Print warning message about multiple actions for a specified item. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param cache + * The action cache. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * @param name + * The item name. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + * @see controller_print_entry_error_cache() + */ +#ifndef _di_controller_print_entry_message_item_rule_ + extern f_status_t controller_print_entry_message_item_rule(fl_print_t * const print, const uint8_t is_entry, const f_string_static_t name); +#endif // _di_controller_print_entry_message_item_rule_ + +/** + * Print warning the "failsafe" entry item action being specified while already in failsafe mode. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param cache + * The action cache. + * + * Must not be NULL. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + * @see controller_print_entry_error_cache() + */ +#ifndef _di_controller_print_entry_warning_item_action_failsafe_twice_ + extern f_status_t controller_print_entry_warning_item_action_failsafe_twice(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry); +#endif // _di_controller_print_entry_warning_item_action_failsafe_twice_ + +/** + * Print message about the specified entry being in the given state. + * + * This generally only applies to the "ready" entry item action. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * @param name + * The name of the state. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + * @see controller_print_entry_error_cache() + */ +#ifndef _di_controller_print_entry_message_state_ + extern f_status_t controller_print_entry_message_state(fl_print_t * const print, const uint8_t is_entry, const f_string_static_t name); +#endif // _di_controller_print_entry_message_state_ + +/** + * Print warning message about multiple actions for a specified item. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param cache + * The action cache. + * + * Must not be NULL. + * @param is_entry + * If TRUE, then this loads as an entry. + * If FALSE, then this loads as an exit. + * @param name + * The item name. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + * @see controller_print_entry_error_cache() */ -#ifndef _di_controller_entry_print_error_file_ - extern f_status_t controller_entry_print_error_file(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, 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); -#endif // _di_controller_entry_print_error_file_ +#ifndef _di_controller_print_entry_warning_item_action_multiple_ + extern f_status_t controller_print_entry_warning_item_action_multiple(fl_print_t * const print, controller_cache_action_t * const cache, const uint8_t is_entry, const f_string_static_t name); +#endif // _di_controller_print_entry_warning_item_action_multiple_ #ifdef __cplusplus } // extern "C" diff --git a/sources/c/main/print/entry/setting.c b/sources/c/main/print/entry/setting.c index 971e390..653417d 100644 --- a/sources/c/main/print/entry/setting.c +++ b/sources/c/main/print/entry/setting.c @@ -19,7 +19,7 @@ extern "C" { fl_print_format("%[%/Q%]", print.to.stream, print.notable, cache->buffer_file, range, print.notable); fl_print_format("%['%S.%]%r", print.to.stream, print.context, after, print.context, f_string_eol_s); - controller_entry_print_error_cache(is_entry, print, cache->action); + controller_print_entry_error_cache(is_entry, print, &cache->action); controller_unlock_print_flush(print.to, thread); @@ -44,7 +44,7 @@ extern "C" { fl_print_format("%[%Q%]", main->warning.to.stream, main->warning.notable, cache->action.name_action, main->warning.notable); fl_print_format("%[' is being ignored.%]%r", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s); - controller_entry_print_error_cache(is_entry, main->warning, cache->action); + controller_print_entry_error_cache(is_entry, main->warning, &cache->action); controller_unlock_print_flush(main->warning.to, &main->thread); @@ -72,7 +72,7 @@ extern "C" { fl_print_format("%[%un%]", main->error.to.stream, main->error.notable, maximum, main->error.notable); fl_print_format("%[ Content.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - controller_entry_print_error_cache(is_entry, main->error, cache->action); + controller_print_entry_error_cache(is_entry, main->error, &cache->action); controller_unlock_print_flush(main->error.to, &main->thread); @@ -98,7 +98,7 @@ extern "C" { fl_print_format("%[%un%]", main->error.to.stream, main->error.notable, total, main->error.notable); fl_print_format("%[ Content.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - controller_entry_print_error_cache(is_entry, main->error, cache->action); + controller_print_entry_error_cache(is_entry, main->error, &cache->action); controller_unlock_print_flush(main->error.to, &main->thread); @@ -122,7 +122,7 @@ extern "C" { fl_print_format("%[%Q%]", main->warning.to.stream, main->warning.notable, cache->action.name_action, main->warning.notable); fl_print_format("%['.%]%r", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s); - controller_entry_print_error_cache(is_entry, main->warning, cache->action); + controller_print_entry_error_cache(is_entry, main->warning, &cache->action); controller_unlock_print_flush(main->warning.to, &main->thread); @@ -149,7 +149,7 @@ extern "C" { fl_print_format("%[%/Q%]", main->warning.to.stream, main->warning.notable, cache->buffer_file, cache->content_actions.array[index].array[0], main->warning.notable); fl_print_format("%['.%]%r", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s); - controller_entry_print_error_cache(is_entry, main->warning, cache->action); + controller_print_entry_error_cache(is_entry, main->warning, &cache->action); controller_unlock_print_flush(main->warning.to, &main->thread); diff --git a/sources/c/main/print/perform.c b/sources/c/main/print/perform.c index 2d5da06..e14241b 100644 --- a/sources/c/main/print/perform.c +++ b/sources/c/main/print/perform.c @@ -109,7 +109,7 @@ extern "C" { f_file_stream_lock(print->to); - controller_entry_print_error_cache(print->to, main->thread.cache.action, is_entry); + controller_print_entry_error_cache(print->to, &main->thread.cache.action, is_entry); controller_unlock_print_flush(print->to, &main->thread); } @@ -146,7 +146,7 @@ extern "C" { f_file_stream_lock(print->to); - controller_entry_print_error_cache(print->to, main->thread.cache.action, is_entry); + controller_print_entry_error_cache(print->to, &main->thread.cache.action, is_entry); controller_unlock_print_flush(print->to, &main->thread); } diff --git a/sources/c/main/print/rule/setting.c b/sources/c/main/print/rule/setting.c index 20db1b8..ff8bbc2 100644 --- a/sources/c/main/print/rule/setting.c +++ b/sources/c/main/print/rule/setting.c @@ -66,7 +66,7 @@ extern "C" { f_status_t controller_print_rule_setting_read_mapping(controller_t * const main, const f_string_static_t name, const f_string_map_t map) { if (main->program.error.verbosity != f_console_verbosity_debug_e) { - if (!(main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) { + if (!(main->program.error.verbosity == f_console_verbosity_verbose_e && (main->setting.flag & controller_main_flag_simulate_e))) { return F_output_not; } } @@ -87,7 +87,7 @@ extern "C" { f_status_t controller_print_rule_setting_read_value(controller_t * const main, const f_string_static_t name, const f_string_static_t name_sub, const f_string_static_t value, const f_string_t suffix) { if (main->program.error.verbosity != f_console_verbosity_debug_e) { - if (!(main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) { + if (!(main->program.error.verbosity == f_console_verbosity_verbose_e && (main->setting.flag & controller_main_flag_simulate_e))) { return F_output_not; } } @@ -116,7 +116,7 @@ extern "C" { f_status_t controller_print_rule_setting_read_values(controller_t * const main, controller_cache_t * const cache, const f_string_static_t name, const f_number_unsigned_t index) { if (main->program.error.verbosity != f_console_verbosity_debug_e) { - if (!(main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) { + if (!(main->program.error.verbosity == f_console_verbosity_verbose_e && (main->setting.flag & controller_main_flag_simulate_e))) { return F_output_not; } } diff --git a/sources/c/main/rule/instance.c b/sources/c/main/rule/instance.c index 88cbda6..ade4ce9 100644 --- a/sources/c/main/rule/instance.c +++ b/sources/c/main/rule/instance.c @@ -285,7 +285,7 @@ extern "C" { options_instance = 0; - if (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) { + if (main->setting.flag & controller_main_flag_simulate_e) { options_instance |= controller_instance_option_simulate_e; } diff --git a/sources/c/main/rule/setting.c b/sources/c/main/rule/setting.c index 118b009..e4d9990 100644 --- a/sources/c/main/rule/setting.c +++ b/sources/c/main/rule/setting.c @@ -1137,7 +1137,7 @@ extern "C" { rule->timeout_stop = number; } - if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) { + if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->setting.flag & controller_main_flag_simulate_e))) { f_string_static_t name_sub = controller_stop_s; if (timeout_code == controller_rule_timeout_code_kill_d) { @@ -1300,7 +1300,7 @@ extern "C" { rule->nice = number; rule->has |= controller_rule_has_nice_d; - if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) || main->program.error.verbosity == f_console_verbosity_verbose_e) { + if ((main->setting.flag & controller_main_flag_simulate_e) || main->program.error.verbosity == f_console_verbosity_verbose_e) { cache->action.generic.used = 0; status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], &cache->action.generic); @@ -1376,7 +1376,7 @@ extern "C" { rule->user = number; rule->has |= controller_rule_has_user_d; - if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) { + if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->setting.flag & controller_main_flag_simulate_e))) { cache->action.generic.used = 0; status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], &cache->action.generic); @@ -1593,7 +1593,7 @@ extern "C" { controller_print_rule_setting_read_values(main, controller_environment_s, i, cache); } else { - if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) { + if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->setting.flag & controller_main_flag_simulate_e))) { controller_lock_print(main->program.output.to, &main->thread); fl_print_format("%rProcessing rule item action '%[%r%]' setting value to an empty set.%r", main->program.output.to, f_string_eol_s, main->program.context.set.title, controller_environment_s, main->program.context.set.title, f_string_eol_s); @@ -1806,7 +1806,7 @@ extern "C" { ++rule->ons.used; } - if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) { + if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->setting.flag & controller_main_flag_simulate_e))) { controller_lock_print(main->program.output.to, &main->thread); fl_print_format("%rProcessing rule item action '%[%r%]', adding ", main->program.output.to, f_string_eol_s, main->program.context.set.title, controller_on_s, main->program.context.set.title); diff --git a/sources/c/main/thread/cleanup.c b/sources/c/main/thread/cleanup.c index 4de82ae..4cd3838 100644 --- a/sources/c/main/thread/cleanup.c +++ b/sources/c/main/thread/cleanup.c @@ -16,7 +16,7 @@ extern "C" { if (main->thread.enabled != controller_thread_enabled_e) return 0; const f_time_spec_t delay = { - .tv_sec = (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) + .tv_sec = (main->setting.flag & controller_main_flag_simulate_e) ? controller_thread_cleanup_interval_short_d : controller_thread_cleanup_interval_long_d, .tv_nsec = 0, diff --git a/sources/c/main/thread/entry.c b/sources/c/main/thread/entry.c index b5a739f..fbd46bd 100644 --- a/sources/c/main/thread/entry.c +++ b/sources/c/main/thread/entry.c @@ -28,13 +28,13 @@ extern "C" { else if (*status != F_child) { *status = controller_entry_preprocess(main, F_true); - if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) && (main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) { + if ((main->setting.flag & controller_main_flag_simulate_e) && (main->setting.flag & controller_main_flag_validate_e)) { controller_print_entry_validate_setting(main, F_true); } } if (F_status_is_error_not(*status) && *status != F_child) { - if (!(main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e) || (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e)) { + if (!(main->setting.flag & controller_main_flag_validate_e) || (main->setting.flag & controller_main_flag_simulate_e)) { if (main->process.entry.pid == controller_entry_pid_require_e && f_file_exists(main->process.path_pid, F_true) == F_true) { *status = F_status_set_error(F_available_not); @@ -147,13 +147,13 @@ extern "C" { else if (*status != F_child) { *status = controller_entry_preprocess(main, F_false); - if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) && (main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) { + if ((main->setting.flag & controller_main_flag_simulate_e) && (main->setting.flag & controller_main_flag_validate_e)) { controller_print_entry_validate_setting(main, F_false); } } if (F_status_is_error_not(*status) && *status != F_child && *status != F_file_found_not) { - if (!(main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e) || (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e)) { + if (!(main->setting.flag & controller_main_flag_validate_e) || (main->setting.flag & controller_main_flag_simulate_e)) { *status = controller_entry_process(main, F_false, F_false); -- 1.8.3.1