From e014a2dd3a30d2fd381021aff1b1f4681b6932c9 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 29 Jun 2024 22:40:51 -0500 Subject: [PATCH] Progress: Continue migrating the project. --- data/build/settings | 4 +-- sources/c/main/controller.h | 1 + sources/c/main/print/error/rule.h | 7 ++++ sources/c/main/print/error/rule/item.h | 2 +- sources/c/main/print/error/rule/setting.c | 21 +++++++----- sources/c/main/print/error/rule/setting.h | 26 ++++++++------ sources/c/main/print/output/rule/execute.c | 1 + sources/c/main/print/output/rule/setting.c | 33 ++++++++++++++++++ sources/c/main/print/output/rule/setting.h | 55 ++++++++++++++++++++++++++++++ sources/c/main/rule/setting.c | 43 +++++++++-------------- 10 files changed, 145 insertions(+), 48 deletions(-) create mode 100644 sources/c/main/print/output/rule/setting.c create mode 100644 sources/c/main/print/output/rule/setting.h diff --git a/data/build/settings b/data/build/settings index 40c0813..5cce5f4 100644 --- a/data/build/settings +++ b/data/build/settings @@ -55,7 +55,7 @@ build_sources_library print/error/entry.c print/error/entry/action.c print/error build_sources_library print/error/perform/pid.c build_sources_library print/error/rule.c print/error/rule/action.c print/error/rule/item.c print/error/rule/setting.c build_sources_library print/lock.c print/error/lock.c -build_sources_library print/output/entry/setting.c print/output/rule/execute.c +build_sources_library print/output/entry/setting.c print/output/rule/execute.c print/output/rule/setting.c build_sources_library print/message.c print/message/entry.c print/message/entry/action.c print/message/entry/item.c build_sources_library print/verbose.c build_sources_library print/warning.c print/warning/entry/action.c print/warning/entry/item.c print/warning/entry/setting.c print/warning/rule/action.c print/warning/rule/item.c print/warning/rule/setting.c @@ -80,7 +80,7 @@ build_sources_headers print/error/entry.h print/error/entry/action.h print/error build_sources_headers print/error/perform/pid.h build_sources_headers print/error/rule.h print/error/rule/action.h print/error/rule/item.h print/error/rule/setting.h build_sources_headers print/lock.h print/error/lock.h -build_sources_headers print/output/entry/setting.h print/output/rule/execute.h +build_sources_headers print/output/entry/setting.h print/output/rule/execute.h print/output/rule/setting.h build_sources_headers print/message.h print/message/entry.h print/message/entry/action.h print/message/entry/item.h build_sources_headers print/verbose.h build_sources_headers print/warning.h print/warning/entry/action.h print/warning/entry/item.h print/warning/entry/setting.h print/warning/rule/action.h print/warning/rule/item.h print/warning/rule/setting.h diff --git a/sources/c/main/controller.h b/sources/c/main/controller.h index 10fe4b0..a7f5c17 100644 --- a/sources/c/main/controller.h +++ b/sources/c/main/controller.h @@ -134,6 +134,7 @@ #include #include #include +#include #include #include #include diff --git a/sources/c/main/print/error/rule.h b/sources/c/main/print/error/rule.h index 1193163..d03aeaa 100644 --- a/sources/c/main/print/error/rule.h +++ b/sources/c/main/print/error/rule.h @@ -73,6 +73,13 @@ extern "C" { * @param action * The action cache. * + * This uses: + * - action.line_action + * - action.line_item + * - action.name_action + * - action.name_file + * - action.name_item + * * Must not be NULL. * @param item * If TRUE, then this error is associated with an item. diff --git a/sources/c/main/print/error/rule/item.h b/sources/c/main/print/error/rule/item.h index a2607d3..02b7118 100644 --- a/sources/c/main/print/error/rule/item.h +++ b/sources/c/main/print/error/rule/item.h @@ -30,7 +30,7 @@ extern "C" { * * Must not be NULL. * @param cache - * A structure for containing and caching relevant data. + * The Action cache. * * Must not be NULL. * @param item diff --git a/sources/c/main/print/error/rule/setting.c b/sources/c/main/print/error/rule/setting.c index 3a49420..e598661 100644 --- a/sources/c/main/print/error/rule/setting.c +++ b/sources/c/main/print/error/rule/setting.c @@ -32,29 +32,32 @@ 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) { + } +#endif // _di_controller_print_error_rule_setting_value_unsupported_ + #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_t * const cache, 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) { + 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_object, const f_range_t range_content, const f_string_t after, const f_number_unsigned_t line_item) { - if (!print || !print->custom || !cache) 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; - 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); + action->line_item = line_item; + f_fss_count_lines(buffer, range_object.start, &action->line_item, &main->setting.state); - cache->action.line_action = ++cache->action.line_item; + action->line_action = ++action->line_item; controller_lock_print(print->to, &main->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(f_string_format_Q_range_single_s.string, print->to, print->notable, buffer, range_content, print->notable); fl_print_format("%['%S.%]%r", print->to, print->context, after, print->context, f_string_eol_s); - controller_print_error_rule_cache(print, &cache->action, F_false); + controller_print_error_rule_cache(print, action, F_false); controller_unlock_print_flush(print->to, &main->thread); diff --git a/sources/c/main/print/error/rule/setting.h b/sources/c/main/print/error/rule/setting.h index a00afd5..a209cde 100644 --- a/sources/c/main/print/error/rule/setting.h +++ b/sources/c/main/print/error/rule/setting.h @@ -56,25 +56,31 @@ extern "C" { * This is intended only to be used for simple messages. * * @param print - * The error or warning output structure. + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. * * Must not be NULL. - * @param cache - * A structure for containing and caching relevant data. + * @param action + * The Action cache. + * + * This alters action.line_item to get the current line. * * Must not be NULL. * @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 buffer + * The buffer representing the Rule settings. + * @param range_object + * The range within the buffer representing the setting Object. + * @param range_content + * The range within the buffer representing the setting Content. * @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. * * @return * F_okay on success. @@ -83,7 +89,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_t * const cache, 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); + 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_object, const f_range_t range_content, const f_string_t after, const f_number_unsigned_t line_item); #endif // _di_controller_print_error_rule_setting_with_range_ /** diff --git a/sources/c/main/print/output/rule/execute.c b/sources/c/main/print/output/rule/execute.c index e6d13ac..18372a0 100644 --- a/sources/c/main/print/output/rule/execute.c +++ b/sources/c/main/print/output/rule/execute.c @@ -42,6 +42,7 @@ extern "C" { return F_okay; } #endif // _di_controller_print_entry_output_execute_simulate_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/sources/c/main/print/output/rule/setting.c b/sources/c/main/print/output/rule/setting.c new file mode 100644 index 0000000..e52256c --- /dev/null +++ b/sources/c/main/print/output/rule/setting.c @@ -0,0 +1,33 @@ +#include "../../../controller.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_controller_print_output_rule_execute_setting_simulate_adding_range_3_ + f_status_t controller_print_output_rule_execute_setting_simulate_adding_range_3(fl_print_t * const print, const f_string_static_t name, const f_string_static_t buffer, const f_range_t range_1, const f_range_t range_2, const f_range_t range_3) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + controller_t * const main = (controller_t *) print->custom; + + if (print->verbosity < f_console_verbosity_debug_e && !((main->setting.flag & controller_main_flag_simulate_e) && print->verbosity > f_console_verbosity_normal_e)) { + return F_output_not; + } + + controller_lock_print(print->to, &main->thread); + + fl_print_format("%rProcessing Rule Item Action '%[%r%]', adding ", print->to, f_string_eol_s, main->program.context.set.title, name, main->program.context.set.title); + fl_print_format("'%[%/Q%]' of ", print->to, main->program.context.set.notable, buffer, range_1, main->program.context.set.notable); + fl_print_format("'%[%/Q%]/", print->to, main->program.context.set.important, buffer, range_2, main->program.context.set.important); + fl_print_format("%[%/Q%]'.%r", print->to, main->program.context.set.important, buffer, range_3, main->program.context.set.important, f_string_eol_s); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_output_rule_execute_setting_simulate_adding_range_3_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/main/print/output/rule/setting.h b/sources/c/main/print/output/rule/setting.h new file mode 100644 index 0000000..3bbec1e --- /dev/null +++ b/sources/c/main/print/output/rule/setting.h @@ -0,0 +1,55 @@ +/** + * FLL - Level 3 + * + * Project: Controller + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print rule setting output functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _controller_main_print_output_rule_setting_h +#define _controller_main_print_output_rule_setting_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print message about processing a Rule Item Action adding with the three Content ranges in the buffer. + * + * @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 name + * The Rule Item Action name. + * @param buffer + * A bufer containing the values. + * @param range_1 + * A range within the buffer representing value one. + * @param range_2 + * A range within the buffer representing value two. + * @param range_3 + * A range within the buffer representing value three. + * + * @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_output_rule_execute_setting_simulate_adding_range_3_ + extern f_status_t controller_print_output_rule_execute_setting_simulate_adding_range_3(fl_print_t * const print, const f_string_static_t name, const f_string_static_t buffer, const f_range_t range_1, const f_range_t range_2, const f_range_t range_3); +#endif // _di_controller_print_output_rule_execute_setting_simulate_adding_range_3_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _controller_main_print_output_rule_setting_h diff --git a/sources/c/main/rule/setting.c b/sources/c/main/rule/setting.c index a74c64c..6b72e11 100644 --- a/sources/c/main/rule/setting.c +++ b/sources/c/main/rule/setting.c @@ -318,13 +318,13 @@ extern "C" { if (state.status == F_data_not || state.status == F_number || state.status == F_number_overflow || state.status == F_number_underflow || state.status == F_number_negative || state.status == F_number_decimal) { if (state.status == F_number_underflow) { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too small for this system", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an unsupported number", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[j], ", the number is too small for this system", line_item); } else if (state.status == F_number_overflow || state.status == F_number_positive) { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too large for this system", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an unsupported number", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[j], ", the number is too large for this system", line_item); } else { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an invalid number", cache->content_actions.array[i].array[j], ", only whole numbers are allowed for an affinity value", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an invalid number", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[j], ", only whole numbers are allowed for an affinity value", line_item); } state.status = F_status_set_error(F_valid_not); @@ -478,7 +478,7 @@ extern "C" { rule->cgroup.as_new = F_true; } else { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an unknown option", cache->content_actions.array[i].array[0], "", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an unknown option", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[0], "", line_item); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -714,13 +714,13 @@ extern "C" { if (state.status == F_data_not || state.status == F_number || state.status == F_number_overflow || state.status == F_number_underflow || state.status == F_number_negative || state.status == F_number_positive || state.status == F_number_decimal) { if (state.status == F_number_underflow) { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too small for this system", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an unsupported number", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[j], ", the number is too small for this system", line_item); } else if (state.status == F_number_overflow) { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too large for this system", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an unsupported number", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[j], ", the number is too large for this system", line_item); } else { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an unsupported number", cache->content_actions.array[i].array[j], ", only whole numbers are allowed for a resource limit value", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an unsupported number", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[j], ", only whole numbers are allowed for a resource limit value", line_item); } state.status = F_status_set_error(F_valid_not); @@ -946,7 +946,7 @@ extern "C" { rule->scheduler.priority = 49; } else { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an unknown scheduler", cache->content_actions.array[i].array[0], "", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an unknown scheduler", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[0], "", line_item); if (F_status_is_error_not(status_return)) { status_return = F_status_set_error(F_valid_not); @@ -1097,10 +1097,10 @@ extern "C" { state.status = F_status_set_fine(state.status); if (state.status == F_number_overflow) { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an unsupported number", cache->content_actions.array[i].array[1], ", the number is too large for this system", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an unsupported number", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[1], ", the number is too large for this system", line_item); } else if (state.status == F_data_not || state.status == F_number || state.status == F_number_underflow || state.status == F_number_negative || state.status == F_number_positive || state.status == F_number_decimal) { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an invalid number", cache->content_actions.array[i].array[1], ", only positive whole numbers are allowed", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an invalid number", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[1], ", only positive whole numbers are allowed", line_item); } else { @@ -1338,13 +1338,13 @@ extern "C" { state.status = F_status_set_fine(state.status); if (state.status == F_exist_not) { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an invalid user", cache->content_actions.array[i].array[0], ", because no user was found by that name", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an invalid user", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[0], ", because no user was found by that name", line_item); } else if (state.status == F_number_too_large) { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an invalid user", cache->content_actions.array[i].array[0], ", because the given ID is too large", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an invalid user", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[0], ", because the given ID is too large", line_item); } else if (state.status == F_number) { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an invalid user", cache->content_actions.array[i].array[0], ", because the given ID is not a valid supported number", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an invalid user", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[0], ", because the given ID is not a valid supported number", line_item); } else { @@ -1429,13 +1429,13 @@ extern "C" { state.status = F_status_set_fine(state.status); if (state.status == F_exist_not) { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an invalid group", cache->content_actions.array[i].array[j], ", because no group was found by that name", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an invalid group", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[j], ", because no group was found by that name", line_item); } else if (state.status == F_number_too_large) { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an invalid group", cache->content_actions.array[i].array[j], ", because the given ID is too large", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an invalid group", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[j], ", because the given ID is too large", line_item); } else if (state.status == F_number) { - controller_print_error_rule_setting_with_range(&main->program.error, cache, " has an invalid group", cache->content_actions.array[i].array[j], ", because the given ID is not a valid supported number", i, line_item); + controller_print_error_rule_setting_with_range(&main->program.error, &cache->action, " has an invalid group", cache->buffer_item, cache->object_actions.array[i], cache->content_actions.array[i].array[j], ", because the given ID is not a valid supported number", line_item); } else { @@ -1797,16 +1797,7 @@ extern "C" { ++rule->ons.used; } - if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->setting.flag & controller_main_flag_simulate_e))) { - controller_lock_print(main->program.output.to, &main->thread); - - fl_print_format("%rProcessing Rule Item Action '%[%r%]', adding ", main->program.output.to, f_string_eol_s, main->program.context.set.title, controller_on_s, main->program.context.set.title); - fl_print_format("'%[%/Q%]' of ", main->program.output.to, main->program.context.set.notable, cache->buffer_item, cache->content_actions.array[i].array[1], main->program.context.set.notable); - fl_print_format("'%[%/Q%]/", main->program.output.to, main->program.context.set.important, cache->buffer_item, cache->content_actions.array[i].array[2], main->program.context.set.important); - fl_print_format("%[%/Q%]'.%r", main->program.output.to, main->program.context.set.important, cache->buffer_item, cache->content_actions.array[i].array[3], main->program.context.set.important, f_string_eol_s); - - controller_unlock_print_flush(main->program.output.to, &main->thread); - } + controller_print_output_rule_execute_setting_simulate_adding_range_3(&main->program.output, controller_on_s, cache->buffer_item, cache->content_actions.array[i].array[1], cache->content_actions.array[i].array[2], cache->content_actions.array[i].array[3]); } // for // Restore the current name item and line number, which there should already be enough allocated space for. -- 1.8.3.1