Move some code into a private common header.
Merge the entry and items cache into a single cache.
#include "controller.h"
+#include "private-common.h"
#include "private-control.h"
#include "private-entry.h"
#include "private-rule.h"
}
controller_setting_t setting = controller_setting_t_initialize;
-
- controller_entry_cache_t cache_entry = controller_entry_cache_t_initialize;
- controller_rule_cache_t cache_rule = controller_rule_cache_t_initialize;
+ controller_cache_t cache = controller_cache_t_initialize;
f_string_static_t entry_name = f_string_static_t_initialize;
}
if (F_status_is_error_not(status)) {
- status = controller_entry_read(*data, setting, entry_name, &cache_entry, &setting.entry);
+ status = controller_entry_read(*data, setting, entry_name, &cache, &setting.entry);
// @fixme this is temporary and may or may not be used when finished codestorming.
if (F_status_is_error(setting.entry.status)) {
}
if (F_status_is_error_not(status)) {
+ status = controller_preprocess_rules(*data, &setting, &cache);
+ }
+
+ if (F_status_is_error_not(status)) {
if (data->parameters[controller_parameter_test].result == f_console_result_found || data->parameters[controller_parameter_validate].result == f_console_result_found) {
// @todo validate happens first, report and handle validation problems or success.
controller_file_pid_delete(*data, setting.path_pid);
controller_macro_setting_t_delete_simple(setting);
- controller_macro_entry_cache_t_delete_simple(cache_entry);
- controller_macro_rule_cache_t_delete_simple(cache_rule);
+ controller_macro_cache_t_delete_simple(cache);
controller_delete_data(data);
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ */
+#ifndef _PRIVATE_common_h
+#define _PRIVATE_common_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_string_
+ #define controller_string_asynchronous "asynchronous"
+ #define controller_string_create "create"
+ #define controller_string_command "command"
+ #define controller_string_consider "consider"
+ #define controller_string_control_group "control_group"
+ #define controller_string_default "default"
+ #define controller_string_define "define"
+ #define controller_string_entry "entry"
+ #define controller_string_entries "entries"
+ #define controller_string_environment "environment"
+ #define controller_string_failsafe "failsafe"
+ #define controller_string_group "group"
+ #define controller_string_item "item"
+ #define controller_string_kill "kill"
+ #define controller_string_main "main"
+ #define controller_string_name "name"
+ #define controller_string_need "need"
+ #define controller_string_parameter "parameter"
+ #define controller_string_path "path"
+ #define controller_string_pid "pid"
+ #define controller_string_ready "ready"
+ #define controller_string_reload "reload"
+ #define controller_string_require "require"
+ #define controller_string_restart "restart"
+ #define controller_string_rule "rule"
+ #define controller_string_rules "rules"
+ #define controller_string_script "script"
+ #define controller_string_service "service"
+ #define controller_string_settings "settings"
+ #define controller_string_start "start"
+ #define controller_string_stop "stop"
+ #define controller_string_timeout "timeout"
+ #define controller_string_use "use"
+ #define controller_string_user "user"
+ #define controller_string_wait "wait"
+ #define controller_string_want "want"
+ #define controller_string_wish "wish"
+
+ #define controller_string_asynchronous_length 12
+ #define controller_string_create_length 6
+ #define controller_string_command_length 7
+ #define controller_string_consider_length 8
+ #define controller_string_control_group_length 13
+ #define controller_string_define_length 6
+ #define controller_string_default_length 7
+ #define controller_string_entry_length 5
+ #define controller_string_entries_length 7
+ #define controller_string_environment_length 11
+ #define controller_string_failsafe_length 8
+ #define controller_string_group_length 5
+ #define controller_string_item_length 4
+ #define controller_string_kill_length 4
+ #define controller_string_main_length 4
+ #define controller_string_name_length 4
+ #define controller_string_need_length 4
+ #define controller_string_parameter_length 9
+ #define controller_string_path_length 4
+ #define controller_string_pid_length 3
+ #define controller_string_ready_length 5
+ #define controller_string_reload_length 6
+ #define controller_string_require_length 7
+ #define controller_string_restart_length 7
+ #define controller_string_rule_length 4
+ #define controller_string_rules_length 5
+ #define controller_string_script_length 6
+ #define controller_string_service_length 7
+ #define controller_string_settings_length 8
+ #define controller_string_start_length 5
+ #define controller_string_stop_length 4
+ #define controller_string_timeout_length 7
+ #define controller_string_use_length 3
+ #define controller_string_user_length 4
+ #define controller_string_wait_length 4
+ #define controller_string_want_length 4
+ #define controller_string_wish_length 4
+#endif // _di_controller_string_
+
+#ifndef _di_controller_rule_action_t_
+ enum {
+ controller_rule_action_method_extended = 1,
+ controller_rule_action_method_extended_list,
+ };
+
+ enum {
+ controller_rule_action_type_create = 1,
+ controller_rule_action_type_group,
+ controller_rule_action_type_kill,
+ controller_rule_action_type_restart,
+ controller_rule_action_type_reload,
+ controller_rule_action_type_start,
+ controller_rule_action_type_stop,
+ controller_rule_action_type_use,
+ controller_rule_action_type_user,
+ };
+
+ typedef struct {
+ f_string_length_t line;
+
+ f_status_t status;
+
+ f_string_dynamics_t parameters;
+ } controller_rule_action_t;
+
+ #define controller_rule_action_t_initialize \
+ { \
+ 0, \
+ F_known_not, \
+ f_string_dynamics_t_initialize, \
+ }
+
+ #define controller_macro_rule_action_t_delete_simple(action) \
+ f_macro_string_dynamics_t_delete_simple(action.parameters)
+#endif // _di_controller_rule_action_t_
+
+#ifndef _di_controller_rule_actions_t_
+ typedef struct {
+ uint8_t method;
+ uint8_t type;
+
+ controller_rule_action_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } controller_rule_actions_t;
+
+ #define controller_rule_actions_t_initialize \
+ { \
+ 0, \
+ 0, \
+ 0, \
+ 0, \
+ 0, \
+ }
+
+ #define controller_macro_rule_actions_t_delete_simple(actions) \
+ actions.used = actions.size; \
+ while (actions.used) { \
+ actions.used--; \
+ controller_macro_rule_action_t_delete_simple(actions.array[actions.used]); \
+ } \
+ f_memory_delete((void **) & actions.array, sizeof(controller_rule_action_t), actions.size); \
+ actions.size = 0;
+#endif // _di_controller_rule_actions_t_
+
+#ifndef _di_controller_rule_item_t_
+ enum {
+ controller_rule_item_type_command = 1,
+ controller_rule_item_type_script,
+ controller_rule_item_type_service,
+ controller_rule_item_type_settings,
+ };
+
+ typedef struct {
+ uint8_t type;
+ f_string_length_t line;
+
+ controller_rule_actions_t actions;
+ } controller_rule_item_t;
+
+ #define controller_rule_item_t_initialize \
+ { \
+ 0, \
+ 0, \
+ controller_rule_actions_t_initialize, \
+ }
+
+ #define controller_macro_rule_item_t_delete_simple(item) \
+ controller_macro_rule_actions_t_delete_simple(item.actions)
+#endif // _di_controller_rule_item_t_
+
+#ifndef _di_controller_rule_items_t_
+ typedef struct {
+ controller_rule_item_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } controller_rule_items_t;
+
+ #define controller_rule_items_initialize \
+ { \
+ 0, \
+ 0, \
+ 0, \
+ }
+
+ #define controller_macro_rule_items_t_delete_simple(items) \
+ items.used = items.size; \
+ while (items.used) { \
+ items.used--; \
+ controller_macro_rule_item_t_delete_simple(items.array[items.used]); \
+ } \
+ f_memory_delete((void **) & items.array, sizeof(controller_rule_item_t), items.size); \
+ items.size = 0;
+#endif // _di_controller_rule_items_t_
+
+#ifndef _di_controller_rule_t_
+ enum {
+ controller_rule_setting_type_control_group = 1,
+ controller_rule_setting_type_define,
+ controller_rule_setting_type_environment,
+ controller_rule_setting_type_name,
+ controller_rule_setting_type_need,
+ controller_rule_setting_type_parameter,
+ controller_rule_setting_type_path,
+ controller_rule_setting_type_want,
+ controller_rule_setting_type_wish,
+ };
+
+ typedef struct {
+ f_status_t status;
+
+ f_string_dynamic_t id;
+ f_string_dynamic_t name;
+ f_string_dynamic_t control_group;
+ f_string_dynamic_t path;
+
+ f_string_maps_t define;
+ f_string_maps_t parameter;
+
+ f_string_dynamics_t environment;
+ f_string_dynamics_t need;
+ f_string_dynamics_t want;
+ f_string_dynamics_t wish;
+
+ controller_rule_items_t items;
+ } controller_rule_t;
+
+ #define controller_rule_t_initialize \
+ { \
+ F_known_not, \
+ f_string_dynamic_t_initialize, \
+ f_string_dynamic_t_initialize, \
+ f_string_dynamic_t_initialize, \
+ f_string_dynamic_t_initialize, \
+ f_string_maps_t_initialize, \
+ f_string_maps_t_initialize, \
+ f_string_dynamics_t_initialize, \
+ f_string_dynamics_t_initialize, \
+ f_string_dynamics_t_initialize, \
+ f_string_dynamics_t_initialize, \
+ controller_rule_items_initialize, \
+ }
+
+ #define controller_macro_rule_t_delete_simple(rule) \
+ f_macro_string_dynamic_t_delete_simple(rule.id) \
+ f_macro_string_dynamic_t_delete_simple(rule.name) \
+ f_macro_string_dynamic_t_delete_simple(rule.control_group) \
+ f_macro_string_dynamic_t_delete_simple(rule.path) \
+ f_macro_string_maps_t_delete_simple(rule.define) \
+ f_macro_string_maps_t_delete_simple(rule.parameter) \
+ f_macro_string_dynamics_t_delete_simple(rule.environment) \
+ f_macro_string_dynamics_t_delete_simple(rule.need) \
+ f_macro_string_dynamics_t_delete_simple(rule.want) \
+ f_macro_string_dynamics_t_delete_simple(rule.wish) \
+ controller_macro_rule_items_t_delete_simple(rule.items)
+#endif // _di_controller_rule_t_
+
+#ifndef _di_controller_rules_t_
+ typedef struct {
+ controller_rule_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } controller_rules_t;
+
+ #define controller_rules_t_initialize \
+ { \
+ 0, \
+ 0, \
+ 0, \
+ }
+
+ #define controller_macro_rules_t_delete_simple(rules) \
+ rules.used = rules.size; \
+ while (rules.used) { \
+ rules.used--; \
+ controller_macro_rule_t_delete_simple(rules.array[rules.used]); \
+ } \
+ f_memory_delete((void **) & rules.array, sizeof(controller_rule_t), rules.size); \
+ rules.size = 0;
+#endif // _di_controller_rules_t_
+
+#ifndef _di_controller_entry_action_t_
+ enum {
+ controller_entry_action_type_consider = 1,
+ controller_entry_action_type_failsafe,
+ controller_entry_action_type_item,
+ controller_entry_action_type_ready,
+ controller_entry_action_type_rule,
+ controller_entry_action_type_timeout,
+ };
+
+ #define controller_entry_rule_code_asynchronous 0x1
+ #define controller_entry_rule_code_require 0x2
+ #define controller_entry_rule_code_wait 0x4
+
+ #define controller_entry_timeout_code_kill 0x1
+ #define controller_entry_timeout_code_start 0x2
+ #define controller_entry_timeout_code_stop 0x4
+
+ typedef struct {
+ uint8_t type;
+ uint8_t code;
+
+ f_string_length_t line;
+ f_number_unsigned_t timeout;
+
+ f_status_t status;
+
+ f_string_dynamics_t parameters;
+ } controller_entry_action_t;
+
+ #define controller_entry_action_t_initialize \
+ { \
+ 0, \
+ 0, \
+ 0, \
+ 0, \
+ F_known_not, \
+ f_string_dynamics_t_initialize, \
+ }
+
+ #define controller_macro_entry_action_t_delete_simple(action) \
+ f_macro_string_dynamics_t_delete_simple(action.parameters)
+#endif // _di_controller_entry_action_t_
+
+#ifndef _di_controller_entry_actions_t_
+ typedef struct {
+ controller_entry_action_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } controller_entry_actions_t;
+
+ #define controller_entry_actions_t_initialize \
+ { \
+ 0, \
+ 0, \
+ 0, \
+ }
+
+ #define controller_macro_entry_actions_t_delete_simple(actions) \
+ actions.used = actions.size; \
+ while (actions.used) { \
+ actions.used--; \
+ controller_macro_entry_action_t_delete_simple(actions.array[actions.used]); \
+ } \
+ f_memory_delete((void **) & actions.array, sizeof(controller_entry_action_t), actions.size); \
+ actions.size = 0;
+#endif // _di_controller_entry_actions_t_
+
+#ifndef _di_controller_entry_item_t_
+ typedef struct {
+ f_string_length_t line;
+
+ f_string_dynamic_t name;
+ controller_entry_actions_t actions;
+ } controller_entry_item_t;
+
+ #define controller_entry_item_t_initialize \
+ { \
+ 0, \
+ f_string_dynamic_t_initialize, \
+ controller_entry_actions_t_initialize, \
+ }
+
+ #define controller_macro_entry_item_t_delete_simple(item) \
+ f_macro_string_dynamic_t_delete_simple(item.name) \
+ controller_macro_entry_actions_t_delete_simple(item.actions)
+#endif // _di_controller_entry_item_t_
+
+#ifndef _di_controller_entry_items_t_
+ typedef struct {
+ controller_entry_item_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } controller_entry_items_t;
+
+ #define controller_entry_items_t_initialize \
+ { \
+ 0, \
+ 0, \
+ 0, \
+ }
+
+ #define controller_macro_entry_items_t_delete_simple(items) \
+ items.used = items.size; \
+ while (items.used) { \
+ items.used--; \
+ controller_macro_entry_item_t_delete_simple(items.array[items.used]); \
+ } \
+ f_memory_delete((void **) & items.array, sizeof(controller_entry_item_t), items.size); \
+ items.size = 0;
+#endif // _di_controller_entry_items_t_
+
+#ifndef _di_controller_entry_t_
+ typedef struct {
+ f_status_t status;
+ controller_entry_items_t items;
+ } controller_entry_t;
+
+ #define controller_entry_t_initialize \
+ { \
+ F_known_not, \
+ controller_entry_items_t_initialize, \
+ }
+
+ #define controller_macro_entry_t_delete_simple(entry) \
+ controller_macro_entry_items_t_delete_simple(entry.items)
+#endif // _di_controller_entry_t_
+
+#ifndef _di_controller_setting_t
+ enum {
+ controller_setting_ready_no = 0,
+ controller_setting_ready_wait,
+ controller_setting_ready_yes,
+ };
+
+ typedef struct {
+ bool interruptable;
+ uint8_t ready;
+
+ f_string_dynamic_t path_pid;
+ f_string_dynamic_t path_setting;
+
+ controller_entry_t entry;
+ controller_rules_t rules;
+ } controller_setting_t;
+
+ #define controller_setting_t_initialize \
+ { \
+ F_false, \
+ 0, \
+ f_string_dynamic_t_initialize, \
+ f_string_dynamic_t_initialize, \
+ controller_entry_t_initialize, \
+ controller_rules_t_initialize, \
+ }
+
+ #define controller_macro_setting_t_delete_simple(setting) \
+ f_macro_string_dynamic_t_delete_simple(setting.path_pid) \
+ f_macro_string_dynamic_t_delete_simple(setting.path_setting) \
+ controller_macro_entry_t_delete_simple(setting.entry) \
+ controller_macro_rules_t_delete_simple(setting.rules)
+#endif // _di_controller_setting_t
+
+#ifndef _di_controller_cache_t_
+ typedef struct {
+ f_string_length_t line_action;
+ f_string_length_t line_item;
+
+ f_string_range_t range_action;
+
+ f_fss_comments_t comments;
+ f_fss_delimits_t delimits;
+
+ f_fss_content_t content_action;
+ f_fss_contents_t content_actions;
+ f_fss_contents_t content_items;
+ f_fss_objects_t object_actions;
+ f_fss_objects_t object_items;
+
+ f_string_dynamic_t buffer_file;
+ f_string_dynamic_t buffer_item;
+ f_string_dynamic_t buffer_path;
+
+ f_string_dynamic_t name_action;
+ f_string_dynamic_t name_file;
+ f_string_dynamic_t name_item;
+ } controller_cache_t;
+
+ #define controller_cache_t_initialize \
+ { \
+ 0, \
+ 0, \
+ f_string_range_t_initialize, \
+ f_fss_comments_t_initialize, \
+ f_fss_delimits_t_initialize, \
+ f_fss_content_t_initialize, \
+ f_fss_contents_t_initialize, \
+ f_fss_contents_t_initialize, \
+ f_fss_objects_t_initialize, \
+ f_fss_objects_t_initialize, \
+ f_string_dynamic_t_initialize, \
+ f_string_dynamic_t_initialize, \
+ f_string_dynamic_t_initialize, \
+ f_string_dynamic_t_initialize, \
+ f_string_dynamic_t_initialize, \
+ f_string_dynamic_t_initialize, \
+ }
+
+ #define controller_macro_cache_t_delete_simple(cache) \
+ f_macro_fss_comments_t_delete_simple(cache.comments) \
+ f_macro_fss_delimits_t_delete_simple(cache.delimits) \
+ f_macro_fss_content_t_delete_simple(cache.content_action) \
+ f_macro_fss_contents_t_delete_simple(cache.content_actions) \
+ f_macro_fss_contents_t_delete_simple(cache.content_items) \
+ f_macro_fss_objects_t_delete_simple(cache.object_actions) \
+ f_macro_fss_objects_t_delete_simple(cache.object_items) \
+ f_macro_string_dynamic_t_delete_simple(cache.buffer_file) \
+ f_macro_string_dynamic_t_delete_simple(cache.buffer_item) \
+ f_macro_string_dynamic_t_delete_simple(cache.buffer_path) \
+ f_macro_string_dynamic_t_delete_simple(cache.name_action) \
+ f_macro_string_dynamic_t_delete_simple(cache.name_file) \
+ f_macro_string_dynamic_t_delete_simple(cache.name_item)
+#endif // _di_controller_cache_t_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _PRIVATE_common_h
#include "controller.h"
+#include "private-common.h"
#include "private-control.h"
#ifdef __cplusplus
#ifndef _PRIVATE_control_h
#define _PRIVATE_control_h
-#include "private-controller.h"
-
#ifdef __cplusplus
extern "C" {
#endif
#include "controller.h"
+#include "private-common.h"
#include "private-control.h"
#include "private-entry.h"
#include "private-rule.h"
}
#endif // _di_controller_file_pid_delete_
+#ifndef _di_controller_preprocess_rules_
+ f_return_status controller_preprocess_rules(const controller_data_t data, controller_setting_t *setting, controller_cache_t *cache) {
+ // @todo
+ return F_none;
+ }
+#endif // _di_controller_preprocess_rules_
+
#ifndef _di_controller_status_simplify_
f_return_status controller_status_simplify(const f_status_t status) {
extern "C" {
#endif
-#ifndef _di_controller_string_
- #define controller_string_asynchronous "asynchronous"
- #define controller_string_create "create"
- #define controller_string_command "command"
- #define controller_string_consider "consider"
- #define controller_string_control_group "control_group"
- #define controller_string_default "default"
- #define controller_string_define "define"
- #define controller_string_entry "entry"
- #define controller_string_entries "entries"
- #define controller_string_environment "environment"
- #define controller_string_failsafe "failsafe"
- #define controller_string_group "group"
- #define controller_string_item "item"
- #define controller_string_kill "kill"
- #define controller_string_main "main"
- #define controller_string_name "name"
- #define controller_string_need "need"
- #define controller_string_parameter "parameter"
- #define controller_string_path "path"
- #define controller_string_pid "pid"
- #define controller_string_ready "ready"
- #define controller_string_reload "reload"
- #define controller_string_require "require"
- #define controller_string_restart "restart"
- #define controller_string_rule "rule"
- #define controller_string_rules "rules"
- #define controller_string_script "script"
- #define controller_string_service "service"
- #define controller_string_settings "settings"
- #define controller_string_start "start"
- #define controller_string_stop "stop"
- #define controller_string_timeout "timeout"
- #define controller_string_use "use"
- #define controller_string_user "user"
- #define controller_string_wait "wait"
- #define controller_string_want "want"
- #define controller_string_wish "wish"
-
- #define controller_string_asynchronous_length 12
- #define controller_string_create_length 6
- #define controller_string_command_length 7
- #define controller_string_consider_length 8
- #define controller_string_control_group_length 13
- #define controller_string_define_length 6
- #define controller_string_default_length 7
- #define controller_string_entry_length 5
- #define controller_string_entries_length 7
- #define controller_string_environment_length 11
- #define controller_string_failsafe_length 8
- #define controller_string_group_length 5
- #define controller_string_item_length 4
- #define controller_string_kill_length 4
- #define controller_string_main_length 4
- #define controller_string_name_length 4
- #define controller_string_need_length 4
- #define controller_string_parameter_length 9
- #define controller_string_path_length 4
- #define controller_string_pid_length 3
- #define controller_string_ready_length 5
- #define controller_string_reload_length 6
- #define controller_string_require_length 7
- #define controller_string_restart_length 7
- #define controller_string_rule_length 4
- #define controller_string_rules_length 5
- #define controller_string_script_length 6
- #define controller_string_service_length 7
- #define controller_string_settings_length 8
- #define controller_string_start_length 5
- #define controller_string_stop_length 4
- #define controller_string_timeout_length 7
- #define controller_string_use_length 3
- #define controller_string_user_length 4
- #define controller_string_wait_length 4
- #define controller_string_want_length 4
- #define controller_string_wish_length 4
-#endif // _di_controller_string_
-
-#ifndef _di_controller_rule_action_t_
- enum {
- controller_rule_action_method_extended = 1,
- controller_rule_action_method_extended_list,
- };
-
- enum {
- controller_rule_action_type_create = 1,
- controller_rule_action_type_group,
- controller_rule_action_type_kill,
- controller_rule_action_type_restart,
- controller_rule_action_type_reload,
- controller_rule_action_type_start,
- controller_rule_action_type_stop,
- controller_rule_action_type_use,
- controller_rule_action_type_user,
- };
-
- typedef struct {
- f_string_length_t line;
-
- f_status_t status;
-
- f_string_dynamics_t parameters;
- } controller_rule_action_t;
-
- #define controller_rule_action_t_initialize \
- { \
- 0, \
- F_known_not, \
- f_string_dynamics_t_initialize, \
- }
-
- #define controller_macro_rule_action_t_delete_simple(action) \
- f_macro_string_dynamics_t_delete_simple(action.parameters)
-#endif // _di_controller_rule_action_t_
-
-#ifndef _di_controller_rule_actions_t_
- typedef struct {
- uint8_t method;
- uint8_t type;
-
- controller_rule_action_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } controller_rule_actions_t;
-
- #define controller_rule_actions_t_initialize \
- { \
- 0, \
- 0, \
- 0, \
- 0, \
- 0, \
- }
-
- #define controller_macro_rule_actions_t_delete_simple(actions) \
- actions.used = actions.size; \
- while (actions.used) { \
- actions.used--; \
- controller_macro_rule_action_t_delete_simple(actions.array[actions.used]); \
- } \
- f_memory_delete((void **) & actions.array, sizeof(controller_rule_action_t), actions.size); \
- actions.size = 0;
-#endif // _di_controller_rule_actions_t_
-
-#ifndef _di_controller_rule_item_t_
- enum {
- controller_rule_item_type_command = 1,
- controller_rule_item_type_script,
- controller_rule_item_type_service,
- controller_rule_item_type_settings,
- };
-
- typedef struct {
- uint8_t type;
- f_string_length_t line;
-
- controller_rule_actions_t actions;
- } controller_rule_item_t;
-
- #define controller_rule_item_t_initialize \
- { \
- 0, \
- 0, \
- controller_rule_actions_t_initialize, \
- }
-
- #define controller_macro_rule_item_t_delete_simple(item) \
- controller_macro_rule_actions_t_delete_simple(item.actions)
-#endif // _di_controller_rule_item_t_
-
-#ifndef _di_controller_rule_items_t_
- typedef struct {
- controller_rule_item_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } controller_rule_items_t;
-
- #define controller_rule_items_initialize \
- { \
- 0, \
- 0, \
- 0, \
- }
-
- #define controller_macro_rule_items_t_delete_simple(items) \
- items.used = items.size; \
- while (items.used) { \
- items.used--; \
- controller_macro_rule_item_t_delete_simple(items.array[items.used]); \
- } \
- f_memory_delete((void **) & items.array, sizeof(controller_rule_item_t), items.size); \
- items.size = 0;
-#endif // _di_controller_rule_items_t_
-
-#ifndef _di_controller_rule_t_
- enum {
- controller_rule_setting_type_control_group = 1,
- controller_rule_setting_type_define,
- controller_rule_setting_type_environment,
- controller_rule_setting_type_name,
- controller_rule_setting_type_need,
- controller_rule_setting_type_parameter,
- controller_rule_setting_type_path,
- controller_rule_setting_type_want,
- controller_rule_setting_type_wish,
- };
-
- typedef struct {
- f_status_t status;
-
- f_string_dynamic_t id;
- f_string_dynamic_t name;
- f_string_dynamic_t control_group;
- f_string_dynamic_t path;
-
- f_string_maps_t define;
- f_string_maps_t parameter;
-
- f_string_dynamics_t environment;
- f_string_dynamics_t need;
- f_string_dynamics_t want;
- f_string_dynamics_t wish;
-
- controller_rule_items_t items;
- } controller_rule_t;
-
- #define controller_rule_t_initialize \
- { \
- F_known_not, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_maps_t_initialize, \
- f_string_maps_t_initialize, \
- f_string_dynamics_t_initialize, \
- f_string_dynamics_t_initialize, \
- f_string_dynamics_t_initialize, \
- f_string_dynamics_t_initialize, \
- controller_rule_items_initialize, \
- }
-
- #define controller_macro_rule_t_delete_simple(rule) \
- f_macro_string_dynamic_t_delete_simple(rule.id) \
- f_macro_string_dynamic_t_delete_simple(rule.name) \
- f_macro_string_dynamic_t_delete_simple(rule.control_group) \
- f_macro_string_dynamic_t_delete_simple(rule.path) \
- f_macro_string_maps_t_delete_simple(rule.define) \
- f_macro_string_maps_t_delete_simple(rule.parameter) \
- f_macro_string_dynamics_t_delete_simple(rule.environment) \
- f_macro_string_dynamics_t_delete_simple(rule.need) \
- f_macro_string_dynamics_t_delete_simple(rule.want) \
- f_macro_string_dynamics_t_delete_simple(rule.wish) \
- controller_macro_rule_items_t_delete_simple(rule.items)
-#endif // _di_controller_rule_t_
-
-#ifndef _di_controller_rules_t_
- typedef struct {
- controller_rule_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } controller_rules_t;
-
- #define controller_rules_t_initialize \
- { \
- 0, \
- 0, \
- 0, \
- }
-
- #define controller_macro_rules_t_delete_simple(rules) \
- rules.used = rules.size; \
- while (rules.used) { \
- rules.used--; \
- controller_macro_rule_t_delete_simple(rules.array[rules.used]); \
- } \
- f_memory_delete((void **) & rules.array, sizeof(controller_rule_t), rules.size); \
- rules.size = 0;
-#endif // _di_controller_rules_t_
-
-#ifndef _di_controller_entry_action_t_
- enum {
- controller_entry_action_type_consider = 1,
- controller_entry_action_type_failsafe,
- controller_entry_action_type_item,
- controller_entry_action_type_ready,
- controller_entry_action_type_rule,
- controller_entry_action_type_timeout,
- };
-
- #define controller_entry_rule_code_asynchronous 0x1
- #define controller_entry_rule_code_require 0x2
- #define controller_entry_rule_code_wait 0x4
-
- #define controller_entry_timeout_code_kill 0x1
- #define controller_entry_timeout_code_start 0x2
- #define controller_entry_timeout_code_stop 0x4
-
- typedef struct {
- uint8_t type;
- uint8_t code;
-
- f_string_length_t line;
- f_number_unsigned_t timeout;
-
- f_status_t status;
-
- f_string_dynamics_t parameters;
- } controller_entry_action_t;
-
- #define controller_entry_action_t_initialize \
- { \
- 0, \
- 0, \
- 0, \
- 0, \
- F_known_not, \
- f_string_dynamics_t_initialize, \
- }
-
- #define controller_macro_entry_action_t_delete_simple(action) \
- f_macro_string_dynamics_t_delete_simple(action.parameters)
-#endif // _di_controller_entry_action_t_
-
-#ifndef _di_controller_entry_actions_t_
- typedef struct {
- controller_entry_action_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } controller_entry_actions_t;
-
- #define controller_entry_actions_t_initialize \
- { \
- 0, \
- 0, \
- 0, \
- }
-
- #define controller_macro_entry_actions_t_delete_simple(actions) \
- actions.used = actions.size; \
- while (actions.used) { \
- actions.used--; \
- controller_macro_entry_action_t_delete_simple(actions.array[actions.used]); \
- } \
- f_memory_delete((void **) & actions.array, sizeof(controller_entry_action_t), actions.size); \
- actions.size = 0;
-#endif // _di_controller_entry_actions_t_
-
-#ifndef _di_controller_entry_item_t_
- typedef struct {
- f_string_length_t line;
-
- f_string_dynamic_t name;
- controller_entry_actions_t actions;
- } controller_entry_item_t;
-
- #define controller_entry_item_t_initialize \
- { \
- 0, \
- f_string_dynamic_t_initialize, \
- controller_entry_actions_t_initialize, \
- }
-
- #define controller_macro_entry_item_t_delete_simple(item) \
- f_macro_string_dynamic_t_delete_simple(item.name) \
- controller_macro_entry_actions_t_delete_simple(item.actions)
-#endif // _di_controller_entry_item_t_
-
-#ifndef _di_controller_entry_items_t_
- typedef struct {
- controller_entry_item_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } controller_entry_items_t;
-
- #define controller_entry_items_t_initialize \
- { \
- 0, \
- 0, \
- 0, \
- }
-
- #define controller_macro_entry_items_t_delete_simple(items) \
- items.used = items.size; \
- while (items.used) { \
- items.used--; \
- controller_macro_entry_item_t_delete_simple(items.array[items.used]); \
- } \
- f_memory_delete((void **) & items.array, sizeof(controller_entry_item_t), items.size); \
- items.size = 0;
-#endif // _di_controller_entry_items_t_
-
-#ifndef _di_controller_entry_t_
- typedef struct {
- f_status_t status;
- controller_entry_items_t items;
- } controller_entry_t;
-
- #define controller_entry_t_initialize \
- { \
- F_known_not, \
- controller_entry_items_t_initialize, \
- }
-
- #define controller_macro_entry_t_delete_simple(entry) \
- controller_macro_entry_items_t_delete_simple(entry.items)
-#endif // _di_controller_entry_t_
-
-#ifndef _di_controller_setting_t
- typedef struct {
- bool interruptable;
- bool ready;
-
- f_string_dynamic_t path_pid;
- f_string_dynamic_t path_setting;
-
- controller_entry_t entry;
- controller_rules_t rules;
- } controller_setting_t;
-
- #define controller_setting_t_initialize \
- { \
- F_false, \
- F_false, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- controller_entry_t_initialize, \
- controller_rules_t_initialize, \
- }
-
- #define controller_macro_setting_t_delete_simple(setting) \
- f_macro_string_dynamic_t_delete_simple(setting.path_pid) \
- f_macro_string_dynamic_t_delete_simple(setting.path_setting) \
- controller_macro_entry_t_delete_simple(setting.entry) \
- controller_macro_rules_t_delete_simple(setting.rules)
-#endif // _di_controller_setting_t
-
/**
* Load a file from the controller settings directory.
*
#endif // _di_controller_file_pid_delete_
/**
+ * Load relevant rules into memory and performing other pre-process tasks.
+ *
+ * @param data
+ * The program data.
+ * @param setting
+ * The controller settings data.
+ * @param cache
+ * The cache.
+ *
+ * @return
+ * F_none on success.
+ */
+#ifndef _di_controller_preprocess_rules_
+ extern f_return_status controller_preprocess_rules(const controller_data_t data, controller_setting_t *setting, controller_cache_t *cache) f_gcc_attribute_visibility_internal;
+#endif // _di_controller_preprocess_rules_
+
+/**
* Given a wide range of status codes, simplify them down to a small subset.
*
* @param status
#include "controller.h"
+#include "private-common.h"
+#include "private-controller.h"
#include "private-entry.h"
#ifdef __cplusplus
#endif // _di_controller_entry_actions_increase_by_
#ifndef _di_controller_entry_actions_read_
- f_return_status controller_entry_actions_read(const controller_data_t data, const controller_setting_t setting, const f_string_range_t content_range, controller_entry_cache_t *cache, controller_entry_actions_t *actions) {
+ f_return_status controller_entry_actions_read(const controller_data_t data, const controller_setting_t setting, const f_string_range_t content_range, controller_cache_t *cache, controller_entry_actions_t *actions) {
f_status_t status = F_none;
f_status_t status_action = F_none;
#endif // _di_controller_entry_actions_read_
#ifndef _di_controller_entry_error_print_
- void controller_entry_error_print(const fll_error_print_t output, const controller_entry_cache_t cache) {
+ void controller_entry_error_print(const fll_error_print_t output, const controller_cache_t cache) {
if (output.verbosity != f_console_verbosity_quiet) {
fprintf(output.to.stream, "%c", f_string_eol[0]);
#endif // _di_controller_entry_items_increase_by_
#ifndef _di_controller_entry_read_
- f_return_status controller_entry_read(const controller_data_t data, const controller_setting_t setting, const f_string_static_t entry_name, controller_entry_cache_t *cache, controller_entry_t *entry) {
+ f_return_status controller_entry_read(const controller_data_t data, const controller_setting_t setting, const f_string_static_t entry_name, controller_cache_t *cache, controller_entry_t *entry) {
f_status_t status = F_none;
entry->status = F_known_not;
#ifndef _PRIVATE_entry_h
#define _PRIVATE_entry_h
-#include "private-controller.h"
-
-#ifndef _di_controller_entry_cache_t_
- typedef struct {
- f_string_length_t line_action;
- f_string_length_t line_item;
-
- f_fss_comments_t comments;
- f_fss_delimits_t delimits;
-
- f_fss_content_t content_action;
- f_fss_contents_t content_actions;
- f_fss_contents_t content_items;
- f_fss_objects_t object_actions;
- f_fss_objects_t object_items;
-
- f_string_dynamic_t buffer_file;
- f_string_dynamic_t buffer_path;
-
- f_string_dynamic_t name_action;
- f_string_dynamic_t name_file;
- f_string_dynamic_t name_item;
- } controller_entry_cache_t;
-
- #define controller_entry_cache_t_initialize \
- { \
- 0, \
- 0, \
- f_fss_comments_t_initialize, \
- f_fss_delimits_t_initialize, \
- f_fss_content_t_initialize, \
- f_fss_contents_t_initialize, \
- f_fss_contents_t_initialize, \
- f_fss_objects_t_initialize, \
- f_fss_objects_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- }
-
- #define controller_macro_entry_cache_t_delete_simple(cache) \
- f_macro_fss_comments_t_delete_simple(cache.comments) \
- f_macro_fss_delimits_t_delete_simple(cache.delimits) \
- f_macro_fss_content_t_delete_simple(cache.content_action) \
- f_macro_fss_contents_t_delete_simple(cache.content_actions) \
- f_macro_fss_contents_t_delete_simple(cache.content_items) \
- f_macro_fss_objects_t_delete_simple(cache.object_actions) \
- f_macro_fss_objects_t_delete_simple(cache.object_items) \
- f_macro_string_dynamic_t_delete_simple(cache.buffer_file) \
- f_macro_string_dynamic_t_delete_simple(cache.buffer_path) \
- f_macro_string_dynamic_t_delete_simple(cache.name_action) \
- f_macro_string_dynamic_t_delete_simple(cache.name_file) \
- f_macro_string_dynamic_t_delete_simple(cache.name_item)
-#endif // _di_controller_entry_cache_t_
-
#ifdef __cplusplus
extern "C" {
#endif
* @see fll_fss_extended_read()
*/
#ifndef _di_controller_entry_actions_read_
- extern f_return_status controller_entry_actions_read(const controller_data_t data, const controller_setting_t setting, const f_string_range_t content_range, controller_entry_cache_t *cache, controller_entry_actions_t *items) f_gcc_attribute_visibility_internal;
+ extern f_return_status controller_entry_actions_read(const controller_data_t data, const controller_setting_t setting, const f_string_range_t content_range, controller_cache_t *cache, controller_entry_actions_t *items) f_gcc_attribute_visibility_internal;
#endif // _di_controller_entry_actions_read_
/**
* @see controller_entry_read()
*/
#ifndef _di_controller_entry_error_print_
- extern void controller_entry_error_print(const fll_error_print_t output, const controller_entry_cache_t cache) f_gcc_attribute_visibility_internal;
+ extern void controller_entry_error_print(const fll_error_print_t output, const controller_cache_t cache) f_gcc_attribute_visibility_internal;
#endif // _di_controller_entry_error_print_
/**
* @see fll_fss_basic_list_read()
*/
#ifndef _di_controller_entry_read_
- extern f_return_status controller_entry_read(const controller_data_t data, const controller_setting_t setting, const f_string_static_t entry_name, controller_entry_cache_t *cache, controller_entry_t *entry) f_gcc_attribute_visibility_internal;
+ extern f_return_status controller_entry_read(const controller_data_t data, const controller_setting_t setting, const f_string_static_t entry_name, controller_cache_t *cache, controller_entry_t *entry) f_gcc_attribute_visibility_internal;
#endif // _di_controller_entry_read_
#ifdef __cplusplus
#include "controller.h"
+#include "private-common.h"
+#include "private-controller.h"
#include "private-rule.h"
#ifdef __cplusplus
#endif // _di_controller_rule_actions_increase_by_
#ifndef _di_controller_rule_actions_read_
- f_return_status controller_rule_actions_read(const controller_data_t data, controller_rule_cache_t *cache, controller_rule_item_t *item, controller_rule_actions_t *actions, f_string_range_t *range) {
+ f_return_status controller_rule_actions_read(const controller_data_t data, controller_cache_t *cache, controller_rule_item_t *item, controller_rule_actions_t *actions, f_string_range_t *range) {
f_status_t status = F_none;
actions->used = 0;
#endif // _di_controller_rule_actions_read_
#ifndef _di_controller_rule_error_print_
- void controller_rule_error_print(const fll_error_print_t output, const controller_rule_cache_t cache, const bool item) {
+ void controller_rule_error_print(const fll_error_print_t output, const controller_cache_t cache, const bool item) {
if (output.verbosity != f_console_verbosity_quiet) {
fprintf(output.to.stream, "%c", f_string_eol[0]);
#endif // _di_controller_rule_error_print_
#ifndef _di_controller_rule_item_read_
- f_return_status controller_rule_item_read(const controller_data_t data, controller_rule_cache_t *cache, controller_rule_item_t *item) {
+ f_return_status controller_rule_item_read(const controller_data_t data, controller_cache_t *cache, controller_rule_item_t *item) {
f_status_t status = F_none;
f_string_range_t range = f_macro_string_range_t_initialize(cache->buffer_item.used);
#endif // _di_controller_rule_items_increase_by_
#ifndef _di_controller_rule_read_
- f_return_status controller_rule_read(const controller_data_t data, const controller_setting_t setting, const f_string_static_t rule_id, controller_rule_cache_t *cache, controller_rule_t *rule) {
+ f_return_status controller_rule_read(const controller_data_t data, const controller_setting_t setting, const f_string_static_t rule_id, controller_cache_t *cache, controller_rule_t *rule) {
f_status_t status = F_none;
bool for_item = F_true;
#endif // _di_controller_rule_read_
#ifndef _di_controller_rule_setting_read_
- f_return_status controller_rule_setting_read(const controller_data_t data, controller_rule_cache_t *cache, controller_rule_t *rule) {
+ f_return_status controller_rule_setting_read(const controller_data_t data, controller_cache_t *cache, controller_rule_t *rule) {
f_status_t status = F_none;
f_status_t status_return = F_none;
#ifndef _PRIVATE_rule_h
#define _PRIVATE_rule_h
-#include "private-controller.h"
-
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef _di_controller_rule_cache_t_
- typedef struct {
- f_string_length_t line_action;
- f_string_length_t line_item;
-
- f_string_range_t range_action;
-
- f_fss_comments_t comments;
- f_fss_delimits_t delimits;
-
- f_fss_content_t content_action;
- f_fss_contents_t content_actions;
- f_fss_contents_t content_items;
- f_fss_objects_t object_actions;
- f_fss_objects_t object_items;
-
- f_string_dynamic_t buffer_file;
- f_string_dynamic_t buffer_item;
- f_string_dynamic_t buffer_path;
-
- f_string_dynamic_t name_action;
- f_string_dynamic_t name_file;
- f_string_dynamic_t name_item;
- } controller_rule_cache_t;
-
- #define controller_rule_cache_t_initialize \
- { \
- 0, \
- 0, \
- f_string_range_t_initialize, \
- f_fss_comments_t_initialize, \
- f_fss_delimits_t_initialize, \
- f_fss_content_t_initialize, \
- f_fss_contents_t_initialize, \
- f_fss_contents_t_initialize, \
- f_fss_objects_t_initialize, \
- f_fss_objects_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- }
-
- #define controller_macro_rule_cache_t_delete_simple(cache) \
- f_macro_fss_comments_t_delete_simple(cache.comments) \
- f_macro_fss_delimits_t_delete_simple(cache.delimits) \
- f_macro_fss_content_t_delete_simple(cache.content_action) \
- f_macro_fss_contents_t_delete_simple(cache.content_actions) \
- f_macro_fss_contents_t_delete_simple(cache.content_items) \
- f_macro_fss_objects_t_delete_simple(cache.object_actions) \
- f_macro_fss_objects_t_delete_simple(cache.object_items) \
- f_macro_string_dynamic_t_delete_simple(cache.buffer_file) \
- f_macro_string_dynamic_t_delete_simple(cache.buffer_item) \
- f_macro_string_dynamic_t_delete_simple(cache.name_action) \
- f_macro_string_dynamic_t_delete_simple(cache.name_file) \
- f_macro_string_dynamic_t_delete_simple(cache.name_item)
-#endif // _di_controller_rule_cache_t_
-
/**
* Read the rule action.
*
* @see f_fss_count_lines()
*/
#ifndef _di_controller_rule_actions_read_
- extern f_return_status controller_rule_actions_read(const controller_data_t data, controller_rule_cache_t *cache, controller_rule_item_t *item, controller_rule_actions_t *actions, f_string_range_t *range) f_gcc_attribute_visibility_internal;
+ extern f_return_status controller_rule_actions_read(const controller_data_t data, controller_cache_t *cache, controller_rule_item_t *item, controller_rule_actions_t *actions, f_string_range_t *range) f_gcc_attribute_visibility_internal;
#endif // _di_controller_rule_actions_read_
/**
* @see controller_rule_setting_read()
*/
#ifndef _di_controller_rule_error_print_
- void controller_rule_error_print(const fll_error_print_t output, const controller_rule_cache_t cache, const bool item) f_gcc_attribute_visibility_internal;
+ void controller_rule_error_print(const fll_error_print_t output, const controller_cache_t cache, const bool item) f_gcc_attribute_visibility_internal;
#endif // _di_controller_rule_error_print_
/**
* @see fl_string_dynamic_terminate_after()
*/
#ifndef _di_controller_rule_item_read_
- extern f_return_status controller_rule_item_read(const controller_data_t data, controller_rule_cache_t *cache, controller_rule_item_t *item) f_gcc_attribute_visibility_internal;
+ extern f_return_status controller_rule_item_read(const controller_data_t data, controller_cache_t *cache, controller_rule_item_t *item) f_gcc_attribute_visibility_internal;
#endif // _di_controller_rule_item_read_
/**
* @see fll_fss_basic_list_read().
*/
#ifndef _di_controller_rule_read_
- extern f_return_status controller_rule_read(const controller_data_t data, const controller_setting_t setting, const f_string_static_t rule_id, controller_rule_cache_t *cache, controller_rule_t *rule) f_gcc_attribute_visibility_internal;
+ extern f_return_status controller_rule_read(const controller_data_t data, const controller_setting_t setting, const f_string_static_t rule_id, controller_cache_t *cache, controller_rule_t *rule) f_gcc_attribute_visibility_internal;
#endif // _di_controller_rule_read_
/**
* @see fll_path_canonical()
*/
#ifndef _di_controller_rule_setting_read_
- extern f_return_status controller_rule_setting_read(const controller_data_t data, controller_rule_cache_t *cache, controller_rule_t *rule) f_gcc_attribute_visibility_internal;
+ extern f_return_status controller_rule_setting_read(const controller_data_t data, controller_cache_t *cache, controller_rule_t *rule) f_gcc_attribute_visibility_internal;
#endif // _di_controller_rule_setting_read_
#ifdef __cplusplus