From: Kevin Day Date: Thu, 31 Mar 2022 03:45:34 +0000 (-0500) Subject: Update: Move the program data into the main for control. X-Git-Tag: 0.5.9~15 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=a5e9cfea7a754cddf5d2aeb996dc0a27e1d4c807;p=fll Update: Move the program data into the main for control. Move parameter initialization and deallocation for FLL program data into main.c. --- diff --git a/level_3/control/c/common.c b/level_3/control/c/common.c index 7408506..846c3d5 100644 --- a/level_3/control/c/common.c +++ b/level_3/control/c/common.c @@ -170,13 +170,6 @@ extern "C" { } #endif // _di_control_payload_type_name_ -#ifndef _di_control_main_delete_ - f_status_t control_main_delete(fll_program_data_t * const main) { - - return fll_program_data_delete(main); - } -#endif // _di_control_main_delete_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/control/c/common.h b/level_3/control/c/common.h index bb61eda..7c86200 100644 --- a/level_3/control/c/common.h +++ b/level_3/control/c/common.h @@ -236,25 +236,6 @@ extern "C" { extern f_string_static_t control_payload_type_name(const uint8_t type); #endif // _di_control_payload_type_name_ -/** - * Deallocate main. - * - * Be sure to call this after executing control_main(). - * - * @param main - * The main program data. - * - * @return - * F_none on success. - * - * Status codes (with error bit) are returned on any problem. - * - * @see control_main() - */ -#ifndef _di_control_main_delete_ - extern f_status_t control_main_delete(fll_program_data_t * const main); -#endif // _di_control_main_delete_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/control/c/control.c b/level_3/control/c/control.c index 4dde4e5..330b2b6 100644 --- a/level_3/control/c/control.c +++ b/level_3/control/c/control.c @@ -56,10 +56,6 @@ extern "C" { f_status_t status = F_none; - f_console_parameter_t parameters[] = control_console_parameter_t_initialize; - main->parameters.array = parameters; - main->parameters.used = control_total_parameters_d; - { f_console_parameter_id_t ids[3] = { control_parameter_no_color_e, control_parameter_light_e, control_parameter_dark_e }; const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 3); @@ -92,8 +88,6 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); } - control_main_delete(main); - return F_status_set_error(status); } } @@ -105,12 +99,7 @@ extern "C" { const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 4); status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(status)) { - control_main_delete(main); - - return status; - } + if (F_status_is_error(status)) return status; if (choice == control_parameter_verbosity_quiet_e) { main->output.verbosity = f_console_verbosity_quiet_e; @@ -139,16 +128,12 @@ extern "C" { if (main->parameters.array[control_parameter_help_e].result == f_console_result_found_e) { control_print_help(main); - control_main_delete(main); - return F_none; } if (main->parameters.array[control_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, control_program_version_s); - control_main_delete(main); - return F_none; } @@ -289,8 +274,6 @@ extern "C" { } } - control_main_delete(main); - return status; } #endif // _di_control_main_ diff --git a/level_3/control/c/control.h b/level_3/control/c/control.h index e36c237..6e066c6 100644 --- a/level_3/control/c/control.h +++ b/level_3/control/c/control.h @@ -75,8 +75,6 @@ extern "C" { /** * Execute main program. * - * Be sure to call control_main_delete() after executing this. - * * If main.signal is non-zero, then this blocks and handles the following signals: * - F_signal_abort * - F_signal_broken_pipe @@ -96,8 +94,6 @@ extern "C" { * F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal. * * Status codes (with error bit) are returned on any problem. - * - * @see control_main_delete() */ #ifndef _di_control_main_ extern f_status_t control_main(fll_program_data_t * const main, const f_console_arguments_t *arguments); diff --git a/level_3/control/c/main.c b/level_3/control/c/main.c index d71ff3b..c475e01 100644 --- a/level_3/control/c/main.c +++ b/level_3/control/c/main.c @@ -5,6 +5,10 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); fll_program_data_t data = fll_program_data_t_initialize; + f_console_parameter_t parameters[] = control_console_parameter_t_initialize; + data.parameters.array = parameters; + data.parameters.used = control_total_parameters_d; + if (f_pipe_input_exists()) { data.process_pipe = F_true; } @@ -13,6 +17,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { const f_status_t status = control_main(&data, &arguments); + fll_program_data_delete(&data); + fll_program_standard_setdown(&data.signal); if (F_status_is_error(status)) return 1;