From 94c6c923736490d76b75eab8cc1dbc177cfde426 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 25 Jan 2022 23:41:14 -0600 Subject: [PATCH] Progress: Control and Controller. This primarily focuses on migrating the controller static strings from f_string_t to f_string_static_t. Other changes and fixes do exist. --- level_3/control/c/control.c | 8 +- level_3/controller/c/control/private-control.c | 2 + level_3/controller/c/controller/controller.c | 95 ++++++-- level_3/controller/c/controller/controller.h | 269 +++++++++++++++------ level_3/controller/c/main.c | 9 +- level_3/controller/c/rule/private-rule.c | 45 ++-- level_3/controller/c/rule/private-rule.h | 4 +- level_3/controller/c/rule/private-rule_print.c | 4 +- level_3/controller/c/rule/private-rule_print.h | 2 +- level_3/controller/data/build/defines | 15 +- .../data/settings/example/entries/up.entry | 9 + 11 files changed, 331 insertions(+), 131 deletions(-) create mode 100644 level_3/controller/data/settings/example/entries/up.entry diff --git a/level_3/control/c/control.c b/level_3/control/c/control.c index ce8b57f..0d00bd6 100644 --- a/level_3/control/c/control.c +++ b/level_3/control/c/control.c @@ -51,8 +51,8 @@ extern "C" { fll_program_print_help_usage(main->output.to, main->context, control_program_name_s.string, control_command_s.string); - fl_print_format(" When the %[%s%s%] parameter represents a directory path then the file name is generated from either the", main->output.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, control_long_socket_s.string, main->context.set.notable); - fl_print_format(" %[%s%s%] parameter or from the control settings file.%c%c", main->output.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, control_long_name_s.string, main->context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + fl_print_format(" When the %[%s%q%] parameter represents a directory path then the file name is generated from either the", main->output.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, control_long_socket_s, main->context.set.notable); + fl_print_format(" %[%s%q%] parameter or from the control settings file.%c%c", main->output.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, control_long_name_s, main->context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); fl_print_format(" A rule action allows for either the full rule path, such as '%[boot/root%]'", main->output.to.stream, main->context.set.notable, main->context.set.notable); fl_print_format(" as a single parameter or two parameters with the first representing the rule directory path '%[boot%]'", main->output.to.stream, main->context.set.notable, main->context.set.notable); @@ -210,11 +210,11 @@ extern "C" { control_data_t data = control_data_t_initialize; // Verify commands before attempting to connect to the socket. - if (control_command_identify(main, &data, arguments->argv[0]) == F_found) { + if (control_command_identify(main, &data, arguments->argv[main->remaining.array[0]]) == F_found) { status = control_command_verify(main, &data, arguments); } else { - control_print_error_parameter_command_not(main, arguments->argv[0]); + control_print_error_parameter_command_not(main, arguments->argv[main->remaining.array[0]]); status = F_status_set_error(F_parameter); } diff --git a/level_3/controller/c/control/private-control.c b/level_3/controller/c/control/private-control.c index fcdeca2..ffc0ddd 100644 --- a/level_3/controller/c/control/private-control.c +++ b/level_3/controller/c/control/private-control.c @@ -131,6 +131,8 @@ extern "C" { // @todo process the data. + fll_print_format("\nDEBUG: received packet: '%Q'\n", stdout, control->input); + // @todo send any responses. f_socket_disconnect(&client, f_socket_close_fast_e); diff --git a/level_3/controller/c/controller/controller.c b/level_3/controller/c/controller/controller.c index 72b759e..e9ecc0d 100644 --- a/level_3/controller/c/controller/controller.c +++ b/level_3/controller/c/controller/controller.c @@ -12,12 +12,57 @@ extern "C" { #endif +#ifndef _di_controller_program_version_ + const f_string_static_t controller_program_version_s = macro_f_string_static_t_initialize2(CONTROLLER_program_version_s, 0, CONTROLLER_program_version_s_length); +#endif // _di_controller_program_version_ + +#ifndef _di_controller_program_name_ + const f_string_static_t controller_program_name_s = macro_f_string_static_t_initialize2(CONTROLLER_program_name_s, 0, CONTROLLER_program_name_s_length); + const f_string_static_t controller_program_name_long_s = macro_f_string_static_t_initialize2(CONTROLLER_program_name_long_s, 0, CONTROLLER_program_name_long_s_length); + + const f_string_static_t controller_program_name_init_s = macro_f_string_static_t_initialize2(CONTROLLER_program_name_init_s, 0, CONTROLLER_program_name_init_s_length); + const f_string_static_t controller_program_name_init_long_s = macro_f_string_static_t_initialize2(CONTROLLER_program_name_init_long_s, 0, CONTROLLER_program_name_init_long_s_length); +#endif // _di_controller_program_name_ + +#ifndef _di_controller_defines_ + const f_string_static_t controller_default_program_script_s = macro_f_string_static_t_initialize2(CONTROLLER_default_program_script_s, 0, CONTROLLER_default_program_script_s_length); + const f_string_static_t controller_name_socket_s = macro_f_string_static_t_initialize2(CONTROLLER_name_socket_s, 0, CONTROLLER_name_socket_s_length); + const f_string_static_t controller_path_pid_s = macro_f_string_static_t_initialize2(CONTROLLER_path_pid_s, 0, CONTROLLER_path_pid_s_length); + const f_string_static_t controller_path_pid_init_s = macro_f_string_static_t_initialize2(CONTROLLER_path_pid_init_s, 0, CONTROLLER_path_pid_init_s_length); + const f_string_static_t controller_path_pid_suffix_s = macro_f_string_static_t_initialize2(CONTROLLER_path_pid_s, 0, CONTROLLER_path_pid_s_length); + const f_string_static_t controller_path_settings_s = macro_f_string_static_t_initialize2(CONTROLLER_path_settings_s, 0, CONTROLLER_path_settings_s_length); + const f_string_static_t controller_path_settings_init_s = macro_f_string_static_t_initialize2(CONTROLLER_path_settings_init_s, 0, CONTROLLER_path_settings_init_s_length); + const f_string_static_t controller_path_socket_s = macro_f_string_static_t_initialize2(CONTROLLER_path_socket_s, 0, CONTROLLER_path_socket_s_length); + const f_string_static_t controller_path_socket_prefix_s = macro_f_string_static_t_initialize2(CONTROLLER_path_socket_prefix_s, 0, CONTROLLER_path_socket_prefix_s_length); + const f_string_static_t controller_path_socket_suffix_s = macro_f_string_static_t_initialize2(CONTROLLER_path_socket_suffix_s, 0, CONTROLLER_path_socket_suffix_s_length); + + const f_string_static_t controller_short_cgroup_s = macro_f_string_static_t_initialize2(CONTROLLER_short_cgroup_s, 0, CONTROLLER_short_cgroup_s_length); + const f_string_static_t controller_short_daemon_s = macro_f_string_static_t_initialize2(CONTROLLER_short_daemon_s, 0, CONTROLLER_short_daemon_s_length); + const f_string_static_t controller_short_init_s = macro_f_string_static_t_initialize2(CONTROLLER_short_init_s, 0, CONTROLLER_short_init_s_length); + const f_string_static_t controller_short_interruptible_s = macro_f_string_static_t_initialize2(CONTROLLER_short_interruptible_s, 0, CONTROLLER_short_interruptible_s_length); + const f_string_static_t controller_short_pid_s = macro_f_string_static_t_initialize2(CONTROLLER_short_pid_s, 0, CONTROLLER_short_pid_s_length); + const f_string_static_t controller_short_settings_s = macro_f_string_static_t_initialize2(CONTROLLER_short_settings_s, 0, CONTROLLER_short_settings_s_length); + const f_string_static_t controller_short_simulate_s = macro_f_string_static_t_initialize2(CONTROLLER_short_simulate_s, 0, CONTROLLER_short_simulate_s_length); + const f_string_static_t controller_short_uninterruptible_s = macro_f_string_static_t_initialize2(CONTROLLER_short_uninterruptible_s, 0, CONTROLLER_short_uninterruptible_s_length); + const f_string_static_t controller_short_validate_s = macro_f_string_static_t_initialize2(CONTROLLER_short_validate_s, 0, CONTROLLER_short_validate_s_length); + + const f_string_static_t controller_long_cgroup_s = macro_f_string_static_t_initialize2(CONTROLLER_long_cgroup_s, 0, CONTROLLER_long_cgroup_s_length); + const f_string_static_t controller_long_daemon_s = macro_f_string_static_t_initialize2(CONTROLLER_long_daemon_s, 0, CONTROLLER_long_daemon_s_length); + const f_string_static_t controller_long_init_s = macro_f_string_static_t_initialize2(CONTROLLER_long_init_s, 0, CONTROLLER_long_init_s_length); + const f_string_static_t controller_long_interruptible_s = macro_f_string_static_t_initialize2(CONTROLLER_long_interruptible_s, 0, CONTROLLER_long_interruptible_s_length); + const f_string_static_t controller_long_pid_s = macro_f_string_static_t_initialize2(CONTROLLER_long_pid_s, 0, CONTROLLER_long_pid_s_length); + const f_string_static_t controller_long_settings_s = macro_f_string_static_t_initialize2(CONTROLLER_long_settings_s, 0, CONTROLLER_long_settings_s_length); + const f_string_static_t controller_long_simulate_s = macro_f_string_static_t_initialize2(CONTROLLER_long_simulate_s, 0, CONTROLLER_long_simulate_s_length); + const f_string_static_t controller_long_uninterruptible_s = macro_f_string_static_t_initialize2(CONTROLLER_long_uninterruptible_s, 0, CONTROLLER_long_uninterruptible_s_length); + const f_string_static_t controller_long_validate_s = macro_f_string_static_t_initialize2(CONTROLLER_long_validate_s, 0, CONTROLLER_long_validate_s_length); +#endif // _di_controller_defines_ + #ifndef _di_controller_print_help_ f_status_t controller_print_help(controller_main_t * const main) { controller_lock_print(main->output.to, 0); - fll_program_print_help_header(main->output.to, main->context, main->program_name_long, controller_program_version_s); + fll_program_print_help_header(main->output.to, main->context, main->program_name_long.string, controller_program_version_s.string); fll_program_print_help_option(main->output.to, main->context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); fll_program_print_help_option(main->output.to, main->context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); @@ -31,24 +76,24 @@ extern "C" { f_print_character(f_string_eol_s[0], main->output.to.stream); - fll_program_print_help_option(main->output.to, main->context, controller_short_cgroup_s, controller_long_cgroup_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a custom control group file path, such as '" F_control_group_path_system_prefix_s F_control_group_path_system_default_s "'."); - fll_program_print_help_option(main->output.to, main->context, controller_short_daemon_s, controller_long_daemon_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Run in daemon only mode (do not process the entry)."); - fll_program_print_help_option(main->output.to, main->context, controller_short_init_s, controller_long_init_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " The program will run as an init replacement."); - fll_program_print_help_option(main->output.to, main->context, controller_short_interruptible_s, controller_long_interruptible_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Designate that this program can be interrupted by a signal."); - fll_program_print_help_option(main->output.to, main->context, controller_short_pid_s, controller_long_pid_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a custom pid file path, such as '" controller_path_pid_s CONTROLLER_default_s controller_path_pid_suffix_s "'."); - fll_program_print_help_option(main->output.to, main->context, controller_short_settings_s, controller_long_settings_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a custom settings path, such as '" controller_path_settings_s "'."); - fll_program_print_help_option(main->output.to, main->context, controller_short_simulate_s, controller_long_simulate_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Run as a simulation."); - fll_program_print_help_option(main->output.to, main->context, controller_short_uninterruptible_s, controller_long_uninterruptible_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Designate that this program cannot be interrupted by a signal."); - fll_program_print_help_option(main->output.to, main->context, controller_short_validate_s, controller_long_validate_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Validate the settings (entry and rules) without running (does not simulate)."); + fll_program_print_help_option(main->output.to, main->context, controller_short_cgroup_s.string, controller_long_cgroup_s.string, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a custom control group file path, such as '" F_control_group_path_system_prefix_s F_control_group_path_system_default_s "'."); + fll_program_print_help_option(main->output.to, main->context, controller_short_daemon_s.string, controller_long_daemon_s.string, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Run in daemon only mode (do not process the entry)."); + fll_program_print_help_option(main->output.to, main->context, controller_short_init_s.string, controller_long_init_s.string, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " The program will run as an init replacement."); + fll_program_print_help_option(main->output.to, main->context, controller_short_interruptible_s.string, controller_long_interruptible_s.string, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Designate that this program can be interrupted by a signal."); + fll_program_print_help_option(main->output.to, main->context, controller_short_pid_s.string, controller_long_pid_s.string, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a custom pid file path, such as '" CONTROLLER_path_pid_s CONTROLLER_default_s CONTROLLER_path_pid_suffix_s "'."); + fll_program_print_help_option(main->output.to, main->context, controller_short_settings_s.string, controller_long_settings_s.string, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a custom settings path, such as '" CONTROLLER_path_settings_s "'."); + fll_program_print_help_option(main->output.to, main->context, controller_short_simulate_s.string, controller_long_simulate_s.string, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Run as a simulation."); + fll_program_print_help_option(main->output.to, main->context, controller_short_uninterruptible_s.string, controller_long_uninterruptible_s.string, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Designate that this program cannot be interrupted by a signal."); + fll_program_print_help_option(main->output.to, main->context, controller_short_validate_s.string, controller_long_validate_s.string, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Validate the settings (entry and rules) without running (does not simulate)."); - fll_program_print_help_usage(main->output.to, main->context, main->program_name, "entry"); + fll_program_print_help_usage(main->output.to, main->context, main->program_name.string, "entry"); - fl_print_format(" When both the %[%s%s%] parameter and the", main->output.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_simulate_s, main->context.set.notable); - fl_print_format(" %[%s%s%] parameter are specified, then additional information on each would be executed rule is printed but no simulation is performed.%c%c", main->output.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_validate_s, main->context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + fl_print_format(" When both the %[%s%q%] parameter and the", main->output.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_simulate_s, main->context.set.notable); + fl_print_format(" %[%s%q%] parameter are specified, then additional information on each would be executed rule is printed but no simulation is performed.%c%c", main->output.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_validate_s, main->context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" The default interrupt behavior is to operate as if the %[%s%s%] parameter is passed.%c%c", main->output.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, main->setting_default.used ? controller_long_uninterruptible_s : controller_long_interruptible_s, main->context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + fl_print_format(" The default interrupt behavior is to operate as if the %[%s%q%] parameter is passed.%c%c", main->output.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, main->setting_default.used ? controller_long_uninterruptible_s : controller_long_interruptible_s, main->context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); - fl_print_format(" Specify an empty string for the %[%s%s%] parameter to disable pid file creation for this program.%c%c", main->output.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_pid_s, main->context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + fl_print_format(" Specify an empty string for the %[%s%q%] parameter to disable pid file creation for this program.%c%c", main->output.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_pid_s, main->context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); controller_unlock_print_flush(main->output.to, 0); @@ -152,7 +197,7 @@ extern "C" { if (main->parameters[controller_parameter_version_e].result == f_console_result_found_e) { controller_lock_print(main->output.to, 0); - fll_program_print_version(main->output.to, controller_program_version_s); + fll_program_print_version(main->output.to, controller_program_version_s.string); controller_unlock_print_flush(main->output.to, 0); @@ -228,17 +273,17 @@ extern "C" { } else { if (main->parameters[controller_parameter_init_e].result == f_console_result_found_e && !main->as_init) { - status = f_string_append(controller_path_settings_init_s, controller_path_settings_init_s_length, &setting.path_setting); + status = f_string_dynamic_append(controller_path_settings_init_s, &setting.path_setting); } else if (main->setting_default.used) { - status = f_string_append(main->setting_default.string, main->setting_default.used, &setting.path_setting); + status = f_string_dynamic_append(main->setting_default, &setting.path_setting); } else { - status = f_string_append(controller_path_settings_s, controller_path_settings_s_length, &setting.path_setting); + status = f_string_dynamic_append(controller_path_settings_s, &setting.path_setting); } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); } } @@ -274,22 +319,22 @@ extern "C" { if (F_status_is_error_not(status) && !setting.path_pid.used && !main->parameters[controller_parameter_pid_e].locations.used) { if (main->parameters[controller_parameter_init_e].result == f_console_result_found_e) { - status = f_string_append(controller_path_pid_init_s, controller_path_pid_init_s_length, &setting.path_pid); + status = f_string_dynamic_append(controller_path_pid_init_s, &setting.path_pid); } else { - status = f_string_append(main->path_pid.string, main->path_pid.used, &setting.path_pid); + status = f_string_dynamic_append(main->path_pid, &setting.path_pid); } if (F_status_is_error_not(status)) { - status = f_string_append(setting.name_entry.string, setting.name_entry.used, &setting.path_pid); + status = f_string_dynamic_append(setting.name_entry, &setting.path_pid); } if (F_status_is_error_not(status)) { - status = f_string_append(controller_path_pid_suffix_s, controller_path_pid_suffix_s_length, &setting.path_pid); + status = f_string_dynamic_append(controller_path_pid_suffix_s, &setting.path_pid); } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); } } diff --git a/level_3/controller/c/controller/controller.h b/level_3/controller/c/controller/controller.h index 9ff5e89..87fb5f8 100644 --- a/level_3/controller/c/controller/controller.h +++ b/level_3/controller/c/controller/controller.h @@ -87,88 +87,219 @@ extern "C" { #endif #ifndef _di_controller_program_version_ - #define controller_program_version_major_s F_string_ascii_0_s - #define controller_program_version_minor_s F_string_ascii_5_s - #define controller_program_version_micro_s F_string_ascii_8_s + #define CONTROLLER_program_version_major_s F_string_ascii_0_s + #define CONTROLLER_program_version_minor_s F_string_ascii_5_s + #define CONTROLLER_program_version_micro_s F_string_ascii_8_s - #ifndef controller_program_version_nano_prefix_s - #define controller_program_version_nano_prefix_s + #define CONTROLLER_program_version_major_s_length 1 + #define CONTROLLER_program_version_minor_s_length 1 + #define CONTROLLER_program_version_micro_s_length 1 + + #ifndef CONTROLLER_program_version_nano_prefix_s + #define CONTROLLER_program_version_nano_prefix_s + + #define CONTROLLER_program_version_nano_prefix_s_length 0 #endif - #ifndef controller_program_version_nano_s - #define controller_program_version_nano_s + #ifndef CONTROLLER_program_version_nano_s + #define CONTROLLER_program_version_nano_s + + #define CONTROLLER_program_version_nano_s_length 0 #endif - #define controller_program_version_s controller_program_version_major_s F_string_ascii_period_s controller_program_version_minor_s F_string_ascii_period_s controller_program_version_micro_s controller_program_version_nano_prefix_s controller_program_version_nano_s + #define CONTROLLER_program_version_s CONTROLLER_program_version_major_s F_string_ascii_period_s CONTROLLER_program_version_minor_s F_string_ascii_period_s CONTROLLER_program_version_micro_s CONTROLLER_program_version_nano_prefix_s CONTROLLER_program_version_nano_s + + #define CONTROLLER_program_version_s_length CONTROLLER_program_version_major_s_length + F_string_ascii_period_s_length + CONTROLLER_program_version_minor_s_length + F_string_ascii_period_s_length + CONTROLLER_program_version_nano_prefix_s_length + CONTROLLER_program_version_nano_s_length + + extern const f_string_static_t controller_program_version_s; #endif // _di_controller_program_version_ #ifndef _di_controller_program_name_ - #define controller_program_name_s "controller" - #define controller_program_name_long_s "Controller Program" + #define CONTROLLER_program_name_s "controller" + #define CONTROLLER_program_name_long_s "Controller Program" + + #define CONTROLLER_program_name_init_s "init" + #define CONTROLLER_program_name_init_long_s "Init Program" + + #define CONTROLLER_program_name_s_length 7 + #define CONTROLLER_program_name_long_s_length 15 + + #define CONTROLLER_program_name_init_s_length 4 + #define CONTROLLER_program_name_init_long_s_length 12 - #define controller_program_name_init_s "init" - #define controller_program_name_init_long_s "Init Program" + extern const f_string_static_t controller_program_name_s; + extern const f_string_static_t controller_program_name_long_s; + + extern const f_string_static_t controller_program_name_init_s; + extern const f_string_static_t controller_program_name_init_long_s; #endif // _di_controller_program_name_ #ifndef _di_controller_defines_ // The init pid path is a system-specific path and needs to be more easily contolled at compile time. #if defined(_override_controller_path_pid_init_) && defined(_override_controller_path_pid_init_length_) - #define controller_path_pid_init_s _override_controller_path_pid_init_ - #define controller_path_pid_init_s_length _override_controller_path_pid_init_length_ + #define CONTROLLER_path_pid_init_s _override_controller_path_pid_init_ + #define CONTROLLER_path_pid_init_s_length _override_controller_path_pid_init_length_ #elif defined(_controller_as_init_) - #define controller_path_pid_init_s "/var/run/init/init-" - #define controller_path_pid_init_s_length 19 + #define CONTROLLER_path_pid_init_s "/var/run/init/init-" + #define CONTROLLER_path_pid_init_s_length 19 #else - #define controller_path_pid_init_s "/var/run/controller/controller-" - #define controller_path_pid_init_s_length 31 + #define CONTROLLER_path_pid_init_s "/var/run/controller/controller-" + #define CONTROLLER_path_pid_init_s_length 31 #endif // defined(_override_controller_path_pid_init_) && defined(_override_controller_path_pid_init_length_) // The settings path is a system-specific path and needs to be more easily contolled at compile time. #if defined(_override_controller_path_settings_init_) && defined(_override_controller_path_settings_init_length_) - #define controller_path_settings_init_s _override_controller_path_settings_init_ - #define controller_path_settings_init_s_length _override_controller_path_settings_init_length_ + #define CONTROLLER_path_settings_init_s _override_controller_path_settings_init_ + #define CONTROLLER_path_settings_init_s_length _override_controller_path_settings_init_length_ #elif defined(_controller_as_init_) - #define controller_path_settings_init_s "/etc/init" - #define controller_path_settings_init_s_length 9 + #define CONTROLLER_path_settings_init_s "/etc/init" + #define CONTROLLER_path_settings_init_s_length 9 #else - #define controller_path_settings_init_s "/etc/controller" - #define controller_path_settings_init_s_length 15 + #define CONTROLLER_path_settings_init_s "/etc/controller" + #define CONTROLLER_path_settings_init_s_length 15 #endif // defined(_override_controller_path_settings_init_) && defined(_override_controller_path_settings_init_length_) - #ifdef _override_controller_default_program_script_ - #define controller_default_program_script_s _override_controller_default_program_script_ + // The socket path is a system-specific path and needs to be more easily contolled at compile time. + #if defined(_override_controller_name_socket_) && defined(_override_controller_name_socket_length_) + #define CONTROLLER_name_socket_s _override_controller_name_socket_ + + #define CONTROLLER_name_socket_s_length _override_controller_name_socket_length_ + #else + #define CONTROLLER_name_socket_s "default" + + #define CONTROLLER_name_socket_s_length 7 + #endif // defined(_override_controller_name_socket_) && defined(_override_controller_name_socket_length_) + + // The path_socket is a system-specific path and should match the path compiled into the controller program. + #if defined(_override_controller_path_socket_) && defined(_override_controller_path_socket_length_) + #define CONTROLLER_path_socket_s _override_controller_path_socket_ + + #define CONTROLLER_path_socket_s_length _override_controller_path_socket_length_ + #elif defined(_controller_as_init_) + #define CONTROLLER_path_socket_s "/var/run/init" + + #define CONTROLLER_path_socket_s_length 13 #else - #define controller_default_program_script_s "bash" - #endif // _override_controller_default_program_script_ - - #define controller_path_pid_s "controller/run/controller-" - #define controller_path_pid_suffix_s ".pid" - #define controller_path_settings_s "controller" - - #define controller_path_pid_s_length 26 - #define controller_path_pid_suffix_s_length 4 - #define controller_path_settings_s_length 10 - - #define controller_short_cgroup_s "c" - #define controller_short_daemon_s "d" - #define controller_short_init_s "I" - #define controller_short_interruptible_s "i" - #define controller_short_pid_s "p" - #define controller_short_settings_s "s" - #define controller_short_simulate_s "S" - #define controller_short_uninterruptible_s "U" - #define controller_short_validate_s "v" - - #define controller_long_cgroup_s "cgroup" - #define controller_long_daemon_s "daemon" - #define controller_long_init_s "init" - #define controller_long_interruptible_s "interruptible" - #define controller_long_pid_s "pid" - #define controller_long_settings_s "settings" - #define controller_long_simulate_s "simulate" - #define controller_long_uninterruptible_s "uninterruptible" - #define controller_long_validate_s "validate" + #define CONTROLLER_path_socket_s "/var/run/controller" + + #define CONTROLLER_path_socket_s_length 19 + #endif // defined(_override_controller_path_socket_) && defined(_override_controller_path_socket_length_) + + // The name_socket_prefix is a system-specific path and should match the path compiled into the controller program. + #if defined(_override_controller_path_socket_prefix_) && defined(_override_controller_path_socket_prefix_length_) + #define CONTROLLER_path_socket_prefix_s _override_controller_path_socket_prefix_ + + #define CONTROLLER_path_socket_prefix_s_length _override_controller_path_socket_prefix_length_ + #elif defined(_controller_as_init_) + #define CONTROLLER_path_socket_prefix_s "init-" + + #define CONTROLLER_path_socket_prefix_s_length 5 + #else + #define CONTROLLER_path_socket_prefix_s "" + + #define CONTROLLER_path_socket_prefix_s_length 0 + #endif // defined(_override_controller_name_socket_prefix_) && defined(_override_controller_name_socket_prefix_length_) + + // The name_socket_suffix is a system-specific path and should match the path compiled into the controller program. + #if defined(_override_controller_path_socket_suffix_) && defined(_override_controller_path_socket_suffix_length_) + #define CONTROLLER_path_socket_suffix_s _override_controller_path_socket_suffix_ + + #define CONTROLLER_path_socket_suffix_s_length _override_controller_path_socket_suffix_length_ + #else + #define CONTROLLER_path_socket_suffix_s ".socket" + + #define CONTROLLER_path_socket_suffix_s_length 7 + #endif // defined(_override_controller_name_socket_suffix_) && defined(_override_controller_name_socket_suffix_length_) + + #if defined(_override_controller_default_program_script_) && defined(_override_controller_default_program_script_length_) + #define CONTROLLER_default_program_script_s _override_controller_default_program_script_ + + #define CONTROLLER_default_program_script_s_length _override_controller_default_program_script_length_ + #else + #define CONTROLLER_default_program_script_s "bash" + + #define CONTROLLER_default_program_script_s_length 4 + #endif // defined(_override_controller_default_program_script_) && defined(_override_controller_default_program_script_length_) + + #define CONTROLLER_path_pid_s "controller/run/controller-" + #define CONTROLLER_path_pid_suffix_s ".pid" + #define CONTROLLER_path_settings_s "controller" + + #define CONTROLLER_path_pid_s_length 26 + #define CONTROLLER_path_pid_suffix_s_length 4 + #define CONTROLLER_path_settings_s_length 10 + + extern const f_string_static_t controller_default_program_script_s; + extern const f_string_static_t controller_name_socket_s; + extern const f_string_static_t controller_path_pid_s; + extern const f_string_static_t controller_path_pid_init_s; + extern const f_string_static_t controller_path_pid_suffix_s; + extern const f_string_static_t controller_path_settings_s; + extern const f_string_static_t controller_path_settings_init_s; + extern const f_string_static_t controller_path_socket_s; + extern const f_string_static_t controller_path_socket_prefix_s; + extern const f_string_static_t controller_path_socket_suffix_s; + + #define CONTROLLER_short_cgroup_s "c" + #define CONTROLLER_short_daemon_s "d" + #define CONTROLLER_short_init_s "I" + #define CONTROLLER_short_interruptible_s "i" + #define CONTROLLER_short_pid_s "p" + #define CONTROLLER_short_settings_s "s" + #define CONTROLLER_short_simulate_s "S" + #define CONTROLLER_short_uninterruptible_s "U" + #define CONTROLLER_short_validate_s "v" + + #define CONTROLLER_long_cgroup_s "cgroup" + #define CONTROLLER_long_daemon_s "daemon" + #define CONTROLLER_long_init_s "init" + #define CONTROLLER_long_interruptible_s "interruptible" + #define CONTROLLER_long_pid_s "pid" + #define CONTROLLER_long_settings_s "settings" + #define CONTROLLER_long_simulate_s "simulate" + #define CONTROLLER_long_uninterruptible_s "uninterruptible" + #define CONTROLLER_long_validate_s "validate" + + #define CONTROLLER_short_cgroup_s_length 1 + #define CONTROLLER_short_daemon_s_length 1 + #define CONTROLLER_short_init_s_length 1 + #define CONTROLLER_short_interruptible_s_length 1 + #define CONTROLLER_short_pid_s_length 1 + #define CONTROLLER_short_settings_s_length 1 + #define CONTROLLER_short_simulate_s_length 1 + #define CONTROLLER_short_uninterruptible_s_length 1 + #define CONTROLLER_short_validate_s_length 1 + + #define CONTROLLER_long_cgroup_s_length 6 + #define CONTROLLER_long_daemon_s_length 6 + #define CONTROLLER_long_init_s_length 4 + #define CONTROLLER_long_interruptible_s_length 13 + #define CONTROLLER_long_pid_s_length 3 + #define CONTROLLER_long_settings_s_length 8 + #define CONTROLLER_long_simulate_s_length 8 + #define CONTROLLER_long_uninterruptible_s_length 15 + #define CONTROLLER_long_validate_s_length 8 + + extern const f_string_static_t controller_short_cgroup_s; + extern const f_string_static_t controller_short_daemon_s; + extern const f_string_static_t controller_short_init_s; + extern const f_string_static_t controller_short_interruptible_s; + extern const f_string_static_t controller_short_pid_s; + extern const f_string_static_t controller_short_settings_s; + extern const f_string_static_t controller_short_simulate_s; + extern const f_string_static_t controller_short_uninterruptible_s; + extern const f_string_static_t controller_short_validate_s; + + extern const f_string_static_t controller_long_cgroup_s; + extern const f_string_static_t controller_long_daemon_s; + extern const f_string_static_t controller_long_init_s; + extern const f_string_static_t controller_long_interruptible_s; + extern const f_string_static_t controller_long_pid_s; + extern const f_string_static_t controller_long_settings_s; + extern const f_string_static_t controller_long_simulate_s; + extern const f_string_static_t controller_long_uninterruptible_s; + extern const f_string_static_t controller_long_validate_s; enum { controller_parameter_help_e, @@ -203,15 +334,15 @@ extern "C" { macro_f_console_parameter_t_initialize(f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_debug_s, f_console_standard_long_debug_s, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, 0, f_console_type_inverse_e), \ - macro_f_console_parameter_t_initialize(controller_short_cgroup_s, controller_long_cgroup_s, 0, 1, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(controller_short_daemon_s, controller_long_daemon_s, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(controller_short_init_s, controller_long_init_s, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(controller_short_interruptible_s, controller_long_interruptible_s, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(controller_short_pid_s, controller_long_pid_s, 0, 1, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(controller_short_settings_s, controller_long_settings_s, 0, 1, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(controller_short_simulate_s, controller_long_simulate_s, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(controller_short_uninterruptible_s, controller_long_uninterruptible_s, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(controller_short_validate_s, controller_long_validate_s, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(controller_short_cgroup_s.string, controller_long_cgroup_s.string, 0, 1, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(controller_short_daemon_s.string, controller_long_daemon_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(controller_short_init_s.string, controller_long_init_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(controller_short_interruptible_s.string, controller_long_interruptible_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(controller_short_pid_s.string, controller_long_pid_s.string, 0, 1, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(controller_short_settings_s.string, controller_long_settings_s.string, 0, 1, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(controller_short_simulate_s.string, controller_long_simulate_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(controller_short_uninterruptible_s.string, controller_long_uninterruptible_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(controller_short_validate_s.string, controller_long_validate_s.string, 0, 0, f_console_type_normal_e), \ } #define controller_total_parameters_d 18 @@ -235,8 +366,8 @@ extern "C" { mode_t umask; int child; - f_string_t program_name; - f_string_t program_name_long; + f_string_static_t program_name; + f_string_static_t program_name_long; f_string_static_t setting_default; f_string_static_t path_pid; @@ -256,8 +387,8 @@ extern "C" { 0, \ 0, \ 0, \ - f_string_t_initialize, \ - f_string_t_initialize, \ + f_string_static_t_initialize, \ + f_string_static_t_initialize, \ f_string_static_t_initialize, \ f_string_static_t_initialize, \ f_color_context_t_initialize, \ diff --git a/level_3/controller/c/main.c b/level_3/controller/c/main.c index 7858f71..f1f031d 100644 --- a/level_3/controller/c/main.c +++ b/level_3/controller/c/main.c @@ -45,16 +45,13 @@ int main(const int argc, const f_string_t *argv) { #ifdef _controller_as_init_ data.program_name = controller_program_name_init_s; data.program_name_long = controller_program_name_init_long_s; - data.setting_default.string = controller_path_settings_init_s; - data.setting_default.used = controller_path_settings_init_s_length; - data.path_pid.string = controller_path_pid_init_s; - data.path_pid.used = controller_path_pid_init_s_length; + data.setting_default = controller_path_settings_init_s; + data.path_pid = controller_path_pid_init_s; data.as_init = F_true; #else data.program_name = controller_program_name_s; data.program_name_long = controller_program_name_long_s; - data.path_pid.string = controller_path_pid_s; - data.path_pid.used = controller_path_pid_s_length; + data.path_pid = controller_path_pid_s; #endif // _controller_as_init_ const f_status_t status = controller_main(&data, &arguments); diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index 6dcc56d..340010d 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -1127,7 +1127,7 @@ extern "C" { if (process->rule.items.array[i].type == controller_rule_item_type_command_e) { for (;;) { - status = controller_rule_execute_foreground(process->rule.items.array[i].type, 0, process->rule.items.array[i].actions.array[j].parameters, options, &execute_set, process); + status = controller_rule_execute_foreground(process->rule.items.array[i].type, f_string_static_empty_s, process->rule.items.array[i].actions.array[j].parameters, options, &execute_set, process); if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; @@ -1157,7 +1157,12 @@ extern "C" { for (;;) { - status = controller_rule_execute_foreground(process->rule.items.array[i].type, process->rule.script.used ? process->rule.script.string : controller_default_program_script_s, arguments_none, options, &execute_set, process); + if (process->rule.script.used) { + status = controller_rule_execute_foreground(process->rule.items.array[i].type, process->rule.script, arguments_none, options, &execute_set, process); + } + else { + status = controller_rule_execute_foreground(process->rule.items.array[i].type, controller_default_program_script_s, arguments_none, options, &execute_set, process); + } if (status == F_child || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; @@ -1186,7 +1191,7 @@ extern "C" { if (process->rule.items.array[i].pid_file.used) { for (;;) { - status = controller_rule_execute_pid_with(process->rule.items.array[i].pid_file, process->rule.items.array[i].type, 0, process->rule.items.array[i].actions.array[j].parameters, options, process->rule.items.array[i].with, &execute_set, process); + status = controller_rule_execute_pid_with(process->rule.items.array[i].pid_file, process->rule.items.array[i].type, f_string_static_empty_s, process->rule.items.array[i].actions.array[j].parameters, options, process->rule.items.array[i].with, &execute_set, process); if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; @@ -1224,7 +1229,7 @@ extern "C" { for (;;) { - status = controller_rule_execute_pid_with(process->rule.items.array[i].pid_file, process->rule.items.array[i].type, process->rule.script.used ? process->rule.script.string : controller_default_program_script_s, arguments_none, options, process->rule.items.array[i].with, &execute_set, process); + status = controller_rule_execute_pid_with(process->rule.items.array[i].pid_file, process->rule.items.array[i].type, process->rule.script.used ? process->rule.script : controller_default_program_script_s, arguments_none, options, process->rule.items.array[i].with, &execute_set, process); if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; @@ -1314,7 +1319,7 @@ extern "C" { #endif // _di_controller_rule_execute_ #ifndef _di_controller_rule_execute_foreground_ - f_status_t controller_rule_execute_foreground(const uint8_t type, const f_string_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_process_t * const process) { + 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_process_t * const process) { f_status_t status = F_none; f_status_t status_lock = F_none; @@ -1357,8 +1362,8 @@ extern "C" { fl_print_format("%cSimulating execution of '%[", main->output.to.stream, f_string_eol_s[0], main->context.set.title); - if (program) { - f_print_safely_terminated(program, main->output.to.stream); + if (program.used) { + f_print_dynamic_safely(program, main->output.to.stream); } else { f_print_dynamic_safely(arguments.array[0], main->output.to.stream); @@ -1366,9 +1371,9 @@ extern "C" { fl_print_format("%]' with the arguments: '%[", main->output.to.stream, main->context.set.title, main->context.set.important); - for (f_array_length_t i = program ? 0 : 1; i < arguments.used; ++i) { + for (f_array_length_t i = program.used ? 0 : 1; i < arguments.used; ++i) { - if (program && i || !program && i > 1) { + if (program.used && i || !program.used && i > 1) { f_print_terminated(f_string_space_s, main->output.to.stream); } @@ -1395,11 +1400,11 @@ extern "C" { const f_string_statics_t simulated_arguments = f_string_statics_t_initialize; fl_execute_parameter_t simulated_parameter = macro_fl_execute_parameter_t_initialize(execute_set->parameter.option, execute_set->parameter.wait, process->rule.has & controller_rule_has_environment_d ? execute_set->parameter.environment : 0, execute_set->parameter.signals, &simulated_program); - status = fll_execute_program(controller_default_program_script_s, simulated_arguments, &simulated_parameter, &execute_set->as, (void *) &result); + status = fll_execute_program(controller_default_program_script_s.string, simulated_arguments, &simulated_parameter, &execute_set->as, (void *) &result); } } else { - status = fll_execute_program(program, arguments, &execute_set->parameter, &execute_set->as, (void *) &result); + status = fll_execute_program(program.string, arguments, &execute_set->parameter, &execute_set->as, (void *) &result); } if (status == F_parent) { @@ -1518,7 +1523,7 @@ extern "C" { status = F_status_set_fine(status); if ((WIFEXITED(process->result) && WEXITSTATUS(process->result)) || status == F_control_group || status == F_failure || status == F_limit || status == F_processor || status == F_schedule) { - controller_rule_item_print_error_execute(type == controller_rule_item_type_script_e, program ? program : arguments.used ? arguments.array[0].string : f_string_empty_s, status, process); + controller_rule_item_print_error_execute(type == controller_rule_item_type_script_e, program.used ? program : arguments.array[0], status, process); } else { controller_print_error(thread, main->error, F_status_set_fine(status), "fll_execute_program", F_true); @@ -1532,7 +1537,7 @@ extern "C" { #endif // _di_controller_rule_execute_foreground_ #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_t program, const f_string_statics_t arguments, const uint8_t options, const uint8_t with, controller_execute_set_t * const execute_set, controller_process_t * const process) { + 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_process_t * const process) { f_status_t status = F_none; f_status_t status_lock = F_none; @@ -1613,8 +1618,8 @@ extern "C" { fl_print_format("%cSimulating execution of '%[", main->error.to.stream, f_string_eol_s[0], main->context.set.title); - if (program) { - f_print_safely_terminated(program, main->error.to.stream); + if (program.used) { + f_print_dynamic_safely(program, main->error.to.stream); } else { f_print_dynamic_safely(arguments.array[0], main->error.to.stream); @@ -1622,9 +1627,9 @@ extern "C" { fl_print_format("%]' with the arguments: '%[", main->error.to.stream, main->context.set.title, main->context.set.important); - for (f_array_length_t i = program ? 0 : 1; i < arguments.used; ++i) { + for (f_array_length_t i = program.used ? 0 : 1; i < arguments.used; ++i) { - if (program && i || !program && i > 1) { + if (program.used && i || !program.used && i > 1) { f_print_terminated(f_string_space_s, main->error.to.stream); } @@ -1651,11 +1656,11 @@ extern "C" { const f_string_statics_t simulated_arguments = f_string_statics_t_initialize; fl_execute_parameter_t simulated_parameter = macro_fl_execute_parameter_t_initialize(execute_set->parameter.option, execute_set->parameter.wait, process->rule.has & controller_rule_has_environment_d ? execute_set->parameter.environment : 0, execute_set->parameter.signals, &simulated_program); - status = fll_execute_program(controller_default_program_script_s, simulated_arguments, &simulated_parameter, &execute_set->as, (void *) &result); + status = fll_execute_program(controller_default_program_script_s.string, simulated_arguments, &simulated_parameter, &execute_set->as, (void *) &result); } } else { - status = fll_execute_program(program, arguments, &execute_set->parameter, &execute_set->as, (void *) &result); + status = fll_execute_program(program.string, arguments, &execute_set->parameter, &execute_set->as, (void *) &result); } if (status == F_parent) { @@ -1774,7 +1779,7 @@ extern "C" { status = F_status_set_fine(status); if ((WIFEXITED(process->result) && WEXITSTATUS(process->result)) || status == F_control_group || status == F_failure || status == F_limit || status == F_processor || status == F_schedule) { - controller_rule_item_print_error_execute(type == controller_rule_item_type_utility_e, program ? program : arguments.used ? arguments.array[0].string : f_string_empty_s, status, process); + controller_rule_item_print_error_execute(type == controller_rule_item_type_utility_e, program.used ? program : arguments.array[0], status, process); } else { controller_print_error(thread, main->error, F_status_set_fine(status), "fll_execute_program", F_true); diff --git a/level_3/controller/c/rule/private-rule.h b/level_3/controller/c/rule/private-rule.h index a5f19a9..1a712ea 100644 --- a/level_3/controller/c/rule/private-rule.h +++ b/level_3/controller/c/rule/private-rule.h @@ -267,7 +267,7 @@ extern "C" { * @see fll_execute_program() */ #ifndef _di_controller_rule_execute_foreground_ - extern f_status_t controller_rule_execute_foreground(const uint8_t type, const f_string_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_process_t * const process) F_attribute_visibility_internal_d; + extern f_status_t controller_rule_execute_foreground(const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_process_t * const process) F_attribute_visibility_internal_d; #endif // _di_controller_rule_execute_foreground_ /** @@ -309,7 +309,7 @@ extern "C" { * @see fll_execute_program() */ #ifndef _di_controller_rule_execute_pid_with_ - extern f_status_t controller_rule_execute_pid_with(const f_string_dynamic_t pid_file, const uint8_t type, const f_string_t program, const f_string_statics_t arguments, const uint8_t options, const uint8_t with, controller_execute_set_t * const execute_set, controller_process_t * const process) F_attribute_visibility_internal_d; + extern f_status_t controller_rule_execute_pid_with(const f_string_dynamic_t pid_file, const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, const uint8_t with, controller_execute_set_t * const execute_set, controller_process_t * const process) F_attribute_visibility_internal_d; #endif // _di_controller_rule_execute_pid_with_ /** diff --git a/level_3/controller/c/rule/private-rule_print.c b/level_3/controller/c/rule/private-rule_print.c index f12909c..b15b961 100644 --- a/level_3/controller/c/rule/private-rule_print.c +++ b/level_3/controller/c/rule/private-rule_print.c @@ -75,7 +75,7 @@ extern "C" { #endif // _di_controller_rule_item_print_error_ #ifndef _di_controller_rule_item_print_error_execute_ - void controller_rule_item_print_error_execute(const bool script_is, const f_string_t name, const f_status_t status, controller_process_t * const process) { + void controller_rule_item_print_error_execute(const bool script_is, const f_string_static_t name, const f_status_t status, controller_process_t * const process) { if (((controller_main_t *) process->main_data)->error.verbosity != f_console_verbosity_quiet_e) { fl_print_t * const print = &((controller_main_t *) process->main_data)->error; @@ -83,7 +83,7 @@ extern "C" { controller_lock_print(print->to, (controller_thread_t *) process->main_thread); fl_print_format("%c%[%SThe %s '%]", print->to.stream, f_string_eol_s[0], print->context, print->prefix, script_is ? controller_script_s : controller_program_s, print->context); - fl_print_format("%[%S%]", print->to.stream, print->notable, name, print->notable); + fl_print_format("%[%Q%]", print->to.stream, print->notable, name, print->notable); if (status == F_control_group || status == F_limit || status == F_processor || status == F_schedule) { fl_print_format("%[' failed due to a failure to setup the '%]%[", print->to.stream, print->context, print->context, print->notable); diff --git a/level_3/controller/c/rule/private-rule_print.h b/level_3/controller/c/rule/private-rule_print.h index 144642a..ae7080e 100644 --- a/level_3/controller/c/rule/private-rule_print.h +++ b/level_3/controller/c/rule/private-rule_print.h @@ -106,7 +106,7 @@ extern "C" { * The process to use. */ #ifndef _di_controller_rule_item_print_error_execute_ - extern void controller_rule_item_print_error_execute(const bool script_is, const f_string_t name, const f_status_t status, controller_process_t * const process) F_attribute_visibility_internal_d; + extern void controller_rule_item_print_error_execute(const bool script_is, const f_string_static_t name, const f_status_t status, controller_process_t * const process) F_attribute_visibility_internal_d; #endif // _di_controller_rule_item_print_error_execute_ /** diff --git a/level_3/controller/data/build/defines b/level_3/controller/data/build/defines index 2d347d1..5f948c4 100644 --- a/level_3/controller/data/build/defines +++ b/level_3/controller/data/build/defines @@ -4,9 +4,20 @@ _di_libcap_ Disable libcap support, allow for compiling and linking without libc _libcap_legacy_only_ Disable functionality provided by later versions of libcap (2.43 and later). _controller_as_init_ Build the program to run as if it were "init" by default, including displaying the program name as "Init Program" or "Init". This changes the main.c file only, leaving the library shareable between both "controller" and "init". _override_controller_default_program_script_ Provide a custom script name string to execute (such as php). -_override_controller_path_pid_init_ Provide a custom init path for the system rather than the default. +_override_controller_default_program_script_length_ The number of bytes representing the string in _override_controller_default_program_script_ (not including the terminating NULL). +_override_controller_name_socket_ Use this as the default custom file name representing the controller program socket. +_override_controller_name_socket_length_ The number of bytes representing the string in _override_controller_name_socket_ (not including the terminating NULL). +_override_controller_path_pid_init_ Provide a custom init path for the pid file rather than the default. _override_controller_path_pid_init_length_ The number of bytes representing the string in _override_controller_path_pid_init_ (not including the terminating NULL). -_override_controller_path_settings_init_ Provide a custom init path for the system rather than the default. +_override_controller_path_settings_init_ Provide a custom init path for the settings file rather than the default. _override_controller_path_settings_init_length_ The number of bytes representing the string in _override_controller_path_settings_init_ (not including the terminating NULL). +_override_controller_path_socket_ Use this as the default custom directory path representing the location of the controller program socket. +_override_controller_path_socket_init_ Provide a custom init path for the socket file rather than the default. +_override_controller_path_socket_init_length_ The number of bytes representing the string in _override_controller_path_socket_init_ (not including the terminating NULL). +_override_controller_path_socket_length_ The number of bytes representing the string in _override_controller_path_socket_ (not including the terminating NULL). +_override_controller_path_socket_prefix_ Use this as the default custom prefix prepended to the file name of the file representing the controller program socket. +_override_controller_path_socket_prefix_length_ The number of bytes representing the string in _override_controller_path_socket_prefix_ (not including the terminating NULL). +_override_controller_path_socket_suffix_ Use this as the default custom prefix prepended to the file name of the file representing the controller program socket. +_override_controller_path_socket_suffix_length_ The number of bytes representing the string in _override_controller_path_socket_suffix_ (not including the terminating NULL). _pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. _pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_3/controller/data/settings/example/entries/up.entry b/level_3/controller/data/settings/example/entries/up.entry new file mode 100644 index 0000000..03793e5 --- /dev/null +++ b/level_3/controller/data/settings/example/entries/up.entry @@ -0,0 +1,9 @@ +# fss-0005 + +main: + failsafe maintenance + + ready + +maintenance: + start maintenance boom -- 1.8.3.1