From: Kevin Day Date: Thu, 30 May 2024 01:39:13 +0000 (-0500) Subject: Progress: Continue migrating the project. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=a53b4093c67be9db4440b2a0ad4f647f3c2f08c9;p=controller Progress: Continue migrating the project. --- diff --git a/data/build/settings b/data/build/settings index 65517fe..65ea4a2 100644 --- a/data/build/settings +++ b/data/build/settings @@ -45,7 +45,7 @@ build_sources_library main/common/type/cache.c main/common/type/control.c main/c 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/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/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/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 @@ -56,7 +56,7 @@ build_sources_headers main/common/string/general.h main/common/string/rule.h build_sources_headers main/common/type/cache.h main/common/type/control.h main/common/type/entry.h main/common/type/execute.h main/common/type/global.h main/common/type/lock.h main/common/type/instance.h main/common/type/program.h main/common/type/rule.h main/common/type/thread.h 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/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/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/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/main/common.c b/sources/c/main/common.c index 61d4ddc..c621ae6 100644 --- a/sources/c/main/common.c +++ b/sources/c/main/common.c @@ -4,6 +4,61 @@ extern "C" { #endif +#ifndef _di_controller_main_error_simplify_ + f_status_t controller_main_error_simplify(const f_status_t status) { + + if (status == F_memory_not) { + return F_status_set_error(F_memory); + } + + if (status == F_file_open_max || status == F_space_not || status == F_busy) { + return F_status_set_error(F_resource); + } + + if (status == F_access_denied || status == F_filesystem_quota_block || status == F_prohibited || status == F_input_output) { + return F_status_set_error(F_access); + } + + if (status == F_complete_not_utf || status == F_complete_not_utf_block || status == F_complete_not_utf_eof || status == F_complete_not_utf_eol || status == F_complete_not_utf_eos || status == F_complete_not_utf_stop) { + return F_status_set_error(F_encoding); + } + + if (status == F_number || status == F_number_negative || status == F_number_positive || status == F_number_overflow) { + return F_status_set_error(F_number); + } + + if (status == F_parameter || status == F_found_not || status == F_interrupt || status == F_support_not || status == F_critical) { + return F_status_set_error(status); + } + + if (status == F_valid_not) { + return F_status_set_error(F_valid_not); + } + + return F_status_set_error(F_failure); + } +#endif // _di_controller_main_error_simplify_ + +#ifndef _di_controller_main_range_after_number_sign_ + f_range_t controller_main_range_after_number_sign(const f_string_static_t buffer, const f_range_t range) { + + f_range_t result = range; + + for (; result.start <= result.stop; ++result.start) { + + if (!buffer.string[result.start]) continue; + + if (buffer.string[result.start] == f_string_ascii_minus_s.string[0] || buffer.string[result.start] == f_string_ascii_plus_s.string[0]) { + ++result.start; + } + + break; + } // for + + return result; + } +#endif // _di_controller_main_range_after_number_sign_ + #ifndef _di_controller_main_setting_load_ void controller_main_setting_load(const f_console_arguments_t arguments, controller_main_t * const main, controller_program_t * const program) { diff --git a/sources/c/main/common.h b/sources/c/main/common.h index 62f5c17..d75bcdc 100644 --- a/sources/c/main/common.h +++ b/sources/c/main/common.h @@ -17,6 +17,39 @@ extern "C" { #endif /** + * Given a wide range of status codes (that are errors), simplify them down to a small subset. + * + * @param status + * The status code (without the error bit set) to simplify. + * + * @return + * 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; +#endif // _di_controller_main_error_simplify_ + +/** + * Given a string whose range represents a number, seek past the first positive or negative sign. + * + * This will stop at the first non-NULL, non-'+' and non-'-' characters. + * + * Only the first '+' or '-' are processed. + * + * @param buffer + * The string referenced by the range. + * @param range + * The range within the buffer to process. + * + * @return + * The string range. + * 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; +#endif // _di_controller_main_range_after_number_sign_ + +/** * Perform the standard program setting load settings. * * This prints error messages as appropriate. diff --git a/sources/c/main/common/print.c b/sources/c/main/common/print.c index 7ee611b..4dd7aba 100644 --- a/sources/c/main/common/print.c +++ b/sources/c/main/common/print.c @@ -6,7 +6,6 @@ extern "C" { #ifndef _di_controller_f_a_ const f_string_t controller_f_a[] = { - "controller_rule_actions_increase_by", "controller_rule_copy", "controller_rule_items_increase_by", "controller_path_canonical_relative", @@ -33,6 +32,7 @@ extern "C" { "fl_fss_extended_list_content_read", "fl_fss_extended_list_object_read", "fl_iki_read", + "fll_control_group_prepare", "fll_execute_program", "fll_fss_basic_list_read", "fll_fss_extended_read", diff --git a/sources/c/main/common/print.h b/sources/c/main/common/print.h index 91c2f55..7517992 100644 --- a/sources/c/main/common/print.h +++ b/sources/c/main/common/print.h @@ -39,7 +39,6 @@ extern "C" { */ #ifndef _di_controller_f_e_ enum { - controller_f_controller_rule_actions_increase_by_e, controller_f_controller_rule_copy_e, controller_f_controller_rule_items_increase_by_e, controller_f_controller_path_canonical_relative_e, @@ -66,6 +65,7 @@ extern "C" { controller_f_fl_fss_extended_list_content_read_e, controller_f_fl_fss_extended_list_object_read_e, controller_f_fl_iki_read_e, + controller_f_fll_control_group_prepare_e, controller_f_fll_execute_program_e, controller_f_fll_fss_basic_list_read_e, controller_f_fll_fss_extended_read_e, diff --git a/sources/c/main/common/string.c b/sources/c/main/common/string.c index 6c32c05..89b4756 100644 --- a/sources/c/main/common/string.c +++ b/sources/c/main/common/string.c @@ -30,9 +30,10 @@ extern "C" { const f_string_static_t controller_long_validate_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_validate_s, 0, CONTROLLER_long_validate_s_length); #endif // _di_controller_parameter_s_ -/** - * Special strings used for rules. - */ +#ifndef _di_controller_print_rule_s_ + const f_string_static_t controller_print_rule_control_groups_prepare_s = macro_f_string_static_t_initialize_1(CONTROLLER_print_rule_control_groups_prepare_s, 0, CONTROLLER_print_rule_control_groups_prepare_s_length); +#endif // _di_controller_print_rule_s_ + #ifndef _di_controller_rule_s_ const f_string_static_t controller_rule_needed_s = macro_f_string_static_t_initialize_1(CONTROLLER_rule_needed_s, 0, CONTROLLER_rule_needed_s_length); const f_string_static_t controller_rule_wanted_s = macro_f_string_static_t_initialize_1(CONTROLLER_rule_wanted_s, 0, CONTROLLER_rule_wanted_s_length); diff --git a/sources/c/main/common/string.h b/sources/c/main/common/string.h index a335bd5..4d8cfc7 100644 --- a/sources/c/main/common/string.h +++ b/sources/c/main/common/string.h @@ -211,6 +211,16 @@ extern "C" { #endif // _di_controller_default_s_ /** + * Special strings used for printing. + */ +#ifndef _di_controller_print_rule_s_ + #define CONTROLLER_print_rule_control_groups_prepare_s "prepare control groups for" + #define CONTROLLER_print_rule_control_groups_prepare_s_length 24 + + extern const f_string_static_t controller_print_rule_control_groups_prepare_s; +#endif // _di_controller_print_rule_s_ + +/** * Special strings used for rules. */ #ifndef _di_controller_rule_s_ diff --git a/sources/c/main/common/type/global.h b/sources/c/main/common/type/global.h index c770b0e..77c8614 100644 --- a/sources/c/main/common/type/global.h +++ b/sources/c/main/common/type/global.h @@ -22,12 +22,24 @@ extern "C" { * main: The main program data. * program: The program data. * thread: The thread data for a specific thread. + * + * message: A message printer, with custom set to this structure. + * output: An output printer, with custom set to this structure. + * error: An error printer, with custom set to this structure. + * warning: A warning printer, with custom set to this structure. + * debug: A debug printer, with custom set to this structure. */ #ifndef _di_controller_global_t_ typedef struct { controller_main_t *main; controller_program_t *program; controller_thread_t *thread; + + fl_print_t message; + fl_print_t output; + fl_print_t error; + fl_print_t warning; + fl_print_t debug; } controller_global_t; #define controller_global_t_initialize { 0, 0, 0 } @@ -36,6 +48,11 @@ extern "C" { main, \ program, \ thread, \ + fl_print_t_initialize, \ + fl_print_t_initialize, \ + macro_fl_print_t_initialize_error(), \ + macro_fl_print_t_initialize_warning(), \ + macro_fl_print_t_initialize_debug(), \ } #endif // _di_controller_global_t_ diff --git a/sources/c/main/common/type/instance.h b/sources/c/main/common/type/instance.h index 858dc8a..cec4d27 100644 --- a/sources/c/main/common/type/instance.h +++ b/sources/c/main/common/type/instance.h @@ -30,7 +30,7 @@ extern "C" { * action: The action being performed. * options: Configuration options for this thread. * state: The state of the process. - * type: The currently active process type (from the controller_data_type_*_e). + * type: The currently active process type (from the controller_instance_type_*_e). * result: The last return code from an execution of a process. * * active: A read/write lock representing that something is currently using this (read locks = in use, write lock = begin deleting). diff --git a/sources/c/main/controller.h b/sources/c/main/controller.h index 45fe2ad..6db00c5 100644 --- a/sources/c/main/controller.h +++ b/sources/c/main/controller.h @@ -21,6 +21,7 @@ #include #include #include +#include #include // FLL-0 includes. @@ -52,15 +53,18 @@ // FLL-1 includes. #include +#include #include #include #include #include +#include #include #include // FLL-2 includes. #include +#include #include #include #include @@ -82,6 +86,7 @@ #include #include #include +#include #include #include #include @@ -98,6 +103,7 @@ #include #include #include +#include #include #include #include diff --git a/sources/c/main/print/action.c b/sources/c/main/print/action.c new file mode 100644 index 0000000..61f0547 --- /dev/null +++ b/sources/c/main/print/action.c @@ -0,0 +1,9 @@ +#include "../controller.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/main/print/action.h b/sources/c/main/print/action.h new file mode 100644 index 0000000..c020c90 --- /dev/null +++ b/sources/c/main/print/action.h @@ -0,0 +1,23 @@ +/** + * FLL - Level 3 + * + * Project: Controller + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print action functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _controller_main_print_action_h +#define _controller_main_print_action_h + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _controller_main_print_action_h diff --git a/sources/c/main/print/error.c b/sources/c/main/print/error.c index f23c975..522f4e0 100644 --- a/sources/c/main/print/error.c +++ b/sources/c/main/print/error.c @@ -56,6 +56,62 @@ 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 c4dc057..29581ad 100644 --- a/sources/c/main/print/error.h +++ b/sources/c/main/print/error.h @@ -130,6 +130,61 @@ extern "C" { extern f_status_t controller_main_print_error_status(fl_print_t * const print, const f_string_t function, const f_status_t status); #endif // _di_controller_main_print_error_status_ +/** + * Print generic error/warning information. + * + * This is essentially a wrapper to fll_error_print() that includes locking. + * + * @param thread + * The thread data. + * @param print + * Designates how printing is to be performed. + * @param cache + * The action cache. + * @param status + * The status code to process. + * Make sure this has F_status_set_fine() called if the status code has any error or warning bits. + * @param function + * The name of the function where the error happened. + * 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 fll_error_print() + * @see controller_rule_print_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_ + +/** + * Print additional error/warning information in addition to existing error. + * + * This is explicitly intended to be used in addition to the error message. + * + * This neither locks the thread nor does it check to see if output is enabled or disabled. + * + * @param print + * The error or warning output 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. + * + * @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_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_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/sources/c/main/rule/action.c b/sources/c/main/rule/action.c index 1e49195..d62151a 100644 --- a/sources/c/main/rule/action.c +++ b/sources/c/main/rule/action.c @@ -110,14 +110,14 @@ extern "C" { if (F_status_is_error(status)) { controller_main_print_error(&global->main->program.error, macro_controller_f(f_string_dynamic_append_nulless)); - actions->array[actions->used++].status = controller_status_simplify_error(F_status_set_fine(status)); + actions->array[actions->used++].status = controller_main_error_simplify(F_status_set_fine(status)); return status; } if (actions->array[actions->used].parameters.array[0].used) { - state.step_large = controller_common_allocation_iki_large_d; - state.step_small = controller_common_allocation_iki_small_d; + state.step_large = controller_allocation_iki_large_d; + state.step_small = controller_allocation_iki_small_d; state.interrupt = &controller_main_thread_signal_state_iki; f_range_t range_iki = macro_f_range_t_initialize_2(actions->array[actions->used].parameters.array[0].used); @@ -127,7 +127,7 @@ extern "C" { if (F_status_is_error(status)) { controller_main_print_error(&global->main->program.error, macro_controller_f(fl_iki_read)); - actions->array[actions->used++].status = controller_status_simplify_error(F_status_set_fine(status)); + actions->array[actions->used++].status = controller_main_error_simplify(F_status_set_fine(status)); return status; } @@ -160,10 +160,10 @@ extern "C" { for (i = 0; i < cache->object_actions.used; ++i) { - status = controller_rule_actions_increase_by(controller_allocation_small_d, actions); + status = f_memory_array_increase_by(controller_allocation_small_d, sizeof(controller_rule_action_t), (void **) &actions->array, &actions->used, &actions->size); if (F_status_is_error(status)) { - controller_main_print_error(&global->main->program.error, macro_controller_f(controller_rule_actions_increase_by)); + controller_main_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase_by)); return status; } @@ -183,7 +183,7 @@ extern "C" { status = controller_rule_parameters_read(global, cache->buffer_item, &cache->object_actions.array[i], &cache->content_actions.array[i], &actions->array[actions->used], &state); if (F_status_is_error(status)) { - actions->array[actions->used++].status = controller_status_simplify_error(F_status_set_fine(status)); + actions->array[actions->used++].status = controller_main_error_simplify(F_status_set_fine(status)); return status; } @@ -351,14 +351,14 @@ extern "C" { if (F_status_is_error(status)) { controller_main_print_error(&global->main->program.error, macro_controller_f(f_string_dynamic_partial_mash_nulless)); - actions->array[actions->used++].status = controller_status_simplify_error(F_status_set_fine(status)); + actions->array[actions->used++].status = controller_main_error_simplify(F_status_set_fine(status)); return status; } if (actions->array[actions->used].parameters.array[0].used) { - state.step_large = controller_common_allocation_iki_large_d; - state.step_small = controller_common_allocation_iki_small_d; + state.step_large = controller_allocation_iki_large_d; + state.step_small = controller_allocation_iki_small_d; state.interrupt = &controller_main_thread_signal_state_iki; f_range_t range_iki = macro_f_range_t_initialize_2(actions->array[actions->used].parameters.array[0].used); @@ -368,7 +368,7 @@ extern "C" { if (F_status_is_error(status)) { controller_main_print_error(&global->main->program.error, macro_controller_f(fl_iki_read)); - actions->array[actions->used++].status = controller_status_simplify_error(F_status_set_fine(status)); + actions->array[actions->used++].status = controller_main_error_simplify(F_status_set_fine(status)); return status; } @@ -393,7 +393,7 @@ extern "C" { status = controller_rule_parameters_read(global, cache->buffer_item, 0, &cache->content_action, &actions->array[actions->used], &state); if (F_status_is_error(status)) { - actions->array[actions->used++].status = controller_status_simplify_error(F_status_set_fine(status)); + actions->array[actions->used++].status = controller_main_error_simplify(F_status_set_fine(status)); return status; } @@ -407,9 +407,7 @@ extern "C" { } if (F_status_is_error_not(status) && status == F_data_not) { - if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) { - controller_main_print_rule_debug_item_action_empty(&global->main->program.debug); - } + controller_main_print_rule_debug_item_action_empty(&global->main->program.debug, cache); } return status; @@ -429,7 +427,7 @@ extern "C" { status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, cache->content_action.array[++(*index)], &parsed); if (F_status_set_fine(status) == F_number_positive) { - status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, controller_range_after_number_sign(cache->buffer_item, cache->content_action.array[*index]), &parsed); + status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, controller_main_range_after_number_sign(cache->buffer_item, cache->content_action.array[*index]), &parsed); } if (status == F_data_not) { @@ -470,7 +468,7 @@ extern "C" { } } - controller_rule_print_rule_message_cache(&global->main->program.error, cache->action, F_true); + controller_rule_print_rule_message_cache(&global->main->program.error, &cache->action, F_true); controller_unlock_print_flush(global->main->program.error.to, global->thread); } diff --git a/sources/c/main/rule/action.h b/sources/c/main/rule/action.h index f33ed6e..0307966 100644 --- a/sources/c/main/rule/action.h +++ b/sources/c/main/rule/action.h @@ -79,18 +79,53 @@ extern "C" { * @return * F_okay on success. * - * Errors (with error bit) from: controller_rule_actions_increase_by(). * Errors (with error bit) from: controller_rule_parameters_read(). * Errors (with error bit) from: f_fss_count_lines(). + * Errors (with error bit) from: f_memory_array_increase_by(). * - * @see controller_rule_actions_increase_by() * @see controller_rule_parameters_read() * @see f_fss_count_lines() + * @see f_memory_array_increase_by() */ #ifndef _di_controller_rule_action_read_ extern f_status_t controller_rule_action_read(controller_global_t * const global, const bool is_normal, const uint8_t type, const uint8_t method, controller_cache_t * const cache, controller_rule_item_t * const item, controller_rule_actions_t * const actions, f_range_t * const range); #endif // _di_controller_rule_action_read_ +/** + * Process a number from a rule file, incrementing index as necessary. + * + * This prints error messages as necessary. + * + * This is intended to be called by controller_rule_action_read(). + * + * @param global + * The global data. + * Must not be NULL. + * + * This does not alter global.main.setting.state.status. + * @param name + * The name representing the value whose number is being processed. + * @param cache + * A structure for containing and caching relevant data. + * @param index + * The position within the content action array for some rule to process. + * @param number + * The processed number will be saved here. + * + * @return + * F_okay on success. + * + * F_valid_not (with error bit) on failure due to invalid value. + * + * Errors (with error bit) from: fl_conversion_dynamic_partial_to_signed_detect(). + * + * @see controller_rule_action_read() + * @see fl_conversion_dynamic_partial_to_signed_detect() + */ +#ifndef _di_controller_rule_action_read_rerun_number_ + extern f_status_t controller_rule_action_read_rerun_number(controller_global_t * const global, const f_string_t name, controller_cache_t * const cache, f_number_unsigned_t * const index, f_number_unsigned_t * const number); +#endif // _di_controller_rule_action_read_rerun_number_ + #ifdef __cplusplus } // extern "C" diff --git a/sources/c/main/rule/execute.c b/sources/c/main/rule/execute.c index 41b9e82..7eb4326 100644 --- a/sources/c/main/rule/execute.c +++ b/sources/c/main/rule/execute.c @@ -25,55 +25,55 @@ extern "C" { controller_execute_set_t execute_set = macro_controller_execute_set_t_initialize_1(0, 0, &environment, &signals, 0, fl_execute_as_t_initialize); - if (process->rule.affinity.used) { - execute_set.as.affinity = &process->rule.affinity; + if (instance->rule.affinity.used) { + execute_set.as.affinity = &instance->rule.affinity; } - if (process->rule.capability) { - execute_set.as.capability = process->rule.capability; + if (instance->rule.capability) { + execute_set.as.capability = instance->rule.capability; } - if (process->rule.has & controller_rule_has_cgroup_d) { - execute_set.as.control_group = &process->rule.cgroup; + if (instance->rule.has & controller_rule_has_cgroup_d) { + execute_set.as.control_group = &instance->rule.cgroup; // Make sure all required cgroup directories exist. - if (controller_rule_status_is_available(action, process->rule)) { - status = fll_control_group_prepare(process->rule.cgroup); + if (controller_rule_status_is_available(action, instance->rule)) { + status = fll_control_group_prepare(instance->rule.cgroup); if (F_status_is_error(status)) { - controller_main_print_error_file(&main->program.error, macro_controller_f(fll_control_group_prepare), process->rule.cgroup.path, controller_rule_print_control_groups_prepare_s, fll_error_file_type_directory_e); + controller_main_print_error_file(&global->main->program.error, macro_controller_f(fll_control_group_prepare), instance->rule.cgroup.path, controller_print_rule_control_groups_prepare_s, fll_error_file_type_directory_e); return status; } } } - if (process->rule.has & controller_rule_has_group_d) { - execute_set.as.id_group = &process->rule.group; + if (instance->rule.has & controller_rule_has_group_d) { + execute_set.as.id_group = &instance->rule.group; - if (process->rule.groups.used) { - execute_set.as.id_groups = &process->rule.groups; + if (instance->rule.groups.used) { + execute_set.as.id_groups = &instance->rule.groups; } } - if (process->rule.limits.used) { - execute_set.as.limits = &process->rule.limits; + if (instance->rule.limits.used) { + execute_set.as.limits = &instance->rule.limits; } - if (process->rule.has & controller_rule_has_scheduler_d) { - execute_set.as.scheduler = &process->rule.scheduler; + if (instance->rule.has & controller_rule_has_scheduler_d) { + execute_set.as.scheduler = &instance->rule.scheduler; } - if (process->rule.has & controller_rule_has_nice_d) { - execute_set.as.nice = &process->rule.nice; + if (instance->rule.has & controller_rule_has_nice_d) { + execute_set.as.nice = &instance->rule.nice; } - if (process->rule.has & controller_rule_has_user_d) { - execute_set.as.id_user = &process->rule.user; + if (instance->rule.has & controller_rule_has_user_d) { + execute_set.as.id_user = &instance->rule.user; } - if (process->rule.has & controller_rule_has_environment_d) { - status = fl_environment_load_names(process->rule.environment, &environment); + if (instance->rule.has & controller_rule_has_environment_d) { + status = fl_environment_load_names(instance->rule.environment, &environment); if (F_status_is_error(status)) { controller_main_print_error_status(&global->main->program.error, macro_controller_f(fl_environment_load_names), F_status_set_fine(status)); @@ -84,19 +84,19 @@ extern "C" { // When a "define" from the entry/exit is in the "environment", add it to the exported environments (and overwrite any existing environment variable of the same name). controller_entry_t *entry = 0; - if (process->type == controller_data_type_entry_e) { - entry = &global->setting->entry; + if (instance->type == controller_instance_type_entry_e) { + entry = &global->program->entry; } - else if (process->type == controller_data_type_exit_e) { - entry = &global->setting->exit; + else if (instance->type == controller_instance_type_exit_e) { + entry = &global->program->exit; } if (entry) { for (i = 0; i < entry->define.used; ++i) { - for (j = 0; j < process->rule.environment.used; ++j) { + for (j = 0; j < instance->rule.environment.used; ++j) { - if (f_compare_dynamic(entry->define.array[i].key, process->rule.environment.array[j]) == F_equal_to) { + if (f_compare_dynamic(entry->define.array[i].key, instance->rule.environment.array[j]) == F_equal_to) { for (k = 0; k < environment.used; ++k) { @@ -133,19 +133,19 @@ extern "C" { } // When a "define" is in the "environment", add it to the exported environments (and overwrite any existing environment variable of the same name). - for (i = 0; i < process->rule.define.used; ++i) { + for (i = 0; i < instance->rule.define.used; ++i) { - for (j = 0; j < process->rule.environment.used; ++j) { + for (j = 0; j < instance->rule.environment.used; ++j) { - if (f_compare_dynamic(process->rule.define.array[i].key, process->rule.environment.array[j]) == F_equal_to) { + if (f_compare_dynamic(instance->rule.define.array[i].key, instance->rule.environment.array[j]) == F_equal_to) { for (k = 0; k < environment.used; ++k) { - if (f_compare_dynamic(process->rule.define.array[i].key, environment.array[k].key) == F_equal_to) { + if (f_compare_dynamic(instance->rule.define.array[i].key, environment.array[k].key) == F_equal_to) { environment.array[k].value.used = 0; - status = f_string_dynamic_append(process->rule.define.array[i].value, &environment.array[k].value); + status = f_string_dynamic_append(instance->rule.define.array[i].value, &environment.array[k].value); if (F_status_is_error(status)) { controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status)); @@ -158,7 +158,7 @@ extern "C" { } // for if (k == environment.used) { - status = f_string_maps_append(process->rule.define.array[i], &environment); + status = f_string_maps_append(instance->rule.define.array[i], &environment); if (F_status_is_error(status)) { controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_string_maps_append), F_status_set_fine(status)); @@ -175,15 +175,15 @@ extern "C" { else { controller_entry_t *entry = 0; - if (process->type == controller_data_type_entry_e) { - entry = &global->setting->entry; + if (instance->type == controller_instance_type_entry_e) { + entry = &global->program->entry; } - else if (process->type == controller_data_type_exit_e) { - entry = &global->setting->exit; + else if (instance->type == controller_instance_type_exit_e) { + entry = &global->program->exit; } // When a custom define is specified, it needs to be exported into the environment. - if (entry->define.used || process->rule.define.used) { + if (entry->define.used || instance->rule.define.used) { // Copy all environment variables over when a custom define is used. status = f_environment_get_all(&environment); @@ -205,9 +205,9 @@ extern "C" { } } // for - for (i = 0; i < process->rule.define.used; ++i) { + for (i = 0; i < instance->rule.define.used; ++i) { - status = f_string_maps_append(process->rule.define.array[i], &environment); + status = f_string_maps_append(instance->rule.define.array[i], &environment); if (F_status_is_error(status)) { controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_string_maps_append), F_status_set_fine(status)); @@ -223,54 +223,54 @@ extern "C" { } } - for (i = 0; i < process->rule.items.used && controller_thread_is_enabled_process(process, global->thread); ++i) { + for (i = 0; i < instance->rule.items.used && controller_main_thread_is_enabled_instance(instance, global->thread); ++i) { - if (process->rule.items.array[i].type == controller_rule_item_type_settings_e) continue; + if (instance->rule.items.array[i].type == controller_rule_item_type_settings_e) continue; - for (j = 0; j < process->rule.items.array[i].actions.used; ++j) { + for (j = 0; j < instance->rule.items.array[i].actions.used; ++j) { - if (!controller_thread_is_enabled_process(process, global->thread)) { + if (!controller_main_thread_is_enabled_instance(instance, global->thread)) { status = F_status_set_error(F_interrupt); break; } - if (process->rule.items.array[i].actions.array[j].type != action) continue; + if (instance->rule.items.array[i].actions.array[j].type != action) continue; execute_set.parameter.data = 0; execute_set.parameter.option = FL_execute_parameter_option_threadsafe_d | FL_execute_parameter_option_return_d; - if (process->rule.items.array[i].with & controller_with_full_path_d) { + if (instance->rule.items.array[i].with & controller_with_full_path_d) { execute_set.parameter.option |= FL_execute_parameter_option_path_d; } - if (process->rule.items.array[i].with & controller_with_session_new_d) { + if (instance->rule.items.array[i].with & controller_with_session_new_d) { execute_set.parameter.option |= FL_execute_parameter_option_session_d; } - if (process->rule.items.array[i].type == controller_rule_item_type_command_e) { - status = controller_rule_expand(global, process->rule.items.array[i].actions.array[j], process); + if (instance->rule.items.array[i].type == controller_rule_item_type_command_e) { + 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, process->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false); + 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); break; } do { - status = controller_rule_execute_foreground(process->rule.items.array[i].type, f_string_empty_s, process->cache.expanded, options, &execute_set, process); + status = controller_rule_execute_foreground(instance->rule.items.array[i].type, f_string_empty_s, instance->cache.expanded, options, &execute_set, instance); if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; - } while (controller_rule_execute_rerun(controller_rule_action_type_to_action_execute_type(action), process, &process->rule.items.array[i]) > 0); + } while (controller_rule_execute_rerun(controller_rule_action_type_to_action_execute_type(action), instance, &instance->rule.items.array[i]) > 0); if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status)) { - process->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure); + instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure); - if (!(options & controller_process_option_simulate_d)) break; + if (!(options & controller_instance_option_simulate_e)) break; success = F_status_set_error(F_failure); } @@ -278,41 +278,41 @@ extern "C" { success = F_true; } } - else if (process->rule.items.array[i].type == controller_rule_item_type_script_e) { - status = controller_rule_expand(global, process->rule.items.array[i].actions.array[j], process); + else if (instance->rule.items.array[i].type == controller_rule_item_type_script_e) { + 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, process->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false); + 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); break; } - if (process->cache.expanded.used) { - execute_set.parameter.data = &process->cache.expanded.array[0]; + if (instance->cache.expanded.used) { + execute_set.parameter.data = &instance->cache.expanded.array[0]; } else { execute_set.parameter.data = 0; } do { - if (process->rule.engine.used) { - status = controller_rule_execute_foreground(process->rule.items.array[i].type, process->rule.engine, process->rule.engine_arguments, options, &execute_set, process); + if (instance->rule.engine.used) { + status = controller_rule_execute_foreground(instance->rule.items.array[i].type, instance->rule.engine, instance->rule.engine_arguments, options, &execute_set, instance); } else { - status = controller_rule_execute_foreground(process->rule.items.array[i].type, *global->main->setting.default_engine, process->rule.engine_arguments, options, &execute_set, process); + status = controller_rule_execute_foreground(instance->rule.items.array[i].type, *global->main->setting.default_engine, instance->rule.engine_arguments, options, &execute_set, instance); } if (status == F_child || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; - } while (controller_rule_execute_rerun(controller_rule_action_type_to_action_execute_type(action), process, &process->rule.items.array[i]) > 0); + } while (controller_rule_execute_rerun(controller_rule_action_type_to_action_execute_type(action), instance, &instance->rule.items.array[i]) > 0); if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status)) { - process->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure); + instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure); - if (!(options & controller_process_option_simulate_d)) break; + if (!(options & controller_instance_option_simulate_e)) break; success = F_status_set_error(F_failure); } @@ -320,30 +320,30 @@ extern "C" { success = F_true; } } - else if (process->rule.items.array[i].type == controller_rule_item_type_service_e) { - status = controller_rule_expand(global, process->rule.items.array[i].actions.array[j], process); + else if (instance->rule.items.array[i].type == controller_rule_item_type_service_e) { + 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, process->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false); + 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); break; } - if (process->rule.items.array[i].pid_file.used) { + if (instance->rule.items.array[i].pid_file.used) { do { - status = controller_rule_execute_pid_with(process->rule.items.array[i].pid_file, process->rule.items.array[i].type, f_string_empty_s, process->cache.expanded, options, process->rule.items.array[i].with, &execute_set, process); + status = controller_rule_execute_pid_with(instance->rule.items.array[i].pid_file, instance->rule.items.array[i].type, f_string_empty_s, instance->cache.expanded, options, instance->rule.items.array[i].with, &execute_set, instance); if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; - } while (controller_rule_execute_rerun(controller_rule_action_type_to_action_execute_type(action), process, &process->rule.items.array[i]) > 0); + } while (controller_rule_execute_rerun(controller_rule_action_type_to_action_execute_type(action), instance, &instance->rule.items.array[i]) > 0); if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status)) { - process->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure); + instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure); - if (!(options & controller_process_option_simulate_d)) break; + if (!(options & controller_instance_option_simulate_e)) break; success = F_status_set_error(F_failure); } @@ -354,40 +354,40 @@ extern "C" { else { success = F_status_set_error(F_failure); - controller_rule_action_print_error_missing_pid(&global->main->program.error, process->rule.alias); + controller_rule_action_print_error_missing_pid(&global->main->program.error, instance->rule.alias); } } - else if (process->rule.items.array[i].type == controller_rule_item_type_utility_e) { - if (process->rule.items.array[i].pid_file.used) { - status = controller_rule_expand(global, process->rule.items.array[i].actions.array[j], process); + else if (instance->rule.items.array[i].type == controller_rule_item_type_utility_e) { + if (instance->rule.items.array[i].pid_file.used) { + 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, process->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false); + 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); break; } - if (process->cache.expanded.used) { - execute_set.parameter.data = &process->cache.expanded.array[0]; + if (instance->cache.expanded.used) { + execute_set.parameter.data = &instance->cache.expanded.array[0]; } else { execute_set.parameter.data = 0; } do { - status = controller_rule_execute_pid_with(process->rule.items.array[i].pid_file, process->rule.items.array[i].type, process->rule.engine.used ? process->rule.engine : *global->main->setting.default_engine, process->rule.engine_arguments, options, process->rule.items.array[i].with, &execute_set, process); + status = controller_rule_execute_pid_with(instance->rule.items.array[i].pid_file, instance->rule.items.array[i].type, instance->rule.engine.used ? instance->rule.engine : *global->main->setting.default_engine, instance->rule.engine_arguments, options, instance->rule.items.array[i].with, &execute_set, instance); if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; - } while (controller_rule_execute_rerun(controller_rule_action_type_to_action_execute_type(action), process, &process->rule.items.array[i]) > 0); + } while (controller_rule_execute_rerun(controller_rule_action_type_to_action_execute_type(action), instance, &instance->rule.items.array[i]) > 0); if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status)) { - process->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure); + instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure); - if (!(options & controller_process_option_simulate_d)) break; + if (!(options & controller_instance_option_simulate_e)) break; success = F_status_set_error(F_failure); } @@ -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, process->rule.alias); + controller_rule_action_print_error_missing_pid(&global->main->program.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, process->cache.action, F_true); + controller_rule_print_rule_message_cache(&global->main->program.warning, instance->cache.action, F_true); controller_unlock_print_flush(global->main->program.warning.to, global->thread); } @@ -420,7 +420,7 @@ extern "C" { } } // for - if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_is_error(status) && !(options & controller_process_option_simulate_d)) { + if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_is_error(status) && !(options & controller_instance_option_simulate_e)) { break; } } // for @@ -429,13 +429,13 @@ extern "C" { // Lock failed, attempt to re-establish lock before returning. if (F_status_set_fine(status) == F_lock) { - status = controller_lock_read(process, global->thread, &process->lock); + status = controller_lock_read(instance, global->thread, &instance->lock); if (F_status_is_error(status)) return F_status_set_error(F_lock); success = F_false; } - if (!controller_thread_is_enabled_process(process, global->thread)) { + if (!controller_main_thread_is_enabled_instance(instance, global->thread)) { return F_status_set_error(F_interrupt); } @@ -463,15 +463,15 @@ extern "C" { f_status_t status = F_okay; f_status_t status_lock = F_okay; - controller_main_t * const main = (controller_main_t *) process->main_data; - controller_thread_t * const thread = (controller_thread_t *) process->main_thread; + controller_main_t * const main = (controller_main_t *) instance->main_data; + controller_thread_t * const thread = (controller_thread_t *) instance->main_thread; f_execute_result_t result = f_execute_result_t_initialize; - status = controller_pids_increase(&process->childs); + status = controller_pids_increase(&instance->childs); if (F_status_is_error(status)) { - controller_main_print_error_status(&global->main->program.error, macro_controller_f(controller_pids_increase), F_status_set_fine(status)); + controller_main_print_error_status(&main->program.error, macro_controller_f(controller_pids_increase), F_status_set_fine(status)); return status; } @@ -481,18 +481,18 @@ extern "C" { { f_number_unsigned_t i = 0; - while (i < process->childs.used && process->childs.array[i]) { + while (i < instance->childs.used && instance->childs.array[i]) { ++i; } // while - child = &process->childs.array[i]; + child = &instance->childs.array[i]; - if (i == process->childs.used) { - ++process->childs.used; + if (i == instance->childs.used) { + ++instance->childs.used; } } - if (options & controller_process_option_simulate_d) { + if (options & controller_instance_option_simulate_e) { if (main->program.output.verbosity != f_console_verbosity_quiet_e) { controller_lock_print(main->program.output.to, thread); @@ -517,7 +517,7 @@ extern "C" { } // for fl_print_format("%]' from '", main->program.output.to, main->program.context.set.important); - fl_print_format("%[%Q%]'.%r", main->program.output.to, main->program.context.set.notable, process->rule.name, main->program.context.set.notable, f_string_eol_s); + fl_print_format("%[%Q%]'.%r", main->program.output.to, main->program.context.set.notable, instance->rule.name, main->program.context.set.notable, f_string_eol_s); controller_unlock_print_flush(main->program.output.to, thread); } @@ -526,15 +526,15 @@ 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 *) process->main_setting, delay) == -1) { + if (controller_time_sleep_nanoseconds(main, (controller_process_t *) instance->main_setting, delay) == -1) { status = F_status_set_error(F_interrupt); } } if (F_status_set_fine(status) != F_interrupt) { - fl_execute_parameter_t simulated_parameter = macro_fl_execute_parameter_t_initialize_1(execute_set->parameter.option, execute_set->parameter.wait, process->rule.has & controller_rule_has_environment_d ? execute_set->parameter.environment : 0, execute_set->parameter.signals, &f_string_empty_s); + fl_execute_parameter_t simulated_parameter = macro_fl_execute_parameter_t_initialize_1(execute_set->parameter.option, execute_set->parameter.wait, instance->rule.has & controller_rule_has_environment_d ? execute_set->parameter.environment : 0, execute_set->parameter.signals, &f_string_empty_s); - status = fll_execute_program(*main->setting.default_engine, process->rule.engine_arguments, &simulated_parameter, &execute_set->as, (void *) &result); + status = fll_execute_program(*main->setting.default_engine, instance->rule.engine_arguments, &simulated_parameter, &execute_set->as, (void *) &result); } } else { @@ -545,15 +545,15 @@ extern "C" { const pid_t id_child = result.pid; result.status = 0; - f_thread_unlock(&process->lock); + f_thread_unlock(&instance->lock); - status_lock = controller_lock_write_process(process, thread, &process->lock); + status_lock = controller_lock_write_process(instance, thread, &instance->lock); if (F_status_is_error(status_lock)) { - controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status_lock), F_false, thread); + controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false, thread); if (F_status_set_fine(status_lock) != F_interrupt) { - status = controller_lock_read_process(process, thread, &process->lock); + status = controller_lock_read_process(instance, thread, &instance->lock); if (status == F_okay) { return status_lock; @@ -563,24 +563,24 @@ extern "C" { return F_status_set_error(F_lock); } - // Assign the child process id to allow for the cancel process to send appropriate termination signals to the child process. + // Assign the child instance id to allow for the cancel instance to send appropriate termination signals to the child instance. *child = id_child; - f_thread_unlock(&process->lock); + f_thread_unlock(&instance->lock); - status_lock = controller_lock_read_process(process, thread, &process->lock); + status_lock = controller_lock_read_process(instance, thread, &instance->lock); if (F_status_is_error(status_lock)) { - controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status_lock), F_true, thread); + controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true, thread); } if (F_status_set_fine(status_lock) != F_interrupt) { - // Have the parent wait for the child process to finish. + // Have the parent wait for the child instance to finish. waitpid(id_child, &result.status, 0); } - if (F_status_set_fine(status_lock) == F_interrupt || !controller_thread_is_enabled_process(process, thread)) { + 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); } @@ -589,16 +589,16 @@ extern "C" { } if (status_lock == F_okay) { - f_thread_unlock(&process->lock); + f_thread_unlock(&instance->lock); } - status_lock = controller_lock_write_process(process, thread, &process->lock); + status_lock = controller_lock_write_process(instance, thread, &instance->lock); if (F_status_is_error(status_lock)) { - controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status_lock), F_false, thread); + controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false, thread); if (F_status_set_fine(status_lock) != F_interrupt) { - status = controller_lock_read_process(process, thread, &process->lock); + status = controller_lock_read_process(instance, thread, &instance->lock); if (status == F_okay) { return status_lock; @@ -608,17 +608,17 @@ extern "C" { return F_status_set_error(F_lock); } - process->result = result.status; + instance->result = result.status; // Remove the pid now that waidpid() has returned. *child = 0; - f_thread_unlock(&process->lock); + f_thread_unlock(&instance->lock); - status_lock = controller_lock_read_process(process, thread, &process->lock); + status_lock = controller_lock_read_process(instance, thread, &instance->lock); if (F_status_is_error(status_lock)) { - controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status_lock), F_true, thread); + controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true, thread); return F_status_set_error(F_lock); } @@ -633,7 +633,7 @@ extern "C" { else { main->program.child = result.status; - if (!controller_thread_is_enabled_process(process, thread)) { + if (!controller_main_thread_is_enabled_instance(instance, thread)) { return F_status_set_error(F_interrupt); } } @@ -656,11 +656,11 @@ extern "C" { if (F_status_is_error(status)) { status = F_status_set_fine(status); - if ((WIFEXITED(process->result) && WEXITSTATUS(process->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, process); + 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); } else { - controller_main_print_error_status(&global->main->program.error, macro_controller_f(fll_execute_program), F_status_set_fine(status)); + controller_main_print_error_status(&main->program.error, macro_controller_f(fll_execute_program), F_status_set_fine(status)); } status = F_status_set_error(status); @@ -678,23 +678,23 @@ extern "C" { f_status_t status = F_okay; f_status_t status_lock = F_okay; - controller_main_t * const main = (controller_main_t *) process->main_data; - controller_thread_t * const thread = (controller_thread_t *) process->main_thread; + controller_main_t * const main = (controller_main_t *) instance->main_data; + controller_thread_t * const thread = (controller_thread_t *) instance->main_thread; f_execute_result_t result = f_execute_result_t_initialize; - status = controller_pids_increase(&process->childs); + status = controller_pids_increase(&instance->childs); if (F_status_is_error(status)) { - controller_main_print_error_status(&global->main->program.error, macro_controller_f(controller_pids_increase), F_status_set_fine(status)); + controller_main_print_error_status(&main->program.error, macro_controller_f(controller_pids_increase), F_status_set_fine(status)); return status; } - status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &process->path_pids.array, &process->path_pids.used, &process->path_pids.size); + status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &instance->path_pids.array, &instance->path_pids.used, &instance->path_pids.size); if (F_status_is_error(status)) { - controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_memory_array_increase), F_status_set_fine(status)); + controller_main_print_error_status(&main->program.error, macro_controller_f(f_memory_array_increase), F_status_set_fine(status)); return status; } @@ -705,33 +705,33 @@ extern "C" { { f_number_unsigned_t i = 0; - while (i < process->childs.used && process->childs.array[i]) { + while (i < instance->childs.used && instance->childs.array[i]) { ++i; } // while - child = &process->childs.array[i]; + child = &instance->childs.array[i]; - if (i == process->childs.used) { - ++process->childs.used; + if (i == instance->childs.used) { + ++instance->childs.used; } i = 0; - while (i < process->path_pids.used && process->path_pids.array[i].used) { + while (i < instance->path_pids.used && instance->path_pids.array[i].used) { ++i; } // while - child_pid_file = &process->path_pids.array[i]; + child_pid_file = &instance->path_pids.array[i]; - if (i == process->path_pids.used) { - ++process->path_pids.used; + if (i == instance->path_pids.used) { + ++instance->path_pids.used; } } status = f_file_exists(pid_file, F_true); if (F_status_is_error(status) || status == F_true) { - controller_main_print_error_file_status(&global->main->program.error, macro_controller_f(f_file_exists), status == F_true ? F_file_found : F_status_set_fine(status), pid_file, f_file_operation_find_s, fll_error_file_type_file_e); + controller_main_print_error_file_status(&main->program.error, macro_controller_f(f_file_exists), status == F_true ? F_file_found : F_status_set_fine(status), pid_file, f_file_operation_find_s, fll_error_file_type_file_e); return status; } @@ -739,12 +739,12 @@ extern "C" { status = f_string_dynamic_append_nulless(pid_file, child_pid_file); if (F_status_is_error(status)) { - controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_append_nulless), F_status_set_fine(status)); + controller_main_print_error_status(&main->program.error, macro_controller_f(f_string_dynamic_append_nulless), F_status_set_fine(status)); return status; } - if (options & controller_process_option_simulate_d) { + if (options & controller_instance_option_simulate_e) { if (main->program.error.verbosity > f_console_verbosity_error_e) { controller_lock_print(main->program.error.to, thread); @@ -769,7 +769,7 @@ extern "C" { } // for fl_print_format("%]' from '", main->program.error.to, main->program.context.set.important); - fl_print_format("%[%Q%]'.%r", main->program.error.to, main->program.context.set.notable, process->rule.name, main->program.context.set.notable, f_string_eol_s); + fl_print_format("%[%Q%]'.%r", main->program.error.to, main->program.context.set.notable, instance->rule.name, main->program.context.set.notable, f_string_eol_s); controller_unlock_print_flush(main->program.error.to, thread); } @@ -778,14 +778,14 @@ 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 *) process->main_setting, delay) == -1) { + if (controller_time_sleep_nanoseconds(main, (controller_process_t *) instance->main_setting, delay) == -1) { status = F_status_set_error(F_interrupt); } } if (F_status_set_fine(status) != F_interrupt) { const f_string_statics_t simulated_arguments = f_string_statics_t_initialize; - fl_execute_parameter_t simulated_parameter = macro_fl_execute_parameter_t_initialize_1(execute_set->parameter.option, execute_set->parameter.wait, process->rule.has & controller_rule_has_environment_d ? execute_set->parameter.environment : 0, execute_set->parameter.signals, &f_string_empty_s); + fl_execute_parameter_t simulated_parameter = macro_fl_execute_parameter_t_initialize_1(execute_set->parameter.option, execute_set->parameter.wait, instance->rule.has & controller_rule_has_environment_d ? execute_set->parameter.environment : 0, execute_set->parameter.signals, &f_string_empty_s); status = fll_execute_program(*main->setting.default_engine, simulated_arguments, &simulated_parameter, &execute_set->as, (void *) &result); } @@ -798,15 +798,15 @@ extern "C" { const pid_t id_child = result.pid; result.status = 0; - f_thread_unlock(&process->lock); + f_thread_unlock(&instance->lock); - status_lock = controller_lock_write_process(process, thread, &process->lock); + status_lock = controller_lock_write_process(instance, thread, &instance->lock); if (F_status_is_error(status_lock)) { - controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status_lock), F_false, thread); + controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false, thread); if (F_status_set_fine(status_lock) != F_interrupt) { - status = controller_lock_read_process(process, thread, &process->lock); + status = controller_lock_read_process(instance, thread, &instance->lock); if (status == F_okay) { return status_lock; @@ -816,24 +816,24 @@ extern "C" { return F_status_set_error(F_lock); } - // Assign the child process id to allow for the cancel process to send appropriate termination signals to the child process. + // Assign the child instance id to allow for the cancel instance to send appropriate termination signals to the child instance. *child = id_child; - f_thread_unlock(&process->lock); + f_thread_unlock(&instance->lock); - status_lock = controller_lock_read_process(process, thread, &process->lock); + status_lock = controller_lock_read_process(instance, thread, &instance->lock); if (F_status_is_error(status_lock)) { - controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status_lock), F_true, thread); + controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true, thread); } if (F_status_set_fine(status_lock) != F_interrupt) { - // The child process should perform the change into background, therefore it is safe to wait for the child to exit (another process is spawned). + // The child instance should perform the change into background, therefore it is safe to wait for the child to exit (another instance is spawned). waitpid(id_child, &result.status, 0); } - if (!controller_thread_is_enabled_process(process, thread)) { + if (!controller_main_thread_is_enabled_instance(instance, thread)) { if (status_lock == F_okay) { return F_status_set_error(F_interrupt); } @@ -842,16 +842,16 @@ extern "C" { } if (status_lock == F_okay) { - f_thread_unlock(&process->lock); + f_thread_unlock(&instance->lock); } - status_lock = controller_lock_write_process(process, thread, &process->lock); + status_lock = controller_lock_write_process(instance, thread, &instance->lock); if (F_status_is_error(status_lock)) { - controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status_lock), F_false, thread); + controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false, thread); if (F_status_set_fine(status_lock) != F_interrupt) { - status = controller_lock_read_process(process, thread, &process->lock); + status = controller_lock_read_process(instance, thread, &instance->lock); if (status == F_okay) { return status_lock; @@ -861,17 +861,17 @@ extern "C" { return F_status_set_error(F_lock); } - process->result = result.status; + instance->result = result.status; // Remove the pid now that waidpid() has returned. *child = 0; - f_thread_unlock(&process->lock); + f_thread_unlock(&instance->lock); - status_lock = controller_lock_read_process(process, thread, &process->lock); + status_lock = controller_lock_read_process(instance, thread, &instance->lock); if (F_status_is_error(status_lock)) { - controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status_lock), F_true, thread); + controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true, thread); return F_status_set_error(F_lock); } @@ -886,7 +886,7 @@ extern "C" { else { main->program.child = result.status; - if (!controller_thread_is_enabled_process(process, thread)) { + if (!controller_main_thread_is_enabled_instance(instance, thread)) { return F_status_set_error(F_interrupt); } } @@ -909,11 +909,11 @@ extern "C" { if (F_status_is_error(status)) { status = F_status_set_fine(status); - if ((WIFEXITED(process->result) && WEXITSTATUS(process->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, process); + 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); } else { - controller_main_print_error_status(&global->main->program.error, macro_controller_f(fll_execute_program), F_status_set_fine(status)); + controller_main_print_error_status(&main->program.error, macro_controller_f(fll_execute_program), F_status_set_fine(status)); } return F_status_set_error(status); @@ -928,21 +928,21 @@ extern "C" { if (!instance || !item) return F_status_set_error(F_parameter); - const int result = WIFEXITED(process->result) ? WEXITSTATUS(process->result) : 0; + 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 *) process->main_data; - controller_thread_t * const thread = (controller_thread_t *) process->main_thread; + controller_main_t * const main = (controller_main_t *) instance->main_data; + controller_thread_t * const thread = (controller_thread_t *) instance->main_thread; controller_rule_rerun_item_t *rerun_item = result ? &item->reruns[action].failure : &item->reruns[action].success; - if (!controller_thread_is_enabled_process(process, thread)) return -2; + if (!controller_main_thread_is_enabled_instance(instance, thread)) return -2; if (!rerun_item->max || rerun_item->count < rerun_item->max) { if (main->program.error.verbosity == f_console_verbosity_debug_e) { controller_lock_print(main->program.output.to, thread); fl_print_format("%rRe-running '", main->program.output.to, f_string_eol_s); - fl_print_format("%[%r%]' '", main->program.output.to, main->program.context.set.title, process->rule.alias, main->program.context.set.title); + fl_print_format("%[%r%]' '", main->program.output.to, main->program.context.set.title, instance->rule.alias, main->program.context.set.title); fl_print_format("%[%r%]' with a ", main->program.output.to, main->program.context.set.notable, controller_rule_action_execute_type_name(action), main->program.context.set.notable); fl_print_format("%[%r%] of ", main->program.output.to, main->program.context.set.notable, controller_delay_s, main->program.context.set.notable); fl_print_format("%[%ul%] MegaTime", main->program.output.to, main->program.context.set.notable, rerun_item->delay, main->program.context.set.notable); @@ -963,11 +963,11 @@ extern "C" { if (rerun_item->delay) { const f_time_spec_t delay = controller_time_milliseconds(rerun_item->delay); - if (controller_time_sleep_nanoseconds(main, (controller_process_t *) process->main_setting, delay) == -1) { + if (controller_time_sleep_nanoseconds(main, (controller_process_t *) instance->main_setting, delay) == -1) { return -1; } - if (!controller_thread_is_enabled_process(process, thread)) return -2; + if (!controller_main_thread_is_enabled_instance(instance, thread)) return -2; } if (item->reruns[action].is & (result ? controller_rule_rerun_is_failure_reset_d : controller_rule_rerun_is_success_reset_d)) { diff --git a/sources/c/main/rule/execute.h b/sources/c/main/rule/execute.h index 76d9880..f9fd110 100644 --- a/sources/c/main/rule/execute.h +++ b/sources/c/main/rule/execute.h @@ -39,7 +39,7 @@ extern "C" { * - controller_rule_action_type_stop_e * @param options * Process options to consider when executing. - * If bit controller_process_option_simulate_d, then the rule execution is in simulation mode (printing a message that the rule would be executed but does not execute the rule). + * If bit controller_instance_option_simulate_e, then the rule execution is in simulation mode (printing a message that the rule would be executed but does not execute the rule). * @param process * The process data for processing this rule. * @@ -73,7 +73,7 @@ extern "C" { * The arguments to pass to the program. * @param options * Process options to consider when executing. - * If bit controller_process_option_simulate_d, then the rule execution is in simulation mode (printing a message that the rule would be executed but does not execute the rule). + * If bit controller_instance_option_simulate_e, then the rule execution is in simulation mode (printing a message that the rule would be executed but does not execute the rule). * @param execute_set * The execute parameter and as settings. * @param process @@ -112,7 +112,7 @@ extern "C" { * The arguments to pass to the program. * @param options * Process options to consider when executing. - * If bit controller_process_option_simulate_d, then the rule execution is in simulation mode (printing a message that the rule would be executed but does not execute the rule). + * If bit controller_instance_option_simulate_e, then the rule execution is in simulation mode (printing a message that the rule would be executed but does not execute the rule). * @param with * The "with" option flags. * @param execute_set diff --git a/sources/c/main/rule/expand.c b/sources/c/main/rule/expand.c index e76d144..6256339 100644 --- a/sources/c/main/rule/expand.c +++ b/sources/c/main/rule/expand.c @@ -111,7 +111,7 @@ extern "C" { } // for if (i == process->rule.define.used) { - controller_entry_t * const entry = process->type == controller_data_type_entry_e ? &((controller_process_t *) process->main_setting)->entry : &((controller_process_t *) process->main_setting)->exit; + controller_entry_t * const entry = process->type == controller_instance_type_entry_e ? &((controller_process_t *) process->main_setting)->entry : &((controller_process_t *) process->main_setting)->exit; for (i = 0; i < entry->define.used; ++i) { @@ -160,7 +160,7 @@ extern "C" { } // for if (i == process->rule.parameter.used) { - controller_entry_t * const entry = process->type == controller_data_type_entry_e ? &((controller_process_t *) process->main_setting)->entry : &((controller_process_t *) process->main_setting)->exit; + controller_entry_t * const entry = process->type == controller_instance_type_entry_e ? &((controller_process_t *) process->main_setting)->entry : &((controller_process_t *) process->main_setting)->exit; for (i = 0; i < entry->parameter.used; ++i) { @@ -185,7 +185,6 @@ extern "C" { f_console_standard_long_normal_s, f_console_standard_long_verbose_s, f_console_standard_long_debug_s, - controller_long_init_s, controller_long_interruptible_s, controller_long_daemon_s, controller_long_simulate_s, @@ -207,9 +206,8 @@ extern "C" { f_console_symbol_short_inverse_s, // normal. f_console_symbol_short_inverse_s, // verbose. f_console_symbol_short_inverse_s, // debug. - f_console_symbol_short_normal_s, // daemon. - f_console_symbol_short_normal_s, // init. f_console_symbol_short_normal_s, // interruptible. + f_console_symbol_short_normal_s, // daemon. f_console_symbol_short_normal_s, // simulate. f_console_symbol_short_normal_s, // uninterruptible. f_console_symbol_short_normal_s, // validate. @@ -229,7 +227,6 @@ extern "C" { f_console_standard_short_normal_s, f_console_standard_short_verbose_s, f_console_standard_short_debug_s, - controller_short_init_s, controller_short_interruptible_s, controller_short_daemon_s, controller_short_simulate_s, @@ -244,14 +241,13 @@ extern "C" { }; const uint8_t codes[] = { - f_console_standard_parameter_help_e, + f_console_standard_parameter_light_e, f_console_standard_parameter_dark_e, f_console_standard_parameter_no_color_e, f_console_standard_parameter_verbosity_quiet_e, f_console_standard_parameter_verbosity_normal_e, f_console_standard_parameter_verbosity_verbose_e, f_console_standard_parameter_verbosity_debug_e, - controller_parameter_init_e, controller_parameter_interruptible_e, controller_parameter_daemon_e, controller_parameter_simulate_e, @@ -274,9 +270,8 @@ extern "C" { F_false, // normal. F_false, // verbose. F_false, // debug. - F_false, // daemon. - F_false, // init. F_false, // interruptible. + F_false, // daemon. F_false, // simulate. F_false, // uninterruptible. F_false, // validate. @@ -288,7 +283,7 @@ extern "C" { F_true, // socket. }; - for (f_number_unsigned_t i = 0; i < 17; ++i) { + for (f_number_unsigned_t i = 0; i < 16; ++i) { if (f_compare_dynamic_partial_string(options[i].string, source, options[i].used, content) == F_equal_to) { if (values[i]) { diff --git a/sources/c/main/rule/instance.c b/sources/c/main/rule/instance.c index 06029a5..3437177 100644 --- a/sources/c/main/rule/instance.c +++ b/sources/c/main/rule/instance.c @@ -76,7 +76,7 @@ extern "C" { return status; } - if ((instance->options & controller_instance_option_simulate_d) && (instance->options & controller_instance_option_validate_d)) { + if ((instance->options & controller_instance_option_simulate_e) && (instance->options & controller_instance_option_validate_e)) { controller_rule_validate(global, instance->rule, instance->action, instance->options, &instance->cache); } @@ -182,7 +182,7 @@ extern "C" { status = F_false; } else { - status = controller_rule_find(dynamics[i]->array[j], global->setting->rules, &id_rule); + status = controller_rule_find(dynamics[i]->array[j], global->program->rules, &id_rule); f_thread_unlock(&global->thread->lock.rule); } @@ -206,7 +206,7 @@ extern "C" { status = F_status_set_error(F_found_not); - if (!(instance->options & controller_instance_option_simulate_d)) { + if (!(instance->options & controller_instance_option_simulate_e)) { if (dependency) { f_thread_unlock(&dependency->active); } @@ -241,12 +241,12 @@ extern "C" { // The dependency may have write locks, which needs to be avoided, so copy the alias from the rule. f_string_static_t alias_other_buffer = f_string_static_t_initialize; - alias_other_buffer.used = global->setting->rules.array[id_rule].alias.used; + alias_other_buffer.used = global->program->rules.array[id_rule].alias.used; f_char_t alias_other_buffer_string[alias_other_buffer.used + 1]; alias_other_buffer.string = alias_other_buffer_string; - memcpy(alias_other_buffer_string, global->setting->rules.array[id_rule].alias.string, sizeof(f_char_t) * alias_other_buffer.used); + memcpy(alias_other_buffer_string, global->program->rules.array[id_rule].alias.string, sizeof(f_char_t) * alias_other_buffer.used); alias_other_buffer_string[alias_other_buffer.used] = 0; f_thread_unlock(&global->thread->lock.rule); @@ -263,7 +263,7 @@ extern "C" { status = controller_instance_wait(global, dependency); - if (F_status_is_error(status) && !(instance->options & controller_instance_option_simulate_d)) break; + if (F_status_is_error(status) && !(instance->options & controller_instance_option_simulate_e)) break; status = dependency->rule.status[instance->action]; } @@ -277,18 +277,18 @@ extern "C" { status = status_lock; } - else if (controller_rule_status_is_available(instance->action, global->setting->rules.array[id_rule])) { + else if (controller_rule_status_is_available(instance->action, global->program->rules.array[id_rule])) { f_thread_unlock(&global->thread->lock.rule); f_thread_unlock(&dependency->lock); options_instance = 0; if (global->main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) { - options_instance |= controller_instance_option_simulate_d; + options_instance |= controller_instance_option_simulate_e; } - if (instance->options & controller_instance_option_validate_d) { - options_instance |= controller_instance_option_validate_d; + if (instance->options & controller_instance_option_validate_e) { + options_instance |= controller_instance_option_validate_e; } // Synchronously execute dependency. @@ -309,7 +309,7 @@ extern "C" { controller_unlock_print_flush(global->main->program.error.to, global->thread); - if (!(dependency->options & controller_instance_option_simulate_d) || F_status_set_fine(status) == F_memory_not) { + if (!(dependency->options & controller_instance_option_simulate_e) || F_status_set_fine(status) == F_memory_not) { f_thread_unlock(&dependency->active); break; @@ -329,7 +329,7 @@ extern "C" { } } else { - status = global->setting->rules.array[id_rule].status[instance->action]; + status = global->program->rules.array[id_rule].status[instance->action]; f_thread_unlock(&global->thread->lock.rule); f_thread_unlock(&dependency->lock); @@ -357,7 +357,7 @@ extern "C" { status = status_lock; } - else if (controller_rule_status_is_error(instance->action, global->setting->rules.array[id_rule])) { + else if (controller_rule_status_is_error(instance->action, global->program->rules.array[id_rule])) { f_thread_unlock(&global->thread->lock.rule); if (i == 0 || i == 1) { @@ -371,7 +371,7 @@ extern "C" { status = F_status_set_error(F_found_not); - if (!(dependency->options & controller_instance_option_simulate_d)) { + if (!(dependency->options & controller_instance_option_simulate_e)) { f_thread_unlock(&dependency->active); break; @@ -401,7 +401,7 @@ extern "C" { if (status == F_child || F_status_set_fine(status) == F_interrupt) break; - if (F_status_is_error(status) && !(instance->options & controller_instance_option_simulate_d)) break; + if (F_status_is_error(status) && !(instance->options & controller_instance_option_simulate_e)) break; } // for } @@ -413,7 +413,7 @@ extern "C" { return F_status_set_error(F_interrupt); } - if ((instance->options & controller_instance_option_wait_d) && F_status_is_error_not(status) && (instance->options & controller_instance_option_validate_d)) { + if ((instance->options & controller_instance_option_wait_e) && F_status_is_error_not(status) && (instance->options & controller_instance_option_validate_e)) { status_lock = controller_rule_wait_all_instance_type(global, instance->type, F_false); if (F_status_set_fine(status_lock) == F_interrupt) { @@ -421,10 +421,10 @@ extern "C" { } } - if (!(instance->options & controller_instance_option_validate_d) && F_status_is_error_not(status)) { + if (!(instance->options & controller_instance_option_validate_e) && F_status_is_error_not(status)) { // Find at least one of the requested action when the rule is required. - if (instance->options & controller_instance_option_require_d) { + if (instance->options & controller_instance_option_require_e) { bool missing = F_true; f_number_unsigned_t j = 0; @@ -508,7 +508,7 @@ extern "C" { } if (F_status_is_error(status)) { - instance->rule.status[instance->action] = controller_status_simplify_error(F_status_set_fine(status)); + instance->rule.status[instance->action] = controller_main_error_simplify(F_status_set_fine(status)); } else { instance->rule.status[instance->action] = status; @@ -528,8 +528,8 @@ extern "C" { } // Update the global rule status, which is stored separately from the rule status for this instance. - if (controller_rule_find(instance->rule.alias, global->setting->rules, &id_rule) == F_true) { - controller_rule_t *rule = &global->setting->rules.array[id_rule]; + if (controller_rule_find(instance->rule.alias, global->program->rules, &id_rule) == F_true) { + controller_rule_t *rule = &global->program->rules.array[id_rule]; rule->status[instance->action] = instance->rule.status[instance->action]; @@ -734,7 +734,7 @@ extern "C" { f_thread_unlock(&instance->lock); if (F_status_is_error_not(status)) { - if (instance->action && (options_force & controller_instance_option_asynchronous_d)) { + if (instance->action && (options_force & controller_instance_option_asynchronous_e)) { if (instance->type == controller_instance_type_exit_e) { status = f_thread_create(0, &instance->id_thread, controller_main_thread_instance_other, (void *) instance); } @@ -770,7 +770,7 @@ extern "C" { } } - if (!action || (options_force & controller_instance_option_asynchronous_d)) { + if (!action || (options_force & controller_instance_option_asynchronous_e)) { instance->state = controller_instance_state_done_e; } else { @@ -801,10 +801,22 @@ extern "C" { f_status_t status_lock = F_okay; - controller_global_t * const global = macro_controller_global_t_initialize_1((controller_main_t *) instance->main_data, (controller_instance_t *) instance->main_setting, (controller_thread_t *) instance->main_thread); + controller_global_t global = macro_controller_global_t_initialize((controller_main_t *) instance->main_data, (controller_instance_t *) instance->main_setting, (controller_thread_t *) instance->main_thread); + + global->message = global->main->program.message; + global->output = global->main->program.output; + global->error = global->main->program.error; + global->warning = global->main->program.warning; + global->debug = global->main->program.debug; + + global->message.custom = (void *) &global; + global->output.custom = (void *) &global; + global->error.custom = (void *) &global; + global->warning.custom = (void *) &global; + global->debug.custom = (void *) &global; // The instance and active locks shall be held for the duration of this instanceing (aside from switching between read to/from write). - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { status_lock = controller_lock_read_instance(instance, global->thread, &instance->active); if (F_status_is_error(status_lock)) { @@ -819,7 +831,7 @@ extern "C" { if (F_status_is_error(status_lock)) { controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status_lock), F_true, global->thread); - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } @@ -839,14 +851,14 @@ extern "C" { f_thread_unlock(&instance->lock); - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } return status_lock; } - if (controller_rule_find(instance->rule.alias, global->setting->rules, &id_rule) == F_true) { + if (controller_rule_find(instance->rule.alias, global->program->rules, &id_rule) == F_true) { f_thread_unlock(&instance->lock); status_lock = controller_lock_write_instance(instance, global->thread, &instance->lock); @@ -856,7 +868,7 @@ extern "C" { f_thread_unlock(&global->thread->lock.rule); - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } @@ -865,7 +877,7 @@ extern "C" { controller_rule_delete(&instance->rule); - status = controller_rule_copy(global->setting->rules.array[id_rule], &instance->rule); + status = controller_rule_copy(global->program->rules.array[id_rule], &instance->rule); f_thread_unlock(&instance->lock); @@ -876,7 +888,7 @@ extern "C" { f_thread_unlock(&global->thread->lock.rule); - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } @@ -893,7 +905,7 @@ extern "C" { // This is a "consider" Action, so do not actually execute the rule. f_thread_unlock(&instance->lock); - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } @@ -925,7 +937,7 @@ extern "C" { if (!controller_thread_is_enabled_instance(instance, global->thread)) { f_thread_unlock(&instance->lock); - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } @@ -946,7 +958,7 @@ extern "C" { if (F_status_is_error(status_lock)) { controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status_lock), F_false, global->thread); - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } @@ -962,7 +974,7 @@ extern "C" { if (F_status_is_error(status_lock)) { controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status_lock), F_true, global->thread); - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } @@ -994,7 +1006,7 @@ extern "C" { if (status == F_child) { f_thread_unlock(&instance->lock); - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } @@ -1010,7 +1022,7 @@ extern "C" { f_thread_unlock(&instance->lock); } - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } @@ -1018,8 +1030,8 @@ extern "C" { } if (F_status_set_fine(status) == F_lock) { - if (controller_rule_find(instance->rule.alias, global->setting->rules, &id_rule) == F_true) { - global->setting->rules.array[id_rule].status[instance->action] = status; + if (controller_rule_find(instance->rule.alias, global->program->rules, &id_rule) == F_true) { + global->program->rules.array[id_rule].status[instance->action] = status; } } @@ -1030,7 +1042,7 @@ extern "C" { } if (F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock && !controller_thread_is_enabled_instance(instance, global->thread)) { - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } @@ -1042,14 +1054,14 @@ extern "C" { if (F_status_is_error(status_lock)) { controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status_lock), F_false, global->thread); - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } return status_lock; } - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { instance->state = controller_instance_state_done_e; } else { @@ -1065,7 +1077,7 @@ extern "C" { f_thread_unlock(&instance->lock); - if (options_force & controller_instance_option_asynchronous_d) { + if (options_force & controller_instance_option_asynchronous_e) { f_thread_unlock(&instance->active); } diff --git a/sources/c/main/rule/instance.h b/sources/c/main/rule/instance.h index 59b156e..5a130f3 100644 --- a/sources/c/main/rule/instance.h +++ b/sources/c/main/rule/instance.h @@ -62,8 +62,8 @@ extern "C" { * @param options_force * Force the given instance options, only supporting a subset of instance options. * - * If controller_instance_option_asynchronous_d, then asynchronously execute. - * If not controller_instance_option_asynchronous_d, then synchronously execute. + * If controller_instance_option_asynchronous_e, then asynchronously execute. + * If not controller_instance_option_asynchronous_e, then synchronously execute. * @param alias_rule * The alias of the rule, such as "boot/init". * @param action @@ -71,7 +71,7 @@ extern "C" { * @param options * The instance options to pass to the instance. * @param type - * The instance type, such as controller_data_type_entry_e. + * The instance type, such as controller_instance_type_entry_e. * @param stack * A stack representing the instances already running in this rule instance dependency tree. * This is used to prevent circular dependencies. @@ -109,8 +109,8 @@ extern "C" { * @param options_force * Force the given instance options, only supporting a subset of instance options. * - * If controller_instance_option_asynchronous_d, then asynchronously execute. - * If not controller_instance_option_asynchronous_d, then synchronously execute. + * If controller_instance_option_asynchronous_e, then asynchronously execute. + * If not controller_instance_option_asynchronous_e, then synchronously execute. * @param instance * The instance data. * diff --git a/sources/c/main/rule/item.c b/sources/c/main/rule/item.c index 7656c1a..955e740 100644 --- a/sources/c/main/rule/item.c +++ b/sources/c/main/rule/item.c @@ -161,10 +161,10 @@ extern "C" { method = controller_rule_action_method_extended_e; } - status = controller_rule_actions_increase_by(controller_allocation_small_d, &item->actions); + status = f_memory_array_increase_by(controller_allocation_small_d, sizeof(controller_rule_action_t), (void **) &item->actions.array, &item->actions.used, &item->actions.size); if (F_status_is_error(status)) { - controller_main_print_error_status(&global->main->program.error, macro_controller_f(controller_rule_actions_increase_by), F_status_set_fine(status)); + controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_memory_array_increase_by), F_status_set_fine(status)); break; } diff --git a/sources/c/main/rule/read.c b/sources/c/main/rule/read.c index 47e0f2f..fe5e06a 100644 --- a/sources/c/main/rule/read.c +++ b/sources/c/main/rule/read.c @@ -328,7 +328,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)); - rule->status[0] = controller_status_simplify_error(F_status_set_fine(status)); + rule->status[0] = controller_main_error_simplify(F_status_set_fine(status)); return rule->status[0]; } diff --git a/sources/c/main/rule/read.h b/sources/c/main/rule/read.h index 390b495..75c69c4 100644 --- a/sources/c/main/rule/read.h +++ b/sources/c/main/rule/read.h @@ -42,7 +42,7 @@ extern "C" { * @return * F_okay on success. * - * Simplified status (with error bit) from controller_status_simplify_error() on failure. + * Simplified status (with error bit) from controller_main_error_simplify() on failure. * * @see controller_rule_items_increase_by(). * @see controller_rule_item_read(). @@ -56,41 +56,6 @@ extern "C" { extern f_status_t controller_rule_read(controller_global_t * const global, const bool is_normal, const f_string_static_t alias, controller_cache_t * const cache, controller_entry_t * const entry, controller_rule_t * const rule); #endif // _di_controller_rule_read_ -/** - * Process a number from a rule file, incrementing index as necessary. - * - * This prints error messages as necessary. - * - * This is intended to be called by controller_rule_action_read(). - * - * @param global - * The global data. - * Must not be NULL. - * - * This does not alter global.main.setting.state.status. - * @param name - * The name representing the value whose number is being processed. - * @param cache - * A structure for containing and caching relevant data. - * @param index - * The position within the content action array for some rule to process. - * @param number - * The processed number will be saved here. - * - * @return - * F_okay on success. - * - * F_valid_not (with error bit) on failure due to invalid value. - * - * Errors (with error bit) from: fl_conversion_dynamic_partial_to_signed_detect(). - * - * @see controller_rule_action_read() - * @see fl_conversion_dynamic_partial_to_signed_detect() - */ -#ifndef _di_controller_rule_action_read_rerun_number_ - extern f_status_t controller_rule_action_read_rerun_number(controller_global_t * const global, const f_string_t name, controller_cache_t * const cache, f_number_unsigned_t * const index, f_number_unsigned_t * const number); -#endif // _di_controller_rule_action_read_rerun_number_ - #ifdef __cplusplus } // extern "C" diff --git a/sources/c/main/rule/setting.c b/sources/c/main/rule/setting.c index 25394e3..39acd1d 100644 --- a/sources/c/main/rule/setting.c +++ b/sources/c/main/rule/setting.c @@ -234,7 +234,7 @@ extern "C" { status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, cache->content_actions.array[i].array[j], &number); if (F_status_set_fine(status) == F_number_positive) { - status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, controller_range_after_number_sign(cache->buffer_item, cache->content_actions.array[i].array[j]), &number); + status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, controller_main_range_after_number_sign(cache->buffer_item, cache->content_actions.array[i].array[j]), &number); // Restore error on parameter problem. if (F_status_set_fine(status) == F_parameter) { @@ -417,7 +417,7 @@ extern "C" { rule->cgroup.path.used = 0; - status = f_string_dynamic_append(global->setting->path_cgroup, &rule->cgroup.path); + 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); @@ -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_rule_print_rule_message_cache(&global->main->program.error, &cache->action, F_true); controller_unlock_print_flush(global->main->program.error.to, global->thread); } @@ -629,7 +629,7 @@ extern "C" { status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, cache->content_actions.array[i].array[j], &number); if (F_status_set_fine(status) == F_number_positive) { - status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, controller_range_after_number_sign(cache->buffer_item, cache->content_actions.array[i].array[j]), &number); + status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, controller_main_range_after_number_sign(cache->buffer_item, cache->content_actions.array[i].array[j]), &number); // Restore error on parameter problem. if (F_status_set_fine(status) == F_parameter) { @@ -891,7 +891,7 @@ extern "C" { status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, cache->content_actions.array[i].array[1], &number); if (F_status_set_fine(status) == F_number_positive) { - status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, controller_range_after_number_sign(cache->buffer_item, cache->content_actions.array[i].array[1]), &number); + status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, controller_main_range_after_number_sign(cache->buffer_item, cache->content_actions.array[i].array[1]), &number); // Restore error on parameter problem. if (F_status_set_fine(status) == F_parameter) { @@ -1013,7 +1013,7 @@ extern "C" { status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, cache->buffer_item, cache->content_actions.array[i].array[1], &number); if (F_status_set_fine(status) == F_number_positive) { - status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, cache->buffer_item, controller_range_after_number_sign(cache->buffer_item, cache->content_actions.array[i].array[1]), &number); + status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, cache->buffer_item, controller_main_range_after_number_sign(cache->buffer_item, cache->content_actions.array[i].array[1]), &number); // Restore error on parameter problem. if (F_status_set_fine(status) == F_parameter) { @@ -1167,7 +1167,7 @@ extern "C" { status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, cache->content_actions.array[i].array[0], &number); if (F_status_set_fine(status) == F_number_positive) { - status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, controller_range_after_number_sign(cache->buffer_item, cache->content_actions.array[i].array[0]), &number); + status = fl_conversion_dynamic_partial_to_signed_detect(fl_conversion_data_base_10_c, cache->buffer_item, controller_main_range_after_number_sign(cache->buffer_item, cache->content_actions.array[i].array[0]), &number); // Restore error on parameter problem. if (F_status_set_fine(status) == F_parameter) { diff --git a/sources/c/main/rule/validate.c b/sources/c/main/rule/validate.c index fc4e96d..811c3a2 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_rule_print_rule_message_cache(&global->main->program.error, &cache->action, F_true); controller_unlock_print_flush(main->program.error.to, global->thread); } @@ -65,8 +65,8 @@ extern "C" { fl_print_format("%rRule '", main->program.output.to, f_string_eol_s); fl_print_format("%[%Q%]' has no '", main->program.output.to, main->program.context.set.title, rule.name, main->program.context.set.title); fl_print_format("%[%r%]' action to execute and would '", main->program.output.to, main->program.context.set.title, controller_rule_action_type_name(action), main->program.context.set.title); - fl_print_format("%[%r%]' because it is '", main->program.output.to, main->program.context.set.important, options & controller_process_option_require_d ? controller_fail_s : controller_succeed_s, main->program.context.set.important); - fl_print_format("%[%r%]'.%r", main->program.output.to, main->program.context.set.important, options & controller_process_option_require_d ? controller_required_s : controller_optional_s, main->program.context.set.important, f_string_eol_s); + fl_print_format("%[%r%]' because it is '", main->program.output.to, main->program.context.set.important, options & controller_instance_option_require_e ? controller_fail_s : controller_succeed_s, main->program.context.set.important); + fl_print_format("%[%r%]'.%r", main->program.output.to, main->program.context.set.important, options & controller_instance_option_require_e ? controller_required_s : controller_optional_s, main->program.context.set.important, f_string_eol_s); } else { fl_print_format("%rRule '", main->program.output.to, f_string_eol_s); @@ -76,8 +76,8 @@ extern "C" { fl_print_format("'%[%r%]', ", main->program.output.to, main->program.context.set.title, controller_service_s, main->program.context.set.title); fl_print_format("'%[%r%]', or ", main->program.output.to, main->program.context.set.title, controller_script_s, main->program.context.set.title); fl_print_format("'%[%r%]'", main->program.output.to, main->program.context.set.title, controller_utility_s, main->program.context.set.title); - fl_print_format(") and would '%[%r%]' because it is '", main->program.output.to, main->program.context.set.important, options & controller_process_option_require_d ? controller_fail_s : controller_succeed_s, main->program.context.set.important); - fl_print_format("%[%r%]'.%r", main->program.output.to, main->program.context.set.important, options & controller_process_option_require_d ? controller_required_s : controller_optional_s, main->program.context.set.important, f_string_eol_s); + fl_print_format(") and would '%[%r%]' because it is '", main->program.output.to, main->program.context.set.important, options & controller_instance_option_require_e ? controller_fail_s : controller_succeed_s, main->program.context.set.important); + fl_print_format("%[%r%]'.%r", main->program.output.to, main->program.context.set.important, options & controller_instance_option_require_e ? controller_required_s : controller_optional_s, main->program.context.set.important, f_string_eol_s); } controller_unlock_print_flush(main->program.output.to, global->thread); @@ -126,7 +126,7 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, main->program.output.to); // How. - fl_print_format(" %[%r%] %r%r", main->program.output.to, main->program.context.set.important, controller_how_s, main->program.context.set.important, options & controller_process_option_asynchronous_d ? controller_asynchronous_s : controller_synchronous_s, f_string_eol_s); + fl_print_format(" %[%r%] %r%r", main->program.output.to, main->program.context.set.important, controller_how_s, main->program.context.set.important, options & controller_instance_option_asynchronous_e ? controller_asynchronous_s : controller_synchronous_s, f_string_eol_s); // Nice. fl_print_format(" %[%r%]", main->program.output.to, main->program.context.set.important, controller_nice_s, main->program.context.set.important); @@ -194,7 +194,7 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, main->program.output.to); // Wait. - fl_print_format(" %[%r%] %r%r", main->program.output.to, main->program.context.set.important, controller_wait_s, main->program.context.set.important, options & controller_process_option_wait_d ? controller_yes_s : controller_no_s, f_string_eol_s); + fl_print_format(" %[%r%] %r%r", main->program.output.to, main->program.context.set.important, controller_wait_s, main->program.context.set.important, options & controller_instance_option_wait_e ? controller_yes_s : controller_no_s, f_string_eol_s); // Affinity. fl_print_format(" %[%r%] {%r", main->program.output.to, main->program.context.set.important, controller_affinity_s, main->program.context.set.important, f_string_eol_s); diff --git a/sources/c/main/rule/validate.h b/sources/c/main/rule/validate.h index e8934ee..4479a9e 100644 --- a/sources/c/main/rule/validate.h +++ b/sources/c/main/rule/validate.h @@ -35,8 +35,8 @@ extern "C" { * @param options * A number using bits to represent specific boolean options. * If no bits set, then operate normally in a synchronous manner. - * If bit controller_process_option_simulate_d, then the rule execution is in simulation mode (printing a message that the rule would be executed but does not execute the rule). - * If bit controller_process_option_asynchronous_d, then run asynchronously. + * If bit controller_instance_option_simulate_e, then the rule execution is in simulation mode (printing a message that the rule would be executed but does not execute the rule). + * If bit controller_instance_option_asynchronous_e, then run asynchronously. * @param cache * A structure for containing and caching relevant data. */ diff --git a/sources/c/main/rule/wait.c b/sources/c/main/rule/wait.c index 36863a6..f625427 100644 --- a/sources/c/main/rule/wait.c +++ b/sources/c/main/rule/wait.c @@ -75,7 +75,7 @@ extern "C" { } if (required) { - if (!(instance_list[i]->options & controller_instance_option_require_d)) { + if (!(instance_list[i]->options & controller_instance_option_require_e)) { f_thread_unlock(&instance_list[i]->lock); f_thread_unlock(&instance_list[i]->active); @@ -128,7 +128,7 @@ extern "C" { if (F_status_is_error(status_lock)) break; } - if (instance_list[i]->options & controller_instance_option_require_d) { + if (instance_list[i]->options & controller_instance_option_require_e) { if (controller_rule_status_is_error(instance_list[i]->action, instance_list[i]->rule)) { status = F_status_set_error(F_require); @@ -169,7 +169,7 @@ extern "C" { break; } - if ((instance_list[i]->options & controller_instance_option_require_d)) { + if ((instance_list[i]->options & controller_instance_option_require_e)) { f_thread_unlock(&instance_list[i]->lock); if (controller_rule_status_is_error(instance_list[i]->action, instance_list[i]->rule)) { @@ -212,7 +212,7 @@ extern "C" { if (!global) return F_status_set_error(F_parameter); - return controller_rule_wait_all(global, type != controller_data_type_exit_e, required); + return controller_rule_wait_all(global, type != controller_instance_type_exit_e, required); } #endif // _di_controller_rule_wait_all_instance_type_ diff --git a/sources/c/main/thread/instance.c b/sources/c/main/thread/instance.c index 54370a6..fa747b4 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_process_option_asynchronous_d, instance); + const f_status_t status = controller_rule_process_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. @@ -39,7 +39,7 @@ extern "C" { return; } - controller_entry_t * const entry = is_normal ? &global->setting->entry : &global->setting->exit; + controller_entry_t * const entry = is_normal ? &global->program->entry : &global->program->exit; controller_instance_t *instance = 0; f_time_spec_t time = f_time_spec_t_initialize; @@ -55,7 +55,7 @@ extern "C" { time.tv_sec = 0; time.tv_nsec = interval_nanoseconds; - if (global->setting->mode == controller_setting_mode_helper_e && global->main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e) { + if (global->program->mode == controller_setting_mode_helper_e && global->main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e) { int value = 0; f_number_unsigned_t lapsed = 0; @@ -118,7 +118,7 @@ extern "C" { global->thread->id_signal = 0; } - if (global->setting->mode == controller_setting_mode_helper_e && global->main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e) { + if (global->program->mode == controller_setting_mode_helper_e && global->main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e) { f_thread_mutex_unlock(&global->thread->lock.cancel); return; @@ -131,7 +131,7 @@ extern "C" { instance = global->thread->instances.array[i]; // Do not cancel exit instances, when not performing "execute" during exit. - if (instance->type == controller_data_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) { + if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) { continue; } @@ -164,7 +164,7 @@ extern "C" { instance = global->thread->instances.array[i]; // Do not wait for instances, when not performing "execute" during exit. - if (instance->type == controller_data_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) { + if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) { continue; } @@ -225,7 +225,7 @@ extern "C" { instance = global->thread->instances.array[i]; // Do not kill exit instances, when not performing "execute" during exit. - if (instance->type == controller_data_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) continue; + if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) continue; if (instance->id_thread) { if (instance->childs.used) { @@ -253,7 +253,7 @@ extern "C" { for (j = 0; j < instance->childs.size; ++j) { // Do not kill exit processes, when not performing "execute" during exit. - if (instance->type == controller_data_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) continue; + if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) continue; if (instance->childs.array[j]) { @@ -271,7 +271,7 @@ extern "C" { for (j = 0; j < instance->path_pids.used; ++j) { // Do not kill exit processes, when not performing "execute" during exit. - if (instance->type == controller_data_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) continue; + if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) continue; if (f_file_exists(instance->path_pids.array[j], F_true) == F_true) { status = controller_file_pid_read(instance->path_pids.array[j], &pid); @@ -290,7 +290,7 @@ extern "C" { while (instance->childs.used) { // Do not shrink below an exit instances, when not performing "execute" during exit. - if (instance->type == controller_data_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) break; + if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) break; if (instance->childs.array[j] > 0) break; --instance->childs.used; @@ -300,7 +300,7 @@ extern "C" { while (instance->path_pids.used) { // Do not shrink below an exit instances, when not performing "execute" during exit. - if (instance->type == controller_data_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) break; + if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) break; if (instance->path_pids.array[j].used) break; --instance->path_pids.used; @@ -318,7 +318,7 @@ extern "C" { if (global->thread->enabled != controller_thread_enabled_exit_e) return; - if (global->setting->ready == controller_setting_ready_done_e) { + if (global->program->ready == controller_setting_ready_done_e) { // The exit processing runs using the entry thread. if (global->thread->id_entry) { diff --git a/sources/c/main/thread/is.c b/sources/c/main/thread/is.c index 02a594f..6132976 100644 --- a/sources/c/main/thread/is.c +++ b/sources/c/main/thread/is.c @@ -25,7 +25,7 @@ extern "C" { #ifndef _di_controller_main_thread_is_enabled_instance_type_ f_status_t controller_main_thread_is_enabled_instance_type(const uint8_t type, controller_thread_t * const thread) { - return controller_main_thread_is_enabled(type != controller_data_type_exit_e, thread); + return controller_main_thread_is_enabled(type != controller_instance_type_exit_e, thread); } #endif // _di_controller_main_thread_is_enabled_instance_type_