The control program is now in its own separate project.
+++ /dev/null
-#include "control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_control_action_type_identify_
- const uint8_t control_action_type_identify(const f_string_static_t action) {
-
- if (f_compare_dynamic(action, control_freeze_s) == F_equal_to) return control_action_type_freeze_e;
- if (f_compare_dynamic(action, control_kexec_s) == F_equal_to) return control_action_type_kexec_e;
- if (f_compare_dynamic(action, control_kill_s) == F_equal_to) return control_action_type_kill_e;
- if (f_compare_dynamic(action, control_pause_s) == F_equal_to) return control_action_type_pause_e;
- if (f_compare_dynamic(action, control_reboot_s) == F_equal_to) return control_action_type_reboot_e;
- if (f_compare_dynamic(action, control_reload_s) == F_equal_to) return control_action_type_reload_e;
- if (f_compare_dynamic(action, control_rerun_s) == F_equal_to) return control_action_type_rerun_e;
- if (f_compare_dynamic(action, control_restart_s) == F_equal_to) return control_action_type_restart_e;
- if (f_compare_dynamic(action, control_resume_s) == F_equal_to) return control_action_type_resume_e;
- if (f_compare_dynamic(action, control_shutdown_s) == F_equal_to) return control_action_type_shutdown_e;
- if (f_compare_dynamic(action, control_start_s) == F_equal_to) return control_action_type_start_e;
- if (f_compare_dynamic(action, control_stop_s) == F_equal_to) return control_action_type_stop_e;
- if (f_compare_dynamic(action, control_thaw_s) == F_equal_to) return control_action_type_thaw_e;
-
- return 0;
- }
-#endif // _di_control_action_type_identify_
-
-#ifndef _di_control_action_type_name_
- const f_string_static_t control_action_type_name(const uint8_t type) {
-
- switch (type) {
- case control_action_type_freeze_e:
- return control_freeze_s;
-
- case control_action_type_kexec_e:
- return control_kexec_s;
-
- case control_action_type_kill_e:
- return control_kill_s;
-
- case control_action_type_pause_e:
- return control_pause_s;
-
- case control_action_type_reboot_e:
- return control_reboot_s;
-
- case control_action_type_reload_e:
- return control_reload_s;
-
- case control_action_type_rerun_e:
- return control_rerun_s;
-
- case control_action_type_restart_e:
- return control_restart_s;
-
- case control_action_type_resume_e:
- return control_resume_s;
-
- case control_action_type_shutdown_e:
- return control_shutdown_s;
-
- case control_action_type_start_e:
- return control_start_s;
-
- case control_action_type_stop_e:
- return control_stop_s;
-
- case control_action_type_thaw_e:
- return control_thaw_s;
- }
-
- return f_string_empty_s;
- }
-#endif // _di_control_action_type_name_
-
-#ifndef _di_control_action_verify_
- void control_action_verify(control_main_t * const main) {
-
- if (!main) return;
-
- switch (main->setting.action) {
- case control_action_type_freeze_e:
- case control_action_type_kill_e:
- case control_action_type_pause_e:
- case control_action_type_reload_e:
- case control_action_type_rerun_e:
- case control_action_type_restart_e:
- case control_action_type_resume_e:
- case control_action_type_start_e:
- case control_action_type_stop_e:
- case control_action_type_thaw_e:
- if (main->setting.actions.used < 3) {
- control_print_error_parameter_action_rule_not(&main->program.error, main->setting.actions.array[0]);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
-
- if (main->setting.actions.used > 3) {
- if (f_compare_dynamic(control_at_s, main->setting.actions.array[3]) == F_equal_to) {
- if (main->setting.actions.used < 5) {
- control_print_error_parameter_action_rule_too_few_with(&main->program.error, main->setting.actions.array[0], control_at_s);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
-
- if (main->setting.actions.used > 5) {
- control_print_error_parameter_action_rule_too_many_with(&main->program.error, main->setting.actions.array[0], control_at_s);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
- }
- else if (f_compare_dynamic(control_in_s, main->setting.actions.array[3]) == F_equal_to) {
- if (main->setting.actions.used < 6) {
- control_print_error_parameter_action_rule_too_few_with(&main->program.error, main->setting.actions.array[0], control_in_s);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
- }
- else if (f_compare_dynamic(control_now_s, main->setting.actions.array[3]) == F_equal_to) {
- if (main->setting.actions.used > 4) {
- control_print_error_parameter_action_rule_too_many_with(&main->program.error, main->setting.actions.array[0], control_now_s);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
- }
- else {
- control_print_error_parameter_action_rule_with_unknown(&main->program.error, main->setting.actions.array[0], main->setting.actions.array[2]);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
- }
-
- if (!main->setting.actions.array[1].used) {
- if (main->setting.actions.used == 3) {
- control_print_error_parameter_action_rule_empty(&main->program.error, main->setting.actions.array[0]);
- }
- else {
- control_print_error_parameter_action_rule_directory_empty(&main->program.error, main->setting.actions.array[0]);
- }
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
-
- if (main->setting.actions.used == 3) {
- if (!main->setting.actions.array[2].used) {
- control_print_error_parameter_action_rule_basename_empty(&main->program.error, main->setting.actions.array[0]);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
- }
-
- main->setting.state.status = F_okay;
-
- return;
-
- case control_action_type_kexec_e:
- case control_action_type_reboot_e:
- case control_action_type_shutdown_e:
- if (main->setting.actions.used < 2) {
- control_print_error_parameter_action_rule_too_few(&main->program.error, main->setting.actions.array[0]);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
-
- if (f_compare_dynamic(control_at_s, main->setting.actions.array[1]) == F_equal_to) {
- if (main->setting.actions.used < 3) {
- control_print_error_parameter_action_rule_too_few_with(&main->program.error, main->setting.actions.array[0], control_at_s);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
-
- if (main->setting.actions.used > 3) {
- control_print_error_parameter_action_rule_too_many_with(&main->program.error, main->setting.actions.array[0], control_at_s);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
- }
- else if (f_compare_dynamic(control_in_s, main->setting.actions.array[1]) == F_equal_to) {
- if (main->setting.actions.used < 4) {
- control_print_error_parameter_action_rule_too_few_with(&main->program.error, main->setting.actions.array[0], control_in_s);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
- }
- else if (f_compare_dynamic(control_now_s, main->setting.actions.array[1]) == F_equal_to) {
- if (main->setting.actions.used > 2) {
- control_print_error_parameter_action_rule_too_many_with(&main->program.error, main->setting.actions.array[0], control_now_s);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
- }
- else {
- control_print_error_parameter_action_rule_with_unknown(&main->program.error, main->setting.actions.array[0], main->setting.actions.array[1]);
-
- main->setting.state.status = F_status_set_error(F_parameter);
-
- return;
- }
- }
-
- main->setting.state.status = F_okay;
- }
-#endif // _di_control_action_verify_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the action functionality.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_action_h
-#define _control_action_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Identify the action code the given name represents.
- *
- * @param action
- * The string representing an action.
- *
- * @return
- * The action type code on success.
- * 0 if name is unknown.
- */
-#ifndef _di_control_action_type_identify_
- extern const uint8_t control_action_type_identify(const f_string_static_t action);
-#endif // _di_control_action_type_identify_
-
-/**
- * Get a string representing the action type.
- *
- * @param type
- * The action type id.
- *
- * @return
- * The string with used > 0 on success.
- * The string with used == 0 if no match was found.
- */
-#ifndef _di_control_action_type_name_
- extern const f_string_static_t control_action_type_name(const uint8_t type);
-#endif // _di_control_action_type_name_
-
-/**
- * Verify that the additional parameters are reasonably correct for the identified action.
- *
- * @param main
- * The main program data.
- *
- * This alters main.setting.state.status:
- * F_okay on success.
- *
- * F_parameter (with error bit) on parameter validation/verification failure.
- */
-#ifndef _di_control_action_verify_
- extern void control_action_verify(control_main_t * const main);
-#endif // _di_control_action_verify_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_action_h
+++ /dev/null
-#include "control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_control_setting_load_
- void control_setting_load(const f_console_arguments_t arguments, control_main_t * const main) {
-
- if (!main) return;
-
- main->setting.state.step_small = control_allocation_console_d;
-
- f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0);
-
- main->setting.state.step_small = control_allocation_small_d;
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error(&main->program.error, macro_control_f(f_console_parameter_process));
-
- return;
- }
-
- main->setting.state.status = fll_program_parameter_process_context_standard(F_true, &main->program);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error(&main->program.error, macro_control_f(fll_program_parameter_process_context_standard));
-
- return;
- }
-
- main->setting.state.status = fll_program_parameter_process_verbosity_standard(F_true, &main->program);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error(&main->program.error, macro_control_f(fll_program_parameter_process_verbosity_standard));
-
- return;
- }
-
- if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) {
- main->setting.flag |= control_main_flag_help_e;
-
- return;
- }
-
- if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) {
- main->setting.flag |= control_main_flag_version_e;
-
- return;
- }
-
- if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) {
- main->setting.flag |= control_main_flag_copyright_e;
-
- return;
- }
-
- if (main->program.parameters.array[control_parameter_return_e].result & f_console_result_found_e) {
- main->setting.flag |= control_main_flag_return_e;
-
- return;
- }
-
- f_number_unsigned_t index = 0;
-
- if (main->program.pipe & fll_program_data_pipe_input_e) {
- main->setting.flag |= control_main_flag_pipe_e;
- }
- else {
- main->setting.flag &= ~control_main_flag_pipe_e;
- }
-
- // The settings path is statically allocated.
- if (main->program.parameters.array[control_parameter_settings_e].result & f_console_result_value_e) {
- index = main->program.parameters.array[control_parameter_settings_e].values.array[main->program.parameters.array[control_parameter_settings_e].values.used - 1];
-
- main->setting.path_settings.string = main->program.parameters.arguments.array[index].string;
- main->setting.path_settings.used = main->program.parameters.arguments.array[index].used;
- main->setting.path_settings.size = 0;
- }
- else {
- main->setting.path_settings.string = control_path_settings_s.string;
- main->setting.path_settings.used = control_path_settings_s.used;
- main->setting.path_settings.size = 0;
- }
-
- {
- f_file_t file = f_file_t_initialize;
-
- main->setting.state.status = f_file_stream_open(main->setting.path_settings, f_file_open_mode_read_s, &file);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error_file(&main->program.error, macro_control_f(f_file_stream_open), main->setting.path_settings, f_file_operation_open_s, fll_error_file_type_file_e);
-
- return;
- }
-
- main->setting.state.status = f_file_stream_read(file, &main->cache.large);
-
- f_file_stream_flush(file);
- f_file_stream_close(&file);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error_file(&main->program.error, macro_control_f(f_file_stream_read), main->setting.path_settings, f_file_operation_read_s, fll_error_file_type_file_e);
-
- return;
- }
- }
-
- if (main->cache.large.used) {
- main->setting.range.start = 0;
- main->setting.range.stop = main->cache.large.used - 1;
- }
- else {
- main->setting.range.start = 1;
- main->setting.range.stop = 0;
- }
-
- fll_fss_extended_read(main->cache.large, &main->setting.range, &main->cache.objects, &main->cache.contents, 0, 0, &main->cache.delimits, 0, &main->setting.state);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error_file(&main->program.error, macro_control_f(fll_fss_extended_read), main->setting.path_settings, f_file_operation_process_s, fll_error_file_type_file_e);
-
- return;
- }
-
- f_fss_apply_delimit(main->cache.delimits, &main->cache.large, &main->setting.state);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error_file(&main->program.error, macro_control_f(f_fss_apply_delimit), main->setting.path_settings, f_file_operation_process_s, fll_error_file_type_file_e);
-
- return;
- }
-
- uint8_t i = 0;
- uint8_t parameter_hass[] = { 0, 0, 0, 0 };
- f_number_unsigned_t parameter_ats[] = { 0, 0, 0, 0 };
-
- {
- const f_string_static_t parameter_names[] = {
- control_name_socket_s,
- control_path_socket_s,
- control_path_socket_prefix_s,
- control_path_socket_suffix_s,
- };
-
- f_number_unsigned_t j = 0;
- uint8_t k = 0;
-
- for (; j < main->cache.objects.used; ++j) {
-
- for (k = 0; k < 4; ++k) {
-
- if (!parameter_names[k].used) continue;
-
- main->setting.range.start = 0;
- main->setting.range.stop = parameter_names[k].used - 1;
-
- if (f_compare_dynamic_partial(parameter_names[k], main->cache.large, main->setting.range, main->cache.objects.array[j]) == F_equal_to) {
- parameter_hass[k] = F_true;
- parameter_ats[k] = j;
-
- break;
- }
- } // for
- } // for
- }
-
- // The settings path is statically allocated, except when read from the settings file.
- if (main->program.parameters.array[control_parameter_socket_e].result & f_console_result_value_e) {
- index = main->program.parameters.array[control_parameter_settings_e].values.array[main->program.parameters.array[control_parameter_settings_e].values.used - 1];
-
- main->setting.path_socket.string = main->program.parameters.arguments.array[index].string;
- main->setting.path_socket.used = main->program.parameters.arguments.array[index].used;
- main->setting.path_socket.size = 0;
- }
- else if (parameter_hass[1]) {
- main->setting.state.status = f_string_dynamic_partial_append_nulless(main->cache.large, main->cache.objects.array[parameter_ats[1]], &main->setting.path_socket);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error_file(&main->program.error, macro_control_f(f_string_dynamic_partial_append_nulless), main->setting.path_socket, f_file_operation_process_s, fll_error_file_type_file_e);
-
- return;
- }
- }
- else {
- main->setting.path_socket.string = controller_path_socket_s.string;
- main->setting.path_socket.used = controller_path_socket_s.used;
- main->setting.path_socket.size = 0;
- }
-
- main->setting.state.status = f_file_exists(main->setting.path_socket, F_true);
-
- if (F_status_is_error(main->setting.state.status) || main->setting.state.status == F_false) {
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error_file(&main->program.error, macro_control_f(f_file_exists), main->setting.path_socket, f_file_operation_find_s, fll_error_file_type_directory_e);
-
- if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
- fll_print_dynamic_raw(f_string_eol_s, main->program.error.to);
- }
- }
-
- main->setting.state.status = F_status_set_error(F_socket_not);
-
- control_print_error_socket_file_missing(&main->program.error, main->setting.path_socket);
-
- return;
- }
-
- // Construct the file name when the socket path is a directory.
- if (f_file_is(main->setting.path_socket, F_file_type_directory_d, F_true) == F_true) {
- main->setting.state.status = f_string_dynamic_append_assure(f_path_separator_s, &main->setting.path_socket);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error(&main->program.error, macro_control_f(f_string_dynamic_append_assure));
-
- return;
- }
-
- {
- const uint8_t append_ids[] = {
- 0,
- control_parameter_name_e,
- 0,
- };
-
- const uint8_t append_hass[] = {
- parameter_hass[2],
- parameter_hass[0],
- parameter_hass[3],
- };
-
- const f_string_static_t append_defaults[] = {
- controller_path_socket_prefix_s,
- controller_name_socket_s,
- controller_path_socket_suffix_s,
- };
-
- for (i = 0; i < 3; ++i) {
-
- if (append_ids[i] && main->program.parameters.array[append_ids[i]].result & f_console_result_value_e) {
- index = main->program.parameters.array[append_ids[i]].values.array[main->program.parameters.array[append_ids[i]].values.used - 1];
-
- main->setting.state.status = f_string_dynamic_append(main->program.parameters.arguments.array[index], &main->setting.path_socket);
- }
- else if (append_hass[i]) {
- main->setting.state.status = f_string_dynamic_partial_append_nulless(main->cache.large, main->cache.objects.array[append_hass[i]], &main->setting.path_socket);
- }
- else {
- main->setting.state.status = f_string_dynamic_append_nulless(append_defaults[i], &main->setting.path_socket);
- }
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error(
- &main->program.error,
- ((append_ids[i] && main->program.parameters.array[append_ids[i]].result & f_console_result_value_e) || !append_hass[i])
- ? macro_control_f(f_string_dynamic_append)
- : macro_control_f(f_string_dynamic_partial_append_nulless)
- );
-
- return;
- }
- } // for
-
- main->setting.state.status = f_file_exists(main->setting.path_socket, F_true);
-
- if (F_status_is_error(main->setting.state.status) || main->setting.state.status == F_false) {
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error_file(&main->program.error, macro_control_f(f_file_exists), main->setting.path_socket, f_file_operation_find_s, fll_error_file_type_directory_e);
-
- if (main->program.error.verbosity > f_console_verbosity_quiet_e) {
- fll_print_dynamic_raw(f_string_eol_s, main->program.error.to);
- }
- }
-
- main->setting.state.status = F_status_set_error(F_socket_not);
-
- control_print_error_socket_file_missing(&main->program.error, main->setting.path_socket);
-
- return;
- }
- }
- }
-
- if (f_file_is(main->setting.path_socket, F_file_type_socket_d, F_true) == F_false) {
- main->setting.state.status = F_status_set_error(F_socket_not);
-
- control_print_error_socket_file_not(&main->program.error, main->setting.path_socket);
-
- return;
- }
-
- main->setting.state.status = f_socket_create(&main->setting.socket);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error(&main->program.error, macro_control_f(f_socket_create));
-
- control_print_error_socket_file_failed(&main->program.error, main->setting.path_socket);
-
- return;
- }
-
- main->setting.state.status = f_socket_connect(&main->setting.socket);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error(&main->program.error, macro_control_f(f_socket_connect));
-
- control_print_error_socket_file_failed(&main->program.error, main->setting.path_socket);
-
- return;
- }
-
- f_memory_array_resize(0, sizeof(f_range_t), (void **) &main->cache.objects.array, &main->cache.objects.used, &main->cache.objects.size);
- f_memory_arrays_resize(0, sizeof(f_ranges_t), (void **) &main->cache.contents.array, &main->cache.contents.used, &main->cache.contents.size, &f_rangess_delete_callback);
- f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &main->cache.delimits.array, &main->cache.delimits.used, &main->cache.delimits.size);
-
- {
- const uint8_t ids[] = {
- control_parameter_name_e,
- control_parameter_settings_e,
- control_parameter_socket_e
- };
-
- const f_string_static_t names[] = {
- control_long_name_s,
- control_long_settings_s,
- control_long_socket_s
- };
-
- f_status_t error_printed_not = F_false;
-
- for (i = 0; i < 3; ++i) {
-
- if (main->program.parameters.array[ids[i]].result & f_console_result_found_e) {
- main->setting.state.status = F_status_set_error(F_parameter);
-
- if (error_printed_not) {
- error_printed_not = F_true;
- }
-
- control_print_error_parameter_value_not(&main->program.error, names[i]);
- }
- else if (main->program.parameters.array[ids[i]].result & f_console_result_value_e) {
- index = main->program.parameters.array[ids[i]].values.array[main->program.parameters.array[ids[i]].values.used - 1];
-
- if (!main->program.parameters.arguments.array[index].used) {
- main->setting.state.status = F_status_set_error(F_parameter);
-
- if (error_printed_not) {
- error_printed_not = F_true;
- }
-
- control_print_error_parameter_value_empty(&main->program.error, names[i]);
- }
- }
- } // for
- }
-
- main->cache.large.used = 0;
-
- if (main->cache.large.size > control_default_buffer_limit_soft_large_d) {
- main->setting.state.status = f_memory_array_resize(control_default_buffer_limit_soft_large_d, sizeof(f_char_t), (void **) &main->cache.large.string, &main->cache.large.used, &main->cache.large.size);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error(&main->program.error, macro_control_f(f_memory_array_resize));
-
- return;
- }
- }
-
- if (main->program.parameters.remaining.used) {
- main->setting.state.status = f_memory_array_increase_by(main->program.parameters.remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.actions.array, &main->setting.actions.used, &main->setting.actions.size);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error(&main->program.error, macro_control_f(f_memory_array_increase_by));
-
- return;
- }
-
- index = 0;
-
- for (f_number_unsigned_t number = 0; index < main->program.parameters.remaining.used; ++index) {
-
- if (control_signal_check(main)) return;
-
- number = main->program.parameters.remaining.array[index];
-
- // Statically allocate the inner strings.
- main->setting.actions.array[main->setting.actions.used].string = main->program.parameters.arguments.array[number].string;
- main->setting.actions.array[main->setting.actions.used].used = main->program.parameters.arguments.array[number].used;
- main->setting.actions.array[main->setting.actions.used++].size = 0;
- } // for
- }
-
- main->setting.state.status = F_okay;
- }
-#endif // _di_control_setting_load_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the common data structures.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_common_h
-#define _control_common_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Perform the standard program setting load process.
- *
- * This prints error messages as appropriate.
- *
- * If either main or setting is NULL, then this immediately returns without doing anything.
- *
- * @param arguments
- * The parameters passed to the process (often referred to as command line arguments).
- * @param main
- * The main program data and settings.
- *
- * This alters main.setting.state.status:
- * F_okay on success.
- *
- * Errors (with error bit) from: f_console_parameter_process().
- * Errors (with error bit) from: fll_program_parameter_process_context().
- *
- * @see f_console_parameter_process()
- * @see fll_program_parameter_process_context()
- */
-#ifndef _di_control_setting_load_
- extern void control_setting_load(const f_console_arguments_t arguments, control_main_t * const main);
-#endif // _di_control_setting_load_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_common_h
+++ /dev/null
-#include "../control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the common define types.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_common_define_h
-#define _control_common_define_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * The program allocation defines.
- *
- * control_allocation_*_d:
- * - console: An allocation step used for small buffers specifically for console parameter.
- * - large: An allocation step used for buffers that are anticipated to have large buffers.
- * - pipe: A buffer size used for processing piped data.
- * - small: An allocation step used for buffers that are anticipated to have small buffers.
- */
-#ifndef _di_control_allocation_d_
- #define control_allocation_console_d 4
- #define control_allocation_large_d 256
- #define control_allocation_pipe_d 16384
- #define control_allocation_small_d 16
-#endif // _di_control_allocation_d_
-
-/**
- * General defines used throughout the program.
- *
- * control_default_*_d:
- * - buffer_limit_soft_large: The preferred maximum size of buffers intended for large data sets such that sizes exceeding this will be shrunk when operations are complete (aka: a soft limit).
- * - buffer_limit_soft_small: The preferred maximum size of buffers intended for small data sets such that sizes exceeding this will be shrunk when operations are complete (aka: a soft limit).
- */
-#ifndef _di_control_default_d_
- #define control_default_buffer_limit_soft_large_d 2048
- #define control_default_buffer_limit_soft_small_d 64
-#endif // _di_control_default_d_
-
-/**
- * The program signal defines.
- *
- * control_signal_*_d:
- * - check: Number of iterations before performing signal check in non-threaded signal handling.
- * - check_failsafe: When using threads, how many consecutive failures to check signal before aborting (as a recursion failsafe).
- * - check_tiny: The tiny check.
- * - check_short: The short signal check.
- */
-#ifndef _di_control_signal_d_
- #define control_signal_check_d 500000
- #define control_signal_check_failsafe_d 20000
- #define control_signal_check_tiny_d 4
- #define control_signal_check_short_d 16
-#endif // _di_control_signal_d_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_common_define_h
+++ /dev/null
-#include "../control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the common enumeration types.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_common_enumeration_h
-#define _control_common_enumeration_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Codes representing supported actions.
- *
- * freeze: Perform the freeze controller operation.
- * kexec: Perform the kexec controller operation (only for init mode).
- * kill: Perform the kill controller operation.
- * pause: Perform the pause controller operation.
- * reboot: Perform the reboot controller operation (only for init mode).
- * reload: Perform the reload controller operation.
- * rerun: Perform the rerun controller operation.
- * restart: Perform the restart controller operation.
- * resume: Perform the resume controller operation.
- * shutdown: Perform the shutdown controller operation (only for init mode).
- * start: Perform the start controller operation.
- * stop: Perform the stop controller operation.
- * thaw: Perform the thaw controller operation.
- */
-#ifndef _di_control_action_type_e_
- enum {
- control_action_type_freeze_e = 1,
- control_action_type_kexec_e,
- control_action_type_kill_e,
- control_action_type_pause_e,
- control_action_type_reboot_e,
- control_action_type_reload_e,
- control_action_type_rerun_e,
- control_action_type_restart_e,
- control_action_type_resume_e,
- control_action_type_shutdown_e,
- control_action_type_start_e,
- control_action_type_stop_e,
- control_action_type_thaw_e,
- }; // enum
-#endif // _di_control_action_type_e_
-
-/**
- * Supported payload types.
- *
- * controller: The payload is a controller payload.
- * error: The payload is an error payload.
- * init: The payload is an init payload (only available when operating in "init" mode).
- */
-#ifndef _di_control_payload_type_e_
- enum {
- control_payload_type_controller_e = 1,
- control_payload_type_error_e,
- control_payload_type_init_e,
- }; // enum
-#endif // _di_control_payload_type_e_
-
-/**
- * A codes repesent different flags associated with a packet.
- *
- * control_packet_flag_*:
- * - binary: Designate that the packet is in binary mode (when not set then packet is in string mode).
- * - endian_big: Designate that the packet is in big endian order (when not set then packet is in little endian order).
- */
-#ifndef _di_control_packet_flag_e_
- #define control_packet_flag_binary_d 0x80
- #define control_packet_flag_endian_big_d 0x40
-#endif // _di_control_packet_flag_e_
-
-/**
- * Flags passed to the main function or program.
- *
- * control_main_flag_*_e:
- * - none: No flags set.
- * - copyright: Print copyright.
- * - header: Enable printing of headers.
- * - help: Print help.
- * - pipe: Use the input pipe.
- * - return: The parameter is specified.
- * - version: Print version.
- * - version_copyright_help: A helper flag representing version, copyright, and help flag bits being set.
- */
-#ifndef _di_control_main_flag_e_
- enum {
- control_main_flag_none_e = 0x0,
- control_main_flag_copyright_e = 0x1,
- control_main_flag_help_e = 0x2,
- control_main_flag_pipe_e = 0x4,
- control_main_flag_return_e = 0x8,
- control_main_flag_version_e = 0x10,
- control_main_flag_version_copyright_help_e = 0x13,
- }; // enum
-#endif // _di_control_main_flag_e_
-
-/**
- * The main program parameters.
- */
-#ifndef _di_control_parameter_d_
- enum {
- control_parameter_name_e = f_console_standard_parameter_last_e,
- control_parameter_return_e,
- control_parameter_settings_e,
- control_parameter_socket_e,
- }; // enum
-
- #define control_console_parameter_t_initialize \
- { \
- macro_fll_program_console_parameter_standard_initialize, \
- \
- macro_f_console_parameter_t_initialize_3(control_short_name_s, control_long_name_s, 1, f_console_flag_normal_e), \
- macro_f_console_parameter_t_initialize_3(control_short_return_s, control_long_return_s, 1, f_console_flag_normal_e), \
- macro_f_console_parameter_t_initialize_3(control_short_settings_s, control_long_settings_s, 1, f_console_flag_normal_e), \
- macro_f_console_parameter_t_initialize_3(control_short_socket_s, control_long_socket_s, 1, f_console_flag_normal_e), \
- }
-
- #define control_parameter_total_d (f_console_parameter_state_type_total_d + 4)
-#endif // _di_control_parameter_d_
-
-/**
- * Flags for fine-tuned print control.
- *
- * control_print_flag_*_e:
- * - none: No flags set.
- * - debug: Stream is for debug printing.
- * - error: Stream is for error printing.
- * - in: Stream is a source file.
- * - message: Stream is for message printing.
- * - out: Stream is a destination file.
- * - warning: Stream is for warning printing.
- */
-#ifndef _di_control_print_flag_e_
- enum {
- control_print_flag_none_e = 0x0,
- control_print_flag_debug_e = 0x1,
- control_print_flag_error_e = 0x2,
- control_print_flag_file_e = 0x4,
- control_print_flag_in_e = 0x8,
- control_print_flag_out_e = 0x10,
- control_print_flag_message_e = 0x20,
- control_print_flag_warning_e = 0x40,
- }; // enum
-#endif // _di_control_print_flag_e_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_common_enumeration_h
+++ /dev/null
-#include "../control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_control_f_a_
- const f_string_t control_f_a[] = {
- "control_packet_build",
- "control_packet_process",
- "control_packet_receive",
- "control_packet_send",
- "f_console_parameter_process",
- "f_file_exists",
- "f_file_stream_open",
- "f_file_stream_read",
- "f_fss_apply_delimit",
- "f_memory_array_increase_by",
- "f_memory_array_resize",
- "f_socket_connect",
- "f_socket_create",
- "f_string_dynamic_append",
- "f_string_dynamic_append_assure",
- "f_string_dynamic_partial_append_nulless",
- "f_thread_create",
- "fll_fss_extended_read",
- "fll_program_parameter_process_context_standard",
- "fll_program_parameter_process_verbosity_standard",
- };
-#endif // _di_control_f_a_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the common print functionality.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_common_print_h
-#define _control_common_print_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * A special array of strings intended for representing funciton names.
- *
- * These are primarily used for printing errors with the function names.
- *
- * The macro macro_control_f() is used to reference the array index by the enum name.
- *
- * macro_control_f():
- * - name: The name of the function.
- */
-#ifndef _di_control_f_a_
- extern const f_string_t control_f_a[];
-
- #define macro_control_f(name) control_f_a[control_f_##name##_e]
-#endif // _di_control_f_a_
-
-/**
- * An enum representing specific indexes within the above array.
- *
- * This is a convenience enum used to make code slightly more readable.
- */
-#ifndef _di_control_f_e_
- enum {
- control_f_control_packet_build_e,
- control_f_control_packet_process_e,
- control_f_control_packet_receive_e,
- control_f_control_packet_send_e,
- control_f_f_console_parameter_process_e,
- control_f_f_file_exists_e,
- control_f_f_file_stream_open_e,
- control_f_f_file_stream_read_e,
- control_f_f_fss_apply_delimit_e,
- control_f_f_memory_array_increase_by_e,
- control_f_f_memory_array_resize_e,
- control_f_f_socket_connect_e,
- control_f_f_socket_create_e,
- control_f_f_string_dynamic_append_e,
- control_f_f_string_dynamic_append_assure_e,
- control_f_f_string_dynamic_partial_append_nulless_e,
- control_f_f_thread_create_e,
- control_f_fll_fss_extended_read_e,
- control_f_fll_program_parameter_process_context_standard_e,
- control_f_fll_program_parameter_process_verbosity_standard_e,
- }; // enum
-#endif // _di_control_f_e_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_common_print_h
+++ /dev/null
-#include "../control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_control_program_version_s_
- const f_string_static_t control_program_version_s = macro_f_string_static_t_initialize_1(CONTROL_program_version_s, 0, CONTROL_program_version_s_length);
-#endif // _di_control_program_version_s_
-
-#ifndef _di_control_program_name_s_
- const f_string_static_t control_program_name_s = macro_f_string_static_t_initialize_1(CONTROL_program_name_s, 0, CONTROL_program_name_s_length);
- const f_string_static_t control_program_name_long_s = macro_f_string_static_t_initialize_1(CONTROL_program_name_long_s, 0, CONTROL_program_name_long_s_length);
-#endif // _di_control_program_name_s_
-
-#ifndef _di_control_parameter_s_
- const f_string_static_t control_short_name_s = macro_f_string_static_t_initialize_1(CONTROL_short_name_s, 0, CONTROL_short_name_s_length);
- const f_string_static_t control_short_return_s = macro_f_string_static_t_initialize_1(CONTROL_short_return_s, 0, CONTROL_short_return_s_length);
- const f_string_static_t control_short_settings_s = macro_f_string_static_t_initialize_1(CONTROL_short_settings_s, 0, CONTROL_short_settings_s_length);
- const f_string_static_t control_short_socket_s = macro_f_string_static_t_initialize_1(CONTROL_short_socket_s, 0, CONTROL_short_socket_s_length);
-
- const f_string_static_t control_long_name_s = macro_f_string_static_t_initialize_1(CONTROL_long_name_s, 0, CONTROL_long_name_s_length);
- const f_string_static_t control_long_return_s = macro_f_string_static_t_initialize_1(CONTROL_long_return_s, 0, CONTROL_long_return_s_length);
- const f_string_static_t control_long_settings_s = macro_f_string_static_t_initialize_1(CONTROL_long_settings_s, 0, CONTROL_long_settings_s_length);
- const f_string_static_t control_long_socket_s = macro_f_string_static_t_initialize_1(CONTROL_long_socket_s, 0, CONTROL_long_socket_s_length);
-#endif // _di_control_parameter_s_
-
-#ifndef _di_control_strings_s_
- const f_string_static_t control_path_settings_s = macro_f_string_static_t_initialize_1(CONTROL_path_settings_s, 0, CONTROL_path_settings_s_length);
-
- const f_string_static_t control_action_s = macro_f_string_static_t_initialize_1(CONTROL_action_s, 0, CONTROL_action_s_length);
- const f_string_static_t control_at_s = macro_f_string_static_t_initialize_1(CONTROL_at_s, 0, CONTROL_at_s_length);
- const f_string_static_t control_controller_s = macro_f_string_static_t_initialize_1(CONTROL_controller_s, 0, CONTROL_controller_s_length);
- const f_string_static_t control_default_s = macro_f_string_static_t_initialize_1(CONTROL_default_s, 0, CONTROL_default_s_length);
- const f_string_static_t control_error_s = macro_f_string_static_t_initialize_1(CONTROL_error_s, 0, CONTROL_error_s_length);
- const f_string_static_t control_in_s = macro_f_string_static_t_initialize_1(CONTROL_in_s, 0, CONTROL_in_s_length);
- const f_string_static_t control_init_s = macro_f_string_static_t_initialize_1(CONTROL_init_s, 0, CONTROL_init_s_length);
- const f_string_static_t control_kexec_s = macro_f_string_static_t_initialize_1(CONTROL_kexec_s, 0, CONTROL_kexec_s_length);
- const f_string_static_t control_length_s = macro_f_string_static_t_initialize_1(CONTROL_length_s, 0, CONTROL_length_s_length);
- const f_string_static_t control_name_socket_s = macro_f_string_static_t_initialize_1(CONTROL_name_socket_s, 0, CONTROL_name_socket_s_length);
- const f_string_static_t control_now_s = macro_f_string_static_t_initialize_1(CONTROL_now_s, 0, CONTROL_now_s_length);
- const f_string_static_t control_path_socket_s = macro_f_string_static_t_initialize_1(CONTROL_path_socket_s, 0, CONTROL_path_socket_s_length);
- const f_string_static_t control_path_socket_prefix_s = macro_f_string_static_t_initialize_1(CONTROL_path_socket_prefix_s, 0, CONTROL_path_socket_prefix_s_length);
- const f_string_static_t control_path_socket_suffix_s = macro_f_string_static_t_initialize_1(CONTROL_path_socket_suffix_s, 0, CONTROL_path_socket_suffix_s_length);
- const f_string_static_t control_status_s = macro_f_string_static_t_initialize_1(CONTROL_status_s, 0, CONTROL_status_s_length);
- const f_string_static_t control_type_s = macro_f_string_static_t_initialize_1(CONTROL_type_s, 0, CONTROL_type_s_length);
-
- const f_string_static_t control_freeze_s = macro_f_string_static_t_initialize_1(CONTROL_freeze_s, 0, CONTROL_freeze_s_length);
- const f_string_static_t control_kill_s = macro_f_string_static_t_initialize_1(CONTROL_kill_s, 0, CONTROL_kill_s_length);
- const f_string_static_t control_pause_s = macro_f_string_static_t_initialize_1(CONTROL_pause_s, 0, CONTROL_pause_s_length);
- const f_string_static_t control_reboot_s = macro_f_string_static_t_initialize_1(CONTROL_reboot_s, 0, CONTROL_reboot_s_length);
- const f_string_static_t control_reload_s = macro_f_string_static_t_initialize_1(CONTROL_reload_s, 0, CONTROL_reload_s_length);
- const f_string_static_t control_rerun_s = macro_f_string_static_t_initialize_1(CONTROL_rerun_s, 0, CONTROL_rerun_s_length);
- const f_string_static_t control_restart_s = macro_f_string_static_t_initialize_1(CONTROL_restart_s, 0, CONTROL_restart_s_length);
- const f_string_static_t control_resume_s = macro_f_string_static_t_initialize_1(CONTROL_resume_s, 0, CONTROL_resume_s_length);
- const f_string_static_t control_shutdown_s = macro_f_string_static_t_initialize_1(CONTROL_shutdown_s, 0, CONTROL_shutdown_s_length);
- const f_string_static_t control_start_s = macro_f_string_static_t_initialize_1(CONTROL_start_s, 0, CONTROL_start_s_length);
- const f_string_static_t control_stop_s = macro_f_string_static_t_initialize_1(CONTROL_stop_s, 0, CONTROL_stop_s_length);
- const f_string_static_t control_thaw_s = macro_f_string_static_t_initialize_1(CONTROL_thaw_s, 0, CONTROL_thaw_s_length);
-#endif // _di_control_strings_s_
-
-#ifndef _di_controller_strings_s_
- const f_string_static_t controller_name_socket_s = macro_f_string_static_t_initialize_1(CONTROLLER_name_socket_s, 0, CONTROLLER_name_socket_s_length);
- const f_string_static_t controller_path_socket_s = macro_f_string_static_t_initialize_1(CONTROLLER_path_socket_s, 0, CONTROLLER_path_socket_s_length);
- const f_string_static_t controller_path_socket_prefix_s = macro_f_string_static_t_initialize_1(CONTROLLER_path_socket_prefix_s, 0, CONTROLLER_path_socket_prefix_s_length);
- const f_string_static_t controller_path_socket_suffix_s = macro_f_string_static_t_initialize_1(CONTROLLER_path_socket_suffix_s, 0, CONTROLLER_path_socket_suffix_s_length);
-#endif // _di_controller_strings_s_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the common string structures.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_common_string_h
-#define _control_common_string_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * The program version.
- */
-#ifndef _di_control_program_version_s_
- #define CONTROL_program_version_major_s F_string_ascii_0_s
- #define CONTROL_program_version_minor_s F_string_ascii_7_s
- #define CONTROL_program_version_micro_s F_string_ascii_0_s
-
- #define CONTROL_program_version_major_s_length F_string_ascii_0_s_length
- #define CONTROL_program_version_minor_s_length F_string_ascii_7_s_length
- #define CONTROL_program_version_micro_s_length F_string_ascii_0_s_length
-
- #if !(defined(CONTROL_program_version_nano_prefix_s) && defined(CONTROL_program_version_nano_prefix_s_length))
- #define CONTROL_program_version_nano_prefix_s
- #define CONTROL_program_version_nano_prefix_s_length 0
- #endif // !(defined(CONTROL_program_version_nano_prefix_s) && defined(CONTROL_program_version_nano_prefix_s_length))
-
- #if !(defined(CONTROL_program_version_nano_s) && defined(CONTROL_program_version_nano_s_length))
- #define CONTROL_program_version_nano_s
- #define CONTROL_program_version_nano_s_length 0
- #endif // !(defined(CONTROL_program_version_nano_s) && defined(CONTROL_program_version_nano_s_length))
-
- #define CONTROL_program_version_s CONTROL_program_version_major_s F_string_ascii_period_s CONTROL_program_version_minor_s F_string_ascii_period_s CONTROL_program_version_micro_s CONTROL_program_version_nano_prefix_s CONTROL_program_version_nano_s
-
- #define CONTROL_program_version_s_length CONTROL_program_version_major_s_length + F_string_ascii_period_s_length + CONTROL_program_version_minor_s_length + F_string_ascii_period_s_length + CONTROL_program_version_micro_s_length + CONTROL_program_version_nano_prefix_s_length + CONTROL_program_version_nano_s_length
-
- extern const f_string_static_t control_program_version_s;
-#endif // _di_control_program_version_s_
-
-/**
- * The program name.
- */
-#ifndef _di_control_program_name_s_
- #define CONTROL_program_name_s "control"
- #define CONTROL_program_name_long_s "Control Program"
-
- #define CONTROL_program_name_s_length 7
- #define CONTROL_program_name_long_s_length 15
-
- extern const f_string_static_t control_program_name_s;
- extern const f_string_static_t control_program_name_long_s;
-#endif // _di_control_program_name_s_
-
-/**
- * The main program parameters.
- */
-#ifndef _di_control_parameter_s_
- #define CONTROL_short_name_s "n"
- #define CONTROL_short_return_s "R"
- #define CONTROL_short_settings_s "s"
- #define CONTROL_short_socket_s "k"
-
- #define CONTROL_long_name_s "name"
- #define CONTROL_long_return_s "return"
- #define CONTROL_long_settings_s "settings"
- #define CONTROL_long_socket_s "socket"
-
- #define CONTROL_short_name_s_length 1
- #define CONTROL_short_return_s_length 1
- #define CONTROL_short_settings_s_length 1
- #define CONTROL_short_socket_s_length 1
-
- #define CONTROL_long_name_s_length 4
- #define CONTROL_long_return_s_length 6
- #define CONTROL_long_settings_s_length 8
- #define CONTROL_long_socket_s_length 6
-
- extern const f_string_static_t control_short_name_s;
- extern const f_string_static_t control_short_return_s;
- extern const f_string_static_t control_short_settings_s;
- extern const f_string_static_t control_short_socket_s;
-
- extern const f_string_static_t control_long_name_s;
- extern const f_string_static_t control_long_return_s;
- extern const f_string_static_t control_long_settings_s;
- extern const f_string_static_t control_long_socket_s;
-#endif // _di_control_parameter_s_
-
-/**
- * All special strings used within this program.
- */
-#ifndef _di_control_strings_s_
- #if defined(_override_control_path_settings_) && defined(_override_control_path_settings_length_)
- #define CONTROL_path_settings_s _override_control_path_settings_
-
- #define CONTROL_path_settings_s_length _override_control_path_settings_length_
- #else
- #define CONTROL_path_settings_s "/etc/control/settings"
-
- #define CONTROL_path_settings_s_length 21
- #endif // defined(_override_control_path_settings_) && defined(_override_control_path_settings_length_)
-
- #define CONTROL_action_s "action"
- #define CONTROL_at_s "at"
- #define CONTROL_controller_s "controller"
- #define CONTROL_default_s "default"
- #define CONTROL_error_s "error"
- #define CONTROL_kexec_s "kexec"
- #define CONTROL_in_s "in"
- #define CONTROL_init_s "init"
- #define CONTROL_length_s "length"
- #define CONTROL_name_socket_s "name_socket"
- #define CONTROL_now_s "now"
- #define CONTROL_path_socket_s "path_socket"
- #define CONTROL_path_socket_prefix_s "path_socket_prefix"
- #define CONTROL_path_socket_suffix_s "path_socket_suffix"
- #define CONTROL_status_s "status"
- #define CONTROL_type_s "type"
-
- #define CONTROL_freeze_s "freeze"
- #define CONTROL_kill_s "kill"
- #define CONTROL_pause_s "pause"
- #define CONTROL_reboot_s "reboot"
- #define CONTROL_reload_s "reload"
- #define CONTROL_rerun_s "rerun"
- #define CONTROL_restart_s "restart"
- #define CONTROL_resume_s "resume"
- #define CONTROL_shutdown_s "shutdown"
- #define CONTROL_start_s "start"
- #define CONTROL_stop_s "stop"
- #define CONTROL_thaw_s "thaw"
-
- #define CONTROL_action_s_length 6
- #define CONTROL_at_s_length 2
- #define CONTROL_controller_s_length 10
- #define CONTROL_default_s_length 7
- #define CONTROL_error_s_length 5
- #define CONTROL_in_s_length 2
- #define CONTROL_init_s_length 4
- #define CONTROL_kexec_s_length 5
- #define CONTROL_length_s_length 6
- #define CONTROL_name_socket_s_length 11
- #define CONTROL_now_s_length 3
- #define CONTROL_path_socket_s_length 11
- #define CONTROL_path_socket_prefix_s_length 18
- #define CONTROL_path_socket_suffix_s_length 18
- #define CONTROL_status_s_length 6
- #define CONTROL_type_s_length 4
-
- #define CONTROL_freeze_s_length 6
- #define CONTROL_kill_s_length 4
- #define CONTROL_pause_s_length 5
- #define CONTROL_reboot_s_length 6
- #define CONTROL_reload_s_length 6
- #define CONTROL_rerun_s_length 5
- #define CONTROL_restart_s_length 7
- #define CONTROL_resume_s_length 6
- #define CONTROL_shutdown_s_length 8
- #define CONTROL_start_s_length 5
- #define CONTROL_stop_s_length 4
- #define CONTROL_thaw_s_length 4
-
- extern const f_string_static_t control_path_settings_s;
-
- extern const f_string_static_t control_action_s;
- extern const f_string_static_t control_at_s;
- extern const f_string_static_t control_controller_s;
- extern const f_string_static_t control_default_s;
- extern const f_string_static_t control_error_s;
- extern const f_string_static_t control_in_s;
- extern const f_string_static_t control_init_s;
- extern const f_string_static_t control_kexec_s;
- extern const f_string_static_t control_length_s;
- extern const f_string_static_t control_name_socket_s;
- extern const f_string_static_t control_now_s;
- extern const f_string_static_t control_path_socket_s;
- extern const f_string_static_t control_path_socket_prefix_s;
- extern const f_string_static_t control_path_socket_suffix_s;
- extern const f_string_static_t control_status_s;
- extern const f_string_static_t control_type_s;
-
- extern const f_string_static_t control_freeze_s;
- extern const f_string_static_t control_kill_s;
- extern const f_string_static_t control_pause_s;
- extern const f_string_static_t control_reboot_s;
- extern const f_string_static_t control_reload_s;
- extern const f_string_static_t control_rerun_s;
- extern const f_string_static_t control_restart_s;
- extern const f_string_static_t control_resume_s;
- extern const f_string_static_t control_shutdown_s;
- extern const f_string_static_t control_start_s;
- extern const f_string_static_t control_stop_s;
- extern const f_string_static_t control_thaw_s;
-#endif // _di_control_strings_s_
-
-/**
- * Controller defines that the control program utilizes.
- *
- * These are intended to exactly match the relevant controller string defines.
- */
-#ifndef _di_controller_strings_s_
-
- // The name_socket is a system-specific path and should match the path compiled into the controller program.
- #if defined(_override_controller_name_socket_) && defined(_override_controller_name_socket_length_)
- #define CONTROLLER_name_socket_s _override_controller_name_socket_
-
- #define CONTROLLER_name_socket_s_length _override_controller_name_socket_length_
- #else
- #define CONTROLLER_name_socket_s "default"
-
- #define CONTROLLER_name_socket_s_length 7
- #endif // defined(_override_controller_name_socket_) && defined(_override_controller_name_socket_length_)
-
- // The path_socket is a system-specific path and should match the path compiled into the controller program.
- #if defined(_override_controller_path_socket_) && defined(_override_controller_path_socket_length_)
- #define CONTROLLER_path_socket_s _override_controller_path_socket_
-
- #define CONTROLLER_path_socket_s_length _override_controller_path_socket_length_
- #elif defined(_controller_as_init_)
- #define CONTROLLER_path_socket_s "/var/run/init"
-
- #define CONTROLLER_path_socket_s_length 13
- #else
- #define CONTROLLER_path_socket_s "/var/run/controller"
-
- #define CONTROLLER_path_socket_s_length 19
- #endif // defined(_override_controller_path_socket_) && defined(_override_controller_path_socket_length_)
-
- // The name_socket_prefix is a system-specific path and should match the path compiled into the controller program.
- #if defined(_override_controller_path_socket_prefix_) && defined(_override_controller_path_socket_prefix_length_)
- #define CONTROLLER_path_socket_prefix_s _override_controller_path_socket_prefix_
-
- #define CONTROLLER_path_socket_prefix_s_length _override_controller_path_socket_prefix_length_
- #elif defined(_controller_as_init_)
- #define CONTROLLER_path_socket_prefix_s "init-"
-
- #define CONTROLLER_path_socket_prefix_s_length 5
- #else
- #define CONTROLLER_path_socket_prefix_s ""
-
- #define CONTROLLER_path_socket_prefix_s_length 0
- #endif // defined(_override_controller_name_socket_prefix_) && defined(_override_controller_name_socket_prefix_length_)
-
- // The name_socket_suffix is a system-specific path and should match the path compiled into the controller program.
- #if defined(_override_controller_path_socket_suffix_) && defined(_override_controller_path_socket_suffix_length_)
- #define CONTROLLER_path_socket_suffix_s _override_controller_path_socket_suffix_
-
- #define CONTROLLER_path_socket_suffix_s_length _override_controller_path_socket_suffix_length_
- #else
- #define CONTROLLER_path_socket_suffix_s ".socket"
-
- #define CONTROLLER_path_socket_suffix_s_length 7
- #endif // defined(_override_controller_name_socket_suffix_) && defined(_override_controller_name_socket_suffix_length_)
-
- extern const f_string_static_t controller_name_socket_s;
- extern const f_string_static_t controller_path_socket_s;
- extern const f_string_static_t controller_path_socket_prefix_s;
- extern const f_string_static_t controller_path_socket_suffix_s;
-#endif // _di_controller_strings_s_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_common_string_h
+++ /dev/null
-#include "../control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_control_main_delete_
- void control_main_delete(control_main_t * const main) {
-
- if (!main) return;
-
- fll_program_data_delete(&main->program);
- control_setting_delete(&main->setting);
-
- f_memory_array_resize(0, sizeof(f_char_t), (void **) &main->cache.large.string, &main->cache.large.used, &main->cache.large.size);
- f_memory_array_resize(0, sizeof(f_char_t), (void **) &main->cache.small.string, &main->cache.small.used, &main->cache.small.size);
- f_memory_array_resize(0, sizeof(f_char_t), (void **) &main->cache.packet.string, &main->cache.packet.used, &main->cache.packet.size);
-
- f_memory_array_resize(0, sizeof(f_range_t), (void **) &main->cache.objects.array, &main->cache.objects.used, &main->cache.objects.size);
- f_memory_arrays_resize(0, sizeof(f_ranges_t), (void **) &main->cache.contents.array, &main->cache.contents.used, &main->cache.contents.size, &f_rangess_delete_callback);
-
- f_memory_array_resize(0, sizeof(f_range_t), (void **) &main->cache.packet_objects.array, &main->cache.packet_objects.used, &main->cache.packet_objects.size);
- f_memory_arrays_resize(0, sizeof(f_ranges_t), (void **) &main->cache.packet_contents.array, &main->cache.packet_contents.used, &main->cache.packet_contents.size, &f_rangess_delete_callback);
-
- f_memory_array_resize(0, sizeof(f_range_t), (void **) &main->cache.header_objects.array, &main->cache.header_objects.used, &main->cache.header_objects.size);
- f_memory_arrays_resize(0, sizeof(f_ranges_t), (void **) &main->cache.header_contents.array, &main->cache.header_contents.used, &main->cache.header_contents.size, &f_rangess_delete_callback);
-
- f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &main->cache.delimits.array, &main->cache.delimits.used, &main->cache.delimits.size);
- }
-#endif // _di_control_main_delete_
-
-#ifndef _di_control_setting_delete_
- void control_setting_delete(control_setting_t * const setting) {
-
- if (!setting) return;
-
- f_memory_array_resize(0, sizeof(f_char_t), (void **) &setting->name_socket.string, &setting->name_socket.used, &setting->name_socket.size);
- f_memory_array_resize(0, sizeof(f_char_t), (void **) &setting->path_settings.string, &setting->path_settings.used, &setting->path_settings.size);
- f_memory_array_resize(0, sizeof(f_char_t), (void **) &setting->path_socket.string, &setting->path_socket.used, &setting->path_socket.size);
-
- f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &setting->actions.array, &setting->actions.used, &setting->actions.size, &f_string_dynamics_delete_callback);
- }
-#endif // _di_control_setting_delete_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the common type structures.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_common_type_h
-#define _control_common_type_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * The control cache.
- *
- * large: A buffer for storing large sets of data.
- * small: A buffer for storing small sets of data.
- * packet: A buffer for storing the send packet or the response payload.
- *
- * objects: An array of ranges representing objects.
- * contents: An array of ranges representing contents.
- * delimits: An array of ranges representing delimits.
- *
- * packet_objects: The FSS Objects for a packet.
- * packet_contents: The FSS Contents for a packet.
- *
- * header_objects: The FSS Objects for a packet payload header.
- * header_contents: The FSS Contents for a packet payload header.
- *
- * delimits: The delimits cache.
- */
-#ifndef _di_control_cache_t_
- typedef struct {
- f_string_dynamic_t large;
- f_string_dynamic_t small;
- f_string_dynamic_t packet;
-
- f_ranges_t objects;
- f_rangess_t contents;
- f_number_unsigneds_t delimits;
-
- f_ranges_t packet_objects;
- f_rangess_t packet_contents;
-
- f_ranges_t header_objects;
- f_rangess_t header_contents;
- } control_cache_t;
-
- #define control_cache_t_initialize \
- { \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_ranges_t_initialize, \
- f_rangess_t_initialize, \
- f_number_unsigneds_t_initialize, \
- f_ranges_t_initialize, \
- f_rangess_t_initialize, \
- f_ranges_t_initialize, \
- f_rangess_t_initialize, \
- }
-#endif // _di_control_cache_t_
-
-/**
- * The packet payload header data.
- *
- * The FSS-000E (Payload) supports multiple objects, but the Control packet does not support this, yet.
- *
- * action: The action type code, for any valid action (see: control_action_types enumeration).
- * type: The packet type represented by the payload packet.
- * status: The status code represented by the payload packet.
- * length: The length of the payload content within the payload packet.
- */
-#ifndef _di_control_payload_header_t_
- typedef struct {
- uint8_t action;
- uint8_t type;
- f_status_t status;
- uint16_t length;
- } control_payload_header_t;
-
- #define control_payload_header_t_initialize \
- { \
- 0, \
- 0, \
- f_status_t_initialize, \
- f_number_unsigned_t_initialize, \
- }
-#endif // _di_control_payload_header_t_
-
-/**
- * The control main program settings.
- *
- * This is passed to the program-specific main entry point to designate program settings.
- * These program settings are often processed from the program arguments (often called the command line arguments).
- *
- * Properties:
- * - flag: Flags passed to the main function.
- * - action: The action type code.
- * - size_write: The write size of a packet request or response.
- *
- * - status_signal: A status used eclusively by the threaded signal handler.
- * - state: The state data used when processing the data.
- *
- * - range: A range for any particular use.
- * - socket: A socket used to connect to the controller.
- *
- * - name_socket: The name of the socket file.
- * - path_settings: The path to the settings file.
- * - path_socket: The path to the socket file.
- * - actions: The requested actions.
- */
-#ifndef _di_control_setting_t_
- typedef struct {
- uint16_t flag;
- uint8_t action;
- f_number_unsigned_t size_write;
-
- f_status_t status_signal;
- f_state_t state;
-
- f_range_t range;
- f_socket_t socket;
-
- f_string_dynamic_t name_socket;
- f_string_dynamic_t path_settings;
- f_string_dynamic_t path_socket;
- f_string_dynamics_t actions;
- } control_setting_t;
-
- #define control_setting_t_initialize \
- { \
- control_main_flag_none_e, \
- 0, \
- 0, \
- F_okay, \
- f_state_t_initialize, \
- f_range_t_initialize, \
- f_socket_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamic_t_initialize, \
- f_string_dynamics_t_initialize, \
- }
-#endif // _di_control_setting_t_
-
-/**
- * The main program data as a single structure.
- *
- * Properties:
- * - program: The main program data.
- * - setting: The settings data.
- * - cache: The cache data.
- */
-#ifndef _di_control_main_t_
- typedef struct {
- fll_program_data_t program;
- control_setting_t setting;
- control_cache_t cache;
- } control_main_t;
-
- #define control_main_t_initialize \
- { \
- fll_program_data_t_initialize, \
- control_setting_t_initialize, \
- control_cache_t_initialize, \
- }
-#endif // _di_control_main_t_
-
-/**
- * Deallocate main program data.
- *
- * @param main
- * The main program data.
- *
- * Must not be NULL.
- *
- * This does not alter main.setting.state.status.
- *
- * @see f_memory_array_resize()
- * @see f_memory_arrays_resize()
- * @see fll_program_data_delete()
- * @see control_setting_delete()
- */
-#ifndef _di_control_main_delete_
- extern void control_main_delete(control_main_t * const main);
-#endif // _di_control_main_delete_
-
-/**
- * Delete the program main setting data.
- *
- * @param setting
- * The program main setting data.
- *
- * Must not be NULL.
- *
- * This does not alter setting.state.status.
- *
- * @see f_memory_array_resize()
- * @see f_memory_arrays_resize()
- */
-#ifndef _di_control_setting_delete_
- extern void control_setting_delete(control_setting_t * const setting);
-#endif // _di_control_setting_delete_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_common_type_h
+++ /dev/null
-#include "control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_control_main_
- void control_main(control_main_t * const main) {
-
- if (!main) return;
- if (F_status_is_error(main->setting.state.status)) return;
-
- main->setting.state.status = F_okay;
-
- if (main->setting.flag & control_main_flag_version_copyright_help_e) {
- if (main->setting.flag & control_main_flag_help_e) {
- control_print_message_help(&main->program.message);
- }
- else if (main->setting.flag & control_main_flag_version_e) {
- fll_program_print_version(&main->program.message, control_program_version_s);
- }
- else if (main->setting.flag & control_main_flag_copyright_e) {
- fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s);
- }
-
- return;
- }
-
- if (main->setting.flag & control_main_flag_pipe_e) {
- control_print_error_pipe_supported_not(&main->program.error);
-
- main->setting.state.status = F_status_set_error(F_support_not);
- }
- else if (main->setting.actions.used) {
- main->setting.action = control_action_type_identify(main->setting.actions.array[0]);
-
- if (main->setting.action) {
- control_action_verify(main);
- }
- else {
- control_print_error_parameter_action_not(&main->program.error, main->setting.actions.array[0]);
-
- main->setting.state.status = F_status_set_error(F_parameter);
- }
-
- if (F_status_is_error_not(main->setting.state.status)) {
- control_packet_build(main);
-
- if (F_status_is_error(main->setting.state.status)) {
- if (F_status_set_fine(main->setting.state.status) == F_too_large) {
- control_print_error_request_packet_too_large(&main->program.error);
- }
- else {
- control_print_error(&main->program.error, macro_control_f(control_packet_build));
- }
- }
-
- if (F_status_is_error_not(main->setting.state.status)) {
- control_packet_send(main);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_error(&main->program.error, macro_control_f(control_packet_send));
- }
- }
-
- if (F_status_is_error_not(main->setting.state.status)) {
- control_payload_header_t header = control_payload_header_t_initialize;
-
- control_packet_receive(main, &header);
-
- if (F_status_is_error(main->setting.state.status)) {
- if (F_status_set_fine(main->setting.state.status) == F_too_large) {
- control_print_error_response_packet_valid_not(&main->program.error);
- }
- else {
- control_print_error(&main->program.error, macro_control_f(control_packet_receive));
- }
- }
- else {
- control_packet_process(main, &header);
-
- // Print the error message only if the error message is not already printed.
- if (F_status_is_error(main->setting.state.status)) {
- if (header.type != control_payload_type_error_e && (header.type != control_payload_type_controller_e || F_status_set_fine(main->setting.state.status) != header.status || (header.status != F_failure && header.status != F_busy))) {
- control_print_error(&main->program.error, macro_control_f(control_packet_process));
- }
- }
- }
- }
- }
-
- if (main->setting.socket.id != -1) {
- f_socket_disconnect(&main->setting.socket, f_socket_close_fast_e);
- }
- }
- else {
- control_print_error_parameter_actions_none(&main->program.error);
-
- main->setting.state.status = F_status_set_error(F_data_not);
- }
-
- if (F_status_is_error(main->setting.state.status)) return;
-
- main->setting.state.status = F_okay;
- }
-#endif // _di_control_main_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- */
-#ifndef _control_h
-#define _control_h
-
-// Libc includes.
-#include <unistd.h>
-
-// FLL-0 includes.
-#include <fll/level_0/type.h>
-#include <fll/level_0/status.h>
-#include <fll/level_0/memory.h>
-#include <fll/level_0/string.h>
-#include <fll/level_0/utf.h>
-#include <fll/level_0/color.h>
-#include <fll/level_0/compare.h>
-#include <fll/level_0/console.h>
-#include <fll/level_0/conversion.h>
-#include <fll/level_0/directory.h>
-#include <fll/level_0/file.h>
-#include <fll/level_0/fss.h>
-#include <fll/level_0/path.h>
-#include <fll/level_0/pipe.h>
-#include <fll/level_0/print.h>
-#include <fll/level_0/rip.h>
-#include <fll/level_0/signal.h>
-#include <fll/level_0/socket.h>
-#include <fll/level_0/thread.h>
-#include <fll/level_0/status_string.h>
-
-// FLL-1 includes.
-#include <fll/level_1/conversion.h>
-#include <fll/level_1/fss.h>
-#include <fll/level_1/print.h>
-#include <fll/level_1/status_string.h>
-
-// FLL-2 includes.
-#include <fll/level_2/error.h>
-#include <fll/level_2/fss/basic_list.h>
-#include <fll/level_2/fss/extended.h>
-#include <fll/level_2/fss/payload.h>
-#include <fll/level_2/print.h>
-#include <fll/level_2/program.h>
-
-// Control includes.
-#include <program/control/main/common/define.h>
-#include <program/control/main/common/enumeration.h>
-#include <program/control/main/common/print.h>
-#include <program/control/main/common/string.h>
-#include <program/control/main/common/type.h>
-#include <program/control/main/common.h>
-#include <program/control/main/print/data.h>
-#include <program/control/main/print/debug.h>
-#include <program/control/main/print/error.h>
-#include <program/control/main/print/message.h>
-#include <program/control/main/print/warning.h>
-#include <program/control/main/action.h>
-#include <program/control/main/packet.h>
-#include <program/control/main/payload.h>
-#include <program/control/main/signal.h>
-#include <program/control/main/thread.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Execute main program.
- *
- * If main.signal is non-zero, then this blocks and handles the following signals:
- * - F_signal_abort
- * - F_signal_broken_pipe
- * - F_signal_hangup
- * - F_signal_interrupt
- * - F_signal_quit
- * - F_signal_termination
- *
- * @param main
- * The main program data and settings.
- *
- * This alters main.setting.state.status:
- * F_okay on success.
- * F_true on success when performing verification and verify passed.
- * F_false on success when performing verification and verify failed.
- *
- * F_interrupt (with error bit) on (exit) signal received.
- * F_parameter (with error bit) if main is NULL or setting is NULL.
- */
-#ifndef _di_control_main_
- extern void control_main(control_main_t * const main);
-#endif // _di_control_main_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_h
+++ /dev/null
-#include "control.h"
-
-int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
-
- control_main_t data = control_main_t_initialize;
-
- data.program.debug.flag |= control_print_flag_debug_e | control_print_flag_out_e;
- data.program.error.flag |= control_print_flag_error_e | control_print_flag_out_e;
- data.program.output.flag |= control_print_flag_out_e;
- data.program.message.flag |= control_print_flag_message_e | control_print_flag_out_e;
- data.program.warning.flag |= control_print_flag_warning_e | control_print_flag_out_e;
- data.program.error.custom = (void *) &data;
- data.program.debug.custom = (void *) &data;
- data.program.message.custom = (void *) &data;
- data.program.output.custom = (void *) &data;
- data.program.warning.custom = (void *) &data;
-
- f_console_parameter_t parameters[] = control_console_parameter_t_initialize;
-
- data.program.parameters.array = parameters;
- data.program.parameters.used = control_parameter_total_d;
- data.program.environment = envp;
-
- data.setting.socket.domain = f_socket_protocol_family_local_e;
- data.setting.socket.type = f_socket_type_stream_e;
- data.setting.socket.length = sizeof(struct sockaddr_un);
-
- if (f_pipe_input_exists()) {
- data.program.pipe = fll_program_data_pipe_input_e;
- }
-
- fll_program_standard_set_up(&data.program);
-
- f_file_umask_get(&data.program.umask);
-
- #ifdef _di_thread_support_
- {
- const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp);
-
- control_setting_load(arguments, &data);
- }
-
- control_main(&data);
- #else
- {
- f_thread_id_t id_signal;
-
- memset(&id_signal, 0, sizeof(f_thread_id_t));
-
- data.setting.state.status = f_thread_create(0, &id_signal, &control_thread_signal, (void *) &data);
-
- if (F_status_is_error(data.setting.state.status)) {
- control_print_error(&data.program.error, macro_control_f(f_thread_create));
- }
- else {
- {
- const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp);
-
- control_setting_load(arguments, &data);
- }
-
- if (!control_signal_check(&data)) {
- control_main(&data);
- }
-
- f_thread_cancel(id_signal);
- f_thread_join(id_signal, 0);
- }
- }
- #endif // _di_thread_support_
-
- control_main_delete(&data);
-
- fll_program_standard_set_down(&data.program);
-
- return (F_status_is_error(data.setting.state.status) || data.setting.state.status == F_false) ? 1 : 0;
-}
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * This file is only ever included by main/main.c and should not normally be included anywhere else.
- * Anything that wants to include this should be providing the "control" program functionality in some manner.
- */
-#ifndef _control_main_h
-#define _control_main_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Standard program entry point.
- *
- * @param argc
- * The number of arguments.
- * @param argv
- * The array of arguments.
- * @param envp
- * The array of all environment variables on program start.
- *
- * @return
- * 0 on success.
- * 1 on error.
- */
-extern int main(const int argc, const f_string_t *argv, const f_string_t *envp);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_main_h
+++ /dev/null
-#include "control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_control_packet_build_
- void control_packet_build(control_main_t * const main) {
-
- if (!main) return;
-
- main->cache.packet.used = 0;
- main->cache.large.used = 0;
- main->cache.small.used = 0;
-
- f_number_unsigned_t i = 0;
-
- {
- f_number_unsigned_t length = 5 + f_fss_header_s.used + f_fss_payload_s.used;
- length += control_action_s.used + control_length_s.used + control_type_s.used;
- length += (f_fss_payload_list_open_s.used + f_fss_payload_list_close_s.used) * 2;
- length += (f_fss_payload_header_open_s.used + f_fss_payload_header_close_s.used) * 3;
- length += main->setting.actions.array[0].used + f_string_ascii_0_s.used;
-
- // @todo This should properly handle escaping the FSS-0001 (Extended) Content and then count that length.
- for (i = 1; i < main->setting.actions.used; ++i) {
- length += f_fss_payload_header_next_s.used + main->setting.actions.array[i].used;
- } // for
-
- if (main->setting.action == control_action_type_kexec_e || main->setting.action == control_action_type_reboot_e || main->setting.action == control_action_type_shutdown_e) {
- length += control_init_s.used;
- }
- else {
- length += control_controller_s.used;
- }
-
- if (length > 0xffffffffu) {
- main->setting.state.status = F_status_set_error(F_too_large);
-
- return;
- }
-
- main->setting.state.status = f_memory_array_resize(length, sizeof(f_char_t), (void **) &main->cache.packet.string, &main->cache.packet.used, &main->cache.packet.size);
- if (F_status_is_error(main->setting.state.status)) return;
- }
-
- f_state_t state = macro_f_state_t_initialize_1(control_allocation_large_d, control_allocation_small_d, F_okay, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0);
-
- f_string_static_t contents_array[main->setting.actions.used];
- f_string_statics_t contents = macro_f_string_statics_t_initialize_1(contents_array, 0, main->setting.actions.used);
-
- // The Packet Control Block.
- {
- f_char_t block_control = (f_char_t) control_packet_flag_binary_d;
-
- #ifdef _is_F_endian_big
- block_control |= (f_char_t) control_packet_flag_endian_big_d;
- #endif // _is_F_endian_big
-
- main->setting.state.status = f_string_append(&block_control, 1, &main->cache.packet);
- if (F_status_is_error(main->setting.state.status)) return;
- }
-
- // Reserve the Packet Size Block to be calculated later.
- main->cache.packet.used = 5;
-
- // Payload Header: type.
- if (main->setting.action == control_action_type_kexec_e || main->setting.action == control_action_type_reboot_e || main->setting.action == control_action_type_shutdown_e) {
- contents_array[0] = control_init_s;
- }
- else {
- contents_array[0] = control_controller_s;
- }
-
- contents.used = 1;
-
- fll_fss_extended_write(control_type_s, contents, 0, &main->cache.large, &state);
-
- // Payload Header: action.
- if (F_status_is_error_not(state.status)) {
- for (contents.used = 0; contents.used < main->setting.actions.used; ++contents.used) {
- contents_array[contents.used] = main->setting.actions.array[contents.used];
- } // for
-
- fll_fss_extended_write(control_action_s, contents, 0, &main->cache.large, &state);
- }
-
- // Payload Header: length.
- if (F_status_is_error_not(state.status)) {
- contents_array[0] = f_string_ascii_0_s;
- contents.used = 1;
-
- fll_fss_extended_write(control_length_s, contents, 0, &main->cache.large, &state);
- }
-
- // Payload Packet: Header.
- if (F_status_is_error_not(state.status)) {
- fll_fss_payload_write(f_fss_header_s, main->cache.large, F_false, 0, &main->cache.packet, &state);
- }
-
- // Payload Packet: Payload.
- if (F_status_is_error_not(state.status)) {
- main->cache.large.used = 0;
-
- fll_fss_payload_write(f_fss_payload_s, main->cache.large, F_false, 0, &main->cache.packet, &state);
- }
-
- if (F_status_is_error(state.status)) {
- main->setting.state.status = state.status;
-
- return;
- }
-
- // Construct Packet Size Block.
- #ifdef _is_F_endian_big
- main->cache.packet.string[1] = main->cache.packet.used & 0xffu;
- main->cache.packet.string[2] = main->cache.packet.used & 0xff00u;
- main->cache.packet.string[3] = main->cache.packet.used & 0xff0000u;
- main->cache.packet.string[4] = main->cache.packet.used & 0xff000000u;
- #else
- main->cache.packet.string[1] = main->cache.packet.used & 0xff000000u;
- main->cache.packet.string[2] = main->cache.packet.used & 0xff0000u;
- main->cache.packet.string[3] = main->cache.packet.used & 0xff00u;
- main->cache.packet.string[4] = main->cache.packet.used & 0xffu;
- #endif // _is_F_endian_big
-
- main->setting.state.status = F_okay;
- }
-#endif // _di_control_packet_build_
-
-#ifndef _di_control_packet_header_flag_
- uint8_t control_packet_header_flag(const uint8_t buffer[]) {
- return (uint8_t) (((buffer[0] & 0x8u) ? control_packet_flag_binary_d : 0) | ((buffer[0] & 0x4u) ? control_packet_flag_endian_big_d : 0));
- }
-#endif // _di_control_packet_header_flag_
-
-#ifndef _di_control_packet_header_length_
- uint32_t control_packet_header_length(const bool is_big, const uint8_t buffer[]) {
-
- #ifdef _is_F_endian_big
- if (is_big) return (buffer[1] << 24u) | (buffer[2] << 16u) | (buffer[3] << 8u) | buffer[4];
- #else
- if (!is_big) return (buffer[1] << 24u) | (buffer[2] << 16u) | (buffer[3] << 8u) | buffer[4];
- #endif // _is_F_endian_big
-
- return (buffer[4] << 24u) | (buffer[3] << 16u) | (buffer[2] << 8u) | buffer[1];
- }
-#endif // _di_control_packet_header_length_
-
-#ifndef _di_control_packet_receive_
- void control_packet_receive(control_main_t * const main, control_payload_header_t * const header) {
-
- if (!main || !header) return;
-
- main->cache.large.used = 0;
- main->cache.small.used = 0;
- main->cache.packet.used = 0;
- main->cache.packet_objects.used = 0;
- main->cache.packet_contents.used = 0;
- main->cache.header_objects.used = 0;
- main->cache.header_contents.used = 0;
- main->cache.delimits.used = 0;
-
- header->action = 0;
- header->type = 0;
- header->status = F_okay;
- header->length = 0;
-
- f_number_unsigned_t i = 0;
- f_range_t range_header = f_range_t_initialize;
-
- {
- f_number_unsigned_t length = 5;
- uint8_t head[length];
-
- memset(head, 0, sizeof(uint8_t) * length);
-
- main->setting.state.status = f_socket_read(&main->setting.socket, f_socket_flag_peek_e, (void *) head, &length);
- if (F_status_is_error(main->setting.state.status)) return;
-
- if (length < 5) {
- main->setting.state.status = F_status_set_error(F_packet_not);
-
- return;
- }
-
- // Only the first two bits of the 8 Control bits are allowed to be set to 1 for this Packet.
- if (head[0] & (~(control_packet_flag_binary_d | control_packet_flag_endian_big_d))) {
- main->setting.state.status = F_status_set_error(F_packet_not);
-
- return;
- }
-
- length = control_packet_header_length(head[0] & control_packet_flag_endian_big_d, head);
-
- if (length > 0xffffffffu) {
- main->setting.state.status = F_status_set_error(F_too_large);
-
- return;
- }
-
- main->setting.state.status = f_memory_array_increase_by(length, sizeof(f_char_t), (void **) &main->cache.large.string, &main->cache.large.used, &main->cache.large.size);
- if (F_status_is_error(main->setting.state.status)) return;
-
- main->setting.state.status = f_socket_read(&main->setting.socket, f_socket_flag_wait_all_e, (void *) head, &length);
- if (F_status_is_error(main->setting.state.status)) return;
-
- if (length < main->cache.large.used) {
- main->setting.state.status = F_status_set_error(F_too_small);
-
- return;
- }
-
- if (length > main->cache.large.used) {
- main->setting.state.status = F_status_set_error(F_too_large);
-
- return;
- }
- }
-
- {
- f_state_t state = macro_f_state_t_initialize_1(control_allocation_large_d, control_allocation_small_d, F_okay, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0);
- f_range_t range_packet = macro_f_range_t_initialize_2(main->cache.large.used);
-
- fll_fss_basic_list_read(main->cache.large, &range_packet, &main->cache.packet_objects, &main->cache.packet_contents, &main->cache.delimits, 0, 0, &state);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_debug_packet_message(&main->program.debug, "Failure while reading FSS Basic List in the response packet", 0, 0);
-
- if (F_status_set_fine(main->setting.state.status) == F_memory_not) return;
-
- main->setting.state.status = F_status_set_error(F_header);
-
- return;
- }
-
- f_fss_apply_delimit(main->cache.delimits, &main->cache.large, &state);
-
- if (F_status_is_error(state.status)) {
- main->setting.state.status = state.status;
-
- control_print_debug_packet_message(&main->program.debug, "Failure while processing delimits for the FSS Basic List in the response packet", 0, 0);
-
- main->setting.state.status = F_status_set_error(F_header);
-
- return;
- }
-
- main->cache.delimits.used = 0;
-
- {
- f_ranges_t *content_header = 0;
- f_ranges_t *content_payload = 0;
-
- for (; i < main->cache.packet_objects.used; ++i) {
-
- if (f_compare_dynamic_partial_string(f_fss_header_s.string, main->cache.large, f_fss_header_s.used, main->cache.packet_objects.array[i]) == F_equal_to) {
-
- // The FSS-000E (Payload) standard does not prohibit multiple "header", but such cases are not supported by the controller and the control programs.
- if (content_header) {
- control_print_debug_packet_message(&main->program.debug, "Multiple %[" F_fss_header_s "%] found in response packet", 0, 0);
-
- main->setting.state.status = F_status_set_error(F_payload_not);
-
- return;
- }
-
- content_header = &main->cache.packet_contents.array[i];
- }
- else if (f_compare_dynamic_partial_string(f_fss_payload_s.string, main->cache.large, f_fss_payload_s.used, main->cache.packet_objects.array[i]) == F_equal_to) {
-
- // Only a single "payload" is supported by the FSS-000E (Payload) standard.
- if (content_payload) {
- control_print_debug_packet_message(&main->program.debug, "Multiple %[" F_fss_payload_s "%] found in response packet", 0, 0);
-
- main->setting.state.status = F_status_set_error(F_payload_not);
-
- return;
- }
-
- if (i + 1 < main->cache.packet_contents.used) {
- control_print_debug_packet_message(&main->program.debug, "Invalid FSS Payload format, the %[" F_fss_payload_s "%] is required to be the last FSS Basic List Object", 0, 0);
-
- main->setting.state.status = F_status_set_error(F_payload_not);
-
- return;
- }
-
- content_payload = &main->cache.packet_contents.array[i];
- }
- } // for
-
- if (!content_header) {
- control_print_debug_packet_message(&main->program.debug, "Did not find a %[" F_fss_header_s "%] in the response packet", 0, 0);
-
- main->setting.state.status = F_status_set_error(F_payload_not);
-
- return;
- }
-
- if (!content_payload) {
- control_print_debug_packet_message(&main->program.debug, "Did not find a %[" F_fss_payload_s "%] in the response packet", 0, 0);
-
- main->setting.state.status = F_status_set_error(F_payload_not);
-
- return;
- }
-
- range_header = content_header->array[0];
- }
-
- {
- // 0x1 = found action, 0x2 = found length, 0x4 = found status, 0x8 = found_type.
- uint8_t found = 0;
- f_number_unsigned_t number = 0;
- f_range_t range = range_header;
-
- fll_fss_extended_read(main->cache.large, &range, &main->cache.header_objects, &main->cache.header_contents, 0, 0, &main->cache.delimits, 0, &state);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_debug_packet_message(&main->program.debug, "Failure while reading FSS Extended in the response packet", 0, 0);
-
- if (F_status_set_fine(main->setting.state.status) == F_memory_not) return;
-
- main->setting.state.status = F_status_set_error(F_header_not);
-
- return;
- }
-
- f_fss_apply_delimit(main->cache.delimits, &main->cache.large, &state);
-
- if (F_status_is_error(state.status)) {
- main->setting.state.status = state.status;
-
- control_print_debug_packet_message(&main->program.debug, "Failure while processing delimits for the FSS Basic List in the response packet", 0, 0);
-
- main->setting.state.status = F_status_set_error(F_header_not);
-
- return;
- }
-
- if (!main->cache.header_contents.used) {
- control_print_debug_packet_message(&main->program.debug, "Did not find any Content within the %[" F_fss_header_s "%]", 0, 0);
-
- main->setting.state.status = F_status_set_error(F_header_not);
-
- return;
- }
-
- for (i = 0; i < main->cache.header_objects.used; ++i) {
-
- if (f_compare_dynamic_partial_string(control_action_s.string, main->cache.large, control_action_s.used, main->cache.header_objects.array[i]) == F_equal_to) {
- if (!(found & 0x1)) {
- const f_number_unsigned_t action_length = (main->cache.header_contents.array[i].array[0].stop - main->cache.header_contents.array[i].array[0].start) + 1;
- char action_string[action_length + 1];
- const f_string_static_t action = macro_f_string_static_t_initialize_1(action_string, 0, action_length);
-
- memcpy(action_string, main->cache.large.string + main->cache.header_contents.array[i].array[0].start, action_length);
- action_string[action_length] = 0;
-
- found |= 0x1;
-
- control_print_debug_packet_header_object_and_content(&main->program.debug, control_action_s, main->cache.large, main->cache.header_contents.array[i].array[0]);
-
- header->action = control_action_type_identify(action);
-
- if (!header->action) {
- control_print_debug_packet_message(&main->program.debug, "Failed to identify %[" CONTROL_action_s "%] from: ", &main->cache.large, &main->cache.header_contents.array[i].array[0]);
-
- main->setting.state.status = F_status_set_error(F_header_not);
-
- return;
- }
- }
- else {
- control_print_warning_packet_header_duplicate_object(&main->program.warning, control_action_s);
- }
- }
- else if (f_compare_dynamic_partial_string(control_length_s.string, main->cache.large, control_length_s.used, main->cache.header_objects.array[i]) == F_equal_to) {
- if (!(found & 0x2)) {
- found |= 0x2;
- number = 0;
-
- control_print_debug_packet_header_object_and_content(&main->program.debug, control_length_s, main->cache.large, main->cache.header_contents.array[i].array[0]);
-
- main->setting.state.status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, main->cache.large, main->cache.header_contents.array[i].array[0], &number);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_debug_packet_message(&main->program.debug, "Failed to process number for %[" CONTROL_length_s "%] in the response packet, number is:", &main->cache.large, &main->cache.header_contents.array[i].array[0]);
-
- main->setting.state.status = F_status_set_error(F_header_not);
-
- return;
- }
-
- if (number > F_type_size_max_32_unsigned_d) {
- control_print_debug_packet_message(&main->program.debug, "Processed number for %[" CONTROL_length_s "%] exceeds allowed size in the response packet, number is:", &main->cache.large, &main->cache.header_contents.array[i].array[0]);
-
- main->setting.state.status = F_status_set_error(F_header_not);
-
- return;
- }
-
- header->length = (uint16_t) number;
- }
- else {
- control_print_warning_packet_header_duplicate_object(&main->program.warning, control_length_s);
- }
- }
- else if (f_compare_dynamic_partial_string(control_status_s.string, main->cache.large, control_status_s.used, main->cache.header_objects.array[i]) == F_equal_to) {
- if (!(found & 0x4)) {
- found |= 0x4;
- number = 0;
-
- control_print_debug_packet_header_object_and_content(&main->program.debug, control_status_s, main->cache.large, main->cache.header_contents.array[i].array[0]);
-
- // Attempt to get packet status as a number.
- main->setting.state.status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, main->cache.large, main->cache.header_contents.array[i].array[0], &number);
-
- if (F_status_set_fine(main->setting.state.status) == F_number) {
-
- // Not a number, so attempt get by packet status string name.
- const f_number_unsigned_t name_length = (main->cache.header_contents.array[i].array[0].stop - main->cache.header_contents.array[i].array[0].start) + 1;
- char name_string[name_length + 1];
- const f_string_static_t name = macro_f_string_static_t_initialize_1(name_string, 0, name_length);
-
- memcpy(name_string, main->cache.large.string + main->cache.header_contents.array[i].array[0].start, name_length);
- name_string[name_length] = 0;
-
- main->setting.state.status = fl_status_string_from(name, &header->status);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_debug_packet_message(&main->program.debug, "Failed to process %[" CONTROL_status_s "%] in the response packet, Content is:", &main->cache.large, &main->cache.header_contents.array[i].array[0]);
-
- main->setting.state.status = F_status_set_error(F_header_not);
-
- return;
- }
- }
- else if (F_status_is_error(main->setting.state.status)) {
- control_print_debug_packet_message(&main->program.debug, "Failed to process number for %[" CONTROL_status_s "%] in the response packet, number is:", &main->cache.large, &main->cache.header_contents.array[i].array[0]);
-
- if (F_status_set_fine(main->setting.state.status) == F_memory_not) return;
-
- main->setting.state.status = F_status_set_error(F_header_not);
-
- return;
- }
- else {
- if (number > F_status_size_max_with_bits_d) {
- control_print_debug_packet_message(&main->program.debug, "Processed number for %[" CONTROL_status_s "%] exceeds allowed size in the response packet, number is:", &main->cache.large, &main->cache.header_contents.array[i].array[0]);
-
- main->setting.state.status = F_status_set_error(F_header_not);
-
- return;
- }
- }
- }
- else {
- control_print_warning_packet_header_duplicate_object(&main->program.warning, control_length_s);
- }
- }
- else if (f_compare_dynamic_partial_string(control_type_s.string, main->cache.large, control_type_s.used, main->cache.header_objects.array[i]) == F_equal_to) {
- if (!(found & 0x8)) {
- found |= 0x8;
-
- control_print_debug_packet_header_object_and_content(&main->program.debug, control_type_s, main->cache.large, main->cache.header_contents.array[i].array[0]);
-
- if (f_compare_dynamic_partial_string(control_controller_s.string, main->cache.large, control_controller_s.used, main->cache.header_contents.array[i].array[0]) == F_equal_to) {
- header->type = control_payload_type_controller_e;
- }
- else if (f_compare_dynamic_partial_string(control_error_s.string, main->cache.large, control_error_s.used, main->cache.header_contents.array[i].array[0]) == F_equal_to) {
- header->type = control_payload_type_error_e;
- }
- else {
- control_print_debug_packet_message(&main->program.debug, "Unknown %[" CONTROL_type_s "%] in response packet, Content is:", &main->cache.large, &main->cache.header_contents.array[i].array[0]);
-
- main->setting.state.status = F_status_set_error(F_header_not);
-
- return;
- }
- }
- else {
- control_print_warning_packet_header_duplicate_object(&main->program.warning, control_type_s);
- }
- }
- }
- }
- }
-
- main->setting.state.status = F_okay;
- }
-#endif // _di_control_packet_receive_
-
-#ifndef _di_control_packet_process_
- void control_packet_process(control_main_t * const main, control_payload_header_t * const header) {
-
- if (!main || !header) return;
-
- f_string_static_t string_status = f_string_static_t_initialize;
-
- {
- main->setting.state.status = f_status_string_to(header->status, &string_status);
-
- if (F_status_is_error(main->setting.state.status)) {
- control_print_warning_packet_process_string_to_failed(&main->program.warning, header->status, main->setting.state.status);
-
- return;
- }
- }
-
- if (main->setting.flag & control_main_flag_return_e) {
- fll_print_format("response %q %q %q%r", main->program.output.to, control_payload_type_name(header->type), control_action_type_name(header->action), string_status, f_string_eol_s);
- }
- else if (header->type == control_payload_type_error_e) {
- control_print_error_packet_response(&main->program.error, *header, string_status);
- }
- else if (header->status == F_failure) {
- control_print_error_packet_response_failure(&main->program.error, *header, string_status);
- }
- else if (header->status == F_busy) {
- control_print_warning_packet_response_busy(&main->program.warning, *header, string_status);
- }
- else if (header->status == F_done || header->status == F_success) {
- control_print_message_packet_response(&main->program.output, *header, string_status);
- }
- else {
-
- // Set type to 0 to inform the caller to handle this error.
- header->type = 0;
-
- main->setting.state.status = F_status_set_error(F_known_not);
-
- return;
- }
-
- if (header->type == control_payload_type_error_e || header->status == F_failure || header->status == F_busy) {
- main->setting.state.status = F_status_set_error(header->status);
- }
- else {
- main->setting.state.status = header->status;
- }
- }
-#endif // _di_control_packet_process_
-
-#ifndef _di_control_packet_send_
- void control_packet_send(control_main_t * const main) {
-
- if (!main) return;
-
- main->setting.size_write = main->cache.packet.used;
-
- main->setting.state.status = f_socket_write(&main->setting.socket, 0, (void *) &main->cache.packet, 0);
- }
-#endif // _di_control_packet_send_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the packet functionality.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_packet_h
-#define _control_packet_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Build the payload, storing it in the large cache.
- *
- * @param main
- * The main program data.
- *
- * @return
- * F_okay on success.
- *
- * F_too_large (with error bit) If the message is too large for the packet format to transmit.
- *
- * Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_string_append().
- * Errors (with error bit) from: f_string_dynamic_append().
- * Errors (with error bit) from: fll_fss_extended_write().
- * Errors (with error bit) from: fll_fss_payload_write().
- *
- * @see f_memory_array_resize()
- * @see f_string_append()
- * @see f_string_dynamic_append()
- */
-#ifndef _di_control_packet_build_
- extern void control_packet_build(control_main_t * const main);
-#endif // _di_control_packet_build_
-
-/**
- * Given the header buffer, get the flag bits.
- *
- * @param buffer
- * The buffer to read the length of and get the
- *
- * @return
- * The 8-bit number representing the flags.
- */
-#ifndef _di_control_packet_header_flag_
- extern uint8_t control_packet_header_flag(const uint8_t buffer[]);
-#endif // _di_control_packet_header_flag_
-
-/**
- * Given the header buffer, get the length bits.
- *
- * The endianness is automatically detected and swapped by this function to guarantee host order bytes.
- *
- * @param is_big
- * If TRUE, then the length in the buffer is in big endian format.
- * If FALSE, then the length in the buffer is in little endian format.
- * @param buffer
- * The buffer to read the length of and get the
- *
- * @return
- * The 32-bit number representing the length.
- */
-#ifndef _di_control_packet_header_length_
- extern uint32_t control_packet_header_length(const bool is_big, const uint8_t buffer[]);
-#endif // _di_control_packet_header_length_
-
-/**
- * Receive the response from the remote socket, storing it in the large cache.
- *
- * @todo consider returning F_header (with error bit) fo most header processing errors rather than individual status codes.
- *
- * @param main
- * The main program data.
- *
- * This alters main.setting.state.status:
- * F_okay on success.
- *
- * F_header_not (with error bit) If there is a problem processing the packet header.
- * F_memory_not (with error bit) On out of memory issues (this is passed through from called functions).
- * F_packet_not (with error bit) If the received packet is not a valid packet or not a supported packet structure.
- * F_payload_not (with error bit) If there is a problem processing the packet payload.
- * F_too_large (with error bit) If the received packet specifies a size that is too large or the actual size is larger than the specified size.
- * F_too_small (with error bit) If the received packet actual size is smaller than the specified size.
- *
- * Errors (with error bit) from: f_memory_array_increase_by().
- * Errors (with error bit) from: f_socket_read().
- * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect().
- * Errors (with error bit) from: fll_fss_extended_read().
- * Errors (with error bit) from: fll_fss_basic_list_read().
- * @param header
- * The control payload packet header data.
- *
- * @see f_memory_array_increase_by()
- * @see f_socket_read()
- * @see fl_conversion_dynamic_partial_to_unsigned_detect()
- * @see f_fss_apply_delimit()
- * @see fl_status_string_from()
- * @see fll_fss_extended_read()
- * @see fll_fss_basic_list_read()
- */
-#ifndef _di_control_packet_receive_
- extern void control_packet_receive(control_main_t * const main, control_payload_header_t * const header);
-#endif // _di_control_packet_receive_
-
-/**
- * Process the received and loaded packet.
- *
- * @param main
- * The main program data.
- *
- * This alters main.setting.state.status:
- * F_done on success but action has no success or failure states.
- * F_success on success.
- *
- * F_busy (with error bit)
- * F_failure (with error bit) on success but controller returned failure for action.
- * F_known_not (with error bit) if the Payload type is unknown.
- * Any error (with error bit) on failure where the error is defined by the controller service.
- * @param header
- * The control payload packet header data.
- */
-#ifndef _di_control_packet_process_
- extern void control_packet_process(control_main_t * const main, control_payload_header_t * const header);
-#endif // _di_control_packet_process_
-
-/**
- * Send the payload to the remote socket, getting the payload from the large cache.
- *
- * @param main
- * The main program data.
- *
- * This alters main.setting.state.status:
- * F_okay on success.
- *
- * Errors (with error bit) from: f_socket_write().
- *
- * @see f_socket_write()
- */
-#ifndef _di_control_packet_send_
- extern void control_packet_send(control_main_t * const main);
-#endif // _di_control_packet_send_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_packet_h
+++ /dev/null
-#include "control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_control_payload_type_identify_
- const uint8_t control_payload_type_identify(const f_string_static_t payload) {
-
- if (f_compare_dynamic(payload, control_controller_s) == F_equal_to) return control_payload_type_controller_e;
- if (f_compare_dynamic(payload, control_error_s) == F_equal_to) return control_payload_type_error_e;
- if (f_compare_dynamic(payload, control_init_s) == F_equal_to) return control_payload_type_init_e;
-
- return 0;
- }
-#endif // _di_control_payload_type_identify_
-
-#ifndef _di_control_payload_type_name_
- const f_string_static_t control_payload_type_name(const uint8_t type) {
-
- switch (type) {
- case control_payload_type_controller_e:
- return control_controller_s;
-
- case control_payload_type_error_e:
- return control_error_s;
-
- case control_payload_type_init_e:
- return control_init_s;
- }
-
- return f_string_empty_s;
- }
-#endif // _di_control_payload_type_name_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the payload functionality.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_payload_h
-#define _control_payload_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Identify the payload code the given name represents.
- *
- * @param payload
- * The string representing a payload.
- *
- * @return
- * The payload type code on success.
- * 0 if name is unknown.
- */
-#ifndef _di_control_payload_type_identify_
- extern const uint8_t control_payload_type_identify(const f_string_static_t payload);
-#endif // _di_control_payload_type_identify_
-
-/**
- * Get a string representing the payload type.
- *
- * @param type
- * The payload type id.
- *
- * @return
- * The string with used > 0 on success.
- * The string with used == 0 if no match was found.
- */
-#ifndef _di_control_payload_type_name_
- extern const f_string_static_t control_payload_type_name(const uint8_t type);
-#endif // _di_control_payload_type_name_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_payload_h
+++ /dev/null
-#include "../control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the print data functionality.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_print_data_h
-#define _control_print_data_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_print_data_h
+++ /dev/null
-#include "../control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_control_print_debug_packet_header_object_and_content_
- f_status_t control_print_debug_packet_header_object_and_content(fl_print_t * const print, const f_string_static_t object, const f_string_static_t content, const f_range_t content_range) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_debug_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("Packet header Object '%[%Q%]", print->to, print->set->notable, object, print->set->notable);
- fl_print_format("' has value '%[%/Q%]'.%r", print->to, print->set->notable, content, content_range, print->set->notable, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_debug_packet_header_object_and_content_
-
-#ifndef _di_control_print_debug_packet_message_
- f_status_t control_print_debug_packet_message(fl_print_t * const print, const f_string_t message, const f_string_static_t *buffer, const f_range_t *range) {
-
- if (!print || !print->custom) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_debug_e) return F_output_not;
-
- control_main_t * const main = (control_main_t *) print->custom;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%s", print->to, message);
-
- if (buffer) {
- if (range) {
- fl_print_format("'%[%/Q%]'", print->to, print->set->notable, *buffer, *range, print->set->notable);
- }
- else {
- fl_print_format("'%[%/Q%]'", print->to, print->set->notable, *buffer, print->set->notable);
- }
- }
-
- if (main->setting.state.status) {
- fl_print_format(", with status code %[%ui%]'", print->to, print->set->notable, main->setting.state.status, print->set->notable);
- }
-
- fl_print_format(".%r", print->to, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_debug_packet_message_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the print functionality.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_print_debug_h
-#define _control_print_debug_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Print a message displaying the object and content for some packet header.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param object
- * The object string.
- * @param content
- * The content string.
- * @param content_range
- * The range representing the content where the content is found within the content string.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_debug_packet_header_object_and_content_
- extern f_status_t control_print_debug_packet_header_object_and_content(fl_print_t * const print, const f_string_static_t object, const f_string_static_t content, const f_range_t content_range);
-#endif // _di_control_print_debug_packet_header_object_and_content_
-
-/**
- * Print a debug message regarding some packet.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param message
- * The message to print.
- *
- * A single "%[" followed by a single "%]" is supported in the message and is replaced with "notable" context.
- * @param buffer
- * (optional) An additonal message to print (this is syntax highlighted).
- * Set to NULL to not use.
- * @param range
- * (optional) The range within the buffer to print rather than printing the entire buffer.
- * Set to NULL to not use.
- * This is ignored when buffer is NULL.
- * @param status
- * (optional) A status code that triggered the failure (this is syntax highlighted).
- * Set to NULL to not use.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_debug_packet_message_
- extern f_status_t control_print_debug_packet_message(fl_print_t * const print, const f_string_t message, const f_string_static_t *buffer, const f_range_t *range);
-#endif // _di_control_print_debug_packet_message_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_print_debug_h
+++ /dev/null
-#include "../control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_control_print_error_
- f_status_t control_print_error(fl_print_t * const print, const f_string_t function) {
-
- if (!print || !print->custom) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- fll_error_print(print, F_status_set_fine(((control_main_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e);
-
- return F_okay;
- }
-#endif // _di_control_print_error_
-
-#ifndef _di_control_print_error_file_
- f_status_t control_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) {
-
- if (!print || !print->custom) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- control_main_t * const main = (control_main_t *) print->custom;
-
- fll_error_file_print(print, F_status_set_fine(main->setting.state.status), function, fll_error_file_flag_fallback_e, name, operation, type);
-
- return F_okay;
- }
-#endif // _di_control_print_error_file_
-
-#ifndef _di_control_print_error_packet_response_
- f_status_t control_print_error_packet_response(fl_print_t * const print, const control_payload_header_t header, const f_string_static_t string_status) {
-
- if (!print || !print->custom) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- control_main_t * const main = (control_main_t *) print->custom;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QReceived error response for " CONTROL_action_s " '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, control_action_type_name(header.action), print->set->notable);
- fl_print_format("%[' with status '%]", print->to, print->set->error, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, string_status, print->set->notable);
- fl_print_format("%[' (%]", print->to, print->set->error, print->set->error);
- fl_print_format(f_string_format_ui_single_s.string, print->to, print->set->notable, header.status, print->set->notable);
-
- if (header.length) {
- fl_print_format("%[): %/Q%]%r", print->to, print->set->error, print->set->error, main->cache.large, main->cache.packet_contents.array[main->cache.packet_contents.used - 1].array[0], f_string_eol_s);
- }
- else {
- fl_print_format("%[).%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
- }
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_packet_response_
-
-#ifndef _di_control_print_error_packet_response_failure_
- f_status_t control_print_error_packet_response_failure(fl_print_t * const print, const control_payload_header_t header, const f_string_static_t string_status) {
-
- if (!print || !print->custom) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- control_main_t * const main = (control_main_t *) print->custom;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe action '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, control_action_type_name(header.action), print->set->notable);
- fl_print_format("%[' failed with status '%]", print->to, print->set->error, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, string_status, print->set->notable);
- fl_print_format("%[' (%]", print->to, print->set->error, print->set->error);
- fl_print_format(f_string_format_ui_single_s.string, print->to, print->set->notable, header.status, print->set->notable);
-
- if (header.length) {
- fl_print_format("%[): %/Q%]%r", print->to, print->set->error, print->set->error, main->cache.large, main->cache.packet_contents.array[main->cache.packet_contents.used - 1].array[0], f_string_eol_s);
- }
- else {
- fl_print_format("%[).%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
- }
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_packet_response_failure_
-
-#ifndef _di_control_print_error_parameter_actions_none_
- f_status_t control_print_error_parameter_actions_none(fl_print_t * const print) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- fll_print_format("%[%QNo actions provided.%]%r", print->to, print->set->error, print->prefix, print->set->error, f_string_eol_s);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_actions_none_
-
-#ifndef _di_control_print_error_parameter_action_not_
- f_status_t control_print_error_parameter_action_not(fl_print_t * const print, const f_string_static_t action) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe parameter '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, action, print->set->notable);
- fl_print_format("%[' is not a known controller action.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_action_not_
-
-#ifndef _di_control_print_error_parameter_action_rule_basename_empty_
- f_status_t control_print_error_parameter_action_rule_basename_empty(fl_print_t * const print, const f_string_static_t action) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe action parameter '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, action, print->set->notable);
- fl_print_format("%[' a rule base name cannot be an empty string.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_action_rule_basename_empty_
-
-#ifndef _di_control_print_error_parameter_action_rule_directory_empty_
- f_status_t control_print_error_parameter_action_rule_directory_empty(fl_print_t * const print, const f_string_static_t action) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe action parameter '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, action, print->set->notable);
- fl_print_format("%[' a rule directory path cannot be an empty string.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_action_rule_directory_empty_
-
-#ifndef _di_control_print_error_parameter_action_rule_empty_
- f_status_t control_print_error_parameter_action_rule_empty(fl_print_t * const print, const f_string_static_t action) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe action parameter '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, action, print->set->notable);
- fl_print_format("%[' a rule name cannot be an empty string.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_action_rule_empty_
-
-#ifndef _di_control_print_error_parameter_action_rule_not_
- f_status_t control_print_error_parameter_action_rule_not(fl_print_t * const print, const f_string_static_t action) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe action parameter '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, action, print->set->notable);
- fl_print_format("%[' requires either a full rule name or a rule directory path along with the rule base name.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_action_rule_not_
-
-#ifndef _di_control_print_error_parameter_action_rule_too_few_
- f_status_t control_print_error_parameter_action_rule_too_few(fl_print_t * const print, const f_string_static_t action) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe action parameter '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, action, print->set->notable);
- fl_print_format("%[' has too few arguments.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_action_rule_too_few_
-
-#ifndef _di_control_print_error_parameter_action_rule_too_few_with_
- f_status_t control_print_error_parameter_action_rule_too_few_with(fl_print_t * const print, const f_string_static_t action, const f_string_static_t with) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe action parameter '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, action, print->set->notable);
- fl_print_format("%[' when used with '%]", print->to, print->set->error, print->set->error, f_string_eol_s);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, with, print->set->notable);
- fl_print_format("%[' has too few arguments.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_action_rule_too_few_with_
-
-#ifndef _di_control_print_error_parameter_action_rule_too_many_
- f_status_t control_print_error_parameter_action_rule_too_many(fl_print_t * const print, const f_string_static_t action) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe action parameter '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, action, print->set->notable);
- fl_print_format("%[' has too many arguments.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_action_rule_too_many_
-
-#ifndef _di_control_print_error_parameter_action_rule_too_many_with_
- f_status_t control_print_error_parameter_action_rule_too_many_with(fl_print_t * const print, const f_string_static_t action, const f_string_static_t with) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe action parameter '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, action, print->set->notable);
- fl_print_format("%[' when used with '%]", print->to, print->set->error, print->set->error, f_string_eol_s);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, with, print->set->notable);
- fl_print_format("%[' has too many arguments.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_action_rule_too_many_with_
-
-#ifndef _di_control_print_error_parameter_action_rule_with_unknown_
- f_status_t control_print_error_parameter_action_rule_with_unknown(fl_print_t * const print, const f_string_static_t action, const f_string_static_t with) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe action parameter '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, action, print->set->notable);
- fl_print_format("%[' does not know the argument '%]", print->to, print->set->error, print->set->error, f_string_eol_s);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, with, print->set->notable);
- fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_action_rule_with_unknown_
-
-#ifndef _di_control_print_error_parameter_value_empty_
- f_status_t control_print_error_parameter_value_empty(fl_print_t * const print, const f_string_static_t parameter) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe value for the parameter '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_rr_single_s.string, print->to, print->set->notable, f_console_symbol_long_normal_s, parameter, print->set->notable);
- fl_print_format("%[' must not be an empty string.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_value_empty_
-
-#ifndef _di_control_print_error_parameter_value_not_
- f_status_t control_print_error_parameter_value_not(fl_print_t * const print, const f_string_static_t parameter) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe parameter '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_rr_single_s.string, print->to, print->set->notable, f_console_symbol_long_normal_s, parameter, print->set->notable);
- fl_print_format("%[' is specified, but no value is given.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_parameter_value_not_
-
-#ifndef _di_control_print_error_pipe_supported_not_
- f_status_t control_print_error_pipe_supported_not(fl_print_t * const print) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- fll_print_format("%[%QPipe input is not supported by this program.%]%r", print->to, print->set->error, print->prefix, print->set->error, f_string_eol_s);
-
- return F_okay;
- }
-#endif // _di_control_print_error_pipe_supported_not_
-
-#ifndef _di_control_print_error_response_packet_valid_not_
- f_status_t control_print_error_response_packet_valid_not(fl_print_t * const print) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- fll_print_format("%[%QThe received response is not a valid or supported packet.%]%r", print->to, print->set->error, print->prefix, print->set->error, f_string_eol_s);
-
- return F_okay;
- }
-#endif // _di_control_print_error_response_packet_valid_not_
-
-#ifndef _di_control_print_error_request_packet_too_large_
- f_status_t control_print_error_request_packet_too_large(fl_print_t * const print) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- fll_print_format("%[%QThe generated packet is too large, cannot send packet.%]%r", print->to, print->set->error, print->prefix, print->set->error, f_string_eol_s);
-
- return F_okay;
- }
-#endif // _di_control_print_error_request_packet_too_large_
-
-#ifndef _di_control_print_error_socket_file_failed_
- f_status_t control_print_error_socket_file_failed(fl_print_t * const print, const f_string_static_t path_socket) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QFailed to connect to the socket file '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, path_socket, print->set->notable);
- fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_socket_file_failed_
-
-#ifndef _di_control_print_error_socket_file_missing_
- f_status_t control_print_error_socket_file_missing(fl_print_t * const print, const f_string_static_t path_socket) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe controller socket file '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, path_socket, print->set->notable);
- fl_print_format("%[' could not be found and is required.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_socket_file_missing_
-
-#ifndef _di_control_print_error_socket_file_not_
- f_status_t control_print_error_socket_file_not(fl_print_t * const print, const f_string_static_t path_socket) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe controller socket file '%]", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, path_socket, print->set->notable);
- fl_print_format("%[' is not a socket file.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_error_socket_file_not_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the print error functionality.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_print_error_h
-#define _control_print_error_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Print generic error message regarding a function failing in some way.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param function
- * The name of the function associated with the error.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- *
- * @see fll_error_print()
- */
-#ifndef _di_control_print_error_
- extern f_status_t control_print_error(fl_print_t * const print, const f_string_t function);
-#endif // _di_control_print_error_
-
-/**
- * Print file related error or warning messages.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param function
- * The name of the function where the error happened.
- * Set to 0 to disable.
- * @param name
- * The name of the file or directory.
- * @param operation
- * The operation that fails, such as 'create' or 'access'.
- * @param type
- * A valid file type code from the fll_error_file_type enum.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- *
- * @see fll_error_file_print()
- */
-#ifndef _di_control_print_error_file_
- extern f_status_t control_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type);
-#endif // _di_control_print_error_file_
-
-/**
- * Print an error from the packet response.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param header
- * The control payload packet header data.
- * @param status
- * A string representing the name of the status code from header.status.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_packet_response_
- extern f_status_t control_print_error_packet_response(fl_print_t * const print, const control_payload_header_t header, const f_string_static_t status);
-#endif // _di_control_print_error_packet_response_
-
-/**
- * Print a error about a packet response failure.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param header
- * The control payload packet header data.
- * @param status
- * A string representing the name of the status code from header.status.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_packet_response_failure_
- extern f_status_t control_print_error_packet_response_failure(fl_print_t * const print, const control_payload_header_t header, const f_string_static_t string_status);
-#endif // _di_control_print_error_packet_response_failure_
-/**
- * Print an error message about no actions being provided.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_actions_none_
- extern f_status_t control_print_error_parameter_actions_none(fl_print_t * const print);
-#endif // _di_control_print_error_parameter_actions_none_
-
-/**
- * Print an error message about the given parameter not matching the known set of controller actions.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param action
- * The parameter representing an action.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_action_not_
- extern f_status_t control_print_error_parameter_action_not(fl_print_t * const print, const f_string_static_t action);
-#endif // _di_control_print_error_parameter_action_not_
-
-/**
- * Print an error message about the given parameter being a rule action having an empty rule basename.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param action
- * The parameter representing an action.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_action_rule_basename_empty_
- extern f_status_t control_print_error_parameter_action_rule_basename_empty(fl_print_t * const print, const f_string_static_t action);
-#endif // _di_control_print_error_parameter_action_rule_basename_empty_
-
-/**
- * Print an error message about the given parameter being a rule action having an empty rule directory path.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param action
- * The parameter representing an action.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_action_rule_directory_empty_
- extern f_status_t control_print_error_parameter_action_rule_directory_empty(fl_print_t * const print, const f_string_static_t action);
-#endif // _di_control_print_error_parameter_action_rule_directory_empty_
-
-/**
- * Print an error message about the given parameter being a rule action having an empty rule name.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param action
- * The parameter representing an action.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_action_rule_empty_
- extern f_status_t control_print_error_parameter_action_rule_empty(fl_print_t * const print, const f_string_static_t action);
-#endif // _di_control_print_error_parameter_action_rule_empty_
-
-/**
- * Print an error message about the given parameter being a rule action but no rule name is specified.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param action
- * The parameter representing an action.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_action_rule_not_
- extern f_status_t control_print_error_parameter_action_rule_not(fl_print_t * const print, const f_string_static_t action);
-#endif // _di_control_print_error_parameter_action_rule_not_
-
-/**
- * Print an error message about the given parameter being a rule action having too few arguments passed.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param action
- * The parameter representing an action.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_action_rule_too_few_
- extern f_status_t control_print_error_parameter_action_rule_too_few(fl_print_t * const print, const f_string_static_t action);
-#endif // _di_control_print_error_parameter_action_rule_too_few_
-
-/**
- * Print an error message about the given parameter being a rule action having few many arguments passed for a given "with".
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param action
- * The parameter representing an action.
- * @param with
- * The additional parameter in which is requiring additional arguments that are not met.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_action_rule_too_few_with_
- extern f_status_t control_print_error_parameter_action_rule_too_few_with(fl_print_t * const print, const f_string_static_t action, const f_string_static_t with);
-#endif // _di_control_print_error_parameter_action_rule_too_few_with_
-
-/**
- * Print an error message about the given parameter being a rule action having too many arguments passed.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param action
- * The parameter representing an action.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_action_rule_too_many_
- extern f_status_t control_print_error_parameter_action_rule_too_many(fl_print_t * const print, const f_string_static_t action);
-#endif // _di_control_print_error_parameter_action_rule_too_many_
-
-/**
- * Print an error message about the given parameter being a rule action having too many arguments passed for a given "with".
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param action
- * The parameter representing an action.
- * @param with
- * The additional parameter in which is requiring additional arguments that are not met.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_action_rule_too_many_with_
- extern f_status_t control_print_error_parameter_action_rule_too_many_with(fl_print_t * const print, const f_string_static_t action, const f_string_static_t with);
-#endif // _di_control_print_error_parameter_action_rule_too_many_with_
-/**
- * Print an error message about the given parameter being unknown for the use with the given action.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param action
- * The parameter representing an action.
- * @param with
- * The additional parameter in which is requiring additional arguments that are not met.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_action_rule_with_unknown_
- extern f_status_t control_print_error_parameter_action_rule_with_unknown(fl_print_t * const print, const f_string_static_t action, const f_string_static_t with);
-#endif // _di_control_print_error_parameter_action_rule_with_unknown_
-
-/**
- * Print an error message about the parameter's associated value being an empty string.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param parameter
- * The parameter name.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_value_empty_
- extern f_status_t control_print_error_parameter_value_empty(fl_print_t * const print, const f_string_static_t parameter);
-#endif // _di_control_print_error_parameter_value_empty_
-
-/**
- * Print an error message about the parameter missings its associated value.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param parameter
- * The parameter name.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_parameter_value_not_
- extern f_status_t control_print_error_parameter_value_not(fl_print_t * const print, const f_string_static_t parameter);
-#endif // _di_control_print_error_parameter_value_not_
-
-/**
- * Print an error message about a pipe input being unsupported.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_pipe_supported_not_
- extern f_status_t control_print_error_pipe_supported_not(fl_print_t * const print);
-#endif // _di_control_print_error_pipe_supported_not_
-
-/**
- * Print an error message about the response packet format either being invalid or not supported.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_response_packet_valid_not_
- extern f_status_t control_print_error_response_packet_valid_not(fl_print_t * const print);
-#endif // _di_control_print_error_response_packet_valid_not_
-
-/**
- * Print an error message about the request packet being too large.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_request_packet_too_large_
- extern f_status_t control_print_error_request_packet_too_large(fl_print_t * const print);
-#endif // _di_control_print_error_request_packet_too_large_
-
-/**
- * Print an error message about failure to connect to the socket file.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param path_socket
- * The socket file path.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_socket_file_failed_
- extern f_status_t control_print_error_socket_file_failed(fl_print_t * const print, const f_string_static_t path_socket);
-#endif // _di_control_print_error_socket_file_failed_
-
-/**
- * Print an error message about the socket file not being found.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param path_socket
- * The socket file path.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_socket_file_missing_
- extern f_status_t control_print_error_socket_file_missing(fl_print_t * const print, const f_string_static_t path_socket);
-#endif // _di_control_print_error_socket_file_missing_
-
-/**
- * Print an error message about the socket file not actually being a socket file.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param path_socket
- * The socket file path.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_error_socket_file_not_
- extern f_status_t control_print_error_socket_file_not(fl_print_t * const print, const f_string_static_t path_socket);
-#endif // _di_control_print_error_socket_file_not_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_print_error_h
+++ /dev/null
-#include "../control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_control_print_message_help_
- f_status_t control_print_message_help(fl_print_t * const print) {
-
- if (!print) return F_status_set_error(F_output_not);
-
- f_file_stream_lock(print->to);
-
- fll_program_print_help_header(print, control_program_name_long_s, control_program_version_s);
-
- fll_program_print_help_option_standard(print);
-
- f_print_dynamic_raw(f_string_eol_s, print->to);
-
- fll_program_print_help_option(print, control_short_name_s, control_long_name_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Specify the name of the controller socket file.");
- fll_program_print_help_option(print, control_short_return_s, control_long_return_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print a message about the response packet.");
- fll_program_print_help_option(print, control_short_settings_s, control_long_settings_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Specify a directory path or a full path to the control settings file.");
- fll_program_print_help_option(print, control_short_socket_s, control_long_socket_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Specify a directory path or a full path to the controller socket file.");
-
- f_print_dynamic_raw(f_string_eol_s, print->to);
-
- fll_program_print_help_usage(print, control_program_name_s, control_action_s);
-
- fl_print_format("%r When the %[%r%r%] parameter represents a directory path then the file name is generated from either the", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, control_long_socket_s, print->set->notable);
- fl_print_format(" %[%r%r%] parameter or from the control settings file.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, control_long_name_s, print->set->notable, f_string_eol_s, f_string_eol_s);
-
- fl_print_format(" A rule action allows for either the full rule path, such as '%[boot/root%]'", print->to, print->set->notable, print->set->notable);
- fl_print_format(" as a single parameter or two parameters with the first representing the rule directory path '%[boot%]'", print->to, print->set->notable, print->set->notable);
- fl_print_format(" and the second representing the rule base name '%[root%]'.%r%r", print->to, print->set->notable, print->set->notable, f_string_eol_s, f_string_eol_s);
-
- fl_print_format(" The %[%r%r%] parameter is intended to be used for scripting and is of the form \"response [type] [action] [status]\".%r", print->to, print->set->notable, f_console_symbol_long_normal_s, control_long_return_s, print->set->notable, f_string_eol_s);
- fl_print_format(" Be sure to use the %[%r%r%] parameter to suppress output when using this in scripting.%r", print->to, print->set->notable, f_console_symbol_long_inverse_s, f_console_standard_long_quiet_s, print->set->notable, f_string_eol_s);
- fl_print_format(" No response is returned on program errors, especially those errors that prevent communicating to the controller.%r", print->to, f_string_eol_s);
-
- f_file_stream_flush(print->to);
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_message_help_
-
-#ifndef _di_control_print_message_packet_response_
- f_status_t control_print_message_packet_response(fl_print_t * const print, const control_payload_header_t header, const f_string_static_t string_status) {
-
- if (!print || !print->custom) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_normal_e) return F_output_not;
-
- control_main_t * const main = (control_main_t *) print->custom;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("The action '", print->to);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, control_action_type_name(header.action), print->set->notable);
-
- if (header.status == F_done) {
- fl_print_format("' is performed", print->to);
- }
- else {
- fl_print_format("' is successfully performed", print->to);
- }
-
- if (header.length) {
- fl_print_format(": %/Q%r", print->to, main->cache.large, main->cache.packet_contents.array[main->cache.packet_contents.used - 1].array[0], f_string_eol_s);
- }
- else {
- fl_print_format(".%r", print->to, f_string_eol_s);
- }
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_message_packet_response_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the print functionality.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_print_message_h
-#define _control_print_message_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Print help.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- *
- * @see f_file_stream_flush()
- * @see f_file_stream_lock()
- * @see f_file_stream_unlock()
- * @see f_print_dynamic_raw()
- * @see fl_print_format()
- *
- * @see fll_program_print_help_header()
- * @see fll_program_print_help_option()
- * @see fll_program_print_help_option_standard()
- * @see fll_program_print_help_usage()
- */
-#ifndef _di_control_print_message_help_
- extern f_status_t control_print_message_help(fl_print_t * const print);
-#endif // _di_control_print_message_help_
-
-/**
- * Print a message about a packet response.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param header
- * The control payload packet header data.
- * @param status
- * A string representing the name of the status code from header.status.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_message_packet_response_
- extern f_status_t control_print_message_packet_response(fl_print_t * const print, const control_payload_header_t header, const f_string_static_t string_status);
-#endif // _di_control_print_message_packet_response_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_print_message_h
+++ /dev/null
-#include "../control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_control_print_warning_packet_header_duplicate_object_
- f_status_t control_print_warning_packet_header_duplicate_object(fl_print_t * const print, const f_string_static_t response_header) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_verbose_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe received response header '%]", print->to, print->set->warning, print->prefix, print->set->warning);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, response_header, print->set->notable);
- fl_print_format("%[' is repeated.%]%r", print->to, print->set->warning, print->set->warning, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_warning_packet_header_duplicate_object_
-
-#ifndef _di_control_print_warning_packet_process_string_to_failed_
- f_status_t control_print_warning_packet_process_string_to_failed(fl_print_t * const print, const f_status_t status_of, const f_status_t status_error) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_verbose_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QFailed while calling f_status_string_to() for status%] ", print->to, print->set->warning, print->set->warning, print->set->warning);
- fl_print_format(f_string_format_ui_single_s.string, print->to, print->set->notable, status_of, print->set->notable);
- fl_print_format("%[, failing with status code%] ", print->to, print->set->warning, status_error, print->set->warning);
- fl_print_format(f_string_format_ui_single_s.string, print->to, print->set->notable, status_error, print->set->notable);
- fl_print_format(f_string_format_sentence_end_s.string, print->to, print->set->warning, print->set->warning, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_warning_packet_process_string_to_failed_
-
-#ifndef _di_control_print_warning_packet_response_busy_
- f_status_t control_print_warning_packet_response_busy(fl_print_t * const print, const control_payload_header_t header, const f_string_static_t string_status) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_verbose_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QThe action '%]", print->to, print->set->warning, print->prefix, print->set->warning);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, control_action_type_name(header.action), print->set->notable);
- fl_print_format("%[' could not be performed because the service is busy.%]%r", print->to, print->set->warning, print->set->warning, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_control_print_warning_packet_response_busy_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the print functionality.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_print_warning_h
-#define _control_print_warning_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Print a warning message about a response header being repeated (when debugging).
- *
- * This program currently does not support multiple headers for any given valid header Object.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param response_header
- * The repeated response header.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_warning_packet_header_duplicate_object_
- extern f_status_t control_print_warning_packet_header_duplicate_object(fl_print_t * const print, const f_string_static_t response_header);
-#endif // _di_control_print_warning_packet_header_duplicate_object_
-
-/**
- * Print a warning message about a failure when calling f_status_string_to().
- *
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param status_of
- * The status code to be translating to a string.
- * @param status_error
- * The status code representing the failure status returned by f_status_string_to().
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- *
- * @see f_status_string_to()
- */
-#ifndef _di_control_print_warning_packet_process_string_to_failed_
- extern f_status_t control_print_warning_packet_process_string_to_failed(fl_print_t * const print, const f_status_t status_of, const f_status_t status_error);
-#endif // _di_control_print_warning_packet_process_string_to_failed_
-
-/**
- * Print a warning about a packet response returning as busy.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param header
- * The control payload packet header data.
- * @param status
- * A string representing the name of the status code from header.status.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_control_print_warning_packet_response_busy_
- extern f_status_t control_print_warning_packet_response_busy(fl_print_t * const print, const control_payload_header_t header, const f_string_static_t string_status);
-#endif // _di_control_print_warning_packet_response_busy_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_print_warning_h
+++ /dev/null
-#include "control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides the process functionality.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_process_h
-#define _control_process_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_process_h
+++ /dev/null
-#include "control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if !defined(_di_control_signal_check_) && defined(_di_thread_support_)
- f_status_t control_signal_check(control_main_t * const main) {
-
- if (!main || main->program.signal.id == -1) return F_false;
-
- if (!((++main->program.signal_check) % control_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
- fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
-
- main->setting.state.status = F_status_set_error(F_interrupt);
-
- return F_true;
- }
-
- main->program.signal_check = 0;
- }
-
- return F_false;
- }
-#endif // !defined(_di_control_signal_check_) && defined(_di_thread_support_)
-
-#if !defined(_di_control_signal_check_) && !defined(_di_thread_support_)
- f_status_t control_signal_check(control_main_t * const main) {
-
- if (!main || main->program.signal.id == -1) return F_false;
-
- if (main->program.signal_received) {
- fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
-
- main->setting.state.status = F_status_set_error(F_interrupt);
-
- return F_true;
- }
-
- return F_false;
- }
-#endif // !defined(_di_control_signal_check_) && !defined(_di_thread_support_)
-
-#if !defined(_di_control_signal_handler_) && !defined(_di_thread_support_)
- void control_signal_handler(control_main_t * const main) {
-
- if (!main) return;
-
- siginfo_t information;
- f_number_unsigned_t failsafe = 0;
-
- memset(&information, 0, sizeof(siginfo_t));
-
- main->program.signal_received = 0;
-
- f_signal_set_empty(&main->program.signal.set);
- f_signal_set_add(F_signal_abort, &main->program.signal.set);
- f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
- f_signal_set_add(F_signal_hangup, &main->program.signal.set);
- f_signal_set_add(F_signal_interrupt, &main->program.signal.set);
- f_signal_set_add(F_signal_quit, &main->program.signal.set);
- f_signal_set_add(F_signal_termination, &main->program.signal.set);
-
- if (main->program.signal.id == -1) {
- main->setting.status_signal = f_signal_open(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
-
- return;
- }
- }
-
- do {
- memset(&information, 0, sizeof(siginfo_t));
-
- main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
- if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
- if (++failsafe >= control_signal_check_failsafe_d) break;
- }
-
- switch (information.si_signo) {
- case F_signal_abort:
- case F_signal_broken_pipe:
- case F_signal_hangup:
- case F_signal_interrupt:
- case F_signal_quit:
- case F_signal_termination:
- main->program.signal_received = information.si_signo;
-
- break;
- }
-
- failsafe = 0;
- main->setting.status_signal = F_okay;
-
- } while (!main->program.signal_received);
-
- f_signal_close(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
- }
- }
-#endif // !defined(_di_control_signal_handler_) && !defined(_di_thread_support_)
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides signal functionality.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_signal_h
-#define _control_signal_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Check to see if a signal is received.
- *
- * If main.signal is non-zero, then this handles the following signals:
- * - F_signal_abort
- * - F_signal_broken_pipe
- * - F_signal_hangup
- * - F_signal_interrupt
- * - F_signal_quit
- * - F_signal_termination
- *
- * There is a threaded and a non-threaded version of this.
- * The non-threaded version checks periodically using control_signal_check_d and updates main->signal_check as needed.
- * The threaded version checks the flag state which is set by a separate thread that is blocking until signal is received.
- *
- * @param main
- * The main program and settings data.
- *
- * This does not alter main.setting.state.status.
- *
- * @return
- * F_true on signal received.
- * F_false otherwise.
- *
- * @see control_signal_handler()
- *
- * @see fll_program_standard_signal_received()
- */
-#ifndef _di_control_signal_check_
- extern f_status_t control_signal_check(control_main_t * const main);
-#endif // _di_control_signal_check_
-
-/**
- * Signal handler for signals/interrupts.
- *
- * This blocks until an expected signal is recieved.
- * When an expected signal is received it then sets the
- *
- * If main.signal is non-zero, then this handles the following signals:
- * - F_signal_abort
- * - F_signal_broken_pipe
- * - F_signal_hangup
- * - F_signal_interrupt
- * - F_signal_quit
- * - F_signal_termination
- *
- * @param main
- * The main program and settings data.
- *
- * This alters main.program.signal_received, setting it to a received signal.
- *
- * This alters main.setting.state.status:
- * Errors (with error bit) from: f_signal_open()
- * Errors (with error bit) from: f_signal_wait()
- *
- * @see f_signal_close()
- * @see f_signal_open()
- * @see f_signal_wait()
- */
-#if !defined(_di_control_signal_handler_) && !defined(_di_thread_support_)
- extern void control_signal_handler(control_main_t * const main);
-#endif // !defined(_di_control_signal_handler_) && !defined(_di_thread_support_)
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_signal_h
+++ /dev/null
-#include "control.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if !defined(_di_control_thread_signal_) && !defined(_di_thread_support_)
- void * control_thread_signal(void * const main) {
-
- f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
-
- if (main) {
- control_signal_handler((control_main_t *) main);
- }
-
- return 0;
- }
-#endif // !defined(_di_control_thread_signal_) && !defined(_di_thread_support_)
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: Control
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Provides thread functionality.
- *
- * This is auto-included and should not need to be explicitly included.
- */
-#ifndef _control_thread_h
-#define _control_thread_h
-
-/**
- * Thread handler for signals/interrupts.
- *
- * If main.signal is non-zero, then this handles the following signals:
- * - F_signal_abort
- * - F_signal_broken_pipe
- * - F_signal_hangup
- * - F_signal_interrupt
- * - F_signal_quit
- * - F_signal_termination
- *
- * @param main
- * The program and settings data.
- *
- * Must be of type control_main_t.
- *
- * @return
- * 0, always.
- *
- * @see f_thread_cancel_state_set()
- *
- * @see control_signal_handler()
- */
-#if !defined(_di_control_thread_signal_) && !defined(_di_thread_support_)
- extern void * control_thread_signal(void * const main);
-#endif // !defined(_di_control_thread_signal_) && !defined(_di_thread_support_)
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _control_thread_h
+++ /dev/null
-# fss-0000
-
-_di_thread_support_ Disables thread support.
-
-_controller_as_init_ The controller program is compiled as an init replacement and this control program should treat it as such.
-_override_controller_name_socket_ Use this as the default custom file name representing the controller program socket.
-_override_controller_name_socket_length_ The number of bytes representing the string in _override_controller_name_socket_ (not including the terminating NULL).
-_override_controller_path_socket_ Use this as the default custom directory path representing the location of the controller program socket.
-_override_controller_path_socket_length_ The number of bytes representing the string in _override_controller_path_socket_ (not including the terminating NULL).
-_override_controller_path_socket_prefix_ Use this as the default custom prefix prepended to the file name of the file representing the controller program socket.
-_override_controller_path_socket_prefix_length_ The number of bytes representing the string in _override_controller_path_socket_prefix_ (not including the terminating NULL).
-_override_controller_path_socket_suffix_ Use this as the default custom prefix prepended to the file name of the file representing the controller program socket.
-_override_controller_path_socket_suffix_length_ The number of bytes representing the string in _override_controller_path_socket_suffix_ (not including the terminating NULL).
-_override_control_path_settings_ Use this as the default full path to the controlsettings.
-_override_control_path_settings_length_ The number of bytes representing the string in _override_controller_path_settings_length_ (not including the terminating NULL).
-
-_pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr.
-_pthread_sigqueue_unsupported_ Disable GNU specific sigqueue().
+++ /dev/null
-# fss-0000
-
-f_type
-f_status
-f_memory
-f_type_array
-f_string
-f_utf
-f_color
-f_compare
-f_console
-f_file
-f_fss
-f_parse
-f_path
-f_pipe
-f_print
-f_rip
-f_signal
-f_socket
-f_status_string
-f_thread
-
-fl_fss
-fl_print
-
-fll_error
-fll_fss
-fll_print
-fll_program
-fll_status_string
+++ /dev/null
-# fss-0005 iki-0002
-
-settings:
- fail exit
- modes individual individual_thread level monolithic clang test fanalyzer coverage thread threadlesss
-
- environment PATH LD_LIBRARY_PATH
- environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH
-
-main:
- build
-
-install:
- shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color'
-
-help:
- print
- print context:'title'Fakefile Options for Control Program.context:'reset'
-
- print
- print The following operations are available\:
- print " - context:'notable'help:context:'reset' Perform the help operation, printing this message."
- print " - context:'notable'install:context:'reset' A helper operation that simply calls the ./install.sh script with default settings."
- print " - context:'notable'main:context:'reset' The default compilation using the build settings mode."
-
- print
- print The context:'notable'install[context]:'reset' operation supports the context:'notable'work[context]:'reset', context:'notable'verbosity[context]:'reset', and context:'notable'color[context]:'reset' parameters.
+++ /dev/null
-# fss-0001
-#
-# Modes:
-# - individual: Compile using per project (individual) libraries, does not handle thread or threadless cases.
-# - individual_thread: This is required when compiling in individual mode with "thread" mode.
-# - level: Compile using per level libraries.
-# - monolithic: Compile using per monolithic libraries.
-# - clang: Use clang rather than the default, which is generally gcc.
-# - gcc: Use gcc specific settings.
-# - test: Compile for a test, such as unit testing.
-# - fanalyzer: Compile using GCC's -fanalyzer compile time option.
-# - coverage: Compile for building coverage.
-# - thread: Compile with thread support.
-# - threadless: Compile without thread support.
-#
-
-build_name control
-
-version_major 0
-version_minor 7
-version_micro 0
-version_file micro
-version_target minor
-
-modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless
-modes_default monolithic thread gcc
-
-build_compiler gcc
-build_compiler-clang clang
-build_indexer ar
-build_indexer_arguments rcs
-build_language c
-
-build_libraries -lc
-build_libraries-individual -lfll_error -lfll_fss -lfll_print -lfll_program -lfl_conversion -lfl_fss -lfl_print -lfl_status_string -lf_color -lf_compare -lf_console -lf_conversion -lf_file -lf_fss -lf_memory -lf_parse -lf_path -lf_pipe -lf_print -lf_rip -lf_signal -lf_socket -lf_status_string -lf_string -lf_type_array -lf_utf
-build_libraries-individual_thread -lf_thread
-build_libraries-level -lfll_2 -lfll_1 -lfll_0
-build_libraries-monolithic -lfll
-
-build_sources_library main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/string.c main/common/type.c main/print/data.c main/print/debug.c main/print/error.c main/print/message.c main/print/warning.c main/action.c main/control.c main/packet.c main/payload.c main/signal.c main/thread.c
-
-build_sources_program main/main.c
-
-build_sources_headers main/common.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/string.h main/common/type.h main/print/data.h main/print/debug.h main/print/error.h main/print/message.h main/print/warning.h main/action.h main/control.h main/packet.h main/payload.h main/signal.h main/thread.h
-
-build_sources_documentation man
-
-build_script yes
-build_shared yes
-build_static no
-
-path_headers program/control
-path_library_script script
-path_library_shared shared
-path_library_static static
-path_object_script script
-path_object_shared shared
-path_object_static static
-path_program_script script
-path_program_shared shared
-path_program_static static
-
-has_path_standard yes
-preserve_path_headers yes
-
-search_exclusive yes
-search_shared yes
-search_static yes
-
-environment PATH LD_LIBRARY_PATH
-environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH
-
-#defines -D_di_libcap_
-defines -D_libcap_legacy_only_
-defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_
-defines-threadless -D_di_thread_support_
-
-flags -O2 -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces
-flags -fstack-clash-protection -fno-delete-null-pointer-checks
-flags -Wl,-z,nodlopen -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
-flags-clang -Wno-logical-op-parentheses
-flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/
-flags-fanalyzer -fanalyzer
-flags-gcc_13 -fstrict-flex-arrays=3
-flags-test -O0 -fstack-protector-strong -Wall
-flags-thread -pthread
-
-flags_library -fPIC
-flags_object -fPIC
-flags_program -fPIE
+++ /dev/null
-.TH CONTROL "1" "March 2023" "FLL - Control 0.7.0" "User Commands"
-.SH NAME
-control \- Give commands or make requests to the \fBcontroller\fR program.
-.SH SYNOPSIS
-.B control
-[\fI\,OPTIONS\/\fR] [\fI\,ACTION\/\fR]
-.SH DESCRIPTION
-.PP
-When the \fB\-\-socket\fR parameter represents a directory path then the file name is generated from either the \fB\-\-name\fR parameter or from the control settings file.
-
-A rule action allows for either the full rule path, such as '\fBboot/root\fR' as a single parameter or two parameters with the first representing the rule directory path '\fBboot\fR' and the second representing the rule base name '\fBroot\fR'.
-
-The \fB\-\-return\fR parameter is intended to be used for scripting and is of the form "\fBresponse [type] [action] [status]\fR".
-Be sure to use the \fB++quiet\fR parameter to suppress output when using this in scripting.
-No response is returned on program errors, especially those errors that prevent communicating to the controller.
-.SH OPTIONS
-.TP
-\fB\{\-h, \-\-help\fR
-Print the help message.
-.TP
-\fB+C, ++copyright\fR
-Print the copyright.
-.TP
-\fB+d, ++dark\fR
-Output using colors that show up better on dark backgrounds.
-.TP
-\fB+l, ++light\fR
-Output using colors that show up better on light backgrounds.
-.TP
-\fB+n, ++no_color\fR
-Do not print using color.
-.TP
-\fB+Q, ++quiet\fR
-Decrease verbosity, silencing most output.
-.TP
-\fB+E, ++error\fR
-Decrease verbosity, using only error output.
-.TP
-\fB+N, ++normal\fR
-Set verbosity to normal.
-.TP
-\fB+V, ++verbose\fR
-Increase verbosity beyond normal output.
-.TP
-\fB+D, ++debug\fR
-Enable debugging, significantly increasing verbosity beyond normal output.
-.TP
-\fB+v, ++version\fR
-Print only the version number.
-.TP
-\fB\-n, \-\-name\fR
-Specify the name of the controller socket file.
-.TP
-\fB\-R, \-\-return\fR
-Print a message about the response packet.
-.TP
-\fB\-s, \-\-settings\fR
-Specify a directory path or a full path to the control settings file.
-.TP
-\fB\-k, \-\-socket\fR
-Specify a directory path or a full path to the controller socket file.
-.SH ACTION
-.TP
-The action to perform.
-.SH SEE ALSO
-.PP
-\fBcontroller\fR(1),
-\fBcontroller\-actions\fR(5),
-\fBcontroller\-entry\fR(5),
-\fBcontroller\-exit\fR(5),
-\fBcontroller\-packet\fR(5),
-\fBcontroller\-rule\fR(5)
-.SH AUTHOR
-Written by Kevin Day.
-.SH COPYRIGHT
-.PP
-Copyright \(co 2007-2024 Kevin Day, GNU LGPL Version 2.1 or later.
+++ /dev/null
-# fss-0001
-
-name_socket default
-path_socket /var/run/controller
-path_socket_prefix controller-
-path_socket_suffix .socket
+++ /dev/null
-# fss-0002
-#
-# license: open-standard-license-1.0-or-later
-# version 2024/07/02
-#
-
-Packet Request:
- The Control program sends packets and receives packet responses from the Controller program over the Controller program's Control socket.
- This documentation describes the request packets sent by this program.
-
- The purpose of these request packets are to ask the Controller program to perform a requested action.
-
- The communications to/from the Controller program utilize the FSS-000F (Simple Packet).
- This Simple Packet is expected to contain within it the FSS-000E (Payload) format.
-
- The Payload contains within it a Header and a Payload.
- Note the potential confusion here between the Payload when referring to the Packet format and the Payload referring to the Content within the Payload Packet.
- To avoid this, henceforth "Payload Packet" refers to the FSS-000E (Payload) used within the FSS-000F (Simple Packet).
- The "Payload Header" refers to either the Object ("header:") or Content within the Payload Packet representing the header.
- The "Payload Object" refers to the Object within the Payload Packet (ie: "payload:").
- The "Payload Content" refers to the Content within the Payload Packet.
-
- The FSS-000E (Payload Packet) is very flexible in what it allows within the Header of the Payload Packet.
- The Control program is more restrictive and supports only a subset of the possibilities (which this is explicitly allowed by the Specification).
-
- The Control program only supports the following Payload Packet header Objects for the request\:
- - type: Allows only a single type header Object and may only be one of: "controller", "error", or "init".
- - length: Allows only a single length header Object and must properly describe the length of the entire Payload Packet as per the referenced Specifications.
- - action: Allows only a single action header Object and whose first Content must only be one of: "freeze", "kexec", "kill", "pause", "reboot", "reload", "rerun", "restart", "resume", "shutdown", "start", "stop", and "thaw".
-
- The number of Content associated with a action are specific to the requirements of that action.
-
- The Payload Content is not used and should always be of length 0.
-
- The Payload Content represents the rule being started in FSS-0001 (Extended) format, such as "service sshd".
-
- For example, given the command: "control start service sshd in 5 minutes".
- The "action" Object would be "start service sshd in 5 minutes".
+++ /dev/null
-# fss-0002
-#
-# license: open-standard-license-1.0-or-later
-# version 2024/07/02
-#
-
-Packet Response:
- The control program sends packets and receives packet responses from the controller program over the controller program's control socket.
- This documentation describes the expected response packets and how these response packets are handled.
-
- The communications to/from the controller program utilize the FSS-000F (Simple Packet).
- This Simple Packet is expected to contain within it the FSS-000E (Payload) format.
-
- The Payload contains within it a Header and a Payload.
- Note the potential confusion here between the Payload when referring to the Packet format and the Payload referring to the Content within the Payload Packet.
- The "Payload Header" refers to either the Object ("header:") or Content within the Payload Packet representing the header.
- The "Payload Object" refers to the Object within the Payload Packet (ie: "payload:").
- The "Payload Content" refers to the Content within the Payload Packet.
-
- The Payload Packet (FSS-000E) is very flexible in what it allows within the Header of the Payload Packet.
- The Control program is more restrictive and supports only a subset of the possibilities (which this is explicitly allowed by the Specification).
-
- The Control program only supports the following Payload Packet header Objects for the response\:
- - status: Allows only a single status header Object.
- - type: Allows only a single type header Object and may only be one of: "controller", "error", or "init".
- - action: Allows only a single action header Object and must only be one of: "freeze", "kexec", "kill", "pause", "reboot", "reload", "rerun", "restart", "resume", "shutdown", "start", "stop", and "thaw".
- - length: Allows only a single length header Object and must properly describe the length of the entire Payload Packet as per the referenced Specifications.
-
- The "error" type response Payload Packet is treated as an error response.
- For any error responses that are associated with an action, then the action header is provided (otherwise it is not expected and is ignored).
- For any error responses the Payload Content may be empty but when it is not, then the Payload Content is a single string representing a message further describing the error or the reason for the error.
- These error responses represents errors in attempting to perform some action.
- These responses are not used for actions that return an error as the result of a proper execution or performing of that action.
-
- The "controller" type response Payload Packet represents a response regarding the result of performing a requested action.
- There must always be an "action" designating the action this response is in regards to.
- Only the following are (currently) supported as a status\:
- - F_busy: When unable to perform the action as because the service is too busy or the
- - F_done: When successfully performed the action but the action does not return success or failure.
- - F_failure: When successfully performed the action and the action returned some sort of failure or error.
- - F_success: When successfully performed the action and the action returned some sort of success.
-
- When using the -R/--return parameter, the program prints specially formatted messages to help make the output more scriptable.
-
- The form is "response [type] [action] [status]".
- Examples\:
- - A response that designates the action failed might look like: "response controller my_action F_failure".
- - A response that designates the controller ran out of memory, preventing the action from being run: "response error my_action F_memory_not".
- - A response that designates the controller ran successfully: "response controller my_action F_success".
-
- When the control program fails to function due to some error, there will be no specially formatted message printed.
- When the controller program fails before it can perform the requested action, then a "response error [action] [status]" formatted message is printed.
- When the controller program successfully performs the action but the result of that action is an error, then a "response controller [action] F_failure" formatted message is printed.
+++ /dev/null
-# fss-0002
-#
-# license: open-standard-license-1.0-or-later
-# version 2024/07/02
-#
-
-Settings Documentation:
- This describes intent and purposes of the control settings file.
-
- The settings file provides default or system-wide settings.
- The system-wide settings file is loaded by default but a custom settings file may be alternatively specified.
- Using this avoids the need to add additional paramters to the command line when calling the control program.
-
- When this file is not specified any hardcoded defaults compiled into the program are used.
-
- The location of the settings file is compile time specific and should be changed depending on the particular design of the system.
- The default path for the control settings file is something like "/etc/control/settings".
-
- - name_socket\:
- This represents the file name used to construct the full socket path.
- The file name represents the name of the file but any file extensions, such as ".suffix", should likely use "path_socket_suffix" to specify the file extension.
-
- When not defined the compiled in default is used.
- The default socket path directory is generally "default" but this could be changed during compile time.
-
- This is required to not be empty so when the Object "path_socket" is defined without any Content, then an error is expected to be thrown.
-
- This is used along with the "path_socket", "path_socket_prefix", and the "path_socket_suffix" to construct the socket file.
-
- - path_socket\:
- This represents the directory path to the socket file provided by the controller or init service.
- This directory path is separate from the file name part so that the name can be more dynamically constructed without having to specify a full directory path each time.
-
- When not defined the compiled in default is used.
- The default socket path directory is generally "/var/run/controller" but this could be changed during compile time.
-
- When the Object "path_socket" is defined without any Content, then no path is added (resulting in the socket relative to the callers current working directory).
-
- This is used along with the "path_socket_prefix", the "path_socket_suffix", and the "name_socket" to construct the socket file.
- A full socket path might look something like "/var/run/controller/controller-default.socket".
-
- It is common for the controller program to be compiled as an init program.
- In this case it may be common for the full socket path to instead be something more like "/var/run/init/init-default.socket".
-
- - path_socket_prefix\:
- This represents a prefix used to construct the full socket path.
- This prefix is prepended to the socket file name.
-
- When not defined the compiled in default is used.
- The default path prefix is generally "controller-" but this could be changed during compile time.
-
- When the Object "path_socket_prefix" is defined without any Content, then no prefix is prepended.
-
- This is used along with the "path_socket", the "path_socket_suffix", and the "name_socket" to construct the socket file.
-
- - path_socket_suffix\:
- This represents a suffix used to construct the full socket path.
- This suffix is appended to the socket file name.
-
- When not defined the compiled in default is used.
- The default path suffix is generally ".socket" but this could be changed during compile time.
-
- When the Object "path_socket_suffix" is defined without any Content, then no suffix is appended.
-
- This is used along with the "path_socket", the "path_socket_prefix", and the "name_socket" to construct the socket file.
+++ /dev/null
-# fss-0002 iki-0000
-#
-# license: open-standard-license-1.0-or-later
-# version 2024/07/02
-#
-# This file (assumed to be named settings.txt) can be more easily read using the following iki_read commands:
-# iki_read settings.txt +Q -w -W code '"' '"'
-#
-# To read the "Entry Specification" section of this file, use this command sequence:
-# fss_basic_list_read settings.txt +Q -cn "Settings Specification" | iki_read +Q -w -W code '"' '"'
-#
-
-Settings Specification:
- The control settings "settings" file follows the FSS-0001 (Extended) format.
-
- Each Object represents a settings property name.
- There is only a distinct set of setting property names (see below).
-
- Each Content represents the values associated with that property.
- Additional restrictions are applied to each Content depending on each specific Object name (see below).
-
- Object Names and their respective Content purpose/restrictions\:
- - name_socket: Must only be a single valid filename, without the directory.
- - path_socket: Must only be a single valid directory.
- - path_socket_prefix: Zero or one string representing a file name.
- - path_socket_suffix: Zero or one string representing a file name.