The f_socket_listen() seems to need its own process or thread.
Give it one.
Make this one as isolated as possible so that it can be forcible exited.
(Because listen() doesn't respect signal handlers.)
#endif
#ifndef _di_controller_cache_action_delete_simple_
- void controller_cache_action_delete_simple(controller_cache_action_t *cache) {
+ void controller_cache_action_delete_simple(controller_cache_action_t * const cache) {
f_string_dynamic_resize(0, &cache->name_action);
f_string_dynamic_resize(0, &cache->name_file);
#endif // _di_controller_cache_action_delete_simple_
#ifndef _di_controller_cache_delete_simple_
- void controller_cache_delete_simple(controller_cache_t *cache) {
+ void controller_cache_delete_simple(controller_cache_t * const cache) {
macro_f_array_lengths_t_delete_simple(cache->ats)
macro_f_array_lengths_t_delete_simple(cache->stack)
* @see f_string_dynamic_resize()
*/
#ifndef _di_controller_cache_action_delete_simple_
- extern void controller_cache_action_delete_simple(controller_cache_action_t *cache) F_attribute_visibility_internal_d;
+ extern void controller_cache_action_delete_simple(controller_cache_action_t * const cache) F_attribute_visibility_internal_d;
#endif // _di_controller_cache_action_delete_simple_
/**
* @see f_string_rangess_resize()
*/
#ifndef _di_controller_cache_delete_simple_
- extern void controller_cache_delete_simple(controller_cache_t *cache) F_attribute_visibility_internal_d;
+ extern void controller_cache_delete_simple(controller_cache_t * const cache) F_attribute_visibility_internal_d;
#endif // _di_controller_cache_delete_simple_
#ifdef __cplusplus
--- /dev/null
+#include "../controller.h"
+#include "../private-common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_packet_delete_simple_
+ void controller_packet_delete_simple(controller_packet_t * const packet) {
+
+ f_string_dynamic_resize(0, &packet->payload);
+ }
+#endif // _di_controller_packet_delete_simple_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ */
+#ifndef _PRIVATE_common_control_h
+#define _PRIVATE_common_control_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Provide default control settings.
+ *
+ * controller_control_default:
+ * - socket_backlog: The amount of waiting client connections to support while handling a socket connection.
+ * - socket_buffer: The size of the buffer in bytes when processing packets (must not be set smaller the packet headers).
+ * - socket_header: The minimum size of the packet header to read to be able to process the size information.
+ * - socket_linger: The number of seconds to linger the connection before closing.
+ * - socket_timeout: The number of microseconds to wait.
+ */
+#ifndef _di_controller_control_defaults_
+ #define controller_control_default_socket_backlog_d 64
+ #define controller_control_default_socket_buffer_d 16384
+ #define controller_control_default_socket_header_d 33
+ #define controller_control_default_socket_linger_d 1
+ #define controller_control_default_socket_timeout_d 10000 // 0.01 seconds.
+#endif // _di_controller_defaults_
+
+/**
+ * A structure representing the packet payload.
+ *
+ * Payload structure: [uint32_t][char X].
+ *
+ * bytes: The header repesenting the number of bytes in the character payload.
+ * payload: The character payload whose size is represented by the header bytes.
+ */
+#ifndef _di_controller_packet_t_
+ typedef struct {
+ uint32_t bytes;
+ f_string_dynamic_t payload;
+ } controller_packet_t;
+
+ #define controller_packet_t_initialize { 0, f_string_dynamic_t_initialize }
+
+ #define macro_controller_packet_t_initialize(bytes, payload) { \
+ bytes, \
+ payload, \
+ }
+#endif // _di_controller_main_t_
+
+/**
+ * Fully deallocate all memory for the given packet without caring about return status.
+ *
+ * @param packet
+ * The packet to deallocate.
+ */
+#ifndef _di_controller_packet_delete_simple_
+ extern void controller_packet_delete_simple(controller_packet_t * const packet) F_attribute_visibility_internal_d;
+#endif // _di_controller_packet_delete_simple_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _PRIVATE_common_control_h
#endif
#ifndef _di_controller_entry_action_delete_simple_
- void controller_entry_action_delete_simple(controller_entry_action_t *action) {
+ void controller_entry_action_delete_simple(controller_entry_action_t * const action) {
f_string_dynamics_resize(0, &action->parameters);
}
#endif // _di_controller_entry_action_delete_simple_
#ifndef _di_controller_entry_actions_delete_simple_
- void controller_entry_actions_delete_simple(controller_entry_actions_t *actions) {
+ void controller_entry_actions_delete_simple(controller_entry_actions_t * const actions) {
actions->used = actions->size;
#endif // _di_controller_entry_actions_delete_simple_
#ifndef _di_controller_entry_actions_increase_by_
- f_status_t controller_entry_actions_increase_by(const f_array_length_t amount, controller_entry_actions_t *actions) {
+ f_status_t controller_entry_actions_increase_by(const f_array_length_t amount, controller_entry_actions_t * const actions) {
if (actions->used + amount > actions->size) {
if (actions->used + amount > F_array_length_t_size_d) {
#endif // _di_controller_entry_actions_increase_by_
#ifndef _di_controller_entry_item_delete_simple_
- void controller_entry_item_delete_simple(controller_entry_item_t *item) {
+ void controller_entry_item_delete_simple(controller_entry_item_t * const item) {
f_string_dynamic_resize(0, &item->name);
#endif // _di_controller_entry_item_delete_simple_
#ifndef _di_controller_entry_items_delete_simple_
- void controller_entry_items_delete_simple(controller_entry_items_t *items) {
+ void controller_entry_items_delete_simple(controller_entry_items_t * const items) {
items->used = items->size;
#endif // _di_controller_entry_items_delete_simple_
#ifndef _di_controller_entry_items_increase_by_
- f_status_t controller_entry_items_increase_by(const f_array_length_t amount, controller_entry_items_t *items) {
+ f_status_t controller_entry_items_increase_by(const f_array_length_t amount, controller_entry_items_t * const items) {
if (items->used + amount > items->size) {
if (items->used + amount > F_array_length_t_size_d) {
* @see f_string_dynamics_resize()
*/
#ifndef _di_controller_entry_action_delete_simple_
- extern void controller_entry_action_delete_simple(controller_entry_action_t *action) F_attribute_visibility_internal_d;
+ extern void controller_entry_action_delete_simple(controller_entry_action_t * const action) F_attribute_visibility_internal_d;
#endif // _di_controller_entry_action_delete_simple_
/**
* @see f_memory_delete()
*/
#ifndef _di_controller_entry_actions_delete_simple_
- extern void controller_entry_actions_delete_simple(controller_entry_actions_t *actions) F_attribute_visibility_internal_d;
+ extern void controller_entry_actions_delete_simple(controller_entry_actions_t * const actions) F_attribute_visibility_internal_d;
#endif // _di_controller_entry_actions_delete_simple_
/**
* @see f_memory_resize()
*/
#ifndef _di_controller_entry_actions_increase_by_
- extern f_status_t controller_entry_actions_increase_by(const f_array_length_t amount, controller_entry_actions_t *actions) F_attribute_visibility_internal_d;
+ extern f_status_t controller_entry_actions_increase_by(const f_array_length_t amount, controller_entry_actions_t * const actions) F_attribute_visibility_internal_d;
#endif // _di_controller_entry_actions_increase_by_
/**
* @see f_string_dynamic_resize()
*/
#ifndef _di_controller_entry_item_delete_simple_
- extern void controller_entry_item_delete_simple(controller_entry_item_t *item) F_attribute_visibility_internal_d;
+ extern void controller_entry_item_delete_simple(controller_entry_item_t * const item) F_attribute_visibility_internal_d;
#endif // _di_controller_entry_item_delete_simple_
/**
* @see f_memory_delete()
*/
#ifndef _di_controller_entry_items_delete_simple_
- extern void controller_entry_items_delete_simple(controller_entry_items_t *items) F_attribute_visibility_internal_d;
+ extern void controller_entry_items_delete_simple(controller_entry_items_t * const items) F_attribute_visibility_internal_d;
#endif // _di_controller_entry_items_delete_simple_
/**
* @see f_memory_resize()
*/
#ifndef _di_controller_entry_items_increase_by_
- extern f_status_t controller_entry_items_increase_by(const f_array_length_t amount, controller_entry_items_t *items) F_attribute_visibility_internal_d;
+ extern f_status_t controller_entry_items_increase_by(const f_array_length_t amount, controller_entry_items_t * const items) F_attribute_visibility_internal_d;
#endif // _di_controller_entry_items_increase_by_
#ifdef __cplusplus
#endif // _di_controller_lock_delete_rw_
#ifndef _di_controller_lock_delete_simple_
- void controller_lock_delete_simple(controller_lock_t *lock) {
+ void controller_lock_delete_simple(controller_lock_t * const lock) {
controller_lock_delete_mutex(&lock->print);
controller_lock_delete_mutex(&lock->alert);
* @see f_thread_mutex_delete()
*/
#ifndef _di_controller_lock_delete_simple_
- extern void controller_lock_delete_simple(controller_lock_t *lock) F_attribute_visibility_internal_d;
+ extern void controller_lock_delete_simple(controller_lock_t * const lock) F_attribute_visibility_internal_d;
#endif // _di_controller_lock_delete_simple_
#ifdef __cplusplus
#endif
#ifndef _di_controller_pids_increase_
- f_status_t controller_pids_increase(controller_pids_t *pids) {
+ f_status_t controller_pids_increase(controller_pids_t * const pids) {
if (pids->used + 1 > pids->size) {
f_array_length_t size = pids->used + controller_common_allocation_small_d;
#endif // _di_controller_pids_increase_
#ifndef _di_controller_pids_resize_
- f_status_t controller_pids_resize(const f_array_length_t length, controller_pids_t *pids) {
+ f_status_t controller_pids_resize(const f_array_length_t length, controller_pids_t * const pids) {
f_status_t status = F_none;
#endif // _di_controller_pids_resize_
#ifndef _di_controller_process_delete_simple_
- void controller_process_delete_simple(controller_process_t *process) {
+ void controller_process_delete_simple(controller_process_t * const process) {
if (process->id_thread) {
f_thread_signal(process->id_thread, F_signal_kill);
#endif // _di_controller_process_delete_simple_
#ifndef _di_controller_processs_delete_simple_
- void controller_processs_delete_simple(controller_processs_t *processs) {
+ void controller_processs_delete_simple(controller_processs_t * const processs) {
controller_processs_resize(0, processs);
}
#endif // _di_controller_processs_delete_simple_
#ifndef _di_controller_processs_increase_
- f_status_t controller_processs_increase(controller_processs_t *processs) {
+ f_status_t controller_processs_increase(controller_processs_t * const processs) {
if (processs->used + 1 > processs->size) {
f_array_length_t size = processs->used + controller_common_allocation_small_d;
#endif // _di_controller_processs_increase_
#ifndef _di_controller_processs_resize_
- f_status_t controller_processs_resize(const f_array_length_t length, controller_processs_t *processs) {
+ f_status_t controller_processs_resize(const f_array_length_t length, controller_processs_t * const processs) {
f_status_t status = F_none;
* @see controller_pids_resize()
*/
#ifndef _di_controller_pids_increase_
- extern f_status_t controller_pids_increase(controller_pids_t *pids) F_attribute_visibility_internal_d;
+ extern f_status_t controller_pids_increase(controller_pids_t * const pids) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_increase_
/**
* @see f_memory_resize()
*/
#ifndef _di_controller_pids_resize_
- extern f_status_t controller_pids_resize(const f_array_length_t length, controller_pids_t *pids) F_attribute_visibility_internal_d;
+ extern f_status_t controller_pids_resize(const f_array_length_t length, controller_pids_t * const pids) F_attribute_visibility_internal_d;
#endif // _di_controller_pids_resize_
/**
* @see f_thread_mutex_delete()
*/
#ifndef _di_controller_process_delete_simple_
- extern void controller_process_delete_simple(controller_process_t *process) F_attribute_visibility_internal_d;
+ extern void controller_process_delete_simple(controller_process_t * const process) F_attribute_visibility_internal_d;
#endif // _di_controller_process_delete_simple_
/**
* @see controller_processs_resize()
*/
#ifndef _di_controller_processs_delete_simple_
- extern void controller_processs_delete_simple(controller_processs_t *processs) F_attribute_visibility_internal_d;
+ extern void controller_processs_delete_simple(controller_processs_t * const processs) F_attribute_visibility_internal_d;
#endif // _di_controller_processs_delete_simple_
/**
* @see controller_processs_resize()
*/
#ifndef _di_controller_processs_increase_
- extern f_status_t controller_processs_increase(controller_processs_t *processs) F_attribute_visibility_internal_d;
+ extern f_status_t controller_processs_increase(controller_processs_t * const processs) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_increase_
/**
* @see f_thread_lock_create()
*/
#ifndef _di_controller_processs_resize_
- extern f_status_t controller_processs_resize(const f_array_length_t length, controller_processs_t *processs) F_attribute_visibility_internal_d;
+ extern f_status_t controller_processs_resize(const f_array_length_t length, controller_processs_t * const processs) F_attribute_visibility_internal_d;
#endif // _di_controller_processs_resize_
#ifdef __cplusplus
#endif
#ifndef _di_controller_rule_action_delete_simple_
- void controller_rule_action_delete_simple(controller_rule_action_t *action) {
+ void controller_rule_action_delete_simple(controller_rule_action_t * const action) {
f_string_dynamics_resize(0, &action->parameters);
}
#endif // _di_controller_rule_action_delete_simple_
#ifndef _di_controller_rule_actions_delete_simple_
- void controller_rule_actions_delete_simple(controller_rule_actions_t *actions) {
+ void controller_rule_actions_delete_simple(controller_rule_actions_t * const actions) {
actions->used = actions->size;
#endif // _di_controller_rule_actions_delete_simple_
#ifndef _di_controller_rule_actions_increase_by_
- f_status_t controller_rule_actions_increase_by(const f_array_length_t amount, controller_rule_actions_t *actions) {
+ f_status_t controller_rule_actions_increase_by(const f_array_length_t amount, controller_rule_actions_t * const actions) {
if (actions->used + amount > actions->size) {
if (actions->used + amount > F_array_length_t_size_d) {
#endif // _di_controller_rule_delete_simple_
#ifndef _di_controller_rule_item_delete_simple_
- void controller_rule_item_delete_simple(controller_rule_item_t *item) {
+ void controller_rule_item_delete_simple(controller_rule_item_t * const item) {
f_string_dynamic_resize(0, &item->pid_file);
#endif // _di_controller_rule_item_delete_simple_
#ifndef _di_controller_rule_items_delete_simple_
- void controller_rule_items_delete_simple(controller_rule_items_t *items) {
+ void controller_rule_items_delete_simple(controller_rule_items_t * const items) {
items->used = items->size;
#endif // _di_controller_rule_items_delete_simple_
#ifndef _di_controller_rule_on_delete_simple_
- void controller_rule_on_delete_simple(controller_rule_on_t *on) {
+ void controller_rule_on_delete_simple(controller_rule_on_t * const on) {
f_string_dynamics_resize(0, &on->need);
f_string_dynamics_resize(0, &on->want);
#endif // _di_controller_rule_on_delete_simple_
#ifndef _di_controller_rule_ons_delete_simple_
- void controller_rule_ons_delete_simple(controller_rule_ons_t *ons) {
+ void controller_rule_ons_delete_simple(controller_rule_ons_t * const ons) {
ons->used = ons->size;
#endif // _di_controller_rule_ons_delete_simple_
#ifndef _di_controller_rule_ons_increase_
- f_status_t controller_rule_ons_increase(controller_rule_ons_t *ons) {
+ f_status_t controller_rule_ons_increase(controller_rule_ons_t * const ons) {
if (ons->used + 1 > ons->size) {
f_array_length_t size = ons->used + controller_common_allocation_small_d;
#endif // _di_controller_rule_ons_increase_
#ifndef _di_controller_rule_ons_resize_
- f_status_t controller_rule_ons_resize(const f_array_length_t length, controller_rule_ons_t *ons) {
+ f_status_t controller_rule_ons_resize(const f_array_length_t length, controller_rule_ons_t * const ons) {
for (f_array_length_t i = length; i < ons->size; ++i) {
controller_rule_on_delete_simple(&ons->array[i]);
#endif // _di_controller_rule_ons_resize_
#ifndef _di_controller_rules_delete_simple_
- void controller_rules_delete_simple(controller_rules_t *rules) {
+ void controller_rules_delete_simple(controller_rules_t * const rules) {
controller_rules_resize(0, rules);
}
#endif // _di_controller_rules_delete_simple_
#ifndef _di_controller_rules_increase_
- f_status_t controller_rules_increase(controller_rules_t *rules) {
+ f_status_t controller_rules_increase(controller_rules_t * const rules) {
if (rules->used + 1 > rules->size) {
f_array_length_t size = rules->used + controller_common_allocation_small_d;
#endif // _di_controller_rules_increase_
#ifndef _di_controller_rules_resize_
- f_status_t controller_rules_resize(const f_array_length_t length, controller_rules_t *rules) {
+ f_status_t controller_rules_resize(const f_array_length_t length, controller_rules_t * const rules) {
for (f_array_length_t i = length; i < rules->size; ++i) {
controller_rule_delete_simple(&rules->array[i]);
* @see f_string_dynamics_resize()
*/
#ifndef _di_controller_rule_action_delete_simple_
- extern void controller_rule_action_delete_simple(controller_rule_action_t *action) F_attribute_visibility_internal_d;
+ extern void controller_rule_action_delete_simple(controller_rule_action_t * const action) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_action_delete_simple_
/**
* @see f_memory_delete()
*/
#ifndef _di_controller_rule_actions_delete_simple_
- extern void controller_rule_actions_delete_simple(controller_rule_actions_t *actions) F_attribute_visibility_internal_d;
+ extern void controller_rule_actions_delete_simple(controller_rule_actions_t * const actions) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_actions_delete_simple_
/**
* Errors (with error bit) from: f_memory_resize().
*/
#ifndef _di_controller_rule_actions_increase_by_
- extern f_status_t controller_rule_actions_increase_by(const f_array_length_t amount, controller_rule_actions_t *actions) F_attribute_visibility_internal_d;
+ extern f_status_t controller_rule_actions_increase_by(const f_array_length_t amount, controller_rule_actions_t * const actions) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_actions_increase_by_
/**
* @see f_string_dynamic_resize()
*/
#ifndef _di_controller_rule_delete_simple_
- extern void controller_rule_delete_simple(controller_rule_t *rule) F_attribute_visibility_internal_d;
+ extern void controller_rule_delete_simple(controller_rule_t * const rule) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_delete_simple_
/**
* @see f_string_dynamic_resize()
*/
#ifndef _di_controller_rule_item_delete_simple_
- extern void controller_rule_item_delete_simple(controller_rule_item_t *item) F_attribute_visibility_internal_d;
+ extern void controller_rule_item_delete_simple(controller_rule_item_t * const item) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_item_delete_simple_
/**
* @see f_memory_delete()
*/
#ifndef _di_controller_rule_items_delete_simple_
- extern void controller_rule_items_delete_simple(controller_rule_items_t *items) F_attribute_visibility_internal_d;
+ extern void controller_rule_items_delete_simple(controller_rule_items_t * const items) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_items_delete_simple_
/**
* @see f_string_dynamic_resize()
*/
#ifndef _di_controller_rule_on_delete_simple_
- extern void controller_rule_on_delete_simple(controller_rule_on_t *on) F_attribute_visibility_internal_d;
+ extern void controller_rule_on_delete_simple(controller_rule_on_t * const on) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_on_delete_simple_
/**
* @see f_memory_delete()
*/
#ifndef _di_controller_rule_ons_delete_simple_
- extern void controller_rule_ons_delete_simple(controller_rule_ons_t *ons) F_attribute_visibility_internal_d;
+ extern void controller_rule_ons_delete_simple(controller_rule_ons_t * const ons) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_ons_delete_simple_
/**
* @see controller_rule_ons_resize()
*/
#ifndef _di_controller_rule_ons_increase_
- extern f_status_t controller_rule_ons_increase(controller_rule_ons_t *ons) F_attribute_visibility_internal_d;
+ extern f_status_t controller_rule_ons_increase(controller_rule_ons_t * const ons) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_increase_
/**
* @see f_memory_resize()
*/
#ifndef _di_controller_rule_ons_resize_
- extern f_status_t controller_rule_ons_resize(const f_array_length_t length, controller_rule_ons_t *ons) F_attribute_visibility_internal_d;
+ extern f_status_t controller_rule_ons_resize(const f_array_length_t length, controller_rule_ons_t * const ons) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_ons_resize_
/**
* @see controller_rules_resize()
*/
#ifndef _di_controller_rules_delete_simple_
- extern void controller_rules_delete_simple(controller_rules_t *rules) F_attribute_visibility_internal_d;
+ extern void controller_rules_delete_simple(controller_rules_t * const rules) F_attribute_visibility_internal_d;
#endif // _di_controller_rules_delete_simple_
/**
* @see controller_rules_resize()
*/
#ifndef _di_controller_rules_increase_
- extern f_status_t controller_rules_increase(controller_rules_t *rules) F_attribute_visibility_internal_d;
+ extern f_status_t controller_rules_increase(controller_rules_t * const rules) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_increase_
/**
* @see f_memory_resize()
*/
#ifndef _di_controller_rules_resize_
- extern f_status_t controller_rules_resize(const f_array_length_t length, controller_rules_t *rules) F_attribute_visibility_internal_d;
+ extern f_status_t controller_rules_resize(const f_array_length_t length, controller_rules_t * const rules) F_attribute_visibility_internal_d;
#endif // _di_controller_rules_resize_
#ifdef __cplusplus
#endif
#ifndef _di_controller_setting_delete_simple_
- void controller_setting_delete_simple(controller_setting_t *setting) {
+ void controller_setting_delete_simple(controller_setting_t * const setting) {
f_string_dynamic_resize(0, &setting->path_control);
f_string_dynamic_resize(0, &setting->path_cgroup);
* @see f_string_dynamic_resize()
*/
#ifndef _di_controller_setting_delete_simple_
- extern void controller_setting_delete_simple(controller_setting_t *setting) F_attribute_visibility_internal_d;
+ extern void controller_setting_delete_simple(controller_setting_t * const setting) F_attribute_visibility_internal_d;
#endif // _di_controller_setting_delete_simple_
#ifdef __cplusplus
#endif
#ifndef _di_controller_task_action_delete_simple_
- void controller_task_action_delete_simple(controller_task_action_t *action) {
+ void controller_task_action_delete_simple(controller_task_action_t * const action) {
f_string_dynamic_resize(0, &action->help);
f_string_dynamics_resize(0, &action->parameters);
#endif // _di_controller_task_action_delete_simple_
#ifndef _di_controller_task_actions_delete_simple_
- void controller_task_actions_delete_simple(controller_task_actions_t *actions) {
+ void controller_task_actions_delete_simple(controller_task_actions_t * const actions) {
actions->used = actions->size;
#endif // _di_controller_task_actions_delete_simple_
#ifndef _di_controller_task_actions_increase_by_
- f_status_t controller_task_actions_increase_by(const f_array_length_t amount, controller_task_actions_t *actions) {
+ f_status_t controller_task_actions_increase_by(const f_array_length_t amount, controller_task_actions_t * const actions) {
if (actions->used + amount > actions->size) {
if (actions->used + amount > F_array_length_t_size_d) {
#endif // _di_controller_task_delete_simple_
#ifndef _di_controller_tasks_delete_simple_
- void controller_tasks_delete_simple(controller_tasks_t *tasks) {
+ void controller_tasks_delete_simple(controller_tasks_t * const tasks) {
controller_tasks_resize(0, tasks);
}
#endif // _di_controller_tasks_delete_simple_
#ifndef _di_controller_tasks_increase_
- f_status_t controller_tasks_increase(controller_tasks_t *tasks) {
+ f_status_t controller_tasks_increase(controller_tasks_t * const tasks) {
if (tasks->used + 1 > tasks->size) {
f_array_length_t size = tasks->used + controller_common_allocation_small_d;
#endif // _di_controller_tasks_increase_
#ifndef _di_controller_tasks_resize_
- f_status_t controller_tasks_resize(const f_array_length_t length, controller_tasks_t *tasks) {
+ f_status_t controller_tasks_resize(const f_array_length_t length, controller_tasks_t * const tasks) {
for (f_array_length_t i = length; i < tasks->size; ++i) {
controller_task_delete_simple(&tasks->array[i]);
* @see f_string_dynamics_resize()
*/
#ifndef _di_controller_task_action_delete_simple_
- extern void controller_task_action_delete_simple(controller_task_action_t *action) F_attribute_visibility_internal_d;
+ extern void controller_task_action_delete_simple(controller_task_action_t * const action) F_attribute_visibility_internal_d;
#endif // _di_controller_task_action_delete_simple_
/**
* Errors (with error bit) from: f_memory_resize().
*/
#ifndef _di_controller_task_actions_increase_by_
- extern f_status_t controller_task_actions_increase_by(const f_array_length_t amount, controller_task_actions_t *actions) F_attribute_visibility_internal_d;
+ extern f_status_t controller_task_actions_increase_by(const f_array_length_t amount, controller_task_actions_t * const actions) F_attribute_visibility_internal_d;
#endif // _di_controller_task_actions_increase_by_
/**
* @see controller_task_items_delete_simple()
*/
#ifndef _di_controller_task_delete_simple_
- extern void controller_task_delete_simple(controller_task_t *task) F_attribute_visibility_internal_d;
+ extern void controller_task_delete_simple(controller_task_t * const task) F_attribute_visibility_internal_d;
#endif // _di_controller_task_delete_simple_
/**
* @see controller_tasks_resize()
*/
#ifndef _di_controller_tasks_delete_simple_
- extern void controller_tasks_delete_simple(controller_tasks_t *tasks) F_attribute_visibility_internal_d;
+ extern void controller_tasks_delete_simple(controller_tasks_t * const tasks) F_attribute_visibility_internal_d;
#endif // _di_controller_tasks_delete_simple_
/**
* @see controller_tasks_resize()
*/
#ifndef _di_controller_tasks_increase_
- extern f_status_t controller_tasks_increase(controller_tasks_t *tasks) F_attribute_visibility_internal_d;
+ extern f_status_t controller_tasks_increase(controller_tasks_t * const tasks) F_attribute_visibility_internal_d;
#endif // _di_controller_task_increase_
/**
* @see f_memory_resize()
*/
#ifndef _di_controller_tasks_resize_
- extern f_status_t controller_tasks_resize(const f_array_length_t length, controller_tasks_t *tasks) F_attribute_visibility_internal_d;
+ extern f_status_t controller_tasks_resize(const f_array_length_t length, controller_tasks_t * const tasks) F_attribute_visibility_internal_d;
#endif // _di_controller_tasks_resize_
#ifdef __cplusplus
#endif
#ifndef _di_controller_thread_delete_simple_
- void controller_thread_delete_simple(controller_thread_t *thread) {
+ void controller_thread_delete_simple(controller_thread_t * const thread) {
controller_lock_delete_simple(&thread->lock);
controller_processs_resize(0, &thread->processs);
* id_cleanup: The thread ID representing the Cleanup Process.
* id_control: The thread ID representing the Control Process.
* id_entry: The thread ID representing the Entry or Exit Process.
+ * id_listen: The thread ID representing the Control Process Listener.
* id_rule: The thread ID representing the Rule Process.
* id_signal: The thread ID representing the Signal Process.
* lock: A r/w lock for operating on this structure.
f_thread_id_t id_cleanup;
f_thread_id_t id_control;
f_thread_id_t id_entry;
+ f_thread_id_t id_listen;
f_thread_id_t id_rule;
f_thread_id_t id_signal;
f_thread_id_t_initialize, \
f_thread_id_t_initialize, \
f_thread_id_t_initialize, \
+ f_thread_id_t_initialize, \
controller_lock_t_initialize, \
controller_processs_t_initialize, \
controller_cache_t_initialize, \
#include "common/private-setting.h"
#include "common/private-thread.h"
#include "common/private-state.h"
+#include "common/private-control.h"
/**
* All special strings used within this program.
#include "controller.h"
#include "private-common.h"
#include "private-control.h"
+#include "private-controller_print.h"
#ifdef __cplusplus
extern "C" {
#endif
+#ifndef _di_controller_control_configure_client_
+ f_status_t controller_control_configure_client(const controller_global_t *global, f_socket_t * const client) {
+
+ struct timeval time_out;
+ time_out.tv_sec = 0;
+ time_out.tv_usec = controller_control_default_socket_timeout_d;
+
+ f_status_t status = f_socket_option_set(client, 1, f_socket_option_time_out_receive_d, (void *) &time_out, sizeof(struct timeval));
+
+ if (F_status_is_error_not(status)) {
+ status = f_socket_option_set(client, 1, f_socket_option_time_out_send_d, (void *) &time_out, sizeof(struct timeval));
+ }
+
+ if (F_status_is_error(status)) {
+ controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_socket_option_set", F_true);
+ }
+
+ return status;
+ }
+#endif // _di_controller_control_configure_client_
+
+#ifndef _di_controller_control_configure_server_
+ f_status_t controller_control_configure_server(const controller_global_t *global, f_socket_t * const server) {
+
+ struct linger value = { 1, 1 };
+
+ f_status_t status = f_socket_option_set(server, controller_control_default_socket_linger_d, f_socket_option_linger_d, (void *) &value, sizeof(struct linger));
+
+ if (F_status_is_error(status)) {
+ controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_socket_option_set", F_true);
+ }
+
+ return status;
+ }
+#endif // _di_controller_control_configure_server_
+
+#ifndef _di_controller_control_accept_
+ f_status_t controller_control_accept(const controller_global_t *global, f_socket_t * const server, controller_packet_t * const packet) {
+
+ f_socket_t client = f_socket_t_initialize;
+
+ f_status_t status = f_socket_accept(&client, server->id);
+
+ if (F_status_is_error(status)) {
+ f_socket_disconnect(&client, f_socket_close_read_write_e);
+
+ controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_socket_accept", F_true);
+
+ return status;
+ }
+
+ controller_control_configure_client(global, &client);
+
+ char buffer[controller_control_default_socket_buffer_d + 1];
+ size_t length = 0;
+
+ memset(buffer, 0, controller_control_default_socket_buffer_d + 1);
+ packet->payload.used = 0;
+
+ // Pre-process the packet header.
+ client.size_read = controller_control_default_socket_header_d;
+ status = f_socket_read(&client, f_socket_flag_peek_d, buffer, &length);
+
+ if (F_status_is_error(status)) {
+ f_socket_disconnect(&client, f_socket_close_read_write_e);
+
+ controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_socket_read", F_true);
+
+ return status;
+ }
+
+ client.size_read = controller_control_default_socket_buffer_d;
+
+ // Get all remaining data.
+ //while (???) { // until done, based on expected length that should be described in the packet header.
+ //message_length = recv(&client, buffer, input_size, receive_flags);
+
+ //} // while
+
+ // process the data.
+
+ // send any responses.
+ // sent = send(&client, packet, output_size, send_flags);
+
+ f_socket_disconnect(&client, f_socket_close_read_write_e);
+
+ return F_none;
+ }
+#endif // _di_controller_control_accept_
+
#ifdef __cplusplus
} // extern "C"
#endif
extern "C" {
#endif
+/**
+ * Configure client socket settings.
+ *
+ * @param global
+ * The global data.
+ * @param client
+ * The client socket structure.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_socket_option_set().
+ *
+ * @see f_socket_option_set()
+ */
+#ifndef _di_controller_control_configure_client_
+ extern f_status_t controller_control_configure_client(const controller_global_t *global, f_socket_t * const client) F_attribute_visibility_internal_d;
+#endif // _di_controller_control_configure_client_
+
+/**
+ * Configure server socket settings.
+ *
+ * @param global
+ * The global data.
+ * @param server
+ * The server socket structure.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_socket_option_set().
+ *
+ * @see f_socket_option_set()
+ */
+#ifndef _di_controller_control_configure_server_
+ extern f_status_t controller_control_configure_server(const controller_global_t *global, f_socket_t * const server) F_attribute_visibility_internal_d;
+#endif // _di_controller_control_configure_server_
+
+/**
+ * Accept connections from a control socket server.
+ *
+ * Connectons are processed and actions are performed.
+ *
+ * @param global
+ * The global data.
+ * @param socket
+ * The socket structure.
+ * @param packet
+ * The control packet data structure.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_socket_accept().
+ *
+ * @see f_socket_accept()
+ */
+#ifndef _di_controller_control_accept_
+ extern f_status_t controller_control_accept(const controller_global_t *global, f_socket_t * const server, controller_packet_t * const packet) F_attribute_visibility_internal_d;
+#endif // _di_controller_control_accept_
+
#ifdef __cplusplus
} // extern "C"
#endif
#include "private-controller_print.h"
#include "private-entry_print.h"
#include "private-lock_print.h"
+#include "private-thread_control.h"
#ifdef __cplusplus
extern "C" {
if (F_status_is_error(status)) {
if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_append", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_append", F_true);
}
return status;
if (F_status_is_error(status)) {
if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
}
return status;
}
if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_print_error_file(global.main->error, F_status_set_fine(status), "f_file_stream_open", F_true, path, "open", fll_error_file_type_file_e, global.thread);
+ controller_print_error_file(global.thread, global.main->error, F_status_set_fine(status), "f_file_stream_open", F_true, path, "open", fll_error_file_type_file_e);
}
}
else {
if (F_status_is_error(status)) {
if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_print_error_file(global.main->error, F_status_set_fine(status), "f_file_stream_read", F_true, path, "read", fll_error_file_type_file_e, global.thread);
+ controller_print_error_file(global.thread, global.main->error, F_status_set_fine(status), "f_file_stream_read", F_true, path, "read", fll_error_file_type_file_e);
}
}
}
if (F_status_is_error(status)) {
if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_print_error_file(global.main->error, F_status_set_fine(status), "f_file_stat", F_true, path, "stat", fll_error_file_type_file_e, global.thread);
+ controller_print_error_file(global.thread, global.main->error, F_status_set_fine(status), "f_file_stat", F_true, path, "stat", fll_error_file_type_file_e);
}
}
else {
#endif // _di_controller_file_pid_delete_
#ifndef _di_controller_file_pid_read_
- f_status_t controller_file_pid_read(const f_string_static_t path, pid_t *pid) {
+ f_status_t controller_file_pid_read(const f_string_static_t path, pid_t * const pid) {
*pid = 0;
#endif // _di_controller_file_pid_read_
#ifndef _di_controller_get_id_user_
- f_status_t controller_get_id_user(const f_string_static_t buffer, const f_string_range_t range, controller_cache_t * const cache, uid_t *id) {
+ f_status_t controller_get_id_user(const f_string_static_t buffer, const f_string_range_t range, controller_cache_t * const cache, uid_t * const id) {
f_number_unsigned_t number = 0;
f_status_t status = fl_conversion_string_to_number_unsigned(buffer.string, range, &number);
if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
-
- if (status == F_number) {
+ if (F_status_set_fine(status) == F_number) {
cache->action.generic.used = 0;
- status = f_string_dynamic_partial_append_nulless(buffer, range, &cache->action.generic);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_terminate(&cache->action.generic);
+ status = controller_dynamic_rip_nulless_terminated(buffer, range, &cache->action.generic);
if (F_status_is_error(status)) return status;
status = f_account_id_user_by_name(cache->action.generic.string, id);
return F_none;
}
- return F_status_set_error(status);
+ return status;
}
else if (number > F_type_size_32_unsigned_d) {
return F_status_set_error(F_number_too_large);
}
- *id = (uid_t) number;
-
return status;
}
#endif // _di_controller_get_id_user_
#ifndef _di_controller_get_id_group_
- f_status_t controller_get_id_group(const f_string_static_t buffer, const f_string_range_t range, controller_cache_t * const cache, gid_t *id) {
+ f_status_t controller_get_id_group(const f_string_static_t buffer, const f_string_range_t range, controller_cache_t * const cache, gid_t * const id) {
f_number_unsigned_t number = 0;
f_status_t status = fl_conversion_string_to_number_unsigned(buffer.string, range, &number);
if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
-
- if (status == F_number) {
+ if (F_status_set_fine(status) == F_number) {
cache->action.generic.used = 0;
- status = f_string_dynamic_partial_append_nulless(buffer, range, &cache->action.generic);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_terminate(&cache->action.generic);
+ status = controller_dynamic_rip_nulless_terminated(buffer, range, &cache->action.generic);
if (F_status_is_error(status)) return status;
status = f_account_id_group_by_name(cache->action.generic.string, id);
return F_none;
}
- return F_status_set_error(status);
+ return status;
}
else if (number > F_type_size_32_unsigned_d) {
return F_status_set_error(F_number_too_large);
}
- *id = (gid_t) number;
-
return status;
}
#endif // _di_controller_get_id_group_
#ifndef _di_controller_perform_ready_
- f_status_t controller_perform_ready(const controller_global_t global, const bool is_entry, controller_cache_t * const cache) {
+ f_status_t controller_perform_ready(const controller_global_t *global, controller_cache_t * const cache, const bool is_entry) {
if (!is_entry) {
return F_none;
f_status_t status = F_none;
- if (global.setting->entry.pid != controller_entry_pid_disable_e && !global.setting->path_pid.used) {
- if (global.main->parameters[controller_parameter_validate_e].result == f_console_result_additional_e) {
- status = controller_file_pid_create(global.main->pid, global.setting->path_pid);
+ if (global->setting->entry.pid != controller_entry_pid_disable_e && !global->setting->path_pid.used) {
+ if (global->main->parameters[controller_parameter_validate_e].result == f_console_result_additional_e) {
+ status = controller_file_pid_create(global->main->pid, global->setting->path_pid);
}
// Report pid file error but because this could be an "init" program, consider the pid file as optional and continue on.
// Always return immediately on memory errors.
if (F_status_set_fine(status) == F_memory_not) {
- if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->error.to, global.thread);
+ if (global->main->error.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->error.to, global->thread);
- controller_print_error_file(global.main->error, F_status_set_fine(status), "controller_file_pid_create", F_true, global.setting->path_pid.string, "create", fll_error_file_type_file_e, 0);
+ controller_print_error_file(0, global->main->error, F_status_set_fine(status), "controller_file_pid_create", F_true, global->setting->path_pid.string, "create", fll_error_file_type_file_e);
- flockfile(global.main->error.to.stream);
+ flockfile(global->main->error.to.stream);
- controller_entry_print_error_cache(is_entry, global.main->error, cache->action);
+ controller_entry_print_error_cache(is_entry, global->main->error, cache->action);
- controller_unlock_print_flush(global.main->error.to, global.thread);
+ controller_unlock_print_flush(global->main->error.to, global->thread);
}
return status;
}
- if (global.main->warning.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global.main->warning.to, global.thread);
+ if (global->main->warning.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(global->main->warning.to, global->thread);
if (F_status_set_fine(status) == F_read_only) {
- fl_print_format("%c%[%SThe pid file '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context);
- fl_print_format("%[%Q%]", global.main->warning.to.stream, global.main->warning.notable, global.setting->path_pid, global.main->warning.notable);
- fl_print_format("%[' could not be written because the destination is read only.%]%c", global.main->warning.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]);
+ fl_print_format("%c%[%SThe pid file '%]", global->main->warning.to.stream, f_string_eol_s[0], global->main->warning.context, global->main->warning.prefix, global->main->warning.context);
+ fl_print_format("%[%Q%]", global->main->warning.to.stream, global->main->warning.notable, global->setting->path_pid, global->main->warning.notable);
+ fl_print_format("%[' could not be written because the destination is read only.%]%c", global->main->warning.to.stream, global->main->warning.context, global->main->warning.context, f_string_eol_s[0]);
}
else {
- controller_print_error_file(global.main->warning, F_status_set_fine(status), "controller_file_pid_create", F_true, global.setting->path_pid.string, "create", fll_error_file_type_file_e, 0);
+ controller_print_error_file(0, global->main->warning, F_status_set_fine(status), "controller_file_pid_create", F_true, global->setting->path_pid.string, "create", fll_error_file_type_file_e);
}
- controller_entry_print_error_cache(is_entry, global.main->warning, cache->action);
+ controller_entry_print_error_cache(is_entry, global->main->warning, cache->action);
- controller_unlock_print_flush(global.main->warning.to, global.thread);
+ controller_unlock_print_flush(global->main->warning.to, global->thread);
}
status = F_none;
}
else {
- global.setting->pid_created = F_true;
+ global->setting->pid_created = F_true;
- if (global.main->output.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->main->output.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%cPID file '", global.main->output.to.stream, f_string_eol_s[0]);
- fl_print_format("%[%Q%]", global.main->output.to.stream, global.main->context.set.notable, global.setting->path_pid, global.main->context.set.notable);
+ fl_print_format("%cPID file '", global->main->output.to.stream, f_string_eol_s[0]);
+ fl_print_format("%[%Q%]", global->main->output.to.stream, global->main->context.set.notable, global->setting->path_pid, global->main->context.set.notable);
- if (global.main->parameters[controller_parameter_validate_e].result == f_console_result_none_e) {
- fl_print_format("' created.%c", global.main->output.to.stream, f_string_eol_s[0]);
+ if (global->main->parameters[controller_parameter_validate_e].result == f_console_result_none_e) {
+ fl_print_format("' created.%c", global->main->output.to.stream, f_string_eol_s[0]);
}
else {
- fl_print_format("'.%c", global.main->output.to.stream, f_string_eol_s[0]);
+ fl_print_format("'.%c", global->main->output.to.stream, f_string_eol_s[0]);
}
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
}
}
- if (global.setting->path_control.used) {
- if (global.setting->control_readonly) {
- if (f_file_exists(global.setting->path_control.string) != F_true) {
- if (global.main->output.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->setting->path_control.used) {
+ if (global->setting->control_readonly) {
+ if (f_file_exists(global->setting->path_control.string) != F_true) {
+ if (global->main->output.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%c%[%SControl socket '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context);
- fl_print_format("%[%Q%]", global.main->output.to.stream, global.main->context.set.notable, global.setting->path_control, global.main->context.set.notable);
- fl_print_format("' .%c", global.main->output.to.stream, f_string_eol_s[0]);
- fl_print_format("%[' cannot be found while read only mode is enabled and so the Control socket is unavailable.%]%c", global.main->output.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]);
+ fl_print_format("%c%[%SControl socket '%]", global->main->warning.to.stream, f_string_eol_s[0], global->main->warning.context, global->main->warning.prefix, global->main->warning.context);
+ fl_print_format("%[%Q%]", global->main->output.to.stream, global->main->context.set.notable, global->setting->path_control, global->main->context.set.notable);
+ fl_print_format("' .%c", global->main->output.to.stream, f_string_eol_s[0]);
+ fl_print_format("%[' cannot be found while read only mode is enabled and so the Control socket is unavailable.%]%c", global->main->output.to.stream, global->main->warning.context, global->main->warning.context, f_string_eol_s[0]);
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
return status;
}
}
else {
- status = f_socket_create(&global.setting->control_socket);
+ status = f_socket_create(&global->setting->control_socket);
if (F_status_is_error(status)) {
if (F_status_set_fine(status) == F_memory_not) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_socket_create", F_true, global.thread);
+ controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_socket_create", F_true);
return status;
}
- if (global.main->output.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->main->output.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%c%[%SControl socket '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context);
- fl_print_format("%[%Q%]", global.main->output.to.stream, global.main->context.set.notable, global.setting->path_control, global.main->context.set.notable);
- fl_print_format("%[' could not be created, code %]", global.main->output.to.stream, global.main->warning.context, global.main->warning.context);
- fl_print_format("%[%ui%]", global.main->output.to.stream, global.main->context.set.notable, F_status_set_fine(status), global.main->context.set.notable);
- fl_print_format("%[.%]%c", global.main->output.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]);
+ fl_print_format("%c%[%SControl socket '%]", global->main->warning.to.stream, f_string_eol_s[0], global->main->warning.context, global->main->warning.prefix, global->main->warning.context);
+ fl_print_format("%[%Q%]", global->main->output.to.stream, global->main->context.set.notable, global->setting->path_control, global->main->context.set.notable);
+ fl_print_format("%[' could not be created, code %]", global->main->output.to.stream, global->main->warning.context, global->main->warning.context);
+ fl_print_format("%[%ui%]", global->main->output.to.stream, global->main->context.set.notable, F_status_set_fine(status), global->main->context.set.notable);
+ fl_print_format("%[.%]%c", global->main->output.to.stream, global->main->warning.context, global->main->warning.context, f_string_eol_s[0]);
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
}
else {
- status = f_file_remove(global.setting->path_control.string);
+ status = f_file_remove(global->setting->path_control.string);
if (F_status_set_fine(status) == F_memory_not) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_file_remove", F_true, global.thread);
+ controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_file_remove", F_true);
return status;
}
- global.setting->control_socket.name = global.setting->path_control.string;
+ global->setting->control_socket.name = global->setting->path_control.string;
- status = f_socket_bind_file(global.setting->control_socket);
+ status = f_socket_bind_file(global->setting->control_socket);
if (F_status_is_error(status)) {
- f_socket_disconnect(&global.setting->control_socket, f_socket_close_fast_e);
+ f_socket_disconnect(&global->setting->control_socket, f_socket_close_fast_e);
if (F_status_set_fine(status) == F_memory_not) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_socket_bind_file", F_true, global.thread);
+ controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_socket_bind_file", F_true);
return status;
}
- if (global.main->output.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->main->output.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%c%[%SControl socket '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context);
- fl_print_format("%[%Q%]", global.main->output.to.stream, global.main->context.set.notable, global.setting->path_control, global.main->context.set.notable);
- fl_print_format("%[' could not be bound, code %]", global.main->output.to.stream, global.main->warning.context, global.main->warning.context);
- fl_print_format("%[%ui%]", global.main->output.to.stream, global.main->context.set.notable, F_status_set_fine(status), global.main->context.set.notable);
- fl_print_format("%[.%]%c", global.main->output.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]);
+ fl_print_format("%c%[%SControl socket '%]", global->main->warning.to.stream, f_string_eol_s[0], global->main->warning.context, global->main->warning.prefix, global->main->warning.context);
+ fl_print_format("%[%Q%]", global->main->output.to.stream, global->main->context.set.notable, global->setting->path_control, global->main->context.set.notable);
+ fl_print_format("%[' could not be bound, code %]", global->main->output.to.stream, global->main->warning.context, global->main->warning.context);
+ fl_print_format("%[%ui%]", global->main->output.to.stream, global->main->context.set.notable, F_status_set_fine(status), global->main->context.set.notable);
+ fl_print_format("%[.%]%c", global->main->output.to.stream, global->main->warning.context, global->main->warning.context, f_string_eol_s[0]);
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
}
else {
- status = f_file_role_change(global.setting->path_control.string, global.setting->control_user, global.setting->control_group, F_true);
+ status = f_file_role_change(global->setting->path_control.string, global->setting->control_user, global->setting->control_group, F_true);
if (F_status_is_error(status)) {
- f_socket_disconnect(&global.setting->control_socket, f_socket_close_fast_e);
+ f_socket_disconnect(&global->setting->control_socket, f_socket_close_fast_e);
if (F_status_set_fine(status) == F_memory_not) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_file_role_change", F_true, global.thread);
+ controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_file_role_change", F_true);
return status;
}
- if (global.main->output.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->main->output.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%c%[%SControl socket '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context);
- fl_print_format("%[%Q%]", global.main->output.to.stream, global.main->context.set.notable, global.setting->path_control, global.main->context.set.notable);
- fl_print_format("%[' failed to set file roles, code %]", global.main->output.to.stream, global.main->warning.context, global.main->warning.context);
- fl_print_format("%[%ui%]", global.main->output.to.stream, global.main->context.set.notable, F_status_set_fine(status), global.main->context.set.notable);
- fl_print_format("%[.%]%c", global.main->output.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]);
+ fl_print_format("%c%[%SControl socket '%]", global->main->warning.to.stream, f_string_eol_s[0], global->main->warning.context, global->main->warning.prefix, global->main->warning.context);
+ fl_print_format("%[%Q%]", global->main->output.to.stream, global->main->context.set.notable, global->setting->path_control, global->main->context.set.notable);
+ fl_print_format("%[' failed to set file roles, code %]", global->main->output.to.stream, global->main->warning.context, global->main->warning.context);
+ fl_print_format("%[%ui%]", global->main->output.to.stream, global->main->context.set.notable, F_status_set_fine(status), global->main->context.set.notable);
+ fl_print_format("%[.%]%c", global->main->output.to.stream, global->main->warning.context, global->main->warning.context, f_string_eol_s[0]);
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
}
else {
- status = f_file_mode_set(global.setting->path_control.string, global.setting->control_mode);
+ status = f_file_mode_set(global->setting->path_control.string, global->setting->control_mode);
if (F_status_is_error(status)) {
- f_socket_disconnect(&global.setting->control_socket, f_socket_close_fast_e);
+ f_socket_disconnect(&global->setting->control_socket, f_socket_close_fast_e);
if (F_status_set_fine(status) == F_memory_not) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_file_role_change", F_true, global.thread);
+ controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_file_role_change", F_true);
return status;
}
- if (global.main->output.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->main->output.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%c%[%SControl socket '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context);
- fl_print_format("%[%Q%]", global.main->output.to.stream, global.main->context.set.notable, global.setting->path_control, global.main->context.set.notable);
- fl_print_format("%[' failed to set file mode, code %]", global.main->output.to.stream, global.main->warning.context, global.main->warning.context);
- fl_print_format("%[%ui%]", global.main->output.to.stream, global.main->context.set.notable, F_status_set_fine(status), global.main->context.set.notable);
- fl_print_format("%[.%]%c", global.main->output.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]);
+ fl_print_format("%c%[%SControl socket '%]", global->main->warning.to.stream, f_string_eol_s[0], global->main->warning.context, global->main->warning.prefix, global->main->warning.context);
+ fl_print_format("%[%Q%]", global->main->output.to.stream, global->main->context.set.notable, global->setting->path_control, global->main->context.set.notable);
+ fl_print_format("%[' failed to set file mode, code %]", global->main->output.to.stream, global->main->warning.context, global->main->warning.context);
+ fl_print_format("%[%ui%]", global->main->output.to.stream, global->main->context.set.notable, F_status_set_fine(status), global->main->context.set.notable);
+ fl_print_format("%[.%]%c", global->main->output.to.stream, global->main->warning.context, global->main->warning.context, f_string_eol_s[0]);
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
}
else {
- if (global.main->output.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->main->output.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%cControl socket '", global.main->output.to.stream, f_string_eol_s[0]);
- fl_print_format("%[%Q%]", global.main->output.to.stream, global.main->context.set.notable, global.setting->path_control, global.main->context.set.notable);
+ fl_print_format("%cControl socket '", global->main->output.to.stream, f_string_eol_s[0]);
+ fl_print_format("%[%Q%]", global->main->output.to.stream, global->main->context.set.notable, global->setting->path_control, global->main->context.set.notable);
- if (global.main->parameters[controller_parameter_validate_e].result == f_console_result_none_e) {
- fl_print_format("' created.%c", global.main->output.to.stream, f_string_eol_s[0]);
+ if (global->main->parameters[controller_parameter_validate_e].result == f_console_result_none_e) {
+ fl_print_format("' created.%c", global->main->output.to.stream, f_string_eol_s[0]);
}
else {
- fl_print_format("'.%c", global.main->output.to.stream, f_string_eol_s[0]);
+ fl_print_format("'.%c", global->main->output.to.stream, f_string_eol_s[0]);
}
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
+ }
+
+ status = f_thread_create(0, &global->thread->id_listen, &controller_thread_control_listen, (void *) global);
+
+ if (status == F_child) {
+ return status;
}
- // @todo start the control thread.
+ if (F_status_is_error_not(status)) {
+ status = f_thread_create(0, &global->thread->id_control, &controller_thread_control, (void *) global);
+
+ if (status == F_child) {
+ return status;
+ }
+ }
+
+ if (F_status_is_error(status)) {
+ if (global->thread->id_listen) {
+ f_thread_cancel(global->thread->id_listen);
+ f_thread_join(global->thread->id_listen, 0);
+
+ global->thread->id_listen = 0;
+ }
+
+ global->thread->id_control = 0;
+
+ if (global->main->error.verbosity != f_console_verbosity_quiet_e) {
+ controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_thread_create", F_true);
+ }
+ }
}
}
}
#ifndef _di_controller_time_sleep_nanoseconds_
int controller_time_sleep_nanoseconds(controller_main_t * const main, controller_setting_t * const setting, struct timespec time) {
- if (setting->interruptible) {
- f_signal_mask(SIG_UNBLOCK, &main->signal.set, 0);
- }
+ // When sleep is a second or more, instead wait for terminating signals if interruptible.
+ if (setting->interruptible && time.tv_sec) {
+ siginfo_t information;
+ f_signal_t signal = f_signal_t_initialize;
+
+ memset(&information, 0, sizeof(siginfo_t));
- const int result = nanosleep(&time, 0);
+ f_signal_set_empty(&signal.set);
+ f_signal_set_add(F_signal_abort, &signal.set);
+ f_signal_set_add(F_signal_interrupt, &signal.set);
+ f_signal_set_add(F_signal_quit, &signal.set);
+ f_signal_set_add(F_signal_termination, &signal.set);
- if (setting->interruptible) {
- f_signal_mask(SIG_BLOCK, &main->signal.set, 0);
+ if (F_status_is_error(f_signal_wait_until(&signal.set, &time, &information))) {
+ return -1;
+ }
+
+ return 0;
}
- return result;
+ return nanosleep(&time, 0);
}
#endif // _di_controller_time_sleep_nanoseconds_
* Errors (with error bit) from: fl_conversion_string_to_decimal_unsigned()
*/
#ifndef _di_controller_file_pid_read_
- f_status_t controller_file_pid_read(const f_string_static_t path, pid_t *pid) F_attribute_visibility_internal_d;
+ f_status_t controller_file_pid_read(const f_string_static_t path, pid_t * const pid) F_attribute_visibility_internal_d;
#endif // _di_controller_file_pid_read_
/**
* @see fl_conversion_string_to_number_unsigned()
*/
#ifndef _di_controller_get_id_user_
- f_status_t controller_get_id_user(const f_string_static_t buffer, const f_string_range_t range, controller_cache_t * const cache, uid_t *id) F_attribute_visibility_internal_d;
+ f_status_t controller_get_id_user(const f_string_static_t buffer, const f_string_range_t range, controller_cache_t * const cache, uid_t * const id) F_attribute_visibility_internal_d;
#endif // _di_controller_get_id_user_
/**
* @see fl_conversion_string_to_number_unsigned()
*/
#ifndef _di_controller_get_id_group_
- f_status_t controller_get_id_group(const f_string_static_t buffer, const f_string_range_t range, controller_cache_t * const cache, gid_t *id) F_attribute_visibility_internal_d;
+ f_status_t controller_get_id_group(const f_string_static_t buffer, const f_string_range_t range, controller_cache_t * const cache, gid_t * const id) F_attribute_visibility_internal_d;
#endif // _di_controller_get_id_group_
/**
*
* @param global
* The global data.
+ * @param cache
+ * The cache.
* @param is_entry
* If TRUE, then this operate as an entry.
* If FALSE, then this operate as an exit.
- * @param cache
- * The cache.
*
* @return
* F_none on success.
* @see controller_file_pid_create()
*/
#ifndef _di_controller_perform_ready_
- extern f_status_t controller_perform_ready(const controller_global_t global, const bool is_entry, controller_cache_t * const cache) F_attribute_visibility_internal_d;
+ extern f_status_t controller_perform_ready(const controller_global_t *global, controller_cache_t * const cache, const bool is_entry) F_attribute_visibility_internal_d;
#endif // _di_controller_perform_ready_
/**
/**
* Sleep for a given number of nanoseconds.
*
- * The nanosleep() function handles signals within itself.
- * Temporarily unblock signals so that the nanosleep can receive the signal and then restore the signals once done.
- *
- * The signals will not be unblocked when in uninterruptible mode.
- *
* @param main
* The main program data.
* @param setting
* The number of nanoseconds to sleep.
*
* @return
- * The results of nanosleep().
+ * The result of nanosleep().
*
* @see nanosleep()
- * @see controller_time_milliseconds()
*/
#ifndef _di_controller_time_sleep_nanoseconds_
extern int controller_time_sleep_nanoseconds(controller_main_t * const main, controller_setting_t * const setting, struct timespec time) F_attribute_visibility_internal_d;
#endif
#ifndef _di_controller_print_error_
- void controller_print_error(const fl_print_t print, const f_status_t status, const f_string_t function, const bool fallback, controller_thread_t *thread) {
+ void controller_print_error(controller_thread_t * const thread, const fl_print_t print, const f_status_t status, const f_string_t function, const bool fallback) {
if (print.verbosity == f_console_verbosity_quiet_e) return;
if (status == F_interrupt) return;
#endif // _di_controller_print_error_
#ifndef _di_controller_print_error_file_
- void controller_print_error_file(const fl_print_t print, const f_status_t status, const f_string_t function, const bool fallback, const f_string_t name, const f_string_t operation, const uint8_t type, controller_thread_t *thread) {
+ void controller_print_error_file(controller_thread_t * const thread, const fl_print_t print, const f_status_t status, const f_string_t function, const bool fallback, const f_string_t name, const f_string_t operation, const uint8_t type) {
if (print.verbosity == f_console_verbosity_quiet_e) return;
+ if (status == F_interrupt) return;
// fll_error_print() automatically locks, so manually handle only the mutex locking and flushing rather than calling controller_lock_print().
if (thread) {
/**
* Print the error, locking the print mutex during the print.
*
+ * @param thread
+ * (optional) The thread data.
+ * Set to NULL to disable locking on the thread (this should be done only if the lock is already in place).
* @param print
* Designates how printing is to be performed.
* @param status
* Set to 0 to disable.
* @param fallback
* Set to F_true to print the fallback error message for unknown errors.
- * @param thread
- * (optional) The thread data.
- * Set to NULL to disable locking on the thread (this should be done only if the lock is already in place).
*
* @see fll_error_print()
*/
#ifndef _di_controller_print_error_
- extern void controller_print_error(const fl_print_t print, const f_status_t status, const f_string_t function, const bool fallback, controller_thread_t *thread) F_attribute_visibility_internal_d;
+ extern void controller_print_error(controller_thread_t * const thread, const fl_print_t print, const f_status_t status, const f_string_t function, const bool fallback) F_attribute_visibility_internal_d;
#endif // _di_controller_print_error_
/**
* Print the file error, locking the print mutex during the print.
*
+ * @param thread
+ * (optional) The thread data.
+ * Set to NULL to disable locking on the thread (this should be done only if the lock is already in place).
* @param print
* Designates how printing is to be performed.
* @param status
* The operation that fails, such as 'create' or 'access'.
* @param type
* A valid file type code from the fll_error_file_type enum.
- * @param thread
- * (optional) The thread data.
- * Set to NULL to disable locking on the thread (this should be done only if the lock is already in place).
*
* @see fll_error_file_print()
*/
#ifndef _di_controller_print_error_file_
- extern void controller_print_error_file(const fl_print_t print, const f_status_t status, const f_string_t function, const bool fallback, const f_string_t name, const f_string_t operation, const uint8_t type, controller_thread_t *thread) F_attribute_visibility_internal_d;
+ extern void controller_print_error_file(controller_thread_t * const thread, const fl_print_t print, const f_status_t status, const f_string_t function, const bool fallback, const f_string_t name, const f_string_t operation, const uint8_t type) F_attribute_visibility_internal_d;
#endif // _di_controller_print_error_file_
/**
// If ready was never found in the entry, then default to always ready.
if (global.setting->ready == controller_setting_ready_no_e) {
global.setting->ready = controller_setting_ready_yes_e;
-
- // @todo set socket file if applicable.
}
return status;
#endif // _di_controller_entry_preprocess_
#ifndef _di_controller_entry_process_
- f_status_t controller_entry_process(const controller_global_t global, const bool failsafe, const bool is_entry, controller_cache_t * const cache) {
+ f_status_t controller_entry_process(const controller_global_t *global, controller_cache_t * const cache, const bool failsafe, const bool is_entry) {
f_status_t status = F_none;
f_status_t status_lock = F_none;
uint8_t options_force = 0;
uint8_t options_process = 0;
- controller_entry_t *entry = is_entry ? &global.setting->entry : &global.setting->exit;
+ controller_entry_t *entry = is_entry ? &global->setting->entry : &global->setting->exit;
controller_entry_action_t *entry_action = 0;
controller_entry_actions_t *entry_actions = 0;
controller_process_t *process = 0;
macro_f_array_lengths_t_increase_by(status, cache->ats, controller_common_allocation_small_d)
if (F_status_is_error(status)) {
- controller_entry_print_error(is_entry, global.main->error, cache->action, F_status_set_fine(status), "macro_f_array_lengths_t_increase_by", F_true, global.thread);
+ controller_entry_print_error(is_entry, global->main->error, cache->action, F_status_set_fine(status), "macro_f_array_lengths_t_increase_by", F_true, global->thread);
return status;
}
// utilize the ats cache as an item execution stack (at_i is for item index, and at_j (at_i + 1) is for action index).
- cache->ats.array[0] = failsafe ? global.setting->failsafe_item_id : 0;
+ cache->ats.array[0] = failsafe ? global->setting->failsafe_item_id : 0;
cache->ats.array[1] = 0;
cache->ats.used = 2;
status = controller_dynamic_append_terminated(entry->items.array[cache->ats.array[0]].name, &cache->action.name_item);
if (F_status_is_error(status)) {
- controller_entry_print_error(is_entry, global.main->error, cache->action, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true, global.thread);
+ controller_entry_print_error(is_entry, global->main->error, cache->action, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true, global->thread);
return status;
}
- if (global.main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e || global.main->error.verbosity == f_console_verbosity_verbose_e || global.main->error.verbosity == f_console_verbosity_debug_e) {
- if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e || global->main->error.verbosity == f_console_verbosity_verbose_e || global->main->error.verbosity == f_console_verbosity_debug_e) {
+ if (global->main->error.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%cProcessing %s%s item '", global.main->output.to.stream, f_string_eol_s[0], failsafe ? "failsafe " : "", is_entry ? controller_entry_s : controller_exit_s);
- fl_print_format("%[%Q%]'.%c", global.main->output.to.stream, global.main->context.set.notable, cache->action.name_item, global.main->context.set.notable, f_string_eol_s[0]);
+ fl_print_format("%cProcessing %s%s item '", global->main->output.to.stream, f_string_eol_s[0], failsafe ? "failsafe " : "", is_entry ? controller_entry_s : controller_exit_s);
+ fl_print_format("%[%Q%]'.%c", global->main->output.to.stream, global->main->context.set.notable, cache->action.name_item, global->main->context.set.notable, f_string_eol_s[0]);
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
}
- while (controller_thread_is_enabled(is_entry, global.thread)) {
+ // The pre-process determines if ready is explicitly specified within the entry file and if it is not start as ready.
+ if (global->setting->ready == controller_setting_ready_yes_e) {
+ status = controller_perform_ready(global, cache, is_entry);
+ if (F_status_is_error(status)) return status;
+ }
+
+ while (controller_thread_is_enabled(is_entry, global->thread)) {
entry_actions = &entry->items.array[cache->ats.array[at_i]].actions;
- for (; cache->ats.array[at_j] < entry_actions->used && controller_thread_is_enabled(is_entry, global.thread); ++cache->ats.array[at_j]) {
+ for (; cache->ats.array[at_j] < entry_actions->used && controller_thread_is_enabled(is_entry, global->thread); ++cache->ats.array[at_j]) {
entry_action = &entry_actions->array[cache->ats.array[at_j]];
status = controller_dynamic_append_terminated(controller_entry_action_type_name(entry_action->type), &cache->action.name_action);
if (F_status_is_error(status)) {
- controller_entry_print_error(is_entry, global.main->error, cache->action, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true, global.thread);
+ controller_entry_print_error(is_entry, global->main->error, cache->action, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true, global->thread);
return status;
}
if (F_status_is_error(entry_action->status)) {
- if (global.main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e) {
- if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e) {
+ if (global->main->error.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%cThe %s item action '", global.main->output.to.stream, f_string_eol_s[0], is_entry ? controller_entry_s : controller_exit_s);
- fl_print_format("%[%Q%]", global.main->output.to.stream, global.main->context.set.title, cache->action.name_action, global.main->context.set.title);
+ fl_print_format("%cThe %s item action '", global->main->output.to.stream, f_string_eol_s[0], is_entry ? controller_entry_s : controller_exit_s);
+ fl_print_format("%[%Q%]", global->main->output.to.stream, global->main->context.set.title, cache->action.name_action, global->main->context.set.title);
if (entry_action->parameters.used) {
- fl_print_format(" %[", global.main->output.to.stream, global.main->context.set.notable);
+ fl_print_format(" %[", global->main->output.to.stream, global->main->context.set.notable);
- controller_entry_action_parameters_print(global.main->output.to.stream, *entry_action);
+ controller_entry_action_parameters_print(global->main->output.to.stream, *entry_action);
- fl_print_format("%]", global.main->output.to.stream, global.main->context.set.notable);
+ fl_print_format("%]", global->main->output.to.stream, global->main->context.set.notable);
}
- fl_print_format("' is %[%s%] and is in a ", global.main->output.to.stream, global.main->context.set.notable, entry_action->code & controller_entry_rule_code_require_d ? "required" : "optional", global.main->context.set.notable);
+ fl_print_format("' is %[%s%] and is in a ", global->main->output.to.stream, global->main->context.set.notable, entry_action->code & controller_entry_rule_code_require_d ? "required" : "optional", global->main->context.set.notable);
- fl_print_format("%[failed%] state, skipping.%c", global.main->output.to.stream, global.main->context.set.notable, global.main->context.set.notable, global.main->context.set.notable, f_string_eol_s[0]);
+ fl_print_format("%[failed%] state, skipping.%c", global->main->output.to.stream, global->main->context.set.notable, global->main->context.set.notable, global->main->context.set.notable, f_string_eol_s[0]);
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
}
else {
- if ((entry_action->code & controller_entry_rule_code_require_d) && global.main->error.verbosity != f_console_verbosity_quiet_e || !(entry_action->code & controller_entry_rule_code_require_d) && (global.main->warning.verbosity == f_console_verbosity_verbose_e || global.main->warning.verbosity == f_console_verbosity_debug_e)) {
+ if ((entry_action->code & controller_entry_rule_code_require_d) && global->main->error.verbosity != f_console_verbosity_quiet_e || !(entry_action->code & controller_entry_rule_code_require_d) && (global->main->warning.verbosity == f_console_verbosity_verbose_e || global->main->warning.verbosity == f_console_verbosity_debug_e)) {
fl_print_t *output = 0;
if (entry_action->code & controller_entry_rule_code_require_d) {
- output = &global.main->error;
+ output = &global->main->error;
}
else {
- output = &global.main->warning;
+ output = &global->main->warning;
}
- controller_lock_print(output->to, global.thread);
+ controller_lock_print(output->to, global->thread);
fl_print_format("%c%[%SThe %s item action '%]", output->to.stream, f_string_eol_s[0], output->context, output->prefix ? output->prefix : f_string_empty_s, is_entry ? controller_entry_s : controller_exit_s, output->context);
fl_print_format("%[%Q%]", output->to.stream, output->notable, cache->action.name_action, output->notable);
if (entry_action->parameters.used) {
- fl_print_format(" %[", output->to.stream, global.main->context.set.notable);
+ fl_print_format(" %[", output->to.stream, global->main->context.set.notable);
controller_entry_action_parameters_print(output->to.stream, *entry_action);
- fl_print_format("%]", output->to.stream, global.main->context.set.notable);
+ fl_print_format("%]", output->to.stream, global->main->context.set.notable);
}
if (entry_action->code & controller_entry_rule_code_require_d) {
controller_entry_print_error_cache(is_entry, *output, cache->action);
- controller_unlock_print_flush(output->to, global.thread);
+ controller_unlock_print_flush(output->to, global->thread);
}
if (controller_entry_action_type_is_rule(entry_action->type) && entry_action->code & controller_entry_rule_code_require_d) {
}
if (entry_action->type == controller_entry_action_type_ready_e) {
- if ((entry_action->code & controller_entry_rule_code_wait_d) || global.setting->ready == controller_setting_ready_wait_e) {
- if (global.main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e || global.main->error.verbosity == f_console_verbosity_verbose_e || global.main->error.verbosity == f_console_verbosity_debug_e || entry->show == controller_entry_show_init_e) {
- if (global.main->output.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if ((entry_action->code & controller_entry_rule_code_wait_d) || global->setting->ready == controller_setting_ready_wait_e) {
+ if (global->main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e || global->main->error.verbosity == f_console_verbosity_verbose_e || global->main->error.verbosity == f_console_verbosity_debug_e || entry->show == controller_entry_show_init_e) {
+ if (global->main->output.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%cWaiting before processing %s item action '", global.main->output.to.stream, f_string_eol_s[0], is_entry ? controller_entry_s : controller_exit_s);
- fl_print_format("%[%s%]", global.main->output.to.stream, global.main->context.set.title, controller_ready_s, global.main->context.set.title);
- fl_print_format("'.%c", global.main->output.to.stream, f_string_eol_s[0]);
+ fl_print_format("%cWaiting before processing %s item action '", global->main->output.to.stream, f_string_eol_s[0], is_entry ? controller_entry_s : controller_exit_s);
+ fl_print_format("%[%s%]", global->main->output.to.stream, global->main->context.set.title, controller_ready_s, global->main->context.set.title);
+ fl_print_format("'.%c", global->main->output.to.stream, f_string_eol_s[0]);
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
}
- if (global.main->parameters[controller_parameter_validate_e].result == f_console_result_none_e) {
- status = controller_rule_wait_all(global, is_entry, F_false, process);
+ if (global->main->parameters[controller_parameter_validate_e].result == f_console_result_none_e) {
+ status = controller_rule_wait_all(*global, is_entry, F_false, process);
if (F_status_is_error(status)) return status;
}
}
- if (global.setting->ready == controller_setting_ready_yes_e) {
- if (global.main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e || global.main->error.verbosity == f_console_verbosity_verbose_e || global.main->error.verbosity == f_console_verbosity_debug_e) {
- if (global.main->output.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->setting->ready == controller_setting_ready_yes_e) {
+ if (global->main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e || global->main->error.verbosity == f_console_verbosity_verbose_e || global->main->error.verbosity == f_console_verbosity_debug_e) {
+ if (global->main->output.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%cIgnoring %s item action '", global.main->output.to.stream, f_string_eol_s[0], is_entry ? controller_entry_s : controller_exit_s);
- fl_print_format("%[%s%]", global.main->output.to.stream, global.main->context.set.title, controller_ready_s, global.main->context.set.title);
- fl_print_format("', state already is ready.%c", global.main->output.to.stream, f_string_eol_s[0]);
+ fl_print_format("%cIgnoring %s item action '", global->main->output.to.stream, f_string_eol_s[0], is_entry ? controller_entry_s : controller_exit_s);
+ fl_print_format("%[%s%]", global->main->output.to.stream, global->main->context.set.title, controller_ready_s, global->main->context.set.title);
+ fl_print_format("', state already is ready.%c", global->main->output.to.stream, f_string_eol_s[0]);
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
}
}
else {
- if (!failsafe && (global.main->error.verbosity == f_console_verbosity_verbose_e || entry->show == controller_entry_show_init_e) && global.main->parameters[controller_parameter_simulate_e].result == f_console_result_none_e) {
- fl_print_format("%cState is now '%[%s%]'.%c", global.main->output.to.stream, f_string_eol_s[0], global.main->context.set.notable, controller_ready_s, global.main->context.set.notable, f_string_eol_s[0]);
+ if (!failsafe && (global->main->error.verbosity == f_console_verbosity_verbose_e || entry->show == controller_entry_show_init_e) && global->main->parameters[controller_parameter_simulate_e].result == f_console_result_none_e) {
+ fl_print_format("%cState is now '%[%s%]'.%c", global->main->output.to.stream, f_string_eol_s[0], global->main->context.set.notable, controller_ready_s, global->main->context.set.notable, f_string_eol_s[0]);
}
- status = controller_perform_ready(global, is_entry, cache);
+ status = controller_perform_ready(global, cache, is_entry);
if (F_status_is_error(status)) return status;
}
}
else if (entry_action->type == controller_entry_action_type_item_e) {
- if (entry_action->number == 0 || entry_action->number >= entry->items.used || failsafe && entry_action->number == global.setting->failsafe_item_id) {
+ if (entry_action->number == 0 || entry_action->number >= entry->items.used || failsafe && entry_action->number == global->setting->failsafe_item_id) {
// This should not happen if the pre-process is working as intended, but in case it doesn't, return a critical error to prevent infinite recursion and similar errors.
- if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->error.to, global.thread);
+ if (global->main->error.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->error.to, global->thread);
- fl_print_format("%c%[Invalid %s item index '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context);
- fl_print_format("%[%un%]", global.main->error.to.stream, global.main->error.notable, entry_action->number, global.main->error.notable);
- fl_print_format("%[' detected.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]);
+ fl_print_format("%c%[Invalid %s item index '%]", global->main->error.to.stream, f_string_eol_s[0], global->main->error.context, is_entry ? controller_entry_s : controller_exit_s, global->main->error.context);
+ fl_print_format("%[%un%]", global->main->error.to.stream, global->main->error.notable, entry_action->number, global->main->error.notable);
+ fl_print_format("%[' detected.%]%c", global->main->error.to.stream, global->main->error.context, global->main->error.context, f_string_eol_s[0]);
- controller_entry_print_error_cache(is_entry, global.main->error, cache->action);
+ controller_entry_print_error_cache(is_entry, global->main->error, cache->action);
- controller_unlock_print_flush(global.main->error.to, global.thread);
+ controller_unlock_print_flush(global->main->error.to, global->thread);
}
return F_status_is_error(F_critical);
macro_f_array_lengths_t_increase_by(status, cache->ats, controller_common_allocation_small_d)
if (F_status_is_error(status)) {
- controller_entry_print_error(is_entry, global.main->error, cache->action, F_status_set_fine(status), "macro_f_array_lengths_t_increase_by", F_true, global.thread);
+ controller_entry_print_error(is_entry, global->main->error, cache->action, F_status_set_fine(status), "macro_f_array_lengths_t_increase_by", F_true, global->thread);
return status;
}
status = controller_dynamic_append_terminated(entry->items.array[cache->ats.array[at_i]].name, &cache->action.name_item);
if (F_status_is_error(status)) {
- controller_entry_print_error(is_entry, global.main->error, cache->action, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true, global.thread);
+ controller_entry_print_error(is_entry, global->main->error, cache->action, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true, global->thread);
return status;
}
- if (global.main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e || global.main->error.verbosity == f_console_verbosity_verbose_e || global.main->error.verbosity == f_console_verbosity_debug_e) {
- if (global.main->output.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e || global->main->error.verbosity == f_console_verbosity_verbose_e || global->main->error.verbosity == f_console_verbosity_debug_e) {
+ if (global->main->output.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%cProcessing %s item '", global.main->output.to.stream, f_string_eol_s[0], is_entry ? controller_entry_s : controller_exit_s);
- fl_print_format("%[%Q%]", global.main->output.to.stream, global.main->context.set.title, cache->action.name_item, global.main->context.set.title);
- fl_print_format("'.%c", global.main->output.to.stream, f_string_eol_s[0]);
+ fl_print_format("%cProcessing %s item '", global->main->output.to.stream, f_string_eol_s[0], is_entry ? controller_entry_s : controller_exit_s);
+ fl_print_format("%[%Q%]", global->main->output.to.stream, global->main->context.set.title, cache->action.name_item, global->main->context.set.title);
+ fl_print_format("'.%c", global->main->output.to.stream, f_string_eol_s[0]);
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
}
- // exit inner loop to force restarting and start processing the requested item.
+ // Exit inner loop to force restarting and start processing the requested item.
break;
}
else if (entry_action->type == controller_entry_action_type_consider_e || controller_entry_action_type_is_rule(entry_action->type)) {
- status_lock = controller_lock_write(is_entry, global.thread, &global.thread->lock.rule);
+ status_lock = controller_lock_write(is_entry, global->thread, &global->thread->lock.rule);
if (F_status_is_error(status_lock)) {
- controller_lock_print_error_critical(global.main->error, F_status_set_fine(status_lock), F_false, global.thread);
+ controller_lock_print_error_critical(global->main->error, F_status_set_fine(status_lock), F_false, global->thread);
+
break;
}
- status = controller_rules_increase(&global.setting->rules);
+ status = controller_rules_increase(&global->setting->rules);
- f_thread_unlock(&global.thread->lock.rule);
+ f_thread_unlock(&global->thread->lock.rule);
if (F_status_is_error(status)) {
- controller_entry_print_error(is_entry, global.main->error, cache->action, F_status_set_fine(status), "controller_rules_increase", F_true, global.thread);
+ controller_entry_print_error(is_entry, global->main->error, cache->action, F_status_set_fine(status), "controller_rules_increase", F_true, global->thread);
return status;
}
id_rule_name[entry_action->parameters.array[0].used] = f_path_separator_s[0];
id_rule_name[id_rule_length] = 0;
- status_lock = controller_lock_read(is_entry, global.thread, &global.thread->lock.rule);
+ status_lock = controller_lock_read(is_entry, global->thread, &global->thread->lock.rule);
if (F_status_is_error(status_lock)) {
- controller_lock_print_error_critical(global.main->error, F_status_set_fine(status_lock), F_true, global.thread);
+ controller_lock_print_error_critical(global->main->error, F_status_set_fine(status_lock), F_true, global->thread);
+
break;
}
- status = controller_rule_find(alias_rule, global.setting->rules, 0);
+ status = controller_rule_find(alias_rule, global->setting->rules, 0);
- f_thread_unlock(&global.thread->lock.rule);
+ f_thread_unlock(&global->thread->lock.rule);
- if (global.main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e || global.main->error.verbosity == f_console_verbosity_verbose_e || global.main->error.verbosity == f_console_verbosity_debug_e || (entry->show == controller_entry_show_init_e && entry_action->type != controller_entry_action_type_consider_e)) {
- if (global.main->output.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e || global->main->error.verbosity == f_console_verbosity_verbose_e || global->main->error.verbosity == f_console_verbosity_debug_e || (entry->show == controller_entry_show_init_e && entry_action->type != controller_entry_action_type_consider_e)) {
+ if (global->main->output.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%c%s %s item rule ", global.main->output.to.stream, f_string_eol_s[0], entry_action->type == controller_entry_action_type_consider_e ? "Considering" : "Processing", is_entry ? controller_entry_s : controller_exit_s);
- fl_print_format("'%[%Q%]'", global.main->output.to.stream, global.main->context.set.title, alias_rule, global.main->context.set.title);
+ fl_print_format("%c%s %s item rule ", global->main->output.to.stream, f_string_eol_s[0], entry_action->type == controller_entry_action_type_consider_e ? "Considering" : "Processing", is_entry ? controller_entry_s : controller_exit_s);
+ fl_print_format("'%[%Q%]'", global->main->output.to.stream, global->main->context.set.title, alias_rule, global->main->context.set.title);
- if (entry->show == controller_entry_show_init_e && global.main->parameters[controller_parameter_simulate_e].result == f_console_result_none_e) {
- fl_print_format(" [%[%s%]]", global.main->output.to.stream, global.main->context.set.notable, entry_action->code == controller_entry_rule_code_asynchronous_d ? controller_asynchronous_s : controller_synchronous_s, global.main->context.set.notable);
+ if (entry->show == controller_entry_show_init_e && global->main->parameters[controller_parameter_simulate_e].result == f_console_result_none_e) {
+ fl_print_format(" [%[%s%]]", global->main->output.to.stream, global->main->context.set.notable, entry_action->code == controller_entry_rule_code_asynchronous_d ? controller_asynchronous_s : controller_synchronous_s, global->main->context.set.notable);
if (entry_action->code == controller_entry_rule_code_wait_d) {
- fl_print_format(" [%[%s%]]", global.main->output.to.stream, global.main->context.set.notable, controller_wait_s, global.main->context.set.notable);
+ fl_print_format(" [%[%s%]]", global->main->output.to.stream, global->main->context.set.notable, controller_wait_s, global->main->context.set.notable);
}
if (entry_action->code == controller_entry_rule_code_require_d) {
- fl_print_format(" [%[%s%]]", global.main->output.to.stream, global.main->context.set.notable, controller_required_s, global.main->context.set.notable);
+ fl_print_format(" [%[%s%]]", global->main->output.to.stream, global->main->context.set.notable, controller_required_s, global->main->context.set.notable);
}
}
- fl_print_format(".%c", global.main->output.to.stream, f_string_eol_s[0]);
+ fl_print_format(".%c", global->main->output.to.stream, f_string_eol_s[0]);
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
}
- if (!controller_thread_is_enabled(is_entry, global.thread)) break;
+ if (!controller_thread_is_enabled(is_entry, global->thread)) break;
- // the rule is not yet loaded, ensure that it is loaded.
+ // The rule is not yet loaded, ensure that it is loaded.
if (status != F_true) {
- // rule execution will re-use the existing cache, so save the current cache.
+ // Rule execution will re-use the existing cache, so save the current cache.
const f_array_length_t cache_line_action = cache->action.line_action;
const f_array_length_t cache_line_item = cache->action.line_item;
memcpy(cache_name_item, cache->action.name_item.string, cache->action.name_item.used);
memcpy(cache_name_file, cache->action.name_file.string, cache->action.name_file.used);
- status_lock = controller_lock_write(is_entry, global.thread, &global.thread->lock.rule);
+ status_lock = controller_lock_write(is_entry, global->thread, &global->thread->lock.rule);
if (F_status_is_fine(status_lock)) {
- status = controller_rule_read(global, is_entry, alias_rule, cache, entry, &global.setting->rules.array[global.setting->rules.used]);
+ status = controller_rule_read(*global, is_entry, alias_rule, cache, entry, &global->setting->rules.array[global->setting->rules.used]);
}
- // restore cache.
+ // Restore cache.
memcpy(cache->action.name_action.string, cache_name_action, cache_name_action_used);
memcpy(cache->action.name_item.string, cache_name_item, cache_name_item_used);
memcpy(cache->action.name_file.string, cache_name_file, cache_name_file_used);
cache->action.line_item = cache_line_item;
if (F_status_is_error(status_lock)) {
- controller_lock_print_error_critical(global.main->error, F_status_set_fine(status_lock), F_false, global.thread);
+ controller_lock_print_error_critical(global->main->error, F_status_set_fine(status_lock), F_false, global->thread);
break;
}
- if (F_status_set_fine(status) == F_interrupt || !controller_thread_is_enabled(is_entry, global.thread)) {
- f_thread_unlock(&global.thread->lock.rule);
+ if (F_status_set_fine(status) == F_interrupt || !controller_thread_is_enabled(is_entry, global->thread)) {
+ f_thread_unlock(&global->thread->lock.rule);
break;
}
if (F_status_is_error(status)) {
- if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->error.to, global.thread);
+ if (global->main->error.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->error.to, global->thread);
- controller_entry_print_error_cache(is_entry, global.main->error, cache->action);
+ controller_entry_print_error_cache(is_entry, global->main->error, cache->action);
- controller_unlock_print_flush(global.main->error.to, global.thread);
+ controller_unlock_print_flush(global->main->error.to, global->thread);
}
// Designate the action as failed.
entry_action->status = F_status_set_error(F_failure);
- if (global.main->parameters[controller_parameter_simulate_e].result == f_console_result_none_e) {
- f_thread_unlock(&global.thread->lock.rule);
+ if (global->main->parameters[controller_parameter_simulate_e].result == f_console_result_none_e) {
+ f_thread_unlock(&global->thread->lock.rule);
if (entry_action->code & controller_entry_rule_code_require_d) {
return F_status_set_error(F_require);
}
}
else {
- ++global.setting->rules.used;
+ ++global->setting->rules.used;
}
- f_thread_unlock(&global.thread->lock.rule);
+ f_thread_unlock(&global->thread->lock.rule);
}
if (F_status_is_error_not(status)) {
options_force = 0;
options_process = 0;
- if (global.main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e) {
+ if (global->main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e) {
options_process |= controller_process_option_simulate_d;
}
options_process |= controller_process_option_wait_d;
}
- if (global.main->parameters[controller_parameter_validate_e].result == f_console_result_found_e) {
+ if (global->main->parameters[controller_parameter_validate_e].result == f_console_result_found_e) {
options_process |= controller_process_option_validate_d;
}
if (entry_action->code & controller_entry_rule_code_asynchronous_d) {
- if (global.main->parameters[controller_parameter_validate_e].result == f_console_result_none_e) {
+ if (global->main->parameters[controller_parameter_validate_e].result == f_console_result_none_e) {
options_force |= controller_process_option_asynchronous_d;
}
options_process |= controller_process_option_asynchronous_d;
}
- status = controller_rule_process_begin(global, options_force, alias_rule, controller_entry_action_type_to_rule_action_type(entry_action->type), options_process, is_entry ? controller_process_type_entry_e : controller_process_type_exit_e, stack, *cache);
+ status = controller_rule_process_begin(*global, options_force, alias_rule, controller_entry_action_type_to_rule_action_type(entry_action->type), options_process, is_entry ? controller_process_type_entry_e : controller_process_type_exit_e, stack, *cache);
if (F_status_set_fine(status) == F_memory_not || status == F_child || F_status_set_fine(status) == F_interrupt) {
break;
}
- if (F_status_is_error(status) && global.main->parameters[controller_parameter_simulate_e].result == f_console_result_none_e && (entry_action->code & controller_entry_rule_code_require_d)) {
+ if (F_status_is_error(status) && global->main->parameters[controller_parameter_simulate_e].result == f_console_result_none_e && (entry_action->code & controller_entry_rule_code_require_d)) {
return F_status_set_error(F_require);
}
}
}
else if (entry_action->type == controller_entry_action_type_execute_e) {
- if (global.main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e || global.main->error.verbosity == f_console_verbosity_verbose_e || global.main->error.verbosity == f_console_verbosity_debug_e || entry->show == controller_entry_show_init_e) {
- if (global.main->output.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if (global->main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e || global->main->error.verbosity == f_console_verbosity_verbose_e || global->main->error.verbosity == f_console_verbosity_debug_e || entry->show == controller_entry_show_init_e) {
+ if (global->main->output.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%c%s is executing '", global.main->output.to.stream, f_string_eol_s[0], is_entry ? controller_entry_s : controller_exit_s);
+ fl_print_format("%c%s is executing '", global->main->output.to.stream, f_string_eol_s[0], is_entry ? controller_entry_s : controller_exit_s);
for (f_array_length_t k = 0; k < entry_action->parameters.used; ++k) {
- fl_print_format("%[%Q%]", global.main->output.to.stream, global.main->context.set.title, entry_action->parameters.array[k], global.main->context.set.title);
+ fl_print_format("%[%Q%]", global->main->output.to.stream, global->main->context.set.title, entry_action->parameters.array[k], global->main->context.set.title);
if (k + 1 < entry_action->parameters.used) {
- f_print_character(f_string_space_s[0], global.main->output.to.stream);
+ f_print_character(f_string_space_s[0], global->main->output.to.stream);
}
} // for
- fl_print_format("'.%c", global.main->output.to.stream, f_string_eol_s[0]);
+ fl_print_format("'.%c", global->main->output.to.stream, f_string_eol_s[0]);
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
}
- if (global.main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e) {
+ if (global->main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e) {
return F_execute;
}
- controller_thread_process_cancel(global, is_entry, is_entry ? controller_thread_cancel_execute_e : controller_thread_cancel_exit_execute_e, process);
+ controller_thread_process_cancel(*global, is_entry, is_entry ? controller_thread_cancel_execute_e : controller_thread_cancel_exit_execute_e, process);
int result = 0;
int option = FL_execute_parameter_option_path_d;
if (F_status_is_error(status)) {
if (F_status_set_fine(status) == F_file_found_not) {
- if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->error.to, global.thread);
+ if (global->main->error.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->error.to, global->thread);
- fl_print_format("%c%[%SExecution failed, unable to find program or script '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context);
- fl_print_format("%[%Q%]", global.main->error.to.stream, global.main->error.notable, entry_action->parameters.array[0], global.main->error.notable);
- fl_print_format("%['.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]);
+ fl_print_format("%c%[%SExecution failed, unable to find program or script '%]", global->main->error.to.stream, f_string_eol_s[0], global->main->error.context, global->main->error.prefix ? global->main->error.prefix : f_string_empty_s, global->main->error.context);
+ fl_print_format("%[%Q%]", global->main->error.to.stream, global->main->error.notable, entry_action->parameters.array[0], global->main->error.notable);
+ fl_print_format("%['.%]%c", global->main->error.to.stream, global->main->error.context, global->main->error.context, f_string_eol_s[0]);
- controller_entry_print_error_cache(is_entry, global.main->error, cache->action);
+ controller_entry_print_error_cache(is_entry, global->main->error, cache->action);
- controller_unlock_print_flush(global.main->error.to, global.thread);
+ controller_unlock_print_flush(global->main->error.to, global->thread);
}
}
else {
- controller_entry_print_error(is_entry, global.main->error, cache->action, F_status_set_fine(status), "fll_execute_into", F_true, global.thread);
+ controller_entry_print_error(is_entry, global->main->error, cache->action, F_status_set_fine(status), "fll_execute_into", F_true, global->thread);
}
return F_status_set_error(F_execute);
}
else if (result != 0) {
- if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->error.to, global.thread);
+ if (global->main->error.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->error.to, global->thread);
- fl_print_format("%c%[%SExecution failed with return value of '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context);
- fl_print_format("%[%i%]", global.main->error.to.stream, global.main->error.notable, result, global.main->error.notable);
- fl_print_format("$['.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]);
+ fl_print_format("%c%[%SExecution failed with return value of '%]", global->main->error.to.stream, f_string_eol_s[0], global->main->error.context, global->main->error.prefix ? global->main->error.prefix : f_string_empty_s, global->main->error.context);
+ fl_print_format("%[%i%]", global->main->error.to.stream, global->main->error.notable, result, global->main->error.notable);
+ fl_print_format("$['.%]%c", global->main->error.to.stream, global->main->error.context, global->main->error.context, f_string_eol_s[0]);
- controller_entry_print_error_cache(is_entry, global.main->error, cache->action);
+ controller_entry_print_error_cache(is_entry, global->main->error, cache->action);
- controller_unlock_print_flush(global.main->error.to, global.thread);
+ controller_unlock_print_flush(global->main->error.to, global->thread);
}
return F_status_set_error(F_execute);
if (entry_action->code == controller_entry_timeout_code_kill_d) {
entry->timeout_kill = entry_action->number;
- controller_entry_preprocess_print_simulate_setting_value(global, is_entry, controller_timeout_s, controller_kill_s, entry->items.array[global.setting->failsafe_item_id].name, suffix);
+ controller_entry_preprocess_print_simulate_setting_value(*global, is_entry, controller_timeout_s, controller_kill_s, entry->items.array[global->setting->failsafe_item_id].name, suffix);
}
else if (entry_action->code == controller_entry_timeout_code_start_d) {
entry->timeout_start = entry_action->number;
- controller_entry_preprocess_print_simulate_setting_value(global, is_entry, controller_timeout_s, controller_start_s, entry->items.array[global.setting->failsafe_item_id].name, suffix);
+ controller_entry_preprocess_print_simulate_setting_value(*global, is_entry, controller_timeout_s, controller_start_s, entry->items.array[global->setting->failsafe_item_id].name, suffix);
}
else if (entry_action->code == controller_entry_timeout_code_stop_d) {
entry->timeout_stop = entry_action->number;
- controller_entry_preprocess_print_simulate_setting_value(global, is_entry, controller_timeout_s, controller_stop_s, entry->items.array[global.setting->failsafe_item_id].name, suffix);
+ controller_entry_preprocess_print_simulate_setting_value(*global, is_entry, controller_timeout_s, controller_stop_s, entry->items.array[global->setting->failsafe_item_id].name, suffix);
}
}
else if (entry_action->type == controller_entry_action_type_failsafe_e) {
if (failsafe) {
- if (global.main->warning.verbosity == f_console_verbosity_debug_e) {
- controller_lock_print(global.main->warning.to, global.thread);
+ if (global->main->warning.verbosity == f_console_verbosity_debug_e) {
+ controller_lock_print(global->main->warning.to, global->thread);
- fl_print_format("%c%[%SFailsafe may not be specified when running in failsafe, ignoring.%]%c", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context, f_string_eol_s[0]);
+ fl_print_format("%c%[%SFailsafe may not be specified when running in failsafe, ignoring.%]%c", global->main->warning.to.stream, f_string_eol_s[0], global->main->warning.context, global->main->warning.prefix, global->main->warning.context, f_string_eol_s[0]);
- controller_entry_print_error_cache(is_entry, global.main->warning, cache->action);
+ controller_entry_print_error_cache(is_entry, global->main->warning, cache->action);
- controller_unlock_print_flush(global.main->warning.to, global.thread);
+ controller_unlock_print_flush(global->main->warning.to, global->thread);
}
}
else {
if (entry_action->number == 0 || entry_action->number >= entry->items.used) {
// This should not happen if the pre-process is working as designed, but in case it doesn't, return a critical error to prevent infinite recursion and similar errors.
- if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_lock_print(global.main->error.to, global.thread);
+ if (global->main->error.verbosity != f_console_verbosity_quiet_e) {
+ controller_lock_print(global->main->error.to, global->thread);
- fl_print_format("%c%[%SInvalid %s item index '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context);
- fl_print_format("%[%un%]", global.main->error.to.stream, global.main->error.notable, entry_action->number, global.main->error.notable);
- fl_print_format("%[' detected.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]);
+ fl_print_format("%c%[%SInvalid %s item index '%]", global->main->error.to.stream, f_string_eol_s[0], global->main->error.context, global->main->error.prefix ? global->main->error.prefix : f_string_empty_s, is_entry ? controller_entry_s : controller_exit_s, global->main->error.context);
+ fl_print_format("%[%un%]", global->main->error.to.stream, global->main->error.notable, entry_action->number, global->main->error.notable);
+ fl_print_format("%[' detected.%]%c", global->main->error.to.stream, global->main->error.context, global->main->error.context, f_string_eol_s[0]);
- controller_entry_print_error_cache(is_entry, global.main->error, cache->action);
+ controller_entry_print_error_cache(is_entry, global->main->error, cache->action);
- controller_unlock_print_flush(global.main->error.to, global.thread);
+ controller_unlock_print_flush(global->main->error.to, global->thread);
}
return F_status_is_error(F_critical);
}
else {
- global.setting->failsafe_enabled = F_true;
- global.setting->failsafe_item_id = entry_action->number;
+ global->setting->failsafe_enabled = F_true;
+ global->setting->failsafe_item_id = entry_action->number;
- controller_entry_preprocess_print_simulate_setting_value(global, is_entry, controller_failsafe_s, 0, entry->items.array[global.setting->failsafe_item_id].name, 0);
+ controller_entry_preprocess_print_simulate_setting_value(*global, is_entry, controller_failsafe_s, 0, entry->items.array[global->setting->failsafe_item_id].name, 0);
}
}
}
}
}
- // end of actions found, so drop to previous loop in stack.
+ // End of actions found, so drop to previous loop in stack.
if (cache->ats.array[at_j] == entry_actions->used) {
- // all actions for "main" are processed so there is nothing left to do.
+ // All actions for "main" are processed so there is nothing left to do.
if (at_i == 0) break;
at_i -= 2;
status = controller_dynamic_append_terminated(entry->items.array[cache->ats.array[at_i]].name, &cache->action.name_item);
if (F_status_is_error(status)) {
- controller_entry_print_error(is_entry, global.main->error, cache->action, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true, global.thread);
+ controller_entry_print_error(is_entry, global->main->error, cache->action, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true, global->thread);
break;
}
}
} // while
- if (!controller_thread_is_enabled(is_entry, global.thread)) {
+ if (!controller_thread_is_enabled(is_entry, global->thread)) {
return F_status_set_error(F_interrupt);
}
return status_lock;
}
- // check to see if any required processes failed, but do not do this if already operating in failsafe.
- if (F_status_is_error_not(status) && !failsafe && global.main->parameters[controller_parameter_validate_e].result == f_console_result_none_e) {
- const f_status_t status_wait = controller_rule_wait_all(global, is_entry, F_true, 0);
+ // Check to see if any required processes failed, but do not do this if already operating in failsafe.
+ if (F_status_is_error_not(status) && !failsafe && global->main->parameters[controller_parameter_validate_e].result == f_console_result_none_e) {
+ const f_status_t status_wait = controller_rule_wait_all(*global, is_entry, F_true, 0);
if (F_status_is_error(status_wait)) {
return status_wait;
}
}
- if ((global.main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e && global.main->error.verbosity != f_console_verbosity_quiet_e) || global.main->error.verbosity == f_console_verbosity_verbose_e) {
- controller_lock_print(global.main->output.to, global.thread);
+ if ((global->main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e && global->main->error.verbosity != f_console_verbosity_quiet_e) || global->main->error.verbosity == f_console_verbosity_verbose_e) {
+ controller_lock_print(global->main->output.to, global->thread);
- fl_print_format("%cDone processing %s item '", global.main->output.to.stream, f_string_eol_s[0], is_entry ? controller_entry_s : controller_exit_s);
- fl_print_format("%[%s%]", global.main->output.to.stream, global.main->context.set.title, controller_main_s, global.main->context.set.title);
- fl_print_format("'.%c", global.main->output.to.stream, f_string_eol_s[0]);
+ fl_print_format("%cDone processing %s item '", global->main->output.to.stream, f_string_eol_s[0], is_entry ? controller_entry_s : controller_exit_s);
+ fl_print_format("%[%s%]", global->main->output.to.stream, global->main->context.set.title, controller_main_s, global->main->context.set.title);
+ fl_print_format("'.%c", global->main->output.to.stream, f_string_eol_s[0]);
// failsafe should not print the extra newline because the failure exit from controller_main should handle this.
if (!failsafe) {
- f_print_terminated(f_string_eol_s, global.main->output.to.stream);
+ f_print_terminated(f_string_eol_s, global->main->output.to.stream);
}
- controller_unlock_print_flush(global.main->output.to, global.thread);
+ controller_unlock_print_flush(global->main->output.to, global->thread);
}
return status;
status = fll_fss_basic_list_read(cache->buffer_file, state, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fll_fss_basic_list_read", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fll_fss_basic_list_read", F_true);
}
else {
status = fl_fss_apply_delimit(cache->delimits, &cache->buffer_file);
status = controller_dynamic_append_terminated(cache->action.name_item, &entry->items.array[at].name);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true);
break;
}
status = controller_dynamic_append_terminated(entry->items.array[i].name, &cache->action.name_item);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true);
+
break;
}
continue;
}
- // @todo swap the generic with the path_control so that this can then be swapped again using canonical.
cache->action.generic.used = 0;
global.setting->path_control.used = 0;
*
* @param global
* The global data.
+ * @param cache
+ * The main/global cache to use.
* @param failsafe
* If TRUE, operate in failsafe mode (starts at designated failsafe Item).
* If FALSE, operate in normal mode (starts at "main" Item).
* @param is_entry
* If TRUE, then this operate as an entry.
* If FALSE, then this operate as an exit.
- * @param cache
- * The main/global cache to use.
*
* @return
* F_none on success.
* @see controller_dynamic_append_terminated()
*/
#ifndef _di_controller_entry_process_
- extern f_status_t controller_entry_process(const controller_global_t global, const bool failsafe, const bool is_entry, controller_cache_t * const cache) F_attribute_visibility_internal_d;
+ extern f_status_t controller_entry_process(const controller_global_t *global, controller_cache_t * const cache, const bool failsafe, const bool is_entry) F_attribute_visibility_internal_d;
#endif // _di_controller_entry_process_
/**
status = f_string_dynamics_increase(controller_common_allocation_small_d, parameters);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true);
return status;
}
status = f_string_dynamic_partial_append_nulless(buffer, *object, ¶meters->array[0]);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true);
return status;
}
status = f_string_dynamic_terminate_after(¶meters->array[0]);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
return status;
}
status = f_string_dynamics_increase(controller_common_allocation_small_d, parameters);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true);
return status;
}
status = f_string_dynamic_partial_append_nulless(buffer, content->array[i], ¶meters->array[parameters->used]);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true);
return status;
}
status = f_string_dynamic_terminate_after(¶meters->array[parameters->used]);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
return status;
}
}
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fl_fss_extended_list_content_read", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fl_fss_extended_list_content_read", F_true);
}
else if (status == F_fss_found_content) {
status = fl_fss_apply_delimit(cache->delimits, &cache->buffer_item);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true);
}
else {
status = f_string_dynamics_increase(controller_common_allocation_small_d, &actions->array[actions->used].parameters);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true);
}
else {
actions->array[actions->used].type = type;
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_action.array[0], &actions->array[actions->used].parameters.array[0]);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true);
}
status = f_string_dynamic_terminate_after(&actions->array[actions->used].parameters.array[0]);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
}
else {
actions->array[actions->used++].parameters.used = 1;
}
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fll_fss_extended_read", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fll_fss_extended_read", F_true);
}
else {
status = fl_fss_apply_delimit(cache->delimits, &cache->buffer_item);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true);
}
else {
f_array_length_t i = 0;
status = controller_rule_actions_increase_by(controller_common_allocation_small_d, actions);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "controller_rule_actions_increase_by", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "controller_rule_actions_increase_by", F_true);
break;
}
status = f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &actions->array[actions->used].line);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_fss_count_lines", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_fss_count_lines", F_true);
+
break;
}
status = f_string_dynamics_increase(controller_common_allocation_small_d, &actions->array[actions->used].parameters);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true);
actions->array[actions->used].status = controller_status_simplify_error(F_status_set_fine(status));
+
break;
}
}
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fll_fss_extended_content_read", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fll_fss_extended_content_read", F_true);
}
else if (status == F_fss_found_content) {
status = fl_fss_apply_delimit(cache->delimits, &cache->buffer_item);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true);
}
else if (type == controller_rule_action_type_pid_file_e) {
item->pid_file.used = 0;
status = fl_string_dynamic_rip(cache->buffer_item, cache->content_action.array[0], &item->pid_file);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fl_string_dynamic_rip", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fl_string_dynamic_rip", F_true);
}
else {
status = f_string_dynamic_terminate_after(&item->pid_file);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
}
}
}
status = f_string_dynamics_increase(controller_common_allocation_small_d, &actions->array[actions->used].parameters);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true);
}
else {
} // for
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_partial_mash_nulless", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_partial_mash_nulless", F_true);
}
else {
status = f_string_dynamic_terminate_after(&actions->array[actions->used].parameters.array[0]);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
}
else {
actions->array[actions->used++].parameters.used = 1;
status = f_fss_count_lines(cache->buffer_item, range->start, &actions->array[actions->used].line);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_fss_count_lines", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_fss_count_lines", F_true);
}
else {
actions->array[actions->used].type = type;
status = controller_rule_parameters_read(global, cache->buffer_item, 0, &cache->content_action, &actions->array[actions->used].parameters);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "controller_rule_parameters_read", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "controller_rule_parameters_read", F_true);
actions->array[actions->used++].status = controller_status_simplify_error(F_status_set_fine(status));
}
#endif // _di_controller_rule_action_read_
#ifndef _di_controller_rule_action_read_rerun_number_
- f_status_t controller_rule_action_read_rerun_number(const controller_global_t global, const f_string_t name, controller_cache_t * const cache, f_array_length_t *index, f_number_unsigned_t *number) {
+ f_status_t controller_rule_action_read_rerun_number(const controller_global_t global, const f_string_t name, controller_cache_t * const cache, f_array_length_t * const index, f_number_unsigned_t * const number) {
f_status_t status = F_none;
f_number_unsigned_t parsed = 0;
status = F_status_set_fine(status);
if (status != F_valid_not && status != F_number && status != F_number_decimal && status != F_number_overflow && status != F_number_underflow && status != F_number_negative) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true);
}
else {
controller_lock_print(global.main->error.to, global.thread);
status = fll_control_group_prepare(process->rule.cgroup);
if (F_status_is_error(status)) {
- controller_print_error_file(global.main->error, F_status_set_fine(status), "fll_control_group_prepare", F_true, process->rule.cgroup.path.string, "prepare control groups for", fll_error_file_type_directory_e, global.thread);
+ controller_print_error_file(global.thread, global.main->error, F_status_set_fine(status), "fll_control_group_prepare", F_true, process->rule.cgroup.path.string, "prepare control groups for", fll_error_file_type_directory_e);
return status;
}
status = fl_environment_load_names(process->rule.environment, &environment);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fl_environment_load_names", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fl_environment_load_names", F_true);
return status;
}
status = controller_pids_increase(&process->childs);
if (F_status_is_error(status)) {
- controller_print_error(main->error, F_status_set_fine(status), "controller_pids_increase", F_true, thread);
+ controller_print_error(thread, main->error, F_status_set_fine(status), "controller_pids_increase", F_true);
return status;
}
controller_rule_item_print_error_execute(type == controller_rule_item_type_script_e, program ? program : arguments.used ? arguments.array[0].string : f_string_empty_s, status, process);
}
else {
- controller_print_error(main->error, F_status_set_fine(status), "fll_execute_program", F_true, thread);
+ controller_print_error(thread, main->error, F_status_set_fine(status), "fll_execute_program", F_true);
}
status = F_status_set_error(status);
status = controller_pids_increase(&process->childs);
if (F_status_is_error(status)) {
- controller_print_error(main->error, F_status_set_fine(status), "controller_pids_increase", F_true, thread);
+ controller_print_error(thread, main->error, F_status_set_fine(status), "controller_pids_increase", F_true);
return status;
}
status = f_string_dynamics_increase(controller_common_allocation_small_d, &process->path_pids);
if (F_status_is_error(status)) {
- controller_print_error(main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true, thread);
+ controller_print_error(thread, main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true);
return status;
}
status = f_file_exists(pid_file.string);
if (F_status_is_error(status)) {
- controller_print_error_file(main->error, F_status_set_fine(status), "f_file_exists", F_true, pid_file.string, "find", fll_error_file_type_file_e, thread);
+ controller_print_error_file(thread, main->error, F_status_set_fine(status), "f_file_exists", F_true, pid_file.string, "find", fll_error_file_type_file_e);
return status;
}
if (status == F_true) {
- controller_print_error_file(main->error, F_file_found, "f_file_exists", F_true, pid_file.string, "find", fll_error_file_type_file_e, thread);
+ controller_print_error_file(thread, main->error, F_file_found, "f_file_exists", F_true, pid_file.string, "find", fll_error_file_type_file_e);
return F_status_set_error(F_file_found);
}
status = controller_dynamic_append_terminated(pid_file, child_pid_file);
if (F_status_is_error(status)) {
- controller_print_error(main->error, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true, thread);
+ controller_print_error(thread, main->error, F_status_set_fine(status), "controller_dynamic_append_terminated", F_true);
return status;
}
controller_rule_item_print_error_execute(type == controller_rule_item_type_utility_e, program ? program : arguments.used ? arguments.array[0].string : f_string_empty_s, status, process);
}
else {
- controller_print_error(main->error, F_status_set_fine(status), "fll_execute_program", F_true, thread);
+ controller_print_error(thread, main->error, F_status_set_fine(status), "fll_execute_program", F_true);
}
return F_status_set_error(status);
#endif // _di_controller_rule_execute_pid_with_
#ifndef _di_controller_rule_execute_rerun_
- int8_t controller_rule_execute_rerun(const uint8_t action, controller_process_t * const process, controller_rule_item_t *item) {
+ int8_t controller_rule_execute_rerun(const uint8_t action, controller_process_t * const process, controller_rule_item_t * const item) {
const int result = WIFEXITED(process->result) ? WEXITSTATUS(process->result) : 0;
#endif // _di_controller_rule_execute_rerun_
#ifndef _di_controller_rule_id_construct_
- f_status_t controller_rule_id_construct(const controller_global_t global, const f_string_static_t source, const f_string_range_t directory, const f_string_range_t basename, f_string_dynamic_t *alias) {
+ f_status_t controller_rule_id_construct(const controller_global_t global, const f_string_static_t source, const f_string_range_t directory, const f_string_range_t basename, f_string_dynamic_t * const alias) {
f_status_t status = F_none;
status = f_string_dynamic_partial_append_nulless(source, directory, alias);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true);
return status;
}
status = f_string_append(f_path_separator_s, F_path_separator_s_length, alias);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_append", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_append", F_true);
return status;
}
status = f_string_dynamic_partial_append_nulless(source, basename, alias);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true);
return status;
}
status = f_string_dynamic_terminate_after(alias);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
}
return status;
#endif // _di_controller_rule_status_is_error_
#ifndef _di_controller_rule_item_read_
- f_status_t controller_rule_item_read(const controller_global_t global, const bool is_normal, controller_cache_t * const cache, controller_rule_item_t *item) {
+ f_status_t controller_rule_item_read(const controller_global_t global, const bool is_normal, controller_cache_t * const cache, controller_rule_item_t * const item) {
f_status_t status = F_none;
controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_normal, global.thread);
status = fl_fss_extended_list_object_read(cache->buffer_item, state, &range, &cache->range_action, &cache->delimits);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fl_fss_extended_list_object_read", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fl_fss_extended_list_object_read", F_true);
break;
}
status = fl_fss_extended_object_read(cache->buffer_item, state, &range, &cache->range_action, 0, &cache->delimits);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fl_fss_extended_object_read", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fl_fss_extended_object_read", F_true);
break;
}
status = fl_fss_apply_delimit(cache->delimits, &cache->buffer_item);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true);
+
break;
}
status = f_fss_count_lines(cache->buffer_item, cache->range_action.start, &cache->action.line_action);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_fss_count_lines", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_fss_count_lines", F_true);
+
break;
}
status = controller_dynamic_rip_nulless_terminated(cache->buffer_item, cache->range_action, &cache->action.name_action);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "controller_dynamic_rip_nulless_terminated", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "controller_dynamic_rip_nulless_terminated", F_true);
+
break;
}
status = controller_rule_actions_increase_by(controller_common_allocation_small_d, &item->actions);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "controller_rule_actions_increase_by", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "controller_rule_actions_increase_by", F_true);
+
break;
}
#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 *items) {
+ f_status_t controller_rule_items_increase_by(const f_array_length_t amount, controller_rule_items_t * const items) {
if (items->used + amount > items->size) {
if (items->used + amount > F_array_length_t_size_d) {
}
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, process->cache.action, F_status_set_fine(status), "f_string_append", F_true, F_true, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, process->cache.action, F_status_set_fine(status), "f_string_append", F_true, F_true);
return status;
}
status = f_string_dynamic_append(process->rule.alias, &process->cache.action.name_file);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, process->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, process->cache.action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_true);
return status;
}
}
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, process->cache.action, F_status_set_fine(status), "f_string_append", F_true, F_true, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, process->cache.action, F_status_set_fine(status), "f_string_append", F_true, F_true);
return status;
}
status = f_string_dynamic_terminate_after(&process->cache.action.name_file);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, process->cache.action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_true, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, process->cache.action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_true);
return status;
}
}
if (F_status_is_error(status)) {
- controller_rule_item_print_error(global.main->error, process->cache.action, F_true, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, process->cache.action, F_true, F_status_set_fine(status));
}
}
}
if (F_status_is_error(status)) {
controller_lock_print_error_critical(global.main->error, F_status_set_fine(status), F_true, global.thread);
- controller_rule_item_print_error(global.main->error, cache.action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache.action, F_false, F_status_set_fine(status));
f_thread_unlock(&global.thread->lock.process);
}
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_type_array_lengths_resize", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_type_array_lengths_resize", F_true);
}
else {
for (f_array_length_t i = 0; i < stack.used; ++i) {
status = f_string_dynamic_append(cache.action.name_item, &process->cache.action.name_item);
}
else {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true);
}
}
}
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_thread_create", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_thread_create", F_true);
}
}
else {
f_thread_unlock(&global.thread->lock.rule);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "controller_rule_copy", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "controller_rule_copy", F_true);
}
else if (!process->action) {
status = f_type_array_lengths_increase(controller_common_allocation_small_d, &process->stack);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_type_array_lengths_increase", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_type_array_lengths_increase", F_true);
}
else {
f_thread_unlock(&process->lock);
status = f_string_dynamic_append_nulless(alias, &rule->alias);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true);
}
else {
status = f_string_dynamic_terminate_after(&rule->alias);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
}
else {
status = controller_file_load(global, F_true, controller_rules_s, rule->alias, controller_rule_s, controller_rules_s_length, controller_rule_s_length, cache);
status = fll_fss_basic_list_read(cache->buffer_file, state, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fll_fss_basic_list_read", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fll_fss_basic_list_read", F_true);
}
else {
status = fl_fss_apply_delimit(cache->delimits, &cache->buffer_file);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true);
}
}
}
status = controller_rule_items_increase_by(cache->object_items.used, &rule->items);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "controller_rule_items_increase_by", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "controller_rule_items_increase_by", F_true);
}
else {
f_array_length_t i = 0;
status = f_fss_count_lines(cache->buffer_file, cache->object_items.array[i].start, &cache->action.line_item);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_fss_count_lines", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_fss_count_lines", F_true);
+
break;
}
status = controller_dynamic_rip_nulless_terminated(cache->buffer_file, cache->object_items.array[i], &cache->action.name_item);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "controller_dynamic_rip_nulless_terminated", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "controller_dynamic_rip_nulless_terminated", F_true);
+
break;
}
status = f_string_dynamic_partial_append(cache->buffer_file, cache->content_items.array[i].array[0], &cache->buffer_item);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_partial_append", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_partial_append", F_true);
+
break;
}
status = f_string_dynamic_terminate_after(&cache->buffer_item);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
+
break;
}
}
if (F_status_is_error(status)) {
- controller_rule_item_print_error(global.main->error, cache->action, for_item, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, for_item, F_status_set_fine(status));
rule->status[0] = controller_status_simplify_error(F_status_set_fine(status));
}
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "fll_fss_extended_read", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "fll_fss_extended_read", F_true, F_false);
return status;
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->object_actions.array[i], &cache->action.name_item);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
}
else {
status = f_string_dynamic_terminate_after(&cache->action.name_item);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false);
}
}
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, range2, &cache->action.name_action);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
}
else {
status = f_string_dynamic_terminate_after(&cache->action.name_action);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false);
}
}
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
}
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "macro_f_int32s_t_resize", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "macro_f_int32s_t_resize", F_true, F_false);
break;
}
}
}
else {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "fl_conversion_string_to_number_signed", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "fl_conversion_string_to_number_signed", F_true, F_false);
status = F_status_set_error(status);
status = f_string_maps_increase(controller_common_allocation_small_d, setting_maps);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_maps_increase", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_maps_increase", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], &setting_maps->array[setting_maps->used].name);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[1], &setting_maps->array[setting_maps->used].value);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
}
else {
status = f_string_dynamic_terminate_after(&setting_maps->array[setting_maps->used].value);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false);
}
}
if (F_status_is_error(status)) {
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
+
break;
}
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
status = f_string_dynamic_append(global.setting->path_cgroup, &rule->cgroup.path);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_false);
}
else {
rule->cgroup.groups.used = 0;
status = f_string_dynamics_increase(controller_common_allocation_small_d, &rule->cgroup.groups);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamics_increase", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamics_increase", F_true, F_false);
break;
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[j], &rule->cgroup.groups.array[rule->cgroup.groups.used]);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
break;
}
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
macro_f_limit_sets_t_increase(status, controller_common_allocation_small_d, rule->limits);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_limit_sets_increase", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_limit_sets_increase", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
}
}
else {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "fl_conversion_string_to_number_signed", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "fl_conversion_string_to_number_signed", F_true, F_false);
status = F_status_set_error(status);
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
else {
// this function should only return F_complete_not_utf on error.
- controller_rule_print_error(global.main->error, cache->action, F_complete_not_utf, "controller_validate_has_graph", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_complete_not_utf, "controller_validate_has_graph", F_true, F_false);
if (F_status_is_error_not(status_return)) {
status_return = status;
}
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
}
setting_value->used = 0;
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], setting_value);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
}
else {
status = f_string_dynamic_terminate_after(setting_value);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false);
}
}
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
}
}
else {
- controller_rule_print_error(global.main->error, cache->action, status, "fl_conversion_string_to_number_signed", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, status, "fl_conversion_string_to_number_signed", F_true, F_false);
status = F_status_set_error(status);
if (F_status_is_error_not(status_return)) {
cache->action.line_action = ++cache->action.line_item;
- controller_rule_print_error(global.main->error, cache->action, status, "fl_conversion_string_to_number_signed", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, status, "fl_conversion_string_to_number_signed", F_true, F_false);
}
if (F_status_is_error_not(status_return)) {
status = controller_dynamic_rip_nulless_terminated(cache->buffer_item, cache->content_actions.array[i].array[1], &cache->action.generic);
if (F_status_is_error(status)) {
- controller_print_error(global.main->error, F_status_set_fine(status), "controller_dynamic_rip_nulless_terminated", F_true, global.thread);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "controller_dynamic_rip_nulless_terminated", F_true);
+
break;
}
controller_lock_print(global.main->error.to, global.thread);
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
controller_rule_print_error_cache(global.main->error, cache->action, F_false);
controller_lock_print(global.main->error.to, global.thread);
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false);
controller_rule_print_error_cache(global.main->error, cache->action, F_false);
controller_lock_print(global.main->error.to, global.thread);
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_capability_from_text", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_capability_from_text", F_true, F_false);
controller_rule_print_error_cache(global.main->error, cache->action, F_false);
}
}
else {
- controller_rule_print_error(global.main->error, cache->action, status, "fl_conversion_string_to_number_signed", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, status, "fl_conversion_string_to_number_signed", F_true, F_false);
status = F_status_set_error(status);
if (F_status_is_error_not(status_return)) {
controller_lock_print(global.main->error.to, global.thread);
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), cache->action.generic.used ? "f_string_dynamic_partial_append_nulless" : "f_string_dynamic_terminate_after", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), cache->action.generic.used ? "f_string_dynamic_partial_append_nulless" : "f_string_dynamic_terminate_after", F_true, F_false);
controller_rule_print_error_cache(global.main->error, cache->action, F_false);
cache->action.line_action = ++cache->action.line_item;
- controller_rule_print_error(global.main->error, cache->action, status, "controller_get_id_user", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, status, "controller_get_id_user", F_true, F_false);
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
}
if (F_status_is_error_not(status_return)) {
macro_f_int32s_t_increase_by(status, rule->groups, controller_common_allocation_small_d)
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "macro_f_array_lengths_t_increase_by", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "macro_f_array_lengths_t_increase_by", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
cache->action.line_action = ++cache->action.line_item;
- controller_rule_print_error(global.main->error, cache->action, status, "f_account_id_group_by_name", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, status, "f_account_id_group_by_name", F_true, F_false);
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
}
if (F_status_is_error_not(status_return)) {
status = f_string_dynamics_increase(controller_common_allocation_small_d, setting_values);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamics_increase", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamics_increase", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[j], &setting_values->array[setting_values->used]);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false);
}
else {
status = f_string_dynamic_terminate_after(&setting_values->array[setting_values->used]);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false);
}
}
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
else {
// This function should only return F_complete_not_utf on error.
- controller_rule_print_error(global.main->error, cache->action, F_complete_not_utf, "controller_validate_environment_name", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_complete_not_utf, "controller_validate_environment_name", F_true, F_false);
if (F_status_is_error_not(status_return)) {
status_return = status;
setting_values->array[setting_values->used].used = 0;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
}
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "controller_rule_ons_increase", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "controller_rule_ons_increase", F_true, F_false);
}
else {
if (fl_string_dynamic_partial_compare_string(controller_need_s, cache->buffer_item, controller_need_s_length, cache->content_actions.array[i].array[1]) == F_equal_to) {
status = f_string_dynamics_increase_by(controller_common_allocation_small_d, setting_values);
if (F_status_is_error(status)) {
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamics_increase_by", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamics_increase_by", F_true, F_false);
}
}
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
cache->action.line_action = ++cache->action.line_item;
- controller_rule_item_print_error(global.main->error, cache->action, F_false, F_status_set_fine(status), global.thread);
+ controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
continue;
}
if (F_status_is_error(status)) {
setting_values->array[setting_values->used].used = 0;
- controller_rule_print_error(global.main->error, cache->action, F_status_set_fine(status), "f_file_name_base", F_true, F_false, global.thread);
+ controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_file_name_base", F_true, F_false);
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
* -2 to designate exit due to signal/disabled thread.
*/
#ifndef _di_controller_rule_execute_rerun_
- extern int8_t controller_rule_execute_rerun(const uint8_t action, controller_process_t * const process, controller_rule_item_t *item) F_attribute_visibility_internal_d;
+ extern int8_t controller_rule_execute_rerun(const uint8_t action, controller_process_t * const process, controller_rule_item_t * const item) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_execute_rerun_
/**
* @see f_string_dynamic_terminate_after()
*/
#ifndef _di_controller_rule_id_construct_
- extern f_status_t controller_rule_id_construct(const controller_global_t global, const f_string_static_t source, const f_string_range_t directory, const f_string_range_t basename, f_string_dynamic_t *alias) F_attribute_visibility_internal_d;
+ extern f_status_t controller_rule_id_construct(const controller_global_t global, const f_string_static_t source, const f_string_range_t directory, const f_string_range_t basename, f_string_dynamic_t * const alias) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_id_construct_
/**
* @see f_string_dynamic_terminate_after()
*/
#ifndef _di_controller_rule_item_read_
- extern f_status_t controller_rule_item_read(const controller_global_t global, const bool is_normal, controller_cache_t * const cache, controller_rule_item_t *item) F_attribute_visibility_internal_d;
+ extern f_status_t controller_rule_item_read(const controller_global_t global, const bool is_normal, controller_cache_t * const cache, controller_rule_item_t * const item) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_item_read_
/**
* @see f_memory_resize()
*/
#ifndef _di_controller_rule_items_increase_by_
- extern f_status_t controller_rule_items_increase_by(const f_array_length_t amount, controller_rule_items_t *items) F_attribute_visibility_internal_d;
+ extern f_status_t controller_rule_items_increase_by(const f_array_length_t amount, controller_rule_items_t * const items) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_items_increase_by_
/**
* @see fl_conversion_string_to_number_signed()
*/
#ifndef _di_controller_rule_action_read_rerun_number_
- extern f_status_t controller_rule_action_read_rerun_number(const controller_global_t global, const f_string_t name, controller_cache_t * const cache, f_array_length_t *index, f_number_unsigned_t *number) F_attribute_visibility_internal_d;
+ extern f_status_t controller_rule_action_read_rerun_number(const controller_global_t global, const f_string_t name, controller_cache_t * const cache, f_array_length_t * const index, f_number_unsigned_t * const number) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_action_read_rerun_number_
/**
* @see fll_path_canonical()
*/
#ifndef _di_controller_rule_setting_read_
- extern f_status_t controller_rule_setting_read(const controller_global_t global, const bool is_normal, const controller_setting_t setting, controller_cache_t *const cache, controller_rule_t * const rule) F_attribute_visibility_internal_d;
+ extern f_status_t controller_rule_setting_read(const controller_global_t global, const bool is_normal, const controller_setting_t setting, controller_cache_t * const cache, controller_rule_t * const rule) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_setting_read_
/**
#endif
#ifndef _di_controller_rule_print_error_
- void controller_rule_print_error(const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item, controller_thread_t *thread) {
+ void controller_rule_print_error(controller_thread_t * const thread, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item) {
if (print.verbosity == f_console_verbosity_quiet_e) return;
if (status == F_interrupt) return;
#endif // _di_controller_rule_print_error_cache_
#ifndef _di_controller_rule_item_print_error_
- void controller_rule_item_print_error(const fl_print_t print, const controller_cache_action_t cache, const bool item, const f_status_t status, controller_thread_t *thread) {
+ void controller_rule_item_print_error(controller_thread_t * const thread, const fl_print_t print, const controller_cache_action_t cache, const bool item, const f_status_t status) {
if (print.verbosity == f_console_verbosity_quiet_e) return;
if (status == F_interrupt) return;
*
* This is essentially a wrapper to fll_error_print() that includes locking.
*
+ * @param thread
+ * The thread data.
* @param print
* Designates how printing is to be performed.
* @param cache
* Set to 0 to disable.
* @param fallback
* Set to F_true to print the fallback error message for unknown errors.
- * @param thread
- * The thread data.
* @param item
* If TRUE, then this error is associated with an item.
* If FALSE, then this error is associated with a rule setting.
* @see controller_rule_print_error_cache()
*/
#ifndef _di_controller_rule_print_error_
- extern void controller_rule_print_error(const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item, controller_thread_t *thread) F_attribute_visibility_internal_d;
+ extern void controller_rule_print_error(controller_thread_t * const thread, const fl_print_t print, const controller_cache_action_t cache, const f_status_t status, const f_string_t function, const bool fallback, const bool item) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_print_error_
/**
*
* This is explicitly intended to be used in addition to the error message.
*
+ * @param thread
+ * The thread data.
* @param print
* The error or warning print structure.
* @param cache
* If FALSE, then this error is associated with a rule setting.
* @param status
* The status code representing the failure (without the error bit set).
- * @param thread
- * The thread data.
*
* @see controller_rule_print_error_cache()
*/
#ifndef _di_controller_rule_item_print_error_
- extern void controller_rule_item_print_error(const fl_print_t print, const controller_cache_action_t cache, const bool item, const f_status_t status, controller_thread_t *thread) F_attribute_visibility_internal_d;
+ extern void controller_rule_item_print_error(controller_thread_t * const thread, const fl_print_t print, const controller_cache_action_t cache, const bool item, const f_status_t status) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_item_print_error_
/**
#endif
#ifndef _di_controller_thread_cleanup_
- void * controller_thread_cleanup(void *arguments) {
+ void * controller_thread_cleanup(void * const arguments) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
while (global->thread->enabled == controller_thread_enabled_e) {
- controller_time_sleep_nanoseconds(global->main, global->setting, delay);
+ nanosleep(&delay, 0);
if (global->thread->enabled != controller_thread_enabled_e) break;
#endif // _di_controller_thread_cleanup_
#ifndef _di_controller_thread_is_enabled_
- f_status_t controller_thread_is_enabled(const bool is_normal, controller_thread_t *thread) {
+ f_status_t controller_thread_is_enabled(const bool is_normal, controller_thread_t * const thread) {
if (is_normal) {
return thread->enabled == controller_thread_enabled_e;
#endif // _di_controller_thread_is_enabled_
#ifndef _di_controller_thread_is_enabled_process_
- f_status_t controller_thread_is_enabled_process(controller_process_t * const process, controller_thread_t *thread) {
+ f_status_t controller_thread_is_enabled_process(controller_process_t * const process, controller_thread_t * const thread) {
return controller_thread_is_enabled_process_type(process->type, thread);
}
#endif // _di_controller_thread_is_enabled_process_
#ifndef _di_controller_thread_is_enabled_process_type_
- f_status_t controller_thread_is_enabled_process_type(const uint8_t type, controller_thread_t *thread) {
+ f_status_t controller_thread_is_enabled_process_type(const uint8_t type, controller_thread_t * const thread) {
return controller_thread_is_enabled(type != controller_process_type_exit_e, thread);
}
#endif // _di_controller_thread_is_enabled_process_type_
#ifndef _di_controller_thread_main_
- f_status_t controller_thread_main(controller_main_t *main, controller_setting_t *setting) {
+ f_status_t controller_thread_main(controller_main_t * const main, controller_setting_t * const setting) {
f_status_t status = F_none;
status = controller_processs_increase(&thread.processs);
if (F_status_is_error(status)) {
- controller_print_error(main->error, F_status_set_fine(status), "controller_processs_increase", F_true, &thread);
+ controller_print_error(&thread, main->error, F_status_set_fine(status), "controller_processs_increase", F_true);
}
}
thread.id_signal = 0;
if (main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_print_error(main->error, F_status_set_fine(status), "f_thread_create", F_true, &thread);
+ controller_print_error(&thread, main->error, F_status_set_fine(status), "f_thread_create", F_true);
}
}
else {
if (F_status_is_error(status)) {
if (main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_print_error(main->error, F_status_set_fine(status), "f_thread_create", F_true, &thread);
+ controller_print_error(&thread, main->error, F_status_set_fine(status), "f_thread_create", F_true);
}
}
else {
thread.id_rule = 0;
}
else {
- status = f_thread_create(0, &thread.id_control, &controller_thread_control, (void *) &global);
- }
-
- if (F_status_is_error(status)) {
- thread.id_control = 0;
- }
- else {
status = f_thread_create(0, &thread.id_cleanup, &controller_thread_cleanup, (void *) &global);
}
thread.id_cleanup = 0;
if (main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_print_error(main->error, F_status_set_fine(status), "f_thread_create", F_true, &thread);
+ controller_print_error(&thread, main->error, F_status_set_fine(status), "f_thread_create", F_true);
}
}
}
controller_thread_process_exit(&global);
+ if (thread.id_listen) {
+ f_thread_cancel(thread.id_listen);
+ }
+
if (thread.id_signal) f_thread_join(thread.id_signal, 0);
if (thread.id_cleanup) f_thread_join(thread.id_cleanup, 0);
if (thread.id_control) f_thread_join(thread.id_control, 0);
+ if (thread.id_listen) f_thread_join(thread.id_listen, 0);
if (thread.id_entry) f_thread_join(thread.id_entry, 0);
if (thread.id_rule) f_thread_join(thread.id_rule, 0);
thread.id_cleanup = 0;
thread.id_control = 0;
+ thread.id_listen = 0;
+ thread.id_entry = 0;
thread.id_rule = 0;
thread.id_signal = 0;
#endif // _di_controller_thread_main_
#ifndef _di_controller_thread_join_
- f_status_t controller_thread_join(f_thread_id_t *id) {
+ f_status_t controller_thread_join(f_thread_id_t * const id) {
if (!id || !*id) return F_data_not;
* 0, always.
*/
#ifndef _di_controller_thread_cleanup_
- extern void * controller_thread_cleanup(void *arguments) F_attribute_visibility_internal_d;
+ extern void * controller_thread_cleanup(void * const arguments) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_cleanup_
/**
* FALSE when disabled.
*/
#ifndef _di_controller_thread_is_enabled_
- extern f_status_t controller_thread_is_enabled(const bool is_normal, controller_thread_t *thread) F_attribute_visibility_internal_d;
+ extern f_status_t controller_thread_is_enabled(const bool is_normal, controller_thread_t * const thread) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_is_enabled_
/**
* @see controller_thread_is_enabled_process_type()
*/
#ifndef _di_controller_thread_is_enabled_process_
- extern f_status_t controller_thread_is_enabled_process(controller_process_t * const process, controller_thread_t *thread) F_attribute_visibility_internal_d;
+ extern f_status_t controller_thread_is_enabled_process(controller_process_t * const process, controller_thread_t * const thread) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_is_enabled_process_
/**
* @see controller_thread_is_enabled()
*/
#ifndef _di_controller_thread_is_enabled_process_type_
- extern f_status_t controller_thread_is_enabled_process_type(const uint8_t type, controller_thread_t *thread) F_attribute_visibility_internal_d;
+ extern f_status_t controller_thread_is_enabled_process_type(const uint8_t type, controller_thread_t * const thread) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_is_enabled_process_type_
/**
* F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal.
*/
#ifndef _di_controller_thread_main_
- extern f_status_t controller_thread_main(controller_main_t *main, controller_setting_t *setting) F_attribute_visibility_internal_d;
+ extern f_status_t controller_thread_main(controller_main_t * const main, controller_setting_t * const setting) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_main_
/***
* @see f_thread_join()
*/
#ifndef _di_controller_thread_join_
- extern f_status_t controller_thread_join(f_thread_id_t *id) F_attribute_visibility_internal_d;
+ extern f_status_t controller_thread_join(f_thread_id_t * const id) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_join_
#ifdef __cplusplus
#include "controller.h"
#include "private-common.h"
+#include "private-control.h"
+#include "private-controller_print.h"
#include "private-thread.h"
#include "private-thread_control.h"
#endif
#ifndef _di_controller_thread_control_
- void * controller_thread_control(void *arguments) {
+ void * controller_thread_control(void * const arguments) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_global_t *global = (controller_global_t *) arguments;
+ const controller_global_t *global = (controller_global_t *) arguments;
if (global->thread->enabled != controller_thread_enabled_e) return 0;
+ f_status_t status = F_none;
+ f_socket_t * const server = &global->setting->control_socket;
+ controller_packet_t packet = controller_packet_t_initialize;
+
+ controller_control_configure_server(global, server);
+
+ do {
+ status = controller_control_accept(global, server, &packet);
+ } while (F_status_is_fine(status) && status != F_child && global->thread->enabled == controller_thread_enabled_e);
+
+ controller_packet_delete_simple(&packet);
+
return 0;
}
#endif // _di_controller_thread_control_
+#ifndef _di_controller_thread_control_listen_
+ void * controller_thread_control_listen(void * const arguments) {
+
+ f_thread_cancel_state_set(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
+
+ const controller_global_t *global = (controller_global_t *) arguments;
+
+ if (global->thread->enabled != controller_thread_enabled_e) return 0;
+
+ if (global->setting->interruptible) {
+ f_signal_mask(SIG_UNBLOCK, &global->main->signal.set, 0);
+ }
+
+ f_socket_t * const server = &global->setting->control_socket;
+
+ const f_status_t status = f_socket_listen(server, controller_control_default_socket_backlog_d);
+
+ if (F_status_is_error(status)) {
+ controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_socket_listen", F_true);
+ }
+
+ return 0;
+ }
+#endif // _di_controller_thread_control_listen_
+
#ifdef __cplusplus
} // extern "C"
#endif
* 0, always.
*/
#ifndef _di_controller_thread_control_
- extern void * controller_thread_control(void *arguments) F_attribute_visibility_internal_d;
+ extern void * controller_thread_control(void * const arguments) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_control_
+/**
+ * Thread for handling the control listener.
+ *
+ * This runs on a separate thread entirely to be interuptable and closable distinctly from the main control thread.
+ * This is simple and has nothing that needs to be cleaned up and so immediately exits on cancel.
+ *
+ * @param arguments
+ * The thread arguments.
+ * Must be of type controller_global_t.
+ *
+ * @return
+ * 0, always.
+ */
+#ifndef _di_controller_thread_control_listen_
+ extern void * controller_thread_control_listen(void * const arguments) F_attribute_visibility_internal_d;
+#endif // _di_controller_thread_control_listen_
+
#ifdef __cplusplus
} // extern "C"
#endif
#endif
#ifndef _di_controller_thread_entry_
- void * controller_thread_entry(void *arguments) {
+ void * controller_thread_entry(void * const arguments) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
*status = F_status_set_error(F_available_not);
}
else {
- *status = controller_entry_process(*entry->global, F_false, F_true, cache);
+ *status = controller_entry_process(entry->global, cache, F_false, F_true);
if (F_status_is_error(*status)) {
entry->setting->ready = controller_setting_ready_fail_e;
f_thread_create(0, &entry->global->thread->id_signal, &controller_thread_signal_normal, (void *) entry->global);
}
- const f_status_t status_failsafe = controller_entry_process(*entry->global, F_true, F_true, cache);
+ const f_status_t status_failsafe = controller_entry_process(entry->global, cache, F_true, F_true);
if (F_status_is_error(status_failsafe)) {
if (main->error.verbosity != f_console_verbosity_quiet_e) {
#endif // _di_controller_thread_entry_
#ifndef _di_controller_thread_exit_
- void * controller_thread_exit(void *arguments) {
+ void * controller_thread_exit(void * const arguments) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
if (F_status_is_error_not(*status) && *status != F_child && *status != F_file_found_not) {
if (main->parameters[controller_parameter_validate_e].result == f_console_result_none_e || main->parameters[controller_parameter_simulate_e].result == f_console_result_found_e) {
- *status = controller_entry_process(*entry->global, F_false, F_false, cache);
+ *status = controller_entry_process(entry->global, cache, F_false, F_false);
if (F_status_is_error(*status)) {
entry->setting->ready = controller_setting_ready_fail_e;
}
}
- const f_status_t status_failsafe = controller_entry_process(*entry->global, F_true, F_false, cache);
+ const f_status_t status_failsafe = controller_entry_process(entry->global, cache, F_true, F_false);
if (F_status_is_error(status_failsafe)) {
if (main->error.verbosity != f_console_verbosity_quiet_e) {
* 0, always.
*/
#ifndef _di_controller_thread_entry_
- extern void * controller_thread_entry(void *arguments) F_attribute_visibility_internal_d;
+ extern void * controller_thread_entry(void * const arguments) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_entry_
/**
* 0, always.
*/
#ifndef _di_controller_thread_exit_
- extern void * controller_thread_exit(void *arguments) F_attribute_visibility_internal_d;
+ extern void * controller_thread_exit(void * const arguments) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_exit_
#ifdef __cplusplus
time.tv_nsec = controller_thread_exit_process_cancel_wait_d;
nanosleep(&time, 0);
+
continue;
}
else {
#endif // _di_controller_thread_process_cancel_
#ifndef _di_controller_thread_process_exit_
- void controller_thread_process_exit(controller_global_t *global) {
+ void controller_thread_process_exit(controller_global_t * const global) {
if (global->thread->enabled != controller_thread_enabled_exit_e) {
return;
if (F_status_is_error(status)) {
if (global->main->error.verbosity != f_console_verbosity_quiet_e) {
- controller_print_error(global->main->error, F_status_set_fine(status), "f_thread_create", F_true, global->thread);
+ controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_thread_create", F_true);
}
if (F_status_is_error_not(f_thread_mutex_lock(&global->thread->lock.alert))) {
#endif // _di_controller_thread_process_exit_
#ifndef _di_controller_thread_process_normal_
- void * controller_thread_process_normal(void *arguments) {
+ void * controller_thread_process_normal(void * const arguments) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
#endif // _di_controller_thread_process_normal_
#ifndef _di_controller_thread_process_other_
- void * controller_thread_process_other(void *arguments) {
+ void * controller_thread_process_other(void * const arguments) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
* The global thread data.
*/
#ifndef _di_controller_thread_process_exit_
- extern void controller_thread_process_exit(controller_global_t *global) F_attribute_visibility_internal_d;
+ extern void controller_thread_process_exit(controller_global_t * const global) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_process_exit_
/**
* @see controller_thread_process()
*/
#ifndef _di_controller_thread_process_normal_
- extern void * controller_thread_process_normal(void *arguments) F_attribute_visibility_internal_d;
+ extern void * controller_thread_process_normal(void * const arguments) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_process_normal_
/**
* @see controller_thread_process()
*/
#ifndef _di_controller_thread_process_other_
- extern void * controller_thread_process_other(void *arguments) F_attribute_visibility_internal_d;
+ extern void * controller_thread_process_other(void * const arguments) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_process_other_
#ifdef __cplusplus
#endif
#ifndef _di_controller_thread_rule_
- void * controller_thread_rule(void *arguments) {
+ void * controller_thread_rule(void * const arguments) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_global_t *global = (controller_global_t *) arguments;
+ const controller_global_t *global = (controller_global_t *) arguments;
if (!controller_thread_is_enabled(F_true, global->thread)) return 0;
* 0, always.
*/
#ifndef _di_controller_thread_rule_
- extern void * controller_thread_rule(void *arguments) F_attribute_visibility_internal_d;
+ extern void * controller_thread_rule(void * const arguments) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_rule_
#ifdef __cplusplus
#endif
#ifndef _di_controller_thread_signal_
- void controller_thread_signal(const bool is_normal, controller_global_t *global) {
+ void controller_thread_signal(controller_global_t * const global, const bool is_normal) {
if (!controller_thread_is_enabled(is_normal, global->thread)) return;
#endif // _di_controller_thread_signal_
#ifndef _di_controller_thread_signal_state_fss_
- f_status_t controller_thread_signal_state_fss(void *state, void *internal) {
+ f_status_t controller_thread_signal_state_fss(void * const state, void * const internal) {
if (!state) {
return F_interrupt_not;
#endif // _di_controller_thread_signal_state_fss_
#ifndef _di_controller_thread_signal_state_iki_
- f_status_t controller_thread_signal_state_iki(void *state, void *internal) {
+ f_status_t controller_thread_signal_state_iki(void * const state, void * const internal) {
if (!state) {
return F_interrupt_not;
#endif // _di_controller_thread_signal_state_iki_
#ifndef _di_controller_thread_signal_normal_
- void * controller_thread_signal_normal(void *arguments) {
+ void * controller_thread_signal_normal(void * const arguments) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_thread_signal(F_true, (controller_global_t *) arguments);
+ controller_thread_signal((controller_global_t *) arguments, F_true);
return 0;
}
#endif // _di_controller_thread_signal_normal_
#ifndef _di_controller_thread_signal_other_
- void * controller_thread_signal_other(void *arguments) {
+ void * controller_thread_signal_other(void * const arguments) {
f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
- controller_thread_signal(F_false, (controller_global_t *) arguments);
+ controller_thread_signal((controller_global_t *) arguments, F_false);
return 0;
}
/**
* Thread for handling signals/interrupts.
*
+ * @param global
+ * The global data.
* @param is_normal
* If TRUE, then process as if this operates during a normal operation (entry and control).
* If FALSE, then process as if this operates during a an exit operation.
- * @param global
- * The global data.
*/
#ifndef _di_controller_thread_signal_
- extern void controller_thread_signal(const bool is_normal, controller_global_t *global) F_attribute_visibility_internal_d;
+ extern void controller_thread_signal(controller_global_t * const global, const bool is_normal) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_signal_
/**
* F_interrupt (with error bit) if interrupted.
*/
#ifndef _di_controller_thread_signal_state_fss_
- extern f_status_t controller_thread_signal_state_fss(void *state, void *internal) F_attribute_visibility_internal_d;
+ extern f_status_t controller_thread_signal_state_fss(void * const state, void * const internal) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_signal_state_fss_
/**
* F_interrupt (with error bit) if interrupted.
*/
#ifndef _di_controller_thread_signal_state_iki_
- extern f_status_t controller_thread_signal_state_iki(void *state, void *internal) F_attribute_visibility_internal_d;
+ extern f_status_t controller_thread_signal_state_iki(void * const state, void * const internal) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_signal_state_iki_
/**
* @see controller_thread_signal()
*/
#ifndef _di_controller_thread_signal_normal_
- extern void * controller_thread_signal_normal(void *arguments) F_attribute_visibility_internal_d;
+ extern void * controller_thread_signal_normal(void * const arguments) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_signal_normal_
/**
* @see controller_thread_signal()
*/
#ifndef _di_controller_thread_signal_other_
- extern void * controller_thread_signal_other(void *arguments) F_attribute_visibility_internal_d;
+ extern void * controller_thread_signal_other(void * const arguments) F_attribute_visibility_internal_d;
#endif // _di_controller_thread_signal_other_
#ifdef __cplusplus
build_libraries_shared
build_libraries_static
build_sources_library controller.c private-common.c private-process.c
-build_sources_library common/private-cache.c common/private-lock.c common/private-rule.c common/private-task.c common/private-process.c common/private-entry.c common/private-setting.c common/private-thread.c
+build_sources_library common/private-cache.c common/private-control.c common/private-entry.c common/private-lock.c common/private-process.c common/private-rule.c common/private-setting.c common/private-task.c common/private-thread.c
build_sources_library private-control.c private-controller.c private-entry.c private-rule.c private-task.c
build_sources_library private-control_print.c private-controller_print.c private-entry_print.c private-lock.c private-lock_print.c private-rule_print.c private-task_print.c
build_sources_library private-thread.c private-thread_control.c private-thread_entry.c private-thread_process.c private-thread_rule.c private-thread_signal.c