From: Kevin Day Date: Thu, 4 Apr 2024 03:20:54 +0000 (-0500) Subject: Progress: Begin migrating the project, doing some initial preparations. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=2ace4fc71edbb99ae99e72a1c623aa949fcc63bd;p=controller Progress: Begin migrating the project, doing some initial preparations. Tweak the fakefile structure. Remove the "as_init" fakefile mode. Use library instead of object so that both controller and init may use the same library. I may want to create a custon "init only" mode where init uses libinit.so rather than libcontroller.so. Have the build settings pass "-D_controller_as_init_" directly for the init fakefile. Add the child process exit code. I may end up changing this again, but I wanted to start off very consistent with other projects design. Finish the help printing process. The program name is moved into the specific programs. Add missing control group header file include. Fix a mistake whee the main thread signal function is calling itself rather than the main signal handler. This bad behavior results in a segfault. --- diff --git a/data/build/fakefile b/data/build/fakefile index 1de733a..2c64009 100644 --- a/data/build/fakefile +++ b/data/build/fakefile @@ -12,11 +12,11 @@ main: build settings.controller build settings.init -build_controller: +main_controller: build settings build settings.controller -build_init: +main_init: build settings build settings.init @@ -35,17 +35,17 @@ install_init: help: print - print context:'title'Fakefile Options for Controller Program.context:'reset' + print context:'title'Fakefile Options for the Controller and the Init Programs.context:'reset' print print The following operations are available\: print " - context:'notable'help:context:'reset' Perform the help operation, printing this message." - print " - context:'notable'build_controller:context:'reset' Compilation using the build settings mode for the controller program." - print " - context:'notable'build_init:context:'reset' Compilation using the build settings mode for the init program." - print " - context:'notable'install:context:'reset' A helper operation that simply calls the ./install.sh script with default settings." - print " - context:'notable'install_controller:context:'reset' A helper operation that simply calls the ./install.sh script with default settings." - print " - context:'notable'install_init:context:'reset' A helper operation that simply calls the ./install.sh script with default settings." - print " - context:'notable'main:context:'reset' The default compilation using the build settings mode." + print " - context:'notable'install:context:'reset' A helper operation that calls the ./install.sh script for both the controller and init programs." + print " - context:'notable'install_controller:context:'reset' A helper operation that calls the ./install.sh script for the controller program." + print " - context:'notable'install_init:context:'reset' A helper operation that calls the ./install.sh script for the init program." + print " - context:'notable'main:context:'reset' Compilation using the build settings mode for both the controller and init programs (default)." + print " - context:'notable'main_controller:context:'reset' Compilation using the build settings mode for the controller program." + print " - context:'notable'main_init:context:'reset' Compilation using the build settings mode for the init program." print print The context:'notable'install context:'reset'operation supports the context:'notable'work,context:'reset' context:'notable'verbosity,context:'reset' and context:'notable'color context:'reset'parameters. diff --git a/data/build/settings b/data/build/settings index d074de0..592c2c8 100644 --- a/data/build/settings +++ b/data/build/settings @@ -22,7 +22,7 @@ version_micro 0 version_file micro version_target minor -modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless as_init +modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless modes_default monolithic thread gcc build_compiler gcc @@ -40,9 +40,9 @@ build_libraries-individual_thread -lf_thread build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_object 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_object main/print/data.c main/print/debug.c main/print/error.c main/print/message.c main/print/verbose.c main/print/warning.c -build_sources_object main/signal.c main/thread.c +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/print/data.c main/print/debug.c main/print/error.c main/print/message.c main/print/verbose.c main/print/warning.c +build_sources_library main/signal.c main/thread.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/type.h build_sources_headers main/print/data.h main/print/debug.h main/print/error.h main/print/message.h main/print/verbose.h main/print/warning.h @@ -81,7 +81,6 @@ environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY L defines -D_libcap_legacy_only_ defines-threadless -D_di_thread_support_ defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ -defines-as_init -D_controller_as_init_ flags -O2 -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces flags -fstack-clash-protection -fno-delete-null-pointer-checks diff --git a/data/build/settings.controller b/data/build/settings.controller index 6330ad0..faaae85 100644 --- a/data/build/settings.controller +++ b/data/build/settings.controller @@ -22,7 +22,7 @@ version_micro 0 version_file micro version_target minor -modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless as_init +modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless modes_default monolithic thread gcc build_compiler gcc @@ -31,7 +31,7 @@ build_indexer ar build_indexer_arguments rcs build_language c -build_libraries -lc -lcap +build_libraries -lc -lcap -lcontroller build_libraries-individual -lfll_control_group -lfll_error -lfll_execute -lfll_fss -lfll_print -lfll_program -lfll_status_string build_libraries-individual_thread -lf_thread build_libraries-individual -lfl_control_group -lfl_conversion -lfl_directory -lfl_environment -lfl_fss -lfl_iki -lfl_path -lfl_print @@ -40,15 +40,9 @@ build_libraries-individual_thread -lf_thread build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_objects_library main/common.o main/common/define.o main/common/enumeration.o main/common/print.o main/common/string.o main/common/type.o -build_objects_library main/print/data.o main/print/debug.o main/print/error.o main/print/message.o main/print/verbose.o main/print/warning.o -build_objects_library main/signal.o main/thread.o +build_sources_program controller/config.c controller/main.c controller/controller.c controller/string.c -build_sources_library controller/controller.c - -build_sources_program controller/config.c controller/main.c - -build_sources_headers controller/controller.h +build_sources_headers controller/controller.h controller/string.h build_sources_documentation man @@ -83,7 +77,6 @@ environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY L defines -D_libcap_legacy_only_ defines-threadless -D_di_thread_support_ defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ -defines-as_init -D_controller_as_init_ flags -O2 -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces flags -fstack-clash-protection -fno-delete-null-pointer-checks diff --git a/data/build/settings.init b/data/build/settings.init index ed9ae18..71b4b1a 100644 --- a/data/build/settings.init +++ b/data/build/settings.init @@ -22,7 +22,7 @@ version_micro 0 version_file micro version_target minor -modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless as_init +modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless modes_default monolithic thread gcc build_compiler gcc @@ -31,7 +31,7 @@ build_indexer ar build_indexer_arguments rcs build_language c -build_libraries -lc -lcap +build_libraries -lc -lcap -lcontroller build_libraries-individual -lfll_control_group -lfll_error -lfll_execute -lfll_fss -lfll_print -lfll_program -lfll_status_string build_libraries-individual_thread -lf_thread build_libraries-individual -lfl_control_group -lfl_conversion -lfl_directory -lfl_environment -lfl_fss -lfl_iki -lfl_path -lfl_print @@ -40,15 +40,9 @@ build_libraries-individual_thread -lf_thread build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_objects_library main/common.o main/common/define.o main/common/enumeration.o main/common/print.o main/common/string.o main/common/type.o -build_objects_library main/print/data.o main/print/debug.o main/print/error.o main/print/message.o main/print/verbose.o main/print/warning.o -build_objects_library main/signal.o main/thread.o +build_sources_program init/config.c init/main.c init/init.c init/string.c -build_sources_library init/init.c - -build_sources_program init/config.c init/main.c - -build_sources_headers init/init.h +build_sources_headers init/init.h init/string.h build_sources_documentation man @@ -80,10 +74,9 @@ environment PATH LD_LIBRARY_PATH environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH #defines -D_di_libcap_ -defines -D_libcap_legacy_only_ +defines -D_controller_as_init_ -D_libcap_legacy_only_ defines-threadless -D_di_thread_support_ defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ -defines-as_init -D_controller_as_init_ flags -O2 -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces flags -fstack-clash-protection -fno-delete-null-pointer-checks diff --git a/sources/c/controller/controller.c b/sources/c/controller/controller.c index a74c3a8..a22a8ee 100644 --- a/sources/c/controller/controller.c +++ b/sources/c/controller/controller.c @@ -25,7 +25,7 @@ extern "C" { if (main->setting.flag & controller_main_flag_version_copyright_help_e) { if (main->setting.flag & controller_main_flag_help_e) { - controller_main_print_message_help(&main->program.message); + controller_main_print_message_help(&main->program.message, F_false); } else if (main->setting.flag & controller_main_flag_version_e) { fll_program_print_version(&main->program.message, controller_program_version_s); diff --git a/sources/c/controller/controller.h b/sources/c/controller/controller.h index 65b6fa7..db61552 100644 --- a/sources/c/controller/controller.h +++ b/sources/c/controller/controller.h @@ -61,6 +61,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/sources/c/controller/main.c b/sources/c/controller/main.c index 935616e..2d413c6 100644 --- a/sources/c/controller/main.c +++ b/sources/c/controller/main.c @@ -15,8 +15,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; - data.setting.program_name = &controller_program_name_s; - data.setting.program_name_long = &controller_program_name_long_s; + data.setting.program_name = &controller_controller_program_name_s; + data.setting.program_name_long = &controller_controller_program_name_long_s; f_console_parameter_t parameters[] = controller_console_parameter_t_initialize; @@ -72,5 +72,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { fll_program_standard_set_down(&data.program); + if (data.setting.state.status == F_child) { + exit(data.program.child); + } + return (F_status_is_error(data.setting.state.status) || data.setting.state.status == F_false) ? 1 : 0; } diff --git a/sources/c/controller/string.c b/sources/c/controller/string.c new file mode 100644 index 0000000..c7b2c2b --- /dev/null +++ b/sources/c/controller/string.c @@ -0,0 +1,14 @@ +#include "controller.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_controller_controller_program_name_s_ + const f_string_static_t controller_controller_program_name_s = macro_f_string_static_t_initialize_1(CONTROLLER_controller_program_name_s, 0, CONTROLLER_controller_program_name_s_length); + const f_string_static_t controller_controller_program_name_long_s = macro_f_string_static_t_initialize_1(CONTROLLER_controller_program_name_long_s, 0, CONTROLLER_controller_program_name_long_s_length); +#endif // _di_controller_controller_program_name_s_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/controller/string.h b/sources/c/controller/string.h new file mode 100644 index 0000000..ab36bb1 --- /dev/null +++ b/sources/c/controller/string.h @@ -0,0 +1,37 @@ +/** + * FLL - Level 3 + * + * Project: Controller + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common string structures for the controller program. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _controller_controller_string_h +#define _controller_controller_string_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The program name. + */ +#ifndef _di_controller_controller_program_name_s_ + #define CONTROLLER_controller_program_name_s "controller" + #define CONTROLLER_controller_program_name_long_s "Controller" + + #define CONTROLLER_controller_program_name_s_length 10 + #define CONTROLLER_controller_program_name_long_s_length 10 + + extern const f_string_static_t controller_controller_program_name_s; + extern const f_string_static_t controller_controller_program_name_long_s; +#endif // _di_controller_controller_program_name_s_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _controller_controller_string_h diff --git a/sources/c/init/init.c b/sources/c/init/init.c index 7a62eee..a040e13 100644 --- a/sources/c/init/init.c +++ b/sources/c/init/init.c @@ -25,7 +25,7 @@ extern "C" { if (main->setting.flag & controller_main_flag_version_copyright_help_e) { if (main->setting.flag & controller_main_flag_help_e) { - controller_main_print_message_help(&main->program.message); + controller_main_print_message_help(&main->program.message, F_true); } else if (main->setting.flag & controller_main_flag_version_e) { fll_program_print_version(&main->program.message, controller_program_version_s); diff --git a/sources/c/init/init.h b/sources/c/init/init.h index aa55eca..5e4d01d 100644 --- a/sources/c/init/init.h +++ b/sources/c/init/init.h @@ -61,6 +61,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/sources/c/init/main.c b/sources/c/init/main.c index 5c5003a..fc670d3 100644 --- a/sources/c/init/main.c +++ b/sources/c/init/main.c @@ -15,8 +15,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; - data.setting.program_name = &controller_program_name_s; - data.setting.program_name_long = &controller_program_name_long_s; + data.setting.program_name = &controller_init_program_name_s; + data.setting.program_name_long = &controller_init_program_name_long_s; f_console_parameter_t parameters[] = controller_console_parameter_t_initialize; @@ -72,5 +72,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { fll_program_standard_set_down(&data.program); + if (data.setting.state.status == F_child) { + exit(data.program.child); + } + return (F_status_is_error(data.setting.state.status) || data.setting.state.status == F_false) ? 1 : 0; } diff --git a/sources/c/init/string.c b/sources/c/init/string.c new file mode 100644 index 0000000..ff1fd9e --- /dev/null +++ b/sources/c/init/string.c @@ -0,0 +1,14 @@ +#include "init.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_controller_init_program_name_s_ + const f_string_static_t controller_init_program_name_s = macro_f_string_static_t_initialize_1(CONTROLLER_init_program_name_s, 0, CONTROLLER_init_program_name_s_length); + const f_string_static_t controller_init_program_name_long_s = macro_f_string_static_t_initialize_1(CONTROLLER_init_program_name_long_s, 0, CONTROLLER_init_program_name_long_s_length); +#endif // _di_controller_init_program_name_s_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/init/string.h b/sources/c/init/string.h new file mode 100644 index 0000000..5f8e82d --- /dev/null +++ b/sources/c/init/string.h @@ -0,0 +1,37 @@ +/** + * FLL - Level 3 + * + * Project: Controller + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common string structures for the init program. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _controller_init_string_h +#define _controller_init_string_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The program name. + */ +#ifndef _di_controller_init_program_name_s_ + #define CONTROLLER_init_program_name_s "init" + #define CONTROLLER_init_program_name_long_s "Init" + + #define CONTROLLER_init_program_name_s_length 4 + #define CONTROLLER_init_program_name_long_s_length 4 + + extern const f_string_static_t controller_init_program_name_s; + extern const f_string_static_t controller_init_program_name_long_s; +#endif // _di_controller_init_program_name_s_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _controller_init_string_h diff --git a/sources/c/main/common/enumeration.h b/sources/c/main/common/enumeration.h index 19b272b..fedbd4d 100644 --- a/sources/c/main/common/enumeration.h +++ b/sources/c/main/common/enumeration.h @@ -62,10 +62,19 @@ extern "C" { { \ macro_fll_program_console_parameter_standard_initialize, \ \ - macro_f_console_parameter_t_initialize_3(controller_short_controller_s, controller_long_controller_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(controller_short_cgroup_s, controller_long_cgroup_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(controller_short_daemon_s, controller_long_daemon_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(controller_short_init_s, controller_long_init_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(controller_short_interruptible_s, controller_long_interruptible_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(controller_short_pid_s, controller_long_pid_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(controller_short_settings_s, controller_long_settings_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(controller_short_simulate_s, controller_long_simulate_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(controller_short_socket_s, controller_long_socket_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(controller_short_uninterruptible_s, controller_long_uninterruptible_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(controller_short_validate_s, controller_long_validate_s, 0, f_console_flag_normal_e), \ } - #define controller_parameter_total_d (f_console_parameter_state_type_total_d + 1) + #define controller_parameter_total_d (f_console_parameter_state_type_total_d + 10) #endif // _di_controller_parameter_e_ /** diff --git a/sources/c/main/common/string.c b/sources/c/main/common/string.c index f69607d..8630663 100644 --- a/sources/c/main/common/string.c +++ b/sources/c/main/common/string.c @@ -8,15 +8,28 @@ extern "C" { const f_string_static_t controller_program_version_s = macro_f_string_static_t_initialize_1(CONTROLLER_program_version_s, 0, CONTROLLER_program_version_s_length); #endif // _di_controller_program_version_s_ -#ifndef _di_controller_program_name_s_ - const f_string_static_t controller_program_name_s = macro_f_string_static_t_initialize_1(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_initialize_1(CONTROLLER_program_name_long_s, 0, CONTROLLER_program_name_long_s_length); -#endif // _di_controller_program_name_s_ - #ifndef _di_controller_parameter_s_ - const f_string_static_t controller_short_controller_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_controller_s, 0, CONTROLLER_short_controller_s_length); + const f_string_static_t controller_short_cgroup_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_cgroup_s, 0, CONTROLLER_short_cgroup_s_length); + const f_string_static_t controller_short_daemon_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_daemon_s, 0, CONTROLLER_short_daemon_s_length); + const f_string_static_t controller_short_init_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_init_s, 0, CONTROLLER_short_init_s_length); + const f_string_static_t controller_short_interruptible_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_interruptible_s, 0, CONTROLLER_short_interruptible_s_length); + const f_string_static_t controller_short_pid_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_pid_s, 0, CONTROLLER_short_pid_s_length); + const f_string_static_t controller_short_settings_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_settings_s, 0, CONTROLLER_short_settings_s_length); + const f_string_static_t controller_short_simulate_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_simulate_s, 0, CONTROLLER_short_simulate_s_length); + const f_string_static_t controller_short_socket_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_socket_s, 0, CONTROLLER_short_socket_s_length); + const f_string_static_t controller_short_uninterruptible_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_uninterruptible_s, 0, CONTROLLER_short_uninterruptible_s_length); + const f_string_static_t controller_short_validate_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_validate_s, 0, CONTROLLER_short_validate_s_length); - const f_string_static_t controller_long_controller_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_controller_s, 0, CONTROLLER_long_controller_s_length); + const f_string_static_t controller_long_cgroup_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_cgroup_s, 0, CONTROLLER_long_cgroup_s_length); + const f_string_static_t controller_long_daemon_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_daemon_s, 0, CONTROLLER_long_daemon_s_length); + const f_string_static_t controller_long_init_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_init_s, 0, CONTROLLER_long_init_s_length); + const f_string_static_t controller_long_interruptible_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_interruptible_s, 0, CONTROLLER_long_interruptible_s_length); + const f_string_static_t controller_long_pid_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_pid_s, 0, CONTROLLER_long_pid_s_length); + const f_string_static_t controller_long_settings_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_settings_s, 0, CONTROLLER_long_settings_s_length); + const f_string_static_t controller_long_simulate_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_simulate_s, 0, CONTROLLER_long_simulate_s_length); + const f_string_static_t controller_long_socket_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_socket_s, 0, CONTROLLER_long_socket_s_length); + const f_string_static_t controller_long_uninterruptible_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_uninterruptible_s, 0, CONTROLLER_long_uninterruptible_s_length); + const f_string_static_t controller_long_validate_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_validate_s, 0, CONTROLLER_long_validate_s_length); #endif // _di_controller_parameter_s_ #ifdef __cplusplus diff --git a/sources/c/main/common/string.h b/sources/c/main/common/string.h index fff2a1e..5d2ea63 100644 --- a/sources/c/main/common/string.h +++ b/sources/c/main/common/string.h @@ -46,34 +46,74 @@ extern "C" { #endif // _di_controller_program_version_s_ /** - * The program name. - */ -#ifndef _di_controller_program_name_s_ - #define CONTROLLER_program_name_s "controller" - #define CONTROLLER_program_name_long_s "Controller" - - #define CONTROLLER_program_name_s_length 10 - #define CONTROLLER_program_name_long_s_length 10 - - extern const f_string_static_t controller_program_name_s; - extern const f_string_static_t controller_program_name_long_s; -#endif // _di_controller_program_name_s_ - -/** * The main program parameters. */ #ifndef _di_controller_parameter_s_ - #define CONTROLLER_short_controller_s "e" - - #define CONTROLLER_long_controller_s "controller" - - #define CONTROLLER_short_controller_s_length 1 - - #define CONTROLLER_long_controller_s_length 7 - - extern const f_string_static_t controller_short_controller_s; - - extern const f_string_static_t controller_long_controller_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_socket_s "k" + #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_socket_s "socket" + #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_socket_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_socket_s_length 6 + #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_socket_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_socket_s; + extern const f_string_static_t controller_long_uninterruptible_s; + extern const f_string_static_t controller_long_validate_s; #endif // _di_controller_parameter_s_ #ifdef __cplusplus diff --git a/sources/c/main/common/type.h b/sources/c/main/common/type.h index 4a9bd23..5f59d74 100644 --- a/sources/c/main/common/type.h +++ b/sources/c/main/common/type.h @@ -42,6 +42,9 @@ extern "C" { * * status_signal: A status used eclusively by the threaded signal handler. * state: The state data used when processing the FSS data. + * + * program_name: The short program name. + * program_name_long: The long program name. */ #ifndef _di_controller_setting_t_ typedef struct { diff --git a/sources/c/main/controller.h b/sources/c/main/controller.h index 16e3257..5edeb9c 100644 --- a/sources/c/main/controller.h +++ b/sources/c/main/controller.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/sources/c/main/print/message.c b/sources/c/main/print/message.c index 1a2a127..42f1e77 100644 --- a/sources/c/main/print/message.c +++ b/sources/c/main/print/message.c @@ -5,23 +5,41 @@ extern "C" { #endif #ifndef _di_controller_main_print_message_help_ - f_status_t controller_main_print_message_help(fl_print_t * const print) { + f_status_t controller_main_print_message_help(fl_print_t * const print, const uint8_t uninterrupt) { - if (!print) return F_status_set_error(F_output_not); + if (!print || !print->custom) return F_status_set_error(F_output_not); + + controller_main_t * const main = (controller_main_t *) print->custom; f_file_stream_lock(print->to); - fll_program_print_help_header(print, controller_program_name_long_s, controller_program_version_s); + fll_program_print_help_header(print, *main->setting.program_name_long, controller_program_version_s); fll_program_print_help_option_standard(print); f_print_dynamic_raw(f_string_eol_s, print->to); - fll_program_print_help_option(print, controller_short_controller_s, controller_long_controller_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "This is an controller program parameter."); + fll_program_print_help_option(print, controller_short_cgroup_s, controller_long_cgroup_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_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(print, controller_short_daemon_s, controller_long_daemon_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Run in daemon only mode (do not process the entry)."); + fll_program_print_help_option(print, controller_short_init_s, controller_long_init_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " The program will run as an init replacement."); + fll_program_print_help_option(print, controller_short_interruptible_s, controller_long_interruptible_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Designate that this program can be interrupted by a signal."); + fll_program_print_help_option(print, controller_short_pid_s, controller_long_pid_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Specify a custom pid file path, such as 'controller/run/default.pid'."); + fll_program_print_help_option(print, controller_short_settings_s, controller_long_settings_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Specify a custom settings path, such as 'controller/'."); + fll_program_print_help_option(print, controller_short_simulate_s, controller_long_simulate_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Run as a simulation."); + fll_program_print_help_option(print, controller_short_socket_s, controller_long_socket_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Specify a custom socket file path, such as 'controller/run/default.socket'."); + fll_program_print_help_option(print, controller_short_uninterruptible_s, controller_long_uninterruptible_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Designate that this program cannot be interrupted by a signal."); + fll_program_print_help_option(print, controller_short_validate_s, controller_long_validate_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Validate the settings (entry and rules) without running (does not simulate)."); f_print_dynamic_raw(f_string_eol_s, print->to); - fll_program_print_help_usage(print, controller_program_name_s, f_string_empty_s); + fll_program_print_help_usage(print, *main->setting.program_name, f_string_empty_s); + + fl_print_format("%r When both the %[%r%r%] parameter and the", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, controller_long_simulate_s, print->set->notable); + fl_print_format(" %[%r%r%] parameter are specified, then additional information on each would be executed rule is printed but no simulation is performed.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, controller_long_validate_s, print->set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The default interrupt behavior is to operate as if the %[%r%r%] parameter is passed.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, uninterrupt ? controller_long_uninterruptible_s : controller_long_interruptible_s, print->set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" Specify an empty string for the %[%r%r%] parameter to disable pid file creation for this program.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, controller_long_pid_s, print->set->notable, f_string_eol_s); f_file_stream_flush(print->to); f_file_stream_unlock(print->to); diff --git a/sources/c/main/print/message.h b/sources/c/main/print/message.h index 3be5523..c215bb0 100644 --- a/sources/c/main/print/message.h +++ b/sources/c/main/print/message.h @@ -25,6 +25,9 @@ extern "C" { * This requires print.custom to be controller_main_t. * * This does not alter print.custom.setting.state.status. + * @param uninterrupt + * Set to F_true to print that the default behavior is uninterruptible. + * Otherwise, print that the default behavior is interruptible. * * @return * F_okay on success. @@ -41,7 +44,7 @@ extern "C" { * @see fll_program_print_help_usage() */ #ifndef _di_controller_main_print_message_help_ - extern f_status_t controller_main_print_message_help(fl_print_t * const print); + extern f_status_t controller_main_print_message_help(fl_print_t * const print, const uint8_t uninterrupt); #endif // _di_controller_main_print_message_help_ #ifdef __cplusplus diff --git a/sources/c/main/thread.c b/sources/c/main/thread.c index 12af9a7..2214fb7 100644 --- a/sources/c/main/thread.c +++ b/sources/c/main/thread.c @@ -10,7 +10,7 @@ extern "C" { f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0); if (main) { - controller_main_thread_signal((controller_main_t *) main); + controller_main_signal_handler((controller_main_t *) main); } return 0;