Don't provide default examples as the settings.
Move all of these into an examples directory.
The examples directory is placed under a data directory that is intended to be for files such as those under the /usr/share directory.
This shows that the Featureless Make build settings specification is missing the "build_sources_data" which is a /usr/share equivalent of "-build_sources_setting" (aka /etc).
build_sources_library rule.c rule/action.c rule/execute.c rule/expand.c rule/instance.c rule/is.c rule/item.c rule/parameter.c rule/read.c rule/setting.c rule/wait.c
build_sources_library perform.c
build_sources_library print/data.c
-build_sources_library print/debug.c print/debug/rule/action.c print/debug/rule/execute.c print/debug/perform/control.c print/debug/perform/pid.c
+build_sources_library print/debug.c print/debug/rule/action.c print/debug/rule/execute.c print/debug/rule/instance.c print/debug/perform/control.c print/debug/perform/pid.c
build_sources_library print/error.c
build_sources_library print/error/entry.c print/error/entry/action.c print/error/entry/item.c print/error/entry/setting.c
build_sources_library print/error/perform/pid.c
-build_sources_library print/error/rule.c print/error/rule/action.c print/error/rule/item.c print/error/rule/setting.c
+build_sources_library print/error/rule.c print/error/rule/action.c print/error/rule/instance.c print/error/rule/item.c print/error/rule/setting.c
build_sources_library print/lock.c print/error/lock.c
build_sources_library print/output/entry/setting.c print/output/rule/execute.c print/output/rule/setting.c print/output/rule/validate.c
build_sources_library print/message.c print/message/entry.c print/message/entry/action.c print/message/entry/item.c
build_sources_headers rule.h rule/action.h rule/execute.h rule/expand.h rule/instance.h rule/is.h rule/item.h rule/parameter.h rule/read.h rule/setting.h rule/wait.h
build_sources_headers perform.h
build_sources_headers print/data.h
-build_sources_headers print/debug.h print/debug/rule/action.h print/debug/rule/execute.h print/debug/perform/control.h print/debug/perform/pid.h
+build_sources_headers print/debug.h print/debug/rule/action.h print/debug/rule/execute.h print/debug/rule/instance.h print/debug/perform/control.h print/debug/perform/pid.h
build_sources_headers print/error.h
build_sources_headers print/error/entry.h print/error/entry/action.h print/error/entry/item.h print/error/entry/setting.h
build_sources_headers print/error/perform/pid.h
-build_sources_headers print/error/rule.h print/error/rule/action.h print/error/rule/item.h print/error/rule/setting.h
+build_sources_headers print/error/rule.h print/error/rule/action.h print/error/rule/instance.h print/error/rule/item.h print/error/rule/setting.h
build_sources_headers print/lock.h print/error/lock.h
build_sources_headers print/output/entry/setting.h print/output/rule/execute.h print/output/rule/setting.h print/output/rule/validate.h
build_sources_headers print/message.h print/message/entry.h print/message/entry/action.h print/message/entry/item.h
build_sources_documentation man
-build_sources_setting controller
-
build_script yes
build_shared yes
build_static no
#include <program/controller/main/print/debug/perform/pid.h>
#include <program/controller/main/print/debug/rule/action.h>
#include <program/controller/main/print/debug/rule/execute.h>
+#include <program/controller/main/print/debug/rule/instance.h>
#include <program/controller/main/print/error.h>
#include <program/controller/main/print/error/entry.h>
#include <program/controller/main/print/error/entry/action.h>
#include <program/controller/main/print/error/perform/pid.h>
#include <program/controller/main/print/error/rule.h>
#include <program/controller/main/print/error/rule/action.h>
+#include <program/controller/main/print/error/rule/instance.h>
#include <program/controller/main/print/error/rule/item.h>
#include <program/controller/main/print/error/rule/setting.h>
#include <program/controller/main/print/lock.h>
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
- * Provides the print Entry Action debug functionality.
+ * Provides the print Entry Rule Action debug functionality.
*
* This is auto-included and should not need to be explicitly included.
*/
-#ifndef _controller_main_print_debug_entry_action_h
-#define _controller_main_print_debug_entry_action_h
+#ifndef _controller_main_print_debug_rule_action_h
+#define _controller_main_print_debug_rule_action_h
#ifdef __cplusplus
extern "C" {
} // extern "C"
#endif
-#endif // _controller_main_print_debug_entry_action_h
+#endif // _controller_main_print_debug_rule_action_h
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
- * Provides the print Entry Action debug functionality.
+ * Provides the print Entry Rule execute debug functionality.
*
* This is auto-included and should not need to be explicitly included.
*/
--- /dev/null
+#include "../../../controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_print_debug_rule_instance_need_want_wish_
+ f_status_t controller_print_debug_rule_instance_need_want_wish(fl_print_t * const print, controller_instance_t * const instance, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why) {
+
+ if (!print || !print->custom || !instance) return F_status_set_error(F_output_not);
+ if (print->verbosity < f_console_verbosity_debug_e) return F_output_not;
+
+ controller_t * const main = (controller_t *) print->custom;
+
+ controller_lock_print(print->to, &main->thread);
+
+ controller_print_error_rule_item_need_want_wish(print, need_want_wish, value, why);
+
+ controller_print_error_rule_cache(print, &instance->cache.action, F_true);
+
+ controller_unlock_print_flush(print->to, &main->thread);
+
+ return F_okay;
+ }
+#endif // _di_controller_print_debug_rule_instance_need_want_wish_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the print Entry Rule Instance debug functionality.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_main_print_debug_rule_instance_h
+#define _controller_main_print_debug_rule_instance_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Print a warning message related to need/want/wish settings of some Rule for some Instance.
+ *
+ * @param print
+ * The output structure to print to.
+ *
+ * This requires print.custom to be controller_t.
+ *
+ * This does not alter print.custom.setting.state.status.
+ *
+ * Must not be NULL.
+ * @param instance
+ * The Controller Instance.
+ *
+ * Must not be NULL.
+ * @param need_want_wish
+ * The appropriate string, such as "needs", "wants", or "wishes for" to output when describing this error/warning.
+ * This string is expected to already be "safe" (no control characters, etc..).
+ * @param value
+ * The value that is the error or warning.
+ * @param why
+ * A short explanation on why this is an error or warning.
+ *
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_controller_print_debug_rule_instance_need_want_wish_
+ extern f_status_t controller_print_debug_rule_instance_need_want_wish(fl_print_t * const print, controller_instance_t * const instance, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why);
+#endif // #ifndef _di_controller_print_debug_rule_instance_need_want_wish_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_main_print_debug_rule_instance_h
--- /dev/null
+#include "../../../controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_print_error_rule_instance_need_want_wish_
+ f_status_t controller_print_error_rule_instance_need_want_wish(fl_print_t * const print, controller_instance_t * const instance, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why) {
+
+ if (!print || !print->custom || !instance) return F_status_set_error(F_output_not);
+ if (print->verbosity < f_console_verbosity_debug_e) return F_output_not;
+
+ controller_t * const main = (controller_t *) print->custom;
+
+ controller_lock_print(print->to, &main->thread);
+
+ controller_print_error_rule_item_need_want_wish(print, need_want_wish, value, why);
+
+ controller_print_error_rule_cache(print, &instance->cache.action, F_true);
+
+ controller_unlock_print_flush(print->to, &main->thread);
+
+ return F_okay;
+ }
+#endif // _di_controller_print_error_rule_instance_need_want_wish_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the print Entry Rule Instance error functionality.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_main_print_error_rule_instance_h
+#define _controller_main_print_error_rule_instance_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Print a error message related to need/want/wish settings of some Rule for some Instance.
+ *
+ * @param print
+ * The output structure to print to.
+ *
+ * This requires print.custom to be controller_t.
+ *
+ * This does not alter print.custom.setting.state.status.
+ *
+ * Must not be NULL.
+ * @param instance
+ * The Controller Instance.
+ *
+ * Must not be NULL.
+ * @param need_want_wish
+ * The appropriate string, such as "needs", "wants", or "wishes for" to output when describing this error/warning.
+ * This string is expected to already be "safe" (no control characters, etc..).
+ * @param value
+ * The value that is the error or warning.
+ * @param why
+ * A short explanation on why this is an error or warning.
+ *
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_controller_print_error_rule_instance_need_want_wish_
+ extern f_status_t controller_print_error_rule_instance_need_want_wish(fl_print_t * const print, controller_instance_t * const instance, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why);
+#endif // _di_controller_print_error_rule_instance_need_want_wish_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_main_print_error_rule_instance_h
#endif
#ifndef _di_controller_rule_execute_
- f_status_t controller_rule_execute(controller_t * const main, const uint8_t action, const uint8_t options, controller_instance_t * const instance) {
+ f_status_t controller_rule_execute(controller_t * const main, controller_instance_t * const instance, const uint8_t action, const uint8_t options) {
if (!main || !instance) return F_status_set_error(F_parameter);
}
do {
- status = controller_rule_execute_foreground(instance->rule.items.array[i].type, f_string_empty_s, instance->cache.expanded, options, &execute_set, instance);
+ status = controller_rule_execute_foreground(instance, instance->rule.items.array[i].type, f_string_empty_s, instance->cache.expanded, options, &execute_set);
- if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+ if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break;
} while (controller_rule_execute_rerun(instance, &instance->rule.items.array[i], controller_rule_action_type_to_action_execute_type(action)) > 0);
- if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+ if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
if (F_status_is_error(status)) {
instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure);
do {
if (instance->rule.engine.used) {
- status = controller_rule_execute_foreground(instance->rule.items.array[i].type, instance->rule.engine, instance->rule.engine_arguments, options, &execute_set, instance);
+ status = controller_rule_execute_foreground(instance, instance->rule.items.array[i].type, instance->rule.engine, instance->rule.engine_arguments, options, &execute_set);
}
else {
- status = controller_rule_execute_foreground(instance->rule.items.array[i].type, controller_default_engine_s, instance->rule.engine_arguments, options, &execute_set, instance);
+ status = controller_rule_execute_foreground(instance, instance->rule.items.array[i].type, controller_default_engine_s, instance->rule.engine_arguments, options, &execute_set);
}
- if (status == F_child || F_status_set_fine(status) == F_lock) break;
+ if (status == F_child || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break;
} while (controller_rule_execute_rerun(instance, &instance->rule.items.array[i], controller_rule_action_type_to_action_execute_type(action)) > 0);
- if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+ if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
if (F_status_is_error(status)) {
instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure);
do {
status = controller_rule_execute_pid_with(instance, instance->rule.items.array[i].pid_file, instance->rule.items.array[i].type, f_string_empty_s, instance->cache.expanded, options, instance->rule.items.array[i].with, &execute_set);
- if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+ if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break;
} while (controller_rule_execute_rerun(instance, &instance->rule.items.array[i], controller_rule_action_type_to_action_execute_type(action)) > 0);
- if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+ if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
if (F_status_is_error(status)) {
instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure);
do {
status = controller_rule_execute_pid_with(instance, instance->rule.items.array[i].pid_file, instance->rule.items.array[i].type, instance->rule.engine.used ? instance->rule.engine : controller_default_engine_s, instance->rule.engine_arguments, options, instance->rule.items.array[i].with, &execute_set);
- if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+ if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break;
} while (controller_rule_execute_rerun(instance, &instance->rule.items.array[i], controller_rule_action_type_to_action_execute_type(action)) > 0);
- if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+ if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
if (F_status_is_error(status)) {
instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure);
} // for
// Lock failed, attempt to re-establish lock before returning.
- if (F_status_set_fine(status) == F_lock) {
- status = controller_lock_read(instance->type != controller_instance_type_exit_e, F_true, &main->thread, &instance->lock);
- if (F_status_is_error(status)) return F_status_set_error(F_lock);
-
+ if (F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) {
success = F_false;
+
+ if (F_status_set_fine(status) == F_lock_read) {
+ status = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &main->thread, &instance->lock);
+ if (F_status_is_error(status)) return F_status_set_error(F_lock_read);
+
+ status = F_status_set_error(F_lock);
+ }
}
if (success == false && !instance->rule.items.used) {
#endif // _di_controller_rule_execute_
#ifndef _di_controller_rule_execute_foreground_
- f_status_t controller_rule_execute_foreground(const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_instance_t * const instance) {
+ f_status_t controller_rule_execute_foreground(controller_instance_t * const instance, const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set) {
if (!instance || !instance->main) return F_status_set_error(F_parameter);
status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &instance->main->thread, &instance->lock);
if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read);
- return F_status_set_error(F_lock_write);
+ return F_status_set_error(F_lock);
}
instance->result = result.status;
// Try again, after the first interrupt.
if (F_status_set_fine(status_lock) == F_interrupt) {
- status_lock = controller_lock_read_instance(instance, &instance->lock);
+ status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &instance->main->thread, &instance->lock);
}
if (F_status_is_error(status_lock)) {
}
}
- if (WIFEXITED(result.status) ? WEXITSTATUS(result.status) : 0) {
- status = F_status_set_error(F_failure);
- }
- else {
- status = F_okay;
- }
+ status = WIFEXITED(result.status) && WEXITSTATUS(result.status) ? F_status_set_error(F_failure) : F_okay;
}
else {
main->program.child = result.status;
status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &instance->main->thread, &instance->lock);
if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read);
- return F_status_set_error(F_lock_write);
+ return F_status_set_error(F_lock);
}
// Assign the child instance id to allow for the cancel instance to send appropriate termination signals to the child instance.
status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &instance->main->thread, &instance->lock);
if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read);
- return F_status_set_error(F_lock_write);
+ return F_status_set_error(F_lock);
}
instance->result = result.status;
return F_status_set_error(F_lock);
}
- if (WIFEXITED(result.status) ? WEXITSTATUS(result.status) : 0) {
- status = F_status_set_error(F_failure);
- }
- else {
- status = F_okay;
- }
+ status = WIFEXITED(result.status) && WEXITSTATUS(result.status) ? F_status_set_error(F_failure) : F_okay;
}
else {
main->program.child = result.status;
if (!instance || !instance->main || !item) return F_false;
- const int result = WIFEXITED(instance->result) ? WEXITSTATUS(instance->result) : 0;
+ const int result = WIFEXITED(instance->result) && WEXITSTATUS(instance->result);
if (item->reruns[action].is & (result ? controller_rule_rerun_is_failure_d : controller_rule_rerun_is_success_d)) {
controller_t * const main = instance->main;
/**
* Perform an execution of the given Rule.
*
- * This requires that a read lock be set on process->lock before being called.
+ * This requires that a read lock be set on instance->lock before being called.
*
* @param main
* The main program data.
* Must not be NULL.
*
* This does not alter main.setting.state.status.
+ * @param instance
+ * The instance data.
+ *
+ * Must not be NULL.
* @param action
* The Action to perform based on the Action type codes.
*
* @param options
* Process options to consider when executing.
* If bit controller_instance_option_simulate_e, then the Rule execution is in simulation mode (printing a message that the Rule would be executed but does not execute the rule).
- * @param instance
- * The instance data.
- *
- * Must not be NULL.
*
* @return
* F_okay on success.
*
* F_failure (with error bit) if failed to execute.
* F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal.
- * F_lock (with error bit) if failed to re-establish read lock on process->lock while returning.
+ * F_lock (with error bit) if failed to establish a lock, and the instance->lock read lock is already restored.
+ * F_lock_read (with error bit) if failed to re-establish read lock on instance->lock while returning.
*
* On success and the Rule is run synchronously, then the individual status for the Rule is set to F_complete.
* On success and the Rule is run asynchronously, then the individual status for the Rule is set to F_busy.
* On failure, the individual status for the Rule is set to an appropriate error status.
*/
#ifndef _di_controller_rule_execute_
- extern f_status_t controller_rule_execute(controller_t * const main, const uint8_t action, const uint8_t options, controller_instance_t * const instance);
+ extern f_status_t controller_rule_execute(controller_t * const main, controller_instance_t * const instance, const uint8_t action, const uint8_t options);
#endif // _di_controller_rule_execute_
/**
* Perform an execution of the given Rule in the foreground.
*
- * This requires that a read lock be set on process->lock before being called.
+ * This requires that a read lock be set on instance->lock before being called.
+ *
+ * @param instance
+ * The instance data.
*
+ * Must not be NULL.
* @param type
* The item type code.
* @param program
* The execute parameter and as settings.
*
* Must not be NULL.
- * @param instance
- * The instance data.
- *
- * Must not be NULL.
*
* @return
* F_okay on success.
* F_child on child process exiting.
*
* F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal.
- * F_lock_read (with error bit) if failed to re-establish read lock on process->lock while returning.
- * F_lock_write (with error bit) if failed to establish write lock on process->lock, and the read lock is able to be restored.
+ * F_lock (with error bit) if failed to establish a lock, and the instance->lock read lock is already restored.
+ * F_lock_read (with error bit) if failed to re-establish read lock on instance->lock while returning.
*
* Errors (with error bit) from: fll_execute_program().
*
* @see fll_execute_program()
*/
#ifndef _di_controller_rule_execute_foreground_
- extern f_status_t controller_rule_execute_foreground(const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_instance_t * const instance);
+ extern f_status_t controller_rule_execute_foreground(controller_instance_t * const instance, const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set);
#endif // _di_controller_rule_execute_foreground_
/**
/**
* Perform an execution of the given Rule in the foreground or background and creating a PID file.
*
- * This requires that a read lock be set on process->lock before being called.
+ * This requires that a read lock be set on instance->lock before being called.
*
* When this is synchronous, this will wait for the PID file to be generated before continuing.
* When this is asynchronous, this will continue on adding the Rule id and Action to the asynchronous list.
*
+ * @param instance
+ * The instance data.
+ *
+ * Must not be NULL.
* @param pid_file
* The path to the PID file.
* @param type
* The execute parameter and as settings.
*
* Must not be NULL.
- * @param instance
- * The instance data.
- *
- * Must not be NULL.
*
* @return
* F_okay on success.
*
* F_file_found (with error bit) if the PID file already exists.
* F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal.
- * F_lock_read (with error bit) if failed to re-establish read lock on process->lock while returning.
- * F_lock_write (with error bit) if failed to establish write lock on process->lock, and the read lock is able to be restored.
+ * F_lock (with error bit) if failed to establish a lock, and the instance->lock read lock is already restored.
+ * F_lock_read (with error bit) if failed to re-establish read lock on instance->lock while returning.
*
* Errors (with error bit) from: fll_execute_program().
*
f_number_unsigned_t id_rule = 0;
f_number_unsigned_t id_dependency = 0;
- bool found = F_false;
-
controller_instance_t *dependency = 0;
+ uint8_t found = F_false;
uint8_t options_instance = 0;
const f_string_static_t strings[3] = {
f_string_dynamics_t *dynamics[3] = { &empty, &empty, &empty };
if (instance->action) {
-
for (i = 0; i < instance->rule.ons.used; ++i) {
if (instance->rule.ons.array[i].action == instance->action) {
return status;
}
- status = F_true;
- }
-
- if (status == F_true) {
- found = F_true;
-
+ status = found = F_true;
dependency = main->thread.instances.array[id_dependency];
status_lock = controller_lock_read_instance(instance, &dependency->active);
}
}
}
- else {
- f_thread_unlock(&main->thread.lock.instance);
- }
if (status != F_true) {
found = F_false;
id_rule = 0;
- if (i == 0) {
- controller_lock_print(main->program.error.to, &main->thread);
-
- controller_print_error_rule_item_need_want_wish(&main->program.error, strings[i], dynamics[i]->array[j], "is not found");
- controller_print_error_rule_cache(&main->program.error, &instance->cache.action, F_true);
-
- controller_unlock_print_flush(main->program.error.to, &main->thread);
-
+ if (i) {
+ controller_print_debug_rule_instance_need_want_wish(&main->program.warning, instance, strings[i], dynamics[i]->array[j], "is not found");
+ }
+ else {
status = F_status_set_error(F_found_not);
+ controller_print_error_rule_instance_need_want_wish(&main->program.error, instance, strings[i], dynamics[i]->array[j], "is not found");
+
if (!(instance->options & controller_instance_option_simulate_e)) {
if (dependency) {
f_thread_unlock(&dependency->active);
break;
}
}
- else {
- if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(main->program.warning.to, &main->thread);
-
- controller_print_error_rule_item_need_want_wish(&main->program.warning, strings[i], dynamics[i]->array[j], "is not found");
-
- controller_print_error_rule_cache(&main->program.warning, &instance->cache.action, F_true);
-
- controller_unlock_print_flush(main->program.warning.to, &main->thread);
- }
- }
}
else if (found) {
status_lock = controller_lock_read_instance(instance, &main->thread.lock.rule);
if (F_status_is_error(status)) {
if (i == 0 || i == 1 || F_status_set_fine(status) == F_memory_not) {
- controller_lock_print(main->program.error.to, &main->thread);
-
- controller_print_error_rule_item_need_want_wish(&main->program.error, strings[i], alias_other_buffer, "failed during execution");
- controller_print_error_rule_cache(&main->program.error, &instance->cache.action, F_true);
-
- controller_unlock_print_flush(main->program.error.to, &main->thread);
+ controller_print_error_rule_instance_need_want_wish(&main->program.error, instance, strings[i], alias_other_buffer, "failed during execution");
if (!(dependency->options & controller_instance_option_simulate_e) || F_status_set_fine(status) == F_memory_not) {
f_thread_unlock(&dependency->active);
}
}
else {
- if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(main->program.warning.to, &main->thread);
-
- controller_print_error_rule_item_need_want_wish(&main->program.warning, strings[i], alias_other_buffer, "failed during execution");
-
- controller_print_error_rule_cache(&main->program.warning, &instance->cache.action, F_true);
-
- controller_unlock_print_flush(main->program.warning.to, &main->thread);
- }
+ controller_print_debug_rule_instance_need_want_wish(&main->program.warning, instance, strings[i], alias_other_buffer, "failed during execution");
}
}
}
}
if (F_status_is_error(status_lock)) {
- if (F_status_is_error(status_lock)) {
- controller_print_error_rule_item_need_want_wish(&main->program.error, strings[i], alias_other_buffer, "due to lock failure");
- }
-
status = status_lock;
+
+ controller_print_error_rule_instance_need_want_wish(&main->program.error, instance, strings[i], alias_other_buffer, "due to lock failure");
}
else if (controller_rule_status_is_error(instance->action, main->process.rules.array[id_rule])) {
f_thread_unlock(&main->thread.lock.rule);
if (i == 0 || i == 1) {
- controller_lock_print(main->program.error.to, &main->thread);
-
- controller_print_error_rule_item_need_want_wish(&main->program.error, strings[i], alias_other_buffer, "is in a failed state");
-
- controller_print_error_rule_cache(&main->program.error, &instance->cache.action, F_true);
-
- controller_unlock_print_flush(main->program.error.to, &main->thread);
-
status = F_status_set_error(F_found_not);
+ controller_print_error_rule_instance_need_want_wish(&main->program.error, instance, strings[i], alias_other_buffer, "is in a failed state");
+
if (!(dependency->options & controller_instance_option_simulate_e)) {
f_thread_unlock(&dependency->active);
}
}
else {
- if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(main->program.warning.to, &main->thread);
-
- controller_print_error_rule_item_need_want_wish(&main->program.warning, strings[i], alias_other_buffer, "is in a failed state");
-
- controller_print_error_rule_cache(&main->program.warning, &instance->cache.action, F_true);
-
- controller_unlock_print_flush(main->program.warning.to, &main->thread);
- }
+ controller_print_debug_rule_instance_need_want_wish(&main->program.warning, instance, strings[i], alias_other_buffer, "is in a failed state");
}
}
else {
}
if (F_status_is_error_not(status)) {
- status = controller_rule_execute(main, instance->action, instance->options, instance);
+ status = controller_rule_execute(main, instance, instance->action, instance->options);
- if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) return status;
+ if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) return status;
if (F_status_is_error(status)) {
controller_print_error_rule_item(&main->program.error, &instance->cache.action, F_true, F_status_set_fine(status));
if (F_status_is_error(status_lock)) {
controller_print_error_lock_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
- if (F_status_set_fine(status) != F_interrupt) {
- status = controller_lock_read_instance(instance, &instance->lock);
- if (F_status_is_error_not(status)) return status_lock;
- }
+ status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &main->thread, &instance->lock);
+ if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read);
return F_status_set_error(F_lock);
}
if (F_status_is_error(status_lock)) {
controller_print_error_lock_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
+ // Remove the write lock and restore the read lock.
f_thread_unlock(&instance->lock);
- status = controller_lock_read_instance(instance, &instance->lock);
- if (F_status_is_error_not(status)) return status_lock;
+ status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &main->thread, &instance->lock);
+ if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read);
return F_status_set_error(F_lock);
}
f_number_unsigned_t j = 0;
- controller_rule_item_t *rule_item = 0;
-
// Copy all Rule Item Action statuses from the Rule instance to the Rule.
for (i = 0; i < rule->items.used; ++i) {
- rule_item = &rule->items.array[i];
-
- for (j = 0; j < rule_item->actions.used; ++j) {
- rule_item->actions.array[j].status = instance->rule.items.array[i].actions.array[j].status;
+ for (j = 0; j < rule->items.array[i].actions.used; ++j) {
+ rule->items.array[i].actions.array[j].status = instance->rule.items.array[i].actions.array[j].status;
} // for
} // for
}
if (F_status_is_error(status_lock)) {
controller_print_error_lock_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
+ status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &main->thread, &instance->lock);
+ if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read);
+
return F_status_set_error(F_lock);
}
* F_failure on execution failure.
*
* F_interrupt (with error bit) on receiving a instance signal, such as an interrupt signal.
- * F_lock (with error bit) if failed to re-establish read lock on instance->lock while returning.
+ * F_lock (with error bit) if failed to establish a lock, and the instance->lock read lock is already restored.
+ * F_lock_read (with error bit) if failed to re-establish read lock on instance->lock while returning.
*
* Errors (with error bit) from: controller_lock_read().
* Errors (with error bit) from: controller_lock_write().