From de8b65092ab9ca809709c0e0066d967f891c4182 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 17 Mar 2022 21:56:39 -0500 Subject: [PATCH] Cleanup: Restructure to have the *_type_name() functions into public functions under common.h or similar. Have the programs expose these functions to the public API. The enumerations, consequently must also be exposed publicly. --- level_3/control/c/common.h | 56 ++++++- level_3/control/c/private-common.h | 46 ------ level_3/controller/c/common.c | 223 +++++++++++++++++++++++++++ level_3/controller/c/common.h | 153 +++++++++++++++++- level_3/controller/c/common/private-common.h | 26 ---- level_3/controller/c/common/private-entry.h | 18 --- level_3/controller/c/common/private-rule.h | 8 - level_3/controller/c/entry/private-entry.c | 54 ------- level_3/controller/c/entry/private-entry.h | 14 -- level_3/controller/c/rule/private-rule.c | 177 --------------------- level_3/controller/c/rule/private-rule.h | 57 ------- 11 files changed, 426 insertions(+), 406 deletions(-) diff --git a/level_3/control/c/common.h b/level_3/control/c/common.h index 02261fa..61225e2 100644 --- a/level_3/control/c/common.h +++ b/level_3/control/c/common.h @@ -131,26 +131,74 @@ extern "C" { #endif // _di_control_parameters_ /** - * Get the name of the action type. + * Codes representing supported actions. + * + * freeze: Perform the freeze controller operation. + * kill: Perform the kill controller operation. + * pause: Perform the pause controller operation. + * reboot: Perform the reboot controller operation (only for init mode). + * reload: Perform the reload controller operation. + * rerun: Perform the rerun controller operation. + * restart: Perform the restart controller operation. + * resume: Perform the resume controller operation. + * shutdown: Perform the shutdown controller operation (only for init mode). + * start: Perform the start controller operation. + * stop: Perform the stop controller operation. + * thaw: Perform the thaw controller operation. + */ +#ifndef _di_control_action_types_ + enum { + control_action_type_freeze_e = 1, + control_action_type_kill_e, + control_action_type_pause_e, + control_action_type_reboot_e, + control_action_type_reload_e, + control_action_type_rerun_e, + control_action_type_restart_e, + control_action_type_resume_e, + control_action_type_shutdown_e, + control_action_type_start_e, + control_action_type_stop_e, + control_action_type_thaw_e, + }; +#endif // _di_control_action_types_ + +/** + * Supported payload types. + * + * error: The payload is an error payload. + * controller: The payload is a controller payload. + */ +#ifndef _di_control_payload_types_ + enum { + control_payload_type_error_e = 1, + control_payload_type_controller_e, + }; +#endif // _di_control_payload_types_ + +/** + * Get a string representing the action type. * * @param type * The action type id. * * @return - * The string associated with the action type. + * The string with used > 0 on success. + * The string with used == 0 if no match was found. */ #ifndef _di_control_action_type_name_ extern f_string_static_t control_action_type_name(const uint8_t type); #endif // _di_control_action_type_name_ /** - * Get the name of the payload type. + * Get a string representing the payload type. * * @param type * The payload type id. * * @return - * The string associated with the payload type. + * The string with used > 0 on success. + * The string with used == 0 if no match was found. */ #ifndef _di_control_payload_type_name_ extern f_string_static_t control_payload_type_name(const uint8_t type); diff --git a/level_3/control/c/private-common.h b/level_3/control/c/private-common.h index b8214a2..4f6a64d 100644 --- a/level_3/control/c/private-common.h +++ b/level_3/control/c/private-common.h @@ -206,39 +206,6 @@ extern "C" { #endif // _di_control_strings_s_ /** - * Codes representing supported actions. - * - * freeze: Perform the freeze controller operation. - * kill: Perform the kill controller operation. - * pause: Perform the pause controller operation. - * reboot: Perform the reboot controller operation (only for init mode). - * reload: Perform the reload controller operation. - * rerun: Perform the rerun controller operation. - * restart: Perform the restart controller operation. - * resume: Perform the resume controller operation. - * shutdown: Perform the shutdown controller operation (only for init mode). - * start: Perform the start controller operation. - * stop: Perform the stop controller operation. - * thaw: Perform the thaw controller operation. - */ -#ifndef _di_control_action_types_ - enum { - control_action_type_freeze_e = 1, - control_action_type_kill_e, - control_action_type_pause_e, - control_action_type_reboot_e, - control_action_type_reload_e, - control_action_type_rerun_e, - control_action_type_restart_e, - control_action_type_resume_e, - control_action_type_shutdown_e, - control_action_type_start_e, - control_action_type_stop_e, - control_action_type_thaw_e, - }; -#endif // _di_control_action_types_ - -/** * The control cache. * * large: A buffer for storing large sets of data. @@ -311,19 +278,6 @@ extern "C" { #endif // _di_control_data_t_ /** - * Supported payload types. - * - * error: The payload is an error payload. - * controller: The payload is a controller payload. - */ -#ifndef _di_control_payload_types_ - enum { - control_payload_type_error_e = 1, - control_payload_type_controller_e, - }; -#endif // _di_control_payload_types_ - -/** * The packet payload header data. * * The FSS-000E (Payload) supports multiple objects, but the Control packet does not support this, yet. diff --git a/level_3/controller/c/common.c b/level_3/controller/c/common.c index aed3165..588251c 100644 --- a/level_3/controller/c/common.c +++ b/level_3/controller/c/common.c @@ -1,4 +1,5 @@ #include "controller.h" +#include "common/private-common.h" #ifdef __cplusplus extern "C" { @@ -54,6 +55,60 @@ extern "C" { const f_string_static_t controller_long_validate_s = macro_f_string_static_t_initialize(CONTROLLER_long_validate_s, 0, CONTROLLER_long_validate_s_length); #endif // _di_controller_parameters_ +#ifndef _di_controller_entry_action_type_name_ + f_string_static_t controller_entry_action_type_name(const uint8_t type) { + + switch (type) { + case controller_entry_action_type_consider_e: + return controller_consider_s; + + case controller_entry_action_type_execute_e: + return controller_execute_s; + + case controller_entry_action_type_failsafe_e: + return controller_failsafe_s; + + case controller_entry_action_type_freeze_e: + return controller_freeze_s; + + case controller_entry_action_type_item_e: + return controller_item_s; + + case controller_entry_action_type_kill_e: + return controller_kill_s; + + case controller_entry_action_type_pause_e: + return controller_pause_s; + + case controller_entry_action_type_ready_e: + return controller_ready_s; + + case controller_entry_action_type_reload_e: + return controller_reload_s; + + case controller_entry_action_type_restart_e: + return controller_restart_s; + + case controller_entry_action_type_resume_e: + return controller_resume_s; + + case controller_entry_action_type_start_e: + return controller_start_s; + + case controller_entry_action_type_stop_e: + return controller_stop_s; + + case controller_entry_action_type_thaw_e: + return controller_thaw_s; + + case controller_entry_action_type_timeout_e: + return controller_timeout_s; + } + + return f_string_empty_s; + } +#endif // _di_controller_entry_action_type_name_ + #ifndef _di_controller_main_delete_ f_status_t controller_main_delete(controller_main_t * const main) { @@ -65,6 +120,174 @@ extern "C" { } #endif // _di_controller_main_delete_ +#ifndef _di_controller_rule_action_type_name_ + f_string_static_t controller_rule_action_type_name(const uint8_t type) { + + switch (type) { + case controller_rule_action_type_freeze_e: + return controller_freeze_s; + + case controller_rule_action_type_group_e: + return controller_group_s; + + case controller_rule_action_type_kill_e: + return controller_kill_s; + + case controller_rule_action_type_pause_e: + return controller_pause_s; + + case controller_rule_action_type_pid_file_e: + return controller_pid_file_s; + + case controller_rule_action_type_rerun_e: + return controller_rerun_s; + + case controller_rule_action_type_reload_e: + return controller_reload_s; + + case controller_rule_action_type_restart_e: + return controller_restart_s; + + case controller_rule_action_type_resume_e: + return controller_resume_s; + + case controller_rule_action_type_start_e: + return controller_start_s; + + case controller_rule_action_type_stop_e: + return controller_stop_s; + + case controller_rule_action_type_thaw_e: + return controller_thaw_s; + + case controller_rule_action_type_user_e: + return controller_user_s; + + case controller_rule_action_type_with_e: + return controller_with_s; + } + + return f_string_empty_s; + } +#endif // _di_controller_rule_action_type_name_ + +#ifndef _di_controller_rule_action_type_execute_name_ + f_string_static_t controller_rule_action_type_execute_name(const uint8_t type) { + + switch (type) { + case controller_rule_action_type_execute_freeze_e: + return controller_freeze_s; + + case controller_rule_action_type_execute_kill_e: + return controller_kill_s; + + case controller_rule_action_type_execute_pause_e: + return controller_pause_s; + + case controller_rule_action_type_execute_reload_e: + return controller_reload_s; + + case controller_rule_action_type_execute_restart_e: + return controller_restart_s; + + case controller_rule_action_type_execute_resume_e: + return controller_resume_s; + + case controller_rule_action_type_execute_start_e: + return controller_start_s; + + case controller_rule_action_type_execute_stop_e: + return controller_stop_s; + + case controller_rule_action_type_execute_thaw_e: + return controller_thaw_s; + } + + return f_string_empty_s; + } +#endif // _di_controller_rule_action_type_execute_name_ + +#ifndef _di_controller_rule_item_type_name_ + f_string_static_t controller_rule_item_type_name(const uint8_t type) { + + switch (type) { + case controller_rule_item_type_command_e: + return controller_command_s; + + case controller_rule_item_type_script_e: + return controller_script_s; + + case controller_rule_item_type_service_e: + return controller_service_s; + + case controller_rule_item_type_setting_e: + return controller_setting_s; + + case controller_rule_item_type_utility_e: + return controller_utility_s; + } + + return f_string_empty_s; + } +#endif // _di_controller_rule_item_type_name_ + +#ifndef _di_controller_rule_setting_limit_type_name_ + f_string_static_t controller_rule_setting_limit_type_name(const uint8_t type) { + + switch (type) { + case controller_resource_limit_type_as_e: + return controller_as_s; + + case controller_resource_limit_type_core_e: + return controller_core_s; + + case controller_resource_limit_type_cpu_e: + return controller_cpu_s; + + case controller_resource_limit_type_data_e: + return controller_data_s; + + case controller_resource_limit_type_fsize_e: + return controller_fsize_s; + + case controller_resource_limit_type_locks_e: + return controller_locks_s; + + case controller_resource_limit_type_memlock_e: + return controller_memlock_s; + + case controller_resource_limit_type_msgqueue_e: + return controller_msgqueue_s; + + case controller_resource_limit_type_nice_e: + return controller_nice_s; + + case controller_resource_limit_type_nofile_e: + return controller_nofile_s; + + case controller_resource_limit_type_nproc_e: + return controller_nproc_s; + + case controller_resource_limit_type_rss_e: + return controller_rss_s; + + case controller_resource_limit_type_rtprio_e: + return controller_rtprio_s; + + case controller_resource_limit_type_rttime_e: + return controller_rttime_s; + + case controller_resource_limit_type_sigpending_e: + return controller_sigpending_s; + + case controller_resource_limit_type_stack_e: + return controller_stack_s; + } + + return f_string_empty_s; + } +#endif // _di_controller_rule_setting_limit_type_name_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/controller/c/common.h b/level_3/controller/c/common.h index 3c3c363..fdcdc38 100644 --- a/level_3/controller/c/common.h +++ b/level_3/controller/c/common.h @@ -332,8 +332,6 @@ extern "C" { * warning: The output file for warning printing. * signal: The process signal management structure. * context: The color context. - * - * @todo */ #ifndef _di_controller_main_t_ typedef struct { @@ -383,6 +381,101 @@ extern "C" { #endif // _di_controller_main_t_ /** + * Codes representing supported actions. + * + * freeze: Perform the freeze controller operation. + * kill: Perform the kill controller operation. + * pause: Perform the pause controller operation. + * reboot: Perform the reboot controller operation (only for init mode). + * reload: Perform the reload controller operation. + * rerun: Perform the rerun controller operation. + * restart: Perform the restart controller operation. + * resume: Perform the resume controller operation. + * shutdown: Perform the shutdown controller operation (only for init mode). + * start: Perform the start controller operation. + * stop: Perform the stop controller operation. + * thaw: Perform the thaw controller operation. + */ +#ifndef _di_controller_entry_action_types_t_ + enum { + controller_entry_action_type_consider_e = 1, + controller_entry_action_type_execute_e, + controller_entry_action_type_failsafe_e, + controller_entry_action_type_freeze_e, + controller_entry_action_type_item_e, + controller_entry_action_type_kill_e, + controller_entry_action_type_pause_e, + controller_entry_action_type_ready_e, + controller_entry_action_type_reload_e, + controller_entry_action_type_restart_e, + controller_entry_action_type_resume_e, + controller_entry_action_type_start_e, + controller_entry_action_type_stop_e, + controller_entry_action_type_timeout_e, + controller_entry_action_type_thaw_e, + }; +#endif // _di_controller_entry_action_types_t_ + +/** + * Codes representing items. + * + * command: The item type represents a command operation. + * script: The item type represents a script operation. + * service: The item type represents a service operation. + * setting: The item type represents a setting operation. + * utility: The item type represents a utility operation. + */ +#ifndef _di_controller_rule_item_types_t_ + enum { + controller_rule_item_type_command_e = 1, + controller_rule_item_type_script_e, + controller_rule_item_type_service_e, + controller_rule_item_type_setting_e, + controller_rule_item_type_utility_e, + }; +#endif // _di_controller_rule_item_types_t_ + +/** + * A set of codes for resource limitations. + * + * This essentally converts the POSIX standard names into a more verbose format. + */ +#ifndef _di_controller_resource_limit_t_ + enum { + controller_resource_limit_type_as_e = RLIMIT_AS, + controller_resource_limit_type_core_e = RLIMIT_CORE, + controller_resource_limit_type_cpu_e = RLIMIT_CPU, + controller_resource_limit_type_data_e = RLIMIT_DATA, + controller_resource_limit_type_fsize_e = RLIMIT_FSIZE, + controller_resource_limit_type_locks_e = RLIMIT_LOCKS, + controller_resource_limit_type_memlock_e = RLIMIT_MEMLOCK, + controller_resource_limit_type_msgqueue_e = RLIMIT_MSGQUEUE, + controller_resource_limit_type_nice_e = RLIMIT_NICE, + controller_resource_limit_type_nofile_e = RLIMIT_NOFILE, + controller_resource_limit_type_nproc_e = RLIMIT_NPROC, + controller_resource_limit_type_rss_e = RLIMIT_RSS, + controller_resource_limit_type_rtprio_e = RLIMIT_RTPRIO, + controller_resource_limit_type_rttime_e = RLIMIT_RTTIME, + controller_resource_limit_type_sigpending_e = RLIMIT_SIGPENDING, + controller_resource_limit_type_stack_e = RLIMIT_STACK, + }; +#endif // _di_controller_resource_limit_t_ + +/** + * Get a string representing the entry action type. + * + * @param type + * The entry action type code. + * + * @return + * The string with used > 0 on success. + * The string with used == 0 if no match was found. + */ +#ifndef _di_controller_entry_action_type_name_ + extern f_string_static_t controller_entry_action_type_name(const uint8_t type); +#endif // _di_controller_entry_action_type_name_ + +/** * Deallocate main. * * Be sure to call this after executing controller_main(). @@ -409,6 +502,62 @@ extern "C" { extern f_status_t controller_main_delete(controller_main_t * const main); #endif // _di_controller_main_delete_ +/** + * Get a string representing the rule action type. + * + * @param type + * The rule action type code. + * + * @return + * The string with used > 0 on success. + * The string with used == 0 if no match was found. + */ +#ifndef _di_controller_rule_action_type_name_ + extern f_string_static_t controller_rule_action_type_name(const uint8_t type); +#endif // _di_controller_rule_action_type_name_ + +/** + * Get a string representing the rule action execute type. + * + * @param type + * The rule action type execute code. + * + * @return + * The string with used > 0 on success. + * The string with used == 0 if no match was found. + */ +#ifndef _di_controller_rule_action_type_execute_name_ + extern f_string_static_t controller_rule_action_type_execute_name(const uint8_t type); +#endif // _di_controller_rule_action_type_execute_name_ + +/** + * Get a string representing the rule item type. + * + * @param type + * The rule item type code. + * + * @return + * The string with used > 0 on success. + * The string with used == 0 if no match was found. + */ +#ifndef _di_controller_rule_item_type_name_ + extern f_string_static_t controller_rule_item_type_name(const uint8_t type); +#endif // _di_controller_rule_item_type_name_ + +/** + * Get a string representing the rule setting limit type. + * + * @param type + * The rule setting limit type code. + * + * @return + * The string with used > 0 on success. + * The string with used == 0 if no match was found. + */ +#ifndef _di_controller_rule_setting_limit_type_name_ + extern f_string_static_t controller_rule_setting_limit_type_name(const uint8_t type); +#endif // di_controller_rule_setting_limit_type_name_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/controller/c/common/private-common.h b/level_3/controller/c/common/private-common.h index 6318fc3..941f26e 100644 --- a/level_3/controller/c/common/private-common.h +++ b/level_3/controller/c/common/private-common.h @@ -411,32 +411,6 @@ extern "C" { #endif // _di_controller_string_s_ /** - * A set of codes for resource limitations. - * - * This essentally converts the POSIX standard names into a more verbose format. - */ -#ifndef _di_controller_resource_limit_t_ - enum { - controller_resource_limit_type_as_e = RLIMIT_AS, - controller_resource_limit_type_core_e = RLIMIT_CORE, - controller_resource_limit_type_cpu_e = RLIMIT_CPU, - controller_resource_limit_type_data_e = RLIMIT_DATA, - controller_resource_limit_type_fsize_e = RLIMIT_FSIZE, - controller_resource_limit_type_locks_e = RLIMIT_LOCKS, - controller_resource_limit_type_memlock_e = RLIMIT_MEMLOCK, - controller_resource_limit_type_msgqueue_e = RLIMIT_MSGQUEUE, - controller_resource_limit_type_nice_e = RLIMIT_NICE, - controller_resource_limit_type_nofile_e = RLIMIT_NOFILE, - controller_resource_limit_type_nproc_e = RLIMIT_NPROC, - controller_resource_limit_type_rss_e = RLIMIT_RSS, - controller_resource_limit_type_rtprio_e = RLIMIT_RTPRIO, - controller_resource_limit_type_rttime_e = RLIMIT_RTTIME, - controller_resource_limit_type_sigpending_e = RLIMIT_SIGPENDING, - controller_resource_limit_type_stack_e = RLIMIT_STACK, - }; -#endif // _di_controller_resource_limit_t_ - -/** * Provide common/generic definitions. * * The controller_common_allocation_large_d or controller_common_allocation_small_d must be at least 2 for this project. diff --git a/level_3/controller/c/common/private-entry.h b/level_3/controller/c/common/private-entry.h index 3061213..64f4898 100644 --- a/level_3/controller/c/common/private-entry.h +++ b/level_3/controller/c/common/private-entry.h @@ -45,24 +45,6 @@ extern "C" { * parameters: The values associated with the Action. */ #ifndef _di_controller_entry_action_t_ - enum { - controller_entry_action_type_consider_e = 1, - controller_entry_action_type_execute_e, - controller_entry_action_type_failsafe_e, - controller_entry_action_type_freeze_e, - controller_entry_action_type_item_e, - controller_entry_action_type_kill_e, - controller_entry_action_type_pause_e, - controller_entry_action_type_ready_e, - controller_entry_action_type_reload_e, - controller_entry_action_type_restart_e, - controller_entry_action_type_resume_e, - controller_entry_action_type_start_e, - controller_entry_action_type_stop_e, - controller_entry_action_type_timeout_e, - controller_entry_action_type_thaw_e, - }; - #define controller_entry_rule_code_asynchronous_d 0x1 #define controller_entry_rule_code_require_d 0x2 #define controller_entry_rule_code_wait_d 0x4 diff --git a/level_3/controller/c/common/private-rule.h b/level_3/controller/c/common/private-rule.h index 5c7c189..8dbbf9e 100644 --- a/level_3/controller/c/common/private-rule.h +++ b/level_3/controller/c/common/private-rule.h @@ -209,14 +209,6 @@ extern "C" { * actions: The actions associated with the Rule Item. */ #ifndef _di_controller_rule_item_t_ - enum { - controller_rule_item_type_command_e = 1, - controller_rule_item_type_script_e, - controller_rule_item_type_service_e, - controller_rule_item_type_setting_e, - controller_rule_item_type_utility_e, - }; - typedef struct { uint8_t type; uint8_t with; diff --git a/level_3/controller/c/entry/private-entry.c b/level_3/controller/c/entry/private-entry.c index 3920741..cbda287 100644 --- a/level_3/controller/c/entry/private-entry.c +++ b/level_3/controller/c/entry/private-entry.c @@ -35,60 +35,6 @@ extern "C" { } #endif // _di_controller_entry_action_type_is_rule_ -#ifndef _di_controller_entry_action_type_name_ - f_string_static_t controller_entry_action_type_name(const uint8_t type) { - - switch (type) { - case controller_entry_action_type_consider_e: - return controller_consider_s; - - case controller_entry_action_type_execute_e: - return controller_execute_s; - - case controller_entry_action_type_failsafe_e: - return controller_failsafe_s; - - case controller_entry_action_type_freeze_e: - return controller_freeze_s; - - case controller_entry_action_type_item_e: - return controller_item_s; - - case controller_entry_action_type_kill_e: - return controller_kill_s; - - case controller_entry_action_type_pause_e: - return controller_pause_s; - - case controller_entry_action_type_ready_e: - return controller_ready_s; - - case controller_entry_action_type_reload_e: - return controller_reload_s; - - case controller_entry_action_type_restart_e: - return controller_restart_s; - - case controller_entry_action_type_resume_e: - return controller_resume_s; - - case controller_entry_action_type_start_e: - return controller_start_s; - - case controller_entry_action_type_stop_e: - return controller_stop_s; - - case controller_entry_action_type_thaw_e: - return controller_thaw_s; - - case controller_entry_action_type_timeout_e: - return controller_timeout_s; - } - - return f_string_empty_s; - } -#endif // _di_controller_entry_action_type_name_ - #ifndef _di_controller_entry_action_type_to_rule_action_type_ uint8_t controller_entry_action_type_to_rule_action_type(uint8_t type) { diff --git a/level_3/controller/c/entry/private-entry.h b/level_3/controller/c/entry/private-entry.h index 175daf6..3ce7ba0 100644 --- a/level_3/controller/c/entry/private-entry.h +++ b/level_3/controller/c/entry/private-entry.h @@ -27,20 +27,6 @@ extern "C" { #endif // _di_controller_entry_action_type_is_rule_ /** - * Get a string representing the entry action type. - * - * @param type - * The entry action type code. - * - * @return - * The string with used > 0 on success. - * The string with used == 0 if no match was found. - */ -#ifndef _di_controller_entry_action_type_name_ - extern f_string_static_t controller_entry_action_type_name(const uint8_t type) F_attribute_visibility_internal_d; -#endif // _di_controller_entry_action_type_name_ - -/** * Convert the Entry Action type to Rule Action type. * * @param type diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index b52ff24..8cc278f 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -216,93 +216,6 @@ extern "C" { } #endif // _di_controller_rule_action_type_to_action_execute_type_ -#ifndef _di_controller_rule_action_type_name_ - f_string_static_t controller_rule_action_type_name(const uint8_t type) { - - switch (type) { - case controller_rule_action_type_freeze_e: - return controller_freeze_s; - - case controller_rule_action_type_group_e: - return controller_group_s; - - case controller_rule_action_type_kill_e: - return controller_kill_s; - - case controller_rule_action_type_pause_e: - return controller_pause_s; - - case controller_rule_action_type_pid_file_e: - return controller_pid_file_s; - - case controller_rule_action_type_rerun_e: - return controller_rerun_s; - - case controller_rule_action_type_reload_e: - return controller_reload_s; - - case controller_rule_action_type_restart_e: - return controller_restart_s; - - case controller_rule_action_type_resume_e: - return controller_resume_s; - - case controller_rule_action_type_start_e: - return controller_start_s; - - case controller_rule_action_type_stop_e: - return controller_stop_s; - - case controller_rule_action_type_thaw_e: - return controller_thaw_s; - - case controller_rule_action_type_user_e: - return controller_user_s; - - case controller_rule_action_type_with_e: - return controller_with_s; - } - - return f_string_empty_s; - } -#endif // _di_controller_rule_action_type_name_ - -#ifndef _di_controller_rule_action_type_execute_name_ - f_string_static_t controller_rule_action_type_execute_name(const uint8_t type) { - - switch (type) { - case controller_rule_action_type_execute_freeze_e: - return controller_freeze_s; - - case controller_rule_action_type_execute_kill_e: - return controller_kill_s; - - case controller_rule_action_type_execute_pause_e: - return controller_pause_s; - - case controller_rule_action_type_execute_reload_e: - return controller_reload_s; - - case controller_rule_action_type_execute_restart_e: - return controller_restart_s; - - case controller_rule_action_type_execute_resume_e: - return controller_resume_s; - - case controller_rule_action_type_execute_start_e: - return controller_start_s; - - case controller_rule_action_type_execute_stop_e: - return controller_stop_s; - - case controller_rule_action_type_execute_thaw_e: - return controller_thaw_s; - } - - return f_string_empty_s; - } -#endif // _di_controller_rule_action_type_execute_name_ - #ifndef _di_controller_rule_action_read_ f_status_t controller_rule_action_read(const controller_global_t global, const bool is_normal, const uint8_t type, const uint8_t method, controller_cache_t * const cache, controller_rule_item_t *item, controller_rule_actions_t *actions, f_string_range_t *range) { @@ -2477,39 +2390,6 @@ extern "C" { } #endif // _di_controller_rule_item_read_ -#ifndef _di_controller_rule_item_type_name_ - f_string_static_t controller_rule_item_type_name(const uint8_t type) { - - f_string_static_t buffer = f_string_static_t_initialize; - - switch (type) { - case controller_rule_item_type_command_e: - buffer = controller_command_s; - break; - - case controller_rule_item_type_script_e: - buffer = controller_script_s; - break; - - case controller_rule_item_type_service_e: - buffer = controller_service_s; - break; - - case controller_rule_item_type_setting_e: - buffer = controller_setting_s; - break; - - case controller_rule_item_type_utility_e: - buffer = controller_utility_s; - break; - } - - buffer.size = buffer.used; - - return buffer; - } -#endif // _di_controller_rule_item_type_name_ - #ifndef _di_controller_rule_items_increase_by_ f_status_t controller_rule_items_increase_by(const f_array_length_t amount, controller_rule_items_t * const items) { @@ -2531,63 +2411,6 @@ extern "C" { } #endif // _di_controller_rule_items_increase_by_ -#ifndef _di_controller_rule_setting_limit_type_name_ - f_string_static_t controller_rule_setting_limit_type_name(const uint8_t type) { - - switch (type) { - case controller_resource_limit_type_as_e: - return controller_as_s; - - case controller_resource_limit_type_core_e: - return controller_core_s; - - case controller_resource_limit_type_cpu_e: - return controller_cpu_s; - - case controller_resource_limit_type_data_e: - return controller_data_s; - - case controller_resource_limit_type_fsize_e: - return controller_fsize_s; - - case controller_resource_limit_type_locks_e: - return controller_locks_s; - - case controller_resource_limit_type_memlock_e: - return controller_memlock_s; - - case controller_resource_limit_type_msgqueue_e: - return controller_msgqueue_s; - - case controller_resource_limit_type_nice_e: - return controller_nice_s; - - case controller_resource_limit_type_nofile_e: - return controller_nofile_s; - - case controller_resource_limit_type_nproc_e: - return controller_nproc_s; - - case controller_resource_limit_type_rss_e: - return controller_rss_s; - - case controller_resource_limit_type_rtprio_e: - return controller_rtprio_s; - - case controller_resource_limit_type_rttime_e: - return controller_rttime_s; - - case controller_resource_limit_type_sigpending_e: - return controller_sigpending_s; - - case controller_resource_limit_type_stack_e: - return controller_stack_s; - } - - return f_string_empty_s; - } -#endif // _di_controller_rule_setting_limit_type_name_ - #ifndef _di_controller_rule_process_ f_status_t controller_rule_process(const controller_global_t global, controller_process_t * const process) { diff --git a/level_3/controller/c/rule/private-rule.h b/level_3/controller/c/rule/private-rule.h index 504c0fd..3579478 100644 --- a/level_3/controller/c/rule/private-rule.h +++ b/level_3/controller/c/rule/private-rule.h @@ -114,41 +114,12 @@ extern "C" { * The converted action type, converted into an action execute type. * * The code controller_rule_action_type_execute__enum_size_e is returned for unknown types. - * */ #ifndef _di_controller_rule_action_type_to_action_execute_type_ extern uint8_t controller_rule_action_type_to_action_execute_type(const uint8_t type) F_attribute_visibility_internal_d; #endif // _di_controller_rule_action_type_to_action_execute_type_ /** - * Get a string representing the rule action type. - * - * @param type - * The rule action type code. - * - * @return - * The string with used > 0 on success. - * The string with used == 0 if no match was found. - */ -#ifndef _di_controller_rule_action_type_name_ - extern f_string_static_t controller_rule_action_type_name(const uint8_t type) F_attribute_visibility_internal_d; -#endif // _di_controller_rule_action_type_name_ - -/** - * Get a string representing the rule action execute type. - * - * @param type - * The rule action type execute code. - * - * @return - * The string with used > 0 on success. - * The string with used == 0 if no match was found. - */ -#ifndef _di_controller_rule_action_type_execute_name_ - extern f_string_static_t controller_rule_action_type_execute_name(const uint8_t type) F_attribute_visibility_internal_d; -#endif // _di_controller_rule_action_type_execute_name_ - -/** * Read the content within the buffer, processing the action (or a set of within a list) for the given item. * * This will automatically increase the size of the actions array as needed. @@ -503,20 +474,6 @@ extern "C" { #endif // _di_controller_rule_item_read_ /** - * Get a string representing the rule item type. - * - * @param type - * The rule item type code. - * - * @return - * The string with used > 0 on success. - * The string with used == 0 if no match was found. - */ -#ifndef _di_controller_rule_item_type_name_ - extern f_string_static_t controller_rule_item_type_name(const uint8_t type) F_attribute_visibility_internal_d; -#endif // _di_controller_rule_item_type_name_ - -/** * Increase the size of the rule items array by the specified amount, but only if necessary. * * This only increases size if the current used plus amount is greater than the currently allocated size. @@ -539,20 +496,6 @@ extern "C" { #endif // _di_controller_rule_items_increase_by_ /** - * Get a string representing the rule setting limit type. - * - * @param type - * The rule setting limit type code. - * - * @return - * The string with used > 0 on success. - * The string with used == 0 if no match was found. - */ -#ifndef _di_controller_rule_setting_limit_type_name_ - extern f_string_static_t controller_rule_setting_limit_type_name(const uint8_t type) F_attribute_visibility_internal_d; -#endif // di_controller_rule_setting_limit_type_name_ - -/** * Process and execute the given rule. * * Any dependent rules are processed and executed as per "need", "want", and "wish" rule settings. -- 1.8.3.1