build_sources_library main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/string.c main/common/type.c
build_sources_library main/common/type/cache.c main/common/type/control.c main/common/type/entry.c main/common/type/execute.c main/common/type/global.c main/common/type/lock.c main/common/type/instance.c main/common/type/program.c main/common/type/rule.c main/common/type/thread.c
build_sources_library main/common/string/general.c main/common/string/rule.c
-build_sources_library main/instance.c main/lock.c main/path.c main/process.c
+build_sources_library main/convert.c main/instance.c main/instance/prepare.c main/instance/wait.c
+build_sources_library main/file.c main/lock.c main/path.c main/process.c
build_sources_library main/rule.c main/rule/action.c main/rule/execute.c main/rule/expand.c main/rule/instance.c main/rule/is.c main/rule/item.c main/rule/parameter.c main/rule/read.c main/rule/setting.c main/rule/validate.c main/rule/wait.c
build_sources_library main/print/action.c main/print/data.c main/print/debug.c main/print/error.c main/print/lock.c main/print/message.c main/print/rule.c main/print/verbose.c main/print/warning.c
build_sources_library main/print/rule/action.c main/print/rule/item.c main/print/rule/setting.c
build_sources_headers main/common/enumeration/control.h main/common/enumeration/entry.h main/common/enumeration/instance.h main/common/enumeration/program.h main/common/enumeration/rule.h main/common/enumeration/thread.h
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/defs.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/lock.h main/path.h main/process.h
+build_sources_headers main/convert.h main/instance.h main/instance/prepare.h main/instance/wait.h
+build_sources_headers main/file.h main/lock.h main/path.h main/process.h
build_sources_headers main/rule.h main/rule/action.h main/rule/execute.h main/rule/expand.h main/rule/instance.h main/rule/is.h main/rule/item.h main/rule/parameter.h main/rule/read.h main/rule/setting.h main/rule/validate.h main/rule/wait.h
build_sources_headers main/print/action.h main/print/data.h main/print/debug.h main/print/error.h main/print/lock.h main/print/message.h main/print/rule.h main/print/verbose.h main/print/warning.h
build_sources_headers main/print/rule/action.h main/print/rule/item.h main/print/rule/setting.h
int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
- controller_main_t data = controller_main_t_initialize;
+ controller_t data = controller_t_initialize;
controller_program_t program = controller_program_t_initialize;
data.program.debug.flag |= controller_print_flag_debug_e | controller_print_flag_out_e;
{
const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp);
- controller_main_setting_load(arguments, &data, &program);
+ controller_setting_load(arguments, &data, &program);
}
- controller_main_process(&data, &program);
+ controller_process(&data, &program);
- controller_main_delete(&data);
+ controller_delete(&data);
fll_program_standard_set_down(&data.program);
* This file is only ever included by main/main.c and should not normally be included anywhere else.
* Anything that wants to include this should be providing the "controller" program functionality in some manner.
*/
-#ifndef _controller_controller_main_h
-#define _controller_controller_main_h
+#ifndef _controller_controller_h
+#define _controller_controller_h
#ifdef __cplusplus
extern "C" {
} // extern "C"
#endif
-#endif // _controller_controller_main_h
+#endif // _controller_controller_h
int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
- controller_main_t data = controller_main_t_initialize;
+ controller_t data = controller_t_initialize;
controller_program_t program = controller_program_t_initialize;
data.program.debug.flag |= controller_print_flag_debug_e | controller_print_flag_out_e;
{
const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp);
- controller_main_setting_load(arguments, &data, &program);
+ controller_setting_load(arguments, &data, &program);
}
- controller_main_process(&data, &program);
+ controller_process(&data, &program);
fll_program_standard_set_down(&data.program);
extern "C" {
#endif
-#ifndef _di_controller_main_error_simplify_
- f_status_t controller_main_error_simplify(const f_status_t status) {
+#ifndef _di_controller_error_simplify_
+ f_status_t controller_error_simplify(const f_status_t status) {
if (status == F_memory_not) {
return F_status_set_error(F_memory);
return F_status_set_error(F_failure);
}
-#endif // _di_controller_main_error_simplify_
+#endif // _di_controller_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) {
+#ifndef _di_controller_range_after_number_sign_
+ f_range_t controller_range_after_number_sign(const f_string_static_t buffer, const f_range_t range) {
f_range_t result = range;
return result;
}
-#endif // _di_controller_main_range_after_number_sign_
+#endif // _di_controller_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) {
+#ifndef _di_controller_setting_load_
+ void controller_setting_load(const f_console_arguments_t arguments, controller_t * const main, controller_program_t * const program) {
if (!main || !program) return;
main->setting.state.step_small = controller_allocation_small_d;
if (F_status_is_error(main->setting.state.status)) {
- controller_main_print_error(&main->program.error, macro_controller_f(f_console_parameter_process));
+ controller_print_error(&main->program.error, macro_controller_f(f_console_parameter_process));
return;
}
main->setting.state.status = fll_program_parameter_process_context_standard(F_true, &main->program);
if (F_status_is_error(main->setting.state.status)) {
- controller_main_print_error(&main->program.error, macro_controller_f(fll_program_parameter_process_context_standard));
+ controller_print_error(&main->program.error, macro_controller_f(fll_program_parameter_process_context_standard));
return;
}
main->setting.state.status = fll_program_parameter_process_verbosity_standard(F_true, &main->program);
if (F_status_is_error(main->setting.state.status)) {
- controller_main_print_error(&main->program.error, macro_controller_f(fll_program_parameter_process_verbosity_standard));
+ controller_print_error(&main->program.error, macro_controller_f(fll_program_parameter_process_verbosity_standard));
return;
}
main->setting.state.status = f_string_dynamic_append(main->program.parameters.remaining.used ? args[main->program.parameters.remaining.array[0]] : controller_default_s, &program->name_entry);
if (F_status_is_error(main->setting.state.status)) {
- controller_main_print_error(&main->program.error, macro_controller_f(fll_program_parameter_process_verbosity_standard));
+ controller_print_error(&main->program.error, macro_controller_f(fll_program_parameter_process_verbosity_standard));
return;
}
main->setting.state.status = f_path_current(F_false, &program->path_current);
if (F_status_is_error(main->setting.state.status)) {
- controller_main_print_error(&main->program.error, macro_controller_f(f_path_current));
+ controller_print_error(&main->program.error, macro_controller_f(f_path_current));
return;
}
controller_path_canonical_relative(main, program->path_current, args[index], &program->path_setting);
if (F_status_is_error(main->setting.state.status)) {
- controller_main_print_error_file(&main->program.error, macro_controller_f(controller_path_canonical_relative), args[index], f_file_operation_verify_s, fll_error_file_type_path_e);
+ controller_print_error_file(&main->program.error, macro_controller_f(controller_path_canonical_relative), args[index], f_file_operation_verify_s, fll_error_file_type_path_e);
return;
}
main->setting.state.status = f_string_dynamic_append(controller_default_path_settings_s, &program->path_setting);
if (F_status_is_error(main->setting.state.status)) {
- controller_main_print_error(&main->program.error, macro_controller_f(f_string_dynamic_append));
+ controller_print_error(&main->program.error, macro_controller_f(f_string_dynamic_append));
return;
}
}
if (F_status_is_error(main->setting.state.status)) {
- controller_main_print_error(&main->program.error, macro_controller_f(f_string_dynamic_append));
+ controller_print_error(&main->program.error, macro_controller_f(f_string_dynamic_append));
return;
}
controller_path_canonical_relative(main, program->path_current, args[index], &program->path_cgroup);
if (F_status_is_error(main->setting.state.status)) {
- controller_main_print_error_file(&main->program.error, macro_controller_f(controller_path_canonical_relative), args[index], f_file_operation_verify_s, fll_error_file_type_path_e);
+ controller_print_error_file(&main->program.error, macro_controller_f(controller_path_canonical_relative), args[index], f_file_operation_verify_s, fll_error_file_type_path_e);
return;
}
main->setting.state.status = f_string_append_assure(F_path_separator_s, 1, &program->path_cgroup);
if (F_status_is_error(main->setting.state.status)) {
- controller_main_print_error(&main->program.error, macro_controller_f(f_string_append_assure));
+ controller_print_error(&main->program.error, macro_controller_f(f_string_append_assure));
return;
}
}
else {
- controller_main_print_debug_directory_path_empty(&main->program.warning, f_console_symbol_long_normal_s, controller_long_cgroup_s);
+ controller_print_debug_directory_path_empty(&main->program.warning, f_console_symbol_long_normal_s, controller_long_cgroup_s);
}
}
else {
}
if (F_status_is_error(main->setting.state.status)) {
- controller_main_print_error(&main->program.error, macro_controller_f(f_string_dynamic_append_nulless));
+ controller_print_error(&main->program.error, macro_controller_f(f_string_dynamic_append_nulless));
return;
}
main->setting.state.status = f_string_dynamic_append_assure(f_path_separator_s, &program->path_cgroup);
if (F_status_is_error(main->setting.state.status)) {
- controller_main_print_error(&main->program.error, macro_controller_f(f_string_dynamic_append_assure));
+ controller_print_error(&main->program.error, macro_controller_f(f_string_dynamic_append_assure));
return;
}
main->setting.flag |= controller_main_flag_validate_e;
}
}
-#endif // _di_controller_main_setting_load_
+#endif // _di_controller_setting_load_
#ifdef __cplusplus
} // extern "C"
* @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);
-#endif // _di_controller_main_error_simplify_
+#ifndef _di_controller_error_simplify_
+ extern f_status_t controller_error_simplify(const f_status_t status);
+#endif // _di_controller_error_simplify_
/**
* Given a string whose range represents a number, seek past the first positive or negative sign.
* 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);
-#endif // _di_controller_main_range_after_number_sign_
+#ifndef _di_controller_range_after_number_sign_
+ extern f_range_t controller_range_after_number_sign(const f_string_static_t buffer, const f_range_t range);
+#endif // _di_controller_range_after_number_sign_
/**
* Perform the standard program setting load settings.
* @see f_console_parameter_process()
* @see fll_program_parameter_process_context()
*/
-#ifndef _di_controller_main_setting_load_
- extern void controller_main_setting_load(const f_console_arguments_t arguments, controller_main_t * const main, controller_program_t * const program);
-#endif // _di_controller_main_setting_load_
+#ifndef _di_controller_setting_load_
+ extern void controller_setting_load(const f_console_arguments_t arguments, controller_t * const main, controller_program_t * const program);
+#endif // _di_controller_setting_load_
#ifdef __cplusplus
} // extern "C"
* Thread related defines.
*/
#ifndef _di_controller_thread_d_
- #define controller_main_thread_cleanup_interval_long_d 3600 // 1 hour in seconds.
- #define controller_main_thread_cleanup_interval_short_d 180 // 3 minutes in seconds.
- #define controller_main_thread_exit_timeout_d 500 // 0.5 seconds in milliseconds.
- #define controller_main_thread_exit_process_cancel_wait_d 600000000 // 0.6 seconds in nanoseconds.
- #define controller_main_thread_exit_process_cancel_total_d 150 // 90 seconds in multiples of wait.
+ #define controller_thread_cleanup_interval_long_d 3600 // 1 hour in seconds.
+ #define controller_thread_cleanup_interval_short_d 180 // 3 minutes in seconds.
+ #define controller_thread_exit_timeout_d 500 // 0.5 seconds in milliseconds.
+ #define controller_thread_exit_process_cancel_wait_d 600000000 // 0.6 seconds in nanoseconds.
+ #define controller_thread_exit_process_cancel_total_d 150 // 90 seconds in multiples of wait.
#define controller_thread_simulation_timeout_d 200 // 0.2 seconds in milliseconds.
- #define controller_main_thread_signal_wait_timeout_seconds_d 70
- #define controller_main_thread_signal_wait_timeout_nanoseconds_d 0
+ #define controller_thread_signal_wait_timeout_seconds_d 70
+ #define controller_thread_signal_wait_timeout_nanoseconds_d 0
#define controller_thread_lock_read_timeout_seconds_d 3
#define controller_thread_lock_read_timeout_nanoseconds_d 0
#define controller_thread_wait_timeout_4_seconds_d 20
#define controller_thread_wait_timeout_4_nanoseconds_d 0
- #define controller_main_thread_exit_helper_timeout_seconds_d 0
- #define controller_main_thread_exit_helper_timeout_nanoseconds_d 100000000 // 0.1 seconds in nanoseconds.
+ #define controller_thread_exit_helper_timeout_seconds_d 0
+ #define controller_thread_exit_helper_timeout_nanoseconds_d 100000000 // 0.1 seconds in nanoseconds.
- #define controller_main_thread_exit_ready_timeout_seconds_d 0
- #define controller_main_thread_exit_ready_timeout_nanoseconds_d 500000000 // 0.5 seconds in nanoseconds.
+ #define controller_thread_exit_ready_timeout_seconds_d 0
+ #define controller_thread_exit_ready_timeout_nanoseconds_d 500000000 // 0.5 seconds in nanoseconds.
#endif // _di_controller_thread_d_
#ifdef __cplusplus
*
* Execute type starts at 0 because it is intended to be used as an index within a static array.
*
- * controller_main_rule_action_execute_type_*_e:
+ * controller_rule_action_execute_type_*_e:
* - freeze: The Freeze execution instructions.
* - kill: The Kill execution instructions.
* - pause: The Pause execution instructions.
* - stop: The Stop execution instructions.
* - thaw: The Thaw execution instructions.
*/
-#ifndef _di_controller_main_rule_action_execute_type_e_
+#ifndef _di_controller_rule_action_execute_type_e_
enum {
- controller_main_rule_action_execute_type_freeze_e = 0,
- controller_main_rule_action_execute_type_kill_e,
- controller_main_rule_action_execute_type_pause_e,
- controller_main_rule_action_execute_type_reload_e,
- controller_main_rule_action_execute_type_restart_e,
- controller_main_rule_action_execute_type_resume_e,
- controller_main_rule_action_execute_type_start_e,
- controller_main_rule_action_execute_type_stop_e,
- controller_main_rule_action_execute_type_thaw_e,
+ controller_rule_action_execute_type_freeze_e = 0,
+ controller_rule_action_execute_type_kill_e,
+ controller_rule_action_execute_type_pause_e,
+ controller_rule_action_execute_type_reload_e,
+ controller_rule_action_execute_type_restart_e,
+ controller_rule_action_execute_type_resume_e,
+ controller_rule_action_execute_type_start_e,
+ controller_rule_action_execute_type_stop_e,
+ controller_rule_action_execute_type_thaw_e,
// Designate the largest value in the enum, the '__' is intentional.
- controller_main_rule_action_execute_type__enum_size_e,
+ controller_rule_action_execute_type__enum_size_e,
}; // enum
-#endif // _di_controller_main_rule_action_execute_type_e_
+#endif // _di_controller_rule_action_execute_type_e_
/**
* Controller Rule Action method enumeration.
*
- * controller_main_rule_action_method_*_e:
+ * controller_rule_action_method_*_e:
* - none: Nothing set.
* - extended: Designate that this Action is represented using FSS Extended.
* - extended_list: Designate that this Action is represented using FSS Extended List.
*/
-#ifndef _di_controller_main_rule_action_method_e_
+#ifndef _di_controller_rule_action_method_e_
enum {
- controller_main_rule_action_method_none_e = 0,
- controller_main_rule_action_method_extended_e,
- controller_main_rule_action_method_extended_list_e,
+ controller_rule_action_method_none_e = 0,
+ controller_rule_action_method_extended_e,
+ controller_rule_action_method_extended_list_e,
}; // enum
-#endif // _di_controller_main_rule_action_method_e_
+#endif // _di_controller_rule_action_method_e_
/**
* Controller Rule Action type enumeration.
*
- * controller_main_rule_action_type_*_e:
+ * controller_rule_action_type_*_e:
* - none: Nothing set.
* - freeze: The Freeze execution instructions.
* - group: The Group setting.
* - user: The User setting.
* - with: The With flags.
*/
-#ifndef _di_controller_main_rule_action_type_e_
+#ifndef _di_controller_rule_action_type_e_
enum {
- controller_main_rule_action_type_none_e = 0,
- controller_main_rule_action_type_freeze_e,
- controller_main_rule_action_type_group_e,
- controller_main_rule_action_type_kill_e,
- controller_main_rule_action_type_pause_e,
- controller_main_rule_action_type_pid_file_e,
- controller_main_rule_action_type_reload_e,
- controller_main_rule_action_type_rerun_e,
- controller_main_rule_action_type_restart_e,
- controller_main_rule_action_type_resume_e,
- controller_main_rule_action_type_start_e,
- controller_main_rule_action_type_stop_e,
- controller_main_rule_action_type_thaw_e,
- controller_main_rule_action_type_user_e,
- controller_main_rule_action_type_with_e,
+ controller_rule_action_type_none_e = 0,
+ controller_rule_action_type_freeze_e,
+ controller_rule_action_type_group_e,
+ controller_rule_action_type_kill_e,
+ controller_rule_action_type_pause_e,
+ controller_rule_action_type_pid_file_e,
+ controller_rule_action_type_reload_e,
+ controller_rule_action_type_rerun_e,
+ controller_rule_action_type_restart_e,
+ controller_rule_action_type_resume_e,
+ controller_rule_action_type_start_e,
+ controller_rule_action_type_stop_e,
+ controller_rule_action_type_thaw_e,
+ controller_rule_action_type_user_e,
+ controller_rule_action_type_with_e,
// Designate the largest value in the enum, the '__' is intentional.
- controller_main_rule_action_type__enum_size_e,
+ controller_rule_action_type__enum_size_e,
}; // enum
-#endif // _di_controller_main_rule_action_type_e_
+#endif // _di_controller_rule_action_type_e_
/**
* Controller Rule Item type enumeration.
#ifndef _di_controller_f_a_
const f_string_t controller_f_a[] = {
- "controller_main_lock_create",
+ "controller_lock_create",
"controller_rule_copy",
- "controller_rule_items_increase_by",
"controller_path_canonical_relative",
- "controller_pids_increase",
"f_console_parameter_process",
"f_environment_get_all",
+ "f_file_exists",
+ "f_file_stream_open",
+ "f_file_stream_read",
"f_fss_apply_delimit",
"f_fss_count_lines",
"f_memory_array_increase",
"f_memory_array_increase_by",
+ "f_memory_array_resize",
"f_path_current",
"f_rip_dynamic_partial",
"f_rip_dynamic_partial_nulless",
"f_string_dynamic_partial_mash_nulless",
"f_string_maps_append",
"f_thread_create",
+ "f_time_spec_millisecond",
"fl_conversion_dynamic_partial_to_signed_detect",
"fl_environment_load_names",
"fl_fss_extended_list_content_read",
"fl_fss_extended_list_object_read",
+ "fl_fss_extended_object_read",
"fl_iki_read",
"fll_control_group_prepare",
"fll_execute_program",
*/
#ifndef _di_controller_f_e_
enum {
- controller_f_controller_main_lock_create_e,
+ controller_f_controller_lock_create_e,
controller_f_controller_rule_copy_e,
- controller_f_controller_rule_items_increase_by_e,
controller_f_controller_path_canonical_relative_e,
- controller_f_controller_pids_increase_e,
controller_f_f_console_parameter_process_e,
controller_f_f_environment_get_all_e,
+ controller_f_f_file_exists_e,
+ controller_f_f_file_stream_open_e,
+ controller_f_f_file_stream_read_e,
controller_f_f_fss_apply_delimit_e,
controller_f_f_fss_count_lines_e,
controller_f_f_memory_array_increase_e,
controller_f_f_memory_array_increase_by_e,
+ controller_f_f_memory_array_resize_e,
controller_f_f_path_current_e,
controller_f_f_rip_dynamic_partial_e,
controller_f_f_rip_dynamic_partial_nulless_e,
controller_f_f_string_dynamic_partial_mash_nulless_e,
controller_f_f_string_maps_append_e,
controller_f_f_thread_create_e,
+ controller_f_f_time_spec_millisecond_e,
controller_f_fl_conversion_dynamic_partial_to_signed_detect_e,
controller_f_fl_environment_load_names_e,
controller_f_fl_fss_extended_list_content_read_e,
controller_f_fl_fss_extended_list_object_read_e,
+ controller_f_fl_fss_extended_object_read_e,
controller_f_fl_iki_read_e,
controller_f_fll_control_group_prepare_e,
controller_f_fll_execute_program_e,
const f_string_static_t controller_length_s = macro_f_string_static_t_initialize_1(CONTROLLER_length_s, 0, CONTROLLER_length_s_length);
const f_string_static_t controller_limit_s = macro_f_string_static_t_initialize_1(CONTROLLER_limit_s, 0, CONTROLLER_limit_s_length);
const f_string_static_t controller_locks_s = macro_f_string_static_t_initialize_1(CONTROLLER_locks_s, 0, CONTROLLER_locks_s_length);
- const f_string_static_t controller_main_s = macro_f_string_static_t_initialize_1(CONTROLLER_main_s, 0, CONTROLLER_main_s_length);
+ const f_string_static_t controller_s = macro_f_string_static_t_initialize_1(CONTROLLER_main_s, 0, CONTROLLER_main_s_length);
const f_string_static_t controller_max_s = macro_f_string_static_t_initialize_1(CONTROLLER_max_s, 0, CONTROLLER_max_s_length);
const f_string_static_t controller_memlock_s = macro_f_string_static_t_initialize_1(CONTROLLER_memlock_s, 0, CONTROLLER_memlock_s_length);
const f_string_static_t controller_method_s = macro_f_string_static_t_initialize_1(CONTROLLER_method_s, 0, CONTROLLER_method_s_length);
extern const f_string_static_t controller_length_s;
extern const f_string_static_t controller_limit_s;
extern const f_string_static_t controller_locks_s;
- extern const f_string_static_t controller_main_s;
+ extern const f_string_static_t controller_s;
extern const f_string_static_t controller_max_s;
extern const f_string_static_t controller_memlock_s;
extern const f_string_static_t controller_method_s;
extern "C" {
#endif
-#ifndef _di_controller_main_rule_action_method_s_
- const f_string_static_t controller_main_rule_action_method_extended_s = macro_f_string_static_t_initialize_1(CONTROLLER_rule_action_method_extended_s, 0, CONTROLLER_rule_action_method_extended_s_length);
- const f_string_static_t controller_main_rule_action_method_extended_list_s = macro_f_string_static_t_initialize_1(CONTROLLER_rule_action_method_extended_list_s, 0, CONTROLLER_rule_action_method_extended_list_s_length);
-#endif // _di_controller_main_rule_action_method_s_
+#ifndef _di_controller_rule_action_method_s_
+ const f_string_static_t controller_rule_action_method_extended_s = macro_f_string_static_t_initialize_1(CONTROLLER_rule_action_method_extended_s, 0, CONTROLLER_rule_action_method_extended_s_length);
+ const f_string_static_t controller_rule_action_method_extended_list_s = macro_f_string_static_t_initialize_1(CONTROLLER_rule_action_method_extended_list_s, 0, CONTROLLER_rule_action_method_extended_list_s_length);
+#endif // _di_controller_rule_action_method_s_
#ifdef __cplusplus
} // extern "C"
/**
* Controller Rule Action strings.
*
- * controller_main_rule_action_method_*_s:
+ * controller_rule_action_method_*_s:
* - extended: Designate that this Action is represented using FSS Extended.
* - extended_list: Designate that this Action is represented using FSS Extended List.
*/
-#ifndef _di_controller_main_rule_action_method_s_
+#ifndef _di_controller_rule_action_method_s_
#define CONTROLLER_rule_action_method_extended_s "FSS-0001 (Extended)"
#define CONTROLLER_rule_action_method_extended_list_s "FSS-0003 (Extended List)"
#define CONTROLLER_rule_action_method_extended_s_length 19
#define CONTROLLER_rule_action_method_extended_list_s_length 24
- extern const f_string_static_t controller_main_rule_action_method_extended_s;
- extern const f_string_static_t controller_main_rule_action_method_extended_list_s;
-#endif // _di_controller_main_rule_action_method_s_
+ extern const f_string_static_t controller_rule_action_method_extended_s;
+ extern const f_string_static_t controller_rule_action_method_extended_list_s;
+#endif // _di_controller_rule_action_method_s_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_delete_
- void controller_main_delete(controller_main_t * const main) {
+#ifndef _di_controller_delete_
+ void controller_delete(controller_t * const main) {
if (!main) return;
fll_program_data_delete(&main->program);
controller_setting_delete(&main->setting);
}
-#endif // _di_controller_main_delete_
+#endif // _di_controller_delete_
#ifndef _di_controller_setting_delete_
void controller_setting_delete(controller_setting_t * const setting) {
* - program: The main program data.
* - setting: The settings data.
*/
-#ifndef _di_controller_main_t_
- struct controller_main_t_ {
+#ifndef _di_controller_t_
+ struct controller_t_ {
fll_program_data_t program;
controller_setting_t setting;
controller_cache_t cache;
};
- #define controller_main_t_initialize \
+ #define controller_t_initialize \
{ \
fll_program_data_t_initialize, \
controller_setting_t_initialize, \
controller_cache_t_initialize, \
}
-#endif // _di_controller_main_t_
+#endif // _di_controller_t_
/**
* De-allocate main program data.
* @see controller_setting_delete()
* @see fll_program_data_delete()
*/
-#ifndef _di_controller_main_delete_
- extern void controller_main_delete(controller_main_t * const main);
-#endif // _di_controller_main_delete_
+#ifndef _di_controller_delete_
+ extern void controller_delete(controller_t * const main);
+#endif // _di_controller_delete_
/**
* Delete the program main setting data.
/**
* The controller main typedef.
*/
-#ifndef _di_controller_main_t_
- typedef struct controller_main_t_ controller_main_t;
-#endif // _di_controller_main_t_
+#ifndef _di_controller_t_
+ typedef struct controller_t_ controller_t;
+#endif // _di_controller_t_
/**
* The controller program typedef.
0, \
0, \
0, \
- controller_main_thread_exit_timeout_d, \
+ controller_thread_exit_timeout_d, \
0, \
0, \
0, \
*/
#ifndef _di_controller_global_t_
struct controller_global_t_ {
- controller_main_t *main;
+ controller_t *main;
controller_program_t *program;
controller_thread_t *thread;
*
* Properties:
* - is_normal: Boolean designating if this is operating in a normal state.
- * - thread: The thread data.
+ * - global: The global data.
*/
#ifndef _di_controller_interrupt_t_
typedef struct {
bool is_normal;
- controller_thread_t *thread;
+ controller_global_t *global;
} controller_interrupt_t;
#define controller_interrupt_t_initialize { \
0, \
}
- #define macro_controller_interrupt_t_initialize_1(is_normal, thread) { \
+ #define macro_controller_interrupt_t_initialize_1(is_normal, global) { \
is_normal, \
- thread, \
+ global, \
}
#endif // _di_controller_interrupt_t_
controller_rule_t rule;
controller_cache_t cache;
- controller_global_t global;
+ controller_global_t *global;
};
#define controller_instance_t_initialize { \
f_number_unsigneds_t_initialize, \
controller_rule_t_initialize, \
controller_cache_t_initialize, \
- controller_global_t_initialize, \
+ 0, \
}
#endif // _di_controller_instance_t_
}
#endif // _di_controller_rule_delete_
-#ifndef _di_controller_main_rule_action_delete_
- void controller_main_rule_action_delete(controller_main_rule_action_t * const action) {
+#ifndef _di_controller_rule_action_delete_
+ void controller_rule_action_delete(controller_rule_action_t * const action) {
if (!action) return;
f_memory_array_resize(0, sizeof(f_iki_data_t), (void **) &action->ikis.array, &action->ikis.used, &action->ikis.size);
}
-#endif // _di_controller_main_rule_action_delete_
+#endif // _di_controller_rule_action_delete_
-#ifndef _di_controller_main_rule_actions_delete_callback_
- f_status_t controller_main_rule_actions_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) {
+#ifndef _di_controller_rule_actions_delete_callback_
+ f_status_t controller_rule_actions_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) {
{
- controller_main_rule_action_t * const controller_main_rule_actions = (controller_main_rule_action_t *) void_array;
+ controller_rule_action_t * const controller_rule_actions = (controller_rule_action_t *) void_array;
for (f_number_unsigned_t i = start; i < stop; ++i) {
- controller_main_rule_action_delete(&controller_main_rule_actions[i]);
+ controller_rule_action_delete(&controller_rule_actions[i]);
} // for
}
return F_okay;
}
-#endif // _di_controller_main_rule_actions_delete_callback_
+#endif // _di_controller_rule_actions_delete_callback_
#ifndef _di_controller_rule_item_delete_
void controller_rule_item_delete(controller_rule_item_t * const item) {
if (!item) return;
f_memory_array_resize(0, sizeof(f_char_t), (void **) &item->pid_file.string, &item->pid_file.used, &item->pid_file.size);
- f_memory_arrays_resize(0, sizeof(controller_main_rule_action_t), (void **) &item->actions.array, &item->actions.used, &item->actions.size, &controller_main_rule_actions_delete_callback);
+ f_memory_arrays_resize(0, sizeof(controller_rule_action_t), (void **) &item->actions.array, &item->actions.used, &item->actions.size, &controller_rule_actions_delete_callback);
}
#endif // _di_controller_rule_item_delete_
* - status: The last execution status of the Rule Action.
* - parameters: All parameters associated with the Rule Action.
*/
-#ifndef _di_controller_main_rule_action_t_
+#ifndef _di_controller_rule_action_t_
typedef struct {
uint8_t type;
f_number_unsigned_t line;
f_string_dynamics_t parameters;
f_iki_datas_t ikis;
- } controller_main_rule_action_t;
+ } controller_rule_action_t;
- #define controller_main_rule_action_t_initialize { \
+ #define controller_rule_action_t_initialize { \
0, \
0, \
F_known_not, \
f_string_dynamics_t_initialize, \
f_iki_datas_t_initialize, \
}
-#endif // _di_controller_main_rule_action_t_
+#endif // _di_controller_rule_action_t_
/**
* Controller Rule Actions.
* - size: Total amount of allocated space.
* - used: Total number of allocated spaces used.
*/
-#ifndef _di_controller_main_rule_actions_t_
+#ifndef _di_controller_rule_actions_t_
typedef struct {
- controller_main_rule_action_t *array;
+ controller_rule_action_t *array;
f_number_unsigned_t size;
f_number_unsigned_t used;
- } controller_main_rule_actions_t;
+ } controller_rule_actions_t;
- #define controller_main_rule_actions_t_initialize { \
+ #define controller_rule_actions_t_initialize { \
0, \
0, \
0, \
}
-#endif // _di_controller_main_rule_actions_t_
+#endif // _di_controller_rule_actions_t_
/**
* Controller Rule Item.
f_number_unsigned_t line;
f_string_dynamic_t pid_file;
- controller_rule_rerun_t reruns[controller_main_rule_action_execute_type__enum_size_e];
- controller_main_rule_actions_t actions;
+ controller_rule_rerun_t reruns[controller_rule_action_execute_type__enum_size_e];
+ controller_rule_actions_t actions;
} controller_rule_item_t;
#define controller_rule_item_t_initialize \
controller_rule_rerun_t_initialize, \
controller_rule_rerun_t_initialize, \
}, \
- controller_main_rule_actions_t_initialize, \
+ controller_rule_actions_t_initialize, \
}
#endif // _di_controller_rule_item_t_
* - parameter: Any parameters made available to the Rule for IKI substitution.
* - path: The path to the Rule file.
* - scheduler: The scheduler setting if the Rule "has" a scheduler.
- * - status: A set of action-specific success/failure status of the Rule. Each index represents a controller_main_rule_action_type_* enum value. Index 0 represents a global status.
+ * - status: A set of action-specific success/failure status of the Rule. Each index represents a controller_rule_action_type_* enum value. Index 0 represents a global status.
* - timeout_exit: The timeout to wait when exiting the Controller program after sending the terminate signal to send the kill signal.
* - timeout_kill: The timeout to wait relating to using a kill signal.
* - timeout_start: The timeout to wait relating to starting a process.
*/
#ifndef _di_controller_rule_t_
typedef struct {
- f_status_t status[controller_main_rule_action_type__enum_size_e];
+ f_status_t status[controller_rule_action_type__enum_size_e];
f_number_unsigned_t timeout_kill;
f_number_unsigned_t timeout_start;
* @see f_memory_array_resize()
* @see f_memory_arrays_resize()
*/
-#ifndef _di_controller_main_rule_action_delete_
- extern void controller_main_rule_action_delete(controller_main_rule_action_t * const action);
-#endif // _di_controller_main_rule_action_delete_
+#ifndef _di_controller_rule_action_delete_
+ extern void controller_rule_action_delete(controller_rule_action_t * const action);
+#endif // _di_controller_rule_action_delete_
/**
- * A callback intended to be passed to f_memory_arrays_resize() for an controller_main_rule_actions_t structure.
+ * A callback intended to be passed to f_memory_arrays_resize() for an controller_rule_actions_t structure.
*
* This is only called when shrinking the array and generally should perform de-allocations.
*
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * @see controller_main_rule_action_delete()
+ * @see controller_rule_action_delete()
*/
-#ifndef _di_controller_main_rule_actions_delete_callback_
- extern f_status_t controller_main_rule_actions_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array);
-#endif // _di_controller_main_rule_actions_delete_callback_
+#ifndef _di_controller_rule_actions_delete_callback_
+ extern f_status_t controller_rule_actions_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array);
+#endif // _di_controller_rule_actions_delete_callback_
/**
* Delete the Controller Rule Item data.
* @param item
* The Rule Item data.
*
- * @see controller_main_rule_actions_delete()
+ * @see controller_rule_actions_delete()
*
* @see f_memory_array_resize()
*/
#include <fll/level_0/time.h>
#ifndef _di_thread_support_
+ #include <fll/level_0/account.h>
+ #include <fll/level_0/file.h>
#include <fll/level_0/thread.h>
#endif // _di_thread_support_
// FLL-1 includes.
#include <fll/level_1/conversion.h>
#include <fll/level_1/environment.h>
-#include <fll/level_1/execute.h>
-#include <fll/level_1/fss.h>
-#include <fll/level_1/fss/extended.h>
-#include <fll/level_1/fss/extended_list.h>
#include <fll/level_1/iki.h>
#include <fll/level_1/path.h>
-#include <fll/level_1/print.h>
// FLL-2 includes.
#include <fll/level_2/error.h>
+#include <fll/level_2/execute.h>
#include <fll/level_2/control_group.h>
#include <fll/level_2/fss.h>
#include <fll/level_2/fss/basic_list.h>
#include <program/controller/main/common/type/thread.h>
#include <program/controller/main/common/type.h>
#include <program/controller/main/common.h>
+#include <program/controller/main/convert.h>
#include <program/controller/main/lock.h>
#include <program/controller/main/path.h>
#include <program/controller/main/print/action.h>
#include <program/controller/main/thread/rule.h>
#include <program/controller/main/thread/signal.h>
#include <program/controller/main/thread.h>
+#include <program/controller/main/file.h>
#include <program/controller/main/instance.h>
+#include <program/controller/main/instance/prepare.h>
+#include <program/controller/main/instance/wait.h>
#include <program/controller/main/rule.h>
#include <program/controller/main/rule/action.h>
#include <program/controller/main/rule/execute.h>
--- /dev/null
+#include "controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_convert_user_id_
+ f_status_t controller_convert_user_id(const f_string_static_t buffer, const f_range_t range, controller_cache_t * const cache, uid_t * const id) {
+
+ f_number_unsigned_t number = 0;
+
+ f_status_t status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, buffer, range, &number);
+
+ if (F_status_is_error(status)) {
+ if (F_status_set_fine(status) == F_number) {
+ cache->action.generic.used = 0;
+
+ status = f_rip_dynamic_partial_nulless(buffer, range, &cache->action.generic);
+ if (F_status_is_error(status)) return status;
+
+ status = f_account_id_by_name(cache->action.generic, id);
+ if (F_status_is_error(status)) return status;
+
+ return (status == F_exist_not) ? F_status_set_error(F_exist_not) : F_okay;
+ }
+
+ return status;
+ }
+
+ return (number > F_type_size_32_unsigned_d) ? F_status_set_error(F_number_too_large) : F_okay;
+ }
+#endif // _di_controller_convert_user_id_
+
+#ifndef _di_controller_convert_group_id_
+ f_status_t controller_convert_group_id(const f_string_static_t buffer, const f_range_t range, controller_cache_t * const cache, gid_t * const id) {
+
+ f_number_unsigned_t number = 0;
+
+ f_status_t status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, buffer, range, &number);
+
+ if (F_status_is_error(status)) {
+ if (F_status_set_fine(status) == F_number) {
+ cache->action.generic.used = 0;
+
+ status = f_rip_dynamic_partial_nulless(buffer, range, &cache->action.generic);
+ if (F_status_is_error(status)) return status;
+
+ status = f_account_group_id_by_name(cache->action.generic, id);
+ if (F_status_is_error(status)) return status;
+
+ return (status == F_exist_not) ? F_status_set_error(F_exist_not) : F_okay;
+ }
+
+ return status;
+ }
+
+ return (number > F_type_size_32_unsigned_d) ? F_status_set_error(F_number_too_large) : F_okay;
+ }
+#endif // _di_controller_convert_group_id_
+
+#ifndef _di_controller_convert_rule_action_execute_type_string_
+ f_string_static_t controller_convert_rule_action_execute_type_string(const uint8_t type) {
+
+ switch (type) {
+ case controller_rule_action_execute_type_freeze_e:
+ return controller_freeze_s;
+
+ case controller_rule_action_execute_type_kill_e:
+ return controller_kill_s;
+
+ case controller_rule_action_execute_type_pause_e:
+ return controller_pause_s;
+
+ case controller_rule_action_execute_type_reload_e:
+ return controller_reload_s;
+
+ case controller_rule_action_execute_type_restart_e:
+ return controller_restart_s;
+
+ case controller_rule_action_execute_type_resume_e:
+ return controller_resume_s;
+
+ case controller_rule_action_execute_type_start_e:
+ return controller_start_s;
+
+ case controller_rule_action_execute_type_stop_e:
+ return controller_stop_s;
+
+ case controller_rule_action_execute_type_thaw_e:
+ return controller_thaw_s;
+ }
+
+ return f_string_empty_s;
+ }
+#endif // _di_controller_convert_rule_action_execute_type_string_
+
+#ifndef _di_controller_convert_rule_action_type_string_
+ f_string_static_t controller_convert_rule_action_type_string(const uint8_t type) {
+
+ switch (type) {
+ case controller_rule_action_type_freeze_e:
+ return controller_freeze_s;
+
+ case controller_rule_action_type_group_e:
+ return controller_group_s;
+
+ case controller_rule_action_type_kill_e:
+ return controller_kill_s;
+
+ case controller_rule_action_type_pause_e:
+ return controller_pause_s;
+
+ case controller_rule_action_type_pid_file_e:
+ return controller_pid_file_s;
+
+ case controller_rule_action_type_reload_e:
+ return controller_reload_s;
+
+ case controller_rule_action_type_rerun_e:
+ return controller_rerun_s;
+
+ case controller_rule_action_type_restart_e:
+ return controller_restart_s;
+
+ case controller_rule_action_type_resume_e:
+ return controller_resume_s;
+
+ case controller_rule_action_type_start_e:
+ return controller_start_s;
+
+ case controller_rule_action_type_stop_e:
+ return controller_stop_s;
+
+ case controller_rule_action_type_thaw_e:
+ return controller_thaw_s;
+
+ case controller_rule_action_type_user_e:
+ return controller_user_s;
+
+ case controller_rule_action_type_with_e:
+ return controller_with_s;
+ }
+
+ return f_string_empty_s;
+ }
+#endif // _di_controller_convert_rule_action_type_string_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides convert functionality.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_convert_h
+#define _controller_convert_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Convert the string from a string representation of an ID or a user name into the numeric representation of that ID or user name.
+ *
+ * @param buffer
+ * A string containing user name or ID.
+ * @param range
+ * The range within the buffer specifically containing the name or ID.
+ * @param cache
+ * The cache.
+ * @param id
+ * The determined user ID.
+ *
+ * @return
+ * F_okay on success.
+ *
+ * F_exist_not (with error bit) if failed to match the name to an ID.
+ * F_number_too_large (with error bit) if the given ID is too large.
+ *
+ * Errors (with error bit) from: f_account_id_by_name().
+ * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect().
+ * Errors (with error bit) from: f_rip_dynamic_partial_nulless().
+ *
+ * @see f_account_id_by_name()
+ * @see fl_conversion_dynamic_partial_to_unsigned_detect()
+ * @see f_rip_dynamic_partial_nulless()
+ */
+#ifndef _di_controller_convert_user_id_
+ f_status_t controller_convert_user_id(const f_string_static_t buffer, const f_range_t range, controller_cache_t * const cache, uid_t * const id);
+#endif // _di_controller_convert_user_id_
+
+/**
+ * Convert the string from a string representation of an ID or a group name into the numeric representation of that ID or group name.
+ *
+ * @param buffer
+ * A string containing group name or ID.
+ * @param range
+ * The range within the buffer specifically containing the name or ID.
+ * @param cache
+ * The cache.
+ * @param id
+ * The determined group ID.
+ *
+ * @return
+ * F_okay on success.
+ *
+ * F_exist_not (with error bit) if failed to match the name to an ID.
+ * F_number_too_large (with error bit) if the given ID is too large.
+ *
+ * Errors (with error bit) from: f_account_group_id_by_name().
+ * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect().
+ * Errors (with error bit) from: f_rip_dynamic_partial_nulless().
+ *
+ * @see f_account_group_id_by_name()
+ * @see fl_conversion_dynamic_partial_to_unsigned_detect()
+ * @see f_rip_dynamic_partial_nulless()
+ */
+#ifndef _di_controller_convert_group_id_
+ f_status_t controller_convert_group_id(const f_string_static_t buffer, const f_range_t range, controller_cache_t * const cache, gid_t * const id);
+#endif // _di_controller_convert_group_id_
+
+/**
+ * Convert the rule action execute type code to the string representation.
+ *
+ * @param type
+ * The rule action execute type code.
+ *
+ * @return
+ * The string with used > 0 on success.
+ * The string with used == 0 if no match was found.
+ */
+#ifndef _di_controller_convert_rule_action_execute_type_string_
+ extern f_string_static_t controller_convert_rule_action_execute_type_string(const uint8_t type);
+#endif // _di_controller_convert_rule_action_execute_type_string_
+
+/**
+ * Convert the rule action type code to the string representation.
+ *
+ * @param type
+ * The rule action type code.
+ *
+ * @return
+ * The string with used > 0 on success.
+ * The string with used == 0 if no match was found.
+ */
+#ifndef _di_controller_convert_rule_action_type_string_
+ extern f_string_static_t controller_convert_rule_action_type_string(const uint8_t type);
+#endif // _di_controller_convert_rule_action_type_string_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_convert_h
--- /dev/null
+#include "controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_file_load_
+ f_status_t controller_file_load(controller_global_t * const global, controller_cache_t * const cache, const bool required, const f_string_static_t path_prefix, const f_string_static_t path_name, const f_string_static_t path_suffix) {
+
+ if (!global || !cache) return F_status_set_error(F_parameter);
+
+ f_status_t status = F_okay;
+ f_file_t file = f_file_t_initialize;
+
+ cache->action.name_file.used = 0;
+ cache->buffer_file.used = 0;
+ cache->timestamp.seconds = 0;
+ cache->timestamp.seconds_nano = 0;
+
+ status = f_string_dynamic_append(path_prefix, &cache->action.name_file);
+
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(f_path_separator_s, &cache->action.name_file);
+ }
+
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(path_name, &cache->action.name_file);
+ }
+
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(f_path_extension_separator_s, &cache->action.name_file);
+ }
+
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(path_suffix, &cache->action.name_file);
+ }
+
+ if (F_status_is_error(status)) {
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status));
+
+ return status;
+ }
+
+ f_string_static_t path = f_string_static_t_initialize;
+
+ if (global->setting->path_setting.used) {
+ path.used = global->setting->path_setting.used + F_path_separator_s_length + cache->action.name_file.used;
+ }
+ else {
+ path.used = cache->action.name_file.used;
+ }
+
+ f_char_t path_string[path.used + 1];
+ path.string = path_string;
+
+ if (global->setting->path_setting.used) {
+ memcpy(path_string, global->setting->path_setting.string, sizeof(f_char_t) * global->setting->path_setting.used);
+ memcpy(path_string + global->setting->path_setting.used + F_path_separator_s_length, cache->action.name_file.string, sizeof(f_char_t) * cache->action.name_file.used);
+
+ path_string[global->setting->path_setting.used] = f_path_separator_s.string[0];
+ }
+ else {
+ memcpy(path_string, cache->action.name_file.string, sizeof(f_char_t) * cache->action.name_file.used);
+ }
+
+ path_string[path.used] = 0;
+
+
+ status = f_file_stream_open(path, f_string_empty_s, &file);
+
+ if (F_status_is_error(status)) {
+ if (!required && F_status_set_fine(status) == F_file_found_not) {
+ f_file_stream_flush(file);
+ f_file_stream_close(&file);
+
+ return F_file_found_not;
+ }
+
+ if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_print_error_file_status(&global->main->program.error, macro_controller_f(f_file_stream_open), F_true, path, f_file_operation_open_s, fll_error_file_type_file_e, F_status_set_fine(status));
+ }
+ }
+ else {
+ status = f_file_stream_read(file, &cache->buffer_file);
+
+ if (F_status_is_error(status)) {
+ if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_print_error_file(global->thread, &global->main->program.error, F_status_set_fine(status), "f_file_stream_read", F_true, path, f_file_operation_read_s, fll_error_file_type_file_e);
+ }
+ }
+ }
+
+ f_file_stream_flush(file);
+ f_file_stream_close(&file);
+
+ if (F_status_is_error_not(status)) {
+ struct stat stat_file;
+
+ status = f_file_stat(path, F_true, &stat_file);
+
+ if (F_status_is_error(status)) {
+ if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_print_error_file(global->thread, &global->main->program.error, F_status_set_fine(status), "f_file_stat", F_true, path, f_file_operation_stat_s, fll_error_file_type_file_e);
+ }
+ }
+ else {
+ cache->timestamp.seconds = stat_file.st_ctim.tv_sec;
+ cache->timestamp.seconds_nano = stat_file.st_ctim.tv_nsec;
+ }
+ }
+
+ return F_status_is_error(status) ? status : F_okay;
+ }
+#endif // _di_controller_file_load_
+
+#ifndef _di_controller_file_pid_create_
+ f_status_t controller_file_pid_create(const pid_t pid, const f_string_static_t path) {
+
+ f_status_t status = F_okay;
+
+ // The file exists, do not attempt to overwrite.
+ if (f_file_exists(path, F_true) == F_true) return F_status_set_error(F_file_found);
+
+ {
+ f_string_dynamic_t path_directory = f_string_dynamic_t_initialize;
+
+ status = f_file_name_directory(path, &path_directory);
+
+ if (F_status_is_error_not(status)) {
+ status = f_directory_exists(path_directory);
+ }
+
+ f_memory_array_resize(0, sizeof(f_char_t), (void **) &path_directory.string, &path_directory.used, &path_directory.size);
+ if (F_status_is_error(status)) return status;
+
+ // The directory does not exist so do not bother attempting to create a pid file.
+ if (status == F_false) return F_status_set_error(F_directory_not);
+ }
+
+ f_file_t file = f_file_t_initialize;
+
+ file.flag = F_file_flag_write_only_d;
+
+ status = f_file_stream_open(path, f_file_open_mode_read_truncate_s, &file);
+ if (F_status_is_error(status)) return status;
+
+ fll_print_format("%i%r", file, pid, f_string_eol_s);
+
+ f_file_stream_flush(file);
+ f_file_stream_close(&file);
+
+ return F_status_is_error(status) ? status : F_okay;
+ }
+#endif // _di_controller_file_pid_create_
+
+#ifndef _di_controller_file_pid_delete_
+ f_status_t controller_file_pid_delete(const pid_t pid, const f_string_static_t path) {
+
+ // Only delete if the file exists and there is no error while checking.
+ if (f_file_exists(path, F_true) != F_true) return F_okay;
+
+ f_status_t status = F_okay;
+ f_file_t pid_file = f_file_t_initialize;
+
+ status = f_file_stream_open(path, f_file_open_mode_read_s, &pid_file);
+ if (F_status_is_error(status)) return status;
+
+ f_string_dynamic_t pid_buffer = f_string_dynamic_t_initialize;
+
+ status = f_file_stream_read(pid_file, &pid_buffer);
+
+ if (F_status_is_error_not(status)) {
+ status = f_file_stream_flush(pid_file);
+ }
+
+ if (F_status_is_error_not(status)) {
+ status = f_file_stream_close(&pid_file);
+ }
+
+ if (F_status_is_error_not(status)) {
+ f_number_unsigned_t number = 0;
+ f_range_t range = macro_f_range_t_initialize_2(pid_buffer.used);
+
+ for (; range.start < pid_buffer.used; ++range.start) {
+ if (!isspace(pid_buffer.string[range.start])) break;
+ } // for
+
+ for (; range.stop > 0; --range.stop) {
+ if (!isspace(pid_buffer.string[range.stop])) break;
+ } // for
+
+ status = fl_conversion_dynamic_partial_to_unsigned(fl_conversion_data_base_10_c, pid_buffer, range, &number);
+
+ if (F_status_is_error_not(status) && number == pid) {
+ status = f_file_remove(path);
+ }
+ else {
+ status = F_status_set_error(F_number_not);
+ }
+ }
+
+ f_memory_array_resize(0, sizeof(f_char_t), (void **) &pid_buffer.string, &pid_buffer.used, &pid_buffer.size);
+
+ return status;
+ }
+#endif // _di_controller_file_pid_delete_
+
+#ifndef _di_controller_file_pid_read_
+ f_status_t controller_file_pid_read(const f_string_static_t path, pid_t * const pid) {
+
+ *pid = 0;
+
+ f_status_t status = f_file_exists(path, F_true);
+ if (F_status_is_error(status)) return status;
+ if (status != F_true) return F_data_not;
+
+ f_file_t pid_file = f_file_t_initialize;
+
+ status = f_file_stream_open(path, f_file_open_mode_read_s, &pid_file);
+ if (F_status_is_error(status)) return status;
+
+ f_string_dynamic_t pid_buffer = f_string_dynamic_t_initialize;
+
+ status = f_file_stream_read(pid_file, &pid_buffer);
+
+ if (F_status_is_error_not(status)) {
+ status = f_file_stream_flush(pid_file);
+ }
+
+ if (F_status_is_error_not(status)) {
+ status = f_file_stream_close(&pid_file);
+ }
+
+ if (F_status_is_error_not(status)) {
+ f_number_unsigned_t number = 0;
+ f_range_t range = macro_f_range_t_initialize_2(pid_buffer.used);
+
+ for (; range.start < pid_buffer.used; ++range.start) {
+ if (!isspace(pid_buffer.string[range.start])) break;
+ } // for
+
+ for (; range.stop > 0; --range.stop) {
+ if (!isspace(pid_buffer.string[range.stop])) break;
+ } // for
+
+ status = fl_conversion_dynamic_partial_to_unsigned(fl_conversion_data_base_10_c, pid_buffer, range, &number);
+
+ if (F_status_is_error_not(status)) {
+ *pid = (pid_t) number;
+ }
+ }
+
+ f_memory_array_resize(0, sizeof(f_char_t), (void **) &pid_buffer.string, &pid_buffer.used, &pid_buffer.size);
+
+ return status;
+ }
+#endif // _di_controller_file_pid_read_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides file functionality.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_file_h
+#define _controller_file_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Load a file from the controller settings directory.
+ *
+ * @param global
+ * The global data.
+ *
+ * Must not be NULL.
+ * @param cache
+ * The following within the cache is updated:
+ * - name_file: The partial path of the file is inserted.
+ * - buffer_file: The contents of the file is inserted.
+ * - timestamp: This is updated to reflect the last changed timestamp.
+ *
+ * Must not be NULL.
+ *
+ * @param required
+ * If TRUE, the file is required to exist and will throw an error if not found.
+ * If FALSE, the file is not required to exist and will return without error if not found.
+ * @param path_prefix
+ * The path prefix, such as 'entries' from '/etc/controller/entries/default.entry'.
+ * @param path_name
+ * The path name, such as 'default' from '/etc/controller/entries/default.entry'.
+ * @param path_suffix
+ * The path suffix, such as 'entry' from '/etc/controller/entries/default.entry'.
+ *
+ * @return
+ * F_okay on success.
+ * F_file_found_not if required is FALSE and the file is not found.
+ *
+ * Errors (with error bit) from: f_file_stat().
+ * Errors (with error bit) from: f_file_stream_open().
+ * Errors (with error bit) from: f_file_stream_read().
+ * Errors (with error bit) from: f_string_append().
+ *
+ * @see f_file_stat()
+ * @see f_file_stream_open()
+ * @see f_file_stream_read()
+ * @see f_string_append()
+ */
+#ifndef _di_controller_file_load_
+ extern f_status_t controller_file_load(controller_global_t * const global, controller_cache_t * const cache, const bool required, const f_string_static_t path_prefix, const f_string_static_t path_name, const f_string_static_t path_suffix);
+#endif // _di_controller_file_load_
+
+/**
+ * Create the pid file, if possible.
+ *
+ * @param pid
+ * The PID (process id).
+ * @param path
+ * The file path to the pid file to create.
+ *
+ * @return
+ * F_okay on success.
+ * F_access_denied if pid file is not created due to access denied errors.
+ * F_directory_not if pid file is not created due to a parent directory is unavailable or invalid.
+ *
+ * Errors (with error bit) from: f_directory_exists().
+ * Errors (with error bit) from: f_file_name_directory().
+ * Errors (with error bit) from: f_file_stream_open().
+ *
+ * @see f_directory_exists()
+ * @see f_file_name_directory()
+ * @see f_file_stream_open()
+ */
+#ifndef _di_controller_file_pid_create_
+ f_status_t controller_file_pid_create(const pid_t pid, const f_string_static_t path);
+#endif // _di_controller_file_pid_create_
+
+/**
+ * Delete the pid file, if exists and is valid.
+ *
+ * This is meant to be called on exit and avoids checking status codes, returning void.
+ *
+ * @param pid
+ * The PID (process id).
+ * @param path
+ * The file path to the pid file to create.
+ *
+ * @return
+ * F_okay on success.
+ *
+ * F_number_not (with error bit) if the number from the pid file doesn't match the expected pid.
+ *
+ * Errors (with error bit) from: f_file_stream_close().
+ * Errors (with error bit) from: f_file_stream_open().
+ * Errors (with error bit) from: f_file_stream_read().
+ * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned()
+ */
+#ifndef _di_controller_file_pid_delete_
+ f_status_t controller_file_pid_delete(const pid_t pid, const f_string_static_t path);
+#endif // _di_controller_file_pid_delete_
+
+/**
+ * Read the PID from a PID file.
+ *
+ * @param path
+ * The file path to the pid file to create.
+ * @param pid
+ * The PID to be read.
+ *
+ * @return
+ * F_okay on success.
+ *
+ * Errors (with error bit) from: f_file_stream_close().
+ * Errors (with error bit) from: f_file_stream_open().
+ * Errors (with error bit) from: f_file_stream_read().
+ * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned()
+ */
+#ifndef _di_controller_file_pid_read_
+ f_status_t controller_file_pid_read(const f_string_static_t path, pid_t * const pid);
+#endif // _di_controller_file_pid_read_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_file_h
extern "C" {
#endif
+#ifndef _di_controller_instance_find_
+ f_status_t controller_instance_find(const f_number_unsigned_t action, const f_string_static_t alias, const controller_instances_t instances, f_number_unsigned_t * const at) {
+
+ if (!alias.used) return F_okay;
+ if (!instances.used) return F_false;
+
+ for (f_number_unsigned_t i = 0; i < instances.used; ++i) {
+
+ if (instances.array[i] && instances.array[i]->action == action && f_compare_dynamic(alias, instances.array[i]->rule.alias) == F_equal_to) {
+ if (at) *at = i;
+
+ return F_true;
+ }
+ } // for
+
+ return F_false;
+ }
+#endif // _di_controller_instance_find_
+
#ifdef __cplusplus
} // extern "C"
#endif
*
* This is auto-included and should not need to be explicitly included.
*/
-#ifndef _controller_main_instance_h
-#define _controller_main_instance_h
+#ifndef _controller_instance_h
+#define _controller_instance_h
#ifdef __cplusplus
extern "C" {
#endif
+/**
+ * Find an existing instance, for the given Rule Action.
+ *
+ * This does not do any locking or unlocking for the instances data, be sure to lock appropriately before and after calling this.
+ *
+ * @param action
+ * The Rule Action to find.
+ * @param alias
+ * The Rule alias to find.
+ * @param instances
+ * The array of instancees to.
+ * @param at
+ * (optional) The location within instances the id was found.
+ *
+ * Set to NULL to disable.
+ *
+ * @return
+ * F_okay if not given a valid id to search.
+ * F_false if there is no instance found.
+ * F_true if there is a instance found (address is stored in "at").
+ */
+#ifndef _di_controller_instance_find_
+ f_status_t controller_instance_find(const f_number_unsigned_t action, const f_string_static_t alias, const controller_instances_t instances, f_number_unsigned_t * const at);
+#endif // _di_controller_instance_find_
+
#ifdef __cplusplus
} // extern "C"
#endif
-#endif // _controller_main_instance_h
+#endif // _controller_instance_h
--- /dev/null
+#include "../controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_instance_prepare_
+ f_status_t controller_instance_prepare(controller_global_t * const global, const bool is_normal, const uint8_t action, const f_string_static_t alias, f_number_unsigned_t *id) {
+
+ if (!global) return F_status_set_error(F_parameter);
+
+ f_status_t status = F_okay;
+
+ if (controller_instance_find(action, alias, global->thread->instances, id) == F_false) {
+ f_thread_unlock(&global->thread->lock.instance);
+
+ status = controller_lock_write(is_normal, global->thread, &global->thread->lock.instance);
+
+ if (F_status_is_error(status)) {
+ controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status), F_false, global->thread);
+ }
+ else {
+ status = f_memory_array_increase(controller_allocation_small_d, sizeof(controller_instance_t), (void **) &global->thread->instances.array, &global->thread->instances.used, &global->thread->instances.size);
+ }
+
+ if (F_status_is_error_not(status) && global->thread->instances.array[global->thread->instances.used]) {
+
+ controller_instance_t * const instance = global->thread->instances.array[global->thread->instances.used];
+
+ status = controller_lock_write(is_normal, global->thread, &instance->lock);
+
+ if (F_status_is_error(status)) {
+ controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status), F_false, global->thread);
+ }
+ else {
+ instance->action = action;
+ instance->rule.alias.used = 0;
+ instance->global = global;
+
+ status = f_string_dynamic_append(alias, &instance->rule.alias);
+
+ if (F_status_is_error_not(status)) {
+ instance->id = global->thread->instances.used++;
+ status = F_okay;
+
+ if (id) {
+ *id = instance->id;
+ }
+ }
+
+ f_thread_unlock(&instance->lock);
+ }
+ }
+
+ f_thread_unlock(&global->thread->lock.instance);
+
+ // The read lock must be restored on return.
+ status = F_status_is_error(controller_lock_read(is_normal, global->thread, &global->thread->lock.instance))
+ ? F_status_set_error(F_lock)
+ : F_okay;
+ }
+ else {
+ status = F_found;
+ }
+
+ return status;
+ }
+#endif // _di_controller_instance_prepare_
+
+#ifndef _di_controller_instance_prepare_instance_type_
+ f_status_t controller_instance_prepare_instance_type(controller_global_t * const global, const uint8_t type, const uint8_t action, const f_string_static_t alias, f_number_unsigned_t *id) {
+
+ return controller_instance_prepare(global, type != controller_instance_type_exit_e, action, alias, id);
+ }
+#endif // _di_controller_instance_prepare_instance_type_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the instance prepare functionality.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_main_instance_prepare_h
+#define _controller_main_instance_prepare_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Prepare the instance.
+ *
+ * The instance is initialized with the instance id, the rule alias, and the rule action type.
+ * These are the necessary parts for uniquely identifying the instance.
+ *
+ * If a instance by the given Rule alias and Rule Action already exists, then nothing is done.
+ *
+ * This requires that a global.thread->lock.instance lock be set on instance->lock before being called.
+ *
+ * @param global
+ * The global data.
+ *
+ * Must not be NULL.
+ * @param is_normal
+ * If TRUE, then instance as if this operates during a normal operation (entry and control).
+ * If FALSE, then instance as if this operates during a an exit operation.
+ * @param action
+ * The Rule Action to use.
+ * @param alias
+ * The Rule alias to use.
+ * @param id
+ * (optional) The instance ID when found or created.
+ *
+ * Set to NULL to not use.
+ *
+ * @return
+ * F_okay on success.
+ * F_found on success, but nothing was done because an existing instance was found.
+ *
+ * F_lock (with error bit) if failed to re-establish read lock on global.thread->lock.instance while returning.
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_string_dynamic_append().
+ *
+ * Errors (with error bit) from: controller_lock_read().
+ * Errors (with error bit) from: controller_lock_write().
+ *
+ * @see f_string_dynamic_append()
+ * @see controller_lock_read()
+ * @see controller_lock_write()
+ */
+#ifndef _di_controller_instance_prepare_
+ extern f_status_t controller_instance_prepare(controller_global_t * const global, const bool is_normal, const uint8_t action, const f_string_static_t alias, f_number_unsigned_t *id);
+#endif // _di_controller_instance_prepare_
+
+/**
+ * Prepare the instance for some instance type.
+ *
+ * The instance is initialized with the instance id, the rule alias, and the rule action type.
+ * These are the necessary parts for uniquely identifying the instance.
+ *
+ * If a instance by the given Rule alias and Rule Action already exists, then nothing is done.
+ *
+ * This requires that a global.thread->lock.instance lock be set on instance->lock before being called.
+ *
+ * @param global
+ * The global data.
+ *
+ * Must not be NULL.
+ * @param type
+ * The instance type to use when checking if thread is enabled.
+ * @param action
+ * The Rule Action to use.
+ * @param alias
+ * The Rule alias to use.
+ * @param id
+ * (optional) The instance ID when found or created.
+ *
+ * Set to NULL to not use.
+ *
+ * @return
+ * Success from: controller_instance_prepare()
+ *
+ * Errors (with error bit) from: controller_instance_prepare().
+ *
+ * @see controller_instance_prepare()
+ */
+#ifndef _di_controller_instance_prepare_instance_type_
+ extern f_status_t controller_instance_prepare_instance_type(controller_global_t * const global, const uint8_t type, const uint8_t action, const f_string_static_t alias, f_number_unsigned_t *id);
+#endif // _di_controller_instance_prepare_instance_type_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_main_instance_prepare_h
--- /dev/null
+#include "../controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_instance_wait_
+ f_status_t controller_instance_wait(controller_instance_t * const instance) {
+
+ if (!instance || !instance->global || !instance->global->main || !instance->global->thread) return F_status_set_error(F_parameter);
+ if (!controller_thread_is_enabled_instance(instance)) return F_status_set_error(F_interrupt);
+
+ f_time_spec_t time;
+
+ f_status_t status = F_okay;
+ f_status_t status_lock = F_okay;
+
+ uint8_t count = 0;
+
+ do {
+ f_thread_mutex_lock(&instance->wait_lock);
+
+ if (count < controller_thread_wait_timeout_1_before_d) {
+ controller_time_now(controller_thread_wait_timeout_1_seconds_d, controller_thread_wait_timeout_1_nanoseconds_d, &time);
+ }
+ else if (count < controller_thread_wait_timeout_2_before_d) {
+ controller_time_now(controller_thread_wait_timeout_2_seconds_d, controller_thread_wait_timeout_2_nanoseconds_d, &time);
+ }
+ else if (count < controller_thread_wait_timeout_3_before_d) {
+ controller_time_now(controller_thread_wait_timeout_3_seconds_d, controller_thread_wait_timeout_3_nanoseconds_d, &time);
+ }
+ else {
+ controller_time_now(controller_thread_wait_timeout_4_seconds_d, controller_thread_wait_timeout_4_nanoseconds_d, &time);
+ }
+
+ status = f_thread_condition_wait_timed(&time, &instance->wait, &instance->wait_lock);
+
+ f_thread_mutex_unlock(&instance->wait_lock);
+
+ if (!controller_thread_is_enabled_instance(instance)) return F_status_set_error(F_interrupt);
+ if (F_status_is_error(status)) break;
+
+ status_lock = controller_lock_read_instance(instance, &instance->lock);
+
+ if (F_status_is_error(status_lock)) {
+ controller_lock_print_error_critical(&instance->global->main->program.error, F_status_set_fine(status_lock), F_true, instance->global->thread);
+
+ break;
+ }
+
+ if (!controller_rule_status_is_available(instance->action, instance->rule) && !(instance->state == controller_instance_state_active_e || instance->state == controller_instance_state_busy_e)) {
+ f_thread_unlock(&instance->lock);
+
+ return F_okay;
+ }
+
+ if (status != F_time) {
+
+ // move up the wait timer after a trigger was received.
+ if (count < controller_thread_wait_timeout_2_before_d) {
+ count = 0;
+ }
+ else if (count < controller_thread_wait_timeout_3_before_d) {
+ count = controller_thread_wait_timeout_1_before_d;
+ }
+ else {
+ count = controller_thread_wait_timeout_2_before_d;
+ }
+ }
+
+ f_thread_unlock(&instance->lock);
+
+ if (count < controller_thread_wait_timeout_3_before_d) {
+ ++count;
+ }
+
+ } while (status == F_time && controller_thread_is_enabled_instance(instance));
+
+ return status;
+ }
+#endif // _di_controller_instance_wait_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the instance wait functionality.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_main_instance_wait_h
+#define _controller_main_instance_wait_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***
+ * Safely wait for a instance, periodically checking to see if instance completed or check if exiting.
+ *
+ * @param instance
+ * The instance to wait on.
+ *
+ * Must not be NULL.
+ *
+ * @return
+ * F_okay on success.
+ *
+ * F_interrupt (with error bit) on receiving a instance signal, such as an interrupt signal.
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Success from: f_thread_condition_wait_timed().
+ *
+ * Errors (with error bit) from: f_thread_condition_wait_timed().
+ *
+ * @see f_thread_condition_wait_timed()
+ */
+#ifndef _di_controller_instance_wait_
+ extern f_status_t controller_instance_wait(controller_instance_t * const instance);
+#endif // _di_controller_instance_wait_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_main_instance_wait_h
extern "C" {
#endif
-#ifndef _di_controller_main_lock_create_
- f_status_t controller_main_lock_create(controller_lock_t * const lock) {
+#ifndef _di_controller_lock_create_
+ f_status_t controller_lock_create(controller_lock_t * const lock) {
if (!lock) return F_status_set_error(F_parameter);
return F_status_is_error(status) ? status : F_okay;
}
-#endif // _di_controller_main_lock_create_
+#endif // _di_controller_lock_create_
-#ifndef _di_controller_main_lock_read_
- f_status_t controller_main_lock_read(const bool is_normal, controller_thread_t * const thread, f_thread_lock_t * const lock) {
+#ifndef _di_controller_lock_read_
+ f_status_t controller_lock_read(const bool is_normal, controller_thread_t * const thread, f_thread_lock_t * const lock) {
if (!thread || !lock) return F_status_set_error(F_parameter);
for (f_time_spec_t time; ; ) {
- controller_main_time_now(controller_thread_lock_read_timeout_seconds_d, controller_thread_lock_read_timeout_nanoseconds_d, &time);
+ controller_time_now(controller_thread_lock_read_timeout_seconds_d, controller_thread_lock_read_timeout_nanoseconds_d, &time);
status = f_thread_lock_read_timed(&time, lock);
if (status == F_time) {
- if (!controller_main_thread_is_enabled(is_normal, thread)) return F_status_set_error(F_interrupt);
+ if (!controller_thread_is_enabled(is_normal, thread)) return F_status_set_error(F_interrupt);
}
else {
break;
return status;
}
-#endif // _di_controller_main_lock_read_
+#endif // _di_controller_lock_read_
-#ifndef _di_controller_main_lock_read_instance_
- f_status_t controller_main_lock_read_instance(controller_instance_t * const instance, controller_thread_t * const thread, f_thread_lock_t * const lock) {
+#ifndef _di_controller_lock_read_instance_
+ f_status_t controller_lock_read_instance(controller_instance_t * const instance, f_thread_lock_t * const lock) {
- if (!thread || !lock) return F_status_set_error(F_parameter);
+ if (!instance || !lock) return F_status_set_error(F_parameter);
- return controller_main_lock_read_instance_type(instance->type, thread, lock);
+ return controller_lock_read_instance_type(instance->type, instance->global->thread, lock);
}
-#endif // _di_controller_main_lock_read_instance_
+#endif // _di_controller_lock_read_instance_
-#ifndef _di_controller_main_lock_read_instance_type_
- f_status_t controller_main_lock_read_instance_type(const uint8_t type, controller_thread_t * const thread, f_thread_lock_t * const lock) {
+#ifndef _di_controller_lock_read_instance_type_
+ f_status_t controller_lock_read_instance_type(const uint8_t type, controller_thread_t * const thread, f_thread_lock_t * const lock) {
if (!thread || !lock) return F_status_set_error(F_parameter);
- return controller_main_lock_read(type != controller_instance_type_exit_e, thread, lock);
+ return controller_lock_read(type != controller_instance_type_exit_e, thread, lock);
}
-#endif // _di_controller_main_lock_read_instance_type_
+#endif // _di_controller_lock_read_instance_type_
-#ifndef _di_controller_main_lock_write_
- f_status_t controller_main_lock_write(const bool is_normal, controller_thread_t * const thread, f_thread_lock_t * const lock) {
+#ifndef _di_controller_lock_write_
+ f_status_t controller_lock_write(const bool is_normal, controller_thread_t * const thread, f_thread_lock_t * const lock) {
if (!thread || !lock) return F_status_set_error(F_parameter);
for (f_time_spec_t time; ; ) {
- controller_main_time_now(controller_thread_lock_write_timeout_seconds_d, controller_thread_lock_write_timeout_nanoseconds_d, &time);
+ controller_time_now(controller_thread_lock_write_timeout_seconds_d, controller_thread_lock_write_timeout_nanoseconds_d, &time);
status = f_thread_lock_write_timed(&time, lock);
if (status == F_time) {
- if (!controller_main_thread_is_enabled(is_normal, thread)) return F_status_set_error(F_interrupt);
+ if (!controller_thread_is_enabled(is_normal, thread)) return F_status_set_error(F_interrupt);
}
else {
break;
return status;
}
-#endif // _di_controller_main_lock_write_
+#endif // _di_controller_lock_write_
-#ifndef _di_controller_main_lock_write_instance_
- f_status_t controller_main_lock_write_instance(controller_instance_t * const instance, controller_thread_t * const thread, f_thread_lock_t * const lock) {
+#ifndef _di_controller_lock_write_instance_
+ f_status_t controller_lock_write_instance(controller_instance_t * const instance, f_thread_lock_t * const lock) {
- if (!thread || !lock) return F_status_set_error(F_parameter);
+ if (!instance || !lock) return F_status_set_error(F_parameter);
- return controller_main_lock_write_instance_type(instance->type, thread, lock);
+ return controller_lock_write_instance_type(instance->type, instance->global->thread, lock);
}
-#endif // _di_controller_main_lock_write_instance_
+#endif // _di_controller_lock_write_instance_
-#ifndef _di_controller_main_lock_write_instance_type_
- f_status_t controller_main_lock_write_instance_type(const uint8_t type, controller_thread_t * const thread, f_thread_lock_t * const lock) {
+#ifndef _di_controller_lock_write_instance_type_
+ f_status_t controller_lock_write_instance_type(const uint8_t type, controller_thread_t * const thread, f_thread_lock_t * const lock) {
if (!thread || !lock) return F_status_set_error(F_parameter);
- return controller_main_lock_write(type != controller_instance_type_exit_e, thread, lock);
+ return controller_lock_write(type != controller_instance_type_exit_e, thread, lock);
}
-#endif // _di_controller_main_lock_write_instance_type_
+#endif // _di_controller_lock_write_instance_type_
#ifdef __cplusplus
} // extern "C"
*
* This is auto-included and should not need to be explicitly included.
*/
-#ifndef _controller_main_lock_h
-#define _controller_main_lock_h
+#ifndef _controller_lock_h
+#define _controller_lock_h
#ifdef __cplusplus
extern "C" {
* @see f_thread_lock_delete()
* @see f_thread_mutex_delete()
*/
-#ifndef _di_controller_main_lock_create_
- extern f_status_t controller_main_lock_create(controller_lock_t * const lock);
-#endif // _di_controller_main_lock_create_
+#ifndef _di_controller_lock_create_
+ extern f_status_t controller_lock_create(controller_lock_t * const lock);
+#endif // _di_controller_lock_create_
/**
* Wait to get a read lock.
*
* @see f_thread_lock_read_timed()
*/
-#ifndef _di_controller_main_lock_read_
- extern f_status_t controller_main_lock_read(const bool is_normal, controller_thread_t * const thread, f_thread_lock_t * const lock);
-#endif // _di_controller_main_lock_read_
+#ifndef _di_controller_lock_read_
+ extern f_status_t controller_lock_read(const bool is_normal, controller_thread_t * const thread, f_thread_lock_t * const lock);
+#endif // _di_controller_lock_read_
/**
* Wait to get a read lock for some instance.
*
* @param instance
* The instance to use when checking if thread is enabled.
- * @param thread
- * The thread data used to determine if the main thread is disabled or not.
*
* Must not be NULL.
* @param lock
* Must not be NULL.
*
* @return
- * Status from: controller_main_lock_read().
+ * Status from: controller_lock_read().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: controller_main_lock_read().
+ * Errors (with error bit) from: controller_lock_read().
*
- * @see controller_main_lock_read()
+ * @see controller_lock_read()
*/
-#ifndef _di_controller_main_lock_read_instance_
- extern f_status_t controller_main_lock_read_instance(controller_instance_t * const instance, controller_thread_t * const thread, f_thread_lock_t * const lock);
-#endif // _di_controller_main_lock_read_instance_
+#ifndef _di_controller_lock_read_instance_
+ extern f_status_t controller_lock_read_instance(controller_instance_t * const instance, f_thread_lock_t * const lock);
+#endif // _di_controller_lock_read_instance_
/**
* Wait to get a read lock for some instance type.
* Must not be NULL.
*
* @return
- * Status from: controller_main_lock_read().
+ * Status from: controller_lock_read().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: controller_main_lock_read().
+ * Errors (with error bit) from: controller_lock_read().
*
- * @see controller_main_lock_read()
+ * @see controller_lock_read()
*/
-#ifndef _di_controller_main_lock_read_instance_type_
- extern f_status_t controller_main_lock_read_instance_type(const uint8_t type, controller_thread_t * const thread, f_thread_lock_t * const lock);
-#endif // _di_controller_main_lock_read_instance_type_
+#ifndef _di_controller_lock_read_instance_type_
+ extern f_status_t controller_lock_read_instance_type(const uint8_t type, controller_thread_t * const thread, f_thread_lock_t * const lock);
+#endif // _di_controller_lock_read_instance_type_
/**
* Wait to get a write lock.
*
* @see f_thread_lock_write_timed()
*/
-#ifndef _di_controller_main_lock_write_
- extern f_status_t controller_main_lock_write(const bool is_normal, controller_thread_t * const thread, f_thread_lock_t * const lock);
-#endif // _di_controller_main_lock_write_
+#ifndef _di_controller_lock_write_
+ extern f_status_t controller_lock_write(const bool is_normal, controller_thread_t * const thread, f_thread_lock_t * const lock);
+#endif // _di_controller_lock_write_
/**
* Wait to get a write lock for some instance.
*
* @param instance
* The instance to use when checking if thread is enabled.
- * @param thread
- * The thread data used to determine if the main thread is disabled or not.
*
* Must not be NULL.
* @param lock
* Must not be NULL.
*
* @return
- * Status from: controller_main_lock_write_instance_type().
+ * Status from: controller_lock_write_instance_type().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: controller_main_lock_write_instance_type().
+ * Errors (with error bit) from: controller_lock_write_instance_type().
*
- * @see controller_main_lock_write_instance_type()
+ * @see controller_lock_write_instance_type()
*/
-#ifndef _di_controller_main_lock_write_instance_
- extern f_status_t controller_main_lock_write_instance(controller_instance_t * const instance, controller_thread_t * const thread, f_thread_lock_t * const lock);
-#endif // _di_controller_main_lock_write_instance_
+#ifndef _di_controller_lock_write_instance_
+ extern f_status_t controller_lock_write_instance(controller_instance_t * const instance, f_thread_lock_t * const lock);
+#endif // _di_controller_lock_write_instance_
/**
* Wait to get a write lock for some instance type.
* Must not be NULL.
*
* @return
- * Status from: controller_main_lock_write().
+ * Status from: controller_lock_write().
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: controller_main_lock_write().
+ * Errors (with error bit) from: controller_lock_write().
*
- * @see controller_main_lock_write()
+ * @see controller_lock_write()
*/
-#ifndef _di_controller_main_lock_write_instance_type_
- extern f_status_t controller_main_lock_write_instance_type(const uint8_t type, controller_thread_t * const thread, f_thread_lock_t * const lock);
-#endif // _di_controller_main_lock_write_instance_type_
+#ifndef _di_controller_lock_write_instance_type_
+ extern f_status_t controller_lock_write_instance_type(const uint8_t type, controller_thread_t * const thread, f_thread_lock_t * const lock);
+#endif // _di_controller_lock_write_instance_type_
#ifdef __cplusplus
} // extern "C"
#endif
-#endif // _controller_main_lock_h
+#endif // _controller_lock_h
#endif
#ifndef _di_controller_path_canonical_relative_
- void controller_path_canonical_relative(controller_main_t * const main, const f_string_static_t current, const f_string_static_t source, f_string_dynamic_t * const destination) {
+ void controller_path_canonical_relative(controller_t * const main, const f_string_static_t current, const f_string_static_t source, f_string_dynamic_t * const destination) {
if (!main || !destination) return;
*
* This is auto-included and should not need to be explicitly included.
*/
-#ifndef _controller_main_path_h
-#define _controller_main_path_h
+#ifndef _controller_path_h
+#define _controller_path_h
#ifdef __cplusplus
extern "C" {
* @see memmove()
*/
#ifndef _di_controller_path_canonical_relative_
- extern void controller_path_canonical_relative(controller_main_t * const main, const f_string_static_t current, const f_string_static_t source, f_string_dynamic_t * const destination);
+ extern void controller_path_canonical_relative(controller_t * const main, const f_string_static_t current, const f_string_static_t source, f_string_dynamic_t * const destination);
#endif // _di_controller_path_canonical_relative_
#ifdef __cplusplus
} // extern "C"
#endif
-#endif // _controller_main_path_h
+#endif // _controller_path_h
extern "C" {
#endif
-#ifndef _di_controller_main_print_debug_directory_path_empty_
- f_status_t controller_main_print_debug_directory_path_empty(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name) {
+#ifndef _di_controller_print_debug_directory_path_empty_
+ f_status_t controller_print_debug_directory_path_empty(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name) {
if (!print || !print->custom) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_debug_e) return F_output_not;
- controller_main_t * const main = (controller_main_t *) print->custom;
+ controller_t * const main = (controller_t *) print->custom;
controller_lock_print(print->to, 0);
return F_okay;
}
-#endif // _di_controller_main_print_debug_directory_path_empty_
+#endif // _di_controller_print_debug_directory_path_empty_
#ifdef __cplusplus
} // extern "C"
*
* @see fll_error_print()
*/
-#ifndef _di_controller_main_print_debug_directory_path_empty_
- extern f_status_t controller_main_print_debug_directory_path_empty(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name);
-#endif // _di_controller_main_print_debug_directory_path_empty_
+#ifndef _di_controller_print_debug_directory_path_empty_
+ extern f_status_t controller_print_debug_directory_path_empty(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name);
+#endif // _di_controller_print_debug_directory_path_empty_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_print_error_
- f_status_t controller_main_print_error(fl_print_t * const print, const f_string_t function) {
+#ifndef _di_controller_print_error_
+ f_status_t controller_print_error(fl_print_t * const print, const f_string_t function) {
if (!print || !print->custom) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
- controller_main_t * const main = (controller_main_t *) print->custom;
+ controller_t * const main = (controller_t *) print->custom;
fll_error_print(print, F_status_set_fine(main->setting.state.status), function, fll_error_file_flag_fallback_e);
return F_okay;
}
-#endif // _di_controller_main_print_error_
+#endif // _di_controller_print_error_
-#ifndef _di_controller_main_print_error_failsafe_item_
- f_status_t controller_main_print_error_failsafe_item(fl_print_t * const print, controller_thread_t * const thread, f_string_dynamic_t * const name) {
+#ifndef _di_controller_print_error_failsafe_item_
+ f_status_t controller_print_error_failsafe_item(fl_print_t * const print, controller_thread_t * const thread, f_string_dynamic_t * const name) {
if (!print) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
return F_okay;
}
-#endif // _di_controller_main_print_error_failsafe_item_
+#endif // _di_controller_print_error_failsafe_item_
-#ifndef _di_controller_main_print_error_file_
- f_status_t controller_main_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) {
+#ifndef _di_controller_print_error_file_
+ f_status_t controller_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) {
if (!print || !print->custom) return F_status_set_error(F_output_not);
if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not;
- controller_main_t * const main = (controller_main_t *) print->custom;
+ controller_t * const main = (controller_t *) print->custom;
fll_error_file_print(print, F_status_set_fine(main->setting.state.status), function, fll_error_file_flag_fallback_e, name, operation, type);
return F_okay;
}
-#endif // _di_controller_main_print_error_file_
+#endif // _di_controller_print_error_file_
-#ifndef _di_controller_main_print_error_file_status_
- f_status_t controller_main_print_error_file_status(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type, const f_status_t status) {
+#ifndef _di_controller_print_error_file_status_
+ f_status_t controller_print_error_file_status(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type, const f_status_t status) {
if (!print) return F_status_set_error(F_output_not);
if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not;
return F_okay;
}
-#endif // _di_controller_main_print_error_file_status_
+#endif // _di_controller_print_error_file_status_
-#ifndef _di_controller_main_print_error_file_pid_exists_
- f_status_t controller_main_print_error_file_pid_exists(fl_print_t * const print, controller_thread_t * const thread, const f_string_dynamic_t path) {
+#ifndef _di_controller_print_error_file_pid_exists_
+ f_status_t controller_print_error_file_pid_exists(fl_print_t * const print, controller_thread_t * const thread, const f_string_dynamic_t path) {
if (!print) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
return F_okay;
}
-#endif // _di_controller_main_print_error_file_pid_exists_
+#endif // _di_controller_print_error_file_pid_exists_
-#ifndef _di_controller_main_print_error_status_
- f_status_t controller_main_print_error_status(fl_print_t * const print, const f_string_t function, const f_status_t status) {
+#ifndef _di_controller_print_error_status_
+ f_status_t controller_print_error_status(fl_print_t * const print, const f_string_t function, const f_status_t status) {
if (!print) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
return F_okay;
}
-#endif // _di_controller_main_print_error_status_
+#endif // _di_controller_print_error_status_
#ifdef __cplusplus
} // extern "C"
*
* @see fll_error_print()
*/
-#ifndef _di_controller_main_print_error_
- extern f_status_t controller_main_print_error(fl_print_t * const print, const f_string_t function);
-#endif // _di_controller_main_print_error_
+#ifndef _di_controller_print_error_
+ extern f_status_t controller_print_error(fl_print_t * const print, const f_string_t function);
+#endif // _di_controller_print_error_
/**
* Print error message regarding the failsafe item failing.
*
* @see fll_error_print()
*/
-#ifndef _di_controller_main_print_error_failsafe_item_
- extern f_status_t controller_main_print_error_failsafe_item(fl_print_t * const print, controller_thread_t * const thread, f_string_dynamic_t * const name);
-#endif // _di_controller_main_print_error_failsafe_item_
+#ifndef _di_controller_print_error_failsafe_item_
+ extern f_status_t controller_print_error_failsafe_item(fl_print_t * const print, controller_thread_t * const thread, f_string_dynamic_t * const name);
+#endif // _di_controller_print_error_failsafe_item_
/**
* Print file related error or warning messages.
*
* @see fll_error_file_print()
*/
-#ifndef _di_controller_main_print_error_file_
- extern f_status_t controller_main_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type);
-#endif // _di_controller_main_print_error_file_
+#ifndef _di_controller_print_error_file_
+ extern f_status_t controller_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type);
+#endif // _di_controller_print_error_file_
/**
* Print file related error or warning messages.
*
* @see fll_error_file_print()
*/
-#ifndef _di_controller_main_print_error_file_status_
- extern f_status_t controller_main_print_error_file_status(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type, const f_status_t status);
-#endif // _di_controller_main_print_error_file_status_
+#ifndef _di_controller_print_error_file_status_
+ extern f_status_t controller_print_error_file_status(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type, const f_status_t status);
+#endif // _di_controller_print_error_file_status_
/**
* Print generic error message regarding a function failing in some way.
*
* @see fll_error_print()
*/
-#ifndef _di_controller_main_print_error_status_
- 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_
+#ifndef _di_controller_print_error_status_
+ extern f_status_t controller_print_error_status(fl_print_t * const print, const f_string_t function, const f_status_t status);
+#endif // _di_controller_print_error_status_
/**
* Print error message regarding the pid file already existing.
*
* @see fll_error_print()
*/
-#ifndef _di_controller_main_print_error_file_pid_exists_
- extern f_status_t controller_main_print_error_file_pid_exists(fl_print_t * const print, controller_thread_t * const thread, const f_string_dynamic_t path);
-#endif // _di_controller_main_print_error_file_pid_exists_
+#ifndef _di_controller_print_error_file_pid_exists_
+ extern f_status_t controller_print_error_file_pid_exists(fl_print_t * const print, controller_thread_t * const thread, const f_string_dynamic_t path);
+#endif // _di_controller_print_error_file_pid_exists_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_print_message_help_
- f_status_t controller_main_print_message_help(fl_print_t * const print, const uint8_t uninterrupt) {
+#ifndef _di_controller_print_message_help_
+ f_status_t controller_print_message_help(fl_print_t * const print, const uint8_t uninterrupt) {
if (!print || !print->custom) return F_status_set_error(F_output_not);
- controller_main_t * const main = (controller_main_t *) print->custom;
+ controller_t * const main = (controller_t *) print->custom;
f_file_stream_lock(print->to);
return F_okay;
}
-#endif // _di_controller_main_print_message_help_
+#endif // _di_controller_print_message_help_
#ifdef __cplusplus
} // extern "C"
* @param print
* The output structure to print to.
*
- * This requires print.custom to be controller_main_t.
+ * This requires print.custom to be controller_t.
*
* This does not alter print.custom.setting.state.status.
* @param uninterrupt
* @see fll_program_print_help_option()
* @see fll_program_print_help_usage()
*/
-#ifndef _di_controller_main_print_message_help_
- extern f_status_t controller_main_print_message_help(fl_print_t * const print, const uint8_t uninterrupt);
-#endif // _di_controller_main_print_message_help_
+#ifndef _di_controller_print_message_help_
+ extern f_status_t controller_print_message_help(fl_print_t * const print, const uint8_t uninterrupt);
+#endif // _di_controller_print_message_help_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_print_rule_error_
- f_status_t controller_main_print_rule_error(fl_print_t * const print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item) {
+#ifndef _di_controller_print_rule_error_
+ f_status_t controller_print_rule_error(fl_print_t * const print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item) {
if (!print || !print->custom) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
f_file_stream_lock(print->to);
- controller_main_print_rule_error_cache(print, cache, item);
+ controller_print_rule_error_cache(print, cache, item);
controller_unlock_print_flush(print->to, global->thread);
return F_okay;
}
-#endif // _di_controller_main_print_rule_error_
+#endif // _di_controller_print_rule_error_
-#ifndef _di_controller_main_print_rule_error_cache_
- f_status_t controller_main_print_rule_error_cache(fl_print_t * const print, const controller_cache_action_t cache, const bool item) {
+#ifndef _di_controller_print_rule_error_cache_
+ f_status_t controller_print_rule_error_cache(fl_print_t * const print, const controller_cache_action_t cache, const bool item) {
if (!print) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
return F_okay;
}
-#endif // _di_controller_main_print_rule_error_cache_
+#endif // _di_controller_print_rule_error_cache_
#ifdef __cplusplus
} // extern "C"
* If FALSE, then this error is associated with a rule setting.
*
* @see fll_error_print()
- * @see controller_main_print_rule_error_cache()
+ * @see controller_print_rule_error_cache()
*/
-#ifndef _di_controller_main_print_rule_error_
- extern void controller_main_print_rule_error(fl_print_t * const print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item);
-#endif // _di_controller_main_print_rule_error_
+#ifndef _di_controller_print_rule_error_
+ extern void controller_print_rule_error(fl_print_t * const print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item);
+#endif // _di_controller_print_rule_error_
/**
* Print additional error/warning information in addition to existing error.
* If TRUE, then this error is associated with an item.
* If FALSE, then this error is associated with a rule setting.
*
- * @see controller_main_rule_action_read()
- * @see controller_main_rule_item_read()
+ * @see controller_rule_action_read()
+ * @see controller_rule_item_read()
* @see controller_rule_items_read()
- * @see controller_main_rule_read()
- * @see controller_main_rule_setting_read()
+ * @see controller_rule_read()
+ * @see controller_rule_setting_read()
*/
-#ifndef _di_controller_main_print_rule_error_cache_
- extern void controller_main_print_rule_error_cache(fl_print_t * const print, const controller_cache_action_t cache, const bool item);
-#endif // _di_controller_main_print_rule_error_cache_
+#ifndef _di_controller_print_rule_error_cache_
+ extern void controller_print_rule_error_cache(fl_print_t * const print, const controller_cache_action_t cache, const bool item);
+#endif // _di_controller_print_rule_error_cache_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_print_rule_action_error_missing_pid_
- void controller_main_print_rule_action_error_missing_pid(fl_print_t * const print, const f_string_static_t alias) {
+#ifndef _di_controller_print_rule_action_error_missing_pid_
+ void controller_print_rule_action_error_missing_pid(fl_print_t * const print, const f_string_static_t alias) {
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, alias, print->notable);
fl_print_format("%[' is not designating a pid file.%]%r", print->to, print->context, print->context, f_string_eol_s);
}
-#endif // _di_controller_main_print_rule_action_error_missing_pid_
+#endif // _di_controller_print_rule_action_error_missing_pid_
#ifdef __cplusplus
} // extern "C"
* @param alias
* The rule alias of the rule that is missing the pid file designation.
*/
-#ifndef _di_controller_main_print_rule_action_error_missing_pid_
- extern void controller_main_print_rule_action_error_missing_pid(fl_print_t * const print, const f_string_static_t alias);
-#endif // _di_controller_main_print_rule_action_error_missing_pid_
+#ifndef _di_controller_print_rule_action_error_missing_pid_
+ extern void controller_print_rule_action_error_missing_pid(fl_print_t * const print, const f_string_static_t alias);
+#endif // _di_controller_print_rule_action_error_missing_pid_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_print_rule_item_debug_action_empty_
- f_status_t controller_main_print_rule_item_debug_action_empty(fl_print_t * const print, controller_cache_t * const cache) {
+#ifndef _di_controller_print_rule_item_debug_action_empty_
+ f_status_t controller_print_rule_item_debug_action_empty(fl_print_t * const print, controller_cache_t * const cache) {
if (!print || !print->custom || !cache) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_debug_e) return F_output_not;
fl_print_format("%r%[%QAction is empty, nothing to do.%]%r", primt->to, f_string_eol_s, print->context, print->prefix, print->context, f_string_eol_s);
- controller_main_print_rule_error_cache(print, cache->action, F_true);
+ controller_print_rule_error_cache(print, cache->action, F_true);
controller_unlock_print_flush(print->to, global->thread);
return F_okay;
}
-#endif // _di_controller_main_print_rule_item_debug_action_empty_
+#endif // _di_controller_print_rule_item_debug_action_empty_
-#ifndef _di_controller_main_print_rule_item_error_
- void controller_main_print_rule_item_error(fl_print_t * const print, const controller_cache_action_t cache, const bool item, const f_status_t status) {
+#ifndef _di_controller_print_rule_item_error_
+ void controller_print_rule_item_error(fl_print_t * const print, const controller_cache_action_t cache, const bool item, const f_status_t status) {
if (!print || !print->custom) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
// fll_error_print() automatically locks, so manually handle only the mutex locking and flushing rather than calling controller_lock_print().
f_thread_mutex_lock(&global->thread->lock.print);
- controller_main_print_rule_error_cache(print, cache, item);
+ controller_print_rule_error_cache(print, cache, item);
f_file_stream_lock(print->to);
controller_unlock_print_flush(print->to, global->thread);
}
-#endif // _di_controller_main_print_rule_item_error_
+#endif // _di_controller_print_rule_item_error_
-#ifndef _di_controller_main_print_rule_item_error_action_first_
- f_status_t controller_main_print_rule_item_error_action_first(fl_print_t * const print, controller_cache_t * const cache) {
+#ifndef _di_controller_print_rule_item_error_action_first_
+ f_status_t controller_print_rule_item_error_action_first(fl_print_t * const print, controller_cache_t * const cache) {
if (!print || !print->custom || !cache) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, controller_thaw_s, print->notable, print->context);
fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s);
- controller_main_print_rule_error_cache(print, cache->action, F_true);
+ controller_print_rule_error_cache(print, cache->action, F_true);
controller_unlock_print_flush(print->to, global->thread);
return F_okay;
}
-#endif // _di_controller_main_print_rule_item_error_action_first_
+#endif // _di_controller_print_rule_item_error_action_first_
-#ifndef _di_controller_main_print_rule_item_error_action_second_
- f_status_t controller_main_print_rule_item_error_action_second(fl_print_t * const print, controller_cache_t * const cache) {
+#ifndef _di_controller_print_rule_item_error_action_second_
+ f_status_t controller_print_rule_item_error_action_second(fl_print_t * const print, controller_cache_t * const cache) {
if (!print || !print->custom || !cache) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, controller_thaw_s, print->notable, print->context);
fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s);
- controller_main_print_rule_error_cache(print, cache->action, F_true);
+ controller_print_rule_error_cache(print, cache->action, F_true);
controller_unlock_print_flush(print->to, global->thread);
return F_okay;
}
-#endif // _di_controller_main_print_rule_item_error_action_second_
+#endif // _di_controller_print_rule_item_error_action_second_
-#ifndef _di_controller_main_print_rule_item_error_action_unknown_
- f_status_t controller_main_print_rule_item_error_action_unknown(fl_print_t * const print, controller_cache_t * const cache, const f_string_static_t name, const f_number_unsigned_t index) {
+#ifndef _di_controller_print_rule_item_error_action_unknown_
+ f_status_t controller_print_rule_item_error_action_unknown(fl_print_t * const print, controller_cache_t * const cache, const f_string_static_t name, const f_number_unsigned_t index) {
if (!print || !print->custom || !cache) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, cache->buffer_item, cache->content_action.array[index], print->notable);
fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s);
- controller_main_print_rule_error_cache(print, cache->action, F_true);
+ controller_print_rule_error_cache(print, cache->action, F_true);
controller_unlock_print_flush(print->to, global->thread);
return F_okay;
}
-#endif // _di_controller_main_print_rule_item_error_action_unknown_
+#endif // _di_controller_print_rule_item_error_action_unknown_
-#ifndef _di_controller_main_print_rule_item_error_execute_
- void controller_main_print_rule_item_error_execute(fl_print_t * const print, controller_instance_t * const instance, const bool script_is, const f_string_static_t name, const f_status_t status) {
+#ifndef _di_controller_print_rule_item_error_execute_
+ void controller_print_rule_item_error_execute(fl_print_t * const print, controller_instance_t * const instance, const bool script_is, const f_string_static_t name, const f_status_t status) {
if (!print || !print->custom) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
controller_unlock_print_flush(print->to, global->thread);
}
-#endif // _di_controller_main_print_rule_item_error_execute_
+#endif // _di_controller_print_rule_item_error_execute_
-#ifndef _di_controller_main_print_rule_item_error_need_want_wish_
- void controller_main_print_rule_item_error_need_want_wish(fl_print_t * const print, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why) {
+#ifndef _di_controller_print_rule_item_error_need_want_wish_
+ void controller_print_rule_item_error_need_want_wish(fl_print_t * const print, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why) {
if (print->verbosity == f_console_verbosity_quiet_e) return;
fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, value, print->notable);
fl_print_format("%[' %S.%]%r", print->to, print->context, why, print->context, f_string_eol_s);
}
-#endif // _di_controller_main_print_rule_item_error_need_want_wish_
+#endif // _di_controller_print_rule_item_error_need_want_wish_
-#ifndef _di_controller_main_print_rule_item_error_rule_not_loaded_
- void controller_main_print_rule_item_error_rule_not_loaded(fl_print_t * const print, const f_string_static_t alias) {
+#ifndef _di_controller_print_rule_item_error_rule_not_loaded_
+ void controller_print_rule_item_error_rule_not_loaded(fl_print_t * const print, const f_string_static_t alias) {
if (print->verbosity == f_console_verbosity_quiet_e) return;
fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, alias, print->notable);
fl_print_format("%[' is no longer loaded.%]%r", print->to, print->context, print->context, f_string_eol_s);
}
-#endif // _di_controller_main_print_rule_item_error_rule_not_loaded_
+#endif // _di_controller_print_rule_item_error_rule_not_loaded_
#ifdef __cplusplus
} // extern "C"
* @see fll_error_print()
*
* @see controller_lock_print()
- * @see controller_main_print_rule_error_cache()
+ * @see controller_print_rule_error_cache()
* @see controller_unlock_print_flush()
*/
-#ifndef _di_controller_main_print_rule_item_debug_action_empty_
- extern f_status_t controller_main_print_rule_item_debug_action_empty(fl_print_t * const print, controller_cache_t * const cache);
-#endif // _di_controller_main_print_rule_item_debug_action_empty_
+#ifndef _di_controller_print_rule_item_debug_action_empty_
+ extern f_status_t controller_print_rule_item_debug_action_empty(fl_print_t * const print, controller_cache_t * const cache);
+#endif // _di_controller_print_rule_item_debug_action_empty_
/**
* Print additional error/warning information in addition to existing error.
* @param status
* The status code representing the failure (without the error bit set).
*
- * @see controller_main_print_rule_error_cache()
+ * @see controller_print_rule_error_cache()
*/
-#ifndef _di_controller_main_print_rule_item_error_
- extern void controller_main_print_rule_item_error(fl_print_t * const print, const controller_cache_action_t cache, const bool item, const f_status_t status);
-#endif // _di_controller_main_print_rule_item_error_
+#ifndef _di_controller_print_rule_item_error_
+ extern void controller_print_rule_item_error(fl_print_t * const print, const controller_cache_action_t cache, const bool item, const f_status_t status);
+#endif // _di_controller_print_rule_item_error_
/**
* Print rule error message about the first rule item action parameter being invalid.
* @see fll_error_print()
*
* @see controller_lock_print()
- * @see controller_main_print_rule_error_cache()
+ * @see controller_print_rule_error_cache()
* @see controller_unlock_print_flush()
*/
-#ifndef _di_controller_main_print_rule_item_error_action_first_
- extern f_status_t controller_main_print_rule_item_error_action_first(fl_print_t * const print, controller_cache_t * const cache);
-#endif // _di_controller_main_print_rule_item_error_action_first_
+#ifndef _di_controller_print_rule_item_error_action_first_
+ extern f_status_t controller_print_rule_item_error_action_first(fl_print_t * const print, controller_cache_t * const cache);
+#endif // _di_controller_print_rule_item_error_action_first_
/**
* Print rule error message about the second rule item action parameter being invalid.
* @see fll_error_print()
*
* @see controller_lock_print()
- * @see controller_main_print_rule_error_cache()
+ * @see controller_print_rule_error_cache()
* @see controller_unlock_print_flush()
*/
-#ifndef _di_controller_main_print_rule_item_error_action_second_
- extern f_status_t controller_main_print_rule_item_error_action_second(fl_print_t * const print, controller_cache_t * const cache);
-#endif // _di_controller_main_print_rule_item_error_action_second_
+#ifndef _di_controller_print_rule_item_error_action_second_
+ extern f_status_t controller_print_rule_item_error_action_second(fl_print_t * const print, controller_cache_t * const cache);
+#endif // _di_controller_print_rule_item_error_action_second_
/**
* Print rule error message about the rule item action being unknown.
* @see fll_error_print()
*
* @see controller_lock_print()
- * @see controller_main_print_rule_error_cache()
+ * @see controller_print_rule_error_cache()
* @see controller_unlock_print_flush()
*/
-#ifndef _di_controller_main_print_rule_item_error_action_unknown_
- extern f_status_t controller_main_print_rule_item_error_action_unknown(fl_print_t * const print, controller_cache_t * const cache, const f_string_static_t name, const f_number_unsigned_t index);
-#endif // _di_controller_main_print_rule_item_error_action_unknown_
+#ifndef _di_controller_print_rule_item_error_action_unknown_
+ extern f_status_t controller_print_rule_item_error_action_unknown(fl_print_t * const print, controller_cache_t * const cache, const f_string_static_t name, const f_number_unsigned_t index);
+#endif // _di_controller_print_rule_item_error_action_unknown_
/**
* Print an error or warning message related to the failed execution of some program or script.
* @param status
* The status code representing the failure (without the error bit set).
*/
-#ifndef _di_controller_main_print_rule_item_error_execute_
- extern void controller_main_print_rule_item_error_execute(fl_print_t * const print, controller_instance_t * const instance, const bool script_is, const f_string_static_t name, const f_status_t status);
-#endif // _di_controller_main_print_rule_item_error_execute_
+#ifndef _di_controller_print_rule_item_error_execute_
+ extern void controller_print_rule_item_error_execute(fl_print_t * const print, controller_instance_t * const instance, const bool script_is, const f_string_static_t name, const f_status_t status);
+#endif // _di_controller_print_rule_item_error_execute_
/**
* Print an error or warning message related to need/want/wish settings of some rule.
* @param why
* A short explanation on why this is an error or warning.
*/
-#ifndef _di_controller_main_print_rule_item_error_need_want_wish_
- extern void controller_main_print_rule_item_error_need_want_wish(fl_print_t * const print, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why);
-#endif // _di_controller_main_print_rule_item_error_need_want_wish_
+#ifndef _di_controller_print_rule_item_error_need_want_wish_
+ extern void controller_print_rule_item_error_need_want_wish(fl_print_t * const print, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why);
+#endif // _di_controller_print_rule_item_error_need_want_wish_
/**
* Print an error or warning message about some rule not being loaded.
* @param alias
* The rule alias of the rule that is not loaded.
*/
-#ifndef _di_controller_main_print_rule_item_error_rule_not_loaded_
- extern void controller_main_print_rule_item_error_rule_not_loaded(fl_print_t * const print, const f_string_static_t alias);
-#endif // _di_controller_main_print_rule_item_error_rule_not_loaded_
+#ifndef _di_controller_print_rule_item_error_rule_not_loaded_
+ extern void controller_print_rule_item_error_rule_not_loaded(fl_print_t * const print, const f_string_static_t alias);
+#endif // _di_controller_print_rule_item_error_rule_not_loaded_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_print_rule_setting_read_error_
- void controller_main_print_rule_setting_read_error(fl_print_t * const print, const f_string_t message, const f_number_unsigned_t index, const f_number_unsigned_t line_item, controller_thread_t * const thread, controller_cache_t * const cache) {
+#ifndef _di_controller_print_rule_setting_read_error_
+ void controller_print_rule_setting_read_error(fl_print_t * const print, const f_string_t message, const f_number_unsigned_t index, const f_number_unsigned_t line_item, controller_thread_t * const thread, controller_cache_t * const cache) {
if (!print->custom) return;
if (print->verbosity == f_console_verbosity_quiet_e) return;
- controller_main_t * const main = (controller_main_t *) print->custom;
+ controller_t * const main = (controller_t *) print->custom;
f_state_t state = f_state_t_initialize;
fl_print_format("%r%[%QRule setting %S.%]%r", print->to, f_string_eol_s, print->context, print->prefix, message, print->context, f_string_eol_s);
- controller_main_print_rule_error_cache(print, cache->action, F_false);
+ controller_print_rule_error_cache(print, cache->action, F_false);
controller_unlock_print_flush(print->to, thread);
}
-#endif // _di_controller_main_print_rule_setting_read_error_
+#endif // _di_controller_print_rule_setting_read_error_
-#ifndef _di_controller_main_print_rule_setting_read_error_with_range_
- void controller_main_print_rule_setting_read_error_with_range(fl_print_t * const print, const f_string_t before, const f_range_t range, const f_string_t after, const f_number_unsigned_t index, const f_number_unsigned_t line_item, controller_thread_t * const thread, controller_cache_t * const cache) {
+#ifndef _di_controller_print_rule_setting_read_error_with_range_
+ void controller_print_rule_setting_read_error_with_range(fl_print_t * const print, const f_string_t before, const f_range_t range, const f_string_t after, const f_number_unsigned_t index, const f_number_unsigned_t line_item, controller_thread_t * const thread, controller_cache_t * const cache) {
if (!print->custom) return;
if (print->verbosity == f_console_verbosity_quiet_e) return;
- controller_main_t * const main = (controller_main_t *) print->custom;
+ controller_t * const main = (controller_t *) print->custom;
f_state_t state = f_state_t_initialize;
fl_print_format(f_string_format_Q_range_single_s.string, print->to, print->notable, cache->buffer_item, range, print->notable);
fl_print_format("%['%S.%]%r", print->to, print->context, after, print->context, f_string_eol_s);
- controller_main_print_rule_error_cache(print, cache->action, F_false);
+ controller_print_rule_error_cache(print, cache->action, F_false);
controller_unlock_print_flush(print->to, thread);
}
-#endif // _di_controller_main_print_rule_setting_read_error_with_range_
+#endif // _di_controller_print_rule_setting_read_error_with_range_
-#ifndef _di_controller_main_print_rule_setting_read_mapping_
- void controller_main_print_rule_setting_read_mapping(const controller_global_t global, const f_string_static_t name, const f_string_map_t map) {
+#ifndef _di_controller_print_rule_setting_read_mapping_
+ void controller_print_rule_setting_read_mapping(const controller_global_t global, const f_string_static_t name, const f_string_map_t map) {
if (global.main->program.error.verbosity != f_console_verbosity_debug_e) {
if (!(global.main->program.error.verbosity == f_console_verbosity_verbose_e && (global.main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
controller_unlock_print_flush(global.main->program.output.to, global.thread);
}
-#endif // _di_controller_main_print_rule_setting_read_mapping_
+#endif // _di_controller_print_rule_setting_read_mapping_
-#ifndef _di_controller_main_print_rule_setting_read_value_
- void controller_main_print_rule_setting_read_value(const controller_global_t global, const f_string_static_t name, const f_string_static_t name_sub, const f_string_static_t value, const f_string_t suffix) {
+#ifndef _di_controller_print_rule_setting_read_value_
+ void controller_print_rule_setting_read_value(const controller_global_t global, const f_string_static_t name, const f_string_static_t name_sub, const f_string_static_t value, const f_string_t suffix) {
if (global.main->program.error.verbosity != f_console_verbosity_debug_e) {
if (!(global.main->program.error.verbosity == f_console_verbosity_verbose_e && (global.main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
controller_unlock_print_flush(global.main->program.output.to, global.thread);
}
-#endif // _di_controller_main_print_rule_setting_read_value_
+#endif // _di_controller_print_rule_setting_read_value_
-#ifndef _di_controller_main_print_rule_setting_read_values_
- void controller_main_print_rule_setting_read_values(const controller_global_t global, const f_string_static_t name, const f_number_unsigned_t index, controller_cache_t * const cache) {
+#ifndef _di_controller_print_rule_setting_read_values_
+ void controller_print_rule_setting_read_values(const controller_global_t global, const f_string_static_t name, const f_number_unsigned_t index, controller_cache_t * const cache) {
if (global.main->program.error.verbosity != f_console_verbosity_debug_e) {
if (!(global.main->program.error.verbosity == f_console_verbosity_verbose_e && (global.main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
controller_unlock_print_flush(global.main->program.output.to, global.thread);
}
-#endif // _di_controller_main_print_rule_setting_read_value_
+#endif // _di_controller_print_rule_setting_read_value_
#ifdef __cplusplus
} // extern "C"
/**
* Print a message about a rule setting problem.
*
- * This is intended to be explicitly called by controller_main_rule_setting_read().
+ * This is intended to be explicitly called by controller_rule_setting_read().
* This is intended only to be used for simple messages.
*
* @param print
* @param cache
* A structure for containing and caching relevant data.
*
- * @see controller_main_rule_setting_read()
+ * @see controller_rule_setting_read()
*/
-#ifndef _di_controller_main_print_rule_setting_read_error_
- extern void controller_main_print_rule_setting_read_error(fl_print_t * const print, const f_string_t message, const f_number_unsigned_t index, const f_number_unsigned_t line_item, controller_thread_t * const thread, controller_cache_t * const cache);
-#endif // _di_controller_main_print_rule_setting_read_error_
+#ifndef _di_controller_print_rule_setting_read_error_
+ extern void controller_print_rule_setting_read_error(fl_print_t * const print, const f_string_t message, const f_number_unsigned_t index, const f_number_unsigned_t line_item, controller_thread_t * const thread, controller_cache_t * const cache);
+#endif // _di_controller_print_rule_setting_read_error_
/**
* Print a message about a rule setting problem, with additional messages about the value.
*
- * This is intended to be explicitly called by controller_main_rule_setting_read().
+ * This is intended to be explicitly called by controller_rule_setting_read().
* This is intended only to be used for simple messages.
*
* @param print
* @param cache
* A structure for containing and caching relevant data.
*
- * @see controller_main_rule_setting_read()
+ * @see controller_rule_setting_read()
*/
-#ifndef _di_controller_main_print_rule_setting_read_error_with_range_
- extern void controller_main_print_rule_setting_read_error_with_range(fl_print_t * const print, const f_string_t before, const f_range_t range, const f_string_t after, const f_number_unsigned_t index, const f_number_unsigned_t line_item, controller_thread_t * const thread, controller_cache_t * const cache);
-#endif // _di_controller_main_print_rule_setting_read_error_with_range_
+#ifndef _di_controller_print_rule_setting_read_error_with_range_
+ extern void controller_print_rule_setting_read_error_with_range(fl_print_t * const print, const f_string_t before, const f_range_t range, const f_string_t after, const f_number_unsigned_t index, const f_number_unsigned_t line_item, controller_thread_t * const thread, controller_cache_t * const cache);
+#endif // _di_controller_print_rule_setting_read_error_with_range_
/**
* Print message regarding the mapping of a setting when in simulation or verbose mode.
* @param map
* The map being applied.
*/
-#ifndef _di_controller_main_print_rule_setting_read_mapping_
- extern void controller_main_print_rule_setting_read_mapping(const controller_global_t global, const f_string_static_t name, const f_string_map_t map);
-#endif // _di_controller_main_print_rule_setting_read_mapping_
+#ifndef _di_controller_print_rule_setting_read_mapping_
+ extern void controller_print_rule_setting_read_mapping(const controller_global_t global, const f_string_static_t name, const f_string_map_t map);
+#endif // _di_controller_print_rule_setting_read_mapping_
/**
* Print message regarding the population of a setting when in simulation or verbose mode.
* @param suffix
* An additional message to append at the end (before the final period).
*/
-#ifndef _di_controller_main_print_rule_setting_read_value_
- extern void controller_main_print_rule_setting_read_value(const controller_global_t global, const f_string_static_t name, const f_string_static_t name_sub, const f_string_static_t value, const f_string_t suffix);
-#endif // _di_controller_main_print_rule_setting_read_value_
+#ifndef _di_controller_print_rule_setting_read_value_
+ extern void controller_print_rule_setting_read_value(const controller_global_t global, const f_string_static_t name, const f_string_static_t name_sub, const f_string_static_t value, const f_string_t suffix);
+#endif // _di_controller_print_rule_setting_read_value_
/**
* Print message regarding the population of a setting when in simulation or verbose mode.
* @param cache
* A structure for containing and caching relevant data.
*/
-#ifndef _di_controller_main_print_rule_setting_read_values_
- extern void controller_main_print_rule_setting_read_values(const controller_global_t global, const f_string_static_t name, const f_number_unsigned_t index, controller_cache_t * const cache);
-#endif // _di_controller_main_print_rule_setting_read_values_
+#ifndef _di_controller_print_rule_setting_read_values_
+ extern void controller_print_rule_setting_read_values(const controller_global_t global, const f_string_static_t name, const f_number_unsigned_t index, controller_cache_t * const cache);
+#endif // _di_controller_print_rule_setting_read_values_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_process_
- void controller_main_process(controller_main_t * const main, controller_program_t * const program) {
+#ifndef _di_controller_process_
+ void controller_process(controller_t * const main, controller_program_t * const program) {
if (!main || !program || F_status_is_error(main->setting.state.status)) return;
if (main->setting.flag & controller_main_flag_version_copyright_help_e) {
if (main->setting.flag & controller_main_flag_help_e) {
- controller_main_print_message_help(&main->program.message, F_false);
+ controller_print_message_help(&main->program.message, F_false);
}
else if (main->setting.flag & controller_main_flag_version_e) {
fll_program_print_version(&main->program.message, controller_program_version_s);
message.custom = output.custom = error.custom = warning.custom = debug.custom = (void *) &global;
// The global locks must be initialized, but only once, so initialize immediately upon allocation.
- f_status_t status = controller_main_lock_create(&thread.lock);
+ f_status_t status = controller_lock_create(&thread.lock);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&main->program.error, macro_controller_f(controller_main_lock_create), status);
+ controller_print_error_status(&main->program.error, macro_controller_f(controller_lock_create), status);
} else {
status = f_memory_array_increase(controller_allocation_small_d, sizeof(controller_instance_t), (void **) &thread.instances.array, &thread.instances.used, &thread.instances.size);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&main->program.error, macro_controller_f(f_memory_array_increase), status);
+ controller_print_error_status(&main->program.error, macro_controller_f(f_memory_array_increase), status);
}
}
if (F_status_is_error_not(status)) {
- status = f_thread_create(0, &thread.id_signal, &controller_main_thread_signal_normal, (void *) &global);
+ status = f_thread_create(0, &thread.id_signal, &controller_thread_signal_normal, (void *) &global);
}
if (F_status_is_error(status)) {
thread.id_signal = 0;
- controller_main_print_error_status(&main->program.error, macro_controller_f(f_thread_create), status);
+ controller_print_error_status(&main->program.error, macro_controller_f(f_thread_create), status);
}
else {
if (main->setting.flag & controller_main_flag_daemon_e) {
status = F_status_set_error(F_available_not);
program->ready = controller_program_ready_abort_e;
- controller_main_print_error_file_pid_exists(&main->program.error, &thread, program->path_pid);
+ controller_print_error_file_pid_exists(&main->program.error, &thread, program->path_pid);
}
}
else if (program->name_entry.used) {
- status = f_thread_create(0, &thread.id_entry, &controller_main_thread_entry, (void *) &global);
+ status = f_thread_create(0, &thread.id_entry, &controller_thread_entry, (void *) &global);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&main->program.error, macro_controller_f(f_thread_create), status);
+ controller_print_error_status(&main->program.error, macro_controller_f(f_thread_create), status);
}
else {
- controller_main_thread_join(&thread.id_entry);
+ controller_thread_join(&thread.id_entry);
status = thread.status;
thread.id_entry = 0;
if (!(main->setting.flag & controller_main_flag_validate_e)) {
// Wait for the entry thread to complete before starting the rule thread.
- controller_main_thread_join(&thread.id_rule);
+ controller_thread_join(&thread.id_rule);
if (thread.enabled && program->mode == controller_program_mode_service_e) {
- status = f_thread_create(0, &thread.id_rule, &controller_main_thread_rule, (void *) &global);
+ status = f_thread_create(0, &thread.id_rule, &controller_thread_rule, (void *) &global);
if (F_status_is_error(status)) {
thread.id_rule = 0;
}
else {
- status = f_thread_create(0, &thread.id_cleanup, &controller_main_thread_cleanup, (void *) &global);
+ status = f_thread_create(0, &thread.id_cleanup, &controller_thread_cleanup, (void *) &global);
}
if (F_status_is_error(status)) {
thread.id_cleanup = 0;
- controller_main_print_error_status(&main->program.error, macro_controller_f(f_thread_create), status);
+ controller_print_error_status(&main->program.error, macro_controller_f(f_thread_create), status);
}
}
}
return;
}
- if (F_status_is_error_not(status) && status != F_failure && !(main->setting.flag & controller_main_flag_validate_e) && controller_main_thread_is_enabled(F_true, &thread)) {
+ if (F_status_is_error_not(status) && status != F_failure && !(main->setting.flag & controller_main_flag_validate_e) && controller_thread_is_enabled(F_true, &thread)) {
if (program->mode == controller_program_mode_service_e) {
- controller_main_thread_join(&thread.id_signal);
+ controller_thread_join(&thread.id_signal);
}
else if (program->mode == controller_program_mode_helper_e || program->mode == controller_program_mode_program_e) {
- status = controller_main_rule_wait_all(global, F_true, F_false);
+ status = controller_rule_wait_all(&global, F_true, F_false);
}
}
- controller_main_thread_instance_cancel(global, F_true, controller_thread_cancel_call_e);
+ controller_thread_instance_cancel(&global, F_true, controller_thread_cancel_call_e);
- controller_main_thread_instance_exit(&global);
+ controller_thread_instance_exit(&global);
if (thread.id_signal) f_thread_join(thread.id_signal, 0);
if (thread.id_cleanup) f_thread_join(thread.id_cleanup, 0);
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
- return F_status_set_error(F_interrupt);
+ main->setting.state.status = F_status_set_error(F_interrupt);
+ }
+ else {
+ main->setting.state.status = F_status_is_error(status) ? F_status_set_error(F_failure) : F_okay;
}
-
- return F_status_is_error(status) ? F_status_set_error(F_failure) : F_okay;
}
-#endif // _di_controller_main_process_
+#endif // _di_controller_process_
#ifdef __cplusplus
} // extern "C"
*
* This is auto-included and should not need to be explicitly included.
*/
-#ifndef _controller_main_process_h
-#define _controller_main_process_h
+#ifndef _controller_process_h
+#define _controller_process_h
#ifdef __cplusplus
extern "C" {
*
* Must not be NULL.
*/
-#ifndef controller_main_process
- extern void controller_main_process(controller_main_t * const main, controller_program_t * const program);
-#endif // controller_main_process
+#ifndef controller_process
+ extern void controller_process(controller_t * const main, controller_program_t * const program);
+#endif // controller_process
#ifdef __cplusplus
} // extern "C"
#endif
-#endif // _controller_main_process_h
+#endif // _controller_process_h
f_number_unsigned_t i = 0;
- for (; i < controller_main_rule_action_type__enum_size_e; ++i) {
+ for (; i < controller_rule_action_type__enum_size_e; ++i) {
destination->status[i] = source.status[i];
} // for
controller_rule_item_t *item_source = 0;
controller_rule_item_t *item_destination = 0;
- controller_main_rule_action_t *action_source = 0;
- controller_main_rule_action_t *action_destination = 0;
+ controller_rule_action_t *action_source = 0;
+ controller_rule_action_t *action_destination = 0;
if (source.items.used > destination->items.size) {
status = f_memory_arrays_resize(source.items.used, sizeof(controller_rule_item_t), (void **) &destination->items.array, &destination->items.used, &destination->items.size, &controller_rule_items_delete_callback);
item_destination = &destination->items.array[i];
if (item_source->actions.used > item_destination->actions.size) {
- status = f_memory_arrays_resize(item_source->actions.used, sizeof(controller_main_rule_action_t), (void **) &item_destination->actions.array, &item_destination->actions.used, &item_destination->actions.size, &controller_main_rule_actions_delete_callback);
+ status = f_memory_arrays_resize(item_source->actions.used, sizeof(controller_rule_action_t), (void **) &item_destination->actions.array, &item_destination->actions.used, &item_destination->actions.size, &controller_rule_actions_delete_callback);
if (F_status_is_error(status)) return status;
}
status = f_string_dynamic_append(item_source->pid_file, &item_destination->pid_file);
if (F_status_is_error(status)) return status;
- for (j = 0; j < controller_main_rule_action_execute_type__enum_size_e; ++j) {
+ for (j = 0; j < controller_rule_action_execute_type__enum_size_e; ++j) {
item_destination->reruns[j].is = item_source->reruns[j].is;
item_destination->reruns[j].failure.count = item_source->reruns[j].failure.count;
f_status_t status = f_string_dynamic_partial_append_nulless(source, directory, alias);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_partial_append_nulless), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_partial_append_nulless), F_status_set_fine(status));
return status;
}
status = f_string_dynamic_append(f_path_separator_s, alias);
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));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status));
return status;
}
status = f_string_dynamic_partial_append_nulless(source, basename, alias);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_partial_append_nulless), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_partial_append_nulless), F_status_set_fine(status));
return status;
}
extern "C" {
#endif
-#ifndef _di_controller_main_rule_action_method_name_
- f_string_static_t controller_main_rule_action_method_name(const uint8_t type) {
+#ifndef _di_controller_rule_action_method_name_
+ f_string_static_t controller_rule_action_method_name(const uint8_t type) {
- if (type == controller_main_rule_action_method_extended_e) return controller_main_rule_action_method_extended_s;
- if (type == controller_main_rule_action_method_extended_list_e) return controller_main_rule_action_method_extended_list_s;
+ if (type == controller_rule_action_method_extended_e) return controller_rule_action_method_extended_s;
+ if (type == controller_rule_action_method_extended_list_e) return controller_rule_action_method_extended_list_s;
return f_string_empty_s;
}
-#endif // _di_controller_main_rule_action_method_name_
-
-#ifndef _di_controller_main_rule_action_type_to_action_execute_type_
- uint8_t controller_main_rule_action_type_to_action_execute_type(const uint8_t type) {
-
- if (type == controller_main_rule_action_type_freeze_e) return controller_main_rule_action_execute_type_freeze_e;
- if (type == controller_main_rule_action_type_kill_e) return controller_main_rule_action_execute_type_kill_e;
- if (type == controller_main_rule_action_type_pause_e) return controller_main_rule_action_execute_type_pause_e;
- if (type == controller_main_rule_action_type_reload_e) return controller_main_rule_action_execute_type_reload_e;
- if (type == controller_main_rule_action_type_restart_e) return controller_main_rule_action_execute_type_restart_e;
- if (type == controller_main_rule_action_type_resume_e) return controller_main_rule_action_execute_type_resume_e;
- if (type == controller_main_rule_action_type_start_e) return controller_main_rule_action_execute_type_start_e;
- if (type == controller_main_rule_action_type_stop_e) return controller_main_rule_action_execute_type_stop_e;
- if (type == controller_main_rule_action_type_thaw_e) return controller_main_rule_action_execute_type_thaw_e;
-
- return controller_main_rule_action_execute_type__enum_size_e;
+#endif // _di_controller_rule_action_method_name_
+
+#ifndef _di_controller_rule_action_type_to_action_execute_type_
+ uint8_t controller_rule_action_type_to_action_execute_type(const uint8_t type) {
+
+ if (type == controller_rule_action_type_freeze_e) return controller_rule_action_execute_type_freeze_e;
+ if (type == controller_rule_action_type_kill_e) return controller_rule_action_execute_type_kill_e;
+ if (type == controller_rule_action_type_pause_e) return controller_rule_action_execute_type_pause_e;
+ if (type == controller_rule_action_type_reload_e) return controller_rule_action_execute_type_reload_e;
+ if (type == controller_rule_action_type_restart_e) return controller_rule_action_execute_type_restart_e;
+ if (type == controller_rule_action_type_resume_e) return controller_rule_action_execute_type_resume_e;
+ if (type == controller_rule_action_type_start_e) return controller_rule_action_execute_type_start_e;
+ if (type == controller_rule_action_type_stop_e) return controller_rule_action_execute_type_stop_e;
+ if (type == controller_rule_action_type_thaw_e) return controller_rule_action_execute_type_thaw_e;
+
+ return controller_rule_action_execute_type__enum_size_e;
}
-#endif // _di_controller_main_rule_action_type_to_action_execute_type_
+#endif // _di_controller_rule_action_type_to_action_execute_type_
-#ifndef _di_controller_main_rule_action_read_
- f_status_t controller_main_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_main_rule_actions_t * const actions, f_range_t * const range) {
+#ifndef _di_controller_rule_action_read_
+ 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) {
if (!global || !item || !actions || !range) return F_status_set_error(F_parameter);
f_status_t status = F_okay;
- controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, global->thread);
- f_state_t state = macro_f_state_t_initialize_1(controller_allocation_large_d, controller_allocation_small_d, F_okay, 0, 0, 0, &controller_main_thread_signal_state_fss, 0, (void *) &custom, 0);
+ controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, global);
+ f_state_t state = macro_f_state_t_initialize_1(controller_allocation_large_d, controller_allocation_small_d, F_okay, 0, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0);
f_number_unsigned_t i = 0;
cache->delimits.used = 0;
cache->content_action.used = 0;
- if (method == controller_main_rule_action_method_extended_list_e) {
+ if (method == controller_rule_action_method_extended_list_e) {
fl_fss_extended_list_content_read(cache->buffer_item, range, &cache->content_action, &cache->delimits, &cache->comments, &state);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(fl_fss_extended_list_content_read));
+ controller_print_error(&global->main->program.error, macro_controller_f(fl_fss_extended_list_content_read));
return status;
}
f_fss_apply_delimit(cache->delimits, &cache->buffer_item, &state);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(f_fss_apply_delimit));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_fss_apply_delimit));
return status;
}
status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &actions->array[actions->used].parameters.array, &actions->array[actions->used].parameters.used, &actions->array[actions->used].parameters.size);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase));
return status;
}
status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_iki_data_t), (void **) &actions->array[actions->used].ikis.array, &actions->array[actions->used].ikis.used, &actions->array[actions->used].ikis.size);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase));
return status;
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_action.array[0], &actions->array[actions->used].parameters.array[0]);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(f_string_dynamic_append_nulless));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_string_dynamic_append_nulless));
- actions->array[actions->used++].status = controller_main_error_simplify(F_status_set_fine(status));
+ actions->array[actions->used++].status = controller_error_simplify(F_status_set_fine(status));
return status;
}
if (actions->array[actions->used].parameters.array[0].used) {
state.step_large = controller_allocation_iki_large_d;
state.step_small = controller_allocation_iki_small_d;
- state.interrupt = &controller_main_thread_signal_state_iki;
+ state.interrupt = &controller_thread_signal_state_iki;
f_range_t range_iki = macro_f_range_t_initialize_2(actions->array[actions->used].parameters.array[0].used);
fl_iki_read(&actions->array[actions->used].parameters.array[0], &range_iki, &actions->array[actions->used].ikis.array[0], &state);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(fl_iki_read));
+ controller_print_error(&global->main->program.error, macro_controller_f(fl_iki_read));
- actions->array[actions->used++].status = controller_main_error_simplify(F_status_set_fine(status));
+ actions->array[actions->used++].status = controller_error_simplify(F_status_set_fine(status));
return status;
}
fll_fss_extended_read(cache->buffer_item, &cache->content_action.array[0], &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0, &state);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(fll_fss_extended_read));
+ controller_print_error(&global->main->program.error, macro_controller_f(fll_fss_extended_read));
return status;
}
f_fss_apply_delimit(cache->delimits, &cache->buffer_item, &state);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(f_fss_apply_delimit));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_fss_apply_delimit));
return status;
}
for (i = 0; i < cache->object_actions.used; ++i) {
- status = f_memory_array_increase_by(controller_allocation_small_d, sizeof(controller_main_rule_action_t), (void **) &actions->array, &actions->used, &actions->size);
+ 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(f_memory_array_increase_by));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase_by));
return status;
}
f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &actions->array[actions->used].line, &state);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(f_fss_count_lines));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_fss_count_lines));
return status;
}
actions->array[actions->used].line += ++item->line;
actions->array[actions->used].status = F_known_not;
- status = controller_main_rule_parameters_read(global, cache->buffer_item, &cache->object_actions.array[i], &cache->content_actions.array[i], &actions->array[actions->used], &state);
+ 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_main_error_simplify(F_status_set_fine(status));
+ actions->array[actions->used++].status = controller_error_simplify(F_status_set_fine(status));
return status;
}
fl_fss_extended_content_read(cache->buffer_item, range, &cache->content_action, 0, &cache->delimits, &state);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(fll_fss_extended_content_read));
+ controller_print_error(&global->main->program.error, macro_controller_f(fll_fss_extended_content_read));
}
else if (status == F_fss_found_content) {
f_fss_apply_delimit(cache->delimits, &cache->buffer_item, &state);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(f_fss_apply_delimit));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_fss_apply_delimit));
}
- else if (type == controller_main_rule_action_type_pid_file_e) {
+ else if (type == controller_rule_action_type_pid_file_e) {
item->pid_file.used = 0;
status = f_rip_dynamic_partial(cache->buffer_item, cache->content_action.array[0], &item->pid_file);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial));
}
}
- else if (type == controller_main_rule_action_type_rerun_e) {
+ else if (type == controller_rule_action_type_rerun_e) {
uint8_t type_rerun = 0;
if (cache->content_action.used) {
if (f_compare_dynamic_partial_string(controller_freeze_s.string, cache->buffer_item, controller_freeze_s.used, cache->content_action.array[0]) == F_equal_to) {
- type_rerun = controller_main_rule_action_execute_type_freeze_e;
+ type_rerun = controller_rule_action_execute_type_freeze_e;
}
if (f_compare_dynamic_partial_string(controller_kill_s.string, cache->buffer_item, controller_kill_s.used, cache->content_action.array[0]) == F_equal_to) {
- type_rerun = controller_main_rule_action_execute_type_kill_e;
+ type_rerun = controller_rule_action_execute_type_kill_e;
}
else if (f_compare_dynamic_partial_string(controller_pause_s.string, cache->buffer_item, controller_pause_s.used, cache->content_action.array[0]) == F_equal_to) {
- type_rerun = controller_main_rule_action_execute_type_pause_e;
+ type_rerun = controller_rule_action_execute_type_pause_e;
}
else if (f_compare_dynamic_partial_string(controller_reload_s.string, cache->buffer_item, controller_reload_s.used, cache->content_action.array[0]) == F_equal_to) {
- type_rerun = controller_main_rule_action_execute_type_reload_e;
+ type_rerun = controller_rule_action_execute_type_reload_e;
}
else if (f_compare_dynamic_partial_string(controller_restart_s.string, cache->buffer_item, controller_restart_s.used, cache->content_action.array[0]) == F_equal_to) {
- type_rerun = controller_main_rule_action_execute_type_restart_e;
+ type_rerun = controller_rule_action_execute_type_restart_e;
}
else if (f_compare_dynamic_partial_string(controller_resume_s.string, cache->buffer_item, controller_resume_s.used, cache->content_action.array[0]) == F_equal_to) {
- type_rerun = controller_main_rule_action_execute_type_resume_e;
+ type_rerun = controller_rule_action_execute_type_resume_e;
}
else if (f_compare_dynamic_partial_string(controller_start_s.string, cache->buffer_item, controller_start_s.used, cache->content_action.array[0]) == F_equal_to) {
- type_rerun = controller_main_rule_action_execute_type_start_e;
+ type_rerun = controller_rule_action_execute_type_start_e;
}
else if (f_compare_dynamic_partial_string(controller_stop_s.string, cache->buffer_item, controller_stop_s.used, cache->content_action.array[0]) == F_equal_to) {
- type_rerun = controller_main_rule_action_execute_type_stop_e;
+ type_rerun = controller_rule_action_execute_type_stop_e;
}
else if (f_compare_dynamic_partial_string(controller_thaw_s.string, cache->buffer_item, controller_thaw_s.used, cache->content_action.array[0]) == F_equal_to) {
- type_rerun = controller_main_rule_action_execute_type_thaw_e;
+ type_rerun = controller_rule_action_execute_type_thaw_e;
}
}
if (!type_rerun) {
- controller_main_print_rule_item_error_action_first(&global->main->program.error, cache);
+ controller_print_rule_item_error_action_first(&global->main->program.error, cache);
return F_status_set_error(F_valid_not);
}
}
}
else {
- controller_main_print_rule_item_error_action_second(&global->main->program.error, cache);
+ controller_print_rule_item_error_action_second(&global->main->program.error, cache);
return F_status_set_error(F_valid_not);
}
for (i = 2; i < cache->content_action.used; ++i) {
if (f_compare_dynamic_partial_string(controller_delay_s.string, cache->buffer_item, controller_delay_s.used, cache->content_action.array[i]) == F_equal_to) {
- status = controller_main_rule_action_read_rerun_number(global, controller_delay_s.string, cache, &i, &rerun_item->delay);
+ status = controller_rule_action_read_rerun_number(global, controller_delay_s.string, cache, &i, &rerun_item->delay);
}
else if (f_compare_dynamic_partial_string(controller_max_s.string, cache->buffer_item, controller_max_s.used, cache->content_action.array[i]) == F_equal_to) {
- status = controller_main_rule_action_read_rerun_number(global, controller_max_s.string, cache, &i, &rerun_item->max);
+ status = controller_rule_action_read_rerun_number(global, controller_max_s.string, cache, &i, &rerun_item->max);
}
else if (f_compare_dynamic_partial_string(controller_reset_s.string, cache->buffer_item, controller_reset_s.used, cache->content_action.array[i]) == F_equal_to) {
item->reruns[type_rerun].is |= rerun_item == &item->reruns[type_rerun].failure ? controller_rule_rerun_is_failure_reset_d : controller_rule_rerun_is_success_reset_d;
}
else {
- controller_main_print_rule_item_error_action_unknown(&global->main->program.error, cache, controller_rerun_s, i);
+ controller_print_rule_item_error_action_unknown(&global->main->program.error, cache, controller_rerun_s, i);
return F_status_set_error(F_valid_not);
}
} // for
}
- else if (type == controller_main_rule_action_type_with_e) {
+ else if (type == controller_rule_action_type_with_e) {
for (i = 0; i < cache->content_action.used; ++i) {
if (f_compare_dynamic_partial_string(controller_full_path_s.string, cache->buffer_item, controller_full_path_s.used, cache->content_action.array[i]) == F_equal_to) {
item->with &= ~controller_with_session_new_d;
}
else {
- controller_main_print_rule_item_error_action_unknown(&global->main->program.error, cache, controller_with_s, i);
+ controller_print_rule_item_error_action_unknown(&global->main->program.error, cache, controller_with_s, i);
status = F_status_set_error(F_valid_not);
status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &actions->array[actions->used].parameters.array, &actions->array[actions->used].parameters.used, &actions->array[actions->used].parameters.size);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase));
return status;
}
status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_iki_data_t), (void **) &actions->array[actions->used].ikis.array, &actions->array[actions->used].ikis.used, &actions->array[actions->used].ikis.size);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase));
return status;
}
} // for
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(f_string_dynamic_partial_mash_nulless));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_string_dynamic_partial_mash_nulless));
- actions->array[actions->used++].status = controller_main_error_simplify(F_status_set_fine(status));
+ actions->array[actions->used++].status = controller_error_simplify(F_status_set_fine(status));
return status;
}
if (actions->array[actions->used].parameters.array[0].used) {
state.step_large = controller_allocation_iki_large_d;
state.step_small = controller_allocation_iki_small_d;
- state.interrupt = &controller_main_thread_signal_state_iki;
+ state.interrupt = &controller_thread_signal_state_iki;
f_range_t range_iki = macro_f_range_t_initialize_2(actions->array[actions->used].parameters.array[0].used);
fl_iki_read(&actions->array[actions->used].parameters.array[0], &range_iki, &actions->array[actions->used].ikis.array[0], &state);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(fl_iki_read));
+ controller_print_error(&global->main->program.error, macro_controller_f(fl_iki_read));
- actions->array[actions->used++].status = controller_main_error_simplify(F_status_set_fine(status));
+ actions->array[actions->used++].status = controller_error_simplify(F_status_set_fine(status));
return status;
}
f_fss_count_lines(cache->buffer_item, range->start, &actions->array[actions->used].line, &state);
if (F_status_is_error(status)) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(f_fss_count_lines));
+ controller_print_error(&global->main->program.error, macro_controller_f(f_fss_count_lines));
return status;
}
actions->array[actions->used].line += ++item->line;
actions->array[actions->used].status = F_known_not;
- status = controller_main_rule_parameters_read(global, cache->buffer_item, 0, &cache->content_action, &actions->array[actions->used], &state);
+ 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_main_error_simplify(F_status_set_fine(status));
+ actions->array[actions->used++].status = controller_error_simplify(F_status_set_fine(status));
return status;
}
}
if (F_status_is_error_not(status) && status == F_data_not) {
- controller_main_print_rule_item_debug_action_empty(&global->debug, cache);
+ controller_print_rule_item_debug_action_empty(global->debug, cache);
}
return status;
}
-#endif // _di_controller_main_rule_action_read_
+#endif // _di_controller_rule_action_read_
-#ifndef _di_controller_main_rule_action_read_rerun_number_
- f_status_t controller_main_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) {
+#ifndef _di_controller_rule_action_read_rerun_number_
+ 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) {
f_status_t status = F_okay;
f_number_signed_t parsed = 0;
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_main_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_range_after_number_sign(cache->buffer_item, cache->content_action.array[*index]), &parsed);
}
if (status == F_data_not) {
status = F_status_set_fine(status);
if (status != F_valid_not && status != F_number && status != F_number_decimal && status != F_number_overflow && status != F_number_underflow && status != F_number_negative) {
- controller_main_print_error(&global->main->program.error, macro_controller_f(fl_conversion_dynamic_partial_to_signed_detect));
+ controller_print_error(&global->main->program.error, macro_controller_f(fl_conversion_dynamic_partial_to_signed_detect));
}
else {
controller_lock_print(global->main->program.error.to, global->thread);
}
}
- controller_main_print_rule_error_cache(&global->error, &cache->action, F_true);
+ controller_print_rule_error_cache(global->error, cache->action, F_true);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
return F_okay;
}
-#endif // _di_controller_main_rule_action_read_rerun_number_
+#endif // _di_controller_rule_action_read_rerun_number_
#ifdef __cplusplus
} // extern "C"
* The string with used > 0 on success.
* The string with used == 0 if no match was found.
*/
-#ifndef _di_controller_main_rule_action_method_name_
- extern f_string_static_t controller_main_rule_action_method_name(const uint8_t type);
-#endif // _di_controller_main_rule_action_method_name_
+#ifndef _di_controller_rule_action_method_name_
+ extern f_string_static_t controller_rule_action_method_name(const uint8_t type);
+#endif // _di_controller_rule_action_method_name_
/**
* Convert the action type to an action execute type.
* @return
* The converted action type, converted into an action execute type.
*
- * The code controller_main_rule_action_execute_type__enum_size_e is returned for unknown types.
+ * The code controller_rule_action_execute_type__enum_size_e is returned for unknown types.
*/
-#ifndef _di_controller_main_rule_action_type_to_action_execute_type_
- extern uint8_t controller_main_rule_action_type_to_action_execute_type(const uint8_t type);
-#endif // _di_controller_main_rule_action_type_to_action_execute_type_
+#ifndef _di_controller_rule_action_type_to_action_execute_type_
+ extern uint8_t controller_rule_action_type_to_action_execute_type(const uint8_t type);
+#endif // _di_controller_rule_action_type_to_action_execute_type_
/**
* Read the content within the buffer, processing the action (or a set of within a list) for the given item.
* @return
* F_okay on success.
*
- * Errors (with error bit) from: controller_main_rule_parameters_read().
+ * 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_main_rule_parameters_read()
+ * @see controller_rule_parameters_read()
* @see f_fss_count_lines()
* @see f_memory_array_increase_by()
*/
-#ifndef _di_controller_main_rule_action_read_
- extern f_status_t controller_main_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_main_rule_actions_t * const actions, f_range_t * const range);
-#endif // _di_controller_main_rule_action_read_
+#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_main_rule_action_read().
+ * This is intended to be called by controller_rule_action_read().
*
* @param global
* The global data.
*
* Errors (with error bit) from: fl_conversion_dynamic_partial_to_signed_detect().
*
- * @see controller_main_rule_action_read()
+ * @see controller_rule_action_read()
* @see fl_conversion_dynamic_partial_to_signed_detect()
*/
-#ifndef _di_controller_main_rule_action_read_rerun_number_
- extern f_status_t controller_main_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_main_rule_action_read_rerun_number_
+#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" {
#endif
-#ifndef _di_controller_main_rule_execute_
- f_status_t controller_main_rule_execute(controller_global_t * const global, const uint8_t action, const uint8_t options, controller_instance_t * const instance) {
+#ifndef _di_controller_rule_execute_
+ f_status_t controller_rule_execute(controller_global_t * const global, const uint8_t action, const uint8_t options, controller_instance_t * const instance) {
if (!global || !instance) return F_status_set_error(F_parameter);
execute_set.as.control_group = &instance->rule.cgroup;
// Make sure all required cgroup directories exist.
- if (controller_main_rule_status_is_available(action, instance->rule)) {
+ 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(&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);
+ controller_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;
}
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));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(fl_environment_load_names), F_status_set_fine(status));
return status;
}
status = f_string_dynamic_append(entry->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));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status));
return status;
}
status = f_string_maps_append(entry->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));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_maps_append), F_status_set_fine(status));
return status;
}
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));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status));
return status;
}
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));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_maps_append), F_status_set_fine(status));
return status;
}
status = f_environment_get_all(&environment);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_environment_get_all), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_environment_get_all), F_status_set_fine(status));
return status;
}
status = f_string_maps_append(entry->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));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_maps_append), F_status_set_fine(status));
return status;
}
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));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_maps_append), F_status_set_fine(status));
return status;
}
}
}
- for (i = 0; i < instance->rule.items.used && controller_main_thread_is_enabled_instance(instance, global->thread); ++i) {
+ for (i = 0; i < instance->rule.items.used && controller_thread_is_enabled_instance(instance); ++i) {
if (instance->rule.items.array[i].type == controller_rule_item_type_settings_e) continue;
for (j = 0; j < instance->rule.items.array[i].actions.used; ++j) {
- if (!controller_main_thread_is_enabled_instance(instance, global->thread)) {
+ if (!controller_thread_is_enabled_instance(instance)) {
status = F_status_set_error(F_interrupt);
break;
}
if (instance->rule.items.array[i].type == controller_rule_item_type_command_e) {
- status = controller_main_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance);
+ status = controller_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "controller_main_rule_expand", F_true, F_false);
+ controller_print_rule_error(global->error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false);
break;
}
do {
- status = controller_main_rule_execute_foreground(instance->rule.items.array[i].type, f_string_empty_s, instance->cache.expanded, options, &execute_set, instance);
+ 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_main_rule_execute_rerun(controller_main_rule_action_type_to_action_execute_type(action), instance, &instance->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;
}
}
else if (instance->rule.items.array[i].type == controller_rule_item_type_script_e) {
- status = controller_main_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance);
+ status = controller_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "controller_main_rule_expand", F_true, F_false);
+ controller_print_rule_error(global->error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false);
break;
}
do {
if (instance->rule.engine.used) {
- status = controller_main_rule_execute_foreground(instance->rule.items.array[i].type, instance->rule.engine, instance->rule.engine_arguments, options, &execute_set, instance);
+ 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_main_rule_execute_foreground(instance->rule.items.array[i].type, *global->main->setting.default_engine, instance->rule.engine_arguments, options, &execute_set, instance);
+ status = controller_rule_execute_foreground(instance->rule.items.array[i].type, controller_default_engine_s, 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_main_rule_execute_rerun(controller_main_rule_action_type_to_action_execute_type(action), instance, &instance->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;
}
}
else if (instance->rule.items.array[i].type == controller_rule_item_type_service_e) {
- status = controller_main_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance);
+ status = controller_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "controller_main_rule_expand", F_true, F_false);
+ controller_print_rule_error(global->error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false);
break;
}
if (instance->rule.items.array[i].pid_file.used) {
do {
- status = controller_main_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);
+ 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_main_rule_execute_rerun(controller_main_rule_action_type_to_action_execute_type(action), instance, &instance->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;
else {
success = F_status_set_error(F_failure);
- controller_main_print_rule_action_error_missing_pid(&global->error, instance->rule.alias);
+ controller_print_rule_action_error_missing_pid(global->error, instance->rule.alias);
}
}
else if (instance->rule.items.array[i].type == controller_rule_item_type_utility_e) {
if (instance->rule.items.array[i].pid_file.used) {
- status = controller_main_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance);
+ status = controller_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "controller_main_rule_expand", F_true, F_false);
+ controller_print_rule_error(global->error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false);
break;
}
}
do {
- status = controller_main_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);
+ 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 : controller_default_engine_s, 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_main_rule_execute_rerun(controller_main_rule_action_type_to_action_execute_type(action), instance, &instance->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;
else {
success = F_status_set_error(F_failure);
- controller_main_print_rule_action_error_missing_pid(&global->error, instance->rule.alias);
+ controller_print_rule_action_error_missing_pid(global->error, instance->rule.alias);
}
}
else {
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_main_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true);
+ controller_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true);
controller_unlock_print_flush(global->main->program.warning.to, global->thread);
}
// Lock failed, attempt to re-establish lock before returning.
if (F_status_set_fine(status) == F_lock) {
- status = controller_main_lock_read(instance, global->thread, &instance->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_main_thread_is_enabled_instance(instance, global->thread)) {
+ if (!controller_thread_is_enabled_instance(instance)) {
return F_status_set_error(F_interrupt);
}
return F_okay;
}
-#endif // _di_controller_main_rule_execute_
+#endif // _di_controller_rule_execute_
-#ifndef _di_controller_main_rule_execute_foreground_
- f_status_t controller_main_rule_execute_foreground(const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_instance_t * const instance) {
+#ifndef _di_controller_rule_execute_foreground_
+ f_status_t controller_rule_execute_foreground(const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_instance_t * const instance) {
if (!instance) return F_status_set_error(F_parameter);
f_status_t status = F_okay;
f_status_t status_lock = F_okay;
- controller_main_t * const main = ((controller_global_t *) instance->global)->main;
- controller_thread_t * const thread = ((controller_global_t *) instance->global)->thread;
+ controller_t * const main = instance->global->main;
+ controller_thread_t * const thread = instance->global->thread;
f_execute_result_t result = f_execute_result_t_initialize;
- status = controller_pids_increase(&instance->childs);
+ status = f_memory_array_increase(controller_allocation_small_d, sizeof(pid_t), (void **) &instance->childs.array, &instance->childs.used, &instance->childs.size);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&main->program.error, macro_controller_f(controller_pids_increase), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_memory_array_increase), F_status_set_fine(status));
return status;
}
// Sleep for less than a second to better show simulation of synchronous vs asynchronous.
{
- const f_time_spec_t delay = controller_main_time_milliseconds(controller_thread_simulation_timeout_d);
+ f_time_spec_t delay = f_time_spec_t_initialize;
- if (controller_main_time_sleep_nanoseconds((controller_global_t *) instance->global, delay) == -1) {
- status = F_status_set_error(F_interrupt);
+ status = f_time_spec_millisecond(0, controller_thread_simulation_timeout_d, &delay);
+
+ if (F_status_is_error(status)) {
+ controller_print_error_status(&main->program.error, macro_controller_f(f_time_spec_millisecond), F_status_set_fine(status));
+ }
+ else {
+ status = controller_time_sleep_nanoseconds(instance->global, delay);
}
}
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, 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, instance->rule.engine_arguments, &simulated_parameter, &execute_set->as, (void *) &result);
+ status = fll_execute_program(controller_default_engine_s, instance->rule.engine_arguments, &simulated_parameter, &execute_set->as, (void *) &result);
}
}
else {
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_write_instance(instance, thread, &instance->lock);
+ status_lock = controller_lock_write_instance(instance, &instance->active);
if (F_status_is_error(status_lock)) {
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_main_lock_read_instance(instance, thread, &instance->lock);
+ status = controller_lock_read_instance(instance, &instance->active);
if (status == F_okay) {
return status_lock;
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_read_instance(instance, thread, &instance->lock);
+ status_lock = controller_lock_read_instance(instance, &instance->active);
if (F_status_is_error(status_lock)) {
controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true, thread);
waitpid(id_child, &result.status, 0);
}
- if (F_status_set_fine(status_lock) == F_interrupt || !controller_main_thread_is_enabled_instance(instance, thread)) {
+ if (F_status_set_fine(status_lock) == F_interrupt || !controller_thread_is_enabled_instance(instance)) {
return status_lock == F_okay ? F_status_set_error(F_interrupt) : F_status_set_error(F_lock);
}
f_thread_unlock(&instance->lock);
}
- status_lock = controller_main_lock_write_instance(instance, thread, &instance->lock);
+ status_lock = controller_lock_write_instance(instance, &instance->active);
if (F_status_is_error(status_lock)) {
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_main_lock_read_instance(instance, thread, &instance->lock);
+ status = controller_lock_read_instance(instance, &instance->active);
if (status == F_okay) {
return status_lock;
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_read_instance(instance, thread, &instance->lock);
+ status_lock = controller_lock_read_instance(instance, &instance->active);
if (F_status_is_error(status_lock)) {
controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true, thread);
else {
main->program.child = result.status;
- if (!controller_main_thread_is_enabled_instance(instance, thread)) {
+ if (!controller_thread_is_enabled_instance(instance)) {
return F_status_set_error(F_interrupt);
}
}
status = F_status_set_fine(status);
if ((WIFEXITED(instance->result) && WEXITSTATUS(instance->result)) || status == F_control_group || status == F_failure || status == F_limit || status == F_processor || status == F_schedule) {
- controller_main_print_rule_item_error_execute(&global->error, instance, type == controller_rule_item_type_script_e, program.used ? program : arguments.array[0], status);
+ controller_print_rule_item_error_execute(instance->global->error, instance, type == controller_rule_item_type_script_e, program.used ? program : arguments.array[0], status);
}
else {
- controller_main_print_error_status(&global->error, macro_controller_f(fll_execute_program), F_status_set_fine(status));
+ controller_print_error_status(instance->global->error, macro_controller_f(fll_execute_program), F_status_set_fine(status));
}
status = F_status_set_error(status);
return status;
}
-#endif // _di_controller_main_rule_execute_foreground_
+#endif // _di_controller_rule_execute_foreground_
-#ifndef _di_controller_main_rule_execute_pid_with_
- f_status_t controller_main_rule_execute_pid_with(const f_string_dynamic_t pid_file, const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, const uint8_t with, controller_execute_set_t * const execute_set, controller_instance_t * const instance) {
+#ifndef _di_controller_rule_execute_pid_with_
+ f_status_t controller_rule_execute_pid_with(const f_string_dynamic_t pid_file, const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, const uint8_t with, controller_execute_set_t * const execute_set, controller_instance_t * const instance) {
- if (!execute_set || !instance) return F_status_set_error(F_parameter);
+ if (!execute_set || !instance || !instance->global || !instance->global->main || !instance->global->thread) return F_status_set_error(F_parameter);
f_status_t status = F_okay;
f_status_t status_lock = F_okay;
- controller_main_t * const main = ((controller_global_t *) instance->global)->main;
- controller_thread_t * const thread = ((controller_global_t *) instance->global)->thread;
+ controller_t * const main = instance->global->main;
f_execute_result_t result = f_execute_result_t_initialize;
- status = controller_pids_increase(&instance->childs);
+ status = f_memory_array_increase(controller_allocation_small_d, sizeof(pid_t), (void **) &instance->childs.array, &instance->childs.used, &instance->childs.size);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&main->program.error, macro_controller_f(controller_pids_increase), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_memory_array_increase), F_status_set_fine(status));
return status;
}
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(&main->program.error, macro_controller_f(f_memory_array_increase), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_memory_array_increase), F_status_set_fine(status));
return status;
}
status = f_file_exists(pid_file, F_true);
if (F_status_is_error(status) || status == F_true) {
- 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);
+ controller_print_error_file_status(&main->program.error, macro_controller_f(f_file_exists), pid_file, f_file_operation_find_s, fll_error_file_type_file_e, status == F_true ? F_file_found : F_status_set_fine(status));
return status;
}
status = f_string_dynamic_append_nulless(pid_file, child_pid_file);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&main->program.error, macro_controller_f(f_string_dynamic_append_nulless), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_string_dynamic_append_nulless), F_status_set_fine(status));
return status;
}
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);
+ controller_lock_print(main->program.error.to, instance->global->thread);
fl_print_format("%rSimulating execution of '%[", main->program.error.to, f_string_eol_s, main->program.context.set.title);
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, instance->rule.name, main->program.context.set.notable, f_string_eol_s);
- controller_unlock_print_flush(main->program.error.to, thread);
+ controller_unlock_print_flush(main->program.error.to, instance->global->thread);
}
// Sleep for less than a second to better show simulation of synchronous vs asynchronous.
{
- const f_time_spec_t delay = controller_main_time_milliseconds(controller_thread_simulation_timeout_d);
+ f_time_spec_t delay = f_time_spec_t_initialize;
- if (controller_main_time_sleep_nanoseconds((controller_global_t *) instance->global, delay) == -1) {
- status = F_status_set_error(F_interrupt);
+ status = f_time_spec_millisecond(0, controller_thread_simulation_timeout_d, &delay);
+
+ if (F_status_is_error(status)) {
+ controller_print_error_status(&main->program.error, macro_controller_f(f_time_spec_millisecond), F_status_set_fine(status));
+ }
+ else {
+ status = controller_time_sleep_nanoseconds(instance->global, delay);
}
}
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, 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);
+ status = fll_execute_program(controller_default_engine_s, simulated_arguments, &simulated_parameter, &execute_set->as, (void *) &result);
}
}
else {
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_write_instance(instance, thread, &instance->lock);
+ status_lock = controller_lock_write_instance(instance, &instance->active);
if (F_status_is_error(status_lock)) {
- controller_lock_print_error_critical(&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, instance->global->thread);
if (F_status_set_fine(status_lock) != F_interrupt) {
- status = controller_main_lock_read_instance(instance, thread, &instance->lock);
+ status = controller_lock_read_instance(instance, &instance->active);
if (status == F_okay) {
return status_lock;
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_read_instance(instance, thread, &instance->lock);
+ status_lock = controller_lock_read_instance(instance, &instance->active);
if (F_status_is_error(status_lock)) {
- controller_lock_print_error_critical(&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, instance->global->thread);
}
if (F_status_set_fine(status_lock) != F_interrupt) {
waitpid(id_child, &result.status, 0);
}
- if (!controller_main_thread_is_enabled_instance(instance, thread)) {
+ if (!controller_thread_is_enabled_instance(instance)) {
if (status_lock == F_okay) {
return F_status_set_error(F_interrupt);
}
f_thread_unlock(&instance->lock);
}
- status_lock = controller_main_lock_write_instance(instance, thread, &instance->lock);
+ status_lock = controller_lock_write_instance(instance, &instance->active);
if (F_status_is_error(status_lock)) {
- controller_lock_print_error_critical(&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, instance->global->thread);
if (F_status_set_fine(status_lock) != F_interrupt) {
- status = controller_main_lock_read_instance(instance, thread, &instance->lock);
+ status = controller_lock_read_instance(instance, &instance->active);
if (status == F_okay) {
return status_lock;
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_read_instance(instance, thread, &instance->lock);
+ status_lock = controller_lock_read_instance(instance, &instance->active);
if (F_status_is_error(status_lock)) {
- controller_lock_print_error_critical(&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, instance->global->thread);
return F_status_set_error(F_lock);
}
else {
main->program.child = result.status;
- if (!controller_main_thread_is_enabled_instance(instance, thread)) {
+ if (!controller_thread_is_enabled_instance(instance)) {
return F_status_set_error(F_interrupt);
}
}
status = F_status_set_fine(status);
if ((WIFEXITED(instance->result) && WEXITSTATUS(instance->result)) || status == F_control_group || status == F_failure || status == F_limit || status == F_processor || status == F_schedule) {
- controller_main_print_rule_item_error_execute(&global->error, instance, type == controller_rule_item_type_utility_e, program.used ? program : arguments.array[0], status);
+ controller_print_rule_item_error_execute(instance->global->error, instance, type == controller_rule_item_type_utility_e, program.used ? program : arguments.array[0], status);
}
else {
- controller_main_print_error_status(&global->error, macro_controller_f(fll_execute_program), F_status_set_fine(status));
+ controller_print_error_status(instance->global->error, macro_controller_f(fll_execute_program), F_status_set_fine(status));
}
return F_status_set_error(status);
return status;
}
-#endif // _di_controller_main_rule_execute_pid_with_
+#endif // _di_controller_rule_execute_pid_with_
-#ifndef _di_controller_main_rule_execute_rerun_
- int8_t controller_main_rule_execute_rerun(const uint8_t action, controller_instance_t * const instance, controller_rule_item_t * const item) {
+#ifndef _di_controller_rule_execute_rerun_
+ int8_t controller_rule_execute_rerun(const uint8_t action, controller_instance_t * const instance, controller_rule_item_t * const item) {
- if (!instance || !item) return F_status_set_error(F_parameter);
+ if (!instance || !instance->global || !instance->global->main || !instance->global->thread || !item) return F_false;
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_global_t *) instance->global)->main;
- controller_thread_t * const thread = ((controller_global_t *) instance->global)->thread;
- controller_rule_rerun_item_t *rerun_item = result ? &item->reruns[action].failure : &item->reruns[action].success;
+ controller_t * const main = instance->global->main;
+ controller_rule_rerun_item_t * const rerun_item = result ? &item->reruns[action].failure : &item->reruns[action].success;
- if (!controller_main_thread_is_enabled_instance(instance, thread)) return -2;
+ if (!controller_thread_is_enabled_instance(instance)) 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);
+ controller_lock_print(main->program.output.to, instance->global->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, instance->rule.alias, main->program.context.set.title);
- fl_print_format("%[%r%]' with a ", main->program.output.to, main->program.context.set.notable, controller_main_rule_action_execute_type_name(action), main->program.context.set.notable);
+ fl_print_format("%[%r%]' with a ", main->program.output.to, main->program.context.set.notable, controller_convert_rule_action_execute_type_string(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);
fl_print_format(" with no %[%r%].%r", main->program.output.to, main->program.context.set.notable, controller_max_s, main->program.context.set.notable, f_string_eol_s);
}
- controller_unlock_print_flush(main->program.output.to, thread);
+ controller_unlock_print_flush(main->program.output.to, instance->global->thread);
}
if (rerun_item->delay) {
- const f_time_spec_t delay = controller_main_time_milliseconds(rerun_item->delay);
+ f_time_spec_t delay = f_time_spec_t_initialize;
+
+ {
+ const f_status_t status = f_time_spec_millisecond(0, rerun_item->delay, &delay);
+
+ if (F_status_is_error(status)) {
+ controller_print_error_status(&main->program.error, macro_controller_f(f_time_spec_millisecond), F_status_set_fine(status));
+
+ return -1;
+ }
+ }
- if (controller_main_time_sleep_nanoseconds(main, (controller_process_t *) instance->main_setting, delay) == -1) {
- return -1;
+ {
+ const f_status_t status = controller_time_sleep_nanoseconds(instance->global, delay);
+ if (F_status_is_error(status) || status == F_interrupt) return -1;
}
- if (!controller_main_thread_is_enabled_instance(instance, thread)) return -2;
+ if (!controller_thread_is_enabled_instance(instance)) return -2;
}
if (item->reruns[action].is & (result ? controller_rule_rerun_is_failure_reset_d : controller_rule_rerun_is_success_reset_d)) {
return F_false;
}
-#endif // _di_controller_main_rule_execute_rerun_
+#endif // _di_controller_rule_execute_rerun_
#ifdef __cplusplus
} // extern "C"
* The action to perform based on the action type codes.
*
* Only subset of the action type codes are supported:
- * - controller_main_rule_action_type_kill_e
- * - controller_main_rule_action_type_pause_e
- * - controller_main_rule_action_type_reload_e
- * - controller_main_rule_action_type_restart_e
- * - controller_main_rule_action_type_resume_e
- * - controller_main_rule_action_type_start_e
- * - controller_main_rule_action_type_stop_e
+ * - controller_rule_action_type_kill_e
+ * - controller_rule_action_type_pause_e
+ * - controller_rule_action_type_reload_e
+ * - controller_rule_action_type_restart_e
+ * - controller_rule_action_type_resume_e
+ * - controller_rule_action_type_start_e
+ * - controller_rule_action_type_stop_e
* @param options
* Process options to consider when executing.
* 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).
* On success and the rule is run asynchronously, then the individual status for the rule is set to F_busy.
* On failure, the individual status for the rule is set to an appropriate error status.
*/
-#ifndef _di_controller_main_rule_execute_
- extern f_status_t controller_main_rule_execute(controller_global_t * const global, const uint8_t action, const uint8_t options, controller_instance_t * const instance);
-#endif // _di_controller_main_rule_execute_
+#ifndef _di_controller_rule_execute_
+ extern f_status_t controller_rule_execute(controller_global_t * const global, const uint8_t action, const uint8_t options, controller_instance_t * const instance);
+#endif // _di_controller_rule_execute_
/**
* Perform an execution of the given rule in the foreground.
*
* @see fll_execute_program()
*/
-#ifndef _di_controller_main_rule_execute_foreground_
- extern f_status_t controller_main_rule_execute_foreground(const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_instance_t * const instance);
-#endif // _di_controller_main_rule_execute_foreground_
+#ifndef _di_controller_rule_execute_foreground_
+ extern f_status_t controller_rule_execute_foreground(const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_instance_t * const instance);
+#endif // _di_controller_rule_execute_foreground_
/**
* Perform an execution of the given rule in the foreground or background and creating a PID file.
*
* @see fll_execute_program()
*/
-#ifndef _di_controller_main_rule_execute_pid_with_
- extern f_status_t controller_main_rule_execute_pid_with(const f_string_dynamic_t pid_file, const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, const uint8_t with, controller_execute_set_t * const execute_set, controller_instance_t * const instance);
-#endif // _di_controller_main_rule_execute_pid_with_
+#ifndef _di_controller_rule_execute_pid_with_
+ extern f_status_t controller_rule_execute_pid_with(const f_string_dynamic_t pid_file, const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, const uint8_t with, controller_execute_set_t * const execute_set, controller_instance_t * const instance);
+#endif // _di_controller_rule_execute_pid_with_
/**
* Determine whether or not an execute rule should be re-run, applying a delay as requested.
* - EINVAL: Consider this having returned F_status_set_error(F_parameter);
* -2 to designate exit due to signal/disabled thread.
*/
-#ifndef _di_controller_main_rule_execute_rerun_
- extern int8_t controller_main_rule_execute_rerun(const uint8_t action, controller_instance_t * const instance, controller_rule_item_t * const item);
-#endif // _di_controller_main_rule_execute_rerun_
+#ifndef _di_controller_rule_execute_rerun_
+ extern int8_t controller_rule_execute_rerun(const uint8_t action, controller_instance_t * const instance, controller_rule_item_t * const item);
+#endif // _di_controller_rule_execute_rerun_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_rule_expand_
- f_status_t controller_main_rule_expand(controller_global_t * const global, const controller_main_rule_action_t action, controller_instance_t * const instance) {
+#ifndef _di_controller_rule_expand_
+ f_status_t controller_rule_expand(controller_global_t * const global, const controller_rule_action_t action, controller_instance_t * const instance) {
if (!global || !instance) return F_status_set_error(F_parameter);
- process->cache.expanded.used = 0;
+ instance->cache.expanded.used = 0;
if (!action.parameters.used) return F_okay;
- f_status_t status = f_memory_array_increase_by(action.parameters.used, sizeof(f_string_dynamic_t), (void **) &process->cache.expanded.array, &process->cache.expanded.used, &process->cache.expanded.size);
+ f_status_t status = f_memory_array_increase_by(action.parameters.used, sizeof(f_string_dynamic_t), (void **) &instance->cache.expanded.array, &instance->cache.expanded.used, &instance->cache.expanded.size);
if (F_status_is_error(status)) return status;
f_number_unsigned_t i = 0;
f_iki_data_t *iki_data = 0;
f_string_dynamic_t *buffer = 0;
- for (; process->cache.expanded.used < action.parameters.used; ++process->cache.expanded.used) {
+ for (; instance->cache.expanded.used < action.parameters.used; ++instance->cache.expanded.used) {
- buffer = &process->cache.expanded.array[process->cache.expanded.used];
+ buffer = &instance->cache.expanded.array[instance->cache.expanded.used];
buffer->used = 0;
- if (action.ikis.array[process->cache.expanded.used].variable.used) {
- iki_data = &action.ikis.array[process->cache.expanded.used];
+ if (action.ikis.array[instance->cache.expanded.used].variable.used) {
+ iki_data = &action.ikis.array[instance->cache.expanded.used];
// Allocate enough room plus an extra buffer to help reduce reallocations.
- status = f_memory_array_increase_by(action.parameters.array[process->cache.expanded.used].used + controller_allocation_large_d, sizeof(f_char_t), (void **) &buffer->string, &buffer->used, &buffer->size);
+ status = f_memory_array_increase_by(action.parameters.array[instance->cache.expanded.used].used + controller_allocation_large_d, sizeof(f_char_t), (void **) &buffer->string, &buffer->used, &buffer->size);
// Apply the IKI delimits.
for (i = 0; i < iki_data->delimits.used; ++i) {
- action.parameters.array[process->cache.expanded.used].string[iki_data->delimits.array[i]] = f_iki_syntax_placeholder_s.string[0];
+ action.parameters.array[instance->cache.expanded.used].string[iki_data->delimits.array[i]] = f_iki_syntax_placeholder_s.string[0];
} // for
if (iki_data->variable.used) {
range.start = first;
range.stop = iki_data->variable.array[i].start - 1;
- status = f_string_dynamic_partial_append_nulless(action.parameters.array[process->cache.expanded.used], range, buffer);
+ status = f_string_dynamic_partial_append_nulless(action.parameters.array[instance->cache.expanded.used], range, buffer);
if (F_status_is_error(status)) break;
}
- status = controller_main_rule_expand_iki(process, action.parameters.array[process->cache.expanded.used], iki_data->vocabulary.array[i], iki_data->content.array[i], buffer);
+ status = controller_rule_expand_iki(instance, action.parameters.array[instance->cache.expanded.used], iki_data->vocabulary.array[i], iki_data->content.array[i], buffer);
if (F_status_is_error(status)) break;
first = iki_data->variable.array[i].stop + 1;
if (F_status_is_error(status)) break;
// Copy everything after the last IKI variable to the end of the content.
- if (first < action.parameters.array[process->cache.expanded.used].used) {
+ if (first < action.parameters.array[instance->cache.expanded.used].used) {
range.start = first;
- range.stop = action.parameters.array[process->cache.expanded.used].used - 1;
+ range.stop = action.parameters.array[instance->cache.expanded.used].used - 1;
- status = f_string_dynamic_partial_append(action.parameters.array[process->cache.expanded.used], range, buffer);
+ status = f_string_dynamic_partial_append(action.parameters.array[instance->cache.expanded.used], range, buffer);
}
}
else {
- status = f_string_dynamic_append_nulless(action.parameters.array[process->cache.expanded.used], buffer);
+ status = f_string_dynamic_append_nulless(action.parameters.array[instance->cache.expanded.used], buffer);
}
// Unapply the IKI delimits.
for (i = 0; i < iki_data->delimits.used; ++i) {
- action.parameters.array[process->cache.expanded.used].string[iki_data->delimits.array[i]] = f_iki_syntax_slash_s.string[0];
+ action.parameters.array[instance->cache.expanded.used].string[iki_data->delimits.array[i]] = f_iki_syntax_slash_s.string[0];
} // for
}
else {
- status = f_string_dynamic_append(action.parameters.array[process->cache.expanded.used], buffer);
+ status = f_string_dynamic_append(action.parameters.array[instance->cache.expanded.used], buffer);
}
if (F_status_is_error(status)) return status;
return F_okay;
}
-#endif // _di_controller_main_rule_expand_
+#endif // _di_controller_rule_expand_
-#ifndef _di_controller_main_rule_expand_iki_
- f_status_t controller_main_rule_expand_iki(controller_instance_t * const instance, const f_string_static_t source, const f_range_t vocabulary, const f_range_t content, f_string_dynamic_t * const destination) {
+#ifndef _di_controller_rule_expand_iki_
+ f_status_t controller_rule_expand_iki(controller_instance_t * const instance, const f_string_static_t source, const f_range_t vocabulary, const f_range_t content, f_string_dynamic_t * const destination) {
- if (!instance || !destination) return F_status_set_error(F_parameter);
+ if (!instance || !instance->global || !instance->global->program || !destination) return F_status_set_error(F_parameter);
if (vocabulary.start > vocabulary.stop) return F_okay;
if (content.start > content.stop) return F_okay;
f_number_unsigned_t i = 0;
// First check to see if the environment variable is overwritten by a "define".
- for (; i < process->rule.define.used; ++i) {
+ for (; i < instance->rule.define.used; ++i) {
- if (f_compare_dynamic_partial_string(process->rule.define.array[i].key.string, source, process->rule.define.array[i].key.used, content) == F_equal_to) {
- status = f_string_dynamic_append(process->rule.define.array[i].value, destination);
+ if (f_compare_dynamic_partial_string(instance->rule.define.array[i].key.string, source, instance->rule.define.array[i].key.used, content) == F_equal_to) {
+ status = f_string_dynamic_append(instance->rule.define.array[i].value, destination);
if (F_status_is_error(status)) return status;
break;
}
} // for
- if (i == process->rule.define.used) {
- 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;
+ if (i == instance->rule.define.used) {
+ controller_entry_t * const entry = instance->type == controller_instance_type_entry_e ? &instance->global->program->entry : &instance->global->program->exit;
for (i = 0; i < entry->define.used; ++i) {
} // for
if (i == entry->define.used) {
- i = process->rule.define.used;
+ i = instance->rule.define.used;
}
}
- if (i == process->rule.define.used) {
+ if (i == instance->rule.define.used) {
f_string_static_t buffer = f_string_static_t_initialize;
buffer.used = (content.stop - content.start) + 1;
memcpy(buffer_string, source.string + content.start, sizeof(f_char_t) * buffer.used);
buffer_string[buffer.used] = 0;
buffer.string = buffer_string;
- process->cache.action.generic.used = 0;
+ instance->cache.action.generic.used = 0;
- status = f_environment_get(buffer, &process->cache.action.generic);
+ status = f_environment_get(buffer, &instance->cache.action.generic);
if (F_status_is_error(status)) return status;
- status = f_string_dynamic_append(process->cache.action.generic, destination);
+ status = f_string_dynamic_append(instance->cache.action.generic, destination);
if (F_status_is_error(status)) return status;
}
}
else if (f_compare_dynamic_partial_string(controller_parameter_s.string, source, controller_parameter_s.used, vocabulary) == F_equal_to) {
f_number_unsigned_t i = 0;
- for (; i < process->rule.parameter.used; ++i) {
+ for (; i < instance->rule.parameter.used; ++i) {
- if (f_compare_dynamic_partial_string(process->rule.parameter.array[i].key.string, source, process->rule.parameter.array[i].key.used, content) == F_equal_to) {
- status = f_string_dynamic_append(process->rule.parameter.array[i].value, destination);
+ if (f_compare_dynamic_partial_string(instance->rule.parameter.array[i].key.string, source, instance->rule.parameter.array[i].key.used, content) == F_equal_to) {
+ status = f_string_dynamic_append(instance->rule.parameter.array[i].value, destination);
if (F_status_is_error(status)) return status;
break;
}
} // for
- if (i == process->rule.parameter.used) {
- 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;
+ if (i == instance->rule.parameter.used) {
+ controller_entry_t * const entry = instance->type == controller_instance_type_entry_e ? &instance->global->program->entry : &instance->global->program->exit;
for (i = 0; i < entry->parameter.used; ++i) {
}
}
else if (f_compare_dynamic_partial_string(controller_program_s.string, source, controller_program_s.used, vocabulary) == F_equal_to) {
- f_string_static_t * const argv = ((controller_main_t *) process->main_data)->program.parameters.arguments.array;
- f_console_parameters_t * const parameters = &((controller_main_t *) process->main_data)->program.parameters;
+ f_string_static_t * const argv = instance->global->main.program.parameters.arguments.array;
+ f_console_parameters_t * const parameters = &instance->global->main.program.parameters;
const f_string_static_t options[] = {
f_console_standard_long_light_s,
return F_okay;
}
-#endif // _di_controller_main_rule_expand_iki_
+#endif // _di_controller_rule_expand_iki_
#ifdef __cplusplus
} // extern "C"
* @return
* F_okay on success.
*
- * Errors (with error bit) from: controller_main_rule_expand_iki().
+ * Errors (with error bit) from: controller_rule_expand_iki().
*
- * @see controller_main_rule_expand_iki()
+ * @see controller_rule_expand_iki()
*/
-#ifndef _di_controller_main_rule_expand_
- extern f_status_t controller_main_rule_expand(controller_global_t * const global, const controller_main_rule_action_t action, controller_instance_t * const instance);
-#endif // _di_controller_main_rule_expand_
+#ifndef _di_controller_rule_expand_
+ extern f_status_t controller_rule_expand(controller_global_t * const global, const controller_rule_action_t action, controller_instance_t * const instance);
+#endif // _di_controller_rule_expand_
/**
* Expand a single IKI variable into the buffer.
* @see f_environment_get()
* @see f_string_dynamic_append()
*/
-#ifndef _di_controller_main_rule_expand_iki_
- extern f_status_t controller_main_rule_expand_iki(controller_instance_t * const instance, const f_string_static_t source, const f_range_t vocabulary, const f_range_t content, f_string_dynamic_t * const destination);
-#endif // _di_controller_main_rule_expand_iki_
+#ifndef _di_controller_rule_expand_iki_
+ extern f_status_t controller_rule_expand_iki(controller_instance_t * const instance, const f_string_static_t source, const f_range_t vocabulary, const f_range_t content, f_string_dynamic_t * const destination);
+#endif // _di_controller_rule_expand_iki_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_rule_instance_
- f_status_t controller_main_rule_instance(controller_global_t * const global, controller_instance_t * const instance) {
+#ifndef _di_controller_rule_instance_
+ f_status_t controller_rule_instance(controller_instance_t * const instance) {
- if (!global || !instance) return F_status_set_error(F_parameter);
+ if (!instance || !instance->global) return F_status_set_error(F_parameter);
+
+ controller_global_t * const global = instance->global;
switch (instance->action) {
- case controller_main_rule_action_type_freeze_e:
- case controller_main_rule_action_type_kill_e:
- case controller_main_rule_action_type_pause_e:
- case controller_main_rule_action_type_reload_e:
- case controller_main_rule_action_type_restart_e:
- case controller_main_rule_action_type_resume_e:
- case controller_main_rule_action_type_start_e:
- case controller_main_rule_action_type_stop_e:
- case controller_main_rule_action_type_thaw_e:
+ case controller_rule_action_type_freeze_e:
+ case controller_rule_action_type_kill_e:
+ case controller_rule_action_type_pause_e:
+ case controller_rule_action_type_reload_e:
+ case controller_rule_action_type_restart_e:
+ case controller_rule_action_type_resume_e:
+ case controller_rule_action_type_start_e:
+ case controller_rule_action_type_stop_e:
+ case controller_rule_action_type_thaw_e:
break;
default:
controller_lock_print(global->main->program.error.to, global->thread);
fl_print_format("%r%[%QUnsupported action type '%]", global->main->program.error.to, f_string_eol_s, global->main->program.error.context, global->main->program.error.prefix, global->main->program.error.context);
- fl_print_format(f_string_format_r_single_s.string, global->main->program.error.to, global->main->program.error.notable, controller_main_rule_action_type_name(instance->action), global->main->program.error.notable);
+ fl_print_format(f_string_format_r_single_s.string, global->main->program.error.to, global->main->program.error.notable, controller_convert_rule_action_type_string(instance->action), global->main->program.error.notable);
fl_print_format("%[' while attempting to execute rule.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_true);
+ controller_print_rule_error_cache(global->error, instance->cache.action, F_true);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
}
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true);
+ controller_print_rule_error(global->error, instance->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true);
return status;
}
status = f_string_dynamic_append(instance->rule.alias, &instance->cache.action.name_file);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true);
+ controller_print_rule_error(global->error, instance->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true);
return status;
}
}
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, instance->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true);
+ controller_print_rule_error(global->error, instance->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true);
return status;
}
if ((instance->options & controller_instance_option_simulate_e) && (instance->options & controller_instance_option_validate_e)) {
- controller_main_rule_validate(global, instance->rule, instance->action, instance->options, &instance->cache);
+ controller_rule_validate(global, instance->rule, instance->action, instance->options, &instance->cache);
}
f_number_unsigned_t i = 0;
// i==0 is need, i==1 is want, i==2 is wish.
// Loop through all dependencies: wait for depedency, execute dependency, fail due to missing required dependency, or skip unrequired missing dependencies.
- for (i = 0; i < 3 && controller_main_thread_is_enabled_instance(instance, global->thread); ++i) {
+ for (i = 0; i < 3 && controller_thread_is_enabled_instance(instance); ++i) {
- for (j = 0; j < dynamics[i]->used && controller_main_thread_is_enabled_instance(instance, global->thread); ++j) {
+ for (j = 0; j < dynamics[i]->used && controller_thread_is_enabled_instance(instance); ++j) {
id_dependency = 0;
dependency = 0;
found = F_false;
- status_lock = controller_main_lock_read_instance(instance, global->thread, &global->thread->lock.instance);
+ status_lock = controller_lock_read_instance(instance, &global->thread->lock.instance);
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 (F_status_is_error(status)) {
if (F_status_set_fine(status) == F_lock) {
- if (!controller_main_thread_is_enabled_instance_type(instance->type, global->thread)) {
+ if (!controller_thread_is_enabled_instance_type(instance->type, global->thread)) {
return F_status_set_error(F_interrupt);
}
}
if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
controller_lock_print(global->main->program.error.to, global->thread);
- controller_main_print_rule_item_error_rule_not_loaded(&global->main->program.error, dynamics[i]->array[j]);
- controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_false);
+ controller_print_rule_item_error_rule_not_loaded(&global->main->program.error, dynamics[i]->array[j]);
+ controller_print_rule_error_cache(global->error, instance->cache.action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
dependency = global->thread->instances.array[id_dependency];
- status_lock = controller_main_lock_read_instance(instance, global->thread, &dependency->active);
+ status_lock = controller_lock_read_instance(instance, &dependency->active);
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);
else {
f_thread_unlock(&global->thread->lock.instance);
- status_lock = controller_main_lock_read_instance(instance, global->thread, &global->thread->lock.rule);
+ status_lock = controller_lock_read_instance(instance, &global->thread->lock.rule);
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 (i == 0) {
controller_lock_print(global->main->program.error.to, global->thread);
- controller_main_print_rule_item_error_need_want_wish(&global->main->program.error, strings[i], dynamics[i]->array[j], "is not found");
- controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_true);
+ controller_print_rule_item_error_need_want_wish(&global->main->program.error, strings[i], dynamics[i]->array[j], "is not found");
+ controller_print_rule_error_cache(global->error, instance->cache.action, F_true);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) {
controller_lock_print(global->main->program.warning.to, global->thread);
- controller_main_print_rule_item_error_need_want_wish(&global->main->program.warning, strings[i], dynamics[i]->array[j], "is not found");
+ controller_print_rule_item_error_need_want_wish(&global->main->program.warning, strings[i], dynamics[i]->array[j], "is not found");
- controller_main_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true);
+ controller_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true);
controller_unlock_print_flush(global->main->program.warning.to, global->thread);
}
}
}
else if (found) {
- status_lock = controller_main_lock_read_instance(instance, global->thread, &global->thread->lock.rule);
+ status_lock = controller_lock_read_instance(instance, &global->thread->lock.rule);
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);
f_thread_unlock(&global->thread->lock.rule);
- status_lock = controller_main_lock_read_instance(instance, global->thread, &dependency->lock);
+ status_lock = controller_lock_read_instance(instance, &dependency->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, global->thread);
else if (dependency->state == controller_instance_state_active_e || dependency->state == controller_instance_state_busy_e) {
f_thread_unlock(&dependency->lock);
- status = controller_instance_wait(global, dependency);
+ status = controller_instance_wait(dependency);
if (F_status_is_error(status) && !(instance->options & controller_instance_option_simulate_e)) break;
status = dependency->rule.status[instance->action];
}
else {
- status_lock = controller_main_lock_read_instance(instance, global->thread, &global->thread->lock.rule);
+ status_lock = controller_lock_read_instance(instance, &global->thread->lock.rule);
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);
status = status_lock;
}
- else if (controller_main_rule_status_is_available(instance->action, global->program->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);
}
// Synchronously execute dependency.
- status = controller_main_rule_instance_begin(global, 0, alias_other_buffer, instance->action, options_instance, instance->type, instance->stack, dependency->cache);
+ status = controller_rule_instance_begin(global, 0, alias_other_buffer, instance->action, options_instance, instance->type, instance->stack, dependency->cache);
if (status == F_child || F_status_set_fine(status) == F_interrupt) {
f_thread_unlock(&dependency->active);
if (i == 0 || i == 1 || F_status_set_fine(status) == F_memory_not) {
controller_lock_print(global->main->program.error.to, global->thread);
- controller_main_print_rule_item_error_need_want_wish(&global->main->program.error, strings[i], alias_other_buffer, "failed during execution");
- controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_true);
+ controller_print_rule_item_error_need_want_wish(&global->main->program.error, strings[i], alias_other_buffer, "failed during execution");
+ controller_print_rule_error_cache(global->error, instance->cache.action, F_true);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) {
controller_lock_print(global->main->program.warning.to, global->thread);
- controller_main_print_rule_item_error_need_want_wish(&global->main->program.warning, strings[i], alias_other_buffer, "failed during execution");
+ controller_print_rule_item_error_need_want_wish(&global->main->program.warning, strings[i], alias_other_buffer, "failed during execution");
- controller_main_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true);
+ controller_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true);
controller_unlock_print_flush(global->main->program.warning.to, global->thread);
}
}
}
- if (!controller_main_thread_is_enabled_instance(instance, global->thread)) {
+ if (!controller_thread_is_enabled_instance(instance)) {
f_thread_unlock(&dependency->active);
break;
}
if (F_status_is_error_not(status_lock)) {
- status_lock = controller_main_lock_read_instance(instance, global->thread, &global->thread->lock.rule);
+ status_lock = controller_lock_read_instance(instance, &global->thread->lock.rule);
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 (F_status_is_error(status_lock)) {
if (F_status_is_error(status_lock)) {
- controller_main_print_rule_item_error_need_want_wish(&global->main->program.error, strings[i], alias_other_buffer, "due to lock failure");
+ controller_print_rule_item_error_need_want_wish(&global->main->program.error, strings[i], alias_other_buffer, "due to lock failure");
}
status = status_lock;
}
- else if (controller_main_rule_status_is_error(instance->action, global->program->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) {
controller_lock_print(global->main->program.error.to, global->thread);
- controller_main_print_rule_item_error_need_want_wish(&global->main->program.error, strings[i], alias_other_buffer, "is in a failed state");
+ controller_print_rule_item_error_need_want_wish(&global->main->program.error, strings[i], alias_other_buffer, "is in a failed state");
- controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_true);
+ controller_print_rule_error_cache(global->error, instance->cache.action, F_true);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) {
controller_lock_print(global->main->program.warning.to, global->thread);
- controller_main_print_rule_item_error_need_want_wish(&global->main->program.warning, strings[i], alias_other_buffer, "is in a failed state");
+ controller_print_rule_item_error_need_want_wish(&global->main->program.warning, strings[i], alias_other_buffer, "is in a failed state");
- controller_main_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true);
+ controller_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true);
controller_unlock_print_flush(global->main->program.warning.to, global->thread);
}
return status;
}
- if (!controller_main_thread_is_enabled_instance(instance, global->thread)) {
+ if (!controller_thread_is_enabled_instance(instance)) {
return F_status_set_error(F_interrupt);
}
if ((instance->options & controller_instance_option_wait_e) && F_status_is_error_not(status) && (instance->options & controller_instance_option_validate_e)) {
- status_lock = controller_main_rule_wait_all_instance_type(global, instance->type, F_false);
+ status_lock = controller_rule_wait_all_instance_type(global, instance->type, F_false);
if (F_status_set_fine(status_lock) == F_interrupt) {
return status_lock;
fl_print_format("%r%[%QThe rule '%]", global->main->program.error.to, f_string_eol_s, global->main->program.error.context, global->main->program.error.prefix, global->main->program.error.context);
fl_print_format(f_string_format_Q_single_s.string, global->main->program.error.to, global->main->program.error.notable, instance->rule.name, global->main->program.error.notable);
fl_print_format("%[' has no '%]", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context);
- fl_print_format(f_string_format_r_single_s.string, global->main->program.error.to, global->main->program.error.notable, controller_main_rule_action_type_name(instance->action), global->main->program.error.notable);
+ fl_print_format(f_string_format_r_single_s.string, global->main->program.error.to, global->main->program.error.notable, controller_convert_rule_action_type_string(instance->action), global->main->program.error.notable);
fl_print_format("%[' action to execute.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s);
}
else {
fl_print_format("%[') to execute.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s);
}
- controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_true);
+ controller_print_rule_error_cache(global->error, instance->cache.action, F_true);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
}
if (F_status_is_error_not(status)) {
- status = controller_main_rule_execute(global, instance->action, instance->options, instance);
+ status = controller_rule_execute(global, instance->action, instance->options, instance);
if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) {
return status;
}
if (F_status_is_error(status)) {
- controller_main_print_rule_item_error(global->error, instance->cache.action, F_true, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, instance->cache.action, F_true, F_status_set_fine(status));
}
}
}
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_write_instance(instance, global->thread, &instance->lock);
+ status_lock = controller_lock_write_instance(instance, &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, global->thread);
if (F_status_set_fine(status) != F_interrupt) {
- status = controller_main_lock_read_instance(instance, global->thread, &instance->lock);
+ status = controller_lock_read_instance(instance, &instance->lock);
if (F_status_is_error_not(status)) return status_lock;
}
}
if (F_status_is_error(status)) {
- instance->rule.status[instance->action] = controller_main_error_simplify(F_status_set_fine(status));
+ instance->rule.status[instance->action] = controller_error_simplify(F_status_set_fine(status));
}
else {
instance->rule.status[instance->action] = status;
}
- status_lock = controller_main_lock_write_instance(instance, global->thread, &global->thread->lock.rule);
+ status_lock = controller_lock_write_instance(instance, &global->thread->lock.rule);
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);
f_thread_unlock(&instance->lock);
- status = controller_main_lock_read_instance(instance, global->thread, &instance->lock);
+ status = controller_lock_read_instance(instance, &instance->lock);
if (F_status_is_error_not(status)) return status_lock;
return F_status_set_error(F_lock);
f_thread_unlock(&global->thread->lock.rule);
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_read_instance(instance, global->thread, &instance->lock);
+ status_lock = controller_lock_read_instance(instance, &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, global->thread);
return instance->rule.status[instance->action];
}
-#endif // _di_controller_main_rule_instance_
+#endif // _di_controller_rule_instance_
-#ifndef _di_controller_main_rule_instance_begin_
- f_status_t controller_main_rule_instance_begin(controller_global_t * const global, const uint8_t options_force, const f_string_static_t alias_rule, const uint8_t action, const uint8_t options, const uint8_t type, const f_number_unsigneds_t stack, const controller_cache_t cache) {
+#ifndef _di_controller_rule_instance_begin_
+ f_status_t controller_rule_instance_begin(controller_global_t * const global, const uint8_t options_force, const f_string_static_t alias_rule, const uint8_t action, const uint8_t options, const uint8_t type, const f_number_unsigneds_t stack, const controller_cache_t cache) {
if (!global) return F_status_set_error(F_parameter);
- if (!controller_main_thread_is_enabled_instance_type(type, global->thread)) {
+ if (!controller_thread_is_enabled_instance_type(type, global->thread)) {
return F_status_set_error(F_interrupt);
}
controller_instance_t *instance = 0;
- status = controller_main_lock_read_instance_type(type, global->thread, &global->thread->lock.instance);
+ status = controller_lock_read_instance_type(type, global->thread, &global->thread->lock.instance);
if (F_status_is_error(status)) {
controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status), F_true, global->thread);
if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
controller_lock_print(global->main->program.error.to, global->thread);
- controller_main_print_rule_item_error_rule_not_loaded(&global->main->program.error, alias_rule);
- controller_main_print_rule_error_cache(&global->error, cache.action, F_false);
+ controller_print_rule_item_error_rule_not_loaded(&global->main->program.error, alias_rule);
+ controller_print_rule_error_cache(global->error, cache.action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
instance = global->thread->instances.array[at];
- status = controller_main_lock_read_instance_type(type, global->thread, &instance->active);
+ status = controller_lock_read_instance_type(type, global->thread, &instance->active);
if (F_status_is_error(status)) {
controller_lock_print_error_critical(&global->main->program.error, F_status_set_fine(status), F_true, global->thread);
- controller_main_print_rule_item_error(global->error, cache.action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache.action, F_false, F_status_set_fine(status));
f_thread_unlock(&global->thread->lock.instance);
return status;
}
- status_lock = controller_main_lock_write_instance(instance, global->thread, &instance->lock);
+ status_lock = controller_lock_write_instance(instance, &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, global->thread);
// The thread is done, so close the thread.
if (instance->state == controller_instance_state_done_e) {
- controller_main_thread_join(&instance->id_thread);
+ controller_thread_join(&instance->id_thread);
f_thread_mutex_lock(&instance->wait_lock);
f_thread_condition_signal_all(&instance->wait);
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_write_instance(instance, global->thread, &instance->lock);
+ status_lock = controller_lock_write_instance(instance, &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, global->thread);
instance->options = options;
instance->type = type;
- macro_f_time_simple_t_clear(instance->cache.timestamp)
-
instance->cache.ats.used = 0;
instance->cache.stack.used = 0;
instance->cache.comments.used = 0;
instance->cache.action.generic.used = 0;
instance->cache.range_action.start = 1;
instance->cache.range_action.stop = 0;
+ instance->cache.timestamp.seconds = 0;
+ instance->cache.timestamp.seconds_nano = 0;
instance->stack.used = 0;
}
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_memory_array_resize), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_memory_array_resize), F_status_set_fine(status));
}
else {
for (f_number_unsigned_t i = 0; i < stack.used; ++i) {
status = f_string_dynamic_append(cache.action.name_item, &instance->cache.action.name_item);
}
else {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status));
}
}
if (F_status_is_error_not(status)) {
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);
+ status = f_thread_create(0, &instance->id_thread, controller_thread_instance_other, (void *) instance);
}
else {
- status = f_thread_create(0, &instance->id_thread, controller_main_thread_instance_normal, (void *) instance);
+ status = f_thread_create(0, &instance->id_thread, controller_thread_instance_normal, (void *) instance);
}
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_thread_create), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_thread_create), F_status_set_fine(status));
}
}
else {
- status = controller_main_rule_instance_do(options_force, instance);
+ status = controller_rule_instance_do(options_force, instance);
if (status == F_child || F_status_set_fine(status) == F_interrupt) {
f_thread_unlock(&instance->active);
if (!action || F_status_is_error(status) && (instance->state == controller_instance_state_active_e || instance->state == controller_instance_state_busy_e)) {
{
- status_lock = controller_main_lock_write_instance(instance, global->thread, &instance->lock);
+ status_lock = controller_lock_write_instance(instance, &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, global->thread);
return F_okay;
}
-#endif // _di_controller_main_rule_instance_begin_
+#endif // _di_controller_rule_instance_begin_
-#ifndef _di_controller_main_rule_instance_do_
- f_status_t controller_main_rule_instance_do(const uint8_t options_force, controller_instance_t * const instance) {
+#ifndef _di_controller_rule_instance_do_
+ f_status_t controller_rule_instance_do(const uint8_t options_force, controller_instance_t * const instance) {
if (!instance) return F_status_set_error(F_parameter);
f_status_t status_lock = F_okay;
- 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_e) {
- status_lock = controller_main_lock_read_instance(instance, global->thread, &instance->active);
+ status_lock = controller_lock_read_instance(instance, &instance->active);
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);
}
}
- status_lock = controller_main_lock_read_instance(instance, global->thread, &instance->lock);
+ status_lock = controller_lock_read_instance(instance, &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, global->thread);
const f_number_unsigned_t used_original_stack = instance->stack.used;
- status_lock = controller_main_lock_read_instance(instance, global->thread, &global->thread->lock.rule);
+ status_lock = controller_lock_read_instance(instance, &global->thread->lock.rule);
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 (controller_rule_find(instance->rule.alias, global->program->rules, &id_rule) == F_true) {
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_write_instance(instance, global->thread, &instance->lock);
+ status_lock = controller_lock_write_instance(instance, &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, global->thread);
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_read_instance(instance, global->thread, &instance->lock);
+ status_lock = controller_lock_read_instance(instance, &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, global->thread);
f_thread_unlock(&global->thread->lock.rule);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(controller_rule_copy), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(controller_rule_copy), F_status_set_fine(status));
}
else if (!instance->action) {
f_thread_unlock(&instance->active);
}
- return F_instance_not;
+ return F_process_not;
}
else {
- for (f_number_unsigned_t i = 0; i < instance->stack.used && controller_main_thread_is_enabled_instance(instance, global->thread); ++i) {
+ for (f_number_unsigned_t i = 0; i < instance->stack.used && controller_thread_is_enabled_instance(instance); ++i) {
if (instance->stack.array[i] == id_rule) {
if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
fl_print_format(f_string_format_Q_single_s.string, global->main->program.error.to, global->main->program.error.notable, instance->rule.alias, global->main->program.error.notable);
fl_print_format("%[' is already on the execution dependency stack, this recursion is prohibited.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_true);
+ controller_print_rule_error_cache(global->error, instance->cache.action, F_true);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
}
} // for
- if (!controller_main_thread_is_enabled_instance(instance, global->thread)) {
+ if (!controller_thread_is_enabled_instance(instance)) {
f_thread_unlock(&instance->lock);
if (options_force & controller_instance_option_asynchronous_e) {
status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_number_unsigned_t), (void **) &instance->stack.array, &instance->stack.used, &instance->stack.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_print_error_status(&global->main->program.error, macro_controller_f(f_memory_array_increase), F_status_set_fine(status));
}
else {
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_write_instance(instance, global->thread, &instance->lock);
+ status_lock = controller_lock_write_instance(instance, &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, global->thread);
f_thread_unlock(&instance->lock);
- status_lock = controller_main_lock_read_instance(instance, global->thread, &instance->lock);
+ status_lock = controller_lock_read_instance(instance, &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, global->thread);
}
if (F_status_is_error_not(status)) {
- status = controller_main_rule_instance(global, instance);
+ status = controller_rule_instance(instance);
}
}
else {
if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
controller_lock_print(global->main->program.error.to, global->thread);
- controller_main_print_rule_item_error_rule_not_loaded(&global->main->program.error, instance->rule.alias);
- controller_main_print_rule_error_cache(&global->error, instance->cache.action, F_false);
+ controller_print_rule_item_error_rule_not_loaded(&global->main->program.error, instance->rule.alias);
+ controller_print_rule_error_cache(global->error, instance->cache.action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
return status;
}
- status_lock = controller_main_lock_write_instance(instance, global->thread, &global->thread->lock.rule);
+ status_lock = controller_lock_write_instance(instance, &global->thread->lock.rule);
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);
f_thread_unlock(&instance->lock);
}
- if (F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock && !controller_main_thread_is_enabled_instance(instance, global->thread)) {
+ if (F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock && !controller_thread_is_enabled_instance(instance)) {
if (options_force & controller_instance_option_asynchronous_e) {
f_thread_unlock(&instance->active);
}
return F_status_set_error(F_interrupt);
}
- status_lock = controller_main_lock_write_instance(instance, global->thread, &instance->lock);
+ status_lock = controller_lock_write_instance(instance, &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, global->thread);
f_thread_unlock(&instance->active);
}
- if (controller_main_thread_is_enabled_instance(instance, global->thread)) {
+ if (controller_thread_is_enabled_instance(instance)) {
return status;
}
return F_status_set_error(F_interrupt);
}
-#endif // _di_controller_main_rule_instance_do_
+#endif // _di_controller_rule_instance_do_
#ifdef __cplusplus
} // extern "C"
*
* The rule status will be updated by this function.
*
- * @param global
- * The global data.
- *
- * Must not be NULL.
- *
- * This does not alter global.main.setting.state.status.
* @param instance
* The instance data for processing this rule.
*
+ * Must not be NULL.
+ *
* @return
* F_okay on success.
* F_child on child instance exiting.
* F_interrupt (with error bit) on receiving a instance signal, such as an interrupt signal.
* F_lock (with error bit) if failed to re-establish read lock on instance->lock while returning.
*
- * Errors (with error bit) from: controller_main_lock_read().
- * Errors (with error bit) from: controller_main_lock_write().
+ * Errors (with error bit) from: controller_lock_read().
+ * Errors (with error bit) from: controller_lock_write().
*/
-#ifndef _di_controller_main_rule_instance_
- extern f_status_t controller_main_rule_instance(controller_global_t * const global, controller_instance_t * const instance);
-#endif // _di_controller_main_rule_instance_
+#ifndef _di_controller_rule_instance_
+ extern f_status_t controller_rule_instance(controller_instance_t * const instance);
+#endif // _di_controller_rule_instance_
/**
* Synchronously or asynchronously begin processing some rule.
* F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal.
* F_recurse (with error bit) on recursion error (the instance is already on the instance stack).
*
- * Status from: controller_main_rule_instance().
+ * Status from: controller_rule_instance().
*
- * Errors (with error bit) from: controller_main_rule_instance().
+ * Errors (with error bit) from: controller_rule_instance().
* Errors (with error bit) from: f_string_dynamic_append().
* Errors (with error bit) from: f_thread_create().
*
- * @see controller_main_rule_instance()
+ * @see controller_rule_instance()
* @see f_string_dynamic_append()
* @see f_thread_create()
*/
-#ifndef _di_controller_main_rule_instance_begin_
- extern f_status_t controller_main_rule_instance_begin(controller_global_t * const global, const uint8_t options_force, const f_string_static_t alias_rule, const uint8_t action, const uint8_t options, const uint8_t type, const f_number_unsigneds_t stack, const controller_cache_t cache);
-#endif // _di_controller_main_rule_instance_begin_
+#ifndef _di_controller_rule_instance_begin_
+ extern f_status_t controller_rule_instance_begin(controller_global_t * const global, const uint8_t options_force, const f_string_static_t alias_rule, const uint8_t action, const uint8_t options, const uint8_t type, const f_number_unsigneds_t stack, const controller_cache_t cache);
+#endif // _di_controller_rule_instance_begin_
/**
- * Helper for calling controller_main_rule_instance().
+ * Helper for calling controller_rule_instance().
*
* This does all the preparation work that needs to be synchronously performed within the same thread.
* This will copy the rule by the alias to the instance structure.
* F_found_not (with error bit) if unable to for a instance for the given rule id.
* F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal.
*
- * Status from: controller_main_rule_instance().
+ * Status from: controller_rule_instance().
*
* Errors (with error bit) from: controller_rule_copy().
- * Errors (with error bit) from: controller_main_rule_instance().
+ * Errors (with error bit) from: controller_rule_instance().
*
* @see controller_rule_copy()
- * @see controller_main_rule_instance()
- * @see controller_main_rule_instance_begin()
+ * @see controller_rule_instance()
+ * @see controller_rule_instance_begin()
*/
-#ifndef _di_controller_main_rule_instance_do_
- extern f_status_t controller_main_rule_instance_do(const uint8_t options_force, controller_instance_t * const instance);
-#endif // _di_controller_main_rule_instance_do_
+#ifndef _di_controller_rule_instance_do_
+ extern f_status_t controller_rule_instance_do(const uint8_t options_force, controller_instance_t * const instance);
+#endif // _di_controller_rule_instance_do_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_rule_status_is_available_
- f_status_t controller_main_rule_status_is_available(const uint8_t action, const controller_rule_t rule) {
+#ifndef _di_controller_rule_status_is_available_
+ f_status_t controller_rule_status_is_available(const uint8_t action, const controller_rule_t rule) {
return F_status_is_error_not(rule.status[0]) && rule.status[action] == F_known_not;
}
-#endif // _di_controller_main_rule_status_is_available_
+#endif // _di_controller_rule_status_is_available_
-#ifndef _di_controller_main_rule_status_is_error_
- f_status_t controller_main_rule_status_is_error(const uint8_t action, const controller_rule_t rule) {
+#ifndef _di_controller_rule_status_is_error_
+ f_status_t controller_rule_status_is_error(const uint8_t action, const controller_rule_t rule) {
return F_status_is_error(rule.status[0]) || F_status_is_error(rule.status[action]);
}
-#endif // _di_controller_main_rule_status_is_error_
+#endif // _di_controller_rule_status_is_error_
#ifdef __cplusplus
} // extern "C"
* F_true on available (status is F_known_not).
* F_false on unavailable.
*/
-#ifndef _di_controller_main_rule_status_is_available_
- extern f_status_t controller_main_rule_status_is_available(const uint8_t action, const controller_rule_t rule);
-#endif // _di_controller_main_rule_status_is_available_
+#ifndef _di_controller_rule_status_is_available_
+ extern f_status_t controller_rule_status_is_available(const uint8_t action, const controller_rule_t rule);
+#endif // _di_controller_rule_status_is_available_
/**
* Check to see if the given Rule has status is designated as an error for the given Rule Action.
* F_true if status represents an error.
* F_false if status does not represent an error.
*/
-#ifndef _di_controller_main_rule_status_is_error_
- extern f_status_t controller_main_rule_status_is_error(const uint8_t action, const controller_rule_t rule);
-#endif // _di_controller_main_rule_status_is_error_
+#ifndef _di_controller_rule_status_is_error_
+ extern f_status_t controller_rule_status_is_error(const uint8_t action, const controller_rule_t rule);
+#endif // _di_controller_rule_status_is_error_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_rule_item_read_
- f_status_t controller_main_rule_item_read(controller_global_t * const global, const bool is_normal, controller_cache_t * const cache, controller_rule_item_t * const item) {
+#ifndef _di_controller_rule_item_read_
+ f_status_t controller_rule_item_read(controller_global_t * const global, const bool is_normal, controller_cache_t * const cache, controller_rule_item_t * const item) {
if (!global || !cache || !item) return F_status_set_error(F_parameter);
f_status_t status = F_okay;
- controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, global->thread);
- f_state_t state = macro_f_state_t_initialize_1(controller_allocation_large_d, controller_allocation_small_d, F_okay, 0, 0, 0, &controller_main_thread_signal_state_fss, 0, (void *) &custom, 0);
+ controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, global);
+ f_state_t state = macro_f_state_t_initialize_1(controller_allocation_large_d, controller_allocation_small_d, F_okay, 0, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0);
f_range_t range = macro_f_range_t_initialize_2(cache->buffer_item.used);
f_number_unsigned_t last = 0;
fl_fss_extended_list_object_read(cache->buffer_item, &range, &cache->range_action, &cache->delimits, &state);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(fl_fss_extended_list_object_read), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(fl_fss_extended_list_object_read), F_status_set_fine(status));
break;
}
fl_fss_extended_object_read(cache->buffer_item, &range, &cache->range_action, 0, &cache->delimits, &state);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(fl_fss_extended_object_read), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(fl_fss_extended_object_read), F_status_set_fine(status));
break;
}
f_fss_apply_delimit(cache->delimits, &cache->buffer_item, &state);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_fss_apply_delimit), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_fss_apply_delimit), F_status_set_fine(status));
break;
}
f_fss_count_lines(cache->buffer_item, cache->range_action.start, &cache->action.line_action, &state);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_fss_count_lines), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_fss_count_lines), F_status_set_fine(status));
break;
}
status = f_rip_dynamic_partial_nulless(cache->buffer_item, cache->range_action, &cache->action.name_action);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
break;
}
if (f_compare_dynamic(controller_freeze_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_freeze_e;
+ type = controller_rule_action_type_freeze_e;
}
else if (f_compare_dynamic(controller_group_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_group_e;
+ type = controller_rule_action_type_group_e;
}
else if (f_compare_dynamic(controller_kill_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_kill_e;
+ type = controller_rule_action_type_kill_e;
}
else if (f_compare_dynamic(controller_pause_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_pause_e;
+ type = controller_rule_action_type_pause_e;
}
else if (f_compare_dynamic(controller_pid_file_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_pid_file_e;
+ type = controller_rule_action_type_pid_file_e;
}
else if (f_compare_dynamic(controller_reload_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_reload_e;
+ type = controller_rule_action_type_reload_e;
}
else if (f_compare_dynamic(controller_rerun_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_rerun_e;
+ type = controller_rule_action_type_rerun_e;
}
else if (f_compare_dynamic(controller_restart_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_restart_e;
+ type = controller_rule_action_type_restart_e;
}
else if (f_compare_dynamic(controller_resume_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_resume_e;
+ type = controller_rule_action_type_resume_e;
}
else if (f_compare_dynamic(controller_start_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_start_e;
+ type = controller_rule_action_type_start_e;
}
else if (f_compare_dynamic(controller_stop_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_stop_e;
+ type = controller_rule_action_type_stop_e;
}
else if (f_compare_dynamic(controller_thaw_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_thaw_e;
+ type = controller_rule_action_type_thaw_e;
}
else if (f_compare_dynamic(controller_user_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_user_e;
+ type = controller_rule_action_type_user_e;
}
else if (f_compare_dynamic(controller_with_s, cache->action.name_action) == F_equal_to) {
- type = controller_main_rule_action_type_with_e;
+ type = controller_rule_action_type_with_e;
}
else {
if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) {
fl_print_format(f_string_format_Q_single_s.string, global->main->program.warning.to, global->main->program.warning.notable, cache->action.name_action, global->main->program.warning.notable);
fl_print_format(f_string_format_sentence_end_quote_s.string, global->main->program.warning.to, global->main->program.warning.context, global->main->program.warning.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->main->program.warning, cache->action, F_true);
+ controller_print_rule_error_cache(&global->main->program.warning, cache->action, F_true);
controller_unlock_print_flush(global->main->program.warning.to, global->thread);
}
}
if (multiple) {
- if (type == controller_main_rule_action_type_group_e || type == controller_main_rule_action_type_pid_file_e || type == controller_main_rule_action_type_user_e) {
+ if (type == controller_rule_action_type_group_e || type == controller_rule_action_type_pid_file_e || type == controller_rule_action_type_user_e) {
if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
controller_lock_print(global->main->program.error.to, global->thread);
break;
}
- method = controller_main_rule_action_method_extended_list_e;
+ method = controller_rule_action_method_extended_list_e;
}
else {
- method = controller_main_rule_action_method_extended_e;
+ method = controller_rule_action_method_extended_e;
}
- status = f_memory_array_increase_by(controller_allocation_small_d, sizeof(controller_main_rule_action_t), (void **) &item->actions.array, &item->actions.used, &item->actions.size);
+ 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(f_memory_array_increase_by), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_memory_array_increase_by), F_status_set_fine(status));
break;
}
- status = controller_main_rule_action_read(global, is_normal, type, method, cache, item, &item->actions, &range);
+ status = controller_rule_action_read(global, is_normal, type, method, cache, item, &item->actions, &range);
if (F_status_is_error(status)) break;
} // for
return status;
}
-#endif // _di_controller_main_rule_item_read_
+#endif // _di_controller_rule_item_read_
#ifdef __cplusplus
} // extern "C"
* Errors (with error bit) from: f_fss_count_lines().
* Errors (with error bit) from: f_string_dynamic_partial_append_nulless().
*
- * @see controller_main_rule_action_read()
+ * @see controller_rule_action_read()
* @see f_fss_count_lines()
* @see f_string_dynamic_partial_append_nulless()
*/
-#ifndef _di_controller_main_rule_item_read_
- extern f_status_t controller_main_rule_item_read(controller_global_t * const global, const bool is_normal, controller_cache_t * const cache, controller_rule_item_t * const item);
-#endif // _di_controller_main_rule_item_read_
+#ifndef _di_controller_rule_item_read_
+ extern f_status_t controller_rule_item_read(controller_global_t * const global, const bool is_normal, controller_cache_t * const cache, controller_rule_item_t * const item);
+#endif // _di_controller_rule_item_read_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_rule_parameters_read_
- f_status_t controller_main_rule_parameters_read(controller_global_t * const global, const f_string_static_t buffer, f_range_t * const object, f_ranges_t * const content, controller_main_rule_action_t * const action, f_state_t * const state) {
+#ifndef _di_controller_rule_parameters_read_
+ f_status_t controller_rule_parameters_read(controller_global_t * const global, const f_string_static_t buffer, f_range_t * const object, f_ranges_t * const content, controller_rule_action_t * const action, f_state_t * const state) {
if (!global || !object || !content || !action || !state) return F_status_set_error(F_parameter);
}
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, content ? macro_controller_f(f_memory_array_increase_by) : macro_controller_f(f_memory_array_increase), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, content ? macro_controller_f(f_memory_array_increase_by) : macro_controller_f(f_memory_array_increase), F_status_set_fine(status));
return status;
}
status = f_string_dynamic_partial_append_nulless(buffer, *object, &action->parameters.array[0]);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_partial_append_nulless), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_partial_append_nulless), F_status_set_fine(status));
return status;
}
}
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_memory_array_increase_by), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_memory_array_increase_by), F_status_set_fine(status));
return status;
}
status = f_string_dynamic_partial_append_nulless(buffer, content->array[i], &action->parameters.array[action->parameters.used]);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_partial_append_nulless), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_partial_append_nulless), F_status_set_fine(status));
return status;
}
fl_iki_read(&action->parameters.array[action->parameters.used], &range, &action->ikis.array[action->ikis.used], state);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(fl_iki_read), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(fl_iki_read), F_status_set_fine(status));
action->parameters.array[action->parameters.used].used = 0;
return F_okay;
}
-#endif // _di_controller_main_rule_parameters_read_
+#endif // _di_controller_rule_parameters_read_
#ifdef __cplusplus
} // extern "C"
* @see f_memory_array_increase_by()
* @see fl_iki_read()
*/
-#ifndef _di_controller_main_rule_parameters_read_
- extern f_status_t controller_main_rule_parameters_read(controller_global_t * const global, const f_string_static_t buffer, f_range_t * const object, f_ranges_t * const content, controller_main_rule_action_t * const action, f_state_t * const state);
-#endif // _di_controller_main_rule_parameters_read_
+#ifndef _di_controller_rule_parameters_read_
+ extern f_status_t controller_rule_parameters_read(controller_global_t * const global, const f_string_static_t buffer, f_range_t * const object, f_ranges_t * const content, controller_rule_action_t * const action, f_state_t * const state);
+#endif // _di_controller_rule_parameters_read_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_rule_read_
- f_status_t controller_main_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) {
+#ifndef _di_controller_rule_read_
+ 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) {
if (!global || !cache || !entry || !rule) return F_status_set_error(F_parameter);
rule->user = 0;
rule->nice = 0;
- macro_f_time_simple_t_clear(rule->timestamp);
+ rule->timestamp.seconds = 0;
+ rule->timestamp.seconds_nano = 0;
rule->alias.used = 0;
rule->engine.used = 0;
rule->cgroup.groups.array[i].used = 0;
} // for
- for (; i < controller_main_rule_action_type__enum_size_e; ++i) {
+ for (; i < controller_rule_action_type__enum_size_e; ++i) {
rule->status[i] = F_known_not;
} // for
rule->items.array[i].pid_file.used = 0;
rule->items.array[i].actions.used = 0;
- for (j = 0; j < controller_main_rule_action_execute_type__enum_size_e; ++j) {
+ for (j = 0; j < controller_rule_action_execute_type__enum_size_e; ++j) {
rule->items.array[i].reruns[j].is = 0;
status = f_string_dynamic_append_nulless(alias, &rule->alias);
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_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_append_nulless), F_status_set_fine(status));
}
else {
- status = controller_file_load(global, F_true, controller_rules_s, rule->alias, controller_rule_s, cache);
+ status = controller_file_load(global, cache, F_true, controller_rules_s, rule->alias, controller_rule_s);
}
if (F_status_is_error_not(status)) {
rule->timestamp = cache->timestamp;
if (cache->buffer_file.used) {
- controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, global->thread);
- f_state_t state = macro_f_state_t_initialize_1(controller_allocation_large_d, controller_allocation_small_d, F_okay, 0, 0, 0, &controller_main_thread_signal_state_fss, 0, (void *) &custom, 0);
+ controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, global);
+ f_state_t state = macro_f_state_t_initialize_1(controller_allocation_large_d, controller_allocation_small_d, F_okay, 0, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0);
f_range_t range = macro_f_range_t_initialize_2(cache->buffer_file.used);
fll_fss_basic_list_read(cache->buffer_file, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments, &state);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(fll_fss_basic_list_read), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(fll_fss_basic_list_read), F_status_set_fine(status));
}
else {
f_fss_apply_delimit(cache->delimits, &cache->buffer_file, &state);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_fss_apply_delimit), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_fss_apply_delimit), F_status_set_fine(status));
}
}
}
}
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(controller_rule_items_increase_by), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_memory_arrays_resize), F_status_set_fine(status));
}
else {
f_number_unsigned_t i = 0;
f_fss_count_lines(cache->buffer_file, cache->object_items.array[i].start, &cache->action.line_item, &global->main->setting.state);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_fss_count_lines), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_fss_count_lines), F_status_set_fine(status));
break;
}
status = f_rip_dynamic_partial_nulless(cache->buffer_file, cache->object_items.array[i], &cache->action.name_item);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
break;
}
fl_print_format(f_string_format_Q_single_s.string, global->main->program.warning.to, global->main->program.warning.notable, cache->action.name_item, global->main->program.warning.notable);
fl_print_format(f_string_format_sentence_end_quote_s.string, global->main->program.warning.to, global->main->program.warning.context, global->main->program.warning.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->main->program.warning, cache->action, F_true);
+ controller_print_rule_error_cache(&global->main->program.warning, cache->action, F_true);
controller_unlock_print_flush(global->main->program.warning.to, global->thread);
}
status = f_string_dynamic_partial_append(cache->buffer_file, cache->content_items.array[i].array[0], &cache->buffer_item);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
break;
}
rule->items.array[rule->items.used].with |= controller_with_session_same_d;
}
- status = controller_main_rule_item_read(global, is_normal, cache, &rule->items.array[rule->items.used]);
+ status = controller_rule_item_read(global, is_normal, cache, &rule->items.array[rule->items.used]);
if (F_status_is_error(status)) break;
++rule->items.used;
else {
for_item = F_false;
- status = controller_main_rule_setting_read(global, is_normal, *global->setting, cache, rule);
+ status = controller_rule_setting_read(global, is_normal, *global->setting, cache, rule);
if (F_status_is_error(status)) {
if (F_status_set_fine(status) == F_memory_not) break;
}
if (F_status_is_error(status)) {
- controller_main_print_rule_item_error(global->error, cache->action, for_item, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, for_item, F_status_set_fine(status));
- rule->status[0] = controller_main_error_simplify(F_status_set_fine(status));
+ rule->status[0] = controller_error_simplify(F_status_set_fine(status));
return rule->status[0];
}
return F_okay;
}
-#endif // _di_controller_main_rule_read_
+#endif // _di_controller_rule_read_
#ifdef __cplusplus
} // extern "C"
* @return
* F_okay on success.
*
- * Simplified status (with error bit) from controller_main_error_simplify() on failure.
+ * Simplified status (with error bit) from controller_error_simplify() on failure.
+ *
+ * @see controller_rule_item_read().
*
- * @see controller_rule_items_increase_by().
- * @see controller_main_rule_item_read().
* @see f_fss_count_lines().
* @see f_fss_apply_delimit().
+ * @see f_memory_arrays_resize().
* @see f_string_dynamic_partial_append().
* @see f_string_dynamic_partial_append_nulless().
* @see fll_fss_basic_list_read().
*/
-#ifndef _di_controller_main_rule_read_
- extern f_status_t controller_main_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_main_rule_read_
+#ifndef _di_controller_rule_read_
+ 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_
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef _di_controller_main_rule_setting_read_
- f_status_t controller_main_rule_setting_read(controller_global_t * const global, const bool is_normal, controller_cache_t * const cache, controller_rule_t * const rule) {
+#ifndef _di_controller_rule_setting_limit_type_identify_
+ uint8_t controller_rule_setting_limit_type_identify(const f_string_static_t limit) {
+
+ if (f_compare_dynamic(limit, controller_as_s) == F_equal_to) return controller_resource_limit_type_as_e;
+ if (f_compare_dynamic(limit, controller_core_s) == F_equal_to) return controller_resource_limit_type_core_e;
+ if (f_compare_dynamic(limit, controller_cpu_s) == F_equal_to) return controller_resource_limit_type_cpu_e;
+ if (f_compare_dynamic(limit, controller_data_s) == F_equal_to) return controller_resource_limit_type_data_e;
+ if (f_compare_dynamic(limit, controller_fsize_s) == F_equal_to) return controller_resource_limit_type_fsize_e;
+ if (f_compare_dynamic(limit, controller_locks_s) == F_equal_to) return controller_resource_limit_type_locks_e;
+ if (f_compare_dynamic(limit, controller_memlock_s) == F_equal_to) return controller_resource_limit_type_memlock_e;
+ if (f_compare_dynamic(limit, controller_msgqueue_s) == F_equal_to) return controller_resource_limit_type_msgqueue_e;
+ if (f_compare_dynamic(limit, controller_nice_s) == F_equal_to) return controller_resource_limit_type_nice_e;
+ if (f_compare_dynamic(limit, controller_nofile_s) == F_equal_to) return controller_resource_limit_type_nofile_e;
+ if (f_compare_dynamic(limit, controller_nproc_s) == F_equal_to) return controller_resource_limit_type_nproc_e;
+ if (f_compare_dynamic(limit, controller_rss_s) == F_equal_to) return controller_resource_limit_type_rss_e;
+ if (f_compare_dynamic(limit, controller_rtprio_s) == F_equal_to) return controller_resource_limit_type_rtprio_e;
+ if (f_compare_dynamic(limit, controller_rttime_s) == F_equal_to) return controller_resource_limit_type_rttime_e;
+ if (f_compare_dynamic(limit, controller_sigpending_s) == F_equal_to) return controller_resource_limit_type_sigpending_e;
+ if (f_compare_dynamic(limit, controller_stack_s) == F_equal_to) return controller_resource_limit_type_stack_e;
+
+ return 0;
+ }
+#endif // _di_controller_rule_setting_limit_type_identify_
+
+#ifndef _di_controller_rule_setting_limit_type_name_
+ f_string_static_t controller_rule_setting_limit_type_name(const uint8_t type) {
+
+ switch (type) {
+ case controller_resource_limit_type_as_e:
+ return controller_as_s;
+
+ case controller_resource_limit_type_core_e:
+ return controller_core_s;
+
+ case controller_resource_limit_type_cpu_e:
+ return controller_cpu_s;
+
+ case controller_resource_limit_type_data_e:
+ return controller_data_s;
+
+ case controller_resource_limit_type_fsize_e:
+ return controller_fsize_s;
+
+ case controller_resource_limit_type_locks_e:
+ return controller_locks_s;
+
+ case controller_resource_limit_type_memlock_e:
+ return controller_memlock_s;
+
+ case controller_resource_limit_type_msgqueue_e:
+ return controller_msgqueue_s;
+
+ case controller_resource_limit_type_nice_e:
+ return controller_nice_s;
+
+ case controller_resource_limit_type_nofile_e:
+ return controller_nofile_s;
+
+ case controller_resource_limit_type_nproc_e:
+ return controller_nproc_s;
+
+ case controller_resource_limit_type_rss_e:
+ return controller_rss_s;
+
+ case controller_resource_limit_type_rtprio_e:
+ return controller_rtprio_s;
+
+ case controller_resource_limit_type_rttime_e:
+ return controller_rttime_s;
+
+ case controller_resource_limit_type_sigpending_e:
+ return controller_sigpending_s;
+
+ case controller_resource_limit_type_stack_e:
+ return controller_stack_s;
+ }
+
+ return f_string_empty_s;
+ }
+#endif // _di_controller_rule_setting_limit_type_name_
+
+#ifndef _di_controller_rule_setting_read_
+ f_status_t controller_rule_setting_read(controller_global_t * const global, const bool is_normal, controller_cache_t * const cache, controller_rule_t * const rule) {
if (!global || !cache || !rule) return F_status_set_error(F_parameter);
f_range_t range = macro_f_range_t_initialize_2(cache->buffer_item.used);
f_range_t range2 = f_range_t_initialize;
- controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, global->thread);
- f_state_t state = macro_f_state_t_initialize_1(controller_allocation_large_d, controller_allocation_small_d, F_okay, 0, 0, 0, &controller_main_thread_signal_state_fss, 0, (void *) &custom, 0);
+ controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, global);
+ f_state_t state = macro_f_state_t_initialize_1(controller_allocation_large_d, controller_allocation_small_d, F_okay, 0, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0);
fll_fss_extended_read(cache->buffer_item, &range, &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0, &state);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "fll_fss_extended_read", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "fll_fss_extended_read", F_true, F_false);
return status;
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->object_actions.array[i], &cache->action.name_item);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
fl_print_format(f_string_format_Q_single_s.string, global->main->program.warning.to, global->main->program.warning.notable, cache->action.name_item, global->main->program.warning.notable);
fl_print_format(f_string_format_sentence_end_quote_s.string, global->main->program.warning.to, global->main->program.warning.context, global->main->program.warning.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->main->program.warning, cache->action, F_false);
+ controller_print_rule_error_cache(&global->main->program.warning, cache->action, F_false);
controller_unlock_print_flush(global->main->program.warning.to, global->thread);
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, range2, &cache->action.name_action);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
// Get the current line number within the settings item.
cache->action.line_item = line_item;
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
fl_print_format("%r%[%QEmpty rule setting.%]%r", global->main->program.warning.to, f_string_eol_s, global->main->program.warning.context, global->main->program.warning.prefix, global->main->program.warning.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->main->program.warning, cache->action, F_false);
+ controller_print_rule_error_cache(&global->main->program.warning, cache->action, F_false);
controller_unlock_print_flush(global->main->program.warning.to, global->thread);
}
if (type == controller_rule_setting_type_affinity_e) {
if (!cache->content_actions.array[i].used) {
- controller_main_print_rule_setting_read_error(&global->main->program.error, "requires one or more Content", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error(&global->main->program.error, "requires one or more Content", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
status = f_memory_array_increase(controller_allocation_small_d, sizeof(int32_t), (void **) &rule->affinity.array, &rule->affinity.used, &rule->affinity.size);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
break;
}
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_main_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_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) {
if (status == F_data_not || status == F_number || status == F_number_overflow || status == F_number_underflow || status == F_number_negative || status == F_number_decimal) {
if (status == F_number_underflow) {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too small for this system", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too small for this system", i, line_item, global->thread, cache);
}
else if (status == F_number_overflow || status == F_number_positive) {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too large for this system", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too large for this system", i, line_item, global->thread, cache);
}
else {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid number", cache->content_actions.array[i].array[j], ", only whole numbers are allowed for an affinity value", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid number", cache->content_actions.array[i].array[j], ", only whole numbers are allowed for an affinity value", i, line_item, global->thread, cache);
}
status = F_status_set_error(F_valid_not);
}
}
else {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
status = F_status_set_error(status);
rule->affinity.array[rule->affinity.used++] = number;
} // for
- controller_main_print_rule_setting_read_values(global, controller_affinity_s, i, cache);
+ controller_print_rule_setting_read_values(global, controller_affinity_s, i, cache);
continue;
}
if (type == controller_rule_setting_type_define_e || type == controller_rule_setting_type_parameter_e) {
if (cache->content_actions.array[i].used != 2) {
- controller_main_print_rule_setting_read_error(&global->main->program.error, "requires exactly two Content", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error(&global->main->program.error, "requires exactly two Content", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_map_t), (void **) &setting_maps->array, &setting_maps->used, &setting_maps->size);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], &setting_maps->array[setting_maps->used].key);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[1], &setting_maps->array[setting_maps->used].value);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
- controller_main_print_rule_setting_read_mapping(global, type == controller_rule_setting_type_define_e ? controller_define_s : controller_parameter_s, setting_maps->array[setting_maps->used]);
+ controller_print_rule_setting_read_mapping(global, type == controller_rule_setting_type_define_e ? controller_define_s : controller_parameter_s, setting_maps->array[setting_maps->used]);
++setting_maps->used;
if (type == controller_rule_setting_type_cgroup_e) {
if (cache->content_actions.array[i].used < 2 || rule->has & controller_rule_has_cgroup_d) {
- controller_main_print_rule_setting_read_error(&global->main->program.error, "requires two or more Content", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error(&global->main->program.error, "requires two or more Content", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
rule->cgroup.as_new = F_true;
}
else {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unknown option", cache->content_actions.array[i].array[0], "", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unknown option", cache->content_actions.array[i].array[0], "", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
status = f_string_dynamic_append(global->program->path_cgroup, &rule->cgroup.path);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_false);
}
else {
rule->cgroup.groups.used = 0;
status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &rule->cgroup.groups.array, &rule->cgroup.groups.used, &rule->cgroup.groups.size);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
break;
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[j], &rule->cgroup.groups.array[rule->cgroup.groups.used]);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
break;
}
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
rule->has |= controller_rule_has_cgroup_d;
- controller_main_print_rule_setting_read_values(global, controller_cgroup_s, i, cache);
+ controller_print_rule_setting_read_values(global, controller_cgroup_s, i, cache);
continue;
}
if (type == controller_rule_setting_type_limit_e) {
if (cache->content_actions.array[i].used != 3) {
- controller_main_print_rule_setting_read_error(&global->main->program.error, "requires three Content", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error(&global->main->program.error, "requires three Content", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
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_main_print_rule_error_cache(&global->error, &cache->action, F_true);
+ controller_print_rule_error_cache(global->error, cache->action, F_true);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
fl_print_format("%r%[%QThe resource limit type is already specified%]%r", global->main->program.error.to, f_string_eol_s, global->main->program.error.context, global->main->program.error.prefix, global->main->program.error.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->error, cache->action, F_false);
+ controller_print_rule_error_cache(global->error, cache->action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_limit_set_t), (void **) &rule->limits.array, &rule->limits.used, &rule->limits.size);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
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_main_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_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) {
if (status == F_data_not || status == F_number || status == F_number_overflow || status == F_number_underflow || status == F_number_negative || status == F_number_positive || status == F_number_decimal) {
if (status == F_number_underflow) {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too small for this system", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too small for this system", i, line_item, global->thread, cache);
}
else if (status == F_number_overflow) {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too large for this system", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", the number is too large for this system", i, line_item, global->thread, cache);
}
else {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", only whole numbers are allowed for a resource limit value", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[j], ", only whole numbers are allowed for a resource limit value", i, line_item, global->thread, cache);
}
status = F_status_set_error(F_valid_not);
}
}
else {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
status = F_status_set_error(status);
rule->limits.array[rule->limits.used++].type = type;
- controller_main_print_rule_setting_read_values(global, controller_limit_s, i, cache);
+ controller_print_rule_setting_read_values(global, controller_limit_s, i, cache);
continue;
}
}
if (setting_value->used || !cache->content_actions.array[i].used) {
- controller_main_print_rule_setting_read_error(&global->main->program.error, "requires one or more Content", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error(&global->main->program.error, "requires one or more Content", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
fl_print_format(f_string_format_Q_single_s.string, global->main->program.error.to, global->main->program.error.notable, *setting_value, global->main->program.error.notable);
fl_print_format("%[', there must be at least 1 graph character.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->error, cache->action, F_false);
+ controller_print_rule_error_cache(global->error, cache->action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
else {
// This function should only return F_complete_not_utf on error.
- controller_main_print_rule_error(&global->error, cache->action, F_complete_not_utf, "controller_validate_has_graph", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_complete_not_utf, "controller_validate_has_graph", F_true, F_false);
if (F_status_is_error_not(status_return)) {
status_return = status;
}
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
}
setting_value->used = 0;
continue;
}
- controller_main_print_rule_setting_read_value(global, type == controller_rule_setting_type_name_e ? controller_name_s : controller_engine_s, f_string_empty_s, *setting_value, 0);
+ controller_print_rule_setting_read_value(global, type == controller_rule_setting_type_name_e ? controller_name_s : controller_engine_s, f_string_empty_s, *setting_value, 0);
}
else if (type == controller_rule_setting_type_path_e) {
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], setting_value);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
- controller_main_print_rule_setting_read_value(global, controller_path_s, f_string_empty_s, *setting_value, 0);
+ controller_print_rule_setting_read_value(global, controller_path_s, f_string_empty_s, *setting_value, 0);
}
continue;
if (type == controller_rule_setting_type_scheduler_e) {
if (cache->content_actions.array[i].used < 1 || cache->content_actions.array[i].used > 2 || rule->has & controller_rule_has_scheduler_d) {
- controller_main_print_rule_setting_read_error(&global->main->program.error, "requires either one or two Content", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error(&global->main->program.error, "requires either one or two Content", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
rule->scheduler.priority = 49;
}
else {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unknown scheduler", cache->content_actions.array[i].array[0], "", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unknown scheduler", cache->content_actions.array[i].array[0], "", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
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_main_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_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) {
fl_print_format(" allowed for the designated scheduler.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->error, cache->action, F_false);
+ controller_print_rule_error_cache(global->error, cache->action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
}
}
else {
- controller_main_print_rule_error(&global->error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
status = F_status_set_error(status);
if (F_status_is_error_not(status_return)) {
rule->has |= controller_rule_has_scheduler_d;
- controller_main_print_rule_setting_read_values(global, controller_scheduler_s, i, cache);
+ controller_print_rule_setting_read_values(global, controller_scheduler_s, i, cache);
continue;
}
if (type == controller_rule_setting_type_timeout_e) {
if (cache->content_actions.array[i].used != 2) {
- controller_main_print_rule_setting_read_error(&global->main->program.error, "requires exactly two Content", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error(&global->main->program.error, "requires exactly two Content", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
fl_print_format(f_string_format_Q_range_single_s.string, global->main->program.error.to, global->main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[0], global->main->program.error.notable);
fl_print_format("%[' but only supports %r, %r, and %r.%]%r", global->main->program.error.to, global->main->program.error.context, controller_kill_s, controller_start_s, controller_stop_s, global->main->program.error.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->error, cache->action, F_false);
+ controller_print_rule_error_cache(global->error, cache->action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
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_main_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_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) {
status = F_status_set_fine(status);
if (status == F_number_overflow) {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[1], ", the number is too large for this system", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an unsupported number", cache->content_actions.array[i].array[1], ", the number is too large for this system", i, line_item, global->thread, cache);
}
else if (status == F_data_not || status == F_number || status == F_number_underflow || status == F_number_negative || status == F_number_positive || status == F_number_decimal) {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid number", cache->content_actions.array[i].array[1], ", only positive whole numbers are allowed", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid number", cache->content_actions.array[i].array[1], ", only positive whole numbers are allowed", i, line_item, global->thread, cache);
}
else {
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_error(&global->error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
}
if (F_status_is_error_not(status_return)) {
status = f_rip_dynamic_partial_nulless(cache->buffer_item, cache->content_actions.array[i].array[1], &cache->action.generic);
if (F_status_is_error(status)) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
break;
}
- controller_main_print_rule_setting_read_value(global, controller_timeout_s, name_sub, cache->action.generic, 0);
+ controller_print_rule_setting_read_value(global, controller_timeout_s, name_sub, cache->action.generic, 0);
}
}
if (type == controller_rule_setting_type_capability_e || type == controller_rule_setting_type_nice_e || type == controller_rule_setting_type_user_e) {
if (cache->content_actions.array[i].used != 1 || type == controller_rule_setting_type_capability_e && rule->capability || type == controller_rule_setting_type_group_e && (rule->has & controller_rule_has_group_d) || type == controller_rule_setting_type_nice_e && (rule->has & controller_rule_has_nice_d) || type == controller_rule_setting_type_user_e && (rule->has & controller_rule_has_user_d)) {
- controller_main_print_rule_setting_read_error(&global->main->program.error, "requires exactly one Content", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error(&global->main->program.error, "requires exactly one Content", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
controller_lock_print(global->main->program.error.to, global->thread);
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
- controller_main_print_rule_error_cache(&global->error, cache->action, F_false);
+ controller_print_rule_error_cache(global->error, cache->action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
controller_lock_print(global->main->program.error.to, global->thread);
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_capability_from_text", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_capability_from_text", F_true, F_false);
- controller_main_print_rule_error_cache(&global->error, cache->action, F_false);
+ controller_print_rule_error_cache(global->error, cache->action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
break;
}
- controller_main_print_rule_setting_read_error(&global->main->program.error, "failed to process the capabilities", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error(&global->main->program.error, "failed to process the capabilities", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
continue;
}
- controller_main_print_rule_setting_read_value(global, controller_capability_s, f_string_empty_s, cache->action.generic, 0);
+ controller_print_rule_setting_read_value(global, controller_capability_s, f_string_empty_s, cache->action.generic, 0);
}
else if (type == controller_rule_setting_type_nice_e) {
f_number_signed_t number = 0;
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_main_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_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) {
fl_print_format("%[19%]", global->main->program.error.to, global->main->program.error.notable, global->main->program.error.notable);
fl_print_format(" %[are allowed.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->error, cache->action, F_false);
+ controller_print_rule_error_cache(global->error, cache->action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
}
}
else {
- controller_main_print_rule_error(&global->error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
status = F_status_set_error(status);
if (F_status_is_error_not(status_return)) {
controller_lock_print(global->main->program.error.to, global->thread);
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
- controller_main_print_rule_error_cache(&global->error, cache->action, F_false);
+ controller_print_rule_error_cache(global->error, cache->action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
if (F_status_is_error_not(status)) {
- controller_main_print_rule_setting_read_value(global, controller_nice_s, f_string_empty_s, cache->action.generic, 0);
+ controller_print_rule_setting_read_value(global, controller_nice_s, f_string_empty_s, cache->action.generic, 0);
}
}
}
else if (type == controller_rule_setting_type_user_e) {
uid_t number = 0;
- status = controller_get_id_user(cache->buffer_item, cache->content_actions.array[i].array[0], cache, &number);
+ status = controller_convert_user_id(cache->buffer_item, cache->content_actions.array[i].array[0], cache, &number);
if (F_status_is_error(status)) {
status = F_status_set_fine(status);
if (status == F_exist_not) {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because no user was found by that name", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because no user was found by that name", i, line_item, global->thread, cache);
}
else if (status == F_number_too_large) {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because the given ID is too large", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because the given ID is too large", i, line_item, global->thread, cache);
}
else if (status == F_number) {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because the given ID is not a valid supported number", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because the given ID is not a valid supported number", i, line_item, global->thread, cache);
}
else {
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_error(&global->error, cache->action, status, "controller_get_id_user", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, status, "controller_convert_user_id", F_true, F_false);
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
}
if (F_status_is_error_not(status_return)) {
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], &cache->action.generic);
- controller_main_print_rule_setting_read_value(global, controller_user_s, f_string_empty_s, cache->action.generic, 0);
+ controller_print_rule_setting_read_value(global, controller_user_s, f_string_empty_s, cache->action.generic, 0);
}
}
}
if (type == controller_rule_setting_type_group_e) {
if (!cache->content_actions.array[i].used) {
- controller_main_print_rule_setting_read_error(&global->main->program.error, "requires one or more Content", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error(&global->main->program.error, "requires one or more Content", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_int32s_t), (void **) &rule->groups.array, &rule->groups.used, &rule->groups.size);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
- status = controller_get_id_group(cache->buffer_item, cache->content_actions.array[i].array[j], cache, &number);
+ status = controller_convert_group_id(cache->buffer_item, cache->content_actions.array[i].array[j], cache, &number);
if (F_status_is_error(status)) {
status = F_status_set_fine(status);
if (status == F_exist_not) {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because no group was found by that name", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because no group was found by that name", i, line_item, global->thread, cache);
}
else if (status == F_number_too_large) {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because the given ID is too large", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because the given ID is too large", i, line_item, global->thread, cache);
}
else if (status == F_number) {
- controller_main_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because the given ID is not a valid supported number", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error_with_range(&global->main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because the given ID is not a valid supported number", i, line_item, global->thread, cache);
}
else {
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_error(&global->error, cache->action, status, "f_account_group_id_by_name", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, status, "f_account_group_id_by_name", F_true, F_false);
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
}
if (F_status_is_error_not(status_return)) {
}
} // for
- controller_main_print_rule_setting_read_values(global, controller_group_s, i, cache);
+ controller_print_rule_setting_read_values(global, controller_group_s, i, cache);
continue;
}
status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &setting_values->array, &setting_values->used, &setting_values->size);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[j], &setting_values->array[setting_values->used]);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
setting_values->array[setting_values->used].used = 0;
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
fl_print_format(f_string_format_Q_single_s.string, global->main->program.error.to, global->main->program.error.notable, setting_values->array[setting_values->used], global->main->program.error.notable);
fl_print_format(f_string_format_sentence_end_quote_s.string, global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->error, cache->action, F_false);
+ controller_print_rule_error_cache(global->error, cache->action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
else {
// This function should only return F_complete_not_utf on error.
- controller_main_print_rule_error(&global->error, cache->action, F_complete_not_utf, "controller_validate_environment_name", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_complete_not_utf, "controller_validate_environment_name", F_true, F_false);
if (F_status_is_error_not(status_return)) {
status_return = status;
setting_values->array[setting_values->used].used = 0;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
rule->has |= controller_rule_has_environment_d;
if (cache->content_actions.array[i].used) {
- controller_main_print_rule_setting_read_values(global, controller_environment_s, i, cache);
+ controller_print_rule_setting_read_values(global, controller_environment_s, i, cache);
}
else {
if (global->main->program.error.verbosity == f_console_verbosity_debug_e || (global->main->program.error.verbosity == f_console_verbosity_verbose_e && (global->main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
// The "on" Rule Setting.
if (cache->content_actions.array[i].used != 4) {
- controller_main_print_rule_setting_read_error(&global->main->program.error, "requires exactly four Content", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error(&global->main->program.error, "requires exactly four Content", i, line_item, global->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
}
if (f_compare_dynamic_partial_string(controller_freeze_s.string, cache->buffer_item, controller_freeze_s.used, cache->content_actions.array[i].array[0]) == F_equal_to) {
- action = controller_main_rule_action_type_freeze_e;
+ action = controller_rule_action_type_freeze_e;
}
else if (f_compare_dynamic_partial_string(controller_kill_s.string, cache->buffer_item, controller_kill_s.used, cache->content_actions.array[i].array[0]) == F_equal_to) {
- action = controller_main_rule_action_type_kill_e;
+ action = controller_rule_action_type_kill_e;
}
else if (f_compare_dynamic_partial_string(controller_pause_s.string, cache->buffer_item, controller_pause_s.used, cache->content_actions.array[i].array[0]) == F_equal_to) {
- action = controller_main_rule_action_type_pause_e;
+ action = controller_rule_action_type_pause_e;
}
else if (f_compare_dynamic_partial_string(controller_reload_s.string, cache->buffer_item, controller_reload_s.used, cache->content_actions.array[i].array[0]) == F_equal_to) {
- action = controller_main_rule_action_type_reload_e;
+ action = controller_rule_action_type_reload_e;
}
else if (f_compare_dynamic_partial_string(controller_restart_s.string, cache->buffer_item, controller_restart_s.used, cache->content_actions.array[i].array[0]) == F_equal_to) {
- action = controller_main_rule_action_type_restart_e;
+ action = controller_rule_action_type_restart_e;
}
else if (f_compare_dynamic_partial_string(controller_resume_s.string, cache->buffer_item, controller_resume_s.used, cache->content_actions.array[i].array[0]) == F_equal_to) {
- action = controller_main_rule_action_type_resume_e;
+ action = controller_rule_action_type_resume_e;
}
else if (f_compare_dynamic_partial_string(controller_start_s.string, cache->buffer_item, controller_start_s.used, cache->content_actions.array[i].array[0]) == F_equal_to) {
- action = controller_main_rule_action_type_start_e;
+ action = controller_rule_action_type_start_e;
}
else if (f_compare_dynamic_partial_string(controller_stop_s.string, cache->buffer_item, controller_stop_s.used, cache->content_actions.array[i].array[0]) == F_equal_to) {
- action = controller_main_rule_action_type_stop_e;
+ action = controller_rule_action_type_stop_e;
}
else if (f_compare_dynamic_partial_string(controller_thaw_s.string, cache->buffer_item, controller_thaw_s.used, cache->content_actions.array[i].array[0]) == F_equal_to) {
- action = controller_main_rule_action_type_thaw_e;
+ action = controller_rule_action_type_thaw_e;
}
else {
if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
fl_print_format("%[' but only supports %r, %r, %r, %r, %r", global->main->program.error.to, global->main->program.error.context, controller_freeze_s, controller_kill_s, controller_pause_s, controller_reload_s, controller_restart_s);
fl_print_format("%r, %r, %r, and %r.%]%r", global->main->program.error.to, controller_resume_s, controller_start_s, controller_stop_s, controller_thaw_s, global->main->program.error.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->error, cache->action, F_false);
+ controller_print_rule_error_cache(global->error, cache->action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
} // for
if (j == rule->ons.used) {
- status = controller_rule_ons_increase(&rule->ons);
+ status = f_memory_array_increase(controller_allocation_small_d, sizeof(controller_rule_on_t), (void **) &rule->ons.array, &rule->ons.used, &rule->ons.size);
}
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "controller_rule_ons_increase", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), macro_controller_f(f_memory_array_increase), F_true, F_false);
}
else {
if (f_compare_dynamic_partial_string(controller_need_s.string, cache->buffer_item, controller_need_s.used, cache->content_actions.array[i].array[1]) == F_equal_to) {
fl_print_format(f_string_format_Q_range_single_s.string, global->main->program.error.to, global->main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[1], global->main->program.error.notable);
fl_print_format("%[' but only supports %r, %r, and %r.%]%r", global->main->program.error.to, global->main->program.error.context, controller_need_s, controller_want_s, controller_wish_s, global->main->program.error.context, f_string_eol_s);
- controller_main_print_rule_error_cache(&global->error, cache->action, F_false);
+ controller_print_rule_error_cache(global->error, cache->action, F_false);
controller_unlock_print_flush(global->main->program.error.to, global->thread);
}
status = f_memory_array_increase_by(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &setting_values->array, &setting_values->used, &setting_values->size);
if (F_status_is_error(status)) {
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase_by", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase_by", F_true, F_false);
}
}
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
cache->action.line_action = ++cache->action.line_item;
- controller_main_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
if (F_status_is_error(status)) {
setting_values->array[setting_values->used].used = 0;
- controller_main_print_rule_error(&global->error, cache->action, F_status_set_fine(status), "f_file_name_base", F_true, F_false);
+ controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_file_name_base", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
return status_return;
}
-#endif // _di_controller_main_rule_setting_read_
+#endif // _di_controller_rule_setting_read_
#ifdef __cplusplus
} // extern "C"
#endif
/**
+ * Identify the rule item code the given name represents.
+ *
+ * @param item
+ * The string representing an rule action.
+ *
+ * @return
+ * The rule item type code on success.
+ * 0 if name is unknown.
+ */
+#ifndef _di_controller_rule_setting_limit_type_identify_
+ extern uint8_t controller_rule_setting_limit_type_identify(const f_string_static_t item);
+#endif // _di_controller_rule_setting_limit_type_identify_
+
+/**
+ * Get a string representing the rule setting limit type.
+ *
+ * @param type
+ * The rule setting limit type code.
+ *
+ * @return
+ * The string with used > 0 on success.
+ * The string with used == 0 if no match was found.
+ */
+#ifndef _di_controller_rule_setting_limit_type_name_
+ extern f_string_static_t controller_rule_setting_limit_type_name(const uint8_t type);
+#endif // di_controller_rule_setting_limit_type_name_
+
+/**
* Read the content within the buffer, extracting all valid settings.
*
* This will perform additional FSS read functions as appropriate.
*
* @see controller_path_canonical_relative()
*/
-#ifndef _di_controller_main_rule_setting_read_
- extern f_status_t controller_main_rule_setting_read(controller_global_t * const global, const bool is_normal, controller_cache_t * const cache, controller_rule_t * const rule);
-#endif // _di_controller_main_rule_setting_read_
+#ifndef _di_controller_rule_setting_read_
+ extern f_status_t controller_rule_setting_read(controller_global_t * const global, const bool is_normal, controller_cache_t * const cache, controller_rule_t * const rule);
+#endif // _di_controller_rule_setting_read_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_rule_validate_
- void controller_main_rule_validate(controller_global_t * const global, const controller_rule_t rule, const uint8_t action, const uint8_t options, controller_cache_t * const cache) {
+#ifndef _di_controller_rule_validate_
+ void controller_rule_validate(controller_global_t * const global, const controller_rule_t rule, const uint8_t action, const uint8_t options, controller_cache_t * const cache) {
if (!global || !cache) return F_status_set_error(F_parameter);
- controller_main_t * const main = global->main;
+ controller_t * const main = global->main;
switch (action) {
- case controller_main_rule_action_type_freeze_e:
- case controller_main_rule_action_type_kill_e:
- case controller_main_rule_action_type_pause_e:
- case controller_main_rule_action_type_reload_e:
- case controller_main_rule_action_type_restart_e:
- case controller_main_rule_action_type_resume_e:
- case controller_main_rule_action_type_start_e:
- case controller_main_rule_action_type_stop_e:
- case controller_main_rule_action_type_thaw_e:
+ case controller_rule_action_type_freeze_e:
+ case controller_rule_action_type_kill_e:
+ case controller_rule_action_type_pause_e:
+ case controller_rule_action_type_reload_e:
+ case controller_rule_action_type_restart_e:
+ case controller_rule_action_type_resume_e:
+ case controller_rule_action_type_start_e:
+ case controller_rule_action_type_stop_e:
+ case controller_rule_action_type_thaw_e:
break;
default:
controller_lock_print(main->program.error.to, global->thread);
fl_print_format("%r%[%QUnsupported action type '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context);
- fl_print_format(f_string_format_r_single_s.string, main->program.error.to, main->program.error.notable, controller_main_rule_action_type_name(action), main->program.error.notable);
+ fl_print_format(f_string_format_r_single_s.string, main->program.error.to, main->program.error.notable, controller_convert_rule_action_type_string(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_main_print_rule_error_cache(&global->error, &cache->action, F_true);
+ controller_print_rule_error_cache(global->error, cache->action, F_true);
controller_unlock_print_flush(main->program.error.to, global->thread);
}
if (rule.items.used) {
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_main_rule_action_type_name(action), main->program.context.set.title);
+ fl_print_format("%[%r%]' action to execute and would '", main->program.output.to, main->program.context.set.title, controller_convert_rule_action_type_string(action), main->program.context.set.title);
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);
}
{
f_string_static_t action = f_string_static_t_initialize;
- if (rule.ons.array[i].action == controller_main_rule_action_type_freeze_e) {
+ if (rule.ons.array[i].action == controller_rule_action_type_freeze_e) {
action = controller_freeze_s;
}
- else if (rule.ons.array[i].action == controller_main_rule_action_type_kill_e) {
+ else if (rule.ons.array[i].action == controller_rule_action_type_kill_e) {
action = controller_kill_s;
}
- else if (rule.ons.array[i].action == controller_main_rule_action_type_pause_e) {
+ else if (rule.ons.array[i].action == controller_rule_action_type_pause_e) {
action = controller_pause_s;
}
- else if (rule.ons.array[i].action == controller_main_rule_action_type_reload_e) {
+ else if (rule.ons.array[i].action == controller_rule_action_type_reload_e) {
action = controller_reload_s;
}
- else if (rule.ons.array[i].action == controller_main_rule_action_type_restart_e) {
+ else if (rule.ons.array[i].action == controller_rule_action_type_restart_e) {
action = controller_restart_s;
}
- else if (rule.ons.array[i].action == controller_main_rule_action_type_resume_e) {
+ else if (rule.ons.array[i].action == controller_rule_action_type_resume_e) {
action = controller_resume_s;
}
- else if (rule.ons.array[i].action == controller_main_rule_action_type_start_e) {
+ else if (rule.ons.array[i].action == controller_rule_action_type_start_e) {
action = controller_start_s;
}
- else if (rule.ons.array[i].action == controller_main_rule_action_type_stop_e) {
+ else if (rule.ons.array[i].action == controller_rule_action_type_stop_e) {
action = controller_stop_s;
}
- else if (rule.ons.array[i].action == controller_main_rule_action_type_thaw_e) {
+ else if (rule.ons.array[i].action == controller_rule_action_type_thaw_e) {
action = controller_thaw_s;
}
// Items.
if (rule.items.used) {
- controller_main_rule_action_t *action = 0;
+ controller_rule_action_t *action = 0;
controller_rule_item_t *item = 0;
controller_rule_rerun_item_t *rerun_item = 0;
action = &item->actions.array[j];
fl_print_format(" %[%r%] {%r", main->program.output.to, main->program.context.set.important, controller_action_s, main->program.context.set.important, f_string_eol_s);
- fl_print_format(" %[%r%] %r%r", main->program.output.to, main->program.context.set.important, controller_type_s, main->program.context.set.important, controller_main_rule_action_type_name(action->type), f_string_eol_s);
+ fl_print_format(" %[%r%] %r%r", main->program.output.to, main->program.context.set.important, controller_type_s, main->program.context.set.important, controller_convert_rule_action_type_string(action->type), f_string_eol_s);
if (item->type == controller_rule_item_type_script_e || item->type == controller_rule_item_type_utility_e) {
fl_print_format(" %[%r%] {%r", main->program.output.to, main->program.context.set.important, controller_parameter_s, main->program.context.set.important, f_string_eol_s);
// Rerun.
fl_print_format(" %[%r%] {%r", main->program.output.to, main->program.context.set.important, controller_rerun_s, main->program.context.set.important, f_string_eol_s);
- for (j = 0; j < controller_main_rule_action_execute_type__enum_size_e; ++j) {
+ for (j = 0; j < controller_rule_action_execute_type__enum_size_e; ++j) {
for (k = 0; k < 2; ++k) {
if (!k && (item->reruns[j].is & controller_rule_rerun_is_failure_d)) {
fl_print_format(" %[", main->program.output.to, main->program.context.set.important);
switch (j) {
- case controller_main_rule_action_execute_type_freeze_e:
+ case controller_rule_action_execute_type_freeze_e:
f_print_dynamic_raw(controller_freeze_s, main->program.output.to);
break;
- case controller_main_rule_action_execute_type_kill_e:
+ case controller_rule_action_execute_type_kill_e:
f_print_dynamic_raw(controller_kill_s, main->program.output.to);
break;
- case controller_main_rule_action_execute_type_pause_e:
+ case controller_rule_action_execute_type_pause_e:
f_print_dynamic_raw(controller_pause_s, main->program.output.to);
break;
- case controller_main_rule_action_execute_type_reload_e:
+ case controller_rule_action_execute_type_reload_e:
f_print_dynamic_raw(controller_reload_s, main->program.output.to);
break;
- case controller_main_rule_action_execute_type_restart_e:
+ case controller_rule_action_execute_type_restart_e:
f_print_dynamic_raw(controller_restart_s, main->program.output.to);
break;
- case controller_main_rule_action_execute_type_resume_e:
+ case controller_rule_action_execute_type_resume_e:
f_print_dynamic_raw(controller_resume_s, main->program.output.to);
break;
- case controller_main_rule_action_execute_type_start_e:
+ case controller_rule_action_execute_type_start_e:
f_print_dynamic_raw(controller_start_s, main->program.output.to);
break;
- case controller_main_rule_action_execute_type_stop_e:
+ case controller_rule_action_execute_type_stop_e:
f_print_dynamic_raw(controller_stop_s, main->program.output.to);
break;
- case controller_main_rule_action_execute_type_thaw_e:
+ case controller_rule_action_execute_type_thaw_e:
f_print_dynamic_raw(controller_thaw_s, main->program.output.to);
break;
controller_unlock_print_flush(main->program.output.to, global->thread);
}
-#endif // _di_controller_main_rule_validate_
+#endif // _di_controller_rule_validate_
#ifdef __cplusplus
} // extern "C"
* @param cache
* A structure for containing and caching relevant data.
*/
-#ifndef _di_controller_main_rule_validate_
- extern void controller_main_rule_validate(controller_global_t * const global, const controller_rule_t rule, const uint8_t action, const uint8_t options, controller_cache_t * const cache);
-#endif // _di_controller_main_rule_validate_
+#ifndef _di_controller_rule_validate_
+ extern void controller_rule_validate(controller_global_t * const global, const controller_rule_t rule, const uint8_t action, const uint8_t options, controller_cache_t * const cache);
+#endif // _di_controller_rule_validate_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_rule_wait_all_
- f_status_t controller_main_rule_wait_all(controller_global_t * const global, const bool is_normal, const bool required) {
+#ifndef _di_controller_rule_wait_all_
+ f_status_t controller_rule_wait_all(controller_global_t * const global, const bool is_normal, const bool required) {
if (!global) return F_status_set_error(F_parameter);
- f_status_t status_lock = controller_main_lock_read(is_normal, global->thread, &global->thread->lock.instance);
+ f_status_t status_lock = controller_lock_read(is_normal, global->thread, &global->thread->lock.instance);
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);
// Build a list of what to wait for so that anything new after this point will not be waited for.
const f_number_unsigned_t instance_total = global->thread->instances.used;
- controller_data_t *instance_list[instance_total];
+ controller_instance_t *instance_list[instance_total];
for (; i < instance_total; ++i) {
instance_list[i] = global->thread->instances.array[i];
for (i = 0; i < instance_total; ++i) {
- if (!controller_main_thread_is_enabled(is_normal, global->thread)) break;
+ if (!controller_thread_is_enabled(is_normal, global->thread)) break;
// Re-establish global instance read lock to wait for or protect from the cleanup thread while checking the read instance.
- status_lock = controller_main_lock_read(is_normal, global->thread, &global->thread->lock.instance);
+ status_lock = controller_lock_read(is_normal, global->thread, &global->thread->lock.instance);
if (F_status_is_error(status_lock)) break;
if (!instance_list[i]) {
continue;
}
- status_lock = controller_main_lock_read(is_normal, global->thread, &instance_list[i]->active);
+ status_lock = controller_lock_read(is_normal, global->thread, &instance_list[i]->active);
if (F_status_is_error(status_lock)) {
f_thread_unlock(&global->thread->lock.instance);
// Once the active lock is obtained, then the main instance read lock can be safely released.
f_thread_unlock(&global->thread->lock.instance);
- status_lock = controller_main_lock_read(is_normal, global->thread, &instance_list[i]->lock);
+ status_lock = controller_lock_read(is_normal, global->thread, &instance_list[i]->lock);
if (F_status_is_error(status_lock)) {
f_thread_unlock(&instance_list[i]->active);
if (instance_list[i]->state == controller_instance_state_done_e) {
f_thread_unlock(&instance_list[i]->lock);
- status_lock = controller_main_lock_write(is_normal, global->thread, &instance_list[i]->lock);
+ status_lock = controller_lock_write(is_normal, global->thread, &instance_list[i]->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, global->thread);
f_thread_unlock(&instance_list[i]->active);
if (f_thread_lock_write_try(&instance_list[i]->active) == F_okay) {
- controller_main_thread_join(&instance_list[i]->id_thread);
+ controller_thread_join(&instance_list[i]->id_thread);
instance_list[i]->state = controller_instance_state_idle_e;
f_thread_mutex_unlock(&instance_list[i]->wait_lock);
}
- status_lock = controller_main_lock_read(is_normal, global->thread, &instance_list[i]->active);
+ status_lock = controller_lock_read(is_normal, global->thread, &instance_list[i]->active);
if (F_status_is_error(status_lock)) {
f_thread_unlock(&instance_list[i]->lock);
f_thread_unlock(&instance_list[i]->lock);
- status_lock = controller_main_lock_read(is_normal, global->thread, &instance_list[i]->lock);
+ status_lock = controller_lock_read(is_normal, global->thread, &instance_list[i]->lock);
if (F_status_is_error(status_lock)) break;
}
if (instance_list[i]->options & controller_instance_option_require_e) {
- if (controller_main_rule_status_is_error(instance_list[i]->action, instance_list[i]->rule)) {
+ if (controller_rule_status_is_error(instance_list[i]->action, instance_list[i]->rule)) {
status = F_status_set_error(F_require);
f_thread_unlock(&instance_list[i]->lock);
break;
}
- else if (controller_main_rule_status_is_available(instance_list[i]->action, instance_list[i]->rule)) {
+ else if (controller_rule_status_is_available(instance_list[i]->action, instance_list[i]->rule)) {
required_not_run = F_true;
}
}
continue;
}
- if (!controller_main_rule_status_is_error(instance_list[i]->action, instance_list[i]->rule) && (instance_list[i]->state == controller_instance_state_active_e || instance_list[i]->state == controller_instance_state_busy_e)) {
+ if (!controller_rule_status_is_error(instance_list[i]->action, instance_list[i]->rule) && (instance_list[i]->state == controller_instance_state_active_e || instance_list[i]->state == controller_instance_state_busy_e)) {
f_thread_unlock(&instance_list[i]->lock);
- status = controller_instance_wait(global, instance_list[i]);
+ status = controller_instance_wait(instance_list[i]);
if (F_status_set_fine(status) == F_interrupt) {
f_thread_unlock(&instance_list[i]->active);
break;
}
- status_lock = controller_main_lock_read(is_normal, global->thread, &instance_list[i]->lock);
+ status_lock = controller_lock_read(is_normal, global->thread, &instance_list[i]->lock);
if (F_status_is_error(status_lock)) {
f_thread_unlock(&instance_list[i]->active);
if ((instance_list[i]->options & controller_instance_option_require_e)) {
f_thread_unlock(&instance_list[i]->lock);
- if (controller_main_rule_status_is_error(instance_list[i]->action, instance_list[i]->rule)) {
+ if (controller_rule_status_is_error(instance_list[i]->action, instance_list[i]->rule)) {
status = F_status_set_error(F_require);
f_thread_unlock(&instance_list[i]->active);
return status_lock;
}
- if (!controller_main_thread_is_enabled(is_normal, global->thread)) return F_status_set_error(F_interrupt);
+ if (!controller_thread_is_enabled(is_normal, global->thread)) return F_status_set_error(F_interrupt);
if (F_status_set_fine(status) == F_require) return status;
if (required_not_run) return F_require;
return F_okay;
}
-#endif // _di_controller_main_rule_wait_all_
+#endif // _di_controller_rule_wait_all_
-#ifndef _di_controller_main_rule_wait_all_instance_type_
- f_status_t controller_main_rule_wait_all_instance_type(controller_global_t * const global, const uint8_t type, const bool required) {
+#ifndef _di_controller_rule_wait_all_instance_type_
+ f_status_t controller_rule_wait_all_instance_type(controller_global_t * const global, const uint8_t type, const bool required) {
if (!global) return F_status_set_error(F_parameter);
- return controller_main_rule_wait_all(global, type != controller_instance_type_exit_e, required);
+ return controller_rule_wait_all(global, type != controller_instance_type_exit_e, required);
}
-#endif // _di_controller_main_rule_wait_all_instance_type_
+#endif // _di_controller_rule_wait_all_instance_type_
#ifdef __cplusplus
} // extern "C"
* F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal.
* F_require (with error bit set) if a required process is in failed status when required is TRUE.
*/
-#ifndef _di_controller_main_rule_wait_all_
- extern f_status_t controller_main_rule_wait_all(controller_global_t * const global, const bool is_normal, const bool required);
-#endif // _di_controller_main_rule_wait_all_
+#ifndef _di_controller_rule_wait_all_
+ extern f_status_t controller_rule_wait_all(controller_global_t * const global, const bool is_normal, const bool required);
+#endif // _di_controller_rule_wait_all_
/**
* Wait until all currently running Rule processes are complete for some process type.
* If FALSE, process all waits, returning normally.
*
* @return
- * Success from controller_main_rule_wait_all().
+ * Success from controller_rule_wait_all().
*
- * Errors (with error bit) from: controller_main_rule_wait_all().
+ * Errors (with error bit) from: controller_rule_wait_all().
*
- * @see controller_main_rule_wait_all()
+ * @see controller_rule_wait_all()
*/
-#ifndef _di_controller_main_rule_wait_all_instance_type_
- extern f_status_t controller_main_rule_wait_all_instance_type(controller_global_t * const global, const uint8_t type, const bool required);
-#endif // _di_controller_main_rule_wait_all_instance_type_
+#ifndef _di_controller_rule_wait_all_instance_type_
+ extern f_status_t controller_rule_wait_all_instance_type(controller_global_t * const global, const uint8_t type, const bool required);
+#endif // _di_controller_rule_wait_all_instance_type_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#if !defined(_di_controller_main_signal_check_) && defined(_di_thread_support_)
- f_status_t controller_main_signal_check(controller_main_t * const main) {
+#if !defined(_di_controller_signal_check_) && defined(_di_thread_support_)
+ f_status_t controller_signal_check(controller_t * const main) {
if (!main || main->program.signal.id == -1) return F_false;
- if (!((++main->program.signal_check) % controller_main_signal_check_d)) {
+ if (!((++main->program.signal_check) % controller_signal_check_d)) {
if (fll_program_standard_signal_received(&main->program)) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
return F_false;
}
-#endif // !defined(_di_controller_main_signal_check_) && defined(_di_thread_support_)
+#endif // !defined(_di_controller_signal_check_) && defined(_di_thread_support_)
-#if !defined(_di_controller_main_signal_check_) && !defined(_di_thread_support_)
- f_status_t controller_main_signal_check(controller_main_t * const main) {
+#if !defined(_di_controller_signal_check_) && !defined(_di_thread_support_)
+ f_status_t controller_signal_check(controller_t * const main) {
if (!main || main->program.signal.id == -1) return F_false;
return F_false;
}
-#endif // !defined(_di_controller_main_signal_check_) && !defined(_di_thread_support_)
+#endif // !defined(_di_controller_signal_check_) && !defined(_di_thread_support_)
-#if !defined(_di_controller_main_signal_handler_) && !defined(_di_thread_support_)
- void controller_main_signal_handler(controller_main_t * const main) {
+#if !defined(_di_controller_signal_handler_) && !defined(_di_thread_support_)
+ void controller_signal_handler(controller_t * const main) {
if (!main) return;
main->program.signal_received = F_signal_abort;
}
}
-#endif // !defined(_di_controller_main_signal_handler_) && !defined(_di_thread_support_)
+#endif // !defined(_di_controller_signal_handler_) && !defined(_di_thread_support_)
#ifdef __cplusplus
} // extern "C"
*
* This is auto-included and should not need to be explicitly included.
*/
-#ifndef _controller_main_signal_h
-#define _controller_main_signal_h
+#ifndef _controller_signal_h
+#define _controller_signal_h
#ifdef __cplusplus
extern "C" {
* - F_signal_termination
*
* There is a threaded and a non-threaded version of this.
- * The non-threaded version checks periodically using controller_main_signal_check_d and updates main->signal_check as needed.
+ * The non-threaded version checks periodically using controller_signal_check_d and updates main->signal_check as needed.
* The threaded version checks the flag state which is set by a separate thread that is blocking until signal is received.
*
* @param main
* F_true on signal received.
* F_false otherwise.
*
- * @see controller_main_signal_handler()
+ * @see controller_signal_handler()
*
* @see fll_program_standard_signal_received()
*/
-#ifndef _di_controller_main_signal_check_
- extern f_status_t controller_main_signal_check(controller_main_t * const main);
-#endif // _di_controller_main_signal_check_
+#ifndef _di_controller_signal_check_
+ extern f_status_t controller_signal_check(controller_t * const main);
+#endif // _di_controller_signal_check_
/**
* Signal handler for signals/interrupts.
* @see f_signal_open()
* @see f_signal_wait()
*/
-#if !defined(_di_controller_main_signal_handler_) && !defined(_di_thread_support_)
- extern void controller_main_signal_handler(controller_main_t * const main);
-#endif // !defined(_di_controller_main_signal_handler_) && !defined(_di_thread_support_)
+#if !defined(_di_controller_signal_handler_) && !defined(_di_thread_support_)
+ extern void controller_signal_handler(controller_t * const main);
+#endif // !defined(_di_controller_signal_handler_) && !defined(_di_thread_support_)
#ifdef __cplusplus
} // extern "C"
#endif
-#endif // _controller_main_signal_h
+#endif // _controller_signal_h
extern "C" {
#endif
-#ifndef _di_controller_main_thread_detach_
- f_status_t controller_main_thread_detach(f_thread_id_t * const id) {
+#ifndef _di_controller_thread_detach_
+ f_status_t controller_thread_detach(f_thread_id_t * const id) {
if (!id || !*id) return F_data_not;
return status;
}
-#endif // _di_controller_main_thread_detach_
+#endif // _di_controller_thread_detach_
-#ifndef _di_controller_main_thread_join_
- f_status_t controller_main_thread_join(f_thread_id_t * const id) {
+#ifndef _di_controller_thread_join_
+ f_status_t controller_thread_join(f_thread_id_t * const id) {
if (!id || !*id) return F_data_not;
return status;
}
-#endif // _di_controller_main_thread_join_
+#endif // _di_controller_thread_join_
#ifdef __cplusplus
} // extern "C"
*
* @see f_thread_detach()
*/
-#ifndef _di_controller_main_thread_detach_
- extern f_status_t controller_main_thread_detach(f_thread_id_t * const id);
-#endif // _di_controller_main_thread_detach_
+#ifndef _di_controller_thread_detach_
+ extern f_status_t controller_thread_detach(f_thread_id_t * const id);
+#endif // _di_controller_thread_detach_
/***
* Join a thread, assigning id to NULL on success.
*
* @see f_thread_join()
*/
-#ifndef _di_controller_main_thread_join_
- extern f_status_t controller_main_thread_join(f_thread_id_t * const id);
-#endif // _di_controller_main_thread_join_
+#ifndef _di_controller_thread_join_
+ extern f_status_t controller_thread_join(f_thread_id_t * const id);
+#endif // _di_controller_thread_join_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_thread_cleanup_
- void * controller_main_thread_cleanup(void * const arguments) {
+#ifndef _di_controller_thread_cleanup_
+ void * controller_thread_cleanup(void * const arguments) {
if (!arguments) return 0;
if (global->thread->enabled != controller_thread_enabled_e) return 0;
- const f_time_spec_t delay = controller_main_time_seconds(global->main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e)
- ? controller_main_thread_cleanup_interval_short_d
- : controller_main_thread_cleanup_interval_long_d);
+ const f_time_spec_t delay = controller_time_seconds(global->main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e)
+ ? controller_thread_cleanup_interval_short_d
+ : controller_thread_cleanup_interval_long_d);
f_status_t status = F_okay;
// De-allocate any rules in the space that is declared to be unused.
if (i >= global->thread->instances.used) {
- controller_main_rule_delete(&instance->rule);
+ controller_rule_delete(&instance->rule);
}
f_thread_unlock(&instance->active);
return 0;
}
-#endif // _di_controller_main_thread_cleanup_
+#endif // _di_controller_thread_cleanup_
#ifdef __cplusplus
} // extern "C"
* @return
* 0, always.
*/
-#ifndef _di_controller_main_thread_cleanup_
- extern void * controller_main_thread_cleanup(void * const arguments);
-#endif // _di_controller_main_thread_cleanup_
+#ifndef _di_controller_thread_cleanup_
+ extern void * controller_thread_cleanup(void * const arguments);
+#endif // _di_controller_thread_cleanup_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_thread_control_
- void * controller_main_thread_control(void * const arguments) {
+#ifndef _di_controller_thread_control_
+ void * controller_thread_control(void * const arguments) {
if (!arguments) return 0;
// It seems that this function doesn't return to the calling thread for a forked child process, even with the "return 0;" below.
controller_thread_delete_simple(global->thread);
controller_process_delete(global->setting);
- controller_main_delete(global->main);
+ controller_delete(global->main);
}
return 0;
}
-#endif // _di_controller_main_thread_control_
+#endif // _di_controller_thread_control_
#ifdef __cplusplus
} // extern "C"
* @return
* 0, always.
*/
-#ifndef _di_controller_main_thread_control_
- extern void * controller_main_thread_control(void * const arguments);
-#endif // _di_controller_main_thread_control_
+#ifndef _di_controller_thread_control_
+ extern void * controller_thread_control(void * const arguments);
+#endif // _di_controller_thread_control_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_thread_entry_
- void * controller_main_thread_entry(void * const arguments) {
+#ifndef _di_controller_thread_entry_
+ void * controller_thread_entry(void * const arguments) {
if (!arguments) return 0;
controller_global_t * const global = (controller_global_t * const) arguments;
- if (!controller_main_thread_is_enabled(F_true, global->thread)) return 0;
+ if (!controller_thread_is_enabled(F_true, global->thread)) return 0;
f_status_t * const status = &global->thread->status;
- *status = controller_main_entry_read(global, F_true);
+ *status = controller_entry_read(global, F_true);
if (F_status_set_fine(*status) == F_interrupt) {
global->program->ready = controller_program_ready_abort_e;
global->program->ready = controller_program_ready_fail_e;
}
else if (*status != F_child) {
- *status = controller_main_entry_preprocess(global, F_true);
+ *status = controller_entry_preprocess(global, F_true);
if ((global->main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) && (global->main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) {
- controller_main_entry_setting_validate(global, F_true);
+ controller_entry_setting_validate(global, F_true);
}
}
*status = F_status_set_error(F_available_not);
global->program->ready = controller_program_ready_fail_e;
- controller_main_print_error_file_pid_exists(&global->main->program.error, global->thread, global->program->path_pid);
+ controller_print_error_file_pid_exists(&global->main->program.error, global->thread, global->program->path_pid);
}
else {
- *status = controller_main_entry_process(global, F_false, F_true);
+ *status = controller_entry_process(global, F_false, F_true);
if (F_status_is_error(*status)) {
global->program->ready = controller_program_ready_fail_e;
// Restart the signal global->thread to allow for signals while operating the failsafe Items.
if (!global->thread->id_signal) {
- f_thread_create(0, &global->thread->id_signal, &controller_main_thread_signal_normal, (void *) global);
+ f_thread_create(0, &global->thread->id_signal, &controller_thread_signal_normal, (void *) global);
}
- const f_status_t status_failsafe = controller_main_entry_process(global, F_true, F_true);
+ const f_status_t status_failsafe = controller_entry_process(global, F_true, F_true);
if (F_status_is_error(status_failsafe)) {
*status = F_status_set_error(F_failure);
- controller_main_print_error_failsafe_item(&global->main->program.error, global->thread, global->program->entry.items.array[program->failsafe_item_id].name);
+ controller_print_error_failsafe_item(&global->main->program.error, global->thread, global->program->entry.items.array[program->failsafe_item_id].name);
}
else {
if (F_status_is_error_not(*status) && *status != F_child && global->main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e && global->program->mode == controller_program_mode_helper_e) {
f_time_spec_t time;
- time.tv_sec = controller_main_thread_exit_helper_timeout_seconds_d;
- time.tv_nsec = controller_main_thread_exit_helper_timeout_nanoseconds_d;
+ time.tv_sec = controller_thread_exit_helper_timeout_seconds_d;
+ time.tv_nsec = controller_thread_exit_helper_timeout_nanoseconds_d;
nanosleep(&time, 0);
- controller_main_thread_instance_cancel(global, F_true, controller_thread_cancel_exit_e);
+ controller_thread_instance_cancel(global, F_true, controller_thread_cancel_exit_e);
}
}
}
// It seems that this function doesn't return to the calling thread for a forked child process, even with the "return 0;" below.
controller_thread_delete(global->thread);
controller_program_delete(global->program);
- controller_main_delete(global->main);
+ controller_delete(global->main);
// According to the manpages, pthread_exit() calls exit(0), which the value of global->main->program.child should be returned instead.
if (global->main->program.child) exit(global->main->program.child);
return 0;
}
-#endif // _di_controller_main_thread_entry_
+#endif // _di_controller_thread_entry_
-#ifndef _di_controller_main_thread_exit_
- void * controller_main_thread_exit(void * const arguments) {
+#ifndef _di_controller_thread_exit_
+ void * controller_thread_exit(void * const arguments) {
if (!arguments) return 0;
controller_global_t * const global = (controller_global_t * const) arguments;
- controller_main_t * const main = global->main;
+ controller_t * const main = global->main;
controller_cache_t * const cache = &global->thread->cache;
f_status_t * const status = &global->thread->status;
// Restart the signal thread to allow for signals while operating the failsafe Items.
if (!global->thread->id_signal) {
- f_thread_create(0, &global->thread->id_signal, &controller_main_thread_signal_other, (void *) global);
+ f_thread_create(0, &global->thread->id_signal, &controller_thread_signal_other, (void *) global);
}
}
if (F_status_is_error(status_failsafe)) {
*status = F_status_set_error(F_failure);
- controller_main_print_error_failsafe_item(&global->main->program.error, global->thread, global->program->entry.items.array[program->failsafe_item_id].name);
+ controller_print_error_failsafe_item(&global->main->program.error, global->thread, global->program->entry.items.array[program->failsafe_item_id].name);
}
else {
// It seems that this function doesn't return to the calling thread for a forked child process, even with the "return 0;" below.
controller_thread_delete_simple(global->thread);
controller_process_delete(global->program);
- controller_main_delete(main);
+ controller_delete(main);
return 0;
}
return 0;
}
-#endif // _di_controller_main_thread_exit_
+#endif // _di_controller_thread_exit_
#ifdef __cplusplus
} // extern "C"
* @return
* 0, always.
*/
-#ifndef _di_controller_main_thread_entry_
- extern void * controller_main_thread_entry(void * const arguments);
-#endif // _di_controller_main_thread_entry_
+#ifndef _di_controller_thread_entry_
+ extern void * controller_thread_entry(void * const arguments);
+#endif // _di_controller_thread_entry_
/**
* Thread for handling exit file processing.
* @return
* 0, always.
*/
-#ifndef _di_controller_main_thread_exit_
- extern void * controller_main_thread_exit(void * const arguments);
-#endif // _di_controller_main_thread_exit_
+#ifndef _di_controller_thread_exit_
+ extern void * controller_thread_exit(void * const arguments);
+#endif // _di_controller_thread_exit_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_thread_instance_
- void controller_main_thread_instance(const uint8_t is_normal, controller_instance_t * const instance) {
+#ifndef _di_controller_thread_instance_
+ void controller_thread_instance(const uint8_t is_normal, controller_instance_t * const instance) {
if (!instance) return;
- if (!controller_main_thread_is_enabled(is_normal, (controller_thread_t * const) instance->thread)) return;
+ if (!controller_thread_is_enabled(is_normal, (controller_thread_t * const) instance->thread)) return;
- const f_status_t status = controller_main_rule_instance_do(controller_instance_option_asynchronous_e, instance);
+ const f_status_t status = controller_rule_instance_do(controller_instance_option_asynchronous_e, instance);
// A forked child instance should de-allocate 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.
if (status == F_child) {
controller_thread_delete_simple(instance->main_thread);
controller_process_delete(instance->program);
- controller_main_delete(instance->main_data);
+ controller_delete(instance->main_data);
// According to some man pages, pthread_exit() calls exit(0), so expliticly exit to ensure a non-zero code is returned when needed.
if (instance->main_data->program.child) exit(instance->main_data->program.child);
}
}
-#endif // _di_controller_main_thread_instance_
+#endif // _di_controller_thread_instance_
-#ifndef _di_controller_main_thread_instance_cancel_
- void controller_main_thread_instance_cancel(controller_instance_t * const global, const uint8_t is_normal, const uint8_t by) {
+#ifndef _di_controller_thread_instance_cancel_
+ void controller_thread_instance_cancel(controller_global_t * const global, const uint8_t is_normal, const uint8_t by) {
if (!global) return;
f_thread_mutex_lock(&global->thread->lock.cancel);
// Only cancel when enabled.
- if (!controller_main_thread_is_enabled(is_normal, global->thread)) {
+ if (!controller_thread_is_enabled(is_normal, global->thread)) {
f_thread_mutex_unlock(&global->thread->lock.cancel);
return;
if (!instance->id_thread) continue;
- controller_main_thread_detach(&instance->id_thread);
+ controller_thread_detach(&instance->id_thread);
instance->id_thread = 0;
} // for
time.tv_sec = 0;
time.tv_nsec = interval_nanoseconds;
- f_time_sleep_spec(&time, 0);
+ f_time_sleep_spec(time, 0);
lapsed += interval_milliseconds;
}
time.tv_sec = 0;
time.tv_nsec = interval_nanoseconds;
- f_time_sleep_spec(&time, 0);
+ f_time_sleep_spec(time, 0);
lapsed += interval_milliseconds;
}
f_signal_send(F_signal_kill, instance->childs.array[j]);
time.tv_sec = 0;
- time.tv_nsec = controller_main_thread_exit_process_cancel_wait_d;
+ time.tv_nsec = controller_thread_exit_process_cancel_wait_d;
instance->childs.array[j] = 0;
}
} // for
- f_time_sleep_spec(&time, 0);
+ f_time_sleep_spec(time, 0);
}
f_thread_join(instance->id_thread, 0);
f_thread_mutex_unlock(&global->thread->lock.cancel);
}
-#endif // _di_controller_main_thread_instance_cancel_
+#endif // _di_controller_thread_instance_cancel_
-#ifndef _di_controller_main_thread_instance_exit_
- void controller_main_thread_instance_exit(controller_global_t * const global) {
+#ifndef _di_controller_thread_instance_exit_
+ void controller_thread_instance_exit(controller_global_t * const global) {
if (!global) return;
// Restart the signal thread to allow for signals while operating the Exit.
if (!global->thread->id_signal) {
- f_thread_create(0, &global->thread->id_signal, &controller_main_thread_signal_other, (void *) global);
+ f_thread_create(0, &global->thread->id_signal, &controller_thread_signal_other, (void *) global);
}
- const controller_main_entry_t entry = macro_controller_main_entry_t_initialize_1(global, global->setting);
-
- f_status_t status = f_thread_create(0, &global->thread->id_entry, &controller_main_thread_exit, (void *) &entry);
+ f_status_t status = f_thread_create(0, &global->thread->id_entry, &controller_thread_exit, (void *) global);
if (F_status_is_error(status)) {
if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
- controller_main_print_error_status(&global->main->program.error, macro_controller_f(f_thread_create), F_status_set_fine(status));
+ controller_print_error_status(&global->main->program.error, macro_controller_f(f_thread_create), F_status_set_fine(status));
}
if (F_status_is_error_not(f_thread_mutex_lock(&global->thread->lock.alert))) {
break;
}
- controller_main_time_now(controller_main_thread_exit_ready_timeout_seconds_d, controller_main_thread_exit_ready_timeout_nanoseconds_d, &time);
+ controller_time_now(controller_thread_exit_ready_timeout_seconds_d, controller_thread_exit_ready_timeout_nanoseconds_d, &time);
status = f_thread_condition_wait_timed(&time, &global->thread->lock.alert_condition, &global->thread->lock.alert);
global->thread->id_signal = 0;
}
- controller_main_thread_instance_cancel(*global, F_false, controller_thread_cancel_exit_e);
+ controller_thread_instance_cancel(global, F_false, controller_thread_cancel_exit_e);
}
else {
if (F_status_is_error_not(f_thread_mutex_lock(&global->thread->lock.alert))) {
}
}
}
-#endif // _di_controller_main_thread_instance_exit_
+#endif // _di_controller_thread_instance_exit_
-#ifndef _di_controller_main_thread_instance_normal_
- void * controller_main_thread_instance_normal(void * const arguments) {
+#ifndef _di_controller_thread_instance_normal_
+ void * controller_thread_instance_normal(void * const arguments) {
if (!arguments) return 0;
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_main_thread_instance(F_true, (controller_instance_t * const) arguments);
+ controller_thread_instance(F_true, (controller_instance_t * const) arguments);
return 0;
}
-#endif // _di_controller_main_thread_instance_normal_
+#endif // _di_controller_thread_instance_normal_
-#ifndef _di_controller_main_thread_instance_other_
- void * controller_main_thread_instance_other(void * const arguments) {
+#ifndef _di_controller_thread_instance_other_
+ void * controller_thread_instance_other(void * const arguments) {
if (!arguments) return 0;
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_main_thread_instance(F_false, (controller_instance_t * const) arguments);
+ controller_thread_instance(F_false, (controller_instance_t * const) arguments);
return 0;
}
-#endif // _di_controller_main_thread_instance_other_
+#endif // _di_controller_thread_instance_other_
#ifdef __cplusplus
} // extern "C"
*
* Must not be NULL.
*
- * @see controller_main_rule_instance_do()
+ * @see controller_rule_instance_do()
*/
-#ifndef _di_controller_main_thread_instance_
- extern void controller_main_thread_instance(const uint8_t is_normal, controller_instance_t * const instance);
-#endif // _di_controller_main_thread_instance_
+#ifndef _di_controller_thread_instance_
+ extern void controller_thread_instance(const uint8_t is_normal, controller_instance_t * const instance);
+#endif // _di_controller_thread_instance_
/**
* Cancel all process threads.
* If controller_thread_cancel_call_e, then this was not called from within the signal handling thread, so cancel the signal thread.
* If controller_thread_cancel_execute_e, then this was called from within the Entry/Exit for executing a process, so cancel the signal thread but not the Entry thread.
*/
-#ifndef _di_controller_main_thread_instance_cancel_
- extern void controller_main_thread_instance_cancel(controller_global_t * const global, const uint8_t is_normal, const uint8_t by);
-#endif // _di_controller_main_thread_instance_cancel_
+#ifndef _di_controller_thread_instance_cancel_
+ extern void controller_thread_instance_cancel(controller_global_t * const global, const uint8_t is_normal, const uint8_t by);
+#endif // _di_controller_thread_instance_cancel_
/**
* Process the Exit file, if applicable.
*
* This does not alter global.main.setting.state.status.
*/
-#ifndef _di_controller_main_thread_instance_exit_
- extern void controller_main_thread_instance_exit(controller_global_t * const global);
-#endif // _di_controller_main_thread_instance_exit_
+#ifndef _di_controller_thread_instance_exit_
+ extern void controller_thread_instance_exit(controller_global_t * const global);
+#endif // _di_controller_thread_instance_exit_
/**
* Asynchronously execute a Rule process during normal operations.
* @return
* 0, always.
*
- * @see controller_main_thread_instance()
+ * @see controller_thread_instance()
*/
-#ifndef _di_controller_main_thread_instance_normal_
- extern void * controller_main_thread_instance_normal(void * const global);
-#endif // _di_controller_main_thread_instance_normal_
+#ifndef _di_controller_thread_instance_normal_
+ extern void * controller_thread_instance_normal(void * const global);
+#endif // _di_controller_thread_instance_normal_
/**
* Asynchronously execute a Rule process during other operations.
* @return
* 0, always.
*
- * @see controller_main_thread_instance()
+ * @see controller_thread_instance()
*/
-#ifndef _di_controller_main_thread_instance_other_
- extern void * controller_main_thread_instance_other(void * const arguments);
-#endif // _di_controller_main_thread_instance_other_
+#ifndef _di_controller_thread_instance_other_
+ extern void * controller_thread_instance_other(void * const arguments);
+#endif // _di_controller_thread_instance_other_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_thread_is_enabled_
- f_status_t controller_main_thread_is_enabled(const uint8_t is_normal, controller_thread_t * const thread) {
+#ifndef _di_controller_thread_is_enabled_
+ f_status_t controller_thread_is_enabled(const uint8_t is_normal, controller_thread_t * const thread) {
if (!thread) return F_false;
return is_normal ? thread->enabled == controller_thread_enabled_e : thread->enabled;
}
-#endif // _di_controller_main_thread_is_enabled_
+#endif // _di_controller_thread_is_enabled_
-#ifndef _di_controller_main_thread_is_enabled_instance_
- f_status_t controller_main_thread_is_enabled_instance(controller_instance_t * const instance, controller_thread_t * const thread) {
+#ifndef _di_controller_thread_is_enabled_instance_
+ f_status_t controller_thread_is_enabled_instance(controller_instance_t * const instance) {
if (!instance) return F_false;
- return controller_main_thread_is_enabled_instance_type(instance->type, thread);
+ return controller_thread_is_enabled_instance_type(instance->type, instance->global->thread);
}
-#endif // _di_controller_main_thread_is_enabled_instance_
+#endif // _di_controller_thread_is_enabled_instance_
-#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) {
+#ifndef _di_controller_thread_is_enabled_instance_type_
+ f_status_t controller_thread_is_enabled_instance_type(const uint8_t type, controller_thread_t * const thread) {
- return controller_main_thread_is_enabled(type != controller_instance_type_exit_e, thread);
+ return controller_thread_is_enabled(type != controller_instance_type_exit_e, thread);
}
-#endif // _di_controller_main_thread_is_enabled_instance_type_
+#endif // _di_controller_thread_is_enabled_instance_type_
#ifdef __cplusplus
} // extern "C"
* F_true when enabled.
* F_false when disabled.
*/
-#ifndef _di_controller_main_thread_is_enabled_
- extern f_status_t controller_main_thread_is_enabled(const uint8_t is_normal, controller_thread_t * const thread);
-#endif // _di_controller_main_thread_is_enabled_
+#ifndef _di_controller_thread_is_enabled_
+ extern f_status_t controller_thread_is_enabled(const uint8_t is_normal, controller_thread_t * const thread);
+#endif // _di_controller_thread_is_enabled_
/**
* Check to see if thread is enabled for the normal operations like entry and control or for exit operations for some instance.
* The instance to use when checking if thread is enabled.
*
* Must not be NULL.
- * @param thread
- * The thread data.
- *
- * Must not be NULL.
*
* @return
* F_true when enabled.
* F_false when disabled or when parameter is invalid..
*
- * @see controller_main_thread_is_enabled_instance_type()
+ * @see controller_thread_is_enabled_instance_type()
*/
-#ifndef _di_controller_main_thread_is_enabled_instance_
- extern f_status_t controller_main_thread_is_enabled_instance(controller_instance_t * const instance, controller_thread_t * const thread);
-#endif // _di_controller_main_thread_is_enabled_instance_
+#ifndef _di_controller_thread_is_enabled_instance_
+ extern f_status_t controller_thread_is_enabled_instance(controller_instance_t * const instance);
+#endif // _di_controller_thread_is_enabled_instance_
/**
* Check to see if thread is enabled for the normal operations like entry and control or for exit operations for some instance type.
* Must not be NULL.
*
* @return
- * Success from controller_main_thread_is_enabled().
+ * Success from controller_thread_is_enabled().
*
- * @see controller_main_thread_is_enabled()
+ * @see controller_thread_is_enabled()
*/
-#ifndef _di_controller_main_thread_is_enabled_instance_type_
- extern f_status_t controller_main_thread_is_enabled_instance_type(const uint8_t type, controller_thread_t * const thread);
-#endif // _di_controller_main_thread_is_enabled_instance_type_
+#ifndef _di_controller_thread_is_enabled_instance_type_
+ extern f_status_t controller_thread_is_enabled_instance_type(const uint8_t type, controller_thread_t * const thread);
+#endif // _di_controller_thread_is_enabled_instance_type_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_thread_rule_
- void * controller_main_thread_rule(void * const arguments) {
+#ifndef _di_controller_thread_rule_
+ void * controller_thread_rule(void * const arguments) {
if (!arguments) return 0;
controller_global_t * const global = (controller_global_t * const) arguments;
- if (!controller_main_thread_is_enabled(F_true, global->thread)) return 0;
+ if (!controller_thread_is_enabled(F_true, global->thread)) return 0;
return 0;
}
-#endif // _di_controller_main_thread_rule_
+#endif // _di_controller_thread_rule_
#ifdef __cplusplus
} // extern "C"
* @return
* 0, always.
*/
-#ifndef _di_controller_main_thread_rule_
- extern void * controller_main_thread_rule(void * const arguments);
-#endif // _di_controller_main_thread_rule_
+#ifndef _di_controller_thread_rule_
+ extern void * controller_thread_rule(void * const arguments);
+#endif // _di_controller_thread_rule_
#ifdef __cplusplus
} // extern "C"
-#include "controller.h"
+#include "../controller.h"
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef _di_controller_main_thread_signal_
- void controller_main_thread_signal(controller_global_t * const global, const bool is_normal) {
+#ifndef _di_controller_thread_signal_
+ void controller_thread_signal(controller_global_t * const global, const bool is_normal) {
if (!global || !global->main || !global->thread) return;
- if (!controller_main_thread_is_enabled(is_normal, global->thread)) return;
+ if (!controller_thread_is_enabled(is_normal, global->thread)) return;
if (!(global->main->setting.flag & controller_main_flag_interruptible_e)) return;
f_status_t status = F_okay;
siginfo_t information;
f_time_spec_t time = f_time_spec_t_initialize;
- while (controller_main_thread_is_enabled(is_normal, global->thread)) {
+ while (controller_thread_is_enabled(is_normal, global->thread)) {
- controller_main_time_now(controller_main_thread_exit_ready_timeout_seconds_d, controller_main_thread_exit_ready_timeout_nanoseconds_d, &time);
+ controller_time_now(controller_thread_exit_ready_timeout_seconds_d, controller_thread_exit_ready_timeout_nanoseconds_d, &time);
memset((void *) &information, 0, sizeof(siginfo_t));
if (information.si_signo == F_signal_interrupt || information.si_signo == F_signal_abort || information.si_signo == F_signal_quit || information.si_signo == F_signal_termination) {
global->thread->signal = information.si_signo;
- controller_main_thread_instance_cancel(global, is_normal, controller_thread_cancel_signal_e);
+ controller_thread_instance_cancel(global, is_normal, controller_thread_cancel_signal_e);
break;
}
} // while
}
-#endif // _di_controller_main_thread_signal_
+#endif // _di_controller_thread_signal_
-#ifndef _di_controller_main_thread_signal_state_fss_
- void controller_main_thread_signal_state_fss(f_state_t * const state, void * const internal) {
+#ifndef _di_controller_thread_signal_state_fss_
+ void controller_thread_signal_state_fss(f_state_t * const state, void * const internal) {
if (!state || !state->custom) return;
- controller_global_t * const global = (controller_global_t *) state->custom;
+ controller_interrupt_t * const interrupt = (controller_interrupt_t *) state->custom;
- if (!controller_main_thread_is_enabled(custom->is_normal, global->thread)) {
- global->main->program.signal_received = F_signal_abort;
- global->main->setting.state.status = F_status_set_error(F_interrupt);
+ if (!interrupt->global || !interrupt->global->main || !interrupt->global->thread) return;
+
+ if (!controller_thread_is_enabled(interrupt->is_normal, interrupt->global->thread)) {
+ interrupt->global->main->program.signal_received = F_signal_abort;
+ interrupt->global->main->setting.state.status = F_status_set_error(F_interrupt);
}
- else if (global->thread->signal == F_signal_interrupt || global->thread->signal == F_signal_abort || global->thread->signal == F_signal_quit || global->thread->signal == F_signal_termination) {
- global->main->program.signal_received = F_signal_abort;
- global->main->setting.state.status = F_status_set_error(F_interrupt);
+ else if (interrupt->global->thread->signal == F_signal_interrupt || interrupt->global->thread->signal == F_signal_abort || interrupt->global->thread->signal == F_signal_quit || interrupt->global->thread->signal == F_signal_termination) {
+ interrupt->global->main->program.signal_received = F_signal_abort;
+ interrupt->global->main->setting.state.status = F_status_set_error(F_interrupt);
}
}
-#endif // _di_controller_main_thread_signal_state_fss_
+#endif // _di_controller_thread_signal_state_fss_
-#ifndef _di_controller_main_thread_signal_state_iki_
- void controller_main_thread_signal_state_iki(f_state_t * const state, void * const internal) {
+#ifndef _di_controller_thread_signal_state_iki_
+ void controller_thread_signal_state_iki(f_state_t * const state, void * const internal) {
if (!state || !state->custom) return;
- controller_global_t * const global = (controller_global_t *) state->custom;
+ controller_interrupt_t * const interrupt = (controller_interrupt_t *) state->custom;
+
+ if (!interrupt->global || !interrupt->global->main || !interrupt->global->thread) return;
- if (!controller_main_thread_is_enabled(custom->is_normal, global->thread)) {
- global->main->program.signal_received = F_signal_abort;
- global->main->setting.state.status = F_status_set_error(F_interrupt);
+ if (!controller_thread_is_enabled(interrupt->is_normal, interrupt->global->thread)) {
+ interrupt->global->main->program.signal_received = F_signal_abort;
+ interrupt->global->main->setting.state.status = F_status_set_error(F_interrupt);
}
- else if (global->thread->signal == F_signal_interrupt || global->thread->signal == F_signal_abort || global->thread->signal == F_signal_quit || global->thread->signal == F_signal_termination) {
- global->main->program.signal_received = F_signal_abort;
- global->main->setting.state.status = F_status_set_error(F_interrupt);
+ else if (interrupt->global->thread->signal == F_signal_interrupt || interrupt->global->thread->signal == F_signal_abort || interrupt->global->thread->signal == F_signal_quit || interrupt->global->thread->signal == F_signal_termination) {
+ interrupt->global->main->program.signal_received = F_signal_abort;
+ interrupt->global->main->setting.state.status = F_status_set_error(F_interrupt);
}
}
-#endif // _di_controller_main_thread_signal_state_iki_
+#endif // _di_controller_thread_signal_state_iki_
-#ifndef _di_controller_main_thread_signal_normal_
- void * controller_main_thread_signal_normal(void * const global) {
+#ifndef _di_controller_thread_signal_normal_
+ void * controller_thread_signal_normal(void * const global) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_main_thread_signal((controller_global_t * const) global, F_true);
+ controller_thread_signal((controller_global_t * const) global, F_true);
return 0;
}
-#endif // _di_controller_main_thread_signal_normal_
+#endif // _di_controller_thread_signal_normal_
-#ifndef _di_controller_main_thread_signal_other_
- void * controller_main_thread_signal_other(void * const global) {
+#ifndef _di_controller_thread_signal_other_
+ void * controller_thread_signal_other(void * const global) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_main_thread_signal((controller_global_t * const) global, F_false);
+ controller_thread_signal((controller_global_t * const) global, F_false);
return 0;
}
-#endif // _di_controller_main_thread_signal_other_
+#endif // _di_controller_thread_signal_other_
#ifdef __cplusplus
} // extern "C"
* If TRUE, then process as if this operates during a normal operation (entry and control).
* If FALSE, then process as if this operates during a an exit operation.
*/
-#ifndef _di_controller_main_thread_signal_
- extern void controller_main_thread_signal(controller_global_t * const global, const bool is_normal);
-#endif // _di_controller_main_thread_signal_
+#ifndef _di_controller_thread_signal_
+ extern void controller_thread_signal(controller_global_t * const global, const bool is_normal);
+#endif // _di_controller_thread_signal_
/**
* Callback passed to FSS functions for checking for interrupts.
* @param internal
* Not used.
*/
-#ifndef _di_controller_main_thread_signal_state_fss_
- extern void controller_main_thread_signal_state_fss(f_state_t * const state, void * const internal);
-#endif // _di_controller_main_thread_signal_state_fss_
+#ifndef _di_controller_thread_signal_state_fss_
+ extern void controller_thread_signal_state_fss(f_state_t * const state, void * const internal);
+#endif // _di_controller_thread_signal_state_fss_
/**
* Callback passed to IKI functions for checking for interrupts.
* @param internal
* Not used.
*/
-#ifndef _di_controller_main_thread_signal_state_iki_
- extern void controller_main_thread_signal_state_iki(f_state_t * const state, void * const internal);
-#endif // _di_controller_main_thread_signal_state_iki_
+#ifndef _di_controller_thread_signal_state_iki_
+ extern void controller_thread_signal_state_iki(f_state_t * const state, void * const internal);
+#endif // _di_controller_thread_signal_state_iki_
/**
* Thread for handling signals/interrupts during normal operations.
* @return
* 0, always.
*
- * @see controller_main_thread_signal()
+ * @see controller_thread_signal()
*/
-#ifndef _di_controller_main_thread_signal_normal_
- extern void * controller_main_thread_signal_normal(void * const global);
-#endif // _di_controller_main_thread_signal_normal_
+#ifndef _di_controller_thread_signal_normal_
+ extern void * controller_thread_signal_normal(void * const global);
+#endif // _di_controller_thread_signal_normal_
/**
* Thread for handling signals/interrupts during other operations.
* @return
* 0, always.
*
- * @see controller_main_thread_signal()
+ * @see controller_thread_signal()
*/
-#ifndef _di_controller_main_thread_signal_other_
- extern void * controller_main_thread_signal_other(void * const global);
-#endif // _di_controller_main_thread_signal_other_
+#ifndef _di_controller_thread_signal_other_
+ extern void * controller_thread_signal_other(void * const global);
+#endif // _di_controller_thread_signal_other_
#ifdef __cplusplus
} // extern "C"
extern "C" {
#endif
-#ifndef _di_controller_main_time_now_
- void controller_main_time_now(const time_t seconds, const long nanoseconds, f_time_spec_t * const time) {
+#ifndef _di_controller_time_now_
+ void controller_time_now(const time_t seconds, const long nanoseconds, f_time_spec_t * const time) {
{
f_time_value_t now = f_time_value_t_initialize;
time->tv_nsec -= 1000000000;
}
}
-#endif // _di_controller_main_time_now_
+#endif // _di_controller_time_now_
-/*
-#ifndef _di_controller_main_time_milliseconds_
- f_time_spec_t controller_main_time_milliseconds(const f_number_unsigned_t milliseconds) {
-
- f_time_spec_t time;
-
- f_time_spec_millisecond(0, milliseconds, &time);
-
- return time;
- }
-#endif // _di_controller_main_time_milliseconds_
-
-#ifndef _di_controller_main_time_seconds_
- f_time_simple_t controller_main_time_seconds(const f_number_unsigned_t seconds) {
-
- f_time_spec_t time;
-
- f_time_spec_millisecond(seconds, 0, &time);
-
- return time;
- }
-#endif // _di_controller_main_time_seconds_
-*/
-
-#ifndef _di_controller_main_time_sleep_nanoseconds_
- f_status_t controller_main_time_sleep_nanoseconds(controller_global_t * const global, const f_time_spec_t time) {
+#ifndef _di_controller_time_sleep_nanoseconds_
+ f_status_t controller_time_sleep_nanoseconds(controller_global_t * const global, const f_time_spec_t time) {
if (!global || !global->main) return F_status_set_error(F_parameter);
// When sleep is a second or more, instead wait for terminating signals if interruptible.
- if ((global->main->setting.flag & controller_main_flag_interruptible_e) && time.tv_sec) {
+ if ((global->main->program.flag & controller_main_flag_interruptible_e) && time.tv_sec) {
siginfo_t information;
f_signal_t signal = f_signal_t_initialize;
return f_time_sleep_spec(time, 0);
}
-#endif // _di_controller_main_time_sleep_nanoseconds_
+#endif // _di_controller_time_sleep_nanoseconds_
#ifdef __cplusplus
} // extern "C"
*
* This is auto-included and should not need to be explicitly included.
*/
-#ifndef _controller_main_time_h
-#define _controller_main_time_h
+#ifndef _controller_time_h
+#define _controller_time_h
/**
* Get the current time, plus the given offset.
*
* @see f_time_of_day_get()
*/
-#ifndef _di_controller_main_time_now_
- extern void controller_main_time_now(const time_t seconds, const long nanoseconds, f_time_spec_t * const time);
-#endif // _di_controller_main_time_now_
+#ifndef _di_controller_time_now_
+ extern void controller_time_now(const time_t seconds, const long nanoseconds, f_time_spec_t * const time);
+#endif // _di_controller_time_now_
/**
* Sleep for the given time.
*
* @see f_time_of_day_get()
*/
-#ifndef _di_controller_main_time_sleep_nanoseconds_
- extern f_status_t controller_main_time_sleep_nanoseconds(controller_global_t * const global, const f_time_spec_t time);
-#endif // _di_controller_main_time_sleep_nanoseconds_
+#ifndef _di_controller_time_sleep_nanoseconds_
+ extern f_status_t controller_time_sleep_nanoseconds(controller_global_t * const global, const f_time_spec_t time);
+#endif // _di_controller_time_sleep_nanoseconds_
#ifdef __cplusplus
} // extern "C"
#endif
-#endif // _controller_main_time_h
+#endif // _controller_time_h