f_thread_lock_delete(&lock->rule);
f_thread_condition_delete(&lock->alert_condition);
+
+ lock->flag |= controller_lock_flag_setup_not_d;
}
#endif // _di_controller_lock_delete_
cache->action.generic.used = 0;
status = f_rip_dynamic_partial_nulless(buffer, range, &cache->action.generic);
- if (F_status_is_error(status)) return status;
- status = f_account_id_by_name(cache->action.generic, id);
+ if (F_status_is_error_not(status)) {
+ status = f_account_id_by_name(cache->action.generic, id);
+ }
+
if (F_status_is_error(status)) return status;
return (status == F_exist_not) ? F_status_set_error(F_exist_not) : F_okay;
cache->action.generic.used = 0;
status = f_rip_dynamic_partial_nulless(buffer, range, &cache->action.generic);
- if (F_status_is_error(status)) return status;
- status = f_account_group_id_by_name(cache->action.generic, id);
+ if (F_status_is_error_not(status)) {
+ status = f_account_group_id_by_name(cache->action.generic, id);
+ }
+
if (F_status_is_error(status)) return status;
return (status == F_exist_not) ? F_status_set_error(F_exist_not) : F_okay;
if (!main || !entry || !actions) return F_status_set_error(F_parameter);
- f_status_t status_action = F_okay;
-
actions->used = 0;
main->thread.cache.object_actions.used = main->thread.cache.object_actions.size;
return state.status;
}
+ f_status_t status_action = F_okay;
controller_entry_action_t *action = 0;
f_number_unsigned_t allocate = 0;
{
f_status_t status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_map_t), (void **) &setting_maps->array, &setting_maps->used, &setting_maps->size);
- if (F_status_is_error(status)) return status;
- setting_maps->array[setting_maps->used].key.used = 0;
- setting_maps->array[setting_maps->used].value.used = 0;
+ if (F_status_is_error_not(status)) {
+ setting_maps->array[setting_maps->used].key.used = 0;
+ setting_maps->array[setting_maps->used].value.used = 0;
- status = f_string_dynamic_partial_append_nulless(buffer, ranges.array[0], &setting_maps->array[setting_maps->used].key);
- if (F_status_is_error(status)) return status;
+ status = f_string_dynamic_partial_append_nulless(buffer, ranges.array[0], &setting_maps->array[setting_maps->used].key);
+ }
+
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_partial_append_nulless(buffer, ranges.array[1], &setting_maps->array[setting_maps->used].value);
+ }
- status = f_string_dynamic_partial_append_nulless(buffer, ranges.array[1], &setting_maps->array[setting_maps->used].value);
if (F_status_is_error(status)) return status;
}
if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
controller_t * const main = (controller_t *) print->custom;
-
controller_entry_t * const entry = is_entry ? &main->process.entry : &main->process.exit;
controller_lock_print(print->to, &main->thread);
}
else {
rerun_item = 0;
+
continue;
}
switch (j) {
case controller_rule_action_execute_type_freeze_e:
f_print_dynamic_raw(controller_freeze_s, print->to);
+
break;
case controller_rule_action_execute_type_kill_e:
f_print_dynamic_raw(controller_kill_s, print->to);
+
break;
case controller_rule_action_execute_type_pause_e:
f_print_dynamic_raw(controller_pause_s, print->to);
+
break;
case controller_rule_action_execute_type_reload_e:
f_print_dynamic_raw(controller_reload_s, print->to);
+
break;
case controller_rule_action_execute_type_restart_e:
f_print_dynamic_raw(controller_restart_s, print->to);
+
break;
case controller_rule_action_execute_type_resume_e:
f_print_dynamic_raw(controller_resume_s, print->to);
+
break;
case controller_rule_action_execute_type_start_e:
f_print_dynamic_raw(controller_start_s, print->to);
+
break;
case controller_rule_action_execute_type_stop_e:
f_print_dynamic_raw(controller_stop_s, print->to);
+
break;
case controller_rule_action_execute_type_thaw_e:
f_print_dynamic_raw(controller_thaw_s, print->to);
- break;
- default:
break;
}
main->thread.id_rule = 0;
main->thread.id_signal = 0;
- controller_thread_delete(&main->thread);
-
if (F_status_set_fine(status) == F_interrupt) {
main->setting.state.status = F_status_set_error(F_interrupt);
f_status_t status = F_okay;
status = f_string_dynamic_append(source.alias, &destination->alias);
- if (F_status_is_error(status)) return status;
- status = f_string_dynamic_append(source.engine, &destination->engine);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(source.engine, &destination->engine);
+ }
- status = f_string_dynamic_append(source.name, &destination->name);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(source.name, &destination->name);
+ }
- status = f_string_dynamic_append(source.path, &destination->path);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(source.path, &destination->path);
+ }
- status = f_string_maps_append_all(source.define, &destination->define);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_maps_append_all(source.define, &destination->define);
+ }
- status = f_string_maps_append_all(source.parameter, &destination->parameter);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_maps_append_all(source.parameter, &destination->parameter);
+ }
- status = f_string_dynamics_append_all(source.engine_arguments, &destination->engine_arguments);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamics_append_all(source.engine_arguments, &destination->engine_arguments);
+ }
+
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamics_append_all(source.environment, &destination->environment);
+ }
- status = f_string_dynamics_append_all(source.environment, &destination->environment);
if (F_status_is_error(status)) return status;
if (source.ons.used) {
}
status = f_memory_array_append_all((void *) source.affinity.array, source.affinity.used, sizeof(int32_t), (void **) &destination->affinity.array, &destination->affinity.used, &destination->affinity.size);
- if (F_status_is_error(status)) return status;
- if (source.capability) {
+ if (F_status_is_error_not(status) && source.capability) {
status = f_capability_copy(source.capability, &destination->capability);
- if (F_status_is_error(status)) return status;
}
- status = f_control_group_copy(source.cgroup, &destination->cgroup);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_control_group_copy(source.cgroup, &destination->cgroup);
+ }
- status = f_memory_array_append_all(source.groups.array, source.groups.used, sizeof(int32_t), (void **) &destination->groups.array, &destination->groups.used, &destination->groups.size);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_memory_array_append_all(source.groups.array, source.groups.used, sizeof(int32_t), (void **) &destination->groups.array, &destination->groups.used, &destination->groups.size);
+ }
+
+ if (F_status_is_error_not(status)) {
+ destination->limits.used = 0;
+ status = f_memory_array_append_all(source.limits.array, source.limits.used, sizeof(f_limit_set_t), (void **) &destination->limits.array, &destination->limits.used, &destination->limits.size);
+ }
- destination->limits.used = 0;
- status = f_memory_array_append_all(source.limits.array, source.limits.used, sizeof(f_limit_set_t), (void **) &destination->limits.array, &destination->limits.used, &destination->limits.size);
if (F_status_is_error(status)) return status;
if (source.items.used) {
f_status_t status = f_string_dynamic_partial_append_nulless(source, directory, alias);
- if (F_status_is_error(status)) {
- controller_print_error_status(&main->program.error, macro_controller_f(f_string_dynamic_partial_append_nulless), F_status_set_fine(status));
-
- return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append_nulless(f_path_separator_s, alias);
}
- status = f_string_dynamic_append(f_path_separator_s, alias);
-
- if (F_status_is_error(status)) {
- controller_print_error_status(&main->program.error, macro_controller_f(f_string_dynamic_append), F_status_set_fine(status));
-
- return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_partial_append_nulless(source, basename, alias);
}
- status = f_string_dynamic_partial_append_nulless(source, basename, alias);
-
if (F_status_is_error(status)) {
controller_print_error_status(&main->program.error, macro_controller_f(f_string_dynamic_partial_append_nulless), F_status_set_fine(status));
}
#ifndef _di_controller_rule_action_method_name_
f_string_static_t controller_rule_action_method_name(const uint8_t type) {
- if (type == controller_rule_action_method_extended_e) return controller_rule_action_method_extended_s;
- if (type == controller_rule_action_method_extended_list_e) return controller_rule_action_method_extended_list_s;
+ switch (type) {
+ case controller_rule_action_method_extended_e:
+ return controller_rule_action_method_extended_s;
+
+ case controller_rule_action_method_extended_list_e:
+ return controller_rule_action_method_extended_list_s;
+ }
return f_string_empty_s;
}
#ifndef _di_controller_rule_action_type_to_action_execute_type_
uint8_t controller_rule_action_type_to_action_execute_type(const uint8_t type) {
- if (type == controller_rule_action_type_freeze_e) return controller_rule_action_execute_type_freeze_e;
- if (type == controller_rule_action_type_kill_e) return controller_rule_action_execute_type_kill_e;
- if (type == controller_rule_action_type_pause_e) return controller_rule_action_execute_type_pause_e;
- if (type == controller_rule_action_type_reload_e) return controller_rule_action_execute_type_reload_e;
- if (type == controller_rule_action_type_restart_e) return controller_rule_action_execute_type_restart_e;
- if (type == controller_rule_action_type_resume_e) return controller_rule_action_execute_type_resume_e;
- if (type == controller_rule_action_type_start_e) return controller_rule_action_execute_type_start_e;
- if (type == controller_rule_action_type_stop_e) return controller_rule_action_execute_type_stop_e;
- if (type == controller_rule_action_type_thaw_e) return controller_rule_action_execute_type_thaw_e;
+ switch (type) {
+ case controller_rule_action_type_freeze_e:
+ return controller_rule_action_execute_type_freeze_e;
+
+ case controller_rule_action_type_kill_e:
+ return controller_rule_action_execute_type_kill_e;
+
+ case controller_rule_action_type_pause_e:
+ return controller_rule_action_execute_type_pause_e;
+
+ case controller_rule_action_type_reload_e:
+ return controller_rule_action_execute_type_reload_e;
+
+ case controller_rule_action_type_restart_e:
+ return controller_rule_action_execute_type_restart_e;
+
+ case controller_rule_action_type_resume_e:
+ return controller_rule_action_execute_type_resume_e;
+
+ case controller_rule_action_type_start_e:
+ return controller_rule_action_execute_type_start_e;
+
+ case controller_rule_action_type_stop_e:
+ return controller_rule_action_execute_type_stop_e;
+
+ case controller_rule_action_type_thaw_e:
+ return controller_rule_action_execute_type_thaw_e;
+ }
return controller_rule_action_execute_type__enum_size_e;
}
if (!execute_set || !instance || !instance->main) return F_status_set_error(F_parameter);
f_status_t status = F_okay;
-
controller_t * const main = instance->main;
-
f_execute_result_t result = f_execute_result_t_initialize;
status = f_memory_array_increase(controller_allocation_small_d, sizeof(pid_t), (void **) &instance->childs.array, &instance->childs.used, &instance->childs.size);
- if (F_status_is_error(status)) {
- controller_print_error_status(&main->program.error, macro_controller_f(f_memory_array_increase), F_status_set_fine(status));
-
- return status;
+ if (F_status_is_error_not(status)) {
+ status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &instance->path_pids.array, &instance->path_pids.used, &instance->path_pids.size);
}
- status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &instance->path_pids.array, &instance->path_pids.used, &instance->path_pids.size);
-
if (F_status_is_error(status)) {
controller_print_error_status(&main->program.error, macro_controller_f(f_memory_array_increase), F_status_set_fine(status));
f_time_spec_t delay = f_time_spec_t_initialize;
{
- const f_status_t status = f_time_spec_millisecond(0, rerun_item->delay, &delay);
+ f_status_t status = f_time_spec_millisecond(0, rerun_item->delay, &delay);
if (F_status_is_error(status)) {
controller_print_error_status(&main->program.error, macro_controller_f(f_time_spec_millisecond), F_status_set_fine(status));
return -1;
}
- }
- {
- const f_status_t status = controller_time_sleep_nanoseconds(instance->main, delay);
+ status = controller_time_sleep_nanoseconds(instance->main, delay);
if (F_status_is_error(status) || status == F_interrupt) return -1;
}
f_status_t controller_rule_expand_iki(controller_instance_t * const instance, const f_string_static_t source, const f_range_t vocabulary, const f_range_t content, f_string_dynamic_t * const destination) {
if (!instance || !instance->main || !destination) return F_status_set_error(F_parameter);
- if (vocabulary.start > vocabulary.stop) return F_okay;
- if (content.start > content.stop) return F_okay;
+ if (vocabulary.start > vocabulary.stop || content.start > content.stop) return F_okay;
f_status_t status = F_okay;
instance->cache.action.generic.used = 0;
status = f_environment_get(buffer, &instance->cache.action.generic);
- if (F_status_is_error(status)) return status;
- status = f_string_dynamic_append(instance->cache.action.generic, destination);
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(instance->cache.action.generic, destination);
+ }
+
if (F_status_is_error(status)) return status;
}
}
const f_number_unsigned_t index = parameters->array[codes[i]].values.array[parameters->array[codes[i]].values.used - 1];
status = f_memory_array_increase_by(symbols[i].used + expands[i].used + f_string_ascii_space_s.used + argv[index].used + 1, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
- if (F_status_is_error(status)) return status;
- status = f_string_dynamic_append(symbols[i], destination);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(symbols[i], destination);
+ }
- status = f_string_dynamic_append(expands[i], destination);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(expands[i], destination);
+ }
- status = f_string_dynamic_append(f_string_ascii_space_s, destination);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(f_string_ascii_space_s, destination);
+ }
+
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(argv[index], destination);
+ }
- status = f_string_dynamic_append(argv[index], destination);
if (F_status_is_error(status)) return status;
}
}
else {
if (parameters->array[codes[i]].result & f_console_result_found_e) {
- status = f_memory_array_increase_by(symbols[i].used + expands[i].used + 1, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_memory_array_increase_by(symbols[i].used + expands[i].used + 1, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ }
- status = f_string_dynamic_append(symbols[i], destination);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(symbols[i], destination);
+ }
+
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(expands[i], destination);
+ }
- status = f_string_dynamic_append(expands[i], destination);
if (F_status_is_error(status)) return status;
}
}
if (f_compare_dynamic_partial_string(buffer.string, source, buffer.used, content) == F_equal_to) {
if (values[i] && parameters->array[codes[i]].result & f_console_result_value_e || !values[i] && (parameters->array[codes[i]].result & f_console_result_found_e)) {
status = f_memory_array_increase_by(symbols[i].used + expands[i].used + 1, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
- if (F_status_is_error(status)) return status;
- status = f_string_dynamic_append(symbols[i], destination);
- if (F_status_is_error(status)) return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(symbols[i], destination);
+ }
+
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append(expands[i], destination);
+ }
- status = f_string_dynamic_append(expands[i], destination);
if (F_status_is_error(status)) return status;
}
// Find at least one of the requested Action when the Rule is required.
if (instance->options & controller_instance_option_require_e) {
bool missing = F_true;
-
f_number_unsigned_t j = 0;
for (i = 0; i < instance->rule.items.used; ++i) {
f_status_t controller_rule_instance_begin(controller_t * const main, controller_cache_t * const cache, const uint8_t options_force, const f_string_static_t alias_rule, const uint8_t action, const uint8_t options, const uint8_t type, const f_number_unsigneds_t stack) {
if (!main || !cache) return F_status_set_error(F_parameter);
-
- if (!controller_thread_is_enabled_instance_type(&main->thread, type)) {
- return F_status_set_error(F_interrupt);
- }
+ if (!controller_thread_is_enabled_instance_type(&main->thread, type)) return F_status_set_error(F_interrupt);
f_status_t status = controller_lock_read(type != controller_instance_type_exit_e, F_true, &main->thread, &main->thread.lock.instance);
}
f_status_t status = F_okay;
-
f_number_unsigned_t id_rule = 0;
const f_number_unsigned_t used_original_stack = instance->stack.used;
}
if (F_status_is_error_not(state->status)) {
- if (content) {
- state->status = f_memory_array_increase_by(content->used + 1, sizeof(f_iki_data_t), (void **) &action->ikis.array, &action->ikis.used, &action->ikis.size);
- }
- else {
- state->status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_iki_data_t), (void **) &action->ikis.array, &action->ikis.used, &action->ikis.size);
- }
+ state->status = content
+ ? f_memory_array_increase_by(content->used + 1, sizeof(f_iki_data_t), (void **) &action->ikis.array, &action->ikis.used, &action->ikis.size);
+ : f_memory_array_increase(controller_allocation_small_d, sizeof(f_iki_data_t), (void **) &action->ikis.array, &action->ikis.used, &action->ikis.size);
}
if (F_status_is_error(state->status)) {
f_status_t status_return = F_okay;
f_range_t range = macro_f_range_t_initialize_2(cache->buffer_item.used);
- f_range_t range2 = f_range_t_initialize;
controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_normal, main);
f_state_t state = macro_f_state_t_initialize_1(controller_allocation_large_d, controller_allocation_small_d, F_okay, 0, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0);
f_string_dynamics_t *setting_values = 0;
f_string_maps_t *setting_maps = 0;
+ f_range_t range2 = f_range_t_initialize;
f_number_unsigned_t i = 0;
f_number_unsigned_t j = 0;
uint8_t type = 0;
uint8_t action = 0;
- bool empty_disallow = F_true;
+ uint8_t empty_disallow = F_true;
// Save the current name item and line number to restore on return.
const f_number_unsigned_t line_item = cache->action.line_item;
case F_valid_not:
return F_status_set_error(F_valid_not);
-
- default:
- return F_status_set_error(F_failure);
};
+
+ return F_status_set_error(F_failure);
}
#endif // _di_controller_status_simplify_error_
// It seems that this function doesn't return to the calling thread for a forked child process, even with the "return 0;" below.
if (*status == F_child) {
controller_delete(main);
-
- return 0;
}
+ else {
+ controller_thread_instance_force_set_disable(main);
- controller_thread_instance_force_set_disable(main);
-
- f_thread_condition_signal_all(&main->thread.lock.alert_condition);
+ f_thread_condition_signal_all(&main->thread.lock.alert_condition);
+ }
return 0;
}