A lot of the changes made it possible to remove th controller_global_t.
Restructure the code to do this.
Most of the compile errors are fixed.
I still need to go over the logic and fix things.
I still need to copy over some functions.
I still need to move the print functions around.
I still need to do runtime tests once all of the above is completed.
build_libraries-monolithic -lfll
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/type/cache.c main/common/type/control.c main/common/type/entry.c main/common/type/execute.c main/common/type/instance.c main/common/type/interrupt.c main/common/type/lock.c main/common/type/process.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/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/print/rule/action.c main/print/rule/item.c main/print/rule/setting.c
build_sources_library main/signal.c main/time.c
build_sources_library main/thread.c main/thread/cleanup.c main/thread/control.c main/thread/entry.c main/thread/instance.c main/thread/is.c main/thread/rule.c main/thread/signal.c
+build_sources_library main/validate.c
build_sources_headers main/common.h main/controller.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/string.h main/common/thread.h main/common/type.h
build_sources_headers main/common/define/control.h main/common/define/entry.h main/common/define/rule.h main/common/define/thread.h
-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/enumeration/control.h main/common/enumeration/entry.h main/common/enumeration/instance.h main/common/enumeration/process.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/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/instance.h main/common/type/interrupt.h main/common/type/lock.h main/common/type/process.h main/common/type/rule.h main/common/type/thread.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/rule/action.h main/print/rule/item.h main/print/rule/setting.h
build_sources_headers main/signal.h main/time.h
build_sources_headers main/thread.h main/thread/cleanup.h main/thread/control.h main/thread/entry.h main/thread/instance.h main/thread/is.h main/thread/rule.h main/thread/signal.h
+build_sources_headers main/validate.h
build_sources_documentation man
int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
controller_t data = controller_t_initialize;
- controller_program_t program = controller_program_t_initialize;
+ controller_process_t process = controller_process_t_initialize;
+ controller_thread_t thread = controller_thread_t_initialize;
data.program.debug.flag |= controller_print_flag_debug_e | controller_print_flag_out_e;
data.program.error.flag |= controller_print_flag_error_e | controller_print_flag_out_e;
data.program.pipe = fll_program_data_pipe_input_e;
}
+ data.process = &process;
data.setting.flag |= controller_main_flag_interruptible_e;
+ data.thread = &thread;
fll_program_standard_set_up(&data.program);
{
const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp);
- controller_setting_load(arguments, &data, &program);
+ controller_setting_load(arguments, &data);
}
- controller_process(&data, &program);
+ controller_process(&data);
controller_delete(&data);
int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
controller_t data = controller_t_initialize;
- controller_program_t program = controller_program_t_initialize;
+ controller_process_t process = controller_process_t_initialize;
+ controller_thread_t thread = controller_thread_t_initialize;
data.program.debug.flag |= controller_print_flag_debug_e | controller_print_flag_out_e;
data.program.error.flag |= controller_print_flag_error_e | controller_print_flag_out_e;
data.program.pipe = fll_program_data_pipe_input_e;
}
+ data.process = &process;
data.setting.flag &= ~controller_main_flag_interruptible_e;
- program.entry.pid = controller_entry_pid_disable_e;
- program.entry.show = controller_entry_show_init_e;
- program.mode = controller_program_mode_service_e;
+ data.thread = &thread;
+
+ process.entry.pid = controller_entry_pid_disable_e;
+ process.entry.show = controller_entry_show_init_e;
+ process.mode = controller_process_mode_service_e;
fll_program_standard_set_up(&data.program);
{
const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp);
- controller_setting_load(arguments, &data, &program);
+ controller_setting_load(arguments, &data);
}
- controller_process(&data, &program);
+ controller_process(&data);
fll_program_standard_set_down(&data.program);
#endif // _di_controller_range_after_number_sign_
#ifndef _di_controller_setting_load_
- void controller_setting_load(const f_console_arguments_t arguments, controller_t * const main, controller_program_t * const program) {
+ void controller_setting_load(const f_console_arguments_t arguments, controller_t * const main) {
- if (!main || !program) return;
+ if (!main) return;
main->setting.state.step_small = controller_allocation_console_d;
f_string_static_t * const args = main->program.parameters.arguments.array;
f_number_unsigned_t index = 0;
- program->control.server.domain = f_socket_protocol_family_local_e;
- program->control.server.type = f_socket_type_stream_e;
- program->control.server.form = f_socket_address_form_local_e;
+ main->process.control.server.domain = f_socket_protocol_family_local_e;
+ main->process.control.server.type = f_socket_type_stream_e;
+ main->process.control.server.form = f_socket_address_form_local_e;
- memset(&program->control.server.address, 0, sizeof(f_socket_address_t));
+ memset(&main->process.control.server.address, 0, sizeof(f_socket_address_t));
{
const uint8_t codes[] = {
}
// The first remaining argument represents the entry name.
- 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);
+ main->setting.state.status = f_string_dynamic_append(main->program.parameters.remaining.used ? args[main->program.parameters.remaining.array[0]] : controller_default_s, &main->process.name_entry);
if (F_status_is_error(main->setting.state.status)) {
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);
+ main->setting.state.status = f_path_current(F_false, &main->process.path_current);
if (F_status_is_error(main->setting.state.status)) {
controller_print_error(&main->program.error, macro_controller_f(f_path_current));
return;
}
- program->path_setting.used = 0;
+ main->process.path_setting.used = 0;
if (main->program.parameters.array[controller_parameter_settings_e].locations.used) {
index = main->program.parameters.array[controller_parameter_settings_e].values.array[main->program.parameters.array[controller_parameter_settings_e].values.used - 1];
- controller_path_canonical_relative(main, program->path_current, args[index], &program->path_setting);
+ controller_path_canonical_relative(main, main->process.path_current, args[index], &main->process.path_setting);
if (F_status_is_error(main->setting.state.status)) {
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);
}
}
else {
- main->setting.state.status = f_string_dynamic_append(controller_default_path_settings_s, &program->path_setting);
+ main->setting.state.status = f_string_dynamic_append(controller_default_path_settings_s, &main->process.path_setting);
if (F_status_is_error(main->setting.state.status)) {
controller_print_error(&main->program.error, macro_controller_f(f_string_dynamic_append));
}
}
- if (!program->path_pid.used && !main->program.parameters.array[controller_parameter_pid_e].locations.used) {
- main->setting.state.status = f_string_dynamic_append(controller_default_path_pid_s, &program->path_pid);
+ if (!main->process.path_pid.used && !main->program.parameters.array[controller_parameter_pid_e].locations.used) {
+ main->setting.state.status = f_string_dynamic_append(controller_default_path_pid_s, &main->process.path_pid);
if (F_status_is_error_not(main->setting.state.status)) {
- main->setting.state.status = f_string_dynamic_append(f_path_separator_s, &program->path_pid);
+ main->setting.state.status = f_string_dynamic_append(f_path_separator_s, &main->process.path_pid);
}
if (F_status_is_error_not(main->setting.state.status)) {
- main->setting.state.status = f_string_dynamic_append(controller_default_path_pid_prefix_s, &program->path_pid);
+ main->setting.state.status = f_string_dynamic_append(controller_default_path_pid_prefix_s, &main->process.path_pid);
}
if (F_status_is_error_not(main->setting.state.status)) {
- main->setting.state.status = f_string_dynamic_append(program->name_entry, &program->path_pid);
+ main->setting.state.status = f_string_dynamic_append(main->process.name_entry, &main->process.path_pid);
}
if (F_status_is_error_not(main->setting.state.status)) {
- main->setting.state.status = f_string_dynamic_append(controller_default_path_pid_suffix_s, &program->path_pid);
+ main->setting.state.status = f_string_dynamic_append(controller_default_path_pid_suffix_s, &main->process.path_pid);
}
if (F_status_is_error(main->setting.state.status)) {
index = main->program.parameters.array[controller_parameter_cgroup_e].values.array[main->program.parameters.array[controller_parameter_cgroup_e].values.used - 1];
if (args[index].used) {
- controller_path_canonical_relative(main, program->path_current, args[index], &program->path_cgroup);
+ controller_path_canonical_relative(main, main->process.path_current, args[index], &main->process.path_cgroup);
if (F_status_is_error(main->setting.state.status)) {
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);
+ main->setting.state.status = f_string_append_assure(F_path_separator_s, 1, &main->process.path_cgroup);
if (F_status_is_error(main->setting.state.status)) {
controller_print_error(&main->program.error, macro_controller_f(f_string_append_assure));
}
}
else {
- main->setting.state.status = f_string_dynamic_append_nulless(f_control_group_path_system_prefix_s, &program->path_cgroup);
+ main->setting.state.status = f_string_dynamic_append_nulless(f_control_group_path_system_prefix_s, &main->process.path_cgroup);
if (F_status_is_error_not(main->setting.state.status)) {
- main->setting.state.status = f_string_dynamic_append_nulless(f_control_group_path_system_default_s, &program->path_cgroup);
+ main->setting.state.status = f_string_dynamic_append_nulless(f_control_group_path_system_default_s, &main->process.path_cgroup);
}
if (F_status_is_error(main->setting.state.status)) {
return;
}
- main->setting.state.status = f_string_dynamic_append_assure(f_path_separator_s, &program->path_cgroup);
+ main->setting.state.status = f_string_dynamic_append_assure(f_path_separator_s, &main->process.path_cgroup);
if (F_status_is_error(main->setting.state.status)) {
controller_print_error(&main->program.error, macro_controller_f(f_string_dynamic_append_assure));
*
* Errors (with error bit) from: f_console_parameter_process().
* Errors (with error bit) from: fll_program_parameter_process_context().
- * @param program
- * A pointer to the current program settings.
- *
- * Must not be NULL.
*
* @see f_console_parameter_process()
* @see fll_program_parameter_process_context()
*/
#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);
+ extern void controller_setting_load(const f_console_arguments_t arguments, controller_t * const main);
#endif // _di_controller_setting_load_
#ifdef __cplusplus
* Instance options.
*
* controller_instance_option_*_e:
- * - asynchronous: The Instance runs asynchronously.
- * - require: The Instance is required.
- * - simulate: The Instance is being simulated.
- * - validate: The Instance is being validated.
- * - wait: The Instance is blocking (waiting) for all asynchronous Instances before it to complete before running.
+ * - asynchronous: The Instance runs asynchronously.
+ * - require: The Instance is required.
+ * - simulate: The Instance is being simulated.
+ * - validate: The Instance is being validated.
+ * - wait: The Instance is blocking (waiting) for all asynchronous Instances before it to complete before running.
+ * - simulate_validate: A helper flag representing simulate and validate flag bits being set.
*/
#ifndef _di_controller_instance_option_e_
enum {
- controller_instance_option_asynchronous_e = 0x1,
- controller_instance_option_require_e = 0x2,
- controller_instance_option_simulate_e = 0x4,
- controller_instance_option_validate_e = 0x8,
- controller_instance_option_wait_e = 0x10,
+ controller_instance_option_asynchronous_e = 0x1,
+ controller_instance_option_require_e = 0x2,
+ controller_instance_option_simulate_e = 0x4,
+ controller_instance_option_validate_e = 0x8,
+ controller_instance_option_wait_e = 0x10,
+ controller_instance_option_simulate_validate_e = 0xc,
}; // enum
#endif // _di_controller_instance_option_e_
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the common process enumerations.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_main_common_enumeration_process_h
+#define _controller_main_common_enumeration_process_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Controller process flags.
+ *
+ * controller_process_flag_*_e:
+ * - interruptible: When specified, process responds to interrupt signals, otherwise block/ignore interrupt signals.
+ * - pid_created: When specified, the process responds to interrupt signals, otherwise block/ignore interrupt signals.
+ * - failsafe: When specified, failsafe mode is enabled, otherwise failsafe mode is disabled.
+ */
+#ifndef _di_controller_process_flag_e_
+ enum {
+ controller_process_flag_interruptible_e = 0x1,
+ controller_process_flag_pid_created_e = 0x2,
+ controller_process_flag_failsafe_e = 0x4,
+ }; // enum
+#endif // _di_controller_process_flag_e_
+
+/**
+ * Controller process mode enumeration.
+ *
+ * controller_process_mode_*:
+ * - helper: Run as a helper, exiting when finished prrocess entry (and any respective exit).
+ * - program: Run as a program, exiting when finished prrocess entry (and any respective exit).
+ * - service: Run as a service, listening for requests after processing entry.
+ */
+#ifndef _di_controller_process_mode_e_
+ enum {
+ controller_process_mode_service_e = 0,
+ controller_process_mode_helper_e,
+ controller_process_mode_program_e,
+ }; // enum
+#endif // _di_controller_process_mode_e_
+
+/**
+ * Controller process ready enumeration.
+ *
+ * controller_process_ready_*_e:
+ * - no: Entry/Exit is not ready.
+ * - wait: Entry/Exit has "ready" somewhere in the file but is not yet ready.
+ * - yes: Entry/Exit is now ready (Entry/Exit is still being processed).
+ * - done: Entry/Exit is ready and processing is complete.
+ * - fail: Entry/Exit processing failed.
+ * - abort: Abort received before finished processing Entry/Exit.
+ */
+#ifndef _di_controller_process_ready_e_
+ enum {
+ controller_process_ready_no_e = 0,
+ controller_process_ready_wait_e,
+ controller_process_ready_yes_e,
+ controller_process_ready_done_e,
+ controller_process_ready_fail_e,
+ controller_process_ready_abort_e,
+ }; // enum
+#endif // _di_controller_process_ready_e_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_main_common_enumeration_process_h
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Controller
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the common program enumerations.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _controller_main_common_enumeration_program_h
-#define _controller_main_common_enumeration_program_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Controller program flags.
- *
- * controller_setting_flag_*_e:
- * - interruptible: When specified, program responds to interrupt signals, otherwise block/ignore interrupt signals.
- * - pid_created: When specified, the program responds to interrupt signals, otherwise block/ignore interrupt signals.
- * - failsafe: When specified, failsafe mode is enabled, otherwise failsafe mode is disabled.
- */
-#ifndef _di_controller_program_flag_e_
- enum {
- controller_program_flag_interruptible_e = 0x1,
- controller_program_flag_pid_created_e = 0x2,
- controller_program_flag_failsafe_e = 0x4,
- }; // enum
-#endif // _di_controller_program_flag_e_
-
-/**
- * Controller program mode enumeration.
- *
- * controller_program_mode_*:
- * - helper: Run as a helper, exiting when finished prrocess entry (and any respective exit).
- * - program: Run as a program, exiting when finished prrocess entry (and any respective exit).
- * - service: Run as a service, listening for requests after processing entry.
- */
-#ifndef _di_controller_program_mode_e_
- enum {
- controller_program_mode_service_e = 0,
- controller_program_mode_helper_e,
- controller_program_mode_program_e,
- }; // enum
-#endif // _di_controller_program_mode_e_
-
-/**
- * Controller Process ready enumeration.
- *
- * controller_program_ready_*_e:
- * - no: Entry/Exit is not ready.
- * - wait: Entry/Exit has "ready" somewhere in the file but is not yet ready.
- * - yes: Entry/Exit is now ready (Entry/Exit is still being processed).
- * - done: Entry/Exit is ready and processing is complete.
- * - fail: Entry/Exit processing failed.
- * - abort: Abort received before finished processing Entry/Exit.
- */
-#ifndef _di_controller_program_ready_e_
- enum {
- controller_program_ready_no_e = 0,
- controller_program_ready_wait_e,
- controller_program_ready_yes_e,
- controller_program_ready_done_e,
- controller_program_ready_fail_e,
- controller_program_ready_abort_e,
- }; // enum
-#endif // _di_controller_program_ready_e_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _controller_main_common_enumeration_program_h
"f_console_parameter_process",
"f_environment_get_all",
"f_file_exists",
+ "f_file_stat",
"f_file_stream_open",
"f_file_stream_read",
"f_fss_apply_delimit",
"f_memory_array_increase",
"f_memory_array_increase_by",
"f_memory_array_resize",
+ "f_memory_arrays_resize",
"f_path_current",
"f_rip_dynamic_partial",
"f_rip_dynamic_partial_nulless",
controller_f_f_console_parameter_process_e,
controller_f_f_environment_get_all_e,
controller_f_f_file_exists_e,
+ controller_f_f_file_stat_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_memory_array_increase_e,
controller_f_f_memory_array_increase_by_e,
controller_f_f_memory_array_resize_e,
+ controller_f_f_memory_arrays_resize_e,
controller_f_f_path_current_e,
controller_f_f_rip_dynamic_partial_e,
controller_f_f_rip_dynamic_partial_nulless_e,
if (!main) return;
fll_program_data_delete(&main->program);
+
+ controller_cache_delete(&main->cache);
+ controller_process_delete(&main->process);
controller_setting_delete(&main->setting);
+ controller_thread_delete(&main->thread);
}
#endif // _di_controller_delete_
#endif // _di_controller_setting_t_
/**
- * The main program data as a single structure.
+ * The main program data.
*
* The typedef for this is located in the defs.h header.
*
* Properties:
* - program: The main program data.
+ *
+ * - cache: The cache.
+ * - process: The process data.
* - setting: The settings data.
+ * - thread: The thread data.
*/
#ifndef _di_controller_t_
struct controller_t_ {
fll_program_data_t program;
- controller_setting_t setting;
+
controller_cache_t cache;
+ controller_process_t process;
+ controller_setting_t setting;
+ controller_thread_t thread;
};
#define controller_t_initialize \
{ \
fll_program_data_t_initialize, \
- controller_setting_t_initialize, \
controller_cache_t_initialize, \
+ controller_process_t_initialize, \
+ controller_setting_t_initialize, \
+ controller_thread_t_initialize, \
}
#endif // _di_controller_t_
* This does not alter main.setting.state.status.
*
* @see controller_cache_delete()
+ * @see controller_process_delete()
* @see controller_setting_delete()
+ * @see controller_thread_delete()
+ *
* @see fll_program_data_delete()
*/
#ifndef _di_controller_delete_
#endif
/**
- * The controller global typedef.
- */
- #ifndef _di_controller_global_t_
- typedef struct controller_global_t_ controller_global_t;
-#endif // _di_controller_global_t_
-
-/**
* The controller instance typedef.
*/
#ifndef _di_controller_instance_t_
/**
* The controller program typedef.
*/
-#ifndef _di_controller_program_t_
- typedef struct controller_program_t_ controller_program_t;
-#endif // _di_controller_program_t_
+#ifndef _di_controller_process_t
+ typedef struct controller_process_t_ controller_process_t;
+#endif // _di_controller_process_t
/**
* The controller thread typedef.
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Controller
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the common global type structures.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _controller_main_common_type_global_h
-#define _controller_main_common_type_global_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * A wrapper used for passing a common set of all data, particularly for sharing between threads.
- *
- * The typedef for this is located in the defs.h header.
- *
- * Properties:
- * - main: The main program data.
- * - program: The program data.
- * - thread: The thread data for a specific thread.
- *
- * - message: The output file for normal output messages (often stdout), but with custom set to (controller_global_t *).
- * - output: The output file for normal/non-message output, aka data output (often stdout or a file), but with custom set to (controller_global_t *).
- * - error: The output file for error output messages, but with custom set to (controller_global_t *).
- * - warning: The output file for warning output messages, but with custom set to (controller_global_t *).
- * - debug: The output file for debug output messages, but with custom set to (controller_global_t *).
- */
-#ifndef _di_controller_global_t_
- struct controller_global_t_ {
- controller_t *main;
- controller_program_t *program;
- controller_thread_t *thread;
-
- fl_print_t *message;
- fl_print_t *output;
- fl_print_t *error;
- fl_print_t *warning;
- fl_print_t *debug;
- };
-
- #define controller_global_t_initialize { 0, 0, 0, 0, 0, 0, 0, 0 }
-
- #define macro_controller_global_t_initialize_1(main, program, thread, message, output, error, warning, debug) { \
- main, \
- program, \
- thread, \
- message, \
- output, \
- error, \
- warning, \
- debug, \
- }
-#endif // _di_controller_global_t_
-
-/**
- * A structure for passing data to the interrupt state function.
- *
- * Properties:
- * - is_normal: Boolean designating if this is operating in a normal state.
- * - global: The global data.
- */
-#ifndef _di_controller_interrupt_t_
- typedef struct {
- bool is_normal;
-
- controller_global_t *global;
- } controller_interrupt_t;
-
- #define controller_interrupt_t_initialize { \
- F_true, \
- 0, \
- }
-
- #define macro_controller_interrupt_t_initialize_1(is_normal, global) { \
- is_normal, \
- global, \
- }
-#endif // _di_controller_interrupt_t_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _controller_main_common_type_global_h
* - path_pids: An array of paths representing PID files.
* - stack: A stack used to represent dependencies as Rule ID's to avoid circular Rule dependencies (If Rule A waits on Rule B, then Rule B must not wait on Rule A).
*
- * - rule: A copy of the rule actively being executed.
- * - cache: The cache used by this Instance.
- * - global: The global data.
+ * - rule: A copy of the rule actively being executed.
+ * - cache: The cache used by this Instance.
+ * - main: The main program data.
*/
#ifndef _di_controller_instance_t_
struct controller_instance_t_ {
controller_rule_t rule;
controller_cache_t cache;
- controller_global_t *global;
+ controller_t *main;
};
#define controller_instance_t_initialize { \
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the common interrupt type structures.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_main_common_type_interrupt_h
+#define _controller_main_common_type_interrupt_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A structure for passing data to the interrupt state function.
+ *
+ * Properties:
+ * - is_normal: Boolean designating if this is operating in a normal state.
+ * - main: The main program data.
+ */
+#ifndef _di_controller_interrupt_t_
+ typedef struct {
+ bool is_normal;
+
+ controller_t *main;
+ } controller_interrupt_t;
+
+ #define controller_interrupt_t_initialize { \
+ F_true, \
+ 0, \
+ }
+
+ #define macro_controller_interrupt_t_initialize_1(is_normal, main) { \
+ is_normal, \
+ main, \
+ }
+#endif // _di_controller_interrupt_t_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_main_common_type_interrupt_h
--- /dev/null
+#include "../../controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_process_delete_
+ void controller_process_delete(controller_process_t * const process) {
+
+ if (!process) return;
+
+ f_memory_array_resize(0, sizeof(f_char_t), (void **) &process->name_entry.string, &process->name_entry.used, &process->name_entry.size);
+ f_memory_array_resize(0, sizeof(f_char_t), (void **) &process->path_cgroup.string, &process->path_cgroup.used, &process->path_cgroup.size);
+ f_memory_array_resize(0, sizeof(f_char_t), (void **) &process->path_control.string, &process->path_control.used, &process->path_control.size);
+ f_memory_array_resize(0, sizeof(f_char_t), (void **) &process->path_current.string, &process->path_current.used, &process->path_current.size);
+ f_memory_array_resize(0, sizeof(f_char_t), (void **) &process->path_pid.string, &process->path_pid.used, &process->path_pid.size);
+ f_memory_array_resize(0, sizeof(f_char_t), (void **) &process->path_setting.string, &process->path_setting.used, &process->path_setting.size);
+
+ f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &process->entry.define.array, &process->entry.define.used, &process->entry.define.size, &f_string_maps_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &process->entry.parameter.array, &process->entry.parameter.used, &process->entry.parameter.size, &f_string_maps_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &process->exit.define.array, &process->exit.define.used, &process->exit.define.size, &f_string_maps_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &process->exit.parameter.array, &process->exit.parameter.used, &process->exit.parameter.size, &f_string_maps_delete_callback);
+
+ controller_control_delete(&process->control);
+ controller_entry_items_delete(&process->entry.items);
+ controller_entry_items_delete(&process->exit.items);
+ controller_rules_delete(&process->rules);
+ }
+#endif // _di_controller_process_delete_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
- * Provides the common program type structures.
+ * Provides the common process type structures.
*
* This is auto-included and should not need to be explicitly included.
*/
-#ifndef _controller_main_common_type_program_h
-#define _controller_main_common_type_program_h
+#ifndef _controller_main_common_type_process_h
+#define _controller_main_common_type_process_h
#ifdef __cplusplus
extern "C" {
* - exit: The Exit settings.
* - rules: All rules and their respective settings.
*/
-#ifndef _di_controller_program_t_
- struct controller_program_t_ {
+#ifndef _di_controller_process_t
+ struct controller_process_t_ {
uint8_t ready;
uint8_t mode;
controller_rules_t rules;
};
- #define controller_program_t_initialize { \
+ #define controller_process_tinitialize { \
0, \
0, \
0, \
controller_entry_t_initialize, \
controller_rules_t_initialize, \
}
-#endif // _di_controller_program_t_
+#endif // _di_controller_process_t
/**
- * Delete the Controller program data.
+ * Delete the Controller process data.
*
- * @param program
- * A pointer to the current program settings.
+ * @param process
+ * A pointer to the current process data.
*
* Must not be NULL.
*/
-#ifndef _di_controller_program_delete_
- extern void controller_program_delete(controller_program_t * const program);
-#endif // _di_controller_program_delete_
+#ifndef _di_controller_process_delete_
+ extern void controller_process_delete(controller_process_t * const process);
+#endif // _di_controller_process_delete_
#ifdef __cplusplus
} // extern "C"
#endif
-#endif // _controller_main_common_type_program_h
+#endif // _controller_main_common_type_process_h
+++ /dev/null
-#include "../../controller.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_controller_program_delete_
- void controller_program_delete(controller_program_t * const program) {
-
- if (!program) return;
-
- f_memory_array_resize(0, sizeof(f_char_t), (void **) &program->name_entry.string, &program->name_entry.used, &program->name_entry.size);
- f_memory_array_resize(0, sizeof(f_char_t), (void **) &program->path_cgroup.string, &program->path_cgroup.used, &program->path_cgroup.size);
- f_memory_array_resize(0, sizeof(f_char_t), (void **) &program->path_control.string, &program->path_control.used, &program->path_control.size);
- f_memory_array_resize(0, sizeof(f_char_t), (void **) &program->path_current.string, &program->path_current.used, &program->path_current.size);
- f_memory_array_resize(0, sizeof(f_char_t), (void **) &program->path_pid.string, &program->path_pid.used, &program->path_pid.size);
- f_memory_array_resize(0, sizeof(f_char_t), (void **) &program->path_setting.string, &program->path_setting.used, &program->path_setting.size);
-
- f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &program->entry.define.array, &program->entry.define.used, &program->entry.define.size, &f_string_maps_delete_callback);
- f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &program->entry.parameter.array, &program->entry.parameter.used, &program->entry.parameter.size, &f_string_maps_delete_callback);
- f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &program->exit.define.array, &program->exit.define.used, &program->exit.define.size, &f_string_maps_delete_callback);
- f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &program->exit.parameter.array, &program->exit.parameter.used, &program->exit.parameter.size, &f_string_maps_delete_callback);
-
- controller_control_delete(&program->control);
- controller_entry_items_delete(&program->entry.items);
- controller_entry_items_delete(&program->exit.items);
- controller_rules_delete(&program->rules);
- }
-#endif // _di_controller_program_delete_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
#include <program/controller/main/common/enumeration/entry.h>
#include <program/controller/main/common/enumeration/instance.h>
#include <program/controller/main/common/enumeration/rule.h>
-#include <program/controller/main/common/enumeration/program.h>
+#include <program/controller/main/common/enumeration/process.h>
#include <program/controller/main/common/enumeration/thread.h>
#include <program/controller/main/common/type/cache.h>
#include <program/controller/main/common/type/control.h>
#include <program/controller/main/common/type/lock.h>
#include <program/controller/main/common/type/rule.h>
#include <program/controller/main/common/type/defs.h>
-#include <program/controller/main/common/type/global.h>
-#include <program/controller/main/common/type/program.h>
+#include <program/controller/main/common/type/process.h>
#include <program/controller/main/common/type/instance.h>
#include <program/controller/main/common/type/thread.h>
+#include <program/controller/main/common/type/interrupt.h>
#include <program/controller/main/common/type.h>
#include <program/controller/main/common.h>
#include <program/controller/main/convert.h>
#include <program/controller/main/rule/validate.h>
#include <program/controller/main/rule/wait.h>
#include <program/controller/main/process.h>
+#include <program/controller/main/validate.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) {
+ f_status_t controller_file_load(controller_t * const main, 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);
+ if (!main || !cache) return F_status_set_error(F_parameter);
f_status_t status = F_okay;
f_file_t file = f_file_t_initialize;
}
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));
+ controller_print_error_status(&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;
+ if (main->setting.path_setting.used) {
+ path.used = main->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);
+ if (main->setting.path_setting.used) {
+ memcpy(path_string, main->setting.path_setting.string, sizeof(f_char_t) * main->setting.path_setting.used);
+ memcpy(path_string + main->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];
+ path_string[main->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);
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));
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_print_error_file_status(&main->program.error, macro_controller_f(f_file_stream_open), 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);
- }
+ controller_print_error_file_status(&main->program.error, macro_controller_f(f_file_stream_read), path, f_file_operation_read_s, fll_error_file_type_file_e, F_status_set_fine(status));
}
}
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);
- }
+ controller_print_error_file_status(&main->program.error, macro_controller_f(f_file_stat), path, f_file_operation_stat_s, fll_error_file_type_file_e, F_status_set_fine(status));
}
else {
cache->timestamp.seconds = stat_file.st_ctim.tv_sec;
/**
* Load a file from the controller settings directory.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
* @param cache
* @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);
+ extern f_status_t controller_file_load(controller_t * const main, 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_
/**
#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) {
+ f_status_t controller_instance_prepare(controller_t * const main, 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);
+ if (!main) 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);
+ if (controller_instance_find(action, alias, main->thread.instances, id) == F_false) {
+ f_thread_unlock(&main->thread.lock.instance);
- status = controller_lock_write(is_normal, global->thread, &global->thread->lock.instance);
+ status = controller_lock_write(is_normal, &main->thread, &main->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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status), F_false);
}
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);
+ status = f_memory_array_increase(controller_allocation_small_d, sizeof(controller_instance_t), (void **) &main->thread.instances.array, &main->thread.instances.used, &main->thread.instances.size);
}
- if (F_status_is_error_not(status) && global->thread->instances.array[global->thread->instances.used]) {
+ if (F_status_is_error_not(status) && main->thread.instances.array[main->thread.instances.used]) {
- controller_instance_t * const instance = global->thread->instances.array[global->thread->instances.used];
+ controller_instance_t * const instance = main->thread.instances.array[main->thread.instances.used];
- status = controller_lock_write(is_normal, global->thread, &instance->lock);
+ status = controller_lock_write(is_normal, &main->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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status), F_false);
}
else {
instance->action = action;
instance->rule.alias.used = 0;
- instance->global = global;
+ instance->main = main;
status = f_string_dynamic_append(alias, &instance->rule.alias);
if (F_status_is_error_not(status)) {
- instance->id = global->thread->instances.used++;
+ instance->id = main->thread.instances.used++;
status = F_okay;
if (id) {
}
}
- f_thread_unlock(&global->thread->lock.instance);
+ f_thread_unlock(&main->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))
+ status = F_status_is_error(controller_lock_read(is_normal, &main->thread, &main->thread.lock.instance))
? F_status_set_error(F_lock)
: F_okay;
}
#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) {
+ f_status_t controller_instance_prepare_instance_type(controller_t * const main, 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);
+ return controller_instance_prepare(main, type != controller_instance_type_exit_e, action, alias, id);
}
#endif // _di_controller_instance_prepare_instance_type_
*
* 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.
+ * This requires that a main.thread.lock.instance lock be set on instance.lock before being called.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
* @param is_normal
* 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_lock (with error bit) if failed to re-establish read lock on main.thread.lock.instance while returning.
* F_parameter (with error bit) if a parameter is invalid.
*
* Errors (with error bit) from: f_string_dynamic_append().
* @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);
+ extern f_status_t controller_instance_prepare(controller_t * const main, const bool is_normal, const uint8_t action, const f_string_static_t alias, f_number_unsigned_t *id);
#endif // _di_controller_instance_prepare_
/**
*
* 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.
+ * This requires that a main.thread.lock.instance lock be set on instance->lock before being called.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
* @param type
* @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);
+ extern f_status_t controller_instance_prepare_instance_type(controller_t * const main, 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
#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 (!instance || !instance->main) 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;
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);
+ controller_lock_print_error_critical(&instance->main->program.error, F_status_set_fine(status_lock), F_true);
break;
}
#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 (!instance || !lock) return F_status_set_error(F_parameter);
+ if (!instance || !instance->main || !lock) return F_status_set_error(F_parameter);
- return controller_lock_read_instance_type(instance->type, instance->global->thread, lock);
+ return controller_lock_read_instance_type(instance->type, &instance->main->thread, lock);
}
#endif // _di_controller_lock_read_instance_
if (!instance || !lock) return F_status_set_error(F_parameter);
- return controller_lock_write_instance_type(instance->type, instance->global->thread, lock);
+ return controller_lock_write_instance_type(instance->type, &instance->main->thread, lock);
}
#endif // _di_controller_lock_write_instance_
#endif
#ifndef _di_controller_lock_print_error_critical_
- void controller_lock_print_error_critical(fl_print_t * const print, const f_status_t status, const uint8_t is_read, controller_thread_t *thread) {
+ void controller_lock_print_error_critical(fl_print_t * const print, const f_status_t status, const uint8_t is_read) {
// A signal is not an error.
- if (status == F_interrupt) return;
+ if (!print || !print->custom || status == F_interrupt) return;
+
+ controller_t * const main = (controller_t *) print->custom;
if (print->verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(print->to, thread);
+ controller_lock_print(print->to, &main->thread);
fl_print_format("%r%[%QThe pid file '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context);
fl_print_format("%['Critical failure while attempting to establish '%]", print->to, print->context, print->context);
fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s);
- controller_unlock_print_flush(print->to, thread);
+ controller_unlock_print_flush(print->to, &main->thread);
}
}
#endif // _di_controller_lock_print_error_critical_
* @param is_read
* If TRUE, then this is for a read lock.
* If FALSE, then this is for a write lock.
- * @param thread
- * The thread data.
*/
#ifndef _di_controller_lock_print_error_critical_
- extern void controller_lock_print_error_critical(fl_print_t * const print, const f_status_t status, const uint8_t is_read, controller_thread_t *thread);
+ extern void controller_lock_print_error_critical(fl_print_t * const print, const f_status_t status, const uint8_t is_read);
#endif // _di_controller_lock_print_error_critical_
/**
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
if (status == F_interrupt) return F_status_set_error(F_output_not);
- controller_global_t * const global = (controller_global_t *) print->custom;
+ controller_t * const main = (controller_t *) print->custom;
// fll_error_print() automatically locks, so manually handle only the mutex locking and flushing rather than calling controller_lock_print().
- f_thread_mutex_lock(&global->thread->lock.print);
+ f_thread_mutex_lock(&main->thread.lock.print);
fll_error_print(print, status, function, fallback);
controller_print_rule_error_cache(print, cache, item);
- controller_unlock_print_flush(print->to, global->thread);
+ controller_unlock_print_flush(print->to, &main->thread);
return F_okay;
}
fl_print_format("rule %r '%]", print->to, item ? controller_item_s : controller_settings_s, print->context);
fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, cache.name_item, print->notable);
fl_print_format("%[' on line%] ", print->to, print->context, print->context);
- fl_print_format(f_string_format_un_single_s.string", print->to, print->notable, cache.line_item, print->notable);
+ fl_print_format(f_string_format_un_single_s.string, print->to, print->notable, cache.line_item, print->notable);
fl_print_format("%[ for ", print->to, print->context);
}
* @see controller_print_rule_error_cache()
*/
#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);
+ extern 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);
#endif // _di_controller_print_rule_error_
/**
* @see controller_rule_setting_read()
*/
#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);
+ extern f_status_t 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
#endif
#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) {
+ f_status_t 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("%r%[%QThe rule '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context);
fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, alias, print->notable);
fl_print_format("%[' is not designating a pid file.%]%r", print->to, print->context, print->context, f_string_eol_s);
+
+ return F_okay;
}
#endif // _di_controller_print_rule_action_error_missing_pid_
* The error or warning output structure.
* @param alias
* The rule alias of the rule that is missing the pid file designation.
+ *
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
*/
#ifndef _di_controller_print_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);
+ extern f_status_t 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
if (!print || !print->custom || !cache) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_debug_e) return F_output_not;
- controller_global_t * const global = (controller_global_t *) print->custom;
+ controller_t * const main = (controller_t *) print->custom;
- controller_lock_print(print->to, global->thread);
+ controller_lock_print(print->to, &main->thread);
- fl_print_format("%r%[%QAction is empty, nothing to do.%]%r", primt->to, f_string_eol_s, print->context, print->prefix, print->context, f_string_eol_s);
+ fl_print_format("%r%[%QAction is empty, nothing to do.%]%r", print->to, f_string_eol_s, print->context, print->prefix, print->context, f_string_eol_s);
controller_print_rule_error_cache(print, cache->action, F_true);
- controller_unlock_print_flush(print->to, global->thread);
+ controller_unlock_print_flush(print->to, &main->thread);
return F_okay;
}
#endif // _di_controller_print_rule_item_debug_action_empty_
#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) {
+ f_status_t 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;
if (status == F_interrupt) return F_status_set_error(F_output_not);
- controller_global_t * const global = (controller_global_t *) print->custom;
+ controller_t * const main = (controller_t *) print->custom;
// fll_error_print() automatically locks, so manually handle only the mutex locking and flushing rather than calling controller_lock_print().
- f_thread_mutex_lock(&global->thread->lock.print);
+ f_thread_mutex_lock(&main->thread.lock.print);
controller_print_rule_error_cache(print, cache, item);
f_file_stream_lock(print->to);
- controller_unlock_print_flush(print->to, global->thread);
+ controller_unlock_print_flush(print->to, &main->thread);
+
+ return F_okay;
}
#endif // _di_controller_print_rule_item_error_
if (!print || !print->custom || !cache) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
- controller_global_t * const global = (controller_global_t *) print->custom;
+ controller_t * const main = (controller_t *) print->custom;
- controller_lock_print(print->to, global->thread);
+ controller_lock_print(print->to, &main->thread);
fl_print_format("%r%[%QRule item action '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context);
fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, controller_rerun_s, print->notable);
controller_print_rule_error_cache(print, cache->action, F_true);
- controller_unlock_print_flush(print->to, global->thread);
+ controller_unlock_print_flush(print->to, &main->thread);
return F_okay;
}
if (!print || !print->custom || !cache) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
- controller_global_t * const global = (controller_global_t *) print->custom;
+ controller_t * const main = (controller_t *) print->custom;
- controller_lock_print(print->to, global->thread);
+ controller_lock_print(print->to, &main->thread);
fl_print_format("%r%[%QRule item action '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context);
fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, controller_rerun_s, print->notable);
controller_print_rule_error_cache(print, cache->action, F_true);
- controller_unlock_print_flush(print->to, global->thread);
+ controller_unlock_print_flush(print->to, &main->thread);
return F_okay;
}
if (!print || !print->custom || !cache) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
- controller_global_t * const global = (controller_global_t *) print->custom;
+ controller_t * const main = (controller_t *) print->custom;
- controller_lock_print(print->to, global->thread);
+ controller_lock_print(print->to, &main->thread);
fl_print_format("%r%[%QRule item action '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context);
fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, name, print->notable);
controller_print_rule_error_cache(print, cache->action, F_true);
- controller_unlock_print_flush(print->to, global->thread);
+ controller_unlock_print_flush(print->to, &main->thread);
return F_okay;
}
#endif // _di_controller_print_rule_item_error_action_unknown_
#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) {
+ f_status_t 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 || !instance || !instance->main) return F_status_set_error(F_output_not);
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
- controller_global_t * const global = (controller_global_t *) print->custom;
-
- controller_lock_print(print->to, global->thread);
+ controller_lock_print(print->to, &instance->main->thread);
fl_print_format("%r%[%QThe %r '%]", print->to, f_string_eol_s, print->context, print->prefix, script_is ? controller_engine_s : controller_program_s, print->context);
fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, name, print->notable);
fl_print_format("%]%['.%]%r", print->to, print->notable, print->context, print->context, f_string_eol_s);
}
- else if (WIFEXITED(process->result) ? WEXITSTATUS(process->result) : 0) {
- const uint8_t code = WIFEXITED(process->result) ? WEXITSTATUS(process->result) : 0;
+ else if (WIFEXITED(instance->result) ? WEXITSTATUS(instance->result) : 0) {
+ const uint8_t code = WIFEXITED(instance->result) ? WEXITSTATUS(instance->result) : 0;
if (code == F_execute_access) {
fl_print_format("%[' failed, access is denied.%]%r", print->to, print->context, print->context, f_string_eol_s);
fl_print_format("%[' failed.%]%r", print->to, print->context, print->context, f_string_eol_s);
}
- controller_unlock_print_flush(print->to, global->thread);
+ controller_unlock_print_flush(print->to, &instance->main->thread);
+
+ return F_okay;
}
#endif // _di_controller_print_rule_item_error_execute_
#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) {
+ f_status_t 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;
+ if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not;
fl_print_format("%r%[%QThe %r rule '%]", print->to, f_string_eol_s, print->context, print->prefix, need_want_wish, print->context);
fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, value, print->notable);
fl_print_format("%[' %S.%]%r", print->to, print->context, why, print->context, f_string_eol_s);
+
+ return F_okay;
}
#endif // _di_controller_print_rule_item_error_need_want_wish_
#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) {
+ f_status_t 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;
+ if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not;
fl_print_format("%r%[%QThe rule '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context);
fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, alias, print->notable);
fl_print_format("%[' is no longer loaded.%]%r", print->to, print->context, print->context, f_string_eol_s);
+
+ return F_okay;
}
#endif // _di_controller_print_rule_item_error_rule_not_loaded_
* @param status
* The status code representing the failure (without the error bit set).
*
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
* @see controller_print_rule_error_cache()
*/
#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);
+ extern f_status_t 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_
/**
* The code returned by the executed program or script.
* @param status
* The status code representing the failure (without the error bit set).
+ *
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
*/
#ifndef _di_controller_print_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);
+ extern f_status_t 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_
/**
* The value that is the error or warning.
* @param why
* A short explanation on why this is an error or warning.
+ *
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
*/
#ifndef _di_controller_print_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);
+ extern f_status_t 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_
/**
* The error or warning output structure.
* @param alias
* The rule alias of the rule that is not loaded.
+ *
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
*/
#ifndef _di_controller_print_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);
+ extern f_status_t 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
#endif
#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) {
+ f_status_t 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;
+ if (!print->custom) return F_status_set_error(F_output_not);
+ if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not;
controller_t * const main = (controller_t *) print->custom;
controller_print_rule_error_cache(print, cache->action, F_false);
controller_unlock_print_flush(print->to, thread);
+
+ return F_okay;
}
#endif // _di_controller_print_rule_setting_read_error_
#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) {
+ f_status_t 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;
+ if (!print->custom) return F_status_set_error(F_output_not);
+ if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not;
controller_t * const main = (controller_t *) print->custom;
controller_print_rule_error_cache(print, cache->action, F_false);
controller_unlock_print_flush(print->to, thread);
+
+ return F_okay;
}
#endif // _di_controller_print_rule_setting_read_error_with_range_
#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) {
+ f_status_t controller_print_rule_setting_read_mapping(controller_t * const main, const f_string_static_t name, const f_string_map_t map) {
- if (global.main->program.error.verbosity != f_console_verbosity_debug_e) {
- if (!(global.main->program.error.verbosity == f_console_verbosity_verbose_e && (global.main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
- return;
+ if (main->program.error.verbosity != f_console_verbosity_debug_e) {
+ if (!(main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
+ return F_output_not;
}
}
- controller_lock_print(global.main->program.output.to, global.thread);
+ controller_lock_print(main->program.output.to, &main->thread);
+
+ fl_print_format("%rProcessing rule item action '%[%Q%]'", main->program.output.to, f_string_eol_s, main->program.context.set.title, name, main->program.context.set.title);
+ fl_print_format(" mapping '%[%Q%]'", main->program.output.to, main->program.context.set.important, map.key, main->program.context.set.important);
+ fl_print_format(" to value '%[%Q%]'.%r", main->program.output.to, main->program.context.set.important, map.value, main->program.context.set.important, f_string_eol_s);
- fl_print_format("%rProcessing rule item action '%[%Q%]'", global.main->program.output.to, f_string_eol_s, global.main->program.context.set.title, name, global.main->program.context.set.title);
- fl_print_format(" mapping '%[%Q%]'", global.main->program.output.to, global.main->program.context.set.important, map.key, global.main->program.context.set.important);
- fl_print_format(" to value '%[%Q%]'.%r", global.main->program.output.to, global.main->program.context.set.important, map.value, global.main->program.context.set.important, f_string_eol_s);
+ controller_unlock_print_flush(main->program.output.to, &main->thread);
- controller_unlock_print_flush(global.main->program.output.to, global.thread);
+ return F_okay;
}
#endif // _di_controller_print_rule_setting_read_mapping_
#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) {
+ f_status_t controller_print_rule_setting_read_value(controller_t * const main, const f_string_static_t name, const f_string_static_t name_sub, const f_string_static_t value, const f_string_t suffix) {
- if (global.main->program.error.verbosity != f_console_verbosity_debug_e) {
- if (!(global.main->program.error.verbosity == f_console_verbosity_verbose_e && (global.main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
- return;
+ if (main->program.error.verbosity != f_console_verbosity_debug_e) {
+ if (!(main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
+ return F_output_not;
}
}
- controller_lock_print(global.main->program.output.to, global.thread);
+ controller_lock_print(main->program.output.to, &main->thread);
- fl_print_format("%rProcessing rule item action '%[%Q%]' setting ", global.main->program.output.to, f_string_eol_s, global.main->program.context.set.title, name, global.main->program.context.set.title);
+ fl_print_format("%rProcessing rule item action '%[%Q%]' setting ", main->program.output.to, f_string_eol_s, main->program.context.set.title, name, main->program.context.set.title);
if (name_sub.used) {
- fl_print_format("'%[%Q%]'", global.main->program.output.to, global.main->program.context.set.notable, name_sub, global.main->program.context.set.notable);
+ fl_print_format("'%[%Q%]'", main->program.output.to, main->program.context.set.notable, name_sub, main->program.context.set.notable);
}
else {
- f_print_terminated("value", global.main->program.output.to);
+ f_print_terminated("value", main->program.output.to);
}
- fl_print_format(" to '%[%Q%]'", global.main->program.output.to, global.main->program.context.set.important, value, global.main->program.context.set.important);
- fl_print_format("%S.%r", global.main->program.output.to, suffix, f_string_eol_s);
+ fl_print_format(" to '%[%Q%]'", main->program.output.to, main->program.context.set.important, value, main->program.context.set.important);
+ fl_print_format("%S.%r", main->program.output.to, suffix, f_string_eol_s);
- controller_unlock_print_flush(global.main->program.output.to, global.thread);
+ controller_unlock_print_flush(main->program.output.to, &main->thread);
+
+ return F_okay;
}
#endif // _di_controller_print_rule_setting_read_value_
#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) {
+ f_status_t controller_print_rule_setting_read_values(controller_t * const main, const f_string_static_t name, const f_number_unsigned_t index, controller_cache_t * const cache) {
- if (global.main->program.error.verbosity != f_console_verbosity_debug_e) {
- if (!(global.main->program.error.verbosity == f_console_verbosity_verbose_e && (global.main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
- return;
+ if (main->program.error.verbosity != f_console_verbosity_debug_e) {
+ if (!(main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
+ return F_output_not;
}
}
- controller_lock_print(global.main->program.output.to, global.thread);
+ controller_lock_print(main->program.output.to, &main->thread);
- fl_print_format("%rProcessing rule item action '%[%Q%]' setting value to", global.main->program.output.to, f_string_eol_s, global.main->program.context.set.title, name, global.main->program.context.set.title);
+ fl_print_format("%rProcessing rule item action '%[%Q%]' setting value to", main->program.output.to, f_string_eol_s, main->program.context.set.title, name, main->program.context.set.title);
for (f_number_unsigned_t j = 0; j < cache->content_actions.array[index].used; ++j) {
- fl_print_format(" '%[%/Q%]'", global.main->program.output.to, global.main->program.context.set.important, cache->buffer_item, cache->content_actions.array[index].array[j], global.main->program.context.set.important);
+ fl_print_format(" '%[%/Q%]'", main->program.output.to, main->program.context.set.important, cache->buffer_item, cache->content_actions.array[index].array[j], main->program.context.set.important);
if (j + 2 == cache->content_actions.array[index].used) {
if (cache->content_actions.array[index].used > 2) {
- f_print_terminated(",", global.main->program.output.to);
+ f_print_terminated(",", main->program.output.to);
}
- f_print_terminated(" and", global.main->program.output.to);
+ f_print_terminated(" and", main->program.output.to);
}
else if (j + 1 < cache->content_actions.array[index].used) {
- f_print_terminated(",", global.main->program.output.to);
+ f_print_terminated(",", main->program.output.to);
}
} // for
- fl_print_format(".%r", global.main->program.output.to, f_string_eol_s);
+ fl_print_format(".%r", main->program.output.to, f_string_eol_s);
+
+ controller_unlock_print_flush(main->program.output.to, &main->thread);
- controller_unlock_print_flush(global.main->program.output.to, global.thread);
+ return F_okay;
}
#endif // _di_controller_print_rule_setting_read_value_
* @param cache
* A structure for containing and caching relevant data.
*
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
* @see controller_rule_setting_read()
*/
#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);
+ extern f_status_t 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_
/**
* @param cache
* A structure for containing and caching relevant data.
*
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
* @see controller_rule_setting_read()
*/
#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);
+ extern f_status_t 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 global
- * The global data.
+ * @param main
+ * The main program data.
+ *
+ * Must not be NULL.
* @param name
* The Object name of the setting being populated.
* @param map
* The map being applied.
+ *
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
*/
#ifndef _di_controller_print_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);
+ extern f_status_t controller_print_rule_setting_read_mapping(controller_t * const main, 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 global
- * The global data.
+ * @param main
+ * The main program data.
+ *
+ * Must not be NULL.
* @param name
* The Object name of the setting being populated.
* @param name_sub
* The value being set.
* @param suffix
* An additional message to append at the end (before the final period).
+ *
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
*/
#ifndef _di_controller_print_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);
+ extern f_status_t controller_print_rule_setting_read_value(controller_t * const main, 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_
/**
*
* This handles the case where there are multiple values stored in the buffer_item at a given content_actions position.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
+ *
+ * Must not be NULL.
* @param name
* The Object name of the setting being populated.
* @param index
* Position within the content_actions range cache array.
* @param cache
* A structure for containing and caching relevant data.
+ *
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
*/
#ifndef _di_controller_print_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);
+ extern f_status_t controller_print_rule_setting_read_values(controller_t * const main, 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
#endif
#ifndef _di_controller_process_
- void controller_process(controller_t * const main, controller_program_t * const program) {
+ void controller_process(controller_t * const main) {
- if (!main || !program || F_status_is_error(main->setting.state.status)) return;
+ if (!main || F_status_is_error(main->setting.state.status)) return;
main->setting.state.status = F_okay;
return;
}
- fl_print_t message = main->program.message;
- fl_print_t output = main->program.output;
- fl_print_t error = main->program.error;
- fl_print_t warning = main->program.warning;
- fl_print_t debug = main->program.debug;
-
- controller_thread_t thread = controller_thread_t_initialize;
- controller_global_t global = macro_controller_global_t_initialize_1(main, program, &thread, &message, &output, &error, &warning, &debug);
-
- 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_lock_create(&thread.lock);
+ // The locks must be initialized, but only once, so initialize immediately upon allocation.
+ f_status_t status = controller_lock_create(&main->thread.lock);
if (F_status_is_error(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);
+ status = f_memory_array_increase(controller_allocation_small_d, sizeof(controller_instance_t), (void **) &main->thread.instances.array, &main->thread.instances.used, &main->thread.instances.size);
if (F_status_is_error(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_thread_signal_normal, (void *) &global);
+ status = f_thread_create(0, &main->thread.id_signal, &controller_thread_signal_normal, (void *) &main);
}
if (F_status_is_error(status)) {
- thread.id_signal = 0;
+ main->thread.id_signal = 0;
controller_print_error_status(&main->program.error, macro_controller_f(f_thread_create), status);
}
else {
if (main->setting.flag & controller_main_flag_daemon_e) {
- program->ready = controller_program_ready_done_e;
+ main->process.ready = controller_process_ready_done_e;
- if (f_file_exists(program->path_pid, F_true) == F_true) {
+ if (f_file_exists(main->process.path_pid, F_true) == F_true) {
status = F_status_set_error(F_available_not);
- program->ready = controller_program_ready_abort_e;
+ main->process.ready = controller_process_ready_abort_e;
- controller_print_error_file_pid_exists(&main->program.error, &thread, program->path_pid);
+ controller_print_error_file_pid_exists(&main->program.error, &main->thread, main->process.path_pid);
}
}
- else if (program->name_entry.used) {
- status = f_thread_create(0, &thread.id_entry, &controller_thread_entry, (void *) &global);
+ else if (main->process.name_entry.used) {
+ status = f_thread_create(0, &main->thread.id_entry, &controller_thread_entry, (void *) &main);
if (F_status_is_error(status)) {
controller_print_error_status(&main->program.error, macro_controller_f(f_thread_create), status);
}
else {
- controller_thread_join(&thread.id_entry);
+ controller_thread_join(&main->thread.id_entry);
- status = thread.status;
- thread.id_entry = 0;
+ status = main->thread.status;
+ main->thread.id_entry = 0;
}
}
}
// Only make the rule and control threads available once any/all pre-processing are complete.
- if (F_status_is_error_not(status) && status != F_failure && status != F_child && thread.enabled == controller_thread_enabled_e) {
+ if (F_status_is_error_not(status) && status != F_failure && status != F_child && main->thread.enabled == controller_thread_enabled_e) {
if (!(main->setting.flag & controller_main_flag_validate_e)) {
// Wait for the entry thread to complete before starting the rule thread.
- controller_thread_join(&thread.id_rule);
+ controller_thread_join(&main->thread.id_rule);
- if (thread.enabled && program->mode == controller_program_mode_service_e) {
- status = f_thread_create(0, &thread.id_rule, &controller_thread_rule, (void *) &global);
+ if (main->thread.enabled && main->process.mode == controller_process_mode_service_e) {
+ status = f_thread_create(0, &main->thread.id_rule, &controller_thread_rule, (void *) &main);
if (F_status_is_error(status)) {
- thread.id_rule = 0;
+ main->thread.id_rule = 0;
}
else {
- status = f_thread_create(0, &thread.id_cleanup, &controller_thread_cleanup, (void *) &global);
+ status = f_thread_create(0, &main->thread.id_cleanup, &controller_thread_cleanup, (void *) &main);
}
if (F_status_is_error(status)) {
- thread.id_cleanup = 0;
+ main->thread.id_cleanup = 0;
controller_print_error_status(&main->program.error, macro_controller_f(f_thread_create), status);
}
if (status == F_child) {
main->setting.state.status = F_child;
- controller_thread_delete(&thread);
+ controller_thread_delete(&main->thread);
return;
}
- 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_thread_join(&thread.id_signal);
+ if (F_status_is_error_not(status) && status != F_failure && !(main->setting.flag & controller_main_flag_validate_e) && controller_thread_is_enabled(F_true, &main->thread)) {
+ if (main->process.mode == controller_process_mode_service_e) {
+ controller_thread_join(&main->thread.id_signal);
}
- else if (program->mode == controller_program_mode_helper_e || program->mode == controller_program_mode_program_e) {
- status = controller_rule_wait_all(&global, F_true, F_false);
+ else if (main->process.mode == controller_process_mode_helper_e || main->process.mode == controller_process_mode_program_e) {
+ status = controller_rule_wait_all(main, F_true, F_false);
}
}
- controller_thread_instance_cancel(&global, F_true, controller_thread_cancel_call_e);
+ controller_thread_instance_cancel(main, F_true, controller_thread_cancel_call_e);
- controller_thread_instance_exit(&global);
+ controller_thread_instance_exit(main);
- if (thread.id_signal) f_thread_join(thread.id_signal, 0);
- if (thread.id_cleanup) f_thread_join(thread.id_cleanup, 0);
- if (thread.id_control) f_thread_join(thread.id_control, 0);
- if (thread.id_entry) f_thread_join(thread.id_entry, 0);
- if (thread.id_rule) f_thread_join(thread.id_rule, 0);
+ if (main->thread.id_signal) f_thread_join(main->thread.id_signal, 0);
+ if (main->thread.id_cleanup) f_thread_join(main->thread.id_cleanup, 0);
+ if (main->thread.id_control) f_thread_join(main->thread.id_control, 0);
+ if (main->thread.id_entry) f_thread_join(main->thread.id_entry, 0);
+ if (main->thread.id_rule) f_thread_join(main->thread.id_rule, 0);
- thread.id_cleanup = 0;
- thread.id_control = 0;
- thread.id_entry = 0;
- thread.id_rule = 0;
- thread.id_signal = 0;
+ main->thread.id_cleanup = 0;
+ main->thread.id_control = 0;
+ main->thread.id_entry = 0;
+ main->thread.id_rule = 0;
+ main->thread.id_signal = 0;
- controller_thread_delete(&thread);
+ controller_thread_delete(&main->thread);
if (F_status_set_fine(status) == F_interrupt) {
- fll_program_print_signal_received(&main->program.warning, thread.signal);
+ fll_program_print_signal_received(&main->program.warning, main->thread.signal);
if (main->program.output.verbosity > f_console_verbosity_quiet_e) {
fll_print_dynamic_raw(f_string_eol_s, main->program.output.to);
* F_interrupt on (exit) signal received.
*
* F_parameter (with error bit) if main is NULL or setting is NULL.
- * @param program
- * A pointer to the current program settings.
- *
- * Must not be NULL.
*/
#ifndef controller_process
- extern void controller_process(controller_t * const main, controller_program_t * const program);
+ extern void controller_process(controller_t * const main);
#endif // controller_process
#ifdef __cplusplus
#endif // _di_controller_rule_find_
#ifndef _di_controller_rule_id_construct_
- f_status_t controller_rule_id_construct(controller_global_t * const global, const f_string_static_t source, const f_range_t directory, const f_range_t basename, f_string_dynamic_t * const alias) {
+ f_status_t controller_rule_id_construct(controller_t * const main, const f_string_static_t source, const f_range_t directory, const f_range_t basename, f_string_dynamic_t * const alias) {
- if (!global || !global->main || !global->thread) return F_status_set_error(F_parameter);
+ if (!main || !alias) return F_status_set_error(F_parameter);
alias->used = 0;
f_status_t status = f_string_dynamic_partial_append_nulless(source, directory, alias);
if (F_status_is_error(status)) {
- controller_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(&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_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status));
+ controller_print_error_status(&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_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(&main->program.error, macro_controller_f(f_string_dynamic_partial_append_nulless), F_status_set_fine(status));
return status;
}
/**
* Construct an id from two distinct strings found within a single given source.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
+ *
+ * Must not be NULL.
* @param source
* The source string that both the directory and basename are copied from.
* @param directory
* @param alias
* The constructed alias.
*
+ * Must not be NULL.
+ *
* @return
* F_okay on success.
*
* @see f_string_dynamic_partial_append_nulless()
*/
#ifndef _di_controller_rule_id_construct_
- extern f_status_t controller_rule_id_construct(controller_global_t * const global, const f_string_static_t source, const f_range_t directory, const f_range_t basename, f_string_dynamic_t * const alias);
+ extern f_status_t controller_rule_id_construct(controller_t * const main, const f_string_static_t source, const f_range_t directory, const f_range_t basename, f_string_dynamic_t * const alias);
#endif // _di_controller_rule_id_construct_
#ifdef __cplusplus
#endif // _di_controller_rule_action_type_to_action_execute_type_
#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) {
+ f_status_t controller_rule_action_read(controller_t * const main, 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);
+ if (!main || !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);
+ controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, main);
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;
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_print_error(&global->main->program.error, macro_controller_f(fl_fss_extended_list_content_read));
+ controller_print_error(&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_print_error(&global->main->program.error, macro_controller_f(f_fss_apply_delimit));
+ controller_print_error(&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_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase));
+ controller_print_error(&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_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase));
+ controller_print_error(&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_print_error(&global->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));
actions->array[actions->used++].status = controller_error_simplify(F_status_set_fine(status));
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_print_error(&global->main->program.error, macro_controller_f(fl_iki_read));
+ controller_print_error(&main->program.error, macro_controller_f(fl_iki_read));
actions->array[actions->used++].status = controller_error_simplify(F_status_set_fine(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_print_error(&global->main->program.error, macro_controller_f(fll_fss_extended_read));
+ controller_print_error(&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_print_error(&global->main->program.error, macro_controller_f(f_fss_apply_delimit));
+ controller_print_error(&main->program.error, macro_controller_f(f_fss_apply_delimit));
return status;
}
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_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase_by));
+ controller_print_error(&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_print_error(&global->main->program.error, macro_controller_f(f_fss_count_lines));
+ controller_print_error(&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_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(main, 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_error_simplify(F_status_set_fine(status));
fl_fss_extended_content_read(cache->buffer_item, range, &cache->content_action, 0, &cache->delimits, &state);
if (F_status_is_error(status)) {
- controller_print_error(&global->main->program.error, macro_controller_f(fll_fss_extended_content_read));
+ controller_print_error(&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_print_error(&global->main->program.error, macro_controller_f(f_fss_apply_delimit));
+ controller_print_error(&main->program.error, macro_controller_f(f_fss_apply_delimit));
}
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_print_error(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial));
+ controller_print_error(&main->program.error, macro_controller_f(f_rip_dynamic_partial));
}
}
else if (type == controller_rule_action_type_rerun_e) {
}
if (!type_rerun) {
- controller_print_rule_item_error_action_first(&global->main->program.error, cache);
+ controller_print_rule_item_error_action_first(&main->program.error, cache);
return F_status_set_error(F_valid_not);
}
}
}
else {
- controller_print_rule_item_error_action_second(&global->main->program.error, cache);
+ controller_print_rule_item_error_action_second(&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_rule_action_read_rerun_number(global, controller_delay_s.string, cache, &i, &rerun_item->delay);
+ status = controller_rule_action_read_rerun_number(main, 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_rule_action_read_rerun_number(global, controller_max_s.string, cache, &i, &rerun_item->max);
+ status = controller_rule_action_read_rerun_number(main, 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_print_rule_item_error_action_unknown(&global->main->program.error, cache, controller_rerun_s, i);
+ controller_print_rule_item_error_action_unknown(&main->program.error, cache, controller_rerun_s, i);
return F_status_set_error(F_valid_not);
}
item->with &= ~controller_with_session_new_d;
}
else {
- controller_print_rule_item_error_action_unknown(&global->main->program.error, cache, controller_with_s, i);
+ controller_print_rule_item_error_action_unknown(&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_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase));
+ controller_print_error(&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_print_error(&global->main->program.error, macro_controller_f(f_memory_array_increase));
+ controller_print_error(&main->program.error, macro_controller_f(f_memory_array_increase));
return status;
}
} // for
if (F_status_is_error(status)) {
- controller_print_error(&global->main->program.error, macro_controller_f(f_string_dynamic_partial_mash_nulless));
+ controller_print_error(&main->program.error, macro_controller_f(f_string_dynamic_partial_mash_nulless));
actions->array[actions->used++].status = controller_error_simplify(F_status_set_fine(status));
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_print_error(&global->main->program.error, macro_controller_f(fl_iki_read));
+ controller_print_error(&main->program.error, macro_controller_f(fl_iki_read));
actions->array[actions->used++].status = controller_error_simplify(F_status_set_fine(status));
f_fss_count_lines(cache->buffer_item, range->start, &actions->array[actions->used].line, &state);
if (F_status_is_error(status)) {
- controller_print_error(&global->main->program.error, macro_controller_f(f_fss_count_lines));
+ controller_print_error(&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_rule_parameters_read(global, cache->buffer_item, 0, &cache->content_action, &actions->array[actions->used], &state);
+ status = controller_rule_parameters_read(main, cache->buffer_item, 0, &cache->content_action, &actions->array[actions->used], &state);
if (F_status_is_error(status)) {
actions->array[actions->used++].status = controller_error_simplify(F_status_set_fine(status));
}
if (F_status_is_error_not(status) && status == F_data_not) {
- controller_print_rule_item_debug_action_empty(global->debug, cache);
+ controller_print_rule_item_debug_action_empty(&main->program.debug, cache);
}
return status;
#endif // _di_controller_rule_action_read_
#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 controller_rule_action_read_rerun_number(controller_t * const main, 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;
}
if (F_status_is_error(status)) {
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
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_print_error(&global->main->program.error, macro_controller_f(fl_conversion_dynamic_partial_to_signed_detect));
+ controller_print_error(&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_lock_print(main->program.error.to, &main->thread);
- fl_print_format("%r%[%QRule item action '%]", 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_rerun_s, global->main->program.error.notable);
- fl_print_format("%[' requires a positive whole number or 0 for the '%]", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context);
- fl_print_format("%[%S%]", global->main->program.error.to, global->main->program.error.notable, name, global->main->program.error.notable);
- fl_print_format("%[' value", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context);
+ fl_print_format("%r%[%QRule item action '%]", 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_rerun_s, main->program.error.notable);
+ fl_print_format("%[' requires a positive whole number or 0 for the '%]", main->program.error.to, main->program.error.context, main->program.error.context);
+ fl_print_format("%[%S%]", main->program.error.to, main->program.error.notable, name, main->program.error.notable);
+ fl_print_format("%[' value", main->program.error.to, main->program.error.context, main->program.error.context);
if (*index + 1 == cache->content_action.used) {
- fl_print_format(", but none were given.%]%r", global->main->program.error.to, global->main->program.error.context, f_string_eol_s);
+ fl_print_format(", but none were given.%]%r", main->program.error.to, main->program.error.context, f_string_eol_s);
}
else {
- fl_print_format(", but '%]%[%/Q%]", global->main->program.error.to, global->main->program.error.context, global->main->program.error.notable, cache->buffer_item, cache->content_action.array[*index], global->main->program.error.notable);
+ fl_print_format(", but '%]%[%/Q%]", main->program.error.to, main->program.error.context, main->program.error.notable, cache->buffer_item, cache->content_action.array[*index], main->program.error.notable);
if (status == F_number || status == F_number_decimal) {
- fl_print_format("%[' was given.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s);
+ fl_print_format("%[' was given.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s);
}
else if (status == F_number_overflow) {
- fl_print_format("%[' is too large.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s);
+ fl_print_format("%[' is too large.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s);
}
else {
- fl_print_format("%[' is negative.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s);
+ fl_print_format("%[' is negative.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s);
}
}
- controller_print_rule_error_cache(global->error, cache->action, F_true);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_true);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
}
*
* This will automatically increase the size of the actions array as needed.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param is_normal
* 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.
* @see f_memory_array_increase_by()
*/
#ifndef _di_controller_rule_action_read_
- extern f_status_t controller_rule_action_read(controller_global_t * const global, const bool is_normal, const uint8_t type, const uint8_t method, controller_cache_t * const cache, controller_rule_item_t * const item, controller_rule_actions_t * const actions, f_range_t * const range);
+ extern f_status_t controller_rule_action_read(controller_t * const main, 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_
/**
*
* This is intended to be called by controller_rule_action_read().
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param name
* The name representing the value whose number is being processed.
* @param cache
* @see fl_conversion_dynamic_partial_to_signed_detect()
*/
#ifndef _di_controller_rule_action_read_rerun_number_
- extern f_status_t controller_rule_action_read_rerun_number(controller_global_t * const global, const f_string_t name, controller_cache_t * const cache, f_number_unsigned_t * const index, f_number_unsigned_t * const number);
+ extern f_status_t controller_rule_action_read_rerun_number(controller_t * const main, 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_
#endif
#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) {
+ f_status_t controller_rule_execute(controller_t * const main, const uint8_t action, const uint8_t options, controller_instance_t * const instance) {
- if (!global || !instance) return F_status_set_error(F_parameter);
+ if (!main || !instance) return F_status_set_error(F_parameter);
f_status_t status = F_okay;
f_status_t success = F_false;
status = fll_control_group_prepare(instance->rule.cgroup);
if (F_status_is_error(status)) {
- 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);
+ controller_print_error_file(&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_print_error_status(&global->main->program.error, macro_controller_f(fl_environment_load_names), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(fl_environment_load_names), F_status_set_fine(status));
return status;
}
controller_entry_t *entry = 0;
if (instance->type == controller_instance_type_entry_e) {
- entry = &global->program->entry;
+ entry = &main->process.entry;
}
else if (instance->type == controller_instance_type_exit_e) {
- entry = &global->program->exit;
+ entry = &main->process.exit;
}
if (entry) {
status = f_string_dynamic_append(entry->define.array[i].value, &environment.array[k].value);
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));
+ controller_print_error_status(&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_print_error_status(&global->main->program.error, macro_controller_f(f_string_maps_append), F_status_set_fine(status));
+ controller_print_error_status(&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_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status));
+ controller_print_error_status(&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_print_error_status(&global->main->program.error, macro_controller_f(f_string_maps_append), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_string_maps_append), F_status_set_fine(status));
return status;
}
controller_entry_t *entry = 0;
if (instance->type == controller_instance_type_entry_e) {
- entry = &global->program->entry;
+ entry = &main->process.entry;
}
else if (instance->type == controller_instance_type_exit_e) {
- entry = &global->program->exit;
+ entry = &main->process.exit;
}
// When a custom define is specified, it needs to be exported into the environment.
status = f_environment_get_all(&environment);
if (F_status_is_error(status)) {
- controller_print_error_status(&global->main->program.error, macro_controller_f(f_environment_get_all), F_status_set_fine(status));
+ controller_print_error_status(&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_print_error_status(&global->main->program.error, macro_controller_f(f_string_maps_append), F_status_set_fine(status));
+ controller_print_error_status(&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_print_error_status(&global->main->program.error, macro_controller_f(f_string_maps_append), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_string_maps_append), F_status_set_fine(status));
return status;
}
}
if (instance->rule.items.array[i].type == controller_rule_item_type_command_e) {
- status = controller_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance);
+ status = controller_rule_expand(main, instance->rule.items.array[i].actions.array[j], instance);
if (F_status_is_error(status)) {
- controller_print_rule_error(global->error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false);
+ controller_print_rule_error(&main->program.error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false);
break;
}
}
}
else if (instance->rule.items.array[i].type == controller_rule_item_type_script_e) {
- status = controller_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance);
+ status = controller_rule_expand(main, instance->rule.items.array[i].actions.array[j], instance);
if (F_status_is_error(status)) {
- controller_print_rule_error(global->error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false);
+ controller_print_rule_error(&main->program.error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false);
break;
}
}
}
else if (instance->rule.items.array[i].type == controller_rule_item_type_service_e) {
- status = controller_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance);
+ status = controller_rule_expand(main, instance->rule.items.array[i].actions.array[j], instance);
if (F_status_is_error(status)) {
- controller_print_rule_error(global->error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false);
+ controller_print_rule_error(&main->program.error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false);
break;
}
else {
success = F_status_set_error(F_failure);
- controller_print_rule_action_error_missing_pid(global->error, instance->rule.alias);
+ controller_print_rule_action_error_missing_pid(&main->program.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_rule_expand(global, instance->rule.items.array[i].actions.array[j], instance);
+ status = controller_rule_expand(main, instance->rule.items.array[i].actions.array[j], instance);
if (F_status_is_error(status)) {
- controller_print_rule_error(global->error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false);
+ controller_print_rule_error(&main->program.error, instance->cache.action, F_status_set_fine(status), "controller_rule_expand", F_true, F_false);
break;
}
else {
success = F_status_set_error(F_failure);
- controller_print_rule_action_error_missing_pid(global->error, instance->rule.alias);
+ controller_print_rule_action_error_missing_pid(&main->program.error, instance->rule.alias);
}
}
else {
- if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global->main->program.warning.to, global->thread);
+ if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(main->program.warning.to, &main->thread);
- 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);
+ fl_print_format("%r%[%QAction type is unknown, ignoring.%]%r", main->program.warning.to, f_string_eol_s, main->program.warning.context, main->program.warning.prefix, main->program.warning.context, f_string_eol_s);
- controller_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true);
+ controller_print_rule_error_cache(&main->program.warning, instance->cache.action, F_true);
- controller_unlock_print_flush(global->main->program.warning.to, global->thread);
+ controller_unlock_print_flush(main->program.warning.to, &main->thread);
}
if (success == F_false) {
// Lock failed, attempt to re-establish lock before returning.
if (F_status_set_fine(status) == F_lock) {
- status = controller_lock_read(instance, global->thread, &instance->lock);
+ status = controller_lock_read(instance, &main->thread, &instance->lock);
if (F_status_is_error(status)) return F_status_set_error(F_lock);
success = F_false;
#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);
+ if (!instance || !instance->main) return F_status_set_error(F_parameter);
f_status_t status = F_okay;
f_status_t status_lock = F_okay;
- controller_t * const main = instance->global->main;
- controller_thread_t * const thread = instance->global->thread;
+ controller_t * const main = instance->main;
f_execute_result_t result = f_execute_result_t_initialize;
if (options & controller_instance_option_simulate_e) {
if (main->program.output.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(main->program.output.to, thread);
+ controller_lock_print(main->program.output.to, &instance->main->thread);
fl_print_format("%rSimulating execution of '%[", main->program.output.to, f_string_eol_s, main->program.context.set.title);
fl_print_format("%]' from '", main->program.output.to, main->program.context.set.important);
fl_print_format("%[%Q%]'.%r", main->program.output.to, main->program.context.set.notable, instance->rule.name, 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->main->thread);
}
// Sleep for less than a second to better show simulation of synchronous vs asynchronous.
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);
+ status = controller_time_sleep_nanoseconds(instance->main, delay);
}
}
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);
if (F_status_set_fine(status_lock) != F_interrupt) {
status = controller_lock_read_instance(instance, &instance->active);
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);
}
if (F_status_set_fine(status_lock) != F_interrupt) {
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);
if (F_status_set_fine(status_lock) != F_interrupt) {
status = controller_lock_read_instance(instance, &instance->active);
-
- if (status == F_okay) {
- return status_lock;
- }
+ if (status == F_okay) return status_lock;
}
return F_status_set_error(F_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);
return F_status_set_error(F_lock);
}
else {
main->program.child = result.status;
- if (!controller_thread_is_enabled_instance(instance)) {
- return F_status_set_error(F_interrupt);
- }
+ if (!controller_thread_is_enabled_instance(instance)) return F_status_set_error(F_interrupt);
}
if (F_status_is_error(status)) {
}
}
- if (status == F_child || F_status_set_fine(status) == F_interrupt) {
- return status;
- }
+ if (status == F_child || F_status_set_fine(status) == F_interrupt) return status;
if (F_status_is_error(status)) {
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_print_rule_item_error_execute(instance->global->error, instance, type == controller_rule_item_type_script_e, program.used ? program : arguments.array[0], status);
+ controller_print_rule_item_error_execute(&instance->main->program.error, instance, type == controller_rule_item_type_script_e, program.used ? program : arguments.array[0], status);
}
else {
- controller_print_error_status(instance->global->error, macro_controller_f(fll_execute_program), F_status_set_fine(status));
+ controller_print_error_status(&instance->main->program.error, macro_controller_f(fll_execute_program), F_status_set_fine(status));
}
status = F_status_set_error(status);
#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 || !instance->global || !instance->global->main || !instance->global->thread) return F_status_set_error(F_parameter);
+ if (!execute_set || !instance || !instance->main) return F_status_set_error(F_parameter);
f_status_t status = F_okay;
f_status_t status_lock = F_okay;
- controller_t * const main = instance->global->main;
+ controller_t * const main = instance->main;
f_execute_result_t result = f_execute_result_t_initialize;
if (options & controller_instance_option_simulate_e) {
if (main->program.error.verbosity > f_console_verbosity_error_e) {
- controller_lock_print(main->program.error.to, instance->global->thread);
+ controller_lock_print(main->program.error.to, &instance->main->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, instance->global->thread);
+ controller_unlock_print_flush(main->program.error.to, &instance->main->thread);
}
// Sleep for less than a second to better show simulation of synchronous vs asynchronous.
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);
+ status = controller_time_sleep_nanoseconds(instance->main, delay);
}
}
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, instance->global->thread);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
if (F_status_set_fine(status_lock) != F_interrupt) {
status = controller_lock_read_instance(instance, &instance->active);
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, instance->global->thread);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
}
if (F_status_set_fine(status_lock) != F_interrupt) {
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, instance->global->thread);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
if (F_status_set_fine(status_lock) != F_interrupt) {
status = controller_lock_read_instance(instance, &instance->active);
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, instance->global->thread);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
return F_status_set_error(F_lock);
}
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_print_rule_item_error_execute(instance->global->error, instance, type == controller_rule_item_type_utility_e, program.used ? program : arguments.array[0], status);
+ controller_print_rule_item_error_execute(&instance->main->program.error, instance, type == controller_rule_item_type_utility_e, program.used ? program : arguments.array[0], status);
}
else {
- controller_print_error_status(instance->global->error, macro_controller_f(fll_execute_program), F_status_set_fine(status));
+ controller_print_error_status(&instance->main->program.error, macro_controller_f(fll_execute_program), F_status_set_fine(status));
}
return F_status_set_error(status);
#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 || !instance->global || !instance->global->main || !instance->global->thread || !item) return F_false;
+ if (!instance || !instance->main || !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_t * const main = instance->global->main;
+ controller_t * const main = instance->main;
controller_rule_rerun_item_t * const rerun_item = result ? &item->reruns[action].failure : &item->reruns[action].success;
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, instance->global->thread);
+ controller_lock_print(main->program.output.to, &instance->main->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(" 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, instance->global->thread);
+ controller_unlock_print_flush(main->program.output.to, &instance->main->thread);
}
if (rerun_item->delay) {
}
{
- const f_status_t status = controller_time_sleep_nanoseconds(instance->global, delay);
+ const f_status_t status = controller_time_sleep_nanoseconds(instance->main, delay);
if (F_status_is_error(status) || status == F_interrupt) return -1;
}
*
* This requires that a read lock be set on process->lock before being called.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param action
* The action to perform based on the action type codes.
*
* On failure, the individual status for the rule is set to an appropriate error status.
*/
#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);
+ extern f_status_t controller_rule_execute(controller_t * const main, const uint8_t action, const uint8_t options, controller_instance_t * const instance);
#endif // _di_controller_rule_execute_
/**
#endif
#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) {
+ f_status_t controller_rule_expand(controller_t * const main, const controller_rule_action_t action, controller_instance_t * const instance) {
- if (!global || !instance) return F_status_set_error(F_parameter);
+ if (!main || !instance) return F_status_set_error(F_parameter);
instance->cache.expanded.used = 0;
#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 || !instance->global || !instance->global->program || !destination) return F_status_set_error(F_parameter);
+ if (!instance || !instance->main || !destination) return F_status_set_error(F_parameter);
if (vocabulary.start > vocabulary.stop) return F_okay;
if (content.start > content.stop) return F_okay;
} // for
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;
+ controller_entry_t * const entry = instance->type == controller_instance_type_entry_e ? &instance->main->process.entry : &instance->main->process.exit;
for (i = 0; i < entry->define.used; ++i) {
} // for
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;
+ controller_entry_t * const entry = instance->type == controller_instance_type_entry_e ? &instance->main->process.entry : &instance->main->process.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 = instance->global->main.program.parameters.arguments.array;
- f_console_parameters_t * const parameters = &instance->global->main.program.parameters;
+ f_string_static_t * const argv = instance->main->program.parameters.arguments.array;
+ f_console_parameters_t * const parameters = &instance->main->program.parameters;
const f_string_static_t options[] = {
f_console_standard_long_light_s,
/**
* Expand a single IKI variable into the buffer.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param action
* The rule action data.
* @param process
* @see controller_rule_expand_iki()
*/
#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);
+ extern f_status_t controller_rule_expand(controller_t * const main, const controller_rule_action_t action, controller_instance_t * const instance);
#endif // _di_controller_rule_expand_
/**
#ifndef _di_controller_rule_instance_
f_status_t controller_rule_instance(controller_instance_t * const instance) {
- if (!instance || !instance->global) return F_status_set_error(F_parameter);
+ if (!instance || !instance->main) return F_status_set_error(F_parameter);
- controller_global_t * const global = instance->global;
+ controller_t * const main = instance->main;
switch (instance->action) {
case controller_rule_action_type_freeze_e:
break;
default:
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
- controller_lock_print(global->main->program.error.to, global->thread);
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_lock_print(main->program.error.to, &main->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_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);
+ 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_convert_rule_action_type_string(instance->action), main->program.error.notable);
+ fl_print_format("%[' while attempting to execute rule.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s);
- controller_print_rule_error_cache(global->error, instance->cache.action, F_true);
+ controller_print_rule_error_cache(&main->program.error, instance->cache.action, F_true);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
return F_status_set_error(F_parameter);
}
if (F_status_is_error(status)) {
- controller_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(&main->program.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_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(&main->program.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_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(&main->program.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_rule_validate(global, instance->rule, instance->action, instance->options, &instance->cache);
+ if ((instance->options & controller_instance_option_simulate_validate_e) == controller_instance_option_simulate_validate_e) {
+ controller_rule_validate(main, instance->rule, instance->action, instance->options, &instance->cache);
}
f_number_unsigned_t i = 0;
dependency = 0;
found = F_false;
- status_lock = controller_lock_read_instance(instance, &global->thread->lock.instance);
+ status_lock = controller_lock_read_instance(instance, &main->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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
}
else {
- status = controller_instance_prepare_instance_type(global, instance->type, instance->action, dynamics[i]->array[j], &id_dependency);
+ status = controller_instance_prepare_instance_type(main, instance->type, instance->action, dynamics[i]->array[j], &id_dependency);
if (F_status_is_error(status)) {
if (F_status_set_fine(status) == F_lock) {
- if (!controller_thread_is_enabled_instance_type(instance->type, global->thread)) {
+ if (!controller_thread_is_enabled_instance_type(instance->type, &main->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);
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_lock_print(main->program.error.to, &main->thread);
- 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_print_rule_item_error_rule_not_loaded(&main->program.error, dynamics[i]->array[j]);
+ controller_print_rule_error_cache(&main->program.error, instance->cache.action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
return status;
if (status == F_true) {
found = F_true;
- dependency = global->thread->instances.array[id_dependency];
+ dependency = main->thread.instances.array[id_dependency];
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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
status = F_false;
dependency = 0;
- f_thread_unlock(&global->thread->lock.instance);
+ f_thread_unlock(&main->thread.lock.instance);
}
else {
- f_thread_unlock(&global->thread->lock.instance);
+ f_thread_unlock(&main->thread.lock.instance);
- status_lock = controller_lock_read_instance(instance, &global->thread->lock.rule);
+ status_lock = controller_lock_read_instance(instance, &main->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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
status = F_false;
}
else {
- status = controller_rule_find(dynamics[i]->array[j], global->program->rules, &id_rule);
+ status = controller_rule_find(dynamics[i]->array[j], main->process.rules, &id_rule);
- f_thread_unlock(&global->thread->lock.rule);
+ f_thread_unlock(&main->thread.lock.rule);
}
}
}
else {
- f_thread_unlock(&global->thread->lock.instance);
+ f_thread_unlock(&main->thread.lock.instance);
}
if (status != F_true) {
id_rule = 0;
if (i == 0) {
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->thread);
- 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_print_rule_item_error_need_want_wish(&main->program.error, strings[i], dynamics[i]->array[j], "is not found");
+ controller_print_rule_error_cache(&main->program.error, instance->cache.action, F_true);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
status = F_status_set_error(F_found_not);
}
}
else {
- if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global->main->program.warning.to, global->thread);
+ if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(main->program.warning.to, &main->thread);
- controller_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(&main->program.warning, strings[i], dynamics[i]->array[j], "is not found");
- controller_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true);
+ controller_print_rule_error_cache(&main->program.warning, instance->cache.action, F_true);
- controller_unlock_print_flush(global->main->program.warning.to, global->thread);
+ controller_unlock_print_flush(main->program.warning.to, &main->thread);
}
}
}
else if (found) {
- status_lock = controller_lock_read_instance(instance, &global->thread->lock.rule);
+ status_lock = controller_lock_read_instance(instance, &main->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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
found = F_false;
status = status_lock;
// The dependency may have write locks, which needs to be avoided, so copy the alias from the rule.
f_string_static_t alias_other_buffer = f_string_static_t_initialize;
- alias_other_buffer.used = global->program->rules.array[id_rule].alias.used;
+ alias_other_buffer.used = main->process.rules.array[id_rule].alias.used;
f_char_t alias_other_buffer_string[alias_other_buffer.used + 1];
alias_other_buffer.string = alias_other_buffer_string;
- memcpy(alias_other_buffer_string, global->program->rules.array[id_rule].alias.string, sizeof(f_char_t) * alias_other_buffer.used);
+ memcpy(alias_other_buffer_string, main->process.rules.array[id_rule].alias.string, sizeof(f_char_t) * alias_other_buffer.used);
alias_other_buffer_string[alias_other_buffer.used] = 0;
- f_thread_unlock(&global->thread->lock.rule);
+ f_thread_unlock(&main->thread.lock.rule);
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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
status = status_lock;
}
status = dependency->rule.status[instance->action];
}
else {
- status_lock = controller_lock_read_instance(instance, &global->thread->lock.rule);
+ status_lock = controller_lock_read_instance(instance, &main->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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
f_thread_unlock(&dependency->lock);
status = status_lock;
}
- else if (controller_rule_status_is_available(instance->action, global->program->rules.array[id_rule])) {
- f_thread_unlock(&global->thread->lock.rule);
+ else if (controller_rule_status_is_available(instance->action, main->process.rules.array[id_rule])) {
+ f_thread_unlock(&main->thread.lock.rule);
f_thread_unlock(&dependency->lock);
options_instance = 0;
- if (global->main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) {
+ if (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) {
options_instance |= controller_instance_option_simulate_e;
}
}
// Synchronously execute dependency.
- status = controller_rule_instance_begin(global, 0, alias_other_buffer, instance->action, options_instance, instance->type, instance->stack, dependency->cache);
+ status = controller_rule_instance_begin(main, 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 (F_status_is_error(status)) {
if (i == 0 || i == 1 || F_status_set_fine(status) == F_memory_not) {
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->thread);
- 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_print_rule_item_error_need_want_wish(&main->program.error, strings[i], alias_other_buffer, "failed during execution");
+ controller_print_rule_error_cache(&main->program.error, instance->cache.action, F_true);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
if (!(dependency->options & controller_instance_option_simulate_e) || F_status_set_fine(status) == F_memory_not) {
f_thread_unlock(&dependency->active);
}
}
else {
- if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global->main->program.warning.to, global->thread);
+ if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(main->program.warning.to, &main->thread);
- controller_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(&main->program.warning, strings[i], alias_other_buffer, "failed during execution");
- controller_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true);
+ controller_print_rule_error_cache(&main->program.warning, instance->cache.action, F_true);
- controller_unlock_print_flush(global->main->program.warning.to, global->thread);
+ controller_unlock_print_flush(main->program.warning.to, &main->thread);
}
}
}
}
else {
- status = global->program->rules.array[id_rule].status[instance->action];
+ status = main->process.rules.array[id_rule].status[instance->action];
- f_thread_unlock(&global->thread->lock.rule);
+ f_thread_unlock(&main->thread.lock.rule);
f_thread_unlock(&dependency->lock);
}
}
}
if (F_status_is_error_not(status_lock)) {
- status_lock = controller_lock_read_instance(instance, &global->thread->lock.rule);
+ status_lock = controller_lock_read_instance(instance, &main->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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
}
}
if (F_status_is_error(status_lock)) {
if (F_status_is_error(status_lock)) {
- controller_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(&main->program.error, strings[i], alias_other_buffer, "due to lock failure");
}
status = status_lock;
}
- else if (controller_rule_status_is_error(instance->action, global->program->rules.array[id_rule])) {
- f_thread_unlock(&global->thread->lock.rule);
+ else if (controller_rule_status_is_error(instance->action, main->process.rules.array[id_rule])) {
+ f_thread_unlock(&main->thread.lock.rule);
if (i == 0 || i == 1) {
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->thread);
- controller_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(&main->program.error, strings[i], alias_other_buffer, "is in a failed state");
- controller_print_rule_error_cache(global->error, instance->cache.action, F_true);
+ controller_print_rule_error_cache(&main->program.error, instance->cache.action, F_true);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
status = F_status_set_error(F_found_not);
}
}
else {
- if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global->main->program.warning.to, global->thread);
+ if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(main->program.warning.to, &main->thread);
- controller_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(&main->program.warning, strings[i], alias_other_buffer, "is in a failed state");
- controller_print_rule_error_cache(&global->main->program.warning, instance->cache.action, F_true);
+ controller_print_rule_error_cache(&main->program.warning, instance->cache.action, F_true);
- controller_unlock_print_flush(global->main->program.warning.to, global->thread);
+ controller_unlock_print_flush(main->program.warning.to, &main->thread);
}
}
}
else {
- f_thread_unlock(&global->thread->lock.rule);
+ f_thread_unlock(&main->thread.lock.rule);
}
}
}
if ((instance->options & controller_instance_option_wait_e) && F_status_is_error_not(status) && (instance->options & controller_instance_option_validate_e)) {
- status_lock = controller_rule_wait_all_instance_type(global, instance->type, F_false);
+ status_lock = controller_rule_wait_all_instance_type(main, instance->type, F_false);
if (F_status_set_fine(status_lock) == F_interrupt) {
return status_lock;
} // for
if (missing) {
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
- controller_lock_print(global->main->program.error.to, global->thread);
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_lock_print(main->program.error.to, &main->thread);
if (instance->rule.items.used) {
- 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_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);
+ fl_print_format("%r%[%QThe rule '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context);
+ fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, instance->rule.name, main->program.error.notable);
+ fl_print_format("%[' has no '%]", main->program.error.to, main->program.error.context, main->program.error.context);
+ fl_print_format(f_string_format_r_single_s.string, main->program.error.to, main->program.error.notable, controller_convert_rule_action_type_string(instance->action), main->program.error.notable);
+ fl_print_format("%[' action to execute.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s);
}
else {
- 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 known '%]", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context);
- fl_print_format("%[%r %r%]", global->main->program.error.to, global->main->program.error.notable, controller_rule_s, controller_type_s, global->main->program.error.notable);
- fl_print_format("%[' (such as '%]", 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_command_s, global->main->program.error.notable);
- fl_print_format("%[', '%]", 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_service_s, global->main->program.error.notable);
- fl_print_format("%[', '%]", 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_script_s, global->main->program.error.notable);
- fl_print_format("%[', or '%]", 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_utility_s, global->main->program.error.notable);
- 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);
+ fl_print_format("%r%[%QThe rule '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context);
+ fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, instance->rule.name, main->program.error.notable);
+ fl_print_format("%[ has no known '%]", main->program.error.to, main->program.error.context, main->program.error.context);
+ fl_print_format("%[%r %r%]", main->program.error.to, main->program.error.notable, controller_rule_s, controller_type_s, main->program.error.notable);
+ fl_print_format("%[' (such as '%]", main->program.error.to, main->program.error.context, main->program.error.context);
+ fl_print_format(f_string_format_r_single_s.string, main->program.error.to, main->program.error.notable, controller_command_s, main->program.error.notable);
+ fl_print_format("%[', '%]", main->program.error.to, main->program.error.context, main->program.error.context);
+ fl_print_format(f_string_format_r_single_s.string, main->program.error.to, main->program.error.notable, controller_service_s, main->program.error.notable);
+ fl_print_format("%[', '%]", main->program.error.to, main->program.error.context, main->program.error.context);
+ fl_print_format(f_string_format_r_single_s.string, main->program.error.to, main->program.error.notable, controller_script_s, main->program.error.notable);
+ fl_print_format("%[', or '%]", main->program.error.to, main->program.error.context, main->program.error.context);
+ fl_print_format(f_string_format_r_single_s.string, main->program.error.to, main->program.error.notable, controller_utility_s, main->program.error.notable);
+ fl_print_format("%[') to execute.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s);
}
- controller_print_rule_error_cache(global->error, instance->cache.action, F_true);
+ controller_print_rule_error_cache(&main->program.error, instance->cache.action, F_true);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
status = F_status_set_error(F_parameter);
}
if (F_status_is_error_not(status)) {
- status = controller_rule_execute(global, instance->action, instance->options, instance);
+ status = controller_rule_execute(main, 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_print_rule_item_error(global->error, instance->cache.action, F_true, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, instance->cache.action, F_true, F_status_set_fine(status));
}
}
}
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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
if (F_status_set_fine(status) != F_interrupt) {
status = controller_lock_read_instance(instance, &instance->lock);
instance->rule.status[instance->action] = status;
}
- status_lock = controller_lock_write_instance(instance, &global->thread->lock.rule);
+ status_lock = controller_lock_write_instance(instance, &main->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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
f_thread_unlock(&instance->lock);
return F_status_set_error(F_lock);
}
- // Update the global rule status, which is stored separately from the rule status for this instance.
- if (controller_rule_find(instance->rule.alias, global->program->rules, &id_rule) == F_true) {
- controller_rule_t *rule = &global->program->rules.array[id_rule];
+ // Update the rule status, which is stored separately from the rule status for this instance.
+ if (controller_rule_find(instance->rule.alias, main->process.rules, &id_rule) == F_true) {
+ controller_rule_t *rule = &main->process.rules.array[id_rule];
rule->status[instance->action] = instance->rule.status[instance->action];
} // for
}
- f_thread_unlock(&global->thread->lock.rule);
+ f_thread_unlock(&main->thread.lock.rule);
f_thread_unlock(&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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
return F_status_set_error(F_lock);
}
#endif // _di_controller_rule_instance_
#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) {
+ f_status_t controller_rule_instance_begin(controller_t * const main, 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 (!main) return F_status_set_error(F_parameter);
- if (!controller_thread_is_enabled_instance_type(type, global->thread)) {
+ if (!controller_thread_is_enabled_instance_type(type, &main->thread)) {
return F_status_set_error(F_interrupt);
}
controller_instance_t *instance = 0;
- status = controller_lock_read_instance_type(type, global->thread, &global->thread->lock.instance);
+ status = controller_lock_read_instance_type(type, &main->thread, &main->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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status), F_true);
return status;
}
{
f_number_unsigned_t at = 0;
- status = controller_instance_prepare(global, type != controller_instance_type_exit_e, action, alias_rule, &at);
+ status = controller_instance_prepare(main, type != controller_instance_type_exit_e, action, alias_rule, &at);
if (F_status_is_error(status)) {
- f_thread_unlock(&global->thread->lock.instance);
+ f_thread_unlock(&main->thread.lock.instance);
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
- controller_lock_print(global->main->program.error.to, global->thread);
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_lock_print(main->program.error.to, &main->thread);
- 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_print_rule_item_error_rule_not_loaded(&main->program.error, alias_rule);
+ controller_print_rule_error_cache(&main->program.error, cache.action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
return status;
}
- instance = global->thread->instances.array[at];
+ instance = main->thread.instances.array[at];
- status = controller_lock_read_instance_type(type, global->thread, &instance->active);
+ status = controller_lock_read_instance_type(type, &main->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_print_rule_item_error(global->error, cache.action, F_false, F_status_set_fine(status));
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status), F_true);
+ controller_print_rule_item_error(&main->program.error, cache.action, F_false, F_status_set_fine(status));
- f_thread_unlock(&global->thread->lock.instance);
+ f_thread_unlock(&main->thread.lock.instance);
return status;
}
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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
f_thread_unlock(&instance->active);
- f_thread_unlock(&global->thread->lock.instance);
+ f_thread_unlock(&main->thread.lock.instance);
return status_lock;
}
- // Once a write lock on the instance is achieved, it is safe to unlock the global instance read lock.
- f_thread_unlock(&global->thread->lock.instance);
+ // Once a write lock on the instance is achieved, it is safe to unlock the instance read lock.
+ f_thread_unlock(&main->thread.lock.instance);
// If the instance is already running, then there is nothing to do.
if (instance->state == controller_instance_state_active_e || instance->state == controller_instance_state_busy_e) {
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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
f_thread_unlock(&instance->active);
instance->stack.used = 0;
- instance->global = (void *) global;
+ instance->main = (void *) main;
if (F_status_is_error_not(status) && stack.used) {
if (instance->stack.size < stack.used) {
}
if (F_status_is_error(status)) {
- controller_print_error_status(&global->main->program.error, macro_controller_f(f_memory_array_resize), F_status_set_fine(status));
+ controller_print_error_status(&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_print_error_status(&global->main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status));
}
}
}
if (F_status_is_error(status)) {
- controller_print_error_status(&global->main->program.error, macro_controller_f(f_thread_create), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_thread_create), F_status_set_fine(status));
}
}
else {
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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
f_thread_unlock(&instance->active);
#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);
+ if (!instance || !instance->main) return F_status_set_error(F_parameter);
f_status_t status_lock = F_okay;
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);
+ controller_lock_print_error_critical(&instance->main->program.error, F_status_set_fine(status_lock), F_true);
return status_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);
+ controller_lock_print_error_critical(&instance->main->program.error, F_status_set_fine(status_lock), F_true);
if (options_force & controller_instance_option_asynchronous_e) {
f_thread_unlock(&instance->active);
const f_number_unsigned_t used_original_stack = instance->stack.used;
- status_lock = controller_lock_read_instance(instance, &global->thread->lock.rule);
+ status_lock = controller_lock_read_instance(instance, &instance->main->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);
+ controller_lock_print_error_critical(&instance->main->program.error, F_status_set_fine(status_lock), F_true);
f_thread_unlock(&instance->lock);
return status_lock;
}
- if (controller_rule_find(instance->rule.alias, global->program->rules, &id_rule) == F_true) {
+ if (controller_rule_find(instance->rule.alias, instance->main->process.rules, &id_rule) == F_true) {
f_thread_unlock(&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);
+ controller_lock_print_error_critical(&instance->main->program.error, F_status_set_fine(status_lock), F_false);
- f_thread_unlock(&global->thread->lock.rule);
+ f_thread_unlock(&instance->main->thread.lock.rule);
if (options_force & controller_instance_option_asynchronous_e) {
f_thread_unlock(&instance->active);
controller_rule_delete(&instance->rule);
- status = controller_rule_copy(global->program->rules.array[id_rule], &instance->rule);
+ status = controller_rule_copy(instance->main->process.rules.array[id_rule], &instance->rule);
f_thread_unlock(&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);
+ controller_lock_print_error_critical(&instance->main->program.error, F_status_set_fine(status_lock), F_true);
- f_thread_unlock(&global->thread->lock.rule);
+ f_thread_unlock(&instance->main->thread.lock.rule);
if (options_force & controller_instance_option_asynchronous_e) {
f_thread_unlock(&instance->active);
return status_lock;
}
- f_thread_unlock(&global->thread->lock.rule);
+ f_thread_unlock(&instance->main->thread.lock.rule);
if (F_status_is_error(status)) {
- controller_print_error_status(&global->main->program.error, macro_controller_f(controller_rule_copy), F_status_set_fine(status));
+ controller_print_error_status(&instance->main->program.error, macro_controller_f(controller_rule_copy), F_status_set_fine(status));
}
else if (!instance->action) {
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) {
- controller_lock_print(global->main->program.error.to, global->thread);
+ if (instance->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_lock_print(instance->main->program.error.to, &instance->main->thread);
- 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.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);
+ fl_print_format("%r%[%QThe rule '%]", instance->main->program.error.to, f_string_eol_s, instance->main->program.error.context, instance->main->program.error.prefix, instance->main->program.error.context);
+ fl_print_format(f_string_format_Q_single_s.string, instance->main->program.error.to, instance->main->program.error.notable, instance->rule.alias, instance->main->program.error.notable);
+ fl_print_format("%[' is already on the execution dependency stack, this recursion is prohibited.%]%r", instance->main->program.error.to, instance->main->program.error.context, instance->main->program.error.context, f_string_eol_s);
- controller_print_rule_error_cache(global->error, instance->cache.action, F_true);
+ controller_print_rule_error_cache(&instance->main->program.error, instance->cache.action, F_true);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(instance->main->program.error.to, &instance->main->thread);
}
// Never continue on circular recursion errors even in simulate mode.
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_print_error_status(&global->main->program.error, macro_controller_f(f_memory_array_increase), F_status_set_fine(status));
+ controller_print_error_status(&instance->main->program.error, macro_controller_f(f_memory_array_increase), F_status_set_fine(status));
}
else {
f_thread_unlock(&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);
+ controller_lock_print_error_critical(&instance->main->program.error, F_status_set_fine(status_lock), F_false);
if (options_force & controller_instance_option_asynchronous_e) {
f_thread_unlock(&instance->active);
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);
+ controller_lock_print_error_critical(&instance->main->program.error, F_status_set_fine(status_lock), F_true);
if (options_force & controller_instance_option_asynchronous_e) {
f_thread_unlock(&instance->active);
}
}
else {
- f_thread_unlock(&global->thread->lock.rule);
+ f_thread_unlock(&instance->main->thread.lock.rule);
status = F_status_set_error(F_found_not);
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
- controller_lock_print(global->main->program.error.to, global->thread);
+ if (instance->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_lock_print(instance->main->program.error.to, &instance->main->thread);
- 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_print_rule_item_error_rule_not_loaded(&instance->main->program.error, instance->rule.alias);
+ controller_print_rule_error_cache(&instance->main->program.error, instance->cache.action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(instance->main->program.error.to, &instance->main->thread);
}
}
return status;
}
- status_lock = controller_lock_write_instance(instance, &global->thread->lock.rule);
+ status_lock = controller_lock_write_instance(instance, &instance->main->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);
+ controller_lock_print_error_critical(&instance->main->program.error, F_status_set_fine(status_lock), F_false);
if (F_status_set_fine(status) != F_lock) {
f_thread_unlock(&instance->lock);
}
if (F_status_set_fine(status) == F_lock) {
- if (controller_rule_find(instance->rule.alias, global->program->rules, &id_rule) == F_true) {
- global->program->rules.array[id_rule].status[instance->action] = status;
+ if (controller_rule_find(instance->rule.alias, instance->main->process.rules, &id_rule) == F_true) {
+ instance->main->process.rules.array[id_rule].status[instance->action] = status;
}
}
- f_thread_unlock(&global->thread->lock.rule);
+ f_thread_unlock(&instance->main->thread.lock.rule);
if (F_status_set_fine(status) != F_lock) {
f_thread_unlock(&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);
+ controller_lock_print_error_critical(&instance->main->program.error, F_status_set_fine(status_lock), F_false);
if (options_force & controller_instance_option_asynchronous_e) {
f_thread_unlock(&instance->active);
return status_lock;
}
- if (options_force & controller_instance_option_asynchronous_e) {
- instance->state = controller_instance_state_done_e;
- }
- else {
- instance->state = controller_instance_state_idle_e;
- }
-
+ instance->state = (options_force & controller_instance_option_asynchronous_e) ? controller_instance_state_done_e : controller_instance_state_idle_e;
instance->stack.used = used_original_stack;
// inform all things waiting that the instance has finished running.
f_thread_unlock(&instance->active);
}
- if (controller_thread_is_enabled_instance(instance)) {
- return status;
- }
-
- return F_status_set_error(F_interrupt);
+ return controller_thread_is_enabled_instance(instance) ? status : F_status_set_error(F_interrupt);
}
#endif // _di_controller_rule_instance_do_
/**
* Synchronously or asynchronously begin processing some rule.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param options_force
* Force the given instance options, only supporting a subset of instance options.
*
* @see f_thread_create()
*/
#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);
+ extern f_status_t controller_rule_instance_begin(controller_t * const main, 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_
/**
/**
* Check to see if the given Rule has status F_known_not for the given Rule Action.
*
- * The global Rule status is checked for error and any errors on the global Rule status will result in F_false.
+ * The Rule status is checked for error and any errors on the Rule status will result in F_false.
*
* @param action
* The Rule Action type.
/**
* Check to see if the given Rule has status is designated as an error for the given Rule Action.
*
- * The global Rule status is checked for error and any errors on the global Rule status will result in F_true.
+ * The Rule status is checked for error and any errors on the Rule status will result in F_true.
*
* @param action
* The Rule Action type.
#endif
#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) {
+ f_status_t controller_rule_item_read(controller_t * const main, 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);
+ if (!main || !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);
+ controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, main);
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_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(&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_print_error_status(&global->main->program.error, macro_controller_f(fl_fss_extended_object_read), F_status_set_fine(status));
+ controller_print_error_status(&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_print_error_status(&global->main->program.error, macro_controller_f(f_fss_apply_delimit), F_status_set_fine(status));
+ controller_print_error_status(&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_print_error_status(&global->main->program.error, macro_controller_f(f_fss_count_lines), F_status_set_fine(status));
+ controller_print_error_status(&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_print_error_status(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
break;
}
type = controller_rule_action_type_with_e;
}
else {
- if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global->main->program.warning.to, global->thread);
+ if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(main->program.warning.to, &main->thread);
- fl_print_format("%r%[%QUnknown rule item action '%]", global->main->program.warning.to, f_string_eol_s, global->main->program.warning.context, global->main->program.warning.prefix, global->main->program.warning.context);
- 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);
+ fl_print_format("%r%[%QUnknown rule item action '%]", main->program.warning.to, f_string_eol_s, main->program.warning.context, main->program.warning.prefix, main->program.warning.context);
+ fl_print_format(f_string_format_Q_single_s.string, main->program.warning.to, main->program.warning.notable, cache->action.name_action, main->program.warning.notable);
+ fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.warning.to, main->program.warning.context, main->program.warning.context, f_string_eol_s);
- controller_print_rule_error_cache(&global->main->program.warning, cache->action, F_true);
+ controller_print_rule_error_cache(&main->program.warning, cache->action, F_true);
- controller_unlock_print_flush(global->main->program.warning.to, global->thread);
+ controller_unlock_print_flush(main->program.warning.to, &main->thread);
}
continue;
if (multiple) {
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);
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_lock_print(main->program.error.to, &main->thread);
- fl_print_format("%r%[%QFSS Extended List is not allowed for the rule item action '%]", 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, 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);
+ fl_print_format("%r%[%QFSS Extended List is not allowed for the rule item action '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context);
+ fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, cache->action.name_action, main->program.error.notable);
+ fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
status = F_status_set_error(F_support_not);
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_print_error_status(&global->main->program.error, macro_controller_f(f_memory_array_increase_by), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_memory_array_increase_by), F_status_set_fine(status));
break;
}
- status = controller_rule_action_read(global, is_normal, type, method, cache, item, &item->actions, &range);
+ status = controller_rule_action_read(main, is_normal, type, method, cache, item, &item->actions, &range);
if (F_status_is_error(status)) break;
} // for
*
* This will perform additional FSS read functions as appropriate.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param is_normal
* 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.
* @see f_string_dynamic_partial_append_nulless()
*/
#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);
+ extern f_status_t controller_rule_item_read(controller_t * const main, const bool is_normal, controller_cache_t * const cache, controller_rule_item_t * const item);
#endif // _di_controller_rule_item_read_
#ifdef __cplusplus
#endif
#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) {
+ f_status_t controller_rule_parameters_read(controller_t * const main, 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 (!main || !object || !content || !action || !state) return F_status_set_error(F_parameter);
f_status_t status = F_okay;
}
if (F_status_is_error(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));
+ controller_print_error_status(&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_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(&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_print_error_status(&global->main->program.error, macro_controller_f(f_memory_array_increase_by), F_status_set_fine(status));
+ controller_print_error_status(&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_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(&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_print_error_status(&global->main->program.error, macro_controller_f(fl_iki_read), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(fl_iki_read), F_status_set_fine(status));
action->parameters.array[action->parameters.used].used = 0;
*
* The object and content ranges are merged together (in that order) as the action parameters.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param buffer
* The buffer containing the content.
* @param object
* @see fl_iki_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);
+ extern f_status_t controller_rule_parameters_read(controller_t * const main, 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
#endif
#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) {
+ f_status_t controller_rule_read(controller_t * const main, 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);
+ if (!main || !cache || !entry || !rule) return F_status_set_error(F_parameter);
f_status_t status = F_okay;
status = f_string_dynamic_append_nulless(alias, &rule->alias);
if (F_status_is_error(status)) {
- controller_print_error_status(&global->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));
}
else {
- status = controller_file_load(global, cache, F_true, controller_rules_s, rule->alias, controller_rule_s);
+ status = controller_file_load(main, 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);
+ controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, main);
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_print_error_status(&global->main->program.error, macro_controller_f(fll_fss_basic_list_read), F_status_set_fine(status));
+ controller_print_error_status(&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_print_error_status(&global->main->program.error, macro_controller_f(f_fss_apply_delimit), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_fss_apply_delimit), F_status_set_fine(status));
}
}
}
if (F_status_is_error_not(status) && cache->object_items.used) {
if (rule->items.size < cache->object_items.size) {
- status = f_memory_arrays_resize(cache->object_items.size, sizeof(controller_rule_item_t), (void **) &&rule->items.array, &rule->items.used, &rule->items.size, &controller_rule_items_delete_callback);
+ status = f_memory_arrays_resize(cache->object_items.size, sizeof(controller_rule_item_t), (void **) &rule->items.array, &rule->items.used, &rule->items.size, &controller_rule_items_delete_callback);
}
if (F_status_is_error(status)) {
- controller_print_error_status(&global->main->program.error, macro_controller_f(f_memory_arrays_resize), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_memory_arrays_resize), F_status_set_fine(status));
}
else {
f_number_unsigned_t i = 0;
for_item = F_true;
- f_fss_count_lines(cache->buffer_file, cache->object_items.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_file, cache->object_items.array[i].start, &cache->action.line_item, &main->setting.state);
if (F_status_is_error(status)) {
- controller_print_error_status(&global->main->program.error, macro_controller_f(f_fss_count_lines), F_status_set_fine(status));
+ controller_print_error_status(&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_print_error_status(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
break;
}
rule->items.array[rule->items.used].type = controller_rule_item_type_utility_e;
}
else {
- if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global->main->program.warning.to, global->thread);
+ if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(main->program.warning.to, &main->thread);
- fl_print_format("%r%[%QUnknown rule item '%]", global->main->program.warning.to, f_string_eol_s, global->main->program.warning.context, global->main->program.warning.prefix, global->main->program.warning.context);
- 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);
+ fl_print_format("%r%[%QUnknown rule item '%]", main->program.warning.to, f_string_eol_s, main->program.warning.context, main->program.warning.prefix, main->program.warning.context);
+ fl_print_format(f_string_format_Q_single_s.string, main->program.warning.to, main->program.warning.notable, cache->action.name_item, main->program.warning.notable);
+ fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.warning.to, main->program.warning.context, main->program.warning.context, f_string_eol_s);
- controller_print_rule_error_cache(&global->main->program.warning, cache->action, F_true);
+ controller_print_rule_error_cache(&main->program.warning, cache->action, F_true);
- controller_unlock_print_flush(global->main->program.warning.to, global->thread);
+ controller_unlock_print_flush(main->program.warning.to, &main->thread);
}
continue;
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_print_error_status(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
+ controller_print_error_status(&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_rule_item_read(global, is_normal, cache, &rule->items.array[rule->items.used]);
+ status = controller_rule_item_read(main, 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_rule_setting_read(global, is_normal, *global->setting, cache, rule);
+ status = controller_rule_setting_read(main, is_normal, 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_print_rule_item_error(global->error, cache->action, for_item, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, for_item, F_status_set_fine(status));
rule->status[0] = controller_error_simplify(F_status_set_fine(status));
/**
* Read the rule file, extracting all valid items.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param is_normal
* 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.
* @see fll_fss_basic_list_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);
+ extern f_status_t controller_rule_read(controller_t * const main, 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_
#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) {
+ f_status_t controller_rule_setting_read(controller_t * const main, 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);
+ if (!main || !cache || !rule) return F_status_set_error(F_parameter);
f_status_t status = F_okay;
f_status_t status_return = F_okay;
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);
+ controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, main);
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_print_rule_error(global->error, cache->action, F_status_set_fine(status), "fll_fss_extended_read", F_true, F_false);
+ controller_print_rule_error(&main->program.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_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(&main->program.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;
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
continue;
}
type = controller_rule_setting_type_user_e;
}
else {
- if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) {
+ if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_lock_print(global->main->program.warning.to, global->thread);
+ controller_lock_print(main->program.warning.to, &main->thread);
- fl_print_format("%r%[%QUnknown rule setting '%]", global->main->program.warning.to, f_string_eol_s, global->main->program.warning.context, global->main->program.warning.prefix, global->main->program.warning.context);
- 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);
+ fl_print_format("%r%[%QUnknown rule setting '%]", main->program.warning.to, f_string_eol_s, main->program.warning.context, main->program.warning.prefix, main->program.warning.context);
+ fl_print_format(f_string_format_Q_single_s.string, main->program.warning.to, main->program.warning.notable, cache->action.name_item, main->program.warning.notable);
+ fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.warning.to, main->program.warning.context, main->program.warning.context, f_string_eol_s);
- controller_print_rule_error_cache(&global->main->program.warning, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.warning, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.warning.to, global->thread);
+ controller_unlock_print_flush(main->program.warning.to, &main->thread);
}
continue;
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, range2, &cache->action.name_action);
if (F_status_is_error(status)) {
- controller_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(&main->program.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;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
}
else {
if (empty_disallow) {
- if (global->main->program.warning.verbosity == f_console_verbosity_debug_e) {
+ if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_lock_print(global->main->program.warning.to, global->thread);
+ controller_lock_print(main->program.warning.to, &main->thread);
- 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);
+ fl_print_format("%r%[%QEmpty rule setting.%]%r", main->program.warning.to, f_string_eol_s, main->program.warning.context, main->program.warning.prefix, main->program.warning.context, f_string_eol_s);
- controller_print_rule_error_cache(&global->main->program.warning, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.warning, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.warning.to, global->thread);
+ controller_unlock_print_flush(main->program.warning.to, &main->thread);
}
continue;
if (type == controller_rule_setting_type_affinity_e) {
if (!cache->content_actions.array[i].used) {
- controller_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(&main->program.error, "requires one or more Content", i, line_item, &main->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_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
+ controller_print_rule_error(&main->program.error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
break;
}
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_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(&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, &main->thread, cache);
}
else if (status == F_number_overflow || status == F_number_positive) {
- 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);
+ controller_print_rule_setting_read_error_with_range(&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, &main->thread, cache);
}
else {
- 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);
+ controller_print_rule_setting_read_error_with_range(&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, &main->thread, cache);
}
status = F_status_set_error(F_valid_not);
}
}
else {
- controller_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(&main->program.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_print_rule_setting_read_values(global, controller_affinity_s, i, cache);
+ controller_print_rule_setting_read_values(main, 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_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(&main->program.error, "requires exactly two Content", i, line_item, &main->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_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
+ controller_print_rule_error(&main->program.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;
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.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_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(&main->program.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;
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.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_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(&main->program.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;
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
continue;
}
- 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]);
+ controller_print_rule_setting_read_mapping(main, 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_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(&main->program.error, "requires two or more Content", i, line_item, &main->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_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(&main->program.error, " has an unknown option", cache->content_actions.array[i].array[0], "", i, line_item, &main->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
rule->cgroup.path.used = 0;
- status = f_string_dynamic_append(global->program->path_cgroup, &rule->cgroup.path);
+ status = f_string_dynamic_append(main->process.path_cgroup, &rule->cgroup.path);
if (F_status_is_error(status)) {
- controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_false);
+ controller_print_rule_error(&main->program.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_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
+ controller_print_rule_error(&main->program.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_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(&main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
break;
}
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
continue;
}
rule->has |= controller_rule_has_cgroup_d;
- controller_print_rule_setting_read_values(global, controller_cgroup_s, i, cache);
+ controller_print_rule_setting_read_values(main, controller_cgroup_s, i, cache);
continue;
}
if (type == controller_rule_setting_type_limit_e) {
if (cache->content_actions.array[i].used != 3) {
- controller_print_rule_setting_read_error(&global->main->program.error, "requires three Content", i, line_item, global->thread, cache);
+ controller_print_rule_setting_read_error(&main->program.error, "requires three Content", i, line_item, &main->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
type = controller_resource_limit_type_stack_e;
}
else {
- if (global->main->program.error.verbosity == f_console_verbosity_debug_e) {
+ if (main->program.error.verbosity == f_console_verbosity_debug_e) {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->thread);
- fl_print_format("%r%[%QUnknown resource limit 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_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);
+ fl_print_format("%r%[%QUnknown resource limit type '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context);
+ fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, cache->action.name_action, main->program.error.notable);
+ fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s);
- controller_print_rule_error_cache(global->error, cache->action, F_true);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_true);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
if (F_status_is_error_not(status_return)) {
for (j = 0; j < rule->limits.used; ++j) {
if (type == rule->limits.array[j].type) {
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->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);
+ fl_print_format("%r%[%QThe resource limit type is already specified%]%r", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context, f_string_eol_s);
- controller_print_rule_error_cache(global->error, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
status = F_status_set_error(F_valid_not);
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_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
+ controller_print_rule_error(&main->program.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;
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
continue;
}
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_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(&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, &main->thread, cache);
}
else if (status == F_number_overflow) {
- 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);
+ controller_print_rule_setting_read_error_with_range(&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, &main->thread, cache);
}
else {
- 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);
+ controller_print_rule_setting_read_error_with_range(&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, &main->thread, cache);
}
status = F_status_set_error(F_valid_not);
}
}
else {
- controller_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(&main->program.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_print_rule_setting_read_values(global, controller_limit_s, i, cache);
+ controller_print_rule_setting_read_values(main, controller_limit_s, i, cache);
continue;
}
}
if (setting_value->used || !cache->content_actions.array[i].used) {
- controller_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(&main->program.error, "requires one or more Content", i, line_item, &main->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
continue;
}
status = controller_validate_has_graph(*setting_value);
if (status == F_false || F_status_set_fine(status) == F_complete_not_utf) {
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
}
if (status == F_false) {
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
- controller_lock_print(global->main->program.error.to, global->thread);
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_lock_print(main->program.error.to, &main->thread);
- fl_print_format("%r%[%QRule setting has an invalid name '%]", 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, *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);
+ fl_print_format("%r%[%QRule setting has an invalid name '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context);
+ fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, *setting_value, main->program.error.notable);
+ fl_print_format("%[', there must be at least 1 graph character.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s);
- controller_print_rule_error_cache(global->error, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
if (F_status_is_error_not(status_return)) {
else {
// This function should only return F_complete_not_utf on error.
- controller_print_rule_error(global->error, cache->action, F_complete_not_utf, "controller_validate_has_graph", F_true, F_false);
+ controller_print_rule_error(&main->program.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_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
}
setting_value->used = 0;
continue;
}
- 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);
+ controller_print_rule_setting_read_value(main, 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_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(&main->program.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;
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
continue;
}
- controller_print_rule_setting_read_value(global, controller_path_s, f_string_empty_s, *setting_value, 0);
+ controller_print_rule_setting_read_value(main, 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_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(&main->program.error, "requires either one or two Content", i, line_item, &main->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_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(&main->program.error, " has an unknown scheduler", cache->content_actions.array[i].array[0], "", i, line_item, &main->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
status = F_status_set_fine(status);
if ((zero_only && number) || (!zero_only && (number < 1 || number > 99)) || status == F_data_not || status == F_number || status == F_number_overflow || status == F_number_negative || status == F_number_positive) {
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->thread);
- fl_print_format("%r%[%QRule setting has an invalid number '%]", 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_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("%r%[%QRule setting has an invalid number '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context);
+ fl_print_format(f_string_format_Q_range_single_s.string, main->program.error.to, main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[1], main->program.error.notable);
if (zero_only) {
- fl_print_format("%[', only%] ", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context);
- fl_print_format("%[0%]%[ is", global->main->program.error.to, global->main->program.error.notable, global->main->program.error.notable, global->main->program.error.context);
+ fl_print_format("%[', only%] ", main->program.error.to, main->program.error.context, main->program.error.context);
+ fl_print_format("%[0%]%[ is", main->program.error.to, main->program.error.notable, main->program.error.notable, main->program.error.context);
}
else {
- fl_print_format("%[', only the whole numbers inclusively between%] ", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context);
- fl_print_format("%[1%] %[and%] ", global->main->program.error.to, global->main->program.error.notable, global->main->program.error.notable, global->main->program.error.context, global->main->program.error.context);
- fl_print_format("%[99%] %[are", global->main->program.error.to, global->main->program.error.notable, global->main->program.error.notable, global->main->program.error.context);
+ fl_print_format("%[', only the whole numbers inclusively between%] ", main->program.error.to, main->program.error.context, main->program.error.context);
+ fl_print_format("%[1%] %[and%] ", main->program.error.to, main->program.error.notable, main->program.error.notable, main->program.error.context, main->program.error.context);
+ fl_print_format("%[99%] %[are", main->program.error.to, main->program.error.notable, main->program.error.notable, main->program.error.context);
}
- fl_print_format(" allowed for the designated scheduler.%]%r", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context, f_string_eol_s);
+ fl_print_format(" allowed for the designated scheduler.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s);
- controller_print_rule_error_cache(global->error, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
if (F_status_is_error_not(status_return)) {
}
}
else {
- controller_print_rule_error(global->error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
+ controller_print_rule_error(&main->program.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_print_rule_setting_read_values(global, controller_scheduler_s, i, cache);
+ controller_print_rule_setting_read_values(main, controller_scheduler_s, i, cache);
continue;
}
if (type == controller_rule_setting_type_timeout_e) {
if (cache->content_actions.array[i].used != 2) {
- controller_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(&main->program.error, "requires exactly two Content", i, line_item, &main->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
timeout_code = controller_rule_timeout_code_stop_d;
}
else {
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->thread);
- fl_print_format("%r%[%QRule setting's first value has '%]", 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_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);
+ fl_print_format("%r%[%QRule setting's first value has '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context);
+ fl_print_format(f_string_format_Q_range_single_s.string, main->program.error.to, main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[0], main->program.error.notable);
+ fl_print_format("%[' but only supports %r, %r, and %r.%]%r", main->program.error.to, main->program.error.context, controller_kill_s, controller_start_s, controller_stop_s, main->program.error.context, f_string_eol_s);
- controller_print_rule_error_cache(global->error, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
if (F_status_is_error_not(status_return)) {
status = F_status_set_fine(status);
if (status == F_number_overflow) {
- 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);
+ controller_print_rule_setting_read_error_with_range(&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, &main->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_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(&main->program.error, " has an invalid number", cache->content_actions.array[i].array[1], ", only positive whole numbers are allowed", i, line_item, &main->thread, cache);
}
else {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_error(global->error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
+ controller_print_rule_error(&main->program.error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
}
if (F_status_is_error_not(status_return)) {
rule->timeout_stop = number;
}
- 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))) {
+ if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
f_string_static_t name_sub = controller_stop_s;
if (timeout_code == controller_rule_timeout_code_kill_d) {
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_print_error_status(&global->main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
+ controller_print_error_status(&main->program.error, macro_controller_f(f_rip_dynamic_partial_nulless), F_status_set_fine(status));
break;
}
- controller_print_rule_setting_read_value(global, controller_timeout_s, name_sub, cache->action.generic, 0);
+ controller_print_rule_setting_read_value(main, 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_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(&main->program.error, "requires exactly one Content", i, line_item, &main->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->thread);
- controller_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(&main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
- controller_print_rule_error_cache(global->error, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->thread);
- controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_capability_from_text", F_true, F_false);
+ controller_print_rule_error(&main->program.error, cache->action, F_status_set_fine(status), "f_capability_from_text", F_true, F_false);
- controller_print_rule_error_cache(global->error, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
status_return = status;
break;
}
- controller_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(&main->program.error, "failed to process the capabilities", i, line_item, &main->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
continue;
}
- controller_print_rule_setting_read_value(global, controller_capability_s, f_string_empty_s, cache->action.generic, 0);
+ controller_print_rule_setting_read_value(main, 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 = F_status_set_fine(status);
if (number < -20 || number > 19 || status == F_data_not || status == F_number || status == F_number_overflow || status == F_number_underflow || status == F_number_decimal) {
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->thread);
- fl_print_format("%r%[%QRule setting has an invalid number '%]", 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_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("%[', only the whole numbers inclusively between%] ", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context);
- fl_print_format("%[-20%]", global->main->program.error.to, global->main->program.error.notable, global->main->program.error.notable);
- fl_print_format(" %[and%] ", global->main->program.error.to, global->main->program.error.context, global->main->program.error.context);
- 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);
+ fl_print_format("%r%[%QRule setting has an invalid number '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context);
+ fl_print_format(f_string_format_Q_range_single_s.string, main->program.error.to, main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[0], main->program.error.notable);
+ fl_print_format("%[', only the whole numbers inclusively between%] ", main->program.error.to, main->program.error.context, main->program.error.context);
+ fl_print_format("%[-20%]", main->program.error.to, main->program.error.notable, main->program.error.notable);
+ fl_print_format(" %[and%] ", main->program.error.to, main->program.error.context, main->program.error.context);
+ fl_print_format("%[19%]", main->program.error.to, main->program.error.notable, main->program.error.notable);
+ fl_print_format(" %[are allowed.%]%r", main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s);
- controller_print_rule_error_cache(global->error, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
if (F_status_is_error_not(status_return)) {
}
}
else {
- controller_print_rule_error(global->error, cache->action, status, "fl_conversion_dynamic_partial_to_signed_detect", F_true, F_false);
+ controller_print_rule_error(&main->program.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->nice = number;
rule->has |= controller_rule_has_nice_d;
- if ((global->main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) || global->main->program.error.verbosity == f_console_verbosity_verbose_e) {
+ if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) || main->program.error.verbosity == f_console_verbosity_verbose_e) {
cache->action.generic.used = 0;
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], &cache->action.generic);
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->thread);
- controller_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(&main->program.error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
- controller_print_rule_error_cache(global->error, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
}
if (F_status_is_error_not(status)) {
- controller_print_rule_setting_read_value(global, controller_nice_s, f_string_empty_s, cache->action.generic, 0);
+ controller_print_rule_setting_read_value(main, controller_nice_s, f_string_empty_s, cache->action.generic, 0);
}
}
}
status = F_status_set_fine(status);
if (status == F_exist_not) {
- 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);
+ controller_print_rule_setting_read_error_with_range(&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, &main->thread, cache);
}
else if (status == F_number_too_large) {
- 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);
+ controller_print_rule_setting_read_error_with_range(&main->program.error, " has an invalid user", cache->content_actions.array[i].array[0], ", because the given ID is too large", i, line_item, &main->thread, cache);
}
else if (status == F_number) {
- 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);
+ controller_print_rule_setting_read_error_with_range(&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, &main->thread, cache);
}
else {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_error(global->error, cache->action, status, "controller_convert_user_id", F_true, F_false);
+ controller_print_rule_error(&main->program.error, cache->action, status, "controller_convert_user_id", F_true, F_false);
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
}
if (F_status_is_error_not(status_return)) {
rule->user = number;
rule->has |= controller_rule_has_user_d;
- 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))) {
+ if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
cache->action.generic.used = 0;
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], &cache->action.generic);
- controller_print_rule_setting_read_value(global, controller_user_s, f_string_empty_s, cache->action.generic, 0);
+ controller_print_rule_setting_read_value(main, 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_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(&main->program.error, "requires one or more Content", i, line_item, &main->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_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
+ controller_print_rule_error(&main->program.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;
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
continue;
}
status = F_status_set_fine(status);
if (status == F_exist_not) {
- 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);
+ controller_print_rule_setting_read_error_with_range(&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, &main->thread, cache);
}
else if (status == F_number_too_large) {
- 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);
+ controller_print_rule_setting_read_error_with_range(&main->program.error, " has an invalid group", cache->content_actions.array[i].array[j], ", because the given ID is too large", i, line_item, &main->thread, cache);
}
else if (status == F_number) {
- 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);
+ controller_print_rule_setting_read_error_with_range(&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, &main->thread, cache);
}
else {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_error(global->error, cache->action, status, "f_account_group_id_by_name", F_true, F_false);
+ controller_print_rule_error(&main->program.error, cache->action, status, "f_account_group_id_by_name", F_true, F_false);
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
}
if (F_status_is_error_not(status_return)) {
}
} // for
- controller_print_rule_setting_read_values(global, controller_group_s, i, cache);
+ controller_print_rule_setting_read_values(main, 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_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false);
+ controller_print_rule_error(&main->program.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;
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.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_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(&main->program.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;
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
continue;
}
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
if (status == F_false) {
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
- controller_lock_print(global->main->program.error.to, global->thread);
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_lock_print(main->program.error.to, &main->thread);
- fl_print_format("%r%[%QRule setting has an invalid environment variable name '%]", 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, 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);
+ fl_print_format("%r%[%QRule setting has an invalid environment variable name '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context);
+ fl_print_format(f_string_format_Q_single_s.string, main->program.error.to, main->program.error.notable, setting_values->array[setting_values->used], main->program.error.notable);
+ fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.error.to, main->program.error.context, main->program.error.context, f_string_eol_s);
- controller_print_rule_error_cache(global->error, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
if (F_status_is_error_not(status_return)) {
else {
// This function should only return F_complete_not_utf on error.
- controller_print_rule_error(global->error, cache->action, F_complete_not_utf, "controller_validate_environment_name", F_true, F_false);
+ controller_print_rule_error(&main->program.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_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.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_print_rule_setting_read_values(global, controller_environment_s, i, cache);
+ controller_print_rule_setting_read_values(main, 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))) {
- controller_lock_print(global->main->program.output.to, global->thread);
+ if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
+ controller_lock_print(main->program.output.to, &main->thread);
- fl_print_format("%rProcessing rule item action '%[%r%]' setting value to an empty set.%r", global->main->program.output.to, f_string_eol_s, global->main->program.context.set.title, controller_environment_s, global->main->program.context.set.title, f_string_eol_s);
+ fl_print_format("%rProcessing rule item action '%[%r%]' setting value to an empty set.%r", main->program.output.to, f_string_eol_s, main->program.context.set.title, controller_environment_s, main->program.context.set.title, f_string_eol_s);
- controller_unlock_print_flush(global->main->program.output.to, global->thread);
+ controller_unlock_print_flush(main->program.output.to, &main->thread);
}
}
// The "on" Rule Setting.
if (cache->content_actions.array[i].used != 4) {
- controller_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(&main->program.error, "requires exactly four Content", i, line_item, &main->thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
action = controller_rule_action_type_thaw_e;
}
else {
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- f_thread_mutex_lock(&global->thread->lock.print);
+ f_thread_mutex_lock(&main->thread.lock.print);
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->thread);
- fl_print_format("%r%[%QRule setting's second value has '%]", 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_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, %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);
+ fl_print_format("%r%[%QRule setting's second value has '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context);
+ fl_print_format(f_string_format_Q_range_single_s.string, main->program.error.to, main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[1], main->program.error.notable);
+ fl_print_format("%[' but only supports %r, %r, %r, %r, %r", main->program.error.to, main->program.error.context, controller_freeze_s, controller_kill_s, controller_pause_s, controller_reload_s, controller_restart_s);
+ fl_print_format("%r, %r, %r, and %r.%]%r", main->program.error.to, controller_resume_s, controller_start_s, controller_stop_s, controller_thaw_s, main->program.error.context, f_string_eol_s);
- controller_print_rule_error_cache(global->error, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
if (F_status_is_error_not(status_return)) {
}
if (F_status_is_error(status)) {
- controller_print_rule_error(global->error, cache->action, F_status_set_fine(status), macro_controller_f(f_memory_array_increase), F_true, F_false);
+ controller_print_rule_error(&main->program.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) {
setting_values = &rule->ons.array[j].wish;
}
else {
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_lock_print(global->main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->thread);
- fl_print_format("%r%[%QRule setting's second value has '%]", 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_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);
+ fl_print_format("%r%[%QRule setting's second value has '%]", main->program.error.to, f_string_eol_s, main->program.error.context, main->program.error.prefix, main->program.error.context);
+ fl_print_format(f_string_format_Q_range_single_s.string, main->program.error.to, main->program.error.notable, cache->buffer_item, cache->content_actions.array[i].array[1], main->program.error.notable);
+ fl_print_format("%[' but only supports %r, %r, and %r.%]%r", main->program.error.to, main->program.error.context, controller_need_s, controller_want_s, controller_wish_s, main->program.error.context, f_string_eol_s);
- controller_print_rule_error_cache(global->error, cache->action, F_false);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_false);
- controller_unlock_print_flush(global->main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
if (F_status_is_error_not(status_return)) {
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_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(&main->program.error, cache->action, F_status_set_fine(status), "f_memory_array_increase_by", F_true, F_false);
}
}
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.error, cache->action, F_false, F_status_set_fine(status));
continue;
}
- status = controller_rule_id_construct(global, cache->buffer_item, cache->content_actions.array[i].array[2], cache->content_actions.array[i].array[3], &setting_values->array[setting_values->used]);
+ status = controller_rule_id_construct(main, cache->buffer_item, cache->content_actions.array[i].array[2], cache->content_actions.array[i].array[3], &setting_values->array[setting_values->used]);
if (F_status_is_error(status)) {
setting_values->array[setting_values->used].used = 0;
// Get the current line number within the settings item.
cache->action.line_item = line_item;
- f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &global->main->setting.state);
+ f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item, &main->setting.state);
cache->action.line_action = ++cache->action.line_item;
- controller_print_rule_item_error(global->error, cache->action, F_false, F_status_set_fine(status));
+ controller_print_rule_item_error(&main->program.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_print_rule_error(global->error, cache->action, F_status_set_fine(status), "f_file_name_base", F_true, F_false);
+ controller_print_rule_error(&main->program.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;
++rule->ons.used;
}
- 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))) {
- controller_lock_print(global->main->program.output.to, global->thread);
+ if (main->program.error.verbosity == f_console_verbosity_debug_e || (main->program.error.verbosity == f_console_verbosity_verbose_e && (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e))) {
+ controller_lock_print(main->program.output.to, &main->thread);
- fl_print_format("%rProcessing rule item action '%[%r%]', adding ", global->main->program.output.to, f_string_eol_s, global->main->program.context.set.title, controller_on_s, global->main->program.context.set.title);
- fl_print_format("'%[%/Q%]' of ", global->main->program.output.to, global->main->program.context.set.notable, cache->buffer_item, cache->content_actions.array[i].array[1], global->main->program.context.set.notable);
- fl_print_format("'%[%/Q%]/", global->main->program.output.to, global->main->program.context.set.important, cache->buffer_item, cache->content_actions.array[i].array[2], global->main->program.context.set.important);
- fl_print_format("%[%/Q%]'.%r", global->main->program.output.to, global->main->program.context.set.important, cache->buffer_item, cache->content_actions.array[i].array[3], global->main->program.context.set.important, f_string_eol_s);
+ fl_print_format("%rProcessing rule item action '%[%r%]', adding ", main->program.output.to, f_string_eol_s, main->program.context.set.title, controller_on_s, main->program.context.set.title);
+ fl_print_format("'%[%/Q%]' of ", main->program.output.to, main->program.context.set.notable, cache->buffer_item, cache->content_actions.array[i].array[1], main->program.context.set.notable);
+ fl_print_format("'%[%/Q%]/", main->program.output.to, main->program.context.set.important, cache->buffer_item, cache->content_actions.array[i].array[2], main->program.context.set.important);
+ fl_print_format("%[%/Q%]'.%r", main->program.output.to, main->program.context.set.important, cache->buffer_item, cache->content_actions.array[i].array[3], main->program.context.set.important, f_string_eol_s);
- controller_unlock_print_flush(global->main->program.output.to, global->thread);
+ controller_unlock_print_flush(main->program.output.to, &main->thread);
}
} // for
* Errors from this are not considered fatal, but the first error code encountered is returned.
* Memory failure errors are always immediately returned.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param is_normal
* 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.
* @see controller_path_canonical_relative()
*/
#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);
+ extern f_status_t controller_rule_setting_read(controller_t * const main, const bool is_normal, controller_cache_t * const cache, controller_rule_t * const rule);
#endif // _di_controller_rule_setting_read_
#ifdef __cplusplus
#endif
#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) {
+ void controller_rule_validate(controller_t * const main, 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_t * const main = global->main;
+ if (!main || !cache) return;
switch (action) {
case controller_rule_action_type_freeze_e:
default:
if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
- controller_lock_print(main->program.error.to, global->thread);
+ controller_lock_print(main->program.error.to, &main->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_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_print_rule_error_cache(global->error, cache->action, F_true);
+ controller_print_rule_error_cache(&main->program.error, cache->action, F_true);
- controller_unlock_print_flush(main->program.error.to, global->thread);
+ controller_unlock_print_flush(main->program.error.to, &main->thread);
}
return;
} // for
if (missing) {
- controller_lock_print(main->program.output.to, global->thread);
+ controller_lock_print(main->program.output.to, &main->thread);
if (rule.items.used) {
fl_print_format("%rRule '", main->program.output.to, f_string_eol_s);
fl_print_format("%[%r%]'.%r", main->program.output.to, main->program.context.set.important, options & controller_instance_option_require_e ? controller_required_s : controller_optional_s, main->program.context.set.important, f_string_eol_s);
}
- controller_unlock_print_flush(main->program.output.to, global->thread);
+ controller_unlock_print_flush(main->program.output.to, &main->thread);
}
}
- controller_lock_print(main->program.output.to, global->thread);
+ controller_lock_print(main->program.output.to, &main->thread);
fl_print_format("%rRule %[%Q%] {%r", main->program.output.to, f_string_eol_s, main->program.context.set.title, rule.alias, main->program.context.set.title, f_string_eol_s);
fl_print_format("}%r", main->program.output.to, f_string_eol_s);
- controller_unlock_print_flush(main->program.output.to, global->thread);
+ controller_unlock_print_flush(main->program.output.to, &main->thread);
}
#endif // _di_controller_rule_validate_
*
* This automatically sets the rule's status to F_complete.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param rule
* The rule to process.
* @param action
* A structure for containing and caching relevant data.
*/
#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);
+ extern void controller_rule_validate(controller_t * const main, 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
#endif
#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) {
+ f_status_t controller_rule_wait_all(controller_t * const main, const bool is_normal, const bool required) {
- if (!global) return F_status_set_error(F_parameter);
+ if (!main) return F_status_set_error(F_parameter);
- f_status_t status_lock = controller_lock_read(is_normal, global->thread, &global->thread->lock.instance);
+ f_status_t status_lock = controller_lock_read(is_normal, &main->thread, &main->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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
return status_lock;
}
- if (!global->thread->instances.used) {
- f_thread_unlock(&global->thread->lock.instance);
+ if (!main->thread.instances.used) {
+ f_thread_unlock(&main->thread.lock.instance);
return F_data_not;
}
f_number_unsigned_t j = 0;
// 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;
+ const f_number_unsigned_t instance_total = main->thread.instances.used;
controller_instance_t *instance_list[instance_total];
for (; i < instance_total; ++i) {
- instance_list[i] = global->thread->instances.array[i];
+ instance_list[i] = main->thread.instances.array[i];
} // for
- f_thread_unlock(&global->thread->lock.instance);
+ f_thread_unlock(&main->thread.lock.instance);
for (i = 0; i < instance_total; ++i) {
- if (!controller_thread_is_enabled(is_normal, global->thread)) break;
+ if (!controller_thread_is_enabled(is_normal, &main->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_lock_read(is_normal, global->thread, &global->thread->lock.instance);
+ // Re-establish instance read lock to wait for or protect from the cleanup thread while checking the read instance.
+ status_lock = controller_lock_read(is_normal, &main->thread, &main->thread.lock.instance);
if (F_status_is_error(status_lock)) break;
if (!instance_list[i]) {
- f_thread_unlock(&global->thread->lock.instance);
+ f_thread_unlock(&main->thread.lock.instance);
continue;
}
- status_lock = controller_lock_read(is_normal, global->thread, &instance_list[i]->active);
+ status_lock = controller_lock_read(is_normal, &main->thread, &instance_list[i]->active);
if (F_status_is_error(status_lock)) {
- f_thread_unlock(&global->thread->lock.instance);
+ f_thread_unlock(&main->thread.lock.instance);
break;
}
// Once the active lock is obtained, then the main instance read lock can be safely released.
- f_thread_unlock(&global->thread->lock.instance);
+ f_thread_unlock(&main->thread.lock.instance);
- status_lock = controller_lock_read(is_normal, global->thread, &instance_list[i]->lock);
+ status_lock = controller_lock_read(is_normal, &main->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_lock_write(is_normal, global->thread, &instance_list[i]->lock);
+ status_lock = controller_lock_write(is_normal, &main->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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
f_thread_unlock(&instance_list[i]->active);
f_thread_mutex_unlock(&instance_list[i]->wait_lock);
}
- status_lock = controller_lock_read(is_normal, global->thread, &instance_list[i]->active);
+ status_lock = controller_lock_read(is_normal, &main->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_lock_read(is_normal, global->thread, &instance_list[i]->lock);
+ status_lock = controller_lock_read(is_normal, &main->thread, &instance_list[i]->lock);
if (F_status_is_error(status_lock)) break;
}
break;
}
- status_lock = controller_lock_read(is_normal, global->thread, &instance_list[i]->lock);
+ status_lock = controller_lock_read(is_normal, &main->thread, &instance_list[i]->lock);
if (F_status_is_error(status_lock)) {
f_thread_unlock(&instance_list[i]->active);
} // for
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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
return status_lock;
}
- if (!controller_thread_is_enabled(is_normal, global->thread)) return F_status_set_error(F_interrupt);
+ if (!controller_thread_is_enabled(is_normal, &main->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;
#endif // _di_controller_rule_wait_all_
#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) {
+ f_status_t controller_rule_wait_all_instance_type(controller_t * const main, const uint8_t type, const bool required) {
- if (!global) return F_status_set_error(F_parameter);
+ if (!main) return F_status_set_error(F_parameter);
- return controller_rule_wait_all(global, type != controller_instance_type_exit_e, required);
+ return controller_rule_wait_all(main, type != controller_instance_type_exit_e, required);
}
#endif // _di_controller_rule_wait_all_instance_type_
/**
* Wait until all currently running Rule processes are complete.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param is_normal
* 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.
* F_require (with error bit set) if a required process is in failed status when required is TRUE.
*/
#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);
+ extern f_status_t controller_rule_wait_all(controller_t * const main, 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.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param type
* The process type to use when checking if thread is enabled.
* @param required
* @see controller_rule_wait_all()
*/
#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);
+ extern f_status_t controller_rule_wait_all_instance_type(controller_t * const main, const uint8_t type, const bool required);
#endif // _di_controller_rule_wait_all_instance_type_
#ifdef __cplusplus
#endif
#ifndef _di_controller_thread_cleanup_
- void * controller_thread_cleanup(void * const arguments) {
+ void * controller_thread_cleanup(void * const argument) {
- if (!arguments) return 0;
+ if (!argument) return 0;
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_global_t * const global = (controller_global_t * const) arguments;
+ controller_t * const main = (controller_t *) argument;
- if (global->thread->enabled != controller_thread_enabled_e) return 0;
+ if (main->thread.enabled != controller_thread_enabled_e) return 0;
- 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);
+ const f_time_spec_t delay = {
+ .tv_sec = (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,
+ .tv_nsec = 0,
+ };
f_status_t status = F_okay;
- while (global->thread->enabled == controller_thread_enabled_e) {
+ while (main->thread.enabled == controller_thread_enabled_e) {
f_time_sleep_spec(delay, 0);
- if (global->thread->enabled != controller_thread_enabled_e) break;
+ if (main->thread.enabled != controller_thread_enabled_e) break;
- if (f_thread_lock_write_try(&global->thread->lock.instance) == F_okay) {
+ if (f_thread_lock_write_try(&main->thread.lock.instance) == F_okay) {
controller_instance_t *instance = 0;
f_number_unsigned_t i = 0;
- for (; i < global->thread->instances.size && global->thread->enabled == controller_thread_enabled_e; ++i) {
+ for (; i < main->thread.instances.size && main->thread.enabled == controller_thread_enabled_e; ++i) {
- if (!global->thread->instances.array[i]) continue;
+ if (!main->thread.instances.array[i]) continue;
- instance = global->thread->instances.array[i];
+ instance = main->thread.instances.array[i];
// If "active" has a read lock, then do not attempt to clean it.
if (f_thread_lock_write_try(&instance->active) != F_okay) continue;
}
// If instance is active or busy, then do not attempt to clean it.
- if (instance->state == controller_process_state_active_e || instance->state == controller_process_state_busy_e) {
+ if (instance->state == controller_instance_state_active_e || instance->state == controller_instance_state_busy_e) {
f_thread_unlock(&instance->active);
f_thread_unlock(&instance->lock);
status = f_thread_lock_write(&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);
+ controller_lock_print_error_critical(&main->program.error, F_status_set_fine(status), F_false);
f_thread_unlock(&instance->active);
continue;
}
- instance->state = controller_process_state_idle_e;
+ instance->state = controller_instance_state_idle_e;
instance->id_thread = 0;
f_thread_mutex_lock(&instance->wait_lock);
}
// De-allocate dynamic portions of the structure that are only ever needed while the instance is running.
- controller_cache_delete_simple(&instance->cache);
+ controller_cache_delete(&instance->cache);
f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &instance->stack.array, &instance->stack.used, &instance->stack.size);
// Shrink the childs array.
}
// De-allocate any rules in the space that is declared to be unused.
- if (i >= global->thread->instances.used) {
+ if (i >= main->thread.instances.used) {
controller_rule_delete(&instance->rule);
}
f_thread_unlock(&instance->active);
} // for
- f_thread_unlock(&global->thread->lock.instance);
+ f_thread_unlock(&main->thread.lock.instance);
}
} // while
/**
* Thread for periodically cleaning up data when not busy.
*
- * @param arguments
- * The thread arguments.
- * Must be of type controller_global_t.
+ * @param argument
+ * The main program data.
*
+ * Must be of type controller_t.
* Must not be NULL.
*
* @return
* 0, always.
*/
#ifndef _di_controller_thread_cleanup_
- extern void * controller_thread_cleanup(void * const arguments);
+ extern void * controller_thread_cleanup(void * const argument);
#endif // _di_controller_thread_cleanup_
#ifdef __cplusplus
#endif
#ifndef _di_controller_thread_control_
- void * controller_thread_control(void * const arguments) {
+ void * controller_thread_control(void * const argument) {
- if (!arguments) return 0;
+ if (!argument) return 0;
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_global_t * const global = (controller_global_t * const) arguments;
+ controller_t * const main = (controller_t *) argument;
- if (global->thread->enabled != controller_thread_enabled_e) return 0;
+ if (main->thread.enabled != controller_thread_enabled_e) return 0;
f_status_t status = F_okay;
+ // A forked child process should de-allocate memory on exit.
+ // It seems that this function doesn't return to the calling thread for a forked child process, even with the "return 0;" below.
if (status == F_child) {
-
- // A forked child process should de-allocate memory on exit.
- // 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_delete(global->main);
+ controller_delete(main);
}
return 0;
/**
* Thread for handling control requests and responses.
*
- * @param arguments
- * The global data.
- * Must be of type controller_global_t.
+ * @param argument
+ * The main program data.
*
+ * Must be of type controller_t.
* Must not be NULL.
*
* @return
* 0, always.
*/
#ifndef _di_controller_thread_control_
- extern void * controller_thread_control(void * const arguments);
+ extern void * controller_thread_control(void * const argument);
#endif // _di_controller_thread_control_
#ifdef __cplusplus
#endif
#ifndef _di_controller_thread_entry_
- void * controller_thread_entry(void * const arguments) {
+ void * controller_thread_entry(void * const argument) {
- if (!arguments) return 0;
+ if (!argument) return 0;
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_global_t * const global = (controller_global_t * const) arguments;
+ controller_t * const main = (controller_t *) argument;
- if (!controller_thread_is_enabled(F_true, global->thread)) return 0;
+ if (!controller_thread_is_enabled(F_true, &main->thread)) return 0;
- f_status_t * const status = &global->thread->status;
+ f_status_t * const status = &main->thread.status;
- *status = controller_entry_read(global, F_true);
+ *status = controller_entry_read(main, F_true);
if (F_status_set_fine(*status) == F_interrupt) {
- global->program->ready = controller_program_ready_abort_e;
+ main->process.ready = controller_process_ready_abort_e;
}
else if (F_status_is_error(*status)) {
- global->program->ready = controller_program_ready_fail_e;
+ main->process.ready = controller_process_ready_fail_e;
}
else if (*status != F_child) {
- *status = controller_entry_preprocess(global, F_true);
+ *status = controller_entry_preprocess(main, 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_entry_setting_validate(global, F_true);
+ if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) && (main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) {
+ controller_entry_setting_validate(main, F_true);
}
}
if (F_status_is_error_not(*status) && *status != F_child) {
- if (!(global->main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e) || (global->main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e)) {
+ if (!(main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e) || (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e)) {
- if (global->program->entry.pid == controller_entry_pid_require_e && f_file_exists(global->program->path_pid, F_true) == F_true) {
+ if (main->process.entry.pid == controller_entry_pid_require_e && f_file_exists(main->process.path_pid, F_true) == F_true) {
*status = F_status_set_error(F_available_not);
- global->program->ready = controller_program_ready_fail_e;
+ main->process.ready = controller_process_ready_fail_e;
- controller_print_error_file_pid_exists(&global->main->program.error, global->thread, global->program->path_pid);
+ controller_print_error_file_pid_exists(&main->program.error, &main->thread, main->process.path_pid);
}
else {
- *status = controller_entry_process(global, F_false, F_true);
+ *status = controller_entry_process(main, F_false, F_true);
if (F_status_is_error(*status)) {
- global->program->ready = controller_program_ready_fail_e;
+ main->process.ready = controller_process_ready_fail_e;
- if ((F_status_set_fine(*status) == F_execute || F_status_set_fine(*status) == F_require) && (program->flag & controller_setting_flag_failsafe_e)) {
- const uint8_t original_enabled = global->thread->enabled;
+ if ((F_status_set_fine(*status) == F_execute || F_status_set_fine(*status) == F_require) && (main->setting.flag & controller_process_flag_failsafe_e)) {
+ const uint8_t original_enabled = main->thread.enabled;
// Restore operating mode so that the failsafe can execute.
- *status = f_thread_mutex_lock(&global->thread->lock.alert);
+ *status = f_thread_mutex_lock(&main->thread.lock.alert);
if (F_status_is_error_not(*status)) {
- global->thread->enabled = controller_thread_enabled_e;
+ main->thread.enabled = controller_thread_enabled_e;
- f_thread_mutex_unlock(&global->thread->lock.alert);
+ f_thread_mutex_unlock(&main->thread.lock.alert);
}
- // 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_thread_signal_normal, (void *) global);
+ // Restart the signal main->thread to allow for signals while operating the failsafe Items.
+ if (!main->thread.id_signal) {
+ f_thread_create(0, &main->thread.id_signal, &controller_thread_signal_normal, (void *) main);
}
- const f_status_t status_failsafe = controller_entry_process(global, F_true, F_true);
+ const f_status_t status_failsafe = controller_entry_process(main, F_true, F_true);
if (F_status_is_error(status_failsafe)) {
*status = F_status_set_error(F_failure);
- controller_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(&main->program.error, &main->thread, main->process.entry.items.array[main->process.failsafe_item_id].name);
}
else {
// Restore operating mode to value prior to failsafe mode.
- *status = f_thread_mutex_lock(&global->thread->lock.alert);
+ *status = f_thread_mutex_lock(&main->thread.lock.alert);
if (F_status_is_error_not(*status)) {
- global->thread->enabled = original_enabled;
+ main->thread.enabled = original_enabled;
- f_thread_mutex_unlock(&global->thread->lock.alert);
+ f_thread_mutex_unlock(&main->thread.lock.alert);
}
*status = F_failure;
}
}
else if (F_status_set_fine(*status) == F_interrupt) {
- global->program->ready = controller_program_ready_abort_e;
+ main->process.ready = controller_process_ready_abort_e;
}
else if (*status != F_child) {
- global->program->ready = controller_program_ready_done_e;
+ main->process.ready = controller_process_ready_done_e;
}
}
- 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) {
+ if (F_status_is_error_not(*status) && *status != F_child && main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e && main->process.mode == controller_process_mode_helper_e) {
f_time_spec_t time;
time.tv_sec = controller_thread_exit_helper_timeout_seconds_d;
time.tv_nsec = controller_thread_exit_helper_timeout_nanoseconds_d;
nanosleep(&time, 0);
- controller_thread_instance_cancel(global, F_true, controller_thread_cancel_exit_e);
+ controller_thread_instance_cancel(main, F_true, controller_thread_cancel_exit_e);
}
}
}
+ // A forked child process should de-allocate memory on exit.
+ // It seems that this function doesn't return to the calling thread for a forked child process, even with the "return 0;" below.
if (*status == F_child) {
+ controller_delete(main);
- // A forked child process should de-allocate memory on exit.
- // 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_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;
+ // According to the manpages, pthread_exit() calls exit(0), which the value of main->program.child should be returned instead.
+ if (main->program.child) exit(main->program.child);
+ } else {
+ f_thread_condition_signal_all(&main->thread.lock.alert_condition);
}
- f_thread_condition_signal_all(&global->thread->lock.alert_condition);
-
return 0;
}
#endif // _di_controller_thread_entry_
#ifndef _di_controller_thread_exit_
- void * controller_thread_exit(void * const arguments) {
+ void * controller_thread_exit(void * const argument) {
- if (!arguments) return 0;
+ if (!argument) return 0;
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_global_t * const global = (controller_global_t * const) arguments;
+ controller_t * const main = (controller_t *) argument;
+ controller_cache_t * const cache = &main->thread.cache;
+ f_status_t * const status = &main->thread.status;
- controller_t * const main = global->main;
- controller_cache_t * const cache = &global->thread->cache;
- f_status_t * const status = &global->thread->status;
-
- *status = controller_entry_read(global, F_false);
+ *status = controller_entry_read(main, F_false);
if (F_status_set_fine(*status) == F_interrupt) {
- global->program->ready = controller_program_ready_abort_e;
+ main->process.ready = controller_process_ready_abort_e;
}
else if (F_status_is_error(*status)) {
- global->program->ready = controller_program_ready_fail_e;
+ main->process.ready = controller_process_ready_fail_e;
}
else if (*status == F_file_found_not) {
- global->program->ready = controller_program_ready_done_e;
+ main->process.ready = controller_process_ready_done_e;
}
else if (*status != F_child) {
- *status = controller_entry_preprocess(global, F_false, cache);
+ *status = controller_entry_preprocess(main, F_false, cache);
if ((main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) && (main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) {
- controller_entry_setting_validate(global, F_false, cache);
+ controller_entry_setting_validate(main, F_false, cache);
}
}
if (F_status_is_error_not(*status) && *status != F_child && *status != F_file_found_not) {
if (!(main->program.parameters.array[controller_parameter_validate_e].result & f_console_result_found_e) || (main->program.parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e)) {
- *status = controller_entry_process(global, F_false, F_false);
+ *status = controller_entry_process(main, F_false, F_false);
if (F_status_is_error(*status)) {
- global->program->ready = controller_program_ready_fail_e;
+ main->process.ready = controller_process_ready_fail_e;
- if ((F_status_set_fine(*status) == F_execute || F_status_set_fine(*status) == F_require) && (global->program->flag & controller_setting_flag_failsafe_e)) {
+ if ((F_status_set_fine(*status) == F_execute || F_status_set_fine(*status) == F_require) && (main->setting.flag & controller_process_flag_failsafe_e)) {
- const uint8_t original_enabled = global->thread->enabled;
+ const uint8_t original_enabled = main->thread.enabled;
// Restore operating mode so that the failsafe can execute.
if (F_status_set_fine(*status) == F_execute) {
- *status = f_thread_mutex_lock(&global->thread->lock.alert);
+ *status = f_thread_mutex_lock(&main->thread.lock.alert);
if (F_status_is_error_not(*status)) {
- global->thread->enabled = controller_thread_enabled_exit_e;
+ main->thread.enabled = controller_thread_enabled_exit_e;
- f_thread_mutex_unlock(&global->thread->lock.alert);
+ f_thread_mutex_unlock(&main->thread.lock.alert);
}
// 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_thread_signal_other, (void *) global);
+ if (!main->thread.id_signal) {
+ f_thread_create(0, &main->thread.id_signal, &controller_thread_signal_other, (void *) main);
}
}
- const f_status_t status_failsafe = controller_entry_process(global, F_true, F_false);
+ const f_status_t status_failsafe = controller_entry_process(main, F_true, F_false);
if (F_status_is_error(status_failsafe)) {
*status = F_status_set_error(F_failure);
- controller_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(&main->program.error, &main->thread, main->process.entry.items.array[main->process.failsafe_item_id].name);
}
else {
// Restore operating mode to value prior to failsafe mode.
- *status = f_thread_mutex_lock(&global->thread->lock.alert);
+ *status = f_thread_mutex_lock(&main->thread.lock.alert);
if (F_status_is_error_not(*status)) {
- global->thread->enabled = original_enabled;
+ main->thread.enabled = original_enabled;
- f_thread_mutex_unlock(&global->thread->lock.alert);
+ f_thread_mutex_unlock(&main->thread.lock.alert);
}
*status = F_failure;
}
}
else if (F_status_set_fine(*status) == F_interrupt) {
- global->program->ready = controller_program_ready_abort_e;
+ main->process.ready = controller_process_ready_abort_e;
}
else if (*status != F_child) {
- global->program->ready = controller_program_ready_done_e;
+ main->process.ready = controller_process_ready_done_e;
}
}
}
+ // A forked child process should de-allocate memory on exit.
+ // It seems that this function doesn't return to the calling thread for a forked child process, even with the "return 0;" below.
if (*status == F_child) {
-
- // A forked child process should de-allocate memory on exit.
- // 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_delete(main);
return 0;
}
- if (F_status_is_error_not(f_thread_mutex_lock(&global->thread->lock.alert))) {
- global->thread->enabled = controller_thread_enabled_not_e;
+ if (F_status_is_error_not(f_thread_mutex_lock(&main->thread.lock.alert))) {
+ main->thread.enabled = controller_thread_enabled_not_e;
- f_thread_mutex_unlock(&global->thread->lock.alert);
+ f_thread_mutex_unlock(&main->thread.lock.alert);
}
- f_thread_condition_signal_all(&global->thread->lock.alert_condition);
+ f_thread_condition_signal_all(&main->thread.lock.alert_condition);
return 0;
}
* This runs all synchronous rules or spawns asynchronous rules.
*
* @param arguments
- * The global data.
- * Must be of type controller_instance_t.
+ * The main program data.
*
+ * Must be of type controller_t.
* Must not be NULL.
*
* @return
* Do not confuse this with exiting a thread, this is the what process the exit files (similar to that of an entry file).
* Exit files process the "stop" action, whereas the Entry files process the "start" Action
*
- * @param arguments
- * The global data.
- * Must be of type controller_instance_t.
+ * @param argument
+ * The main program data.
*
+ * Must be of type controller_t.
* Must not be NULL.
*
* @return
* 0, always.
*/
#ifndef _di_controller_thread_exit_
- extern void * controller_thread_exit(void * const arguments);
+ extern void * controller_thread_exit(void * const argument);
#endif // _di_controller_thread_exit_
#ifdef __cplusplus
#ifndef _di_controller_thread_instance_
void controller_thread_instance(const uint8_t is_normal, controller_instance_t * const instance) {
- if (!instance) return;
- if (!controller_thread_is_enabled(is_normal, (controller_thread_t * const) instance->thread)) return;
+ if (!instance || !instance->main) return;
+ if (!controller_thread_is_enabled(is_normal, &instance->main->thread)) return;
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_delete(instance->main_data);
+ controller_delete(instance->main);
// 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);
+ if (instance->main->program.child) exit(instance->main->program.child);
}
}
#endif // _di_controller_thread_instance_
#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) {
+ void controller_thread_instance_cancel(controller_t * const main, const uint8_t is_normal, const uint8_t by) {
- if (!global) return;
+ if (!main) return;
- f_thread_mutex_lock(&global->thread->lock.cancel);
+ f_thread_mutex_lock(&main->thread.lock.cancel);
// Only cancel when enabled.
- if (!controller_thread_is_enabled(is_normal, global->thread)) {
- f_thread_mutex_unlock(&global->thread->lock.cancel);
+ if (!controller_thread_is_enabled(is_normal, &main->thread)) {
+ f_thread_mutex_unlock(&main->thread.lock.cancel);
return;
}
- controller_entry_t * const entry = is_normal ? &global->program->entry : &global->program->exit;
+ controller_entry_t * const entry = is_normal ? &main->process.entry : &main->process.exit;
controller_instance_t *instance = 0;
f_time_spec_t time = f_time_spec_t_initialize;
time.tv_sec = 0;
time.tv_nsec = interval_nanoseconds;
- if (global->program->mode == controller_program_mode_helper_e && global->main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e) {
+ if (main->process.mode == controller_process_mode_helper_e && main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e) {
int value = 0;
f_number_unsigned_t lapsed = 0;
- for (i = 0; i < global->thread->instances.used; ++i) {
+ for (i = 0; i < main->thread.instances.used; ++i) {
- if (!global->thread->instances.array[i]) continue;
+ if (!main->thread.instances.array[i]) continue;
- instance = global->thread->instances.array[i];
+ instance = main->thread.instances.array[i];
if (!instance->id_thread) continue;
}
// Use the alert lock to toggle enabled (using it as if it is a write like and a signal lock).
- status = f_thread_mutex_lock(&global->thread->lock.alert);
+ status = f_thread_mutex_lock(&main->thread.lock.alert);
if (F_status_is_error(status)) {
- global->thread->enabled = controller_thread_enabled_not_e;
+ main->thread.enabled = controller_thread_enabled_not_e;
}
else {
if (by == controller_thread_cancel_execute_e) {
- global->thread->enabled = controller_thread_enabled_execute_e;
+ main->thread.enabled = controller_thread_enabled_execute_e;
}
else if (by == controller_thread_cancel_exit_e) {
- global->thread->enabled = controller_thread_enabled_not_e;
+ main->thread.enabled = controller_thread_enabled_not_e;
}
else if (by == controller_thread_cancel_exit_execute_e) {
- global->thread->enabled = controller_thread_enabled_exit_execute_e;
+ main->thread.enabled = controller_thread_enabled_exit_execute_e;
}
else {
- global->thread->enabled = controller_thread_enabled_exit_e;
+ main->thread.enabled = controller_thread_enabled_exit_e;
}
- f_thread_mutex_unlock(&global->thread->lock.alert);
+ f_thread_mutex_unlock(&main->thread.lock.alert);
}
- if (global->thread->id_cleanup) {
- f_thread_cancel(global->thread->id_cleanup);
- f_thread_join(global->thread->id_cleanup, 0);
+ if (main->thread.id_cleanup) {
+ f_thread_cancel(main->thread.id_cleanup);
+ f_thread_join(main->thread.id_cleanup, 0);
- global->thread->id_cleanup = 0;
+ main->thread.id_cleanup = 0;
}
- if (global->thread->id_control) {
- f_thread_cancel(global->thread->id_control);
- f_thread_join(global->thread->id_control, 0);
+ if (main->thread.id_control) {
+ f_thread_cancel(main->thread.id_control);
+ f_thread_join(main->thread.id_control, 0);
- global->thread->id_control = 0;
+ main->thread.id_control = 0;
}
// The sigtimedwait() function that is run inside of signal must be interrupted via the f_thread_cancel().
- if (by != controller_thread_cancel_signal_e && global->thread->id_signal) {
- f_thread_cancel(global->thread->id_signal);
- f_thread_join(global->thread->id_signal, 0);
+ if (by != controller_thread_cancel_signal_e && main->thread.id_signal) {
+ f_thread_cancel(main->thread.id_signal);
+ f_thread_join(main->thread.id_signal, 0);
- global->thread->id_signal = 0;
+ main->thread.id_signal = 0;
}
- if (global->program->mode == controller_program_mode_helper_e && global->main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e) {
- f_thread_mutex_unlock(&global->thread->lock.cancel);
+ if (main->process.mode == controller_process_mode_helper_e && main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e) {
+ f_thread_mutex_unlock(&main->thread.lock.cancel);
return;
}
- for (; i < global->thread->instances.used; ++i) {
+ for (; i < main->thread.instances.used; ++i) {
- if (!global->thread->instances.array[i]) continue;
+ if (!main->thread.instances.array[i]) continue;
- instance = global->thread->instances.array[i];
+ instance = main->thread.instances.array[i];
// Do not cancel exit instances, when not performing "execute" during exit.
- if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) {
+ if (instance->type == controller_instance_type_exit_e && main->thread.enabled != controller_thread_enabled_exit_execute_e) {
continue;
}
for (j = 0; j < instance->childs.used; ++j) {
if (instance->childs.array[j] > 0) {
- f_signal_send(global->thread->signal ? global->thread->signal : F_signal_termination, instance->childs.array[j]);
+ f_signal_send(main->thread.signal ? main->thread.signal : F_signal_termination, instance->childs.array[j]);
}
} // for
status = controller_file_pid_read(instance->path_pids.array[j], &pid);
if (pid) {
- f_signal_send(global->thread->signal ? global->thread->signal : F_signal_termination, pid);
+ f_signal_send(main->thread.signal ? main->thread.signal : F_signal_termination, pid);
}
}
} // for
if (entry->timeout_exit && !(entry->flag & controller_entry_flag_timeout_exit_no_e)) {
f_number_unsigned_t lapsed = 0;
- for (i = 0; i < global->thread->instances.used && lapsed < entry->timeout_exit; ++i) {
+ for (i = 0; i < main->thread.instances.used && lapsed < entry->timeout_exit; ++i) {
- if (!global->thread->instances.array[i]) continue;
+ if (!main->thread.instances.array[i]) continue;
- instance = global->thread->instances.array[i];
+ instance = main->thread.instances.array[i];
// Do not wait for instances, when not performing "execute" during exit.
- if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) {
+ if (instance->type == controller_instance_type_exit_e && main->thread.enabled != controller_thread_enabled_exit_execute_e) {
continue;
}
} // for
}
- for (i = 0; i < global->thread->instances.size; ++i) {
+ for (i = 0; i < main->thread.instances.size; ++i) {
- if (!global->thread->instances.array[i]) continue;
+ if (!main->thread.instances.array[i]) continue;
- instance = global->thread->instances.array[i];
+ instance = main->thread.instances.array[i];
// Do not kill exit instances, when not performing "execute" during exit.
- if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) continue;
+ if (instance->type == controller_instance_type_exit_e && main->thread.enabled != controller_thread_enabled_exit_execute_e) continue;
if (instance->id_thread) {
if (instance->childs.used) {
for (j = 0; j < instance->childs.size; ++j) {
// Do not kill exit processes, when not performing "execute" during exit.
- if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) continue;
+ if (instance->type == controller_instance_type_exit_e && main->thread.enabled != controller_thread_enabled_exit_execute_e) continue;
if (instance->childs.array[j]) {
for (j = 0; j < instance->path_pids.used; ++j) {
// Do not kill exit processes, when not performing "execute" during exit.
- if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) continue;
+ if (instance->type == controller_instance_type_exit_e && main->thread.enabled != controller_thread_enabled_exit_execute_e) continue;
if (f_file_exists(instance->path_pids.array[j], F_true) == F_true) {
status = controller_file_pid_read(instance->path_pids.array[j], &pid);
while (instance->childs.used) {
// Do not shrink below an exit instances, when not performing "execute" during exit.
- if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) break;
+ if (instance->type == controller_instance_type_exit_e && main->thread.enabled != controller_thread_enabled_exit_execute_e) break;
if (instance->childs.array[j] > 0) break;
--instance->childs.used;
while (instance->path_pids.used) {
// Do not shrink below an exit instances, when not performing "execute" during exit.
- if (instance->type == controller_instance_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) break;
+ if (instance->type == controller_instance_type_exit_e && main->thread.enabled != controller_thread_enabled_exit_execute_e) break;
if (instance->path_pids.array[j].used) break;
--instance->path_pids.used;
} // while
} // for
- f_thread_mutex_unlock(&global->thread->lock.cancel);
+ f_thread_mutex_unlock(&main->thread.lock.cancel);
}
#endif // _di_controller_thread_instance_cancel_
#ifndef _di_controller_thread_instance_exit_
- void controller_thread_instance_exit(controller_global_t * const global) {
+ void controller_thread_instance_exit(controller_t * const main) {
- if (!global) return;
+ if (!main) return;
- if (global->thread->enabled != controller_thread_enabled_exit_e) return;
+ if (main->thread.enabled != controller_thread_enabled_exit_e) return;
- if (global->program->ready == controller_program_ready_done_e) {
+ if (main->process.ready == controller_process_ready_done_e) {
// The exit processing runs using the entry thread.
- if (global->thread->id_entry) {
- f_thread_cancel(global->thread->id_entry);
- f_thread_join(global->thread->id_entry, 0);
+ if (main->thread.id_entry) {
+ f_thread_cancel(main->thread.id_entry);
+ f_thread_join(main->thread.id_entry, 0);
- global->thread->id_entry = 0;
+ main->thread.id_entry = 0;
}
// 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_thread_signal_other, (void *) global);
+ if (!main->thread.id_signal) {
+ f_thread_create(0, &main->thread.id_signal, &controller_thread_signal_other, (void *) main);
}
- f_status_t status = f_thread_create(0, &global->thread->id_entry, &controller_thread_exit, (void *) global);
+ f_status_t status = f_thread_create(0, &main->thread.id_entry, &controller_thread_exit, (void *) main);
if (F_status_is_error(status)) {
- if (global->main->program.error.verbosity > f_console_verbosity_quiet_e) {
- controller_print_error_status(&global->main->program.error, macro_controller_f(f_thread_create), F_status_set_fine(status));
+ if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
+ controller_print_error_status(&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))) {
- global->thread->enabled = controller_thread_enabled_not_e;
+ if (F_status_is_error_not(f_thread_mutex_lock(&main->thread.lock.alert))) {
+ main->thread.enabled = controller_thread_enabled_not_e;
- f_thread_mutex_unlock(&global->thread->lock.alert);
+ f_thread_mutex_unlock(&main->thread.lock.alert);
}
else {
- global->thread->enabled = controller_thread_enabled_not_e;
+ main->thread.enabled = controller_thread_enabled_not_e;
}
}
else {
f_time_spec_t time = f_time_spec_t_initialize;
do {
- status = f_thread_mutex_lock(&global->thread->lock.alert);
+ status = f_thread_mutex_lock(&main->thread.lock.alert);
if (F_status_is_error(status)) {
- global->thread->enabled = controller_thread_enabled_not_e;
+ main->thread.enabled = controller_thread_enabled_not_e;
break;
}
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);
+ status = f_thread_condition_wait_timed(&time, &main->thread.lock.alert_condition, &main->thread.lock.alert);
- f_thread_mutex_unlock(&global->thread->lock.alert);
+ f_thread_mutex_unlock(&main->thread.lock.alert);
- } while (F_status_is_error_not(status) && global->thread->enabled == controller_thread_enabled_exit_e);
+ } while (F_status_is_error_not(status) && main->thread.enabled == controller_thread_enabled_exit_e);
if (F_status_is_error(status)) {
- if (F_status_is_error_not(f_thread_mutex_lock(&global->thread->lock.alert))) {
- global->thread->enabled = controller_thread_enabled_not_e;
+ if (F_status_is_error_not(f_thread_mutex_lock(&main->thread.lock.alert))) {
+ main->thread.enabled = controller_thread_enabled_not_e;
- f_thread_mutex_unlock(&global->thread->lock.alert);
+ f_thread_mutex_unlock(&main->thread.lock.alert);
}
else {
- global->thread->enabled = controller_thread_enabled_not_e;
+ main->thread.enabled = controller_thread_enabled_not_e;
}
}
}
// The sigtimedwait() function that is run inside of signal must be interrupted via the f_thread_cancel().
- if (global->thread->id_signal) {
- f_thread_cancel(global->thread->id_signal);
- f_thread_join(global->thread->id_signal, 0);
+ if (main->thread.id_signal) {
+ f_thread_cancel(main->thread.id_signal);
+ f_thread_join(main->thread.id_signal, 0);
- global->thread->id_signal = 0;
+ main->thread.id_signal = 0;
}
- controller_thread_instance_cancel(global, F_false, controller_thread_cancel_exit_e);
+ controller_thread_instance_cancel(main, F_false, controller_thread_cancel_exit_e);
}
else {
- if (F_status_is_error_not(f_thread_mutex_lock(&global->thread->lock.alert))) {
- global->thread->enabled = controller_thread_enabled_not_e;
+ if (F_status_is_error_not(f_thread_mutex_lock(&main->thread.lock.alert))) {
+ main->thread.enabled = controller_thread_enabled_not_e;
- f_thread_mutex_unlock(&global->thread->lock.alert);
+ f_thread_mutex_unlock(&main->thread.lock.alert);
}
else {
- global->thread->enabled = controller_thread_enabled_not_e;
+ main->thread.enabled = controller_thread_enabled_not_e;
}
}
}
#endif // _di_controller_thread_instance_exit_
#ifndef _di_controller_thread_instance_normal_
- void * controller_thread_instance_normal(void * const arguments) {
+ void * controller_thread_instance_normal(void * const argument) {
- if (!arguments) return 0;
+ if (!argument) return 0;
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_thread_instance(F_true, (controller_instance_t * const) arguments);
+ controller_thread_instance(F_true, (controller_instance_t * const) argument);
return 0;
}
#endif // _di_controller_thread_instance_normal_
#ifndef _di_controller_thread_instance_other_
- void * controller_thread_instance_other(void * const arguments) {
+ void * controller_thread_instance_other(void * const argument) {
- if (!arguments) return 0;
+ if (!argument) return 0;
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_thread_instance(F_false, (controller_instance_t * const) arguments);
+ controller_thread_instance(F_false, (controller_instance_t * const) argument);
return 0;
}
/**
* Cancel all process threads.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param is_normal
* If F_true, then process as if this operates during a normal operation (entry and control).
* If F_false, then process as if this operates during a an exit operation.
* 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_thread_instance_cancel_
- extern void controller_thread_instance_cancel(controller_global_t * const global, const uint8_t is_normal, const uint8_t by);
+ extern void controller_thread_instance_cancel(controller_t * const main, const uint8_t is_normal, const uint8_t by);
#endif // _di_controller_thread_instance_cancel_
/**
* Process the Exit file, if applicable.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
*/
#ifndef _di_controller_thread_instance_exit_
- extern void controller_thread_instance_exit(controller_global_t * const global);
+ extern void controller_thread_instance_exit(controller_t * const main);
#endif // _di_controller_thread_instance_exit_
/**
* Asynchronously execute a Rule process during normal operations.
*
- * @param arguments
- * The thread arguments.
- * Must be of type controller_global_t.
+ * @param argument
+ * The instance data.
*
+ * Must be of type controller_instance_t.
* Must not be NULL.
*
* @return
* @see controller_thread_instance()
*/
#ifndef _di_controller_thread_instance_normal_
- extern void * controller_thread_instance_normal(void * const global);
+ extern void * controller_thread_instance_normal(void * const argument);
#endif // _di_controller_thread_instance_normal_
/**
* Asynchronously execute a Rule process during other operations.
*
- * @param arguments
- * The thread arguments.
+ * @param argument
+ * The instance data.
*
- * Must not be NULL.
* Must be of type controller_instance_t.
+ * Must not be NULL.
*
* @return
* 0, always.
* @see controller_thread_instance()
*/
#ifndef _di_controller_thread_instance_other_
- extern void * controller_thread_instance_other(void * const arguments);
+ extern void * controller_thread_instance_other(void * const argument);
#endif // _di_controller_thread_instance_other_
#ifdef __cplusplus
if (!instance) return F_false;
- return controller_thread_is_enabled_instance_type(instance->type, instance->global->thread);
+ return controller_thread_is_enabled_instance_type(instance->type, &instance->main->thread);
}
#endif // _di_controller_thread_is_enabled_instance_
#endif
#ifndef _di_controller_thread_rule_
- void * controller_thread_rule(void * const arguments) {
+ void * controller_thread_rule(void * const argument) {
- if (!arguments) return 0;
+ if (!argument) return 0;
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_global_t * const global = (controller_global_t * const) arguments;
+ controller_t * const main = (controller_t *) argument;
- if (!controller_thread_is_enabled(F_true, global->thread)) return 0;
+ if (!controller_thread_is_enabled(F_true, &main->thread)) return 0;
return 0;
}
*
* @todo the control thread should send commands to this thread, somehow.
*
- * @param arguments
- * The global data.
- * Must be of type controller_global_t.
+ * @param argument
+ * The main program data.
*
+ * Must be of type controller_t.
* Must not be NULL.
*
* @return
* 0, always.
*/
#ifndef _di_controller_thread_rule_
- extern void * controller_thread_rule(void * const arguments);
+ extern void * controller_thread_rule(void * const argument);
#endif // _di_controller_thread_rule_
#ifdef __cplusplus
#endif
#ifndef _di_controller_thread_signal_
- void controller_thread_signal(controller_global_t * const global, const bool is_normal) {
+ void controller_thread_signal(controller_t * const main, const bool is_normal) {
- if (!global || !global->main || !global->thread) return;
- if (!controller_thread_is_enabled(is_normal, global->thread)) return;
- if (!(global->main->setting.flag & controller_main_flag_interruptible_e)) return;
+ if (!main) return;
+ if (!controller_thread_is_enabled(is_normal, &main->thread)) return;
+ if (!(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_thread_is_enabled(is_normal, global->thread)) {
+ while (controller_thread_is_enabled(is_normal, &main->thread)) {
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));
- status = f_signal_wait_until(&global->main->program.signal.set, &time, &information);
+ status = f_signal_wait_until(&main->program.signal.set, &time, &information);
if (status == F_time_out) continue;
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;
+ main->thread.signal = information.si_signo;
- controller_thread_instance_cancel(global, is_normal, controller_thread_cancel_signal_e);
+ controller_thread_instance_cancel(main, is_normal, controller_thread_cancel_signal_e);
break;
}
controller_interrupt_t * const interrupt = (controller_interrupt_t *) state->custom;
- if (!interrupt->global || !interrupt->global->main || !interrupt->global->thread) return;
+ if (!interrupt->main) 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);
+ if (!controller_thread_is_enabled(interrupt->is_normal, &interrupt->main->thread)) {
+ interrupt->main->program.signal_received = F_signal_abort;
+ interrupt->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);
+ else if (interrupt->main->thread.signal == F_signal_interrupt || interrupt->main->thread.signal == F_signal_abort || interrupt->main->thread.signal == F_signal_quit || interrupt->main->thread.signal == F_signal_termination) {
+ interrupt->main->program.signal_received = F_signal_abort;
+ interrupt->main->setting.state.status = F_status_set_error(F_interrupt);
}
}
#endif // _di_controller_thread_signal_state_fss_
controller_interrupt_t * const interrupt = (controller_interrupt_t *) state->custom;
- if (!interrupt->global || !interrupt->global->main || !interrupt->global->thread) return;
+ if (!interrupt->main) 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);
+ if (!controller_thread_is_enabled(interrupt->is_normal, &interrupt->main->thread)) {
+ interrupt->main->program.signal_received = F_signal_abort;
+ interrupt->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);
+ else if (interrupt->main->thread.signal == F_signal_interrupt || interrupt->main->thread.signal == F_signal_abort || interrupt->main->thread.signal == F_signal_quit || interrupt->main->thread.signal == F_signal_termination) {
+ interrupt->main->program.signal_received = F_signal_abort;
+ interrupt->main->setting.state.status = F_status_set_error(F_interrupt);
}
}
#endif // _di_controller_thread_signal_state_iki_
#ifndef _di_controller_thread_signal_normal_
- void * controller_thread_signal_normal(void * const global) {
+ void * controller_thread_signal_normal(void * const argument) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_thread_signal((controller_global_t * const) global, F_true);
+ controller_thread_signal((controller_t *) argument, F_true);
return 0;
}
#endif // _di_controller_thread_signal_normal_
#ifndef _di_controller_thread_signal_other_
- void * controller_thread_signal_other(void * const global) {
+ void * controller_thread_signal_other(void * const argument) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_thread_signal((controller_global_t * const) global, F_false);
+ controller_thread_signal((controller_t *) argument, F_false);
return 0;
}
/**
* Thread for handling signals/interrupts.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
* @param is_normal
* If FALSE, then process as if this operates during a an exit operation.
*/
#ifndef _di_controller_thread_signal_
- extern void controller_thread_signal(controller_global_t * const global, const bool is_normal);
+ extern void controller_thread_signal(controller_t * const main, const bool is_normal);
#endif // _di_controller_thread_signal_
/**
/**
* Thread for handling signals/interrupts during normal operations.
*
- * @param global
- * The global structure.
- * Must be of type controller_global_t.
+ * @param argument
+ * The main program data.
*
+ * Must be of type controller_t.
* Must not be NULL.
*
* @return
* @see controller_thread_signal()
*/
#ifndef _di_controller_thread_signal_normal_
- extern void * controller_thread_signal_normal(void * const global);
+ extern void * controller_thread_signal_normal(void * const argument);
#endif // _di_controller_thread_signal_normal_
/**
* Thread for handling signals/interrupts during other operations.
*
- * @param global
- * The global structure.
- * Must be of type controller_global_t.
+ * @param argument
+ * The main program data.
*
+ * Must be of type controller_t.
* Must not be NULL.
*
* @return
* @see controller_thread_signal()
*/
#ifndef _di_controller_thread_signal_other_
- extern void * controller_thread_signal_other(void * const global);
+ extern void * controller_thread_signal_other(void * const argument);
#endif // _di_controller_thread_signal_other_
#ifdef __cplusplus
#endif // _di_controller_time_now_
#ifndef _di_controller_time_sleep_nanoseconds_
- f_status_t controller_time_sleep_nanoseconds(controller_global_t * const global, const f_time_spec_t time) {
+ f_status_t controller_time_sleep_nanoseconds(controller_t * const main, const f_time_spec_t time) {
- if (!global || !global->main) return F_status_set_error(F_parameter);
+ if (!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->program.flag & controller_main_flag_interruptible_e) && time.tv_sec) {
+ if ((main->setting.flag & controller_main_flag_interruptible_e) && time.tv_sec) {
siginfo_t information;
f_signal_t signal = f_signal_t_initialize;
/**
* Sleep for the given time.
*
- * @param global
- * The global data.
+ * @param main
+ * The main program data.
*
* Must not be NULL.
*
- * This does not alter global.main.setting.state.status.
+ * This does not alter main.setting.state.status.
* @param time
* The time in nanoseconds to wait.
*
* @see f_time_of_day_get()
*/
#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);
+ extern f_status_t controller_time_sleep_nanoseconds(controller_t * const main, const f_time_spec_t time);
#endif // _di_controller_time_sleep_nanoseconds_
#ifdef __cplusplus
--- /dev/null
+#include "controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_validate_define_name_
+ f_status_t controller_validate_environment_name(const f_string_static_t name) {
+
+ if (!name.used) return F_okay;
+
+ f_status_t status = F_okay;
+
+ if (name.string[0] != '_') {
+ status = f_utf_is_alphabetic(name.string, name.used);
+
+ if (F_status_is_error(status)) return status;
+ if (status == F_false) return F_false;
+ }
+
+ for (f_number_unsigned_t i = macro_f_utf_byte_width(name.string[0]); i < name.used; i += macro_f_utf_byte_width(name.string[i])) {
+
+ if (name.string[i] == '_') continue;
+
+ status = f_utf_is_alphabetic_digit(name.string, name.used, 0);
+
+ if (F_status_is_error(status)) return status;
+ if (status == F_false) return F_false;
+ } // for
+
+ return F_true;
+ }
+#endif // _di_controller_validate_define_name_
+
+#ifndef _di_controller_validate_has_graph_
+ f_status_t controller_validate_has_graph(const f_string_static_t name) {
+
+ if (!name.used) return F_okay;
+
+ f_status_t status = F_okay;
+
+ for (f_number_unsigned_t i = 0; i < name.used; i += macro_f_utf_byte_width(name.string[i])) {
+
+ status = f_utf_is_graph(name.string, name.used);
+
+ if (F_status_is_error(status)) return status;
+ if (status == F_true) return F_true;
+ } // for
+
+ return F_false;
+ }
+#endif // _di_controller_validate_has_graph_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides validate functionality.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_validate_h
+#define _controller_validate_h
+
+/**
+ * Validate that the given string is a valid environment variable name.
+ *
+ * A valid environment variable name must begin with an alpha-character or an underscore.
+ * Every character after that may be alphanumeric or underscore.
+ * All other characters, including Unicode characters, are invalid.
+ *
+ * @param name
+ * The string to validate.
+ *
+ * @return
+ * F_true on valid.
+ * F_false on invalid.
+ * F_okay if there is no string to validate (used = 0).
+ *
+ * Errors (with error bit) from: f_utf_is_alphabetic().
+ * Errors (with error bit) from: f_utf_is_alphabetic_digit().
+ *
+ * @see f_utf_is_alphabetic()
+ * @see f_utf_is_alphabetic_digit()
+ */
+#ifndef _di_controller_validate_define_name_
+ extern f_status_t controller_validate_environment_name(const f_string_static_t name);
+#endif // _di_controller_validate_define_name_
+
+/**
+ * Validate that the given string has at least one graph character.
+ *
+ * @param name
+ * The string to validate.
+ *
+ * @return
+ * F_true on valid.
+ * F_false on invalid.
+ * F_okay if there is no string to validate (used = 0).
+ *
+ * Errors (with error bit) from: f_utf_is_graph().
+ *
+ * @see f_utf_is_graph()
+ */
+#ifndef _di_controller_validate_has_graph_
+ extern f_status_t controller_validate_has_graph(const f_string_static_t name);
+#endif // _di_controller_validate_has_graph_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_validate_h