From bba3b663aa176cd76de5781031db606033d67791 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 3 Jul 2024 00:01:08 -0500 Subject: [PATCH] Progress: Continue migrating the project. --- sources/c/main/print/error/rule/setting.c | 185 ++++++++++++++++++++-- sources/c/main/print/error/rule/setting.h | 205 +++++++++++++++++++++++-- sources/c/main/print/warning/rule/setting.c | 26 +--- sources/c/main/print/warning/rule/setting.h | 30 +--- sources/c/main/rule/setting.c | 230 ++++++++-------------------- 5 files changed, 437 insertions(+), 239 deletions(-) diff --git a/sources/c/main/print/error/rule/setting.c b/sources/c/main/print/error/rule/setting.c index 764ebb3..0e3d281 100644 --- a/sources/c/main/print/error/rule/setting.c +++ b/sources/c/main/print/error/rule/setting.c @@ -5,15 +5,13 @@ extern "C" { #endif #ifndef _di_controller_print_error_rule_setting_ - f_status_t controller_print_error_rule_setting(fl_print_t * const print, controller_cache_action_t * const action, const f_string_t message, const f_string_static_t buffer, const f_number_unsigned_t line_start, const f_number_unsigned_t line_item, f_state_t * const state) { + f_status_t controller_print_error_rule_setting(fl_print_t * const print, controller_cache_action_t * const action, const f_string_t message) { - if (!print || !print->custom || !action || !state) return F_status_set_error(F_output_not); + if (!print || !print->custom || !action) return F_status_set_error(F_output_not); if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; controller_t * const main = (controller_t *) print->custom; - controller_rule_setting_line_action(main, action, buffer, line_start, line_item, state); - controller_lock_print(print->to, &main->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); @@ -26,20 +24,37 @@ extern "C" { } #endif // _di_controller_print_error_rule_setting_ -#ifndef _di_controller_print_error_rule_setting_value_unsupported_ - f_status_t controller_print_error_rule_setting_value_unsupported(fl_print_t * const print, controller_cache_action_t * const action, const f_string_t message, const f_number_unsigned_t index, const f_number_unsigned_t line_item) { +#ifndef _di_controller_print_error_rule_setting_reason_name_ + f_status_t controller_print_error_rule_setting_reason_name(fl_print_t * const print, controller_cache_action_t * const action, const f_string_t reason, const f_string_static_t name) { + + if (!print || !print->custom || !action) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%[%Q%S '%]", print->to, f_string_eol_s, print->context, print->prefix, reason, print->context); + fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, name, print->notable); + fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s); + + controller_print_error_rule_cache(print, action, F_false); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; } -#endif // _di_controller_print_error_rule_setting_value_unsupported_ +#endif // _di_controller_print_error_rule_setting_reason_name_ #ifndef _di_controller_print_error_rule_setting_with_range_ - f_status_t controller_print_error_rule_setting_with_range(fl_print_t * const print, controller_cache_action_t * const action, const f_string_t before, const f_string_static_t buffer, const f_range_t range_content, const f_string_t after, const f_number_unsigned_t line_start, const f_number_unsigned_t line_item, f_state_t * const state) { + f_status_t controller_print_error_rule_setting_with_range(fl_print_t * const print, controller_cache_action_t * const action, const f_string_t before, const f_string_static_t buffer, const f_range_t range_content, const f_string_t after, const f_number_unsigned_t start, const f_number_unsigned_t line, f_state_t * const state) { if (!print || !print->custom || !action) return F_status_set_error(F_output_not); if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; controller_t * const main = (controller_t *) print->custom; - controller_rule_setting_line_action(main, action, buffer, line_start, line_item, state); + controller_rule_setting_line_action(main, action, buffer, start, line, state); controller_lock_print(print->to, &main->thread); @@ -80,6 +95,158 @@ extern "C" { } #endif // _di_controller_print_error_rule_setting_mapping_ +#ifndef _di_controller_print_error_rule_setting_name_invalid_ + f_status_t controller_print_error_rule_setting_name_invalid(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t name) { + + if (!print || !print->custom || !action) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%[%QRule setting has an invalid name '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, name, print->notable); + fl_print_format("%[', there must be at least 1 graph character.%]%r", print->to, print->context, print->context, f_string_eol_s); + + controller_print_error_rule_cache(print, action, F_false); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_error_rule_setting_name_invalid_ + +#ifndef _di_controller_print_error_rule_setting_number_invalid_nice_ + f_status_t controller_print_error_rule_setting_number_invalid_nice(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t buffer, const f_range_t range) { + + if (!print || !print->custom || !action) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%[%QRule setting has an invalid number '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, buffer, range, print->notable); + fl_print_format("%[', only the whole numbers inclusively between%] ", print->to, print->context, print->context); + fl_print_format("%[-20%] %[and%]", print->to, print->notable, print->notable, print->context, print->context); + fl_print_format("%[19%] %[are allowed.%]%r", print->to, print->notable, print->notable, print->context, print->context, f_string_eol_s); + + controller_print_error_rule_cache(print, action, F_false); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_error_rule_setting_number_invalid_nice_ + +#ifndef _di_controller_print_error_rule_setting_number_invalid_on_first_ + f_status_t controller_print_error_rule_setting_number_invalid_on_first(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t buffer, const f_range_t range) { + + if (!print || !print->custom || !action) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%[%QThe first value for the rule setting '%]", 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, controller_on_s, print->notable); + fl_print_format("%[' has '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, buffer, range, print->notable); + fl_print_format("%[' but only %r, %r, %r, %r, %r", print->to, print->context, controller_freeze_s, controller_kill_s, controller_pause_s, controller_reload_s, controller_restart_s); + fl_print_format("%r, %r, %r, and %r are supported.%]%r", print->to, controller_resume_s, controller_start_s, controller_stop_s, controller_thaw_s, print->context, f_string_eol_s); + + controller_print_error_rule_cache(print, action, F_false); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_error_rule_setting_number_invalid_on_first_ + +#ifndef _di_controller_print_error_rule_setting_number_invalid_on_second_ + f_status_t controller_print_error_rule_setting_number_invalid_on_second(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t buffer, const f_range_t range) { + + if (!print || !print->custom || !action) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%[%QThe second value for the rule setting '%]", 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, controller_on_s, print->notable); + fl_print_format("%[' has '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, buffer, range, print->notable); + fl_print_format("%[' but only supports %r, %r, and %r.%]%r", print->to, print->context, controller_need_s, controller_want_s, controller_wish_s, print->context, f_string_eol_s); + + controller_print_error_rule_cache(print, action, F_false); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_error_rule_setting_number_invalid_on_second_ + +#ifndef _di_controller_print_error_rule_setting_number_invalid_scheduler_ + f_status_t controller_print_error_rule_setting_number_invalid_scheduler(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t buffer, const f_range_t range, const uint8_t zero_only) { + + if (!print || !print->custom || !action) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%[%QRule setting has an invalid number '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, buffer, range, print->notable); + + if (zero_only) { + fl_print_format("%[', only%] ", print->to, print->context, print->context); + fl_print_format("%[0%]%[ is", print->to, print->notable, print->notable, print->context); + } + else { + fl_print_format("%[', only the whole numbers inclusively between%] ", print->to, print->context, print->context); + fl_print_format("%[1%] %[and%] ", print->to, print->notable, print->notable, print->context, print->context); + fl_print_format("%[99%] %[are", print->to, print->notable, print->notable, print->context); + } + + fl_print_format(" allowed for the designated scheduler.%]%r", print->to, print->context, print->context, f_string_eol_s); + + controller_print_error_rule_cache(print, action, F_false); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_error_rule_setting_number_invalid_scheduler_ + +#ifndef _di_controller_print_error_rule_setting_number_invalid_timeout_ + f_status_t controller_print_error_rule_setting_number_invalid_timeout(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t buffer, const f_range_t range) { + + if (!print || !print->custom || !action) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%r%[%QThe first value for the rule setting '%]", 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, controller_timeout_s, print->notable); + fl_print_format("%[' has '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, buffer, range, print->notable); + fl_print_format("%[' but only %r, %r, and %r are supported.%]%r", print->to, print->context, controller_kill_s, controller_start_s, controller_stop_s, print->context, f_string_eol_s); + + controller_print_error_rule_cache(print, action, F_false); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_error_rule_setting_number_invalid_timeout_ + #ifndef _di_controller_print_error_rule_setting_value_ f_status_t controller_print_error_rule_setting_value(fl_print_t * const print, const f_string_static_t name, const f_string_static_t name_sub, const f_string_static_t value, const f_string_t suffix) { diff --git a/sources/c/main/print/error/rule/setting.h b/sources/c/main/print/error/rule/setting.h index c7821fc..e05ff17 100644 --- a/sources/c/main/print/error/rule/setting.h +++ b/sources/c/main/print/error/rule/setting.h @@ -38,18 +38,36 @@ extern "C" { * Must not be NULL. * @param message * The string to append to the message being printed. - * @param buffer - * The buffer representing the content where the lines will be counted from. - * @param line_start - * The position where to start counting lines. - * @param line_item - * The current line number. - * @param state - * The state information * - * The state.status is modified. + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_controller_print_error_rule_setting_ + extern f_status_t controller_print_error_rule_setting(fl_print_t * const print, controller_cache_action_t * const action, const f_string_t message); +#endif // _di_controller_print_error_rule_setting_ + +/** + * Print a message about a rule setting problem given a specified reason and providing the setting name or value. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param action + * The Action cache. * * Must not be NULL. + * @param reason + * The reason for the error. + * @param name + * The name or value of the setting associated with the error. * * @return * F_okay on success. @@ -57,9 +75,9 @@ extern "C" { * * F_output_not (with error bit) if setting is NULL. */ -#ifndef _di_controller_print_error_rule_setting_ - extern f_status_t controller_print_error_rule_setting(fl_print_t * const print, controller_cache_action_t * const action, const f_string_t message, const f_string_static_t buffer, const f_number_unsigned_t line_start, const f_number_unsigned_t line_item, f_state_t * const state); -#endif // _di_controller_print_error_rule_setting_ +#ifndef _di_controller_print_error_rule_setting_reason_name_ + extern f_status_t controller_print_error_rule_setting_reason_name(fl_print_t * const print, controller_cache_action_t * const action, const f_string_t reason, const f_string_static_t name); +#endif // _di_controller_print_error_rule_setting_reason_name_ /** * Print a message about a rule setting problem, with additional messages about the value. @@ -89,9 +107,9 @@ extern "C" { * The range within the buffer representing the setting Content. * @param after * The string to add to the message being printed (after the value). - * @param line_start + * @param start * The position where to start counting lines. - * @param line_item + * @param line * The current line number. * @param state * The state information @@ -107,7 +125,7 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_controller_print_error_rule_setting_with_range_ - extern f_status_t controller_print_error_rule_setting_with_range(fl_print_t * const print, controller_cache_action_t * const action, const f_string_t before, const f_string_static_t buffer, const f_range_t range_content, const f_string_t after, const f_number_unsigned_t line_start, const f_number_unsigned_t line_item, f_state_t * const state); + extern f_status_t controller_print_error_rule_setting_with_range(fl_print_t * const print, controller_cache_action_t * const action, const f_string_t before, const f_string_static_t buffer, const f_range_t range_content, const f_string_t after, const f_number_unsigned_t start, const f_number_unsigned_t line, f_state_t * const state); #endif // _di_controller_print_error_rule_setting_with_range_ /** @@ -133,6 +151,163 @@ extern "C" { #endif // _di_controller_print_error_rule_setting_mapping_ /** + * Print message regarding the setting being invalid. + * + * @param print + * The error or warning output structure. + * + * Must not be NULL. + * @param action + * The Action cache. + * + * Must not be NULL. + * @param name + * The name of the setting that is invalid. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_controller_print_error_rule_setting_name_invalid_ + extern f_status_t controller_print_error_rule_setting_name_invalid(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t name); +#endif // _di_controller_print_error_rule_setting_name_invalid_ + +/** + * Print message regarding the "nice" setting value being an invalid number. + * + * @param print + * The error or warning output structure. + * + * Must not be NULL. + * @param action + * The Action cache. + * + * Must not be NULL. + * @param buffer + * The buffer containing the invalid number. + * @param range + * The ranger within the buffer representing the invalid number. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_controller_print_error_rule_setting_number_invalid_nice_ + extern f_status_t controller_print_error_rule_setting_number_invalid_nice(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t buffer, const f_range_t range); +#endif // _di_controller_print_error_rule_setting_number_invalid_nice_ + +/** + * Print message regarding the first value for the "on" setting being invalid. + * + * @param print + * The error or warning output structure. + * + * Must not be NULL. + * @param action + * The Action cache. + * + * Must not be NULL. + * @param buffer + * The buffer containing the invalid value. + * @param range + * The ranger within the buffer representing the invalid 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. + */ +#ifndef _di_controller_print_error_rule_setting_number_invalid_on_first_ + extern f_status_t controller_print_error_rule_setting_number_invalid_on_first(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t buffer, const f_range_t range); +#endif // _di_controller_print_error_rule_setting_number_invalid_on_first_ + +/** + * Print message regarding the second value for the "on" setting being invalid. + * + * @param print + * The error or warning output structure. + * + * Must not be NULL. + * @param action + * The Action cache. + * + * Must not be NULL. + * @param buffer + * The buffer containing the invalid value. + * @param range + * The ranger within the buffer representing the invalid 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. + */ +#ifndef _di_controller_print_error_rule_setting_number_invalid_on_second_ + extern f_status_t controller_print_error_rule_setting_number_invalid_on_second(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t buffer, const f_range_t range); +#endif // _di_controller_print_error_rule_setting_number_invalid_on_second_ + +/** + * Print message regarding the "scheduler" setting value being an invalid number. + * + * @param print + * The error or warning output structure. + * + * Must not be NULL. + * @param action + * The Action cache. + * + * Must not be NULL. + * @param buffer + * The buffer containing the invalid number. + * @param range + * The ranger within the buffer representing the invalid number. + * @param zero_only + * If TRUE, then only 0 is supported. + * If FALSE, then only the range 1 through 99 is supported. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_controller_print_error_rule_setting_number_invalid_scheduler_ + extern f_status_t controller_print_error_rule_setting_number_invalid_scheduler(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t buffer, const f_range_t range, const uint8_t zero_only); +#endif // _di_controller_print_error_rule_setting_number_invalid_scheduler_ + +/** + * Print message regarding the "timeout" setting value being invalid. + * + * @param print + * The error or warning output structure. + * + * Must not be NULL. + * @param action + * The Action cache. + * + * Must not be NULL. + * @param buffer + * The buffer containing the invalid value. + * @param range + * The ranger within the buffer representing the invalid 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. + */ +#ifndef _di_controller_print_error_rule_setting_number_invalid_timeout_ + extern f_status_t controller_print_error_rule_setting_number_invalid_timeout(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t buffer, const f_range_t range); +#endif // _di_controller_print_error_rule_setting_number_invalid_timeout_ + +/** * Print message regarding the population of a setting when in simulation or verbose mode. * * @param print diff --git a/sources/c/main/print/warning/rule/setting.c b/sources/c/main/print/warning/rule/setting.c index 38bdca9..6007e42 100644 --- a/sources/c/main/print/warning/rule/setting.c +++ b/sources/c/main/print/warning/rule/setting.c @@ -4,30 +4,8 @@ extern "C" { #endif -#ifndef _di_controller_print_warning_rule_setting_empty_ - f_status_t controller_print_warning_rule_setting_empty(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t name) { - - if (!print || !print->custom || !action) return F_status_set_error(F_output_not); - if (print->verbosity < f_console_verbosity_debug_e) return F_output_not; - - controller_t * const main = (controller_t *) print->custom; - - controller_lock_print(print->to, &main->thread); - - fl_print_format("%r%[%QUnknown Rule setting '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); - fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, name, print->notable); - fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s); - - controller_print_error_rule_cache(print, action, F_true); - - controller_unlock_print_flush(print->to, &main->thread); - - return F_okay; - } -#endif // _di_controller_print_warning_rule_setting_empty_ - #ifndef _di_controller_print_warning_rule_setting_unknown_ - f_status_t controller_print_warning_rule_setting_unknown(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t name) { + f_status_t controller_print_warning_rule_setting_unknown(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t name, const f_string_t what) { if (!print || !print->custom || !action) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_debug_e) return F_output_not; @@ -36,7 +14,7 @@ extern "C" { controller_lock_print(print->to, &main->thread); - fl_print_format("%r%[%QUnknown Rule setting '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context); + fl_print_format("%r%[%Q%S Rule setting '%]", print->to, f_string_eol_s, print->context, print->prefix, what, print->context); fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, name, print->notable); fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s); diff --git a/sources/c/main/print/warning/rule/setting.h b/sources/c/main/print/warning/rule/setting.h index 51f86a1..2d58a87 100644 --- a/sources/c/main/print/warning/rule/setting.h +++ b/sources/c/main/print/warning/rule/setting.h @@ -40,36 +40,8 @@ extern "C" { * * F_output_not (with error bit) if setting is NULL. */ -#ifndef _di_controller_print_warning_rule_setting_empty_ - extern f_status_t controller_print_warning_rule_setting_empty(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t name); -#endif // _di_controller_print_warning_rule_setting_empty_ - -/** - * Print warning message about the Rule Item being unknown. - * - * @param print - * The output structure to print to. - * - * This requires print.custom to be controller_t. - * - * This does not alter print.custom.setting.state.status. - * - * Must not be NULL. - * @param action - * The action cache. - * - * Must not be NULL. - * @param name - * The Item name that is unknown. - * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. - * - * F_output_not (with error bit) if setting is NULL. - */ #ifndef _di_controller_print_warning_rule_setting_unknown_ - extern f_status_t controller_print_warning_rule_setting_unknown(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t name); + extern f_status_t controller_print_warning_rule_setting_unknown(fl_print_t * const print, controller_cache_action_t * const action, const f_string_static_t name, const f_string_t what); #endif // _di_controller_print_warning_rule_setting_unknown_ #ifdef __cplusplus diff --git a/sources/c/main/rule/setting.c b/sources/c/main/rule/setting.c index c7d4d7b..a09bc39 100644 --- a/sources/c/main/rule/setting.c +++ b/sources/c/main/rule/setting.c @@ -236,11 +236,9 @@ extern "C" { type = controller_rule_setting_type_user_e; } else { - if (main->program.warning.verbosity == f_console_verbosity_debug_e) { - controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - controller_print_warning_rule_setting_unknown(&main->program.warning, &cache->action, cache->action.name_item); - } + controller_print_warning_rule_setting_unknown(&main->program.warning, &cache->action, cache->action.name_item, "Unknown"); continue; } @@ -279,17 +277,9 @@ extern "C" { } else { if (empty_disallow) { - if (main->program.warning.verbosity == f_console_verbosity_debug_e) { - controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - - controller_lock_print(main->program.warning.to, &main->thread); - - fl_print_format("%r%[%QEmpty rule setting.%]%r", main->program.warning.to, f_string_eol_s, main->program.warning.context, main->program.warning.prefix, main->program.warning.context, f_string_eol_s); - - controller_print_error_rule_cache(&main->program.warning, &cache->action, F_false); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - controller_unlock_print_flush(main->program.warning.to, &main->thread); - } + controller_print_warning_rule_setting_unknown(&main->program.warning, &cache->action, cache->action.name_item, "Empty"); continue; } @@ -297,7 +287,9 @@ extern "C" { if (type == controller_rule_setting_type_affinity_e) { if (!cache->content_actions.array[i].used) { - controller_print_error_rule_setting(&main->program.error, &cache->action, "requires one or more Content", cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + + controller_print_error_rule_setting(&main->program.error, &cache->action, "requires one or more Content"); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -374,7 +366,9 @@ extern "C" { if (type == controller_rule_setting_type_define_e || type == controller_rule_setting_type_parameter_e) { if (cache->content_actions.array[i].used != 2) { - controller_print_error_rule_setting(&main->program.error, &cache->action, "requires exactly two Content", cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + + controller_print_error_rule_setting(&main->program.error, &cache->action, "requires exactly two Content"); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -474,7 +468,9 @@ 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_print_error_rule_setting(&main->program.error, &cache->action, "requires two or more Content", cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + + controller_print_error_rule_setting(&main->program.error, &cache->action, "requires two or more Content"); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -564,7 +560,9 @@ extern "C" { if (type == controller_rule_setting_type_limit_e) { if (cache->content_actions.array[i].used != 3) { - controller_print_error_rule_setting(&main->program.error, &cache->action, "requires three Content", cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + + controller_print_error_rule_setting(&main->program.error, &cache->action, "requires three Content"); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -622,19 +620,9 @@ extern "C" { type = controller_resource_limit_type_stack_e; } else { - if (main->program.error.verbosity == f_console_verbosity_debug_e) { - controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QUnknown resource limit type '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context); - fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, cache->action.name_action, main->program.error.notable); - fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); - - controller_print_error_rule_cache(&main->program.error, &cache->action, F_true); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - controller_unlock_print_flush(main->program.error.to, &main->thread); - } + controller_print_error_rule_setting_reason_name(&main->program.error, &cache->action, "Unknown resource limit type", cache->action.name_action); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -646,20 +634,12 @@ extern "C" { for (j = 0; j < rule->limits.used; ++j) { if (type == rule->limits.array[j].type) { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QThe resource limit type is already specified%]%r", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context, f_string_eol_s); - - controller_print_error_rule_cache(&main->program.error, &cache->action, F_false); - - controller_unlock_print_flush(main->program.error.to, &main->thread); - } + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); state.status = F_status_set_error(F_valid_not); + controller_print_error_rule_setting_reason_name(&main->program.error, &cache->action, "The resource limit type is already specified", cache->action.name_action); + if (F_status_is_error_not(status_return)) { status_return = state.status; } @@ -770,7 +750,9 @@ extern "C" { } if (setting_value->used || !cache->content_actions.array[i].used) { - controller_print_error_rule_setting(&main->program.error, &cache->action, "requires one or more Content", cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + + controller_print_error_rule_setting(&main->program.error, &cache->action, "requires one or more Content"); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -826,7 +808,7 @@ extern "C" { state.status = controller_validate_has_graph(*setting_value); if (state.status == F_false || F_status_set_fine(state.status) == F_complete_not_utf) { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + { const f_status_t original = state.status; controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); @@ -835,17 +817,7 @@ extern "C" { } if (state.status == F_false) { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QRule setting has an invalid name '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context); - fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, *setting_value, main->program.error.notable); - fl_print_format("%[', there must be at least 1 graph character.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); - - controller_print_error_rule_cache(&main->program.error, &cache->action, F_false); - - controller_unlock_print_flush(main->program.error.to, &main->thread); - } + controller_print_error_rule_setting_name_invalid(&main->program.error, &cache->action, *setting_value); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -905,7 +877,9 @@ 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_print_error_rule_setting(&main->program.error, &cache->action, "requires either one or two Content", cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + + controller_print_error_rule_setting(&main->program.error, &cache->action, "requires either one or two Content"); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -968,37 +942,16 @@ extern "C" { state.status = F_status_set_fine(state.status); if ((zero_only && number) || (!zero_only && (number < 1 || number > 99)) || state.status == F_data_not || state.status == F_number || state.status == F_number_overflow || state.status == F_number_negative || state.status == F_number_positive) { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - { - const f_status_t original = state.status; - - controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - - state.status = original; - } - - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QRule setting has an invalid number '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context); - fl_print_format(f_string_format_Q_range_single_s.string, main->program.error.to, main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[1], main->program.error.notable); - - if (zero_only) { - fl_print_format("%[', only%] ", main->program.error.to, main->program.error.context, main->program.error.context); - fl_print_format("%[0%]%[ is", main->program.error.to, main->program.error.notable, main->program.error.notable, main->program.error.context); - } - else { - fl_print_format("%[', only the whole numbers inclusively between%] ", main->program.error.to, main->program.error.context, main->program.error.context); - fl_print_format("%[1%] %[and%] ", main->program.error.to, main->program.error.notable, main->program.error.notable, main->program.error.context, main->program.error.context); - fl_print_format("%[99%] %[are", main->program.error.to, main->program.error.notable, main->program.error.notable, main->program.error.context); - } - - fl_print_format(" allowed for the designated scheduler.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); + { + const f_status_t original = state.status; - controller_print_error_rule_cache(&main->program.error, &cache->action, F_false); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - controller_unlock_print_flush(main->program.error.to, &main->thread); + state.status = original; } + controller_print_error_rule_setting_number_invalid_scheduler(&main->program.error, &cache->action, cache->buffer_item, cache->content_actions.array[i].array[1], zero_only); + if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); } @@ -1027,7 +980,9 @@ extern "C" { if (type == controller_rule_setting_type_timeout_e) { if (cache->content_actions.array[i].used != 2) { - controller_print_error_rule_setting(&main->program.error, &cache->action, "requires exactly two Content", cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + + controller_print_error_rule_setting(&main->program.error, &cache->action, "requires exactly two Content"); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -1048,26 +1003,16 @@ extern "C" { timeout_code = controller_rule_timeout_code_stop_d; } else { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - { - const f_status_t original = state.status; - - controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - - state.status = original; - } - - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QRule setting's first value has '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context); - fl_print_format(f_string_format_Q_range_single_s.string, main->program.error.to, main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[0], main->program.error.notable); - fl_print_format("%[' but only supports %r, %r, and %r.%]%r", main->program.error.to, main->program.error.context, controller_kill_s, controller_start_s, controller_stop_s, main->program.error.context, f_string_eol_s); + { + const f_status_t original = state.status; - controller_print_error_rule_cache(&main->program.error, &cache->action, F_false); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - controller_unlock_print_flush(main->program.error.to, &main->thread); + state.status = original; } + controller_print_error_rule_setting_number_invalid_timeout(&main->program.error, &cache->action, cache->buffer_item, cache->content_actions.array[i].array[0]); + if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); } @@ -1153,7 +1098,9 @@ 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_print_error_rule_setting(&main->program.error, &cache->action, "requires exactly one Content", cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + + controller_print_error_rule_setting(&main->program.error, &cache->action, "requires exactly one Content"); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -1220,7 +1167,9 @@ extern "C" { break; } - controller_print_error_rule_setting(&main->program.error, &cache->action, "failed to process the capabilities", cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + + controller_print_error_rule_setting(&main->program.error, &cache->action, "failed to process the capabilities"); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -1249,30 +1198,16 @@ extern "C" { state.status = F_status_set_fine(state.status); if (number < -20 || number > 19 || state.status == F_data_not || state.status == F_number || state.status == F_number_overflow || state.status == F_number_underflow || state.status == F_number_decimal) { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - { - const f_status_t original = state.status; - - controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - - state.status = original; - } - - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QRule setting has an invalid number '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context); - fl_print_format(f_string_format_Q_range_single_s.string, main->program.error.to, main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[0], main->program.error.notable); - fl_print_format("%[', only the whole numbers inclusively between%] ", main->program.error.to, main->program.error.context, main->program.error.context); - fl_print_format("%[-20%]", main->program.error.to, main->program.error.notable, main->program.error.notable); - fl_print_format(" %[and%] ", main->program.error.to, main->program.error.context, main->program.error.context); - fl_print_format("%[19%]", main->program.error.to, main->program.error.notable, main->program.error.notable); - fl_print_format(" %[are allowed.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); + { + const f_status_t original = state.status; - controller_print_error_rule_cache(&main->program.error, &cache->action, F_false); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - controller_unlock_print_flush(main->program.error.to, &main->thread); + state.status = original; } + controller_print_error_rule_setting_number_invalid_nice(&main->program.error, &cache->action, cache->buffer_item, cache->content_actions.array[i].array[0]); + if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); } @@ -1383,7 +1318,9 @@ extern "C" { if (type == controller_rule_setting_type_group_e) { if (!cache->content_actions.array[i].used) { - controller_print_error_rule_setting(&main->program.error, &cache->action, "requires one or more Content", cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + + controller_print_error_rule_setting(&main->program.error, &cache->action, "requires one or more Content"); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -1539,17 +1476,7 @@ extern "C" { } if (state.status == F_false) { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QRule setting has an invalid environment variable name '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context); - fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, setting_values->array[setting_values->used], main->program.error.notable); - fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s); - - controller_print_error_rule_cache(&main->program.error, &cache->action, F_false); - - controller_unlock_print_flush(main->program.error.to, &main->thread); - } + controller_print_error_rule_setting_reason_name(&main->program.error, &cache->action, "Rule setting has an invalid environment variable name", setting_values->array[setting_values->used]); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -1584,7 +1511,7 @@ extern "C" { if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->setting.flag & controller_main_flag_simulate_e))) { controller_lock_print(main->program.output.to, &main->thread); - fl_print_format("%rProcessing Rule Item Action '%[%r%]' setting value to an empty set.%r", main->program.output.to, f_string_eol_s, main->program.context.set.title, controller_environment_s, main->program.context.set.title, f_string_eol_s); + fl_print_format("%rProcessing Rule Item Action '%[%r%]' setting value to an empty set.%r", main->program.output.to, f_string_eol_s, main->program.context.set.title, controller_environment_s, main->program.context.set.title, f_string_eol_s); // TODO: don't forget to update these as well. controller_unlock_print_flush(main->program.output.to, &main->thread); } @@ -1595,7 +1522,9 @@ extern "C" { // The "on" Rule Setting. if (cache->content_actions.array[i].used != 4) { - controller_print_error_rule_setting(&main->program.error, &cache->action, "requires exactly four Content", cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, line_item, &state); + + controller_print_error_rule_setting(&main->program.error, &cache->action, "requires exactly four Content"); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -1632,22 +1561,9 @@ extern "C" { action = controller_rule_action_type_thaw_e; } else { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - - f_thread_mutex_lock(&main->thread.lock.print); - - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QRule setting's second value has '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context); - fl_print_format(f_string_format_Q_range_single_s.string, main->program.error.to, main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[1], main->program.error.notable); - fl_print_format("%[' but only supports %r, %r, %r, %r, %r", main->program.error.to, 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", main->program.error.to, controller_resume_s, controller_start_s, controller_stop_s, controller_thaw_s, main->program.error.context, f_string_eol_s); - - controller_print_error_rule_cache(&main->program.error, &cache->action, F_false); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - controller_unlock_print_flush(main->program.error.to, &main->thread); - } + controller_print_error_rule_setting_number_invalid_on_first(&main->program.error, &cache->action, cache->buffer_item, cache->content_actions.array[i].array[1]); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -1678,19 +1594,9 @@ extern "C" { setting_values = &rule->ons.array[j].wish; } else { - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - - controller_lock_print(main->program.error.to, &main->thread); - - fl_print_format("%r%[%QRule setting's second value has '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context); - fl_print_format(f_string_format_Q_range_single_s.string, main->program.error.to, main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[1], main->program.error.notable); - fl_print_format("%[' but only supports %r, %r, and %r.%]%r", main->program.error.to, main->program.error.context, controller_need_s, controller_want_s, controller_wish_s, main->program.error.context, f_string_eol_s); - - controller_print_error_rule_cache(&main->program.error, &cache->action, F_false); + controller_rule_setting_line_action(main, &cache->action, cache->buffer_item, cache->object_actions.array[i].start, cache->action.line_item, &state); - controller_unlock_print_flush(main->program.error.to, &main->thread); - } + controller_print_error_rule_setting_number_invalid_on_second(&main->program.error, &cache->action, cache->buffer_item, cache->content_actions.array[i].array[1]); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); -- 1.8.3.1