From 6c302209bb5b770909c05dea99b84bc9a13e77f3 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 30 May 2024 22:35:16 -0500 Subject: [PATCH] Progress: Continue migrating the project. --- data/build/settings | 2 + sources/c/controller/controller.c | 2 +- sources/c/main/common.h | 4 +- sources/c/main/common/type/instance.h | 3 + sources/c/main/controller.h | 3 + sources/c/main/print/error.c | 56 ----- sources/c/main/print/error.h | 14 +- sources/c/main/print/rule.c | 120 ++-------- sources/c/main/print/rule.h | 157 +++---------- sources/c/main/print/rule/action.c | 20 ++ sources/c/main/print/rule/action.h | 35 +++ sources/c/main/print/rule/item.c | 408 ++++++++++++++++++++++++++++++++++ sources/c/main/print/rule/item.h | 210 +++++++++++++++++ sources/c/main/print/rule/setting.c | 144 ++++++++++++ sources/c/main/print/rule/setting.h | 128 +++++++++++ sources/c/main/rule/action.c | 12 +- sources/c/main/rule/execute.c | 44 ++-- sources/c/main/rule/instance.c | 58 +++-- sources/c/main/rule/item.c | 2 +- sources/c/main/rule/read.c | 4 +- sources/c/main/rule/setting.c | 204 ++++++++--------- sources/c/main/rule/validate.c | 2 +- sources/c/main/thread/instance.c | 2 +- sources/c/main/thread/instance.h | 2 +- 24 files changed, 1183 insertions(+), 453 deletions(-) create mode 100644 sources/c/main/print/rule/action.c create mode 100644 sources/c/main/print/rule/action.h create mode 100644 sources/c/main/print/rule/item.c create mode 100644 sources/c/main/print/rule/item.h create mode 100644 sources/c/main/print/rule/setting.c create mode 100644 sources/c/main/print/rule/setting.h diff --git a/data/build/settings b/data/build/settings index 65ea4a2..30b25a6 100644 --- a/data/build/settings +++ b/data/build/settings @@ -46,6 +46,7 @@ build_sources_library main/common/string/general.c main/common/string/rule.c build_sources_library main/instance.c main/path.c build_sources_library main/rule.c main/rule/action.c main/rule/execute.c main/rule/expand.c main/rule/instance.c main/rule/is.c main/rule/item.c main/rule/parameter.c main/rule/read.c main/rule/setting.c main/rule/validate.c main/rule/wait.c build_sources_library main/print/action.c main/print/data.c main/print/debug.c main/print/error.c main/print/lock.c main/print/message.c main/print/rule.c main/print/verbose.c main/print/warning.c +build_sources_library main/print/rule/action.c main/print/rule/item.c main/print/rule/setting.c build_sources_library main/signal.c main/time.c build_sources_library main/thread.c main/thread/control.c main/thread/entry.c main/thread/instance.c main/thread/is.c main/thread/rule.c @@ -57,6 +58,7 @@ build_sources_headers main/common/type/cache.h main/common/type/control.h main/c build_sources_headers main/instance.h main/path.h build_sources_headers main/rule.h main/rule/action.h main/rule/execute.h main/rule/expand.h main/rule/instance.h main/rule/is.h main/rule/item.h main/rule/parameter.h main/rule/read.h main/rule/setting.h main/rule/validate.h main/rule/wait.h build_sources_headers main/print/action.h main/print/data.h main/print/debug.h main/print/error.h main/print/lock.h main/print/message.h main/print/rule.h main/print/verbose.h main/print/warning.h +build_sources_headers main/print/rule/action.h main/print/rule/item.h main/print/rule/setting.h build_sources_headers main/signal.h main/time.h build_sources_headers main/thread.h main/thread/control.h main/thread/entry.h main/thread/instance.h main/thread/is.h main/thread/rule.h diff --git a/sources/c/controller/controller.c b/sources/c/controller/controller.c index 193120a..f81b2bd 100644 --- a/sources/c/controller/controller.c +++ b/sources/c/controller/controller.c @@ -25,7 +25,7 @@ extern "C" { return; } - // @todo controller_main(&data, &program); + // @todo controller_main(&data, &program); (also needs to include things like controller_main_thread()) if (main->setting.state.status == F_status_set_error(F_child)) return; if (main->setting.state.status == F_status_set_error(F_interrupt)) { diff --git a/sources/c/main/common.h b/sources/c/main/common.h index d75bcdc..5474eb4 100644 --- a/sources/c/main/common.h +++ b/sources/c/main/common.h @@ -26,7 +26,7 @@ extern "C" { * A subset of status codes (with error bit set). */ #ifndef _di_controller_main_error_simplify_ - extern f_status_t controller_main_error_simplify(const f_status_t status) F_attribute_visibility_internal_d; + extern f_status_t controller_main_error_simplify(const f_status_t status); #endif // _di_controller_main_error_simplify_ /** @@ -46,7 +46,7 @@ extern "C" { * The start range will be past the stop range on overflow or on any failure. */ #ifndef _di_controller_main_range_after_number_sign_ - extern f_range_t controller_main_range_after_number_sign(const f_string_static_t buffer, const f_range_t range) F_attribute_visibility_internal_d; + extern f_range_t controller_main_range_after_number_sign(const f_string_static_t buffer, const f_range_t range); #endif // _di_controller_main_range_after_number_sign_ /** diff --git a/sources/c/main/common/type/instance.h b/sources/c/main/common/type/instance.h index cec4d27..fa02e53 100644 --- a/sources/c/main/common/type/instance.h +++ b/sources/c/main/common/type/instance.h @@ -72,6 +72,9 @@ extern "C" { controller_rule_t rule; controller_cache_t cache; + // @fixme change this to void *global where global is controller_global_t?? + // @fixme each instance probably needs its own thread data and this likely needs to be backported if it do-able in a non-breaking-change manner! + // @fixme I may want to instead replace the controller_global_t with controller_instance_t during printing calls (maybe more??). void *main; controller_program_t *program; void *thread; diff --git a/sources/c/main/controller.h b/sources/c/main/controller.h index 6db00c5..b6a8ac2 100644 --- a/sources/c/main/controller.h +++ b/sources/c/main/controller.h @@ -110,6 +110,9 @@ #include #include #include +#include +#include +#include #include #include #include diff --git a/sources/c/main/print/error.c b/sources/c/main/print/error.c index 522f4e0..f23c975 100644 --- a/sources/c/main/print/error.c +++ b/sources/c/main/print/error.c @@ -56,62 +56,6 @@ extern "C" { } #endif // _di_controller_main_print_error_status_ -#ifndef _di_controller_main_print_error_rule_ - f_status_t controller_main_print_error_rule(fl_print_t * const print, const f_status_t status, const f_string_t function, const bool fallback, const bool item) { - - if (!print || !print->custom) return F_status_set_error(F_output_not); - if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - - // fll_error_print() automatically locks, so manually handle only the mutex locking and flushing rather than calling controller_lock_print(). - f_thread_mutex_lock(&global->thread->lock.print); - - controller_global_t * const global = (controller_global_t *) print->custom; // @fixme The print->custom is currently controller_main_t, but threads need to change this. Thread-specific print objects? - - fll_error_print(print, F_status_set_fine(global->main->setting.state.status), function, fll_error_file_flag_fallback_e); - - fll_error_print(print, status, function, fallback); - - f_file_stream_lock(print->to); - - controller_rule_print_error_cache(print, cache, item); - - controller_unlock_print_flush(print->to, thread); - - return F_okay; - } -#endif // _di_controller_main_print_error_rule_ - -#ifndef _di_controller_rule_print_error_cache_ - void controller_rule_print_error_cache(fl_print_t * const print, const controller_cache_action_t cache, const bool item) { - - if (print->verbosity == f_console_verbosity_quiet_e) return; - - fl_print_format("%r%[%QWhile processing ", print->to, f_string_eol_s, print->context, print->prefix); - - if (cache.name_action.used) { - fl_print_format("%r '%]", print->to, item ? controller_action_s : controller_value_s, print->context); - fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, cache.name_action, print->notable); - fl_print_format("%[' on line%] ", print->to, print->context, print->context); - fl_print_format("%[%un%]", print->to, print->notable, cache.line_action, print->notable); - fl_print_format("%[ for ", print->to, print->context); - } - - if (cache.name_item.used) { - fl_print_format("rule %r '%]", print->to, item ? controller_item_s : controller_settings_s, print->context); - fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, cache.name_item, print->notable); - fl_print_format("%[' on line%] ", print->to, print->context, print->context); - fl_print_format("%[%un%]", print->to, print->notable, cache.line_item, print->notable); - fl_print_format("%[ for ", print->to, print->context); - } - - if (cache.name_file.used) { - fl_print_format("rule file '%]%[%Q%]%['", print->to, print->context, print->notable, cache.name_file, print->notable, print->context); - } - - fl_print_format(".%]%r", print->to, print->context, f_string_eol_s); - } -#endif // _di_controller_rule_print_error_cache_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/sources/c/main/print/error.h b/sources/c/main/print/error.h index 29581ad..61fe780 100644 --- a/sources/c/main/print/error.h +++ b/sources/c/main/print/error.h @@ -154,11 +154,11 @@ extern "C" { * If FALSE, then this error is associated with a rule setting. * * @see fll_error_print() - * @see controller_rule_print_error_cache() + * @see controller_main_print_rule_error_cache() */ -#ifndef _di_controller_rule_print_error_ - extern void controller_rule_print_error(controller_thread_t * const thread, fl_print_t * const print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item) F_attribute_visibility_internal_d; -#endif // _di_controller_rule_print_error_ +#ifndef _di_controller_main_print_rule_error_ + extern void controller_main_print_rule_error(controller_thread_t * const thread, fl_print_t * const print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item); +#endif // _di_controller_main_print_rule_error_ /** * Print additional error/warning information in addition to existing error. @@ -181,9 +181,9 @@ extern "C" { * @see controller_rule_read() * @see controller_rule_setting_read() */ -#ifndef _di_controller_rule_print_error_cache_ - extern void controller_rule_print_error_cache(fl_print_t * const print, const controller_cache_action_t cache, const bool item) F_attribute_visibility_internal_d; -#endif // _di_controller_rule_print_error_cache_ +#ifndef _di_controller_main_print_rule_error_cache_ + extern void controller_main_print_rule_error_cache(fl_print_t * const print, const controller_cache_action_t cache, const bool item); +#endif // _di_controller_main_print_rule_error_cache_ #ifdef __cplusplus } // extern "C" diff --git a/sources/c/main/print/rule.c b/sources/c/main/print/rule.c index f2d125c..ebd3627 100644 --- a/sources/c/main/print/rule.c +++ b/sources/c/main/print/rule.c @@ -4,137 +4,63 @@ extern "C" { #endif -#ifndef _di_controller_main_print_rule_debug_item_action_empty_ - f_status_t controller_main_print_rule_debug_item_action_empty(fl_print_t * const print, controller_cache_t * const cache) { +#ifndef _di_controller_main_print_rule_error_ + f_status_t controller_main_print_rule_error(fl_print_t * const print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item) { - if (!print || !cache) return F_status_set_error(F_output_not); - if (print->verbosity < f_console_verbosity_debug_e) return F_output_not; - - controller_lock_print(print->to, global->thread); - - fl_print_format("%r%[%QAction is empty, nothing to do.%]%r", primt->to, f_string_eol_s, print->context, print->prefix, print->context, f_string_eol_s); - - controller_rule_print_rule_message_cache(print, cache->action, F_true); - - controller_unlock_print_flush(print->to, global->thread); - - return F_okay; - } -#endif // _di_controller_main_print_rule_debug_item_action_empty_ - -#ifndef _di_controller_main_print_rule_error_item_action_first_ - f_status_t controller_main_print_rule_error_item_action_first(fl_print_t * const print, controller_cache_t * const cache) { - - if (!print || !cache) return F_status_set_error(F_output_not); + 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_lock_print(print->to, global->thread); - - fl_print_format("%r%[%QRule item action '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); - fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, controller_rerun_s, print->notable); - fl_print_format("%[' has '%]", print->to, print->context, print->context); - fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, cache->buffer_item, cache->content_action.array[0], print->notable); - fl_print_format("%[' as the first value, only the following are allowed: '%]", print->to, print->context, print->context); - fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_freeze_s, print->notable, print->context, print->context); - fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_kill_s, print->notable, print->context, print->context); - fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_pause_s, print->notable, print->context, print->context); - fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_reload_s, print->notable, print->context, print->context); - fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_restart_s, print->notable, print->context, print->context); - fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_resume_s, print->notable, print->context, print->context); - fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_start_s, print->notable, print->context, print->context); - fl_print_format("%[%r%]%[', or '%]", print->to, print->notable, controller_stop_s, print->notable, print->context, print->context); - fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, controller_thaw_s, print->notable, print->context); - fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s); - - controller_rule_print_rule_message_cache(print, cache->action, F_true); - - controller_unlock_print_flush(print->to, global->thread); - - return F_okay; - } -#endif // _di_controller_main_print_rule_error_item_action_first_ - -#ifndef _di_controller_main_print_rule_error_item_action_second_ - f_status_t controller_main_print_rule_error_item_action_second(fl_print_t * const print, controller_cache_t * const cache) { + controller_global_t * const global = (controller_global_t *) print->custom; - if (!print || !cache) return F_status_set_error(F_output_not); - if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + // fll_error_print() automatically locks, so manually handle only the mutex locking and flushing rather than calling controller_lock_print(). + f_thread_mutex_lock(&global->thread->lock.print); - controller_lock_print(print->to, global->thread); + fll_error_print(print, status, function, fallback); - fl_print_format("%r%[%QRule item action '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); - fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, controller_rerun_s, print->notable); - fl_print_format("%[' has '%]", print->to, print->context, print->context); - fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, cache->buffer_item, cache->content_action.array[1], print->notable); - fl_print_format("%[' as the second value, only the following are allowed: '%]", print->to, print->context, print->context); - fl_print_format("%[%r%]%[' or '%]", print->to, print->notable, controller_stop_s, print->notable, print->context, print->context); - fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, controller_thaw_s, print->notable, print->context); - fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s); + f_file_stream_lock(print->to); - controller_rule_print_rule_message_cache(print, cache->action, F_true); + controller_main_print_rule_error_cache(print, cache, item); controller_unlock_print_flush(print->to, global->thread); return F_okay; } -#endif // _di_controller_main_print_rule_error_item_action_second_ +#endif // _di_controller_main_print_rule_error_ -#ifndef _di_controller_main_print_rule_error_item_action_unknown_ - f_status_t controller_main_print_rule_error_item_action_unknown(fl_print_t * const print, controller_cache_t * const cache, const f_string_static_t name, const f_number_unsigned_t index) { +#ifndef _di_controller_main_print_rule_error_cache_ + f_status_t controller_main_print_rule_error_cache(fl_print_t * const print, const controller_cache_action_t cache, const bool item) { - if (!print || !cache) return F_status_set_error(F_output_not); + if (!print) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - controller_lock_print(print->to, global->thread); - - fl_print_format("%r%[%QRule item action '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); - fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, name, print->notable); - fl_print_format("%[' has an unknown value '%]", print->to, print->context, print->context); - fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, cache->buffer_item, cache->content_action.array[index], print->notable); - fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s); - - controller_rule_print_rule_message_cache(print, cache->action, F_true); - - controller_unlock_print_flush(print->to, global->thread); - - return F_okay; - } -#endif // _di_controller_main_print_rule_error_item_action_unknown_ - -#ifndef _di_controller_rule_print_rule_message_cache_ - f_status_t controller_rule_print_rule_message_cache(fl_print_t * const print, controller_cache_action_t * const cache, const bool item) { - - if (!print || !cache) return F_status_set_error(F_output_not); - - if (print->verbosity == f_console_verbosity_quiet_e) return; - fl_print_format("%r%[%QWhile processing ", print->to, f_string_eol_s, print->context, print->prefix); - if (cache->name_action.used) { + if (cache.name_action.used) { fl_print_format("%r '%]", print->to, item ? controller_action_s : controller_value_s, print->context); - fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, cache->name_action, print->notable); + fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, cache.name_action, print->notable); fl_print_format("%[' on line%] ", print->to, print->context, print->context); - fl_print_format("%[%un%]", print->to, print->notable, cache->line_action, print->notable); + fl_print_format(f_string_format_un_single_s.string, print->to, print->notable, cache.line_action, print->notable); fl_print_format("%[ for ", print->to, print->context); } - if (cache->name_item.used) { + if (cache.name_item.used) { fl_print_format("rule %r '%]", print->to, item ? controller_item_s : controller_settings_s, print->context); - fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, cache->name_item, print->notable); + fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, cache.name_item, print->notable); fl_print_format("%[' on line%] ", print->to, print->context, print->context); - fl_print_format("%[%un%]", print->to, print->notable, cache->line_item, print->notable); + fl_print_format(f_string_format_un_single_s.string", print->to, print->notable, cache.line_item, print->notable); fl_print_format("%[ for ", print->to, print->context); } - if (cache->name_file.used) { - fl_print_format("rule file '%]%[%Q%]%['", print->to, print->context, print->notable, cache->name_file, print->notable, print->context); + if (cache.name_file.used) { + fl_print_format("rule file '%]%[%Q%]%['", print->to, print->context, print->notable, cache.name_file, print->notable, print->context); } fl_print_format(".%]%r", print->to, print->context, f_string_eol_s); return F_okay; } -#endif // _di_controller_rule_print_rule_message_cache_ +#endif // _di_controller_main_print_rule_error_cache_ #ifdef __cplusplus } // extern "C" diff --git a/sources/c/main/print/rule.h b/sources/c/main/print/rule.h index 71db437..f2a02d7 100644 --- a/sources/c/main/print/rule.h +++ b/sources/c/main/print/rule.h @@ -17,144 +17,57 @@ extern "C" { #endif /** - * Print rule debug message about the rule item action being empty. + * Print generic error/warning information. * - * @param print - * The output structure to print to. - * Must not be NULL. - * @param cache - * A structure for containing and caching relevant data. - * 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 fl_print_format() - * @see fll_error_print() - * - * @see controller_lock_print() - * @see controller_rule_print_rule_message_cache() - * @see controller_unlock_print_flush() - */ -#ifndef _di_controller_main_print_rule_debug_item_action_empty_ - extern f_status_t controller_main_print_rule_debug_item_action_empty(fl_print_t * const print, controller_cache_t * const cache); -#endif // _di_controller_main_print_rule_debug_item_action_empty_ - -/** - * Print rule error message about the first rule item action parameter being invalid. + * This is essentially a wrapper to fll_error_print() that includes locking. * * @param print - * The output structure to print to. - * Must not be NULL. + * Designates how printing is to be performed. * @param cache - * A structure for containing and caching relevant data. - * 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. + * 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. + * Set to 0 to disable. + * @param fallback + * Set to F_true to print the fallback error message for unknown errors. + * @param item + * If TRUE, then this error is associated with an item. + * If FALSE, then this error is associated with a rule setting. * - * @see fl_print_format() * @see fll_error_print() - * - * @see controller_lock_print() - * @see controller_rule_print_rule_message_cache() - * @see controller_unlock_print_flush() + * @see controller_main_print_rule_error_cache() */ -#ifndef _di_controller_main_print_rule_error_item_action_first_ - extern f_status_t controller_main_print_rule_error_item_action_first(fl_print_t * const print, controller_cache_t * const cache); -#endif // _di_controller_main_print_rule_error_item_action_first_ +#ifndef _di_controller_main_print_rule_error_ + extern void controller_main_print_rule_error(fl_print_t * const print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item); +#endif // _di_controller_main_print_rule_error_ /** - * Print rule error message about the second rule item action parameter being invalid. - * - * @param print - * The output structure to print to. - * Must not be NULL. - * @param cache - * A structure for containing and caching relevant data. - * Must not be NULL. + * Print additional error/warning information in addition to existing error. * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. + * This is explicitly intended to be used in addition to the error message. * - * F_output_not (with error bit) if setting is NULL. - * - * @see fl_print_format() - * @see fll_error_print() - * - * @see controller_lock_print() - * @see controller_rule_print_rule_message_cache() - * @see controller_unlock_print_flush() - */ -#ifndef _di_controller_main_print_rule_error_item_action_second_ - extern f_status_t controller_main_print_rule_error_item_action_second(fl_print_t * const print, controller_cache_t * const cache); -#endif // _di_controller_main_print_rule_error_item_action_second_ - -/** - * Print rule error message about the rule item action being unknown. - * - * @param print - * The output structure to print to. - * Must not be NULL. - * @param cache - * A structure for containing and caching relevant data. - * Must not be NULL. - * @param name - * The parameter name whose value is unknown. - * @param index - * The index in the content action cache representing the unknown value. - * - * @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 fl_print_format() - * @see fll_error_print() - * - * @see controller_lock_print() - * @see controller_rule_print_rule_message_cache() - * @see controller_unlock_print_flush() - */ -#ifndef _di_controller_main_print_rule_error_item_action_unknown_ - extern f_status_t controller_main_print_rule_error_item_action_unknown(fl_print_t * const print, controller_cache_t * const cache, const f_string_static_t name, const f_number_unsigned_t index); -#endif // _di_controller_main_print_rule_error_item_action_unknown_ - -/** - * Print rule error message about the rule item action being unknown. + * 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. - * Must not be NULL. - * - * This does not lock the stream. + * The error or warning output structure. * @param cache * A structure for containing and caching relevant data. - * Must not be NULL. - * @param name - * The parameter name related to the message. - * @param index - * The index in the content action cache representing the parameter value related to the message. - * - * @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 fl_print_format() + * @param item + * If TRUE, then this error is associated with an item. + * If FALSE, then this error is associated with a rule setting. + * + * @see controller_rule_action_read() + * @see controller_rule_item_read() + * @see controller_rule_items_read() + * @see controller_rule_read() + * @see controller_rule_setting_read() */ -#ifndef _di_controller_rule_print_rule_message_cache_ - extern f_status_t controller_rule_print_rule_message_cache(fl_print_t * const print, controller_cache_action_t * const cache, const bool item); -#endif // _di_controller_rule_print_rule_message_cache_ +#ifndef _di_controller_main_print_rule_error_cache_ + extern void controller_main_print_rule_error_cache(fl_print_t * const print, const controller_cache_action_t cache, const bool item); +#endif // _di_controller_main_print_rule_error_cache_ #ifdef __cplusplus } // extern "C" diff --git a/sources/c/main/print/rule/action.c b/sources/c/main/print/rule/action.c new file mode 100644 index 0000000..61c0b35 --- /dev/null +++ b/sources/c/main/print/rule/action.c @@ -0,0 +1,20 @@ +#include "../../controller.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_controller_main_print_rule_action_error_missing_pid_ + void controller_main_print_rule_action_error_missing_pid(fl_print_t * const print, const f_string_static_t alias) { + + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + fl_print_format("%r%[%QThe rule '%]", 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, alias, print->notable); + fl_print_format("%[' is not designating a pid file.%]%r", print->to, print->context, print->context, f_string_eol_s); + } +#endif // _di_controller_main_print_rule_action_error_missing_pid_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/main/print/rule/action.h b/sources/c/main/print/rule/action.h new file mode 100644 index 0000000..c29843d --- /dev/null +++ b/sources/c/main/print/rule/action.h @@ -0,0 +1,35 @@ +/** + * FLL - Level 3 + * + * Project: Controller + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print rule action functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _controller_main_print_rule_action_h +#define _controller_main_print_rule_action_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print an error or warning message about some rule not having the pid file information. + * + * @param print + * The error or warning output structure. + * @param alias + * The rule alias of the rule that is missing the pid file designation. + */ +#ifndef _di_controller_main_print_rule_action_error_missing_pid_ + extern void controller_main_print_rule_action_error_missing_pid(fl_print_t * const print, const f_string_static_t alias); +#endif // _di_controller_main_print_rule_action_error_missing_pid_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _controller_main_print_rule_action_h diff --git a/sources/c/main/print/rule/item.c b/sources/c/main/print/rule/item.c new file mode 100644 index 0000000..ee0793f --- /dev/null +++ b/sources/c/main/print/rule/item.c @@ -0,0 +1,408 @@ +#include "../../controller.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_controller_main_print_rule_item_debug_action_empty_ + f_status_t controller_main_print_rule_item_debug_action_empty(fl_print_t * const print, controller_cache_t * const cache) { + + if (!print || !print->custom || !cache) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_debug_e) return F_output_not; + + controller_global_t * const global = (controller_global_t *) print->custom; + + controller_lock_print(print->to, global->thread); + + fl_print_format("%r%[%QAction is empty, nothing to do.%]%r", primt->to, f_string_eol_s, print->context, print->prefix, print->context, f_string_eol_s); + + controller_main_print_rule_error_cache(print, cache->action, F_true); + + controller_unlock_print_flush(print->to, global->thread); + + return F_okay; + } +#endif // _di_controller_main_print_rule_item_debug_action_empty_ + +#ifndef _di_controller_main_print_rule_item_error_ + void controller_main_print_rule_item_error(fl_print_t * const print, const controller_cache_action_t cache, const bool item, const f_status_t status) { + + 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_global_t * const global = (controller_global_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(&global->thread->lock.print); + + controller_main_print_rule_error_cache(print, cache, item); + + f_file_stream_lock(print->to); + + controller_unlock_print_flush(print->to, global->thread); + } +#endif // _di_controller_main_print_rule_item_error_ + +#ifndef _di_controller_main_print_rule_item_error_action_first_ + f_status_t controller_main_print_rule_item_error_action_first(fl_print_t * const print, controller_cache_t * const cache) { + + if (!print || !print->custom || !cache) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + controller_global_t * const global = (controller_global_t *) print->custom; + + controller_lock_print(print->to, global->thread); + + fl_print_format("%r%[%QRule item action '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, controller_rerun_s, print->notable); + fl_print_format("%[' has '%]", print->to, print->context, print->context); + fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, cache->buffer_item, cache->content_action.array[0], print->notable); + fl_print_format("%[' as the first value, only the following are allowed: '%]", print->to, print->context, print->context); + fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_freeze_s, print->notable, print->context, print->context); + fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_kill_s, print->notable, print->context, print->context); + fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_pause_s, print->notable, print->context, print->context); + fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_reload_s, print->notable, print->context, print->context); + fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_restart_s, print->notable, print->context, print->context); + fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_resume_s, print->notable, print->context, print->context); + fl_print_format("%[%r%]%[', '%]", print->to, print->notable, controller_start_s, print->notable, print->context, print->context); + fl_print_format("%[%r%]%[', or '%]", print->to, print->notable, controller_stop_s, print->notable, print->context, print->context); + fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, controller_thaw_s, print->notable, print->context); + fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s); + + controller_main_print_rule_error_cache(print, cache->action, F_true); + + controller_unlock_print_flush(print->to, global->thread); + + return F_okay; + } +#endif // _di_controller_main_print_rule_item_error_action_first_ + +#ifndef _di_controller_main_print_rule_item_error_action_second_ + f_status_t controller_main_print_rule_item_error_action_second(fl_print_t * const print, controller_cache_t * const cache) { + + if (!print || !print->custom || !cache) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + controller_global_t * const global = (controller_global_t *) print->custom; + + controller_lock_print(print->to, global->thread); + + fl_print_format("%r%[%QRule item action '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, controller_rerun_s, print->notable); + fl_print_format("%[' has '%]", print->to, print->context, print->context); + fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, cache->buffer_item, cache->content_action.array[1], print->notable); + fl_print_format("%[' as the second value, only the following are allowed: '%]", print->to, print->context, print->context); + fl_print_format("%[%r%]%[' or '%]", print->to, print->notable, controller_stop_s, print->notable, print->context, print->context); + fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, controller_thaw_s, print->notable, print->context); + fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s); + + controller_main_print_rule_error_cache(print, cache->action, F_true); + + controller_unlock_print_flush(print->to, global->thread); + + return F_okay; + } +#endif // _di_controller_main_print_rule_item_error_action_second_ + +#ifndef _di_controller_main_print_rule_item_error_action_unknown_ + f_status_t controller_main_print_rule_item_error_action_unknown(fl_print_t * const print, controller_cache_t * const cache, const f_string_static_t name, const f_number_unsigned_t index) { + + if (!print || !print->custom || !cache) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + controller_global_t * const global = (controller_global_t *) print->custom; + + controller_lock_print(print->to, global->thread); + + fl_print_format("%r%[%QRule item action '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, name, print->notable); + fl_print_format("%[' has an unknown value '%]", print->to, print->context, print->context); + fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, cache->buffer_item, cache->content_action.array[index], print->notable); + fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s); + + controller_main_print_rule_error_cache(print, cache->action, F_true); + + controller_unlock_print_flush(print->to, global->thread); + + return F_okay; + } +#endif // _di_controller_main_print_rule_item_error_action_unknown_ + +#ifndef _di_controller_main_print_rule_item_error_execute_ + void controller_main_print_rule_item_error_execute(fl_print_t * const print, controller_instance_t * const instance, const bool script_is, const f_string_static_t name, const f_status_t status) { + + 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_global_t * const global = (controller_global_t *) print->custom; + + controller_lock_print(print->to, global->thread); + + fl_print_format("%r%[%QThe %r '%]", print->to, f_string_eol_s, print->context, print->prefix, script_is ? controller_engine_s : controller_program_s, print->context); + fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, name, print->notable); + + if (status == F_control_group || status == F_limit || status == F_processor || status == F_schedule) { + fl_print_format("%[' failed to setup the '%]%[", print->to, print->context, print->context, print->notable); + + if (status == F_control_group) { + f_print_dynamic_raw(controller_cgroup_s, print->to); + } + else if (status == F_limit) { + f_print_dynamic_raw(controller_limit_s, print->to); + } + else if (status == F_processor) { + f_print_dynamic_raw(controller_processor_s, print->to); + } + else if (status == F_schedule) { + f_print_dynamic_raw(controller_scheduler_s, print->to); + } + + fl_print_format("%]%['.%]%r", print->to, print->notable, print->context, print->context, f_string_eol_s); + } + else if (WIFEXITED(process->result) ? WEXITSTATUS(process->result) : 0) { + const uint8_t code = WIFEXITED(process->result) ? WEXITSTATUS(process->result) : 0; + + if (code == F_execute_access) { + fl_print_format("%[' failed, access is denied.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_bad) { + fl_print_format("%[' failed, unsupported format.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_buffer) { + fl_print_format("%[' invalid memory access in arguments buffer.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_busy) { + fl_print_format("%[' required resources are unavailable, too busy.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_capability) { + fl_print_format("%[' failed to setup capabilities.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_control_group) { + fl_print_format("%[' failed to setup control group.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_child) { + fl_print_format("%[' failed to setup child process.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_directory_not) { + fl_print_format("%[' invalid path, part of the path is not a valid directory.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_failure) { + fl_print_format("%[' failed during execution.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_file_found_not) { + fl_print_format("%[' failed, unable to find file.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_file_type_directory) { + fl_print_format("%[' ELF interpreter is a directory.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_fork_not) { + fl_print_format("%[' fork failure.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_format_not) { + fl_print_format("%[' could not be executed because the program has an invalid ELF header.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_group) { + fl_print_format("%[' failed to setup group.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_input_output) { + fl_print_format("%[' I/O failure.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_limit) { + fl_print_format("%[' failed to setup resource limits.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_loop) { + fl_print_format("%[' max recursion reached.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_memory_not) { + fl_print_format("%[' is out of memory.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_name_not) { + fl_print_format("%[' file name or path is too long.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_nice) { + fl_print_format("%[' failed to setup niceness.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_parameter) { + fl_print_format("%[' failed due to an invalid parameter.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_pipe) { + fl_print_format("%[' pipe failed.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_processor) { + fl_print_format("%[' failed to setup processor affinity.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_prohibited) { + fl_print_format("%[' access prohibited.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_resource_not) { + fl_print_format("%[' resource limit reached.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_schedule) { + fl_print_format("%[' failed to setup scheduler.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_terminal) { + fl_print_format("%[' failed while processing the terminal.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_terminal_known_not) { + fl_print_format("%[' cannot process terminal, unknown terminal control command.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_terminal_not) { + fl_print_format("%[' cannot process terminal, not a known terminal.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_terminal_prohibited) { + fl_print_format("%[' insufficient permissions to process the terminal.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_terminal_valid_not) { + fl_print_format("%[' invalid parameter while processing the terminal.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_too_large) { + fl_print_format("%[' too many arguments or arguments are too large.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_user) { + fl_print_format("%[' failed to setup user.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_valid_not) { + fl_print_format("%[' unknown ELF interpreter format.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_invoke_not) { + fl_print_format("%[' cannot execute command.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_found_not) { + fl_print_format("%[' command not found.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_found_not) { + fl_print_format("%[' invalid argument to exit().%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_hangup) { + fl_print_format("%[' hang up signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_interrupt) { + fl_print_format("%[' interrupt signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_quit) { + fl_print_format("%[' quit signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_illegal) { + fl_print_format("%[' illegal signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_trap) { + fl_print_format("%[' trap signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_abort) { + fl_print_format("%[' abort signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_bus_error) { + fl_print_format("%[' bus error signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_floating_point_error) { + fl_print_format("%[' floating point error signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_kill) { + fl_print_format("%[' kill signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_user_1) { + fl_print_format("%[' user 1 signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_segmentation_fault) { + fl_print_format("%[' segmentation fault signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_user_2) { + fl_print_format("%[' user 2 signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_broken_pipe) { + fl_print_format("%[' broken pipe signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_alarm_clock) { + fl_print_format("%[' alarm clock signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_termination) { + fl_print_format("%[' terminate signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_stack_fault) { + fl_print_format("%[' stack fault signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_child) { + fl_print_format("%[' child signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_continue) { + fl_print_format("%[' continue signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_stop) { + fl_print_format("%[' stop signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_keyboard_stop) { + fl_print_format("%[' keyboard stop signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_tty_in) { + fl_print_format("%[' TTY in signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_tty_out) { + fl_print_format("%[' TTY out signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_urgent) { + fl_print_format("%[' urgent signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_cpu_limit) { + fl_print_format("%[' CPU limit signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_file_size_limit) { + fl_print_format("%[' file size signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_virtual_alarm_clock) { + fl_print_format("%[' virtual alarm clock signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_profile_alarm_clock) { + fl_print_format("%[' profile alarm clock signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_window_size_change) { + fl_print_format("%[' window size change signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_pollable_event) { + fl_print_format("%[' pollable signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_power_failure) { + fl_print_format("%[' power failure signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else if (code == F_execute_signal_bad_system_call) { + fl_print_format("%[' bad system call signal received.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + else { + fl_print_format("%[' failed with the execute error code %]", print->to, print->context, print->context); + fl_print_format("%[%i%]", print->to, print->notable, code, print->notable); + fl_print_format(f_string_format_sentence_end_s.string, print->to, print->context, print->context, f_string_eol_s); + } + } + else { + fl_print_format("%[' failed.%]%r", print->to, print->context, print->context, f_string_eol_s); + } + + controller_unlock_print_flush(print->to, global->thread); + } +#endif // _di_controller_main_print_rule_item_error_execute_ + +#ifndef _di_controller_main_print_rule_item_error_need_want_wish_ + void controller_main_print_rule_item_error_need_want_wish(fl_print_t * const print, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why) { + + if (print->verbosity == f_console_verbosity_quiet_e) return; + + fl_print_format("%r%[%QThe %r rule '%]", print->to, f_string_eol_s, print->context, print->prefix, need_want_wish, print->context); + fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, value, print->notable); + fl_print_format("%[' %S.%]%r", print->to, print->context, why, print->context, f_string_eol_s); + } +#endif // _di_controller_main_print_rule_item_error_need_want_wish_ + +#ifndef _di_controller_main_print_rule_item_error_rule_not_loaded_ + void controller_main_print_rule_item_error_rule_not_loaded(fl_print_t * const print, const f_string_static_t alias) { + + if (print->verbosity == f_console_verbosity_quiet_e) return; + + fl_print_format("%r%[%QThe rule '%]", 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, alias, print->notable); + fl_print_format("%[' is no longer loaded.%]%r", print->to, print->context, print->context, f_string_eol_s); + } +#endif // _di_controller_main_print_rule_item_error_rule_not_loaded_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/main/print/rule/item.h b/sources/c/main/print/rule/item.h new file mode 100644 index 0000000..38d744f --- /dev/null +++ b/sources/c/main/print/rule/item.h @@ -0,0 +1,210 @@ +/** + * FLL - Level 3 + * + * Project: Controller + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print rule item functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _controller_main_print_rule_item_h +#define _controller_main_print_rule_item_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print rule debug message about the rule item action being empty. + * + * @param print + * The output structure to print to. + * Must not be NULL. + * @param cache + * A structure for containing and caching relevant data. + * 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 fl_print_format() + * @see fll_error_print() + * + * @see controller_lock_print() + * @see controller_main_print_rule_error_cache() + * @see controller_unlock_print_flush() + */ +#ifndef _di_controller_main_print_rule_item_debug_action_empty_ + extern f_status_t controller_main_print_rule_item_debug_action_empty(fl_print_t * const print, controller_cache_t * const cache); +#endif // _di_controller_main_print_rule_item_debug_action_empty_ + +/** + * Print additional error/warning information in addition to existing error. + * + * This is explicitly intended to be used in addition to the error message. + * + * @param print + * The error or warning print structure. + * @param cache + * A structure for containing and caching relevant data. + * @param item + * If TRUE, then this error is associated with an item. + * If FALSE, then this error is associated with a rule setting. + * @param status + * The status code representing the failure (without the error bit set). + * + * @see controller_main_print_rule_error_cache() + */ +#ifndef _di_controller_main_print_rule_item_error_ + extern void controller_main_print_rule_item_error(fl_print_t * const print, const controller_cache_action_t cache, const bool item, const f_status_t status); +#endif // _di_controller_main_print_rule_item_error_ + +/** + * Print rule error message about the first rule item action parameter being invalid. + * + * @param print + * The output structure to print to. + * Must not be NULL. + * @param cache + * A structure for containing and caching relevant data. + * 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 fl_print_format() + * @see fll_error_print() + * + * @see controller_lock_print() + * @see controller_main_print_rule_error_cache() + * @see controller_unlock_print_flush() + */ +#ifndef _di_controller_main_print_rule_item_error_action_first_ + extern f_status_t controller_main_print_rule_item_error_action_first(fl_print_t * const print, controller_cache_t * const cache); +#endif // _di_controller_main_print_rule_item_error_action_first_ + +/** + * Print rule error message about the second rule item action parameter being invalid. + * + * @param print + * The output structure to print to. + * Must not be NULL. + * @param cache + * A structure for containing and caching relevant data. + * 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 fl_print_format() + * @see fll_error_print() + * + * @see controller_lock_print() + * @see controller_main_print_rule_error_cache() + * @see controller_unlock_print_flush() + */ +#ifndef _di_controller_main_print_rule_item_error_action_second_ + extern f_status_t controller_main_print_rule_item_error_action_second(fl_print_t * const print, controller_cache_t * const cache); +#endif // _di_controller_main_print_rule_item_error_action_second_ + +/** + * Print rule error message about the rule item action being unknown. + * + * @param print + * The output structure to print to. + * Must not be NULL. + * @param cache + * A structure for containing and caching relevant data. + * Must not be NULL. + * @param name + * The parameter name whose value is unknown. + * @param index + * The index in the content action cache representing the unknown value. + * + * @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 fl_print_format() + * @see fll_error_print() + * + * @see controller_lock_print() + * @see controller_main_print_rule_error_cache() + * @see controller_unlock_print_flush() + */ +#ifndef _di_controller_main_print_rule_item_error_action_unknown_ + extern f_status_t controller_main_print_rule_item_error_action_unknown(fl_print_t * const print, controller_cache_t * const cache, const f_string_static_t name, const f_number_unsigned_t index); +#endif // _di_controller_main_print_rule_item_error_action_unknown_ + +/** + * Print an error or warning message related to the failed execution of some program or script. + * + * @param print + * The output structure to print to. + * + * Must not be NULL. + * @param instance + * The process instance. + * + * Must not be NULL. + * @param script_is + * If TRUE, then this represents a script. + * If FALSE, then this represents a program. + * @param name + * The name of the program or script. + * @param code + * The code returned by the executed program or script. + * @param status + * The status code representing the failure (without the error bit set). + */ +#ifndef _di_controller_main_print_rule_item_error_execute_ + extern void controller_main_print_rule_item_error_execute(fl_print_t * const print, controller_instance_t * const instance, const bool script_is, const f_string_static_t name, const f_status_t status); +#endif // _di_controller_main_print_rule_item_error_execute_ + +/** + * Print an error or warning message related to need/want/wish settings of some rule. + * + * @param print + * The error or warning output structure. + * @param need_want_wish + * The appropriate string, such as "needs", "wants", or "wishes for" to output when describing this error/warning. + * This string is expected to already be "safe" (no control characters, etc..). + * @param value + * The value that is the error or warning. + * @param why + * A short explanation on why this is an error or warning. + */ +#ifndef _di_controller_main_print_rule_item_error_need_want_wish_ + extern void controller_main_print_rule_item_error_need_want_wish(fl_print_t * const print, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why); +#endif // _di_controller_main_print_rule_item_error_need_want_wish_ + +/** + * Print an error or warning message about some rule not being loaded. + * + * @param print + * The error or warning output structure. + * @param alias + * The rule alias of the rule that is not loaded. + */ +#ifndef _di_controller_main_print_rule_item_error_rule_not_loaded_ + extern void controller_main_print_rule_item_error_rule_not_loaded(fl_print_t * const print, const f_string_static_t alias); +#endif // _di_controller_main_print_rule_item_error_rule_not_loaded_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _controller_main_print_rule_item_h diff --git a/sources/c/main/print/rule/setting.c b/sources/c/main/print/rule/setting.c new file mode 100644 index 0000000..87977fe --- /dev/null +++ b/sources/c/main/print/rule/setting.c @@ -0,0 +1,144 @@ +#include "../../controller.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_controller_main_print_rule_setting_read_error_ + void controller_main_print_rule_setting_read_error(fl_print_t * const print, const f_string_t message, const f_number_unsigned_t index, const f_number_unsigned_t line_item, controller_thread_t * const thread, controller_cache_t * const cache) { + + if (!print->custom) return; + if (print->verbosity == f_console_verbosity_quiet_e) return; + + controller_main_t * const main = (controller_main_t *) print->custom; + + f_state_t state = f_state_t_initialize; + + // Get the current line number within the settings item. + cache->action.line_item = line_item; + f_fss_count_lines(cache->buffer_item, cache->object_actions.array[index].start, &cache->action.line_item, &main->setting.state); + + cache->action.line_action = ++cache->action.line_item; + + controller_lock_print(print->to, thread); + + fl_print_format("%r%[%QRule setting %S.%]%r", print->to, f_string_eol_s, print->context, print->prefix, message, print->context, f_string_eol_s); + + controller_main_print_rule_error_cache(print, cache->action, F_false); + + controller_unlock_print_flush(print->to, thread); + } +#endif // _di_controller_main_print_rule_setting_read_error_ + +#ifndef _di_controller_main_print_rule_setting_read_error_with_range_ + void controller_main_print_rule_setting_read_error_with_range(fl_print_t * const print, const f_string_t before, const f_range_t range, const f_string_t after, const f_number_unsigned_t index, const f_number_unsigned_t line_item, controller_thread_t * const thread, controller_cache_t * const cache) { + + if (!print->custom) return; + if (print->verbosity == f_console_verbosity_quiet_e) return; + + controller_main_t * const main = (controller_main_t *) print->custom; + + f_state_t state = f_state_t_initialize; + + // Get the current line number within the settings item. + cache->action.line_item = line_item; + f_fss_count_lines(cache->buffer_item, cache->object_actions.array[index].start, &cache->action.line_item, &main->setting.state); + + cache->action.line_action = ++cache->action.line_item; + + controller_lock_print(print->to, thread); + + fl_print_format("%r%[%QRule setting%S '%]", print->to, f_string_eol_s, print->context, print->prefix, before, print->context); + fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, cache->buffer_item, range, print->notable); + fl_print_format("%['%S.%]%r", print->to, print->context, after, print->context, f_string_eol_s); + + controller_main_print_rule_error_cache(print, cache->action, F_false); + + controller_unlock_print_flush(print->to, thread); + } +#endif // _di_controller_main_print_rule_setting_read_error_with_range_ + +#ifndef _di_controller_main_print_rule_setting_read_mapping_ + void controller_main_print_rule_setting_read_mapping(const controller_global_t global, const f_string_static_t name, const f_string_map_t map) { + + if (global.main->program.error.verbosity != f_console_verbosity_debug_e) { + if (!(global.main->program.error.verbosity == f_console_verbosity_verbose_e && (global.main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) { + return; + } + } + + controller_lock_print(global.main->program.output.to, global.thread); + + fl_print_format("%rProcessing rule item action '%[%Q%]'", global.main->program.output.to, f_string_eol_s, global.main->program.context.set.title, name, global.main->program.context.set.title); + fl_print_format(" mapping '%[%Q%]'", global.main->program.output.to, global.main->program.context.set.important, map.key, global.main->program.context.set.important); + fl_print_format(" to value '%[%Q%]'.%r", global.main->program.output.to, global.main->program.context.set.important, map.value, global.main->program.context.set.important, f_string_eol_s); + + controller_unlock_print_flush(global.main->program.output.to, global.thread); + } +#endif // _di_controller_main_print_rule_setting_read_mapping_ + +#ifndef _di_controller_main_print_rule_setting_read_value_ + void controller_main_print_rule_setting_read_value(const controller_global_t global, 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 (global.main->program.error.verbosity != f_console_verbosity_debug_e) { + if (!(global.main->program.error.verbosity == f_console_verbosity_verbose_e && (global.main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) { + return; + } + } + + controller_lock_print(global.main->program.output.to, global.thread); + + fl_print_format("%rProcessing rule item action '%[%Q%]' setting ", global.main->program.output.to, f_string_eol_s, global.main->program.context.set.title, name, global.main->program.context.set.title); + + if (name_sub.used) { + fl_print_format("'%[%Q%]'", global.main->program.output.to, global.main->program.context.set.notable, name_sub, global.main->program.context.set.notable); + } + else { + f_print_terminated("value", global.main->program.output.to); + } + + fl_print_format(" to '%[%Q%]'", global.main->program.output.to, global.main->program.context.set.important, value, global.main->program.context.set.important); + fl_print_format("%S.%r", global.main->program.output.to, suffix, f_string_eol_s); + + controller_unlock_print_flush(global.main->program.output.to, global.thread); + } +#endif // _di_controller_main_print_rule_setting_read_value_ + +#ifndef _di_controller_main_print_rule_setting_read_values_ + void controller_main_print_rule_setting_read_values(const controller_global_t global, const f_string_static_t name, const f_number_unsigned_t index, controller_cache_t * const cache) { + + if (global.main->program.error.verbosity != f_console_verbosity_debug_e) { + if (!(global.main->program.error.verbosity == f_console_verbosity_verbose_e && (global.main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) { + return; + } + } + + controller_lock_print(global.main->program.output.to, global.thread); + + fl_print_format("%rProcessing rule item action '%[%Q%]' setting value to", global.main->program.output.to, f_string_eol_s, global.main->program.context.set.title, name, global.main->program.context.set.title); + + for (f_number_unsigned_t j = 0; j < cache->content_actions.array[index].used; ++j) { + + fl_print_format(" '%[%/Q%]'", global.main->program.output.to, global.main->program.context.set.important, cache->buffer_item, cache->content_actions.array[index].array[j], global.main->program.context.set.important); + + if (j + 2 == cache->content_actions.array[index].used) { + if (cache->content_actions.array[index].used > 2) { + f_print_terminated(",", global.main->program.output.to); + } + + f_print_terminated(" and", global.main->program.output.to); + } + else if (j + 1 < cache->content_actions.array[index].used) { + f_print_terminated(",", global.main->program.output.to); + } + } // for + + fl_print_format(".%r", global.main->program.output.to, f_string_eol_s); + + controller_unlock_print_flush(global.main->program.output.to, global.thread); + } +#endif // _di_controller_main_print_rule_setting_read_value_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/main/print/rule/setting.h b/sources/c/main/print/rule/setting.h new file mode 100644 index 0000000..624e268 --- /dev/null +++ b/sources/c/main/print/rule/setting.h @@ -0,0 +1,128 @@ +/** + * FLL - Level 3 + * + * Project: Controller + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print rule setting functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _controller_main_print_rule_setting_h +#define _controller_main_print_rule_setting_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print a message about a rule setting problem. + * + * This is intended to be explicitly called by controller_rule_setting_read(). + * This is intended only to be used for simple messages. + * + * @param print + * The error or warning output structure. + * @param message + * The string to append to the message being printed. + * @param index + * The position in the object actions cache representing the object. + * @param line_item + * The current line number. + * @param thread + * The thread data. + * @param cache + * A structure for containing and caching relevant data. + * + * @see controller_rule_setting_read() + */ +#ifndef _di_controller_main_print_rule_setting_read_error_ + extern void controller_main_print_rule_setting_read_error(fl_print_t * const print, const f_string_t message, const f_number_unsigned_t index, const f_number_unsigned_t line_item, controller_thread_t * const thread, controller_cache_t * const cache); +#endif // _di_controller_main_print_rule_setting_read_error_ + +/** + * Print a message about a rule setting problem, with additional messages about the value. + * + * This is intended to be explicitly called by controller_rule_setting_read(). + * This is intended only to be used for simple messages. + * + * @param print + * The error or warning output structure. + * @param before + * The string to add to the message being printed (before the value). + * @param range + * The range within the cache item buffer representing the value. + * @param after + * The string to add to the message being printed (after the value). + * @param index + * The position in the object actions cache representing the object. + * @param line_item + * The current line number. + * @param thread + * The thread data. + * @param cache + * A structure for containing and caching relevant data. + * + * @see controller_rule_setting_read() + */ +#ifndef _di_controller_main_print_rule_setting_read_error_with_range_ + extern void controller_main_print_rule_setting_read_error_with_range(fl_print_t * const print, const f_string_t before, const f_range_t range, const f_string_t after, const f_number_unsigned_t index, const f_number_unsigned_t line_item, controller_thread_t * const thread, controller_cache_t * const cache); +#endif // _di_controller_main_print_rule_setting_read_error_with_range_ + +/** + * Print message regarding the mapping of a setting when in simulation or verbose mode. + * + * @param global + * The global data. + * @param name + * The Object name of the setting being populated. + * @param map + * The map being applied. + */ +#ifndef _di_controller_main_print_rule_setting_read_mapping_ + extern void controller_main_print_rule_setting_read_mapping(const controller_global_t global, const f_string_static_t name, const f_string_map_t map); +#endif // _di_controller_main_print_rule_setting_read_mapping_ + +/** + * Print message regarding the population of a setting when in simulation or verbose mode. + * + * @param global + * The global data. + * @param name + * The Object name of the setting being populated. + * @param name_sub + * A sub-name associated with the setting being populated. + * Set to a string with used set to 0 to not use. + * @param value + * The value being set. + * @param suffix + * An additional message to append at the end (before the final period). + */ +#ifndef _di_controller_main_print_rule_setting_read_value_ + extern void controller_main_print_rule_setting_read_value(const controller_global_t global, const f_string_static_t name, const f_string_static_t name_sub, const f_string_static_t value, const f_string_t suffix); +#endif // _di_controller_main_print_rule_setting_read_value_ + +/** + * Print message regarding the population of a setting when in simulation or verbose mode. + * + * This handles the case where there are multiple values stored in the buffer_item at a given content_actions position. + * + * @param global + * The global data. + * @param name + * The Object name of the setting being populated. + * @param index + * Position within the content_actions range cache array. + * @param cache + * A structure for containing and caching relevant data. + */ +#ifndef _di_controller_main_print_rule_setting_read_values_ + extern void controller_main_print_rule_setting_read_values(const controller_global_t global, const f_string_static_t name, const f_number_unsigned_t index, controller_cache_t * const cache); +#endif // _di_controller_main_print_rule_setting_read_values_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _controller_main_print_rule_setting_h diff --git a/sources/c/main/rule/action.c b/sources/c/main/rule/action.c index d62151a..b74dd92 100644 --- a/sources/c/main/rule/action.c +++ b/sources/c/main/rule/action.c @@ -252,7 +252,7 @@ extern "C" { } if (!type_rerun) { - controller_main_print_rule_error_item_action_first(&global->main->program.error, cache); + controller_main_print_rule_item_error_action_first(&global->main->program.error, cache); return F_status_set_error(F_valid_not); } @@ -270,7 +270,7 @@ extern "C" { } } else { - controller_main_print_rule_error_item_action_second(&global->main->program.error, cache); + controller_main_print_rule_item_error_action_second(&global->main->program.error, cache); return F_status_set_error(F_valid_not); } @@ -287,7 +287,7 @@ extern "C" { item->reruns[type_rerun].is |= rerun_item == &item->reruns[type_rerun].failure ? controller_rule_rerun_is_failure_reset_d : controller_rule_rerun_is_success_reset_d; } else { - controller_main_print_rule_error_item_action_unknown(&global->main->program.error, cache, controller_rerun_s, i); + controller_main_print_rule_item_error_action_unknown(&global->main->program.error, cache, controller_rerun_s, i); return F_status_set_error(F_valid_not); } @@ -312,7 +312,7 @@ extern "C" { item->with &= ~controller_with_session_new_d; } else { - controller_main_print_rule_error_item_action_unknown(&global->main->program.error, cache, controller_with_s, i); + controller_main_print_rule_item_error_action_unknown(&global->main->program.error, cache, controller_with_s, i); status = F_status_set_error(F_valid_not); @@ -407,7 +407,7 @@ extern "C" { } if (F_status_is_error_not(status) && status == F_data_not) { - controller_main_print_rule_debug_item_action_empty(&global->main->program.debug, cache); + controller_main_print_rule_item_debug_action_empty(&global->debug, cache); } return status; @@ -468,7 +468,7 @@ extern "C" { } } - controller_rule_print_rule_message_cache(&global->main->program.error, &cache->action, F_true); + controller_main_print_rule_error_cache(&global->error, &cache->action, F_true); controller_unlock_print_flush(global->main->program.error.to, global->thread); } diff --git a/sources/c/main/rule/execute.c b/sources/c/main/rule/execute.c index 7eb4326..35cc1e3 100644 --- a/sources/c/main/rule/execute.c +++ b/sources/c/main/rule/execute.c @@ -252,7 +252,7 @@ extern "C" { status = controller_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false); + controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false); break; } @@ -282,7 +282,7 @@ extern "C" { status = controller_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false); + controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false); break; } @@ -324,7 +324,7 @@ extern "C" { status = controller_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false); + controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false); break; } @@ -354,7 +354,7 @@ extern "C" { else { success = F_status_set_error(F_failure); - controller_rule_action_print_error_missing_pid(&global->main->program.error, instance->rule.alias); + controller_main_print_rule_action_error_missing_pid(&global->error, instance->rule.alias); } } else if (instance->rule.items.array[i].type == controller_rule_item_type_utility_e) { @@ -362,7 +362,7 @@ extern "C" { status = controller_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false); + controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false); break; } @@ -398,7 +398,7 @@ extern "C" { else { success = F_status_set_error(F_failure); - controller_rule_action_print_error_missing_pid(&global->main->program.error, instance->rule.alias); + controller_main_print_rule_action_error_missing_pid(&global->error, instance->rule.alias); } } else { @@ -407,7 +407,7 @@ extern "C" { fl_print_format("%r%[%QAction type is unknown, ignoring.%]%r", global->main->program.warning.to, f_string_eol_s, global->main->program.warning.context, global->main->program.warning.prefix, global->main->program.warning.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.warning, instance->cache.action, F_true); + controller_main_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true); controller_unlock_print_flush(global->main->program.warning.to, global->thread); } @@ -463,8 +463,8 @@ extern "C" { f_status_t status = F_okay; f_status_t status_lock = F_okay; - controller_main_t * const main = (controller_main_t *) instance->main_data; - controller_thread_t * const thread = (controller_thread_t *) instance->main_thread; + controller_main_t * const main = ((controller_global_t *) instance->global)->main; + controller_thread_t * const thread = ((controller_global_t *) instance->global)->thread; f_execute_result_t result = f_execute_result_t_initialize; @@ -526,7 +526,7 @@ extern "C" { { const f_time_spec_t delay = controller_time_milliseconds(controller_thread_simulation_timeout_d); - if (controller_time_sleep_nanoseconds(main, (controller_process_t *) instance->main_setting, delay) == -1) { + if (controller_time_sleep_nanoseconds((controller_global_t *) instance->global, delay) == -1) { status = F_status_set_error(F_interrupt); } } @@ -581,11 +581,7 @@ extern "C" { } if (F_status_set_fine(status_lock) == F_interrupt || !controller_main_thread_is_enabled_instance(instance, thread)) { - if (status_lock == F_okay) { - return F_status_set_error(F_interrupt); - } - - return F_status_set_error(F_lock); + return status_lock == F_okay ? F_status_set_error(F_interrupt) : F_status_set_error(F_lock); } if (status_lock == F_okay) { @@ -657,10 +653,10 @@ extern "C" { status = F_status_set_fine(status); if ((WIFEXITED(instance->result) && WEXITSTATUS(instance->result)) || status == F_control_group || status == F_failure || status == F_limit || status == F_processor || status == F_schedule) { - controller_rule_item_print_error_execute(type == controller_rule_item_type_script_e, program.used ? program : arguments.array[0], status, instance); + controller_main_print_rule_item_error_execute(&global->error, instance, type == controller_rule_item_type_script_e, program.used ? program : arguments.array[0], status); } else { - controller_main_print_error_status(&main->program.error, macro_controller_f(fll_execute_program), F_status_set_fine(status)); + controller_main_print_error_status(&global->error, macro_controller_f(fll_execute_program), F_status_set_fine(status)); } status = F_status_set_error(status); @@ -678,8 +674,8 @@ extern "C" { f_status_t status = F_okay; f_status_t status_lock = F_okay; - controller_main_t * const main = (controller_main_t *) instance->main_data; - controller_thread_t * const thread = (controller_thread_t *) instance->main_thread; + controller_main_t * const main = ((controller_global_t *) instance->global)->main; + controller_thread_t * const thread = ((controller_global_t *) instance->global)->thread; f_execute_result_t result = f_execute_result_t_initialize; @@ -778,7 +774,7 @@ extern "C" { { const f_time_spec_t delay = controller_time_milliseconds(controller_thread_simulation_timeout_d); - if (controller_time_sleep_nanoseconds(main, (controller_process_t *) instance->main_setting, delay) == -1) { + if (controller_time_sleep_nanoseconds((controller_global_t *) instance->global, delay) == -1) { status = F_status_set_error(F_interrupt); } } @@ -910,10 +906,10 @@ extern "C" { status = F_status_set_fine(status); if ((WIFEXITED(instance->result) && WEXITSTATUS(instance->result)) || status == F_control_group || status == F_failure || status == F_limit || status == F_processor || status == F_schedule) { - controller_rule_item_print_error_execute(type == controller_rule_item_type_utility_e, program.used ? program : arguments.array[0], status, instance); + controller_main_print_rule_item_error_execute(&global->error, instance, type == controller_rule_item_type_utility_e, program.used ? program : arguments.array[0], status); } else { - controller_main_print_error_status(&main->program.error, macro_controller_f(fll_execute_program), F_status_set_fine(status)); + controller_main_print_error_status(&global->error, macro_controller_f(fll_execute_program), F_status_set_fine(status)); } return F_status_set_error(status); @@ -931,8 +927,8 @@ extern "C" { const int result = WIFEXITED(instance->result) ? WEXITSTATUS(instance->result) : 0; if (item->reruns[action].is & (result ? controller_rule_rerun_is_failure_d : controller_rule_rerun_is_success_d)) { - controller_main_t * const main = (controller_main_t *) instance->main_data; - controller_thread_t * const thread = (controller_thread_t *) instance->main_thread; + controller_main_t * const main = ((controller_global_t *) instance->global)->main; + controller_thread_t * const thread = ((controller_global_t *) instance->global)->thread; controller_rule_rerun_item_t *rerun_item = result ? &item->reruns[action].failure : &item->reruns[action].success; if (!controller_main_thread_is_enabled_instance(instance, thread)) return -2; diff --git a/sources/c/main/rule/instance.c b/sources/c/main/rule/instance.c index 3437177..e0d2cad 100644 --- a/sources/c/main/rule/instance.c +++ b/sources/c/main/rule/instance.c @@ -29,7 +29,7 @@ extern "C" { fl_print_format(f_string_format_r_single_s.string, global->main->program.error.to, global->main->program.error.notable, controller_rule_action_type_name(instance->action), global->main->program.error.notable); fl_print_format("%[' while attempting to execute rule.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.error, instance->cache.action, F_true); + controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_true); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -51,7 +51,7 @@ extern "C" { } if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, instance->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true); + controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true); return status; } @@ -59,7 +59,7 @@ extern "C" { status = f_string_dynamic_append(instance->rule.alias, &instance->cache.action.name_file); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, instance->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true); + controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true); return status; } @@ -71,7 +71,7 @@ extern "C" { } if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, instance->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true); + controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true); return status; } @@ -144,8 +144,8 @@ extern "C" { if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global->main->program.error.to, global->thread); - controller_rule_item_print_error_rule_not_loaded(&global->main->program.error, dynamics[i]->array[j]); - controller_rule_print_rule_message_cache(&global->main->program.error, instance->cache.action, F_false); + controller_main_print_rule_item_error_rule_not_loaded(&global->main->program.error, dynamics[i]->array[j]); + controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -199,8 +199,8 @@ extern "C" { if (i == 0) { controller_lock_print(global->main->program.error.to, global->thread); - controller_rule_item_print_error_need_want_wish(&global->main->program.error, strings[i], dynamics[i]->array[j], "is not found"); - controller_rule_print_rule_message_cache(&global->main->program.error, instance->cache.action, F_true); + controller_main_print_rule_item_error_need_want_wish(&global->main->program.error, strings[i], dynamics[i]->array[j], "is not found"); + controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_true); controller_unlock_print_flush(global->main->program.error.to, global->thread); @@ -218,9 +218,9 @@ extern "C" { if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) { controller_lock_print(global->main->program.warning.to, global->thread); - controller_rule_item_print_error_need_want_wish(&global->main->program.warning, strings[i], dynamics[i]->array[j], "is not found"); + controller_main_print_rule_item_error_need_want_wish(&global->main->program.warning, strings[i], dynamics[i]->array[j], "is not found"); - controller_rule_print_rule_message_cache(&global->main->program.warning, instance->cache.action, F_true); + controller_main_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true); controller_unlock_print_flush(global->main->program.warning.to, global->thread); } @@ -304,8 +304,8 @@ extern "C" { if (i == 0 || i == 1 || F_status_set_fine(status) == F_memory_not) { controller_lock_print(global->main->program.error.to, global->thread); - controller_rule_item_print_error_need_want_wish(&global->main->program.error, strings[i], alias_other_buffer, "failed during execution"); - controller_rule_print_rule_message_cache(&global->main->program.error, instance->cache.action, F_true); + controller_main_print_rule_item_error_need_want_wish(&global->main->program.error, strings[i], alias_other_buffer, "failed during execution"); + controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_true); controller_unlock_print_flush(global->main->program.error.to, global->thread); @@ -319,9 +319,9 @@ extern "C" { if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) { controller_lock_print(global->main->program.warning.to, global->thread); - controller_rule_item_print_error_need_want_wish(&global->main->program.warning, strings[i], alias_other_buffer, "failed during execution"); + controller_main_print_rule_item_error_need_want_wish(&global->main->program.warning, strings[i], alias_other_buffer, "failed during execution"); - controller_rule_print_rule_message_cache(&global->main->program.warning, instance->cache.action, F_true); + controller_main_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true); controller_unlock_print_flush(global->main->program.warning.to, global->thread); } @@ -352,7 +352,7 @@ extern "C" { if (F_status_is_error(status_lock)) { if (F_status_is_error(status_lock)) { - controller_rule_item_print_error_need_want_wish(&global->main->program.error, strings[i], alias_other_buffer, "due to lock failure"); + controller_main_print_rule_item_error_need_want_wish(&global->main->program.error, strings[i], alias_other_buffer, "due to lock failure"); } status = status_lock; @@ -363,9 +363,9 @@ extern "C" { if (i == 0 || i == 1) { controller_lock_print(global->main->program.error.to, global->thread); - controller_rule_item_print_error_need_want_wish(&global->main->program.error, strings[i], alias_other_buffer, "is in a failed state"); + controller_main_print_rule_item_error_need_want_wish(&global->main->program.error, strings[i], alias_other_buffer, "is in a failed state"); - controller_rule_print_rule_message_cache(&global->main->program.error, instance->cache.action, F_true); + controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_true); controller_unlock_print_flush(global->main->program.error.to, global->thread); @@ -381,9 +381,9 @@ extern "C" { if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) { controller_lock_print(global->main->program.warning.to, global->thread); - controller_rule_item_print_error_need_want_wish(&global->main->program.warning, strings[i], alias_other_buffer, "is in a failed state"); + controller_main_print_rule_item_error_need_want_wish(&global->main->program.warning, strings[i], alias_other_buffer, "is in a failed state"); - controller_rule_print_rule_message_cache(&global->main->program.warning, instance->cache.action, F_true); + controller_main_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true); controller_unlock_print_flush(global->main->program.warning.to, global->thread); } @@ -468,7 +468,7 @@ extern "C" { fl_print_format("%[') to execute.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s); } - controller_rule_print_rule_message_cache(&global->main->program.error, instance->cache.action, F_true); + controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_true); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -485,7 +485,7 @@ extern "C" { } if (F_status_is_error(status)) { - controller_rule_item_print_error(global->thread, &global->main->program.error, instance->cache.action, F_true, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, instance->cache.action, F_true, F_status_set_fine(status)); } } } @@ -596,8 +596,8 @@ extern "C" { if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global->main->program.error.to, global->thread); - controller_rule_item_print_error_rule_not_loaded(&global->main->program.error, alias_rule); - controller_rule_print_rule_message_cache(&global->main->program.error, cache.action, F_false); + controller_main_print_rule_item_error_rule_not_loaded(&global->main->program.error, alias_rule); + controller_main_print_rule_error_cache(&global->error, cache.action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -611,7 +611,7 @@ extern "C" { if (F_status_is_error(status)) { controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status), F_true, global->thread); - controller_rule_item_print_error(global->thread, &global->main->program.error, cache.action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache.action, F_false, F_status_set_fine(status)); f_thread_unlock(&global->thread->lock.instance); @@ -695,9 +695,7 @@ extern "C" { instance->stack.used = 0; - instance->main_data = (void *) global->main; - instance->main_setting = (void *) global->setting; - instance->main_thread = (void *) global->thread; + instance->global = (void *) global; if (F_status_is_error_not(status) && stack.used) { if (instance->stack.size < stack.used) { @@ -922,7 +920,7 @@ extern "C" { fl_print_format(f_string_format_Q_single_s.string, global->main->program.error.to, global->main->program.error.notable, instance->rule.alias, global->main->program.error.notable); fl_print_format("%[' is already on the execution dependency stack, this recursion is prohibited.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.error, instance->cache.action, F_true); + controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_true); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -996,8 +994,8 @@ extern "C" { if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global->main->program.error.to, global->thread); - controller_rule_item_print_error_rule_not_loaded(&global->main->program.error, instance->rule.alias); - controller_rule_print_rule_message_cache(&global->main->program.error, instance->cache.action, F_false); + controller_main_print_rule_item_error_rule_not_loaded(&global->main->program.error, instance->rule.alias); + controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); } diff --git a/sources/c/main/rule/item.c b/sources/c/main/rule/item.c index 955e740..ce6e457 100644 --- a/sources/c/main/rule/item.c +++ b/sources/c/main/rule/item.c @@ -129,7 +129,7 @@ extern "C" { fl_print_format(f_string_format_Q_single_s.string, global->main->program.warning.to, global->main->program.warning.notable, cache->action.name_action, global->main->program.warning.notable); fl_print_format(f_string_format_sentence_end_quote_s.string, global->main->program.warning.to, global->main->program.warning.context, global->main->program.warning.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.warning, cache->action, F_true); + controller_main_print_rule_error_cache(&global->main->program.warning, cache->action, F_true); controller_unlock_print_flush(global->main->program.warning.to, global->thread); } diff --git a/sources/c/main/rule/read.c b/sources/c/main/rule/read.c index fe5e06a..fa2b181 100644 --- a/sources/c/main/rule/read.c +++ b/sources/c/main/rule/read.c @@ -279,7 +279,7 @@ extern "C" { fl_print_format(f_string_format_Q_single_s.string, global->main->program.warning.to, global->main->program.warning.notable, cache->action.name_item, global->main->program.warning.notable); fl_print_format(f_string_format_sentence_end_quote_s.string, global->main->program.warning.to, global->main->program.warning.context, global->main->program.warning.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.warning, cache->action, F_true); + controller_main_print_rule_error_cache(&global->main->program.warning, cache->action, F_true); controller_unlock_print_flush(global->main->program.warning.to, global->thread); } @@ -326,7 +326,7 @@ extern "C" { } if (F_status_is_error(status)) { - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, for_item, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, for_item, F_status_set_fine(status)); rule->status[0] = controller_main_error_simplify(F_status_set_fine(status)); diff --git a/sources/c/main/rule/setting.c b/sources/c/main/rule/setting.c index 39acd1d..196289c 100644 --- a/sources/c/main/rule/setting.c +++ b/sources/c/main/rule/setting.c @@ -21,7 +21,7 @@ extern "C" { fll_fss_extended_read(cache->buffer_item, &range, &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0, &state); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "fll_fss_extended_read", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "fll_fss_extended_read", F_true, F_false); return status; } @@ -56,7 +56,7 @@ extern "C" { status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->object_actions.array[i], &cache->action.name_item); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); if (F_status_set_fine(status) == F_memory_not) { status_return = status; @@ -74,7 +74,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } @@ -145,7 +145,7 @@ extern "C" { fl_print_format(f_string_format_Q_single_s.string, global->main->program.warning.to, global->main->program.warning.notable, cache->action.name_item, global->main->program.warning.notable); fl_print_format(f_string_format_sentence_end_quote_s.string, global->main->program.warning.to, global->main->program.warning.context, global->main->program.warning.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.warning, cache->action, F_false); + controller_main_print_rule_error_cache(&global->main->program.warning, cache->action, F_false); controller_unlock_print_flush(global->main->program.warning.to, global->thread); } @@ -160,7 +160,7 @@ extern "C" { status = f_string_dynamic_partial_append_nulless(cache->buffer_item, range2, &cache->action.name_action); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); // Get the current line number within the settings item. cache->action.line_item = line_item; @@ -168,7 +168,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); if (F_status_set_fine(status) == F_memory_not) { status_return = status; @@ -197,7 +197,7 @@ extern "C" { fl_print_format("%r%[%QEmpty rule setting.%]%r", global->main->program.warning.to, f_string_eol_s, global->main->program.warning.context, global->main->program.warning.prefix, global->main->program.warning.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.warning, cache->action, F_false); + controller_main_print_rule_error_cache(&global->main->program.warning, cache->action, F_false); controller_unlock_print_flush(global->main->program.warning.to, global->thread); } @@ -208,7 +208,7 @@ extern "C" { if (type == controller_rule_setting_type_affinity_e) { if (!cache->content_actions.array[i].used) { - controller_rule_setting_read_print_error(&global->main->program.error, "requires one or more Content", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error(&global->main->program.error, "requires one or more Content", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -226,7 +226,7 @@ extern "C" { status = f_memory_array_increase(controller_allocation_small_d, sizeof(int32_t), (void **) &rule->affinity.array, &rule->affinity.used, &rule->affinity.size); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); break; } @@ -247,13 +247,13 @@ extern "C" { if (status == F_data_not || status == F_number || status == F_number_overflow || status == F_number_underflow || status == F_number_negative || status == F_number_decimal) { if (status == F_number_underflow) { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too small for this system", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too small for this system", i, line_item, global->thread, cache); } else if (status == F_number_overflow || status == F_number_positive) { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too large for this system", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too large for this system", i, line_item, global->thread, cache); } else { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an invalid number", cache->content_actions.array[i].array[j], ", only whole numbers are allowed for an affinity value", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid number", cache->content_actions.array[i].array[j], ", only whole numbers are allowed for an affinity value", i, line_item, global->thread, cache); } status = F_status_set_error(F_valid_not); @@ -263,7 +263,7 @@ extern "C" { } } else { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false); status = F_status_set_error(status); @@ -278,14 +278,14 @@ extern "C" { rule->affinity.array[rule->affinity.used++] = number; } // for - controller_rule_setting_read_print_values(global, controller_affinity_s, i, cache); + controller_main_print_rule_setting_read_values(global, controller_affinity_s, i, cache); continue; } if (type == controller_rule_setting_type_define_e || type == controller_rule_setting_type_parameter_e) { if (cache->content_actions.array[i].used != 2) { - controller_rule_setting_read_print_error(&global->main->program.error, "requires exactly two Content", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error(&global->main->program.error, "requires exactly two Content", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -304,7 +304,7 @@ extern "C" { status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_map_t), (void **) &setting_maps->array, &setting_maps->used, &setting_maps->size); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); if (F_status_set_fine(status) == F_memory_not) { status_return = status; @@ -322,7 +322,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } @@ -333,7 +333,7 @@ extern "C" { status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], &setting_maps->array[setting_maps->used].key); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); if (F_status_set_fine(status) == F_memory_not) { status_return = status; @@ -350,7 +350,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } @@ -358,7 +358,7 @@ extern "C" { status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[1], &setting_maps->array[setting_maps->used].value); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); if (F_status_set_fine(status) == F_memory_not) { status_return = status; @@ -376,12 +376,12 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } - controller_rule_setting_read_print_mapping(global, type == controller_rule_setting_type_define_e ? controller_define_s : controller_parameter_s, setting_maps->array[setting_maps->used]); + controller_main_print_rule_setting_read_mapping(global, type == controller_rule_setting_type_define_e ? controller_define_s : controller_parameter_s, setting_maps->array[setting_maps->used]); ++setting_maps->used; @@ -390,7 +390,7 @@ extern "C" { if (type == controller_rule_setting_type_cgroup_e) { if (cache->content_actions.array[i].used < 2 || rule->has & controller_rule_has_cgroup_d) { - controller_rule_setting_read_print_error(&global->main->program.error, "requires two or more Content", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error(&global->main->program.error, "requires two or more Content", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -406,7 +406,7 @@ extern "C" { rule->cgroup.as_new = F_true; } else { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an unknown option", cache->content_actions.array[i].array[0], "", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unknown option", cache->content_actions.array[i].array[0], "", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -420,7 +420,7 @@ extern "C" { status = f_string_dynamic_append(global->program->path_cgroup, &rule->cgroup.path); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_false); } else { rule->cgroup.groups.used = 0; @@ -430,7 +430,7 @@ extern "C" { status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &rule->cgroup.groups.array, &rule->cgroup.groups.used, &rule->cgroup.groups.size); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); break; } @@ -440,7 +440,7 @@ extern "C" { status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[j], &rule->cgroup.groups.array[rule->cgroup.groups.used]); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); break; } @@ -468,21 +468,21 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } rule->has |= controller_rule_has_cgroup_d; - controller_rule_setting_read_print_values(global, controller_cgroup_s, i, cache); + controller_main_print_rule_setting_read_values(global, controller_cgroup_s, i, cache); continue; } if (type == controller_rule_setting_type_limit_e) { if (cache->content_actions.array[i].used != 3) { - controller_rule_setting_read_print_error(&global->main->program.error, "requires three Content", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error(&global->main->program.error, "requires three Content", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -554,7 +554,7 @@ extern "C" { fl_print_format(f_string_format_Q_single_s.string, global->main->program.error.to, global->main->program.error.notable, cache->action.name_action, global->main->program.error.notable); fl_print_format(f_string_format_sentence_end_quote_s.string, global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.error, &cache->action, F_true); + controller_main_print_rule_error_cache(&global->error, &cache->action, F_true); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -581,7 +581,7 @@ extern "C" { fl_print_format("%r%[%QThe resource limit type is already specified%]%r", global->main->program.error.to, f_string_eol_s, global->main->program.error.context, global->main->program.error.prefix, global->main->program.error.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.error, cache->action, F_false); + controller_main_print_rule_error_cache(&global->error, cache->action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -599,7 +599,7 @@ extern "C" { status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_limit_set_t), (void **) &rule->limits.array, &rule->limits.used, &rule->limits.size); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); if (F_status_set_fine(status) == F_memory_not) { status_return = status; @@ -617,7 +617,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } @@ -642,13 +642,13 @@ extern "C" { if (status == F_data_not || status == F_number || status == F_number_overflow || status == F_number_underflow || status == F_number_negative || status == F_number_positive || status == F_number_decimal) { if (status == F_number_underflow) { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too small for this system", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too small for this system", i, line_item, global->thread, cache); } else if (status == F_number_overflow) { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too large for this system", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too large for this system", i, line_item, global->thread, cache); } else { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", only whole numbers are allowed for a resource limit value", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", only whole numbers are allowed for a resource limit value", i, line_item, global->thread, cache); } status = F_status_set_error(F_valid_not); @@ -658,7 +658,7 @@ extern "C" { } } else { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false); status = F_status_set_error(status); @@ -682,7 +682,7 @@ extern "C" { rule->limits.array[rule->limits.used++].type = type; - controller_rule_setting_read_print_values(global, controller_limit_s, i, cache); + controller_main_print_rule_setting_read_values(global, controller_limit_s, i, cache); continue; } @@ -700,7 +700,7 @@ extern "C" { } if (setting_value->used || !cache->content_actions.array[i].used) { - controller_rule_setting_read_print_error(&global->main->program.error, "requires one or more Content", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error(&global->main->program.error, "requires one or more Content", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -750,7 +750,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } @@ -775,7 +775,7 @@ extern "C" { fl_print_format(f_string_format_Q_single_s.string, global->main->program.error.to, global->main->program.error.notable, *setting_value, global->main->program.error.notable); fl_print_format("%[', there must be at least 1 graph character.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.error, cache->action, F_false); + controller_main_print_rule_error_cache(&global->error, cache->action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -787,13 +787,13 @@ extern "C" { else { // This function should only return F_complete_not_utf on error. - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_complete_not_utf, "controller_validate_has_graph", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_complete_not_utf, "controller_validate_has_graph", F_true, F_false); if (F_status_is_error_not(status_return)) { status_return = status; } - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); } setting_value->used = 0; @@ -801,13 +801,13 @@ extern "C" { continue; } - controller_rule_setting_read_print_value(global, type == controller_rule_setting_type_name_e ? controller_name_s : controller_engine_s, f_string_empty_s, *setting_value, 0); + controller_main_print_rule_setting_read_value(global, type == controller_rule_setting_type_name_e ? controller_name_s : controller_engine_s, f_string_empty_s, *setting_value, 0); } else if (type == controller_rule_setting_type_path_e) { status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], setting_value); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); if (F_status_set_fine(status) == F_memory_not) { status_return = status; @@ -827,12 +827,12 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } - controller_rule_setting_read_print_value(global, controller_path_s, f_string_empty_s, *setting_value, 0); + controller_main_print_rule_setting_read_value(global, controller_path_s, f_string_empty_s, *setting_value, 0); } continue; @@ -840,7 +840,7 @@ extern "C" { if (type == controller_rule_setting_type_scheduler_e) { if (cache->content_actions.array[i].used < 1 || cache->content_actions.array[i].used > 2 || rule->has & controller_rule_has_scheduler_d) { - controller_rule_setting_read_print_error(&global->main->program.error, "requires either one or two Content", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error(&global->main->program.error, "requires either one or two Content", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -874,7 +874,7 @@ extern "C" { rule->scheduler.priority = 49; } else { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an unknown scheduler", cache->content_actions.array[i].array[0], "", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unknown scheduler", cache->content_actions.array[i].array[0], "", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -928,7 +928,7 @@ extern "C" { fl_print_format(" allowed for the designated scheduler.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.error, cache->action, F_false); + controller_main_print_rule_error_cache(&global->error, cache->action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -938,7 +938,7 @@ extern "C" { } } else { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false); status = F_status_set_error(status); if (F_status_is_error_not(status_return)) { @@ -954,14 +954,14 @@ extern "C" { rule->has |= controller_rule_has_scheduler_d; - controller_rule_setting_read_print_values(global, controller_scheduler_s, i, cache); + controller_main_print_rule_setting_read_values(global, controller_scheduler_s, i, cache); continue; } if (type == controller_rule_setting_type_timeout_e) { if (cache->content_actions.array[i].used != 2) { - controller_rule_setting_read_print_error(&global->main->program.error, "requires exactly two Content", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error(&global->main->program.error, "requires exactly two Content", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -996,7 +996,7 @@ extern "C" { fl_print_format(f_string_format_Q_range_single_s.string, global->main->program.error.to, global->main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[0], global->main->program.error.notable); fl_print_format("%[' but only supports %r, %r, and %r.%]%r", global->main->program.error.to, global->main->program.error.context, controller_kill_s, controller_start_s, controller_stop_s, global->main->program.error.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.error, cache->action, F_false); + controller_main_print_rule_error_cache(&global->error, cache->action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -1025,10 +1025,10 @@ extern "C" { status = F_status_set_fine(status); if (status == F_number_overflow) { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[1], ", the number is too large for this system", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[1], ", the number is too large for this system", i, line_item, global->thread, cache); } else if (status == F_data_not || status == F_number || status == F_number_underflow || status == F_number_negative || status == F_number_positive || status == F_number_decimal) { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an invalid number", cache->content_actions.array[i].array[1], ", only positive whole numbers are allowed", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid number", cache->content_actions.array[i].array[1], ", only positive whole numbers are allowed", i, line_item, global->thread, cache); } else { @@ -1038,7 +1038,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false); } if (F_status_is_error_not(status_return)) { @@ -1076,7 +1076,7 @@ extern "C" { break; } - controller_rule_setting_read_print_value(global, controller_timeout_s, name_sub, cache->action.generic, 0); + controller_main_print_rule_setting_read_value(global, controller_timeout_s, name_sub, cache->action.generic, 0); } } @@ -1085,7 +1085,7 @@ extern "C" { if (type == controller_rule_setting_type_capability_e || type == controller_rule_setting_type_nice_e || type == controller_rule_setting_type_user_e) { if (cache->content_actions.array[i].used != 1 || type == controller_rule_setting_type_capability_e && rule->capability || type == controller_rule_setting_type_group_e && (rule->has & controller_rule_has_group_d) || type == controller_rule_setting_type_nice_e && (rule->has & controller_rule_has_nice_d) || type == controller_rule_setting_type_user_e && (rule->has & controller_rule_has_user_d)) { - controller_rule_setting_read_print_error(&global->main->program.error, "requires exactly one Content", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error(&global->main->program.error, "requires exactly one Content", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -1109,9 +1109,9 @@ extern "C" { controller_lock_print(global->main->program.error.to, global->thread); - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); - controller_rule_print_rule_message_cache(&global->main->program.error, cache->action, F_false); + controller_main_print_rule_error_cache(&global->error, cache->action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); @@ -1139,9 +1139,9 @@ extern "C" { controller_lock_print(global->main->program.error.to, global->thread); - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_capability_from_text", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_capability_from_text", F_true, F_false); - controller_rule_print_rule_message_cache(&global->main->program.error, cache->action, F_false); + controller_main_print_rule_error_cache(&global->error, cache->action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); @@ -1150,7 +1150,7 @@ extern "C" { break; } - controller_rule_setting_read_print_error(&global->main->program.error, "failed to process the capabilities", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error(&global->main->program.error, "failed to process the capabilities", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -1159,7 +1159,7 @@ extern "C" { continue; } - controller_rule_setting_read_print_value(global, controller_capability_s, f_string_empty_s, cache->action.generic, 0); + controller_main_print_rule_setting_read_value(global, controller_capability_s, f_string_empty_s, cache->action.generic, 0); } else if (type == controller_rule_setting_type_nice_e) { f_number_signed_t number = 0; @@ -1197,7 +1197,7 @@ extern "C" { fl_print_format("%[19%]", global->main->program.error.to, global->main->program.error.notable, global->main->program.error.notable); fl_print_format(" %[are allowed.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.error, cache->action, F_false); + controller_main_print_rule_error_cache(&global->error, cache->action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -1207,7 +1207,7 @@ extern "C" { } } else { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false); status = F_status_set_error(status); if (F_status_is_error_not(status_return)) { @@ -1234,9 +1234,9 @@ extern "C" { controller_lock_print(global->main->program.error.to, global->thread); - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); - controller_rule_print_rule_message_cache(&global->main->program.error, cache->action, F_false); + controller_main_print_rule_error_cache(&global->error, cache->action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); @@ -1252,7 +1252,7 @@ extern "C" { } if (F_status_is_error_not(status)) { - controller_rule_setting_read_print_value(global, controller_nice_s, f_string_empty_s, cache->action.generic, 0); + controller_main_print_rule_setting_read_value(global, controller_nice_s, f_string_empty_s, cache->action.generic, 0); } } } @@ -1266,13 +1266,13 @@ extern "C" { status = F_status_set_fine(status); if (status == F_exist_not) { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because no user was found by that name", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because no user was found by that name", i, line_item, global->thread, cache); } else if (status == F_number_too_large) { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because the given ID is too large", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because the given ID is too large", i, line_item, global->thread, cache); } else if (status == F_number) { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because the given ID is not a valid supported number", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because the given ID is not a valid supported number", i, line_item, global->thread, cache); } else { @@ -1282,9 +1282,9 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, status, "controller_get_id_user", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, status, "controller_get_id_user", F_true, F_false); - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); } if (F_status_is_error_not(status_return)) { @@ -1300,7 +1300,7 @@ extern "C" { status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], &cache->action.generic); - controller_rule_setting_read_print_value(global, controller_user_s, f_string_empty_s, cache->action.generic, 0); + controller_main_print_rule_setting_read_value(global, controller_user_s, f_string_empty_s, cache->action.generic, 0); } } } @@ -1310,7 +1310,7 @@ extern "C" { if (type == controller_rule_setting_type_group_e) { if (!cache->content_actions.array[i].used) { - controller_rule_setting_read_print_error(&global->main->program.error, "requires one or more Content", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error(&global->main->program.error, "requires one or more Content", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -1328,7 +1328,7 @@ extern "C" { status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_int32s_t), (void **) &rule->groups.array, &rule->groups.used, &rule->groups.size); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); if (F_status_set_fine(status) == F_memory_not) { status_return = status; @@ -1346,7 +1346,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } @@ -1357,13 +1357,13 @@ extern "C" { status = F_status_set_fine(status); if (status == F_exist_not) { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because no group was found by that name", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because no group was found by that name", i, line_item, global->thread, cache); } else if (status == F_number_too_large) { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because the given ID is too large", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because the given ID is too large", i, line_item, global->thread, cache); } else if (status == F_number) { - controller_rule_setting_read_print_error_with_range(&global->main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because the given ID is not a valid supported number", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because the given ID is not a valid supported number", i, line_item, global->thread, cache); } else { @@ -1373,9 +1373,9 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, status, "f_account_group_id_by_name", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, status, "f_account_group_id_by_name", F_true, F_false); - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); } if (F_status_is_error_not(status_return)) { @@ -1393,7 +1393,7 @@ extern "C" { } } // for - controller_rule_setting_read_print_values(global, controller_group_s, i, cache); + controller_main_print_rule_setting_read_values(global, controller_group_s, i, cache); continue; } @@ -1406,7 +1406,7 @@ extern "C" { status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &setting_values->array, &setting_values->used, &setting_values->size); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); if (F_status_set_fine(status) == F_memory_not) { status_return = status; @@ -1424,7 +1424,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } @@ -1434,7 +1434,7 @@ extern "C" { status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[j], &setting_values->array[setting_values->used]); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false); setting_values->array[setting_values->used].used = 0; @@ -1454,7 +1454,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } @@ -1477,7 +1477,7 @@ extern "C" { fl_print_format(f_string_format_Q_single_s.string, global->main->program.error.to, global->main->program.error.notable, setting_values->array[setting_values->used], global->main->program.error.notable); fl_print_format(f_string_format_sentence_end_quote_s.string, global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.error, cache->action, F_false); + controller_main_print_rule_error_cache(&global->error, cache->action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -1489,7 +1489,7 @@ extern "C" { else { // This function should only return F_complete_not_utf on error. - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_complete_not_utf, "controller_validate_environment_name", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_complete_not_utf, "controller_validate_environment_name", F_true, F_false); if (F_status_is_error_not(status_return)) { status_return = status; @@ -1498,7 +1498,7 @@ extern "C" { setting_values->array[setting_values->used].used = 0; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } @@ -1509,7 +1509,7 @@ extern "C" { rule->has |= controller_rule_has_environment_d; if (cache->content_actions.array[i].used) { - controller_rule_setting_read_print_values(global, controller_environment_s, i, cache); + controller_main_print_rule_setting_read_values(global, controller_environment_s, i, cache); } else { if (global->main->program.error.verbosity == f_console_verbosity_debug_e || (global->main->program.error.verbosity == f_console_verbosity_verbose_e && (global->main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) { @@ -1526,7 +1526,7 @@ extern "C" { // The "on" Rule Setting. if (cache->content_actions.array[i].used != 4) { - controller_rule_setting_read_print_error(&global->main->program.error, "requires exactly four Content", i, line_item, global->thread, cache); + controller_main_print_rule_setting_read_error(&global->main->program.error, "requires exactly four Content", i, line_item, global->thread, cache); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -1580,7 +1580,7 @@ extern "C" { fl_print_format("%[' but only supports %r, %r, %r, %r, %r", global->main->program.error.to, global->main->program.error.context, controller_freeze_s, controller_kill_s, controller_pause_s, controller_reload_s, controller_restart_s); fl_print_format("%r, %r, %r, and %r.%]%r", global->main->program.error.to, controller_resume_s, controller_start_s, controller_stop_s, controller_thaw_s, global->main->program.error.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.error, cache->action, F_false); + controller_main_print_rule_error_cache(&global->error, cache->action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -1601,7 +1601,7 @@ extern "C" { } if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "controller_rule_ons_increase", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "controller_rule_ons_increase", F_true, F_false); } else { if (f_compare_dynamic_partial_string(controller_need_s.string, cache->buffer_item, controller_need_s.used, cache->content_actions.array[i].array[1]) == F_equal_to) { @@ -1628,7 +1628,7 @@ extern "C" { fl_print_format(f_string_format_Q_range_single_s.string, global->main->program.error.to, global->main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[1], global->main->program.error.notable); fl_print_format("%[' but only supports %r, %r, and %r.%]%r", global->main->program.error.to, global->main->program.error.context, controller_need_s, controller_want_s, controller_wish_s, global->main->program.error.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.error, cache->action, F_false); + controller_main_print_rule_error_cache(&global->error, cache->action, F_false); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -1643,7 +1643,7 @@ extern "C" { status = f_memory_array_increase_by(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &setting_values->array, &setting_values->used, &setting_values->size); if (F_status_is_error(status)) { - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_memory_array_increase_by", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase_by", F_true, F_false); } } @@ -1664,7 +1664,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } @@ -1690,7 +1690,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_item_print_error(global->thread, &global->main->program.error, cache->action, F_false, F_status_set_fine(status)); + controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status)); continue; } @@ -1702,7 +1702,7 @@ extern "C" { if (F_status_is_error(status)) { setting_values->array[setting_values->used].used = 0; - controller_rule_print_error(global->thread, &global->main->program.error, cache->action, F_status_set_fine(status), "f_file_name_base", F_true, F_false); + controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_file_name_base", F_true, F_false); if (F_status_set_fine(status) == F_memory_not) { status_return = status; diff --git a/sources/c/main/rule/validate.c b/sources/c/main/rule/validate.c index 811c3a2..d189c05 100644 --- a/sources/c/main/rule/validate.c +++ b/sources/c/main/rule/validate.c @@ -31,7 +31,7 @@ extern "C" { fl_print_format(f_string_format_r_single_s.string, main->program.error.to, main->program.error.notable, controller_rule_action_type_name(action), main->program.error.notable); fl_print_format("%[' while attempting to validate rule execution.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); - controller_rule_print_rule_message_cache(&global->main->program.error, &cache->action, F_true); + controller_main_print_rule_error_cache(&global->error, &cache->action, F_true); controller_unlock_print_flush(main->program.error.to, global->thread); } diff --git a/sources/c/main/thread/instance.c b/sources/c/main/thread/instance.c index fa747b4..9bb2d78 100644 --- a/sources/c/main/thread/instance.c +++ b/sources/c/main/thread/instance.c @@ -10,7 +10,7 @@ extern "C" { if (!instance) return; if (!controller_main_thread_is_enabled(is_normal, (controller_thread_t * const) instance->thread)) return; - const f_status_t status = controller_rule_process_do(controller_instance_option_asynchronous_e, instance); + const f_status_t status = controller_rule_instance_do(controller_instance_option_asynchronous_e, instance); // A forked child instance should deallocate memory on exit. // It seems that this function doesn't return to the calling thread for a forked child instance, even with the "return 0;" below. diff --git a/sources/c/main/thread/instance.h b/sources/c/main/thread/instance.h index 571e074..6cdcd23 100644 --- a/sources/c/main/thread/instance.h +++ b/sources/c/main/thread/instance.h @@ -26,7 +26,7 @@ extern "C" { * The instance data. * Must not be NULL. * - * @see controller_rule_process_do() + * @see controller_rule_instance_do() */ #ifndef _di_controller_main_thread_instance_ extern void controller_main_thread_instance(const uint8_t is_normal, controller_instance_t * const instance); -- 1.8.3.1