From: Kevin Day Date: Thu, 2 Mar 2023 03:59:51 +0000 (-0600) Subject: Progress: Begin updating the programs again. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=5843435a9fbb9de312e89948691571b6ca18e8c5;p=fll Progress: Begin updating the programs again. This focuses mostly on utf8. Do some file restructuring. Perform the new f_state_t and f_status_t related changes. --- diff --git a/build/stand_alone/utf8.settings b/build/stand_alone/utf8.settings index 6cfabbb..ebd860f 100644 --- a/build/stand_alone/utf8.settings +++ b/build/stand_alone/utf8.settings @@ -47,8 +47,7 @@ build_sources_program fll/level_2/error.c fll/level_2/error/common.c fll/level_2 build_sources_program fll/level_2/print.c build_sources_program fll/level_2/program.c fll/level_2/program/common.c fll/level_2/program/print.c fll/level_2/private-program.c -build_sources_program program/utf8/common.c program/utf8/print.c program/utf8/utf8.c -build_sources_program program/utf8/private-common.c program/utf8/private-utf8.c program/utf8/private-utf8_bytesequence.c program/utf8/private-utf8_codepoint.c +build_sources_program program/utf8/common.c program/utf8/bytesequence.c program/utf8/codepoint.c program/utf8/print.c program/utf8/process.c program/utf8/utf8.c build_sources_program program/utf8/main.c diff --git a/level_2/fll_execute/c/private-execute.c b/level_2/fll_execute/c/private-execute.c index 50dbe65..58556d3 100644 --- a/level_2/fll_execute/c/private-execute.c +++ b/level_2/fll_execute/c/private-execute.c @@ -85,7 +85,6 @@ extern "C" { if (as.id_groups) { if (setgroups(as.id_groups->used, (const gid_t *) as.id_groups->array) == -1) { - if (parameter && parameter->option & FL_execute_parameter_option_exit_d) { exit(F_execute_group); } @@ -197,9 +196,7 @@ extern "C" { int descriptors[2] = { -1, -1 }; if (as) { - if (pipe(descriptors) == -1) { - return F_status_set_error(F_pipe); - } + if (pipe(descriptors) == -1) return F_status_set_error(F_pipe); } const pid_t id_process = fork(); @@ -232,9 +229,7 @@ extern "C" { // Close the write pipe for the parent when finished writing. close(descriptors[1]); - if (F_status_is_error(status)) { - return status; - } + if (F_status_is_error(status)) return status; } } @@ -253,9 +248,7 @@ extern "C" { // This must explicitly check for 0 (as opposed to checking (!result)). if (result != 0) { - if (WIFEXITED(*((int *) result))) { - return F_none; - } + if (WIFEXITED(*((int *) result))) return F_none; return F_status_set_error(F_failure); } @@ -378,9 +371,7 @@ extern "C" { int descriptors[2] = { -1, -1 }; - if (pipe(descriptors) == -1) { - return F_status_set_error(F_pipe); - } + if (pipe(descriptors) == -1) return F_status_set_error(F_pipe); const pid_t id_process = fork(); @@ -421,9 +412,7 @@ extern "C" { // Close the write pipe for the parent when finished writing. close(descriptors[1]); - if (F_status_is_error(status)) { - return status; - } + if (F_status_is_error(status)) return status; } if (parameter && parameter->option & FL_execute_parameter_option_return_d) { @@ -441,9 +430,7 @@ extern "C" { // This must explicitly check for 0 (as opposed to checking (!result)). if (result != 0) { - if (WIFEXITED(*((int *) result))) { - return F_none; - } + if (WIFEXITED(*((int *) result))) return F_none; return F_status_set_error(F_failure); } diff --git a/level_2/fll_file/c/private-file.c b/level_2/fll_file/c/private-file.c index f459d4f..06d7cb1 100644 --- a/level_2/fll_file/c/private-file.c +++ b/level_2/fll_file/c/private-file.c @@ -13,9 +13,7 @@ extern "C" { status = f_directory_is(path); if (F_status_is_error(status)) return status; - if (status == F_false) { - return f_file_mode_set(path, mode); - } + if (status == F_false) return f_file_mode_set(path, mode); f_directory_listing_t listing = f_directory_listing_t_initialize; @@ -114,9 +112,7 @@ extern "C" { status = f_directory_is(path); if (F_status_is_error(status)) return status; - if (status == F_false) { - return f_file_role_change(path, uid, gid, dereference); - } + if (status == F_false) return f_file_role_change(path, uid, gid, dereference); f_directory_listing_t listing = f_directory_listing_t_initialize; diff --git a/level_2/fll_fss/c/fss.c b/level_2/fll_fss/c/fss.c index d2f2b1f..3d87274 100644 --- a/level_2/fll_fss/c/fss.c +++ b/level_2/fll_fss/c/fss.c @@ -15,9 +15,7 @@ extern "C" { if (buffer.string[range->start]) break; } - if (range->start > range->stop) { - return F_data_not; - } + if (range->start > range->stop) return F_data_not; // The first character must be a '#'. if (buffer.string[range->start] != f_fss_pound_s.string[0]) { @@ -78,13 +76,7 @@ extern "C" { f_status_t status = f_utf_is_whitespace(buffer.string + range->start, (range->stop - range->start) + 1, F_false); - if (F_status_is_error(status)) { - if (F_status_set_fine(status) == F_maybe) { - return F_status_set_error(F_complete_not_utf); - } - - return status; - } + if (F_status_is_error(status)) return (F_status_set_fine(status) == F_maybe) ? F_status_set_error(F_complete_not_utf) : status; if (status == F_false) { @@ -164,21 +156,9 @@ extern "C" { } while (range->start <= range->stop); if (ids) { - if (ids->used) { - if (found_fss) { - return F_found; - } - - return F_maybe; - } - } - else if (id.used) { - if (found_fss) { - return F_found; - } - - return F_maybe; + if (ids->used) return found_fss ? F_found : F_maybe; } + else if (id.used) return found_fss ? F_found : F_maybe; return F_found_not; } @@ -649,6 +629,7 @@ extern "C" { if (status == F_equal_to) { matched = F_true; + break; } } // for diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index 5470f4a..e0cdc1c 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -11,8 +11,7 @@ extern "C" { f_status_t status = F_none; - // Load parameters. - status = f_console_parameter_process(arguments, &main->parameters, 0); + status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); if (F_status_is_error(status)) return; { diff --git a/level_3/byte_dump/c/byte_dump.h b/level_3/byte_dump/c/byte_dump.h index 336abe7..8dc9794 100644 --- a/level_3/byte_dump/c/byte_dump.h +++ b/level_3/byte_dump/c/byte_dump.h @@ -88,7 +88,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -113,19 +113,17 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: fll_program_parameter_process_context(). - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @see f_console_parameter_process() * @see fll_program_parameter_process_context() */ #ifndef _di_byte_dump_setting_load_ - extern void byte_dump_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, byte_dump_setting_t * const setting, f_state_t * const state); + extern void byte_dump_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, byte_dump_setting_t * const setting); #endif // _di_byte_dump_setting_load_ /** @@ -137,7 +135,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/byte_dump/c/common.c b/level_3/byte_dump/c/common.c index 3cdc827..bacafe1 100644 --- a/level_3/byte_dump/c/common.c +++ b/level_3/byte_dump/c/common.c @@ -77,18 +77,17 @@ extern "C" { #endif // _di_byte_dump_setting_delete_ #ifndef _di_byte_dump_setting_load_ - void byte_dump_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, byte_dump_setting_t * const setting) { + void byte_dump_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, byte_dump_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { byte_dump_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); byte_dump_print_line_last_locked(setting, main->error); return; @@ -106,11 +105,11 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { byte_dump_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); byte_dump_print_line_last_locked(setting, main->error); return; @@ -139,11 +138,11 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { byte_dump_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); byte_dump_print_line_last_locked(setting, main->error); return; diff --git a/level_3/byte_dump/c/common.h b/level_3/byte_dump/c/common.h index 1bdc0a8..2022ea0 100644 --- a/level_3/byte_dump/c/common.h +++ b/level_3/byte_dump/c/common.h @@ -410,12 +410,47 @@ extern "C" { #define byte_dump_setting_t_initialize \ { \ byte_dump_main_flag_none_e, \ - f_state_initialize_t, \ + f_state_t_initialize, \ f_string_static_t_initialize, \ f_string_static_t_initialize, \ } #endif // _di_byte_dump_setting_t_ +/** + * 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. + * @param setting + * The main program settings. + * + * This alters setting.state.status: + * F_none on success. + * + * Errors (with error bit) from: f_console_parameter_process(). + * Errors (with error bit) from: f_file_stream_open(). + * Errors (with error bit) from: f_string_dynamics_resize(). + * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_verbosity(). + * @param state + * A state for providing flags and handling interrupts during long running operations. + * + * @see f_console_parameter_process() + * @see f_file_stream_open() + * @see f_string_dynamics_resize() + * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_verbosity() + */ +#ifndef _di_byte_dump_setting_load_ + extern void byte_dump_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, byte_dump_setting_t * const setting); +#endif // _di_byte_dump_setting_load_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/byte_dump/c/main.c b/level_3/byte_dump/c/main.c index 2106bba..d32ca7f 100644 --- a/level_3/byte_dump/c/main.c +++ b/level_3/byte_dump/c/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - byte_dump_setting_load(arguments, state, &data, &setting); + byte_dump_setting_load(arguments, &data, &setting); } byte_dump_main(&data, &setting); diff --git a/level_3/byte_dump/c/print.c b/level_3/byte_dump/c/print.c index 5fedf6e..f4ea201 100644 --- a/level_3/byte_dump/c/print.c +++ b/level_3/byte_dump/c/print.c @@ -81,7 +81,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & byte_dump_main_flag_verify_e) return; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & byte_dump_main_flag_file_to_e) return F_output_not; } @@ -98,7 +98,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & byte_dump_main_flag_verify_e) return; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & byte_dump_main_flag_file_to_e) return F_output_not; } @@ -115,7 +115,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & byte_dump_main_flag_verify_e) return; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & byte_dump_main_flag_file_to_e) return F_output_not; } @@ -132,7 +132,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & byte_dump_main_flag_verify_e) return; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & byte_dump_main_flag_file_to_e) return F_output_not; } diff --git a/level_3/byte_dump/c/print.h b/level_3/byte_dump/c/print.h index 4445115..c62bd3a 100644 --- a/level_3/byte_dump/c/print.h +++ b/level_3/byte_dump/c/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param output * The file to print to. * @param context @@ -43,7 +43,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -65,7 +65,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -87,7 +87,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -109,7 +109,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/control/c/common.c b/level_3/control/c/common.c index 0b50b01..60fdcee 100644 --- a/level_3/control/c/common.c +++ b/level_3/control/c/common.c @@ -180,18 +180,17 @@ extern "C" { #endif // _di_control_setting_delete_ #ifndef _di_control_setting_load_ - void control_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, control_setting_t * const setting) { + void control_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, control_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { control_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); control_print_line_last_locked(setting, main->error); return; @@ -209,11 +208,11 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { control_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); control_print_line_last_locked(setting, main->error); return; @@ -242,11 +241,11 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { control_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); control_print_line_last_locked(setting, main->error); return; diff --git a/level_3/control/c/common.h b/level_3/control/c/common.h index cc3fa40..4bd5d64 100644 --- a/level_3/control/c/common.h +++ b/level_3/control/c/common.h @@ -313,7 +313,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -338,19 +338,17 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: fll_program_parameter_process_context(). - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @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, fll_program_data_t * const main, control_setting_t * const setting, f_state_t * const state); + extern void control_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, control_setting_t * const setting); #endif // _di_control_setting_load_ /** @@ -362,7 +360,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/control/c/control.c b/level_3/control/c/control.c index dfd066e..2f30e3a 100644 --- a/level_3/control/c/control.c +++ b/level_3/control/c/control.c @@ -12,8 +12,7 @@ extern "C" { f_status_t status = F_none; - // Load parameters. - status = f_console_parameter_process(arguments, &main->parameters, 0); + status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); if (F_status_is_error(status)) return; { diff --git a/level_3/control/c/main.c b/level_3/control/c/main.c index be30363..910a490 100644 --- a/level_3/control/c/main.c +++ b/level_3/control/c/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - control_setting_load(arguments, state, &data, &setting); + control_setting_load(arguments, &data, &setting); } control_main(&data, &setting); diff --git a/level_3/control/c/print.c b/level_3/control/c/print.c index a870f20..ed9fac9 100644 --- a/level_3/control/c/print.c +++ b/level_3/control/c/print.c @@ -54,7 +54,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & control_main_flag_verify_e) return; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & control_main_flag_file_to_e) return F_output_not; } @@ -71,7 +71,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & control_main_flag_verify_e) return; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & control_main_flag_file_to_e) return F_output_not; } @@ -88,7 +88,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & control_main_flag_verify_e) return; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & control_main_flag_file_to_e) return F_output_not; } @@ -105,7 +105,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & control_main_flag_verify_e) return; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & control_main_flag_file_to_e) return F_output_not; } diff --git a/level_3/control/c/print.h b/level_3/control/c/print.h index 0eafb80..1ddaab7 100644 --- a/level_3/control/c/print.h +++ b/level_3/control/c/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -40,7 +40,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -62,7 +62,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -84,7 +84,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -106,7 +106,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/controller/c/common.c b/level_3/controller/c/common.c index a73cf7b..3553ee1 100644 --- a/level_3/controller/c/common.c +++ b/level_3/controller/c/common.c @@ -612,18 +612,17 @@ extern "C" { #endif // _di_controller_setting_delete_ #ifndef _di_controller_setting_load_ - void controller_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, controller_setting_t * const setting) { + void controller_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, controller_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { controller_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); controller_print_line_last_locked(setting, main->error); return; @@ -641,11 +640,11 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { controller_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); controller_print_line_last_locked(setting, main->error); return; @@ -674,11 +673,11 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { controller_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); controller_print_line_last_locked(setting, main->error); return; diff --git a/level_3/controller/c/common.h b/level_3/controller/c/common.h index a194952..86df47a 100644 --- a/level_3/controller/c/common.h +++ b/level_3/controller/c/common.h @@ -706,7 +706,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -731,19 +731,17 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: fll_program_parameter_process_context(). - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @see f_console_parameter_process() * @see fll_program_parameter_process_context() */ #ifndef _di_controller_setting_load_ - extern void controller_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, controller_setting_t * const setting, f_state_t * const state); + extern void controller_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, controller_setting_t * const setting); #endif // _di_controller_setting_load_ /** @@ -755,7 +753,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index fe604eb..cf3db5e 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -17,8 +17,7 @@ extern "C" { f_status_t status = F_none; - // Load parameters. - status = f_console_parameter_process(arguments, &main->parameters, 0); + status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); if (F_status_is_error(status)) return; { diff --git a/level_3/controller/c/main.c b/level_3/controller/c/main.c index 5451809..9a81235 100644 --- a/level_3/controller/c/main.c +++ b/level_3/controller/c/main.c @@ -44,9 +44,8 @@ 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); - f_state_t state = f_state_t_initialize; - controller_setting_load(arguments, state, &data, &setting); + controller_setting_load(arguments, &data, &setting); } controller_main(&data, &setting); diff --git a/level_3/controller/c/print.c b/level_3/controller/c/print.c index 2c9f80a..fb5a7c5 100644 --- a/level_3/controller/c/print.c +++ b/level_3/controller/c/print.c @@ -57,7 +57,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & controller_main_flag_verify_e) return; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & controller_main_flag_file_to_e) return F_output_not; } @@ -74,7 +74,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & controller_main_flag_verify_e) return; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & controller_main_flag_file_to_e) return F_output_not; } @@ -91,7 +91,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & controller_main_flag_verify_e) return; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & controller_main_flag_file_to_e) return F_output_not; } @@ -108,7 +108,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & controller_main_flag_verify_e) return; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & controller_main_flag_file_to_e) return F_output_not; } diff --git a/level_3/controller/c/print.h b/level_3/controller/c/print.h index 32a5be2..0705734 100644 --- a/level_3/controller/c/print.h +++ b/level_3/controller/c/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -40,7 +40,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -62,7 +62,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -84,7 +84,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -106,7 +106,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/fake/c/main/build/print-error.h b/level_3/fake/c/main/build/print-error.h index cebac95..0162701 100644 --- a/level_3/fake/c/main/build/print-error.h +++ b/level_3/fake/c/main/build/print-error.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path @@ -44,7 +44,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path @@ -66,7 +66,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param name @@ -91,7 +91,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param mode @@ -115,7 +115,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path diff --git a/level_3/fake/c/main/build/print-verbose.h b/level_3/fake/c/main/build/print-verbose.h index 377d947..da2266c 100644 --- a/level_3/fake/c/main/build/print-verbose.h +++ b/level_3/fake/c/main/build/print-verbose.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param directory diff --git a/level_3/fake/c/main/build/print-warning.h b/level_3/fake/c/main/build/print-warning.h index a879d95..18e06da 100644 --- a/level_3/fake/c/main/build/print-warning.h +++ b/level_3/fake/c/main/build/print-warning.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param symbol_1 @@ -54,7 +54,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param name @@ -84,7 +84,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param name_1 @@ -110,7 +110,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param name @@ -140,7 +140,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param name_1 @@ -166,7 +166,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param name diff --git a/level_3/fake/c/main/build/print.h b/level_3/fake/c/main/build/print.h index 16b654d..bb166dd 100644 --- a/level_3/fake/c/main/build/print.h +++ b/level_3/fake/c/main/build/print.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -42,7 +42,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -62,7 +62,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -82,7 +82,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -102,7 +102,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -122,7 +122,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -142,7 +142,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -162,7 +162,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param from @@ -186,7 +186,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/fake/c/main/common.c b/level_3/fake/c/main/common.c index f6aa6d5..bb9a99f 100644 --- a/level_3/fake/c/main/common.c +++ b/level_3/fake/c/main/common.c @@ -29,7 +29,7 @@ extern "C" { #endif // _di_fake_setting_delete_ #ifndef _di_fake_setting_load_ - void fake_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, fake_setting_t * const setting) { + void fake_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fake_setting_t * const setting) { if (!main || !setting) return; @@ -42,12 +42,11 @@ extern "C" { data.main = main; data.setting = setting; - // Load parameters. - setting->status = f_console_parameter_process(arguments, &main->parameters, state, (void *) &data); + f_console_parameter_process(arguments, &main->parameters, &setting->state, (void *) &data); } - if (F_status_is_error(setting->status)) { - fake_print_error(setting, main->error, setting->status, macro_fake_f(f_console_parameter_process)); + if (F_status_is_error(setting->state.status)) { + fake_print_error(setting, main->error, setting->state.status, macro_fake_f(f_console_parameter_process)); return; } @@ -64,10 +63,10 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { - fake_print_error(setting, main->error, setting->status, macro_fake_f(fll_program_parameter_process_context)); + if (F_status_is_error(setting->state.status)) { + fake_print_error(setting, main->error, setting->state.status, macro_fake_f(fll_program_parameter_process_context)); return; } @@ -95,10 +94,10 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { - fake_print_error(setting, main->error, setting->status, macro_fake_f(fll_program_parameter_process_verbosity)); + if (F_status_is_error(setting->state.status)) { + fake_print_error(setting, main->error, setting->state.status, macro_fake_f(fll_program_parameter_process_verbosity)); return; } @@ -243,7 +242,7 @@ extern "C" { for (i = 0; i < 9; ++i) { if ((main->parameters.array[parameters[i]].result & f_console_result_found_e) && !(main->parameters.array[parameters[i]].result & f_console_result_value_e)) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); if (main->error.verbosity > f_console_verbosity_quiet_e) { fake_print_line_first_locked(setting, main->error); @@ -261,20 +260,20 @@ extern "C" { if (parameters[i] == fake_parameter_process_e) { for (j = 0; j < main->parameters.arguments.array[index].used; ++j) { - setting->status = f_utf_is_word_dash_plus(main->parameters.arguments.array[index].string + j, main->parameters.arguments.array[index].used - j, F_false); + setting->state.status = f_utf_is_word_dash_plus(main->parameters.arguments.array[index].string + j, main->parameters.arguments.array[index].used - j, F_false); // @todo fix this to print an error about the actual invalid character so that it can be investigated. - if (F_status_is_error(setting->status)) { - if (fake_print_error_fallback(setting, main->error, setting->status, macro_fake_f(f_utf_is_word_dash_plus)) == F_false) { + if (F_status_is_error(setting->state.status)) { + if (fake_print_error_fallback(setting, main->error, setting->state.status, macro_fake_f(f_utf_is_word_dash_plus)) == F_false) { fll_program_print_error_parameter_process(main->error, f_console_symbol_long_normal_s, names[i]); } return; } - if (setting->status == F_false) { - setting->status = F_status_set_error(F_parameter); + if (setting->state.status == F_false) { + setting->state.status = F_status_set_error(F_parameter); fake_print_error_parameter_not_word(setting, main->error, f_console_symbol_long_normal_s, names[i], main->parameters.arguments.array[index]); @@ -284,13 +283,13 @@ extern "C" { } if (cleanups[i]) { - setting->status = f_path_directory_cleanup(main->parameters.arguments.array[index], variable[i]); + setting->state.status = f_path_directory_cleanup(main->parameters.arguments.array[index], variable[i]); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { if (main->error.verbosity > f_console_verbosity_quiet_e) { fake_print_line_first_locked(setting, main->error); - if (fake_print_error_fallback(setting, main->error, setting->status, macro_fake_f(f_path_directory_cleanup)) == F_false) { + if (fake_print_error_fallback(setting, main->error, setting->state.status, macro_fake_f(f_path_directory_cleanup)) == F_false) { fll_program_print_error_parameter_process(main->error, f_console_symbol_long_normal_s, names[i]); } } @@ -302,10 +301,10 @@ extern "C" { // De-allocate memory before replacing it with a statically allocated string. if (variable[i]->size) { - setting->status = f_string_dynamic_resize(0, variable[i]); + setting->state.status = f_string_dynamic_resize(0, variable[i]); - if (F_status_is_error(setting->status)) { - fake_print_error(setting, main->error, setting->status, macro_fake_f(f_string_dynamic_resize)); + if (F_status_is_error(setting->state.status)) { + fake_print_error(setting, main->error, setting->state.status, macro_fake_f(f_string_dynamic_resize)); return; } @@ -317,24 +316,24 @@ extern "C" { } if (!variable[i]->used) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fake_print_error_parameter_not_empty(setting, main->error, f_console_symbol_long_normal_s, names[i], main->parameters.arguments.array[index]); return; } - setting->status = F_none; + setting->state.status = F_none; } } else { // De-allocate memory before replacing it with a statically allocated string. if (variable[i]->size) { - setting->status = f_string_dynamic_resize(0, variable[i]); + setting->state.status = f_string_dynamic_resize(0, variable[i]); - if (F_status_is_error(setting->status)) { - fake_print_error(setting, main->error, setting->status, macro_fake_f(f_string_dynamic_resize)); + if (F_status_is_error(setting->state.status)) { + fake_print_error(setting, main->error, setting->state.status, macro_fake_f(f_string_dynamic_resize)); return; } @@ -368,7 +367,7 @@ extern "C" { for (i = 0; i < 2; ++i) { if ((main->parameters.array[parameters[i]].result & f_console_result_found_e) && !(main->parameters.array[parameters[i]].result & f_console_result_value_e)) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); if (main->error.verbosity > f_console_verbosity_quiet_e) { fake_print_line_first_locked(setting, main->error); @@ -380,13 +379,13 @@ extern "C" { } if (main->parameters.array[parameters[i]].result & f_console_result_value_e) { - setting->status = fll_program_parameter_additional_rip(main->parameters.arguments.array, main->parameters.array[parameters[i]].values, variable[i]); + setting->state.status = fll_program_parameter_additional_rip(main->parameters.arguments.array, main->parameters.array[parameters[i]].values, variable[i]); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { if (main->error.verbosity > f_console_verbosity_quiet_e) { fake_print_line_first_locked(setting, main->error); - if (fake_print_error_fallback(setting, main->error, setting->status, macro_fake_f(fll_program_parameter_additional_rip)) == F_false) { + if (fake_print_error_fallback(setting, main->error, setting->state.status, macro_fake_f(fll_program_parameter_additional_rip)) == F_false) { fll_program_print_error_parameter_process(main->error, f_console_symbol_long_normal_s, names[i]); } } @@ -399,20 +398,20 @@ extern "C" { width_max = main->parameters.arguments.array[i].used - j; - setting->status = f_utf_is_word_dash_plus(main->parameters.arguments.array[i].string + j, width_max, F_false); + setting->state.status = f_utf_is_word_dash_plus(main->parameters.arguments.array[i].string + j, width_max, F_false); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { // @todo fix this to print an error about the actual invalid character so that it can be investigated. - if (fake_print_error_fallback(setting, main->error, setting->status, macro_fake_f(f_utf_is_word_dash_plus)) == F_false) { + if (fake_print_error_fallback(setting, main->error, setting->state.status, macro_fake_f(f_utf_is_word_dash_plus)) == F_false) { fll_program_print_error_parameter_process(main->error, f_console_symbol_long_normal_s, names[i]); } return; } - if (setting->status == F_false) { - setting->status = F_status_set_error(F_parameter); + if (setting->state.status == F_false) { + setting->state.status = F_status_set_error(F_parameter); fake_print_error_parameter_not_word(setting, main->error, f_console_symbol_long_normal_s, names[i], main->parameters.arguments.array[i]); @@ -432,10 +431,10 @@ extern "C" { setting->flag |= fake_main_flag_operation_make_e; setting->flag -= setting->flag & fake_main_flag_operation_e; - setting->status = f_uint8s_increase_by(1, &setting->operations); + setting->state.status = f_uint8s_increase_by(1, &setting->operations); - if (F_status_is_error(setting->status)) { - fake_print_error(setting, main->error, setting->status, macro_fake_f(f_uint8s_increase_by)); + if (F_status_is_error(setting->state.status)) { + fake_print_error(setting, main->error, setting->state.status, macro_fake_f(f_uint8s_increase_by)); return; } diff --git a/level_3/fake/c/main/common.h b/level_3/fake/c/main/common.h index 20470d7..10da11d 100644 --- a/level_3/fake/c/main/common.h +++ b/level_3/fake/c/main/common.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -47,19 +47,17 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: fll_program_parameter_process_context(). - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @see f_console_parameter_process() * @see fll_program_parameter_process_context() */ #ifndef _di_fake_setting_load_ - extern void fake_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fake_setting_t * const setting, f_state_t * const state); + extern void fake_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fake_setting_t * const setting); #endif // _di_fake_setting_load_ /** @@ -95,7 +93,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fake/c/main/fake.c b/level_3/fake/c/main/fake.c index 8bc3e66..eebab5c 100644 --- a/level_3/fake/c/main/fake.c +++ b/level_3/fake/c/main/fake.c @@ -16,13 +16,13 @@ extern "C" { if (!main || !setting) return; - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fake_print_line_last_locked(setting, main->error); return; } - setting->status = F_none; + setting->state.status = F_none; if (setting->flag & fake_main_flag_help_e) { fake_print_help(setting, main->message); @@ -43,7 +43,7 @@ extern "C" { } if ((setting->flag & fake_main_flag_operation_build_e) && (setting->flag & fake_main_flag_operation_make_e)) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fake_print_error_parameter_operation_not_with(setting, main->error, fake_other_operation_build_s, fake_other_operation_make_s); @@ -54,9 +54,9 @@ extern "C" { data.main = main; data.setting = setting; - setting->status = fake_path_generate(&data); + setting->state.status = fake_path_generate(&data); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fake_data_delete(&data); return; @@ -65,15 +65,15 @@ extern "C" { if ((main->pipe & fll_program_data_pipe_input_e) && !(data.setting->flag & fake_main_flag_operation_e)) { data.file_data_build_fakefile.used = 0; - setting->status = f_string_dynamic_append(f_string_ascii_minus_s, &data.file_data_build_fakefile); + setting->state.status = f_string_dynamic_append(f_string_ascii_minus_s, &data.file_data_build_fakefile); - if (F_status_is_error(setting->status)) { - fake_print_error(setting, main->error, setting->status, macro_fake_f(f_string_dynamic_append)); + if (F_status_is_error(setting->state.status)) { + fake_print_error(setting, main->error, setting->state.status, macro_fake_f(f_string_dynamic_append)); } else { setting->fakefile.used = 0; - setting->status = f_string_dynamic_append(f_string_ascii_minus_s, &setting->fakefile); + setting->state.status = f_string_dynamic_append(f_string_ascii_minus_s, &setting->fakefile); } } @@ -95,25 +95,25 @@ extern "C" { if (has_clean) { data.operation = setting->operations.array[i]; - setting->status = fake_validate_parameter_paths(&data); + setting->state.status = fake_validate_parameter_paths(&data); - if (F_status_is_error_not(setting->status) && !(main->pipe & fll_program_data_pipe_input_e)) { - setting->status = f_file_is( + if (F_status_is_error_not(setting->state.status) && !(main->pipe & fll_program_data_pipe_input_e)) { + setting->state.status = f_file_is( setting->operations.array[i] == fake_operation_build_e ? data.file_data_build_settings : data.file_data_build_fakefile, F_file_type_regular_d, F_false ); - if (setting->status == F_false) { - setting->status = F_status_set_error(F_file_not); + if (setting->state.status == F_false) { + setting->state.status = F_status_set_error(F_file_not); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fake_print_error_file( setting, main->error, - F_status_set_fine(setting->status), + F_status_set_fine(setting->state.status), macro_fake_f(f_file_is), setting->operations.array[i] == fake_operation_build_e ? data.file_data_build_settings @@ -132,7 +132,7 @@ extern "C" { if (fll_program_standard_signal_received(main)) { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); break; } @@ -151,45 +151,45 @@ extern "C" { if (data.operation == fake_operation_build_e) { if (check_paths) { - setting->status = fake_validate_parameter_paths(&data); + setting->state.status = fake_validate_parameter_paths(&data); check_paths = F_false; } - if (F_status_is_error_not(setting->status)) { - setting->status = fake_build_operate(&data, 0, main->pipe & fll_program_data_pipe_input_e); + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = fake_build_operate(&data, 0, main->pipe & fll_program_data_pipe_input_e); } } else if (data.operation == fake_operation_clean_e) { - setting->status = fake_clean_operate(&data); + setting->state.status = fake_clean_operate(&data); // Reset in case next operation needs files. check_paths = F_true; } else if (data.operation == fake_operation_make_e) { if (check_paths) { - setting->status = fake_validate_parameter_paths(&data); + setting->state.status = fake_validate_parameter_paths(&data); check_paths = F_false; } - if (F_status_is_error_not(setting->status)) { - setting->status = fake_make_operate(&data); - if (setting->status == F_child) break; + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = fake_make_operate(&data); + if (setting->state.status == F_child) break; } } else if (data.operation == fake_operation_skeleton_e) { - setting->status = fake_skeleton_operate(&data); + setting->state.status = fake_skeleton_operate(&data); // Skeleton is supposed to guarantee these. check_paths = F_false; } - if (setting->status == F_child) break; + if (setting->state.status == F_child) break; if (!((++main->signal_check) % fake_signal_check_short_d)) { if (fll_program_standard_signal_received(main)) { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); break; } @@ -197,13 +197,13 @@ extern "C" { main->signal_check = 0; } - if (F_status_is_error(setting->status)) break; + if (F_status_is_error(setting->state.status)) break; } // for } } - if (F_status_is_error(setting->status)) { - if (F_status_set_fine(setting->status) == F_interrupt) { + if (F_status_is_error(setting->state.status)) { + if (F_status_set_fine(setting->state.status) == F_interrupt) { fake_print_operation_cancelled(setting, main->message, data.operation); } else { @@ -212,12 +212,12 @@ extern "C" { fake_print_line_last_locked(setting, main->error); } - else if (setting->status != F_child) { - if (F_status_is_error_not(setting->status)) { + else if (setting->state.status != F_child) { + if (F_status_is_error_not(setting->state.status)) { fake_print_operation_all_complete(setting, main->message); } - if (setting->status != F_interrupt) { + if (setting->state.status != F_interrupt) { fake_print_line_last_locked(setting, main->message); } } diff --git a/level_3/fake/c/main/fake.h b/level_3/fake/c/main/fake.h index a14503e..fe70009 100644 --- a/level_3/fake/c/main/fake.h +++ b/level_3/fake/c/main/fake.h @@ -130,7 +130,7 @@ extern "C" { * * This is used by the main thread and should not be modified within individual threads. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_child if this is a child process returning. * diff --git a/level_3/fake/c/main/main.c b/level_3/fake/c/main/main.c index f7070c0..358c1bd 100644 --- a/level_3/fake/c/main/main.c +++ b/level_3/fake/c/main/main.c @@ -24,9 +24,8 @@ 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); - f_state_t state = f_state_t_initialize; - fake_setting_load(arguments, state, &data, &setting); + fake_setting_load(arguments, &data, &setting); } fake_main(&data, &setting); diff --git a/level_3/fake/c/main/make/print-error.h b/level_3/fake/c/main/make/print-error.h index dc16a63..f80ac6c 100644 --- a/level_3/fake/c/main/make/print-error.h +++ b/level_3/fake/c/main/make/print-error.h @@ -25,7 +25,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param name @@ -46,7 +46,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param action @@ -69,7 +69,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param name @@ -90,7 +90,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param fakefile @@ -113,7 +113,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -132,7 +132,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param content @@ -155,7 +155,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -174,7 +174,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param type @@ -197,7 +197,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param action @@ -218,7 +218,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param message @@ -239,7 +239,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -258,7 +258,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -277,7 +277,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -296,7 +296,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param operation @@ -317,7 +317,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param buffer * The buffer containing the range to use. * @param range @@ -338,7 +338,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param name @@ -359,7 +359,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param number @@ -384,7 +384,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -403,7 +403,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param return_code @@ -424,7 +424,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param program @@ -445,7 +445,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param name @@ -466,7 +466,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -485,7 +485,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param number @@ -506,7 +506,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param type diff --git a/level_3/fake/c/main/make/print-verbose.h b/level_3/fake/c/main/make/print-verbose.h index e79cfcd..80d2e02 100644 --- a/level_3/fake/c/main/make/print-verbose.h +++ b/level_3/fake/c/main/make/print-verbose.h @@ -23,7 +23,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param arguments @@ -45,7 +45,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param clone @@ -71,7 +71,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param variable @@ -92,7 +92,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param path @@ -113,7 +113,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param arguments @@ -135,7 +135,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param is_directory @@ -159,7 +159,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param program @@ -182,7 +182,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param fail @@ -203,7 +203,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param path @@ -226,7 +226,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param path @@ -247,7 +247,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param what @@ -274,7 +274,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param source @@ -297,7 +297,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param path diff --git a/level_3/fake/c/main/make/print-warning.h b/level_3/fake/c/main/make/print-warning.h index b46b7e5..f14299c 100644 --- a/level_3/fake/c/main/make/print-warning.h +++ b/level_3/fake/c/main/make/print-warning.h @@ -23,7 +23,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param path @@ -46,7 +46,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param name @@ -67,7 +67,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param name @@ -88,7 +88,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param fakefile @@ -109,7 +109,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param file @@ -130,7 +130,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param fakefile @@ -157,7 +157,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param fakefile @@ -186,7 +186,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param fakefile @@ -209,7 +209,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param fakefile diff --git a/level_3/fake/c/main/make/print.h b/level_3/fake/c/main/make/print.h index e1c1389..c89ad5f 100644 --- a/level_3/fake/c/main/make/print.h +++ b/level_3/fake/c/main/make/print.h @@ -23,7 +23,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param fakefile @@ -44,7 +44,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param buffer diff --git a/level_3/fake/c/main/print-error.h b/level_3/fake/c/main/print-error.h index 9de04aa..fdd22e8 100644 --- a/level_3/fake/c/main/print-error.h +++ b/level_3/fake/c/main/print-error.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param status @@ -51,7 +51,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param index @@ -73,7 +73,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param status @@ -115,7 +115,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param before @@ -153,7 +153,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param operation @@ -180,7 +180,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path @@ -202,7 +202,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param operation @@ -228,7 +228,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param script @@ -250,7 +250,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param status @@ -278,7 +278,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param status * The status to use. * This is provided, ignoring setting.status, for thread-safety reasons. @@ -309,7 +309,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path @@ -331,7 +331,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param status @@ -365,7 +365,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param status * The status to use. * This is provided, ignoring setting.status, for thread-safety reasons. @@ -396,7 +396,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param status @@ -434,7 +434,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param status @@ -468,7 +468,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param group @@ -490,7 +490,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param mode @@ -512,7 +512,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param number @@ -737,7 +737,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param symbol @@ -763,7 +763,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param symbol @@ -793,7 +793,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param operation_1 @@ -867,7 +867,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param user diff --git a/level_3/fake/c/main/print-verbose.h b/level_3/fake/c/main/print-verbose.h index e838d70..44d7d66 100644 --- a/level_3/fake/c/main/print-verbose.h +++ b/level_3/fake/c/main/print-verbose.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param source @@ -46,7 +46,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param source @@ -70,7 +70,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path @@ -92,7 +92,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path @@ -114,7 +114,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path @@ -136,7 +136,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path @@ -158,7 +158,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path @@ -180,7 +180,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path @@ -202,7 +202,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path @@ -224,7 +224,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param source diff --git a/level_3/fake/c/main/print-warning.h b/level_3/fake/c/main/print-warning.h index b2d6a9f..459b3b8 100644 --- a/level_3/fake/c/main/print-warning.h +++ b/level_3/fake/c/main/print-warning.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param path diff --git a/level_3/fake/c/main/print.h b/level_3/fake/c/main/print.h index 25f452a..c82cb5d 100644 --- a/level_3/fake/c/main/print.h +++ b/level_3/fake/c/main/print.h @@ -26,7 +26,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param message @@ -52,7 +52,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param before @@ -86,7 +86,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param before @@ -120,7 +120,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param before @@ -157,7 +157,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param before @@ -212,7 +212,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param before @@ -246,7 +246,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param before @@ -280,7 +280,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -300,7 +300,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -322,7 +322,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param message @@ -346,7 +346,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -370,7 +370,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -392,7 +392,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -414,7 +414,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -432,7 +432,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -450,7 +450,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param operation @@ -474,7 +474,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param message @@ -494,7 +494,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param message @@ -516,7 +516,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param before @@ -544,7 +544,7 @@ extern "C" { * The main program settings. * (Must be of type fake_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @param before diff --git a/level_3/firewall/c/common.c b/level_3/firewall/c/common.c index aff8ddb..cb02aae 100644 --- a/level_3/firewall/c/common.c +++ b/level_3/firewall/c/common.c @@ -119,12 +119,11 @@ extern "C" { setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(state, arguments, &main->parameters, 0); + setting->state.status = f_console_parameter_process(state, arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { firewall_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); firewall_print_line_last_locked(setting, main->error); return; @@ -142,11 +141,11 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { firewall_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); firewall_print_line_last_locked(setting, main->error); return; @@ -175,11 +174,11 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { firewall_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); firewall_print_line_last_locked(setting, main->error); return; diff --git a/level_3/firewall/c/common.h b/level_3/firewall/c/common.h index cc7dfdd..e7e351b 100644 --- a/level_3/firewall/c/common.h +++ b/level_3/firewall/c/common.h @@ -475,7 +475,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -500,19 +500,17 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: fll_program_parameter_process_context(). - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @see f_console_parameter_process() * @see fll_program_parameter_process_context() */ #ifndef _di_firewall_setting_load_ - extern void firewall_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, firewall_setting_t * const setting, f_state_t * const state); + extern void firewall_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, firewall_setting_t * const setting); #endif // _di_firewall_setting_load_ /** @@ -524,7 +522,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index a7e9c44..916da21 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -19,8 +19,7 @@ extern "C" { main->child = 0; - // Load parameters. - status = f_console_parameter_process(arguments, &main->parameters, 0); + status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); if (F_status_is_error(status)) return; { diff --git a/level_3/firewall/c/main.c b/level_3/firewall/c/main.c index 2d41d0d..09a0c72 100644 --- a/level_3/firewall/c/main.c +++ b/level_3/firewall/c/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - firewall_setting_load(arguments, state, &data, &setting); + firewall_setting_load(arguments, &data, &setting); } firewall_main(&data, &setting); diff --git a/level_3/firewall/c/print.c b/level_3/firewall/c/print.c index e8c6ac7..cce2c5a 100644 --- a/level_3/firewall/c/print.c +++ b/level_3/firewall/c/print.c @@ -42,7 +42,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -57,7 +57,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -72,7 +72,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -87,7 +87,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } diff --git a/level_3/firewall/c/print.h b/level_3/firewall/c/print.h index 042b5d2..10b85d8 100644 --- a/level_3/firewall/c/print.h +++ b/level_3/firewall/c/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -39,7 +39,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -61,7 +61,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -83,7 +83,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -105,7 +105,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/fss_basic_list_read/c/common.c b/level_3/fss_basic_list_read/c/common.c index b5fa042..fbb4899 100644 --- a/level_3/fss_basic_list_read/c/common.c +++ b/level_3/fss_basic_list_read/c/common.c @@ -71,18 +71,17 @@ extern "C" { #endif // _di_fss_basic_list_read_setting_delete_ #ifndef _di_fss_basic_list_read_setting_load_ - void fss_basic_list_read_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, fss_basic_list_read_setting_t * const setting) { + void fss_basic_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_basic_list_read_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_basic_list_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); fss_basic_list_read_print_line_last_locked(setting, main->error); return; @@ -100,11 +99,11 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_basic_list_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); fss_basic_list_read_print_line_last_locked(setting, main->error); return; @@ -133,11 +132,11 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_basic_list_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); fss_basic_list_read_print_line_last_locked(setting, main->error); return; diff --git a/level_3/fss_basic_list_read/c/common.h b/level_3/fss_basic_list_read/c/common.h index 11761f3..dfb9ade 100644 --- a/level_3/fss_basic_list_read/c/common.h +++ b/level_3/fss_basic_list_read/c/common.h @@ -375,7 +375,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -400,19 +400,17 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: fll_program_parameter_process_context(). - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @see f_console_parameter_process() * @see fll_program_parameter_process_context() */ #ifndef _di_fss_basic_list_read_setting_load_ - extern void fss_basic_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_basic_list_read_setting_t * const setting, f_state_t * const state); + extern void fss_basic_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_basic_list_read_setting_t * const setting); #endif // _di_fss_basic_list_read_setting_load_ /** @@ -424,7 +422,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index 6e59419..901ae71 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -12,8 +12,7 @@ extern "C" { f_status_t status = F_none; - // Load parameters. - status = f_console_parameter_process(arguments, &main->parameters, 0); + status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); if (F_status_is_error(status)) return; { diff --git a/level_3/fss_basic_list_read/c/main.c b/level_3/fss_basic_list_read/c/main.c index 342a8a1..f4f6dbc 100644 --- a/level_3/fss_basic_list_read/c/main.c +++ b/level_3/fss_basic_list_read/c/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - fss_basic_list_read_setting_load(arguments, state, &data, &setting); + fss_basic_list_read_setting_load(arguments, &data, &setting); } fss_basic_list_read_main(&data, &setting); diff --git a/level_3/fss_basic_list_read/c/print.c b/level_3/fss_basic_list_read/c/print.c index 636c9d3..3058f51 100644 --- a/level_3/fss_basic_list_read/c/print.c +++ b/level_3/fss_basic_list_read/c/print.c @@ -120,7 +120,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -135,7 +135,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -150,7 +150,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -165,7 +165,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } diff --git a/level_3/fss_basic_list_read/c/print.h b/level_3/fss_basic_list_read/c/print.h index f9c92fd..391d06c 100644 --- a/level_3/fss_basic_list_read/c/print.h +++ b/level_3/fss_basic_list_read/c/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -39,7 +39,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -61,7 +61,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -83,7 +83,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -105,7 +105,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/fss_basic_read/c/common.c b/level_3/fss_basic_read/c/common.c index b48b7c6..aacee28 100644 --- a/level_3/fss_basic_read/c/common.c +++ b/level_3/fss_basic_read/c/common.c @@ -70,18 +70,17 @@ extern "C" { #endif // _di_fss_basic_read_setting_delete_ #ifndef _di_fss_basic_read_setting_load_ - void fss_basic_read_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, fss_basic_read_setting_t * const setting) { + void fss_basic_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_basic_read_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_basic_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); fss_basic_read_print_line_last_locked(setting, main->error); return; @@ -99,11 +98,11 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_basic_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); fss_basic_read_print_line_last_locked(setting, main->error); return; @@ -132,11 +131,11 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_basic_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); fss_basic_read_print_line_last_locked(setting, main->error); return; diff --git a/level_3/fss_basic_read/c/common.h b/level_3/fss_basic_read/c/common.h index 7002d4f..f74d5ec 100644 --- a/level_3/fss_basic_read/c/common.h +++ b/level_3/fss_basic_read/c/common.h @@ -373,7 +373,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -398,19 +398,17 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: fll_program_parameter_process_context(). - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @see f_console_parameter_process() * @see fll_program_parameter_process_context() */ #ifndef _di_fss_basic_read_setting_load_ - extern void fss_basic_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_basic_read_setting_t * const setting, f_state_t * const state); + extern void fss_basic_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_basic_read_setting_t * const setting); #endif // _di_fss_basic_read_setting_load_ /** @@ -422,7 +420,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 648b439..ce5c222 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -12,8 +12,7 @@ extern "C" { f_status_t status = F_none; - // Load parameters. - status = f_console_parameter_process(arguments, &main->parameters, 0); + status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); if (F_status_is_error(status)) return; { diff --git a/level_3/fss_basic_read/c/fss_basic_read.h b/level_3/fss_basic_read/c/fss_basic_read.h index eb30e3e..7ce305d 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.h +++ b/level_3/fss_basic_read/c/fss_basic_read.h @@ -71,7 +71,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_true on success when performing verification and verify passed. * F_false on success when performing verification and verify failed. diff --git a/level_3/fss_basic_read/c/main.c b/level_3/fss_basic_read/c/main.c index 829bea2..33b3e58 100644 --- a/level_3/fss_basic_read/c/main.c +++ b/level_3/fss_basic_read/c/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - fss_basic_read_setting_load(arguments, state, &data, &setting); + fss_basic_read_setting_load(arguments, &data, &setting); } fss_basic_read_main(&data, &setting); diff --git a/level_3/fss_basic_read/c/print.c b/level_3/fss_basic_read/c/print.c index 08105c4..706cd36 100644 --- a/level_3/fss_basic_read/c/print.c +++ b/level_3/fss_basic_read/c/print.c @@ -120,7 +120,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -135,7 +135,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -150,7 +150,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -165,7 +165,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } diff --git a/level_3/fss_basic_read/c/print.h b/level_3/fss_basic_read/c/print.h index 1001467..eb2920e 100644 --- a/level_3/fss_basic_read/c/print.h +++ b/level_3/fss_basic_read/c/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -39,7 +39,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -61,7 +61,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -83,7 +83,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -105,7 +105,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/fss_embedded_list_read/c/common.c b/level_3/fss_embedded_list_read/c/common.c index 0e254f6..0fc4351 100644 --- a/level_3/fss_embedded_list_read/c/common.c +++ b/level_3/fss_embedded_list_read/c/common.c @@ -69,18 +69,17 @@ extern "C" { #endif // _di_fss_embedded_list_read_setting_delete_ #ifndef _di_fss_embedded_list_read_setting_load_ - void fss_embedded_list_read_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, fss_embedded_list_read_setting_t * const setting) { + void fss_embedded_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_embedded_list_read_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_embedded_list_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); fss_embedded_list_read_print_line_last_locked(setting, main->error); return; @@ -98,11 +97,11 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_embedded_list_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); fss_embedded_list_read_print_line_last_locked(setting, main->error); return; @@ -131,11 +130,11 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_embedded_list_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); fss_embedded_list_read_print_line_last_locked(setting, main->error); return; diff --git a/level_3/fss_embedded_list_read/c/common.h b/level_3/fss_embedded_list_read/c/common.h index 2b767ee..4784a6e 100644 --- a/level_3/fss_embedded_list_read/c/common.h +++ b/level_3/fss_embedded_list_read/c/common.h @@ -356,7 +356,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -381,19 +381,17 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: fll_program_parameter_process_context(). - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @see f_console_parameter_process() * @see fll_program_parameter_process_context() */ #ifndef _di_fss_embedded_list_read_setting_load_ - extern void fss_embedded_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_embedded_list_read_setting_t * const setting, f_state_t * const state); + extern void fss_embedded_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_embedded_list_read_setting_t * const setting); #endif // _di_fss_embedded_list_read_setting_load_ /** @@ -405,7 +403,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c index 7823559..f7015aa 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c @@ -12,8 +12,7 @@ extern "C" { f_status_t status = F_none; - // Load parameters. - status = f_console_parameter_process(arguments, &main->parameters, 0); + status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); if (F_status_is_error(status)) return; { diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h index d203715..8d59c0c 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h @@ -71,7 +71,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_true on success when performing verification and verify passed. * F_false on success when performing verification and verify failed. diff --git a/level_3/fss_embedded_list_read/c/main.c b/level_3/fss_embedded_list_read/c/main.c index a35b5aa..db1288b 100644 --- a/level_3/fss_embedded_list_read/c/main.c +++ b/level_3/fss_embedded_list_read/c/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - fss_embedded_list_read_setting_load(arguments, state, &data, &setting); + fss_embedded_list_read_setting_load(arguments, &data, &setting); } fss_embedded_list_read_main(&data, &setting); diff --git a/level_3/fss_embedded_list_read/c/print.c b/level_3/fss_embedded_list_read/c/print.c index 4ecb7e3..d8d3f4d 100644 --- a/level_3/fss_embedded_list_read/c/print.c +++ b/level_3/fss_embedded_list_read/c/print.c @@ -119,7 +119,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -134,7 +134,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -149,7 +149,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -164,7 +164,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } diff --git a/level_3/fss_embedded_list_read/c/print.h b/level_3/fss_embedded_list_read/c/print.h index cc6a0ad..88280b5 100644 --- a/level_3/fss_embedded_list_read/c/print.h +++ b/level_3/fss_embedded_list_read/c/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -39,7 +39,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -61,7 +61,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -83,7 +83,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -105,7 +105,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/fss_extended_list_read/c/common.c b/level_3/fss_extended_list_read/c/common.c index a024598..1daf721 100644 --- a/level_3/fss_extended_list_read/c/common.c +++ b/level_3/fss_extended_list_read/c/common.c @@ -77,18 +77,17 @@ extern "C" { #endif // _di_fss_extended_list_read_setting_delete_ #ifndef _di_fss_extended_list_read_setting_load_ - void fss_extended_list_read_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, fss_extended_list_read_setting_t * const setting) { + void fss_extended_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_extended_list_read_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_extended_list_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); fss_extended_list_read_print_line_last_locked(setting, main->error); return; @@ -106,11 +105,11 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_extended_list_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); fss_extended_list_read_print_line_last_locked(setting, main->error); return; @@ -139,11 +138,11 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_extended_list_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); fss_extended_list_read_print_line_last_locked(setting, main->error); return; diff --git a/level_3/fss_extended_list_read/c/common.h b/level_3/fss_extended_list_read/c/common.h index 4cf95d3..2a237d9 100644 --- a/level_3/fss_extended_list_read/c/common.h +++ b/level_3/fss_extended_list_read/c/common.h @@ -390,7 +390,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -410,14 +410,12 @@ extern "C" { * * @param arguments * The parameters passed to the process (often referred to as command line arguments). - * @param state - * A state for providing flags and handling interrupts during long running operations. * @param main * The main program data. * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). @@ -427,7 +425,7 @@ extern "C" { * @see fll_program_parameter_process_context() */ #ifndef _di_fss_extended_list_read_setting_load_ - extern void fss_extended_list_read_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, fss_extended_list_read_setting_t * const setting); + extern void fss_extended_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_extended_list_read_setting_t * const setting); #endif // _di_fss_extended_list_read_setting_load_ /** @@ -439,7 +437,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index e570dd7..777871f 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -12,8 +12,7 @@ extern "C" { f_status_t status = F_none; - // Load parameters. - status = f_console_parameter_process(arguments, &main->parameters, 0); + status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); if (F_status_is_error(status)) return; { diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.h b/level_3/fss_extended_list_read/c/fss_extended_list_read.h index e77afb9..b0fb05e 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.h +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.h @@ -71,7 +71,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_true on success when performing verification and verify passed. * F_false on success when performing verification and verify failed. diff --git a/level_3/fss_extended_list_read/c/main.c b/level_3/fss_extended_list_read/c/main.c index 1c384e7..aff8ca9 100644 --- a/level_3/fss_extended_list_read/c/main.c +++ b/level_3/fss_extended_list_read/c/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - fss_extended_list_read_setting_load(arguments, state, &data, &setting); + fss_extended_list_read_setting_load(arguments, &data, &setting); } fss_extended_list_read_main(&data, &setting); diff --git a/level_3/fss_extended_list_read/c/print.c b/level_3/fss_extended_list_read/c/print.c index f50a50c..4e0f81c 100644 --- a/level_3/fss_extended_list_read/c/print.c +++ b/level_3/fss_extended_list_read/c/print.c @@ -120,7 +120,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -135,7 +135,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -150,7 +150,7 @@ extern "C" { if (!setting || print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - if (!F_status_is_error(setting->status)) { + if (!F_status_is_error(setting->state.status)) { if (print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & (fss_extended_list_read_main_flag_verify_e | fss_extended_list_read_main_flag_file_to_e)) return F_output_not; } @@ -166,7 +166,7 @@ extern "C" { if (!setting || print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - if (!F_status_is_error(setting->status)) { + if (!F_status_is_error(setting->state.status)) { if (print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & (fss_extended_list_read_main_flag_verify_e | fss_extended_list_read_main_flag_file_to_e)) return F_output_not; } diff --git a/level_3/fss_extended_list_read/c/print.h b/level_3/fss_extended_list_read/c/print.h index 8293e4b..3fdc8a5 100644 --- a/level_3/fss_extended_list_read/c/print.h +++ b/level_3/fss_extended_list_read/c/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -39,7 +39,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -61,7 +61,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -83,7 +83,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -105,7 +105,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/fss_extended_read/c/common.c b/level_3/fss_extended_read/c/common.c index e8ad344..82679db 100644 --- a/level_3/fss_extended_read/c/common.c +++ b/level_3/fss_extended_read/c/common.c @@ -70,18 +70,17 @@ extern "C" { #endif // _di_fss_extended_read_setting_delete_ #ifndef _di_fss_extended_read_setting_load_ - void fss_extended_read_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, fss_extended_read_setting_t * const setting) { + void fss_extended_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_extended_read_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_extended_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); fss_extended_read_print_line_last_locked(setting, main->error); return; @@ -99,11 +98,11 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_extended_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); fss_extended_read_print_line_last_locked(setting, main->error); return; @@ -132,11 +131,11 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_extended_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); fss_extended_read_print_line_last_locked(setting, main->error); return; diff --git a/level_3/fss_extended_read/c/common.h b/level_3/fss_extended_read/c/common.h index 633d64d..7ed7d35 100644 --- a/level_3/fss_extended_read/c/common.h +++ b/level_3/fss_extended_read/c/common.h @@ -372,7 +372,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -392,14 +392,12 @@ extern "C" { * * @param arguments * The parameters passed to the process (often referred to as command line arguments). - * @param state - * A state for providing flags and handling interrupts during long running operations. * @param main * The main program data. * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). @@ -409,7 +407,7 @@ extern "C" { * @see fll_program_parameter_process_context() */ #ifndef _di_fss_extended_read_setting_load_ - extern void fss_extended_read_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, fss_extended_read_setting_t * const setting); + extern void fss_extended_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_extended_read_setting_t * const setting); #endif // _di_fss_extended_read_setting_load_ /** @@ -421,7 +419,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index c670eb0..356e26f 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -12,8 +12,7 @@ extern "C" { f_status_t status = F_none; - // Load parameters. - status = f_console_parameter_process(arguments, &main->parameters, 0); + status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); if (F_status_is_error(status)) return; { diff --git a/level_3/fss_extended_read/c/main.c b/level_3/fss_extended_read/c/main.c index 50d5679..5998ee6 100644 --- a/level_3/fss_extended_read/c/main.c +++ b/level_3/fss_extended_read/c/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - fss_extended_read_setting_load(arguments, state, &data, &setting); + fss_extended_read_setting_load(arguments, &data, &setting); } fss_extended_read_main(&data, &setting); diff --git a/level_3/fss_extended_read/c/print.c b/level_3/fss_extended_read/c/print.c index f998c49..3e2b971 100644 --- a/level_3/fss_extended_read/c/print.c +++ b/level_3/fss_extended_read/c/print.c @@ -120,7 +120,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -135,7 +135,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -150,7 +150,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & (fss_extended_read_main_flag_verify_e | fss_extended_read_main_flag_file_to_e)) return F_output_not; } @@ -166,7 +166,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & (fss_extended_read_main_flag_verify_e | fss_extended_read_main_flag_file_to_e)) return F_output_not; } diff --git a/level_3/fss_extended_read/c/print.h b/level_3/fss_extended_read/c/print.h index e325aa3..e633228 100644 --- a/level_3/fss_extended_read/c/print.h +++ b/level_3/fss_extended_read/c/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -39,7 +39,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -61,7 +61,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -83,7 +83,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -105,7 +105,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/fss_identify/c/common.c b/level_3/fss_identify/c/common.c index f133f1b..6578bb8 100644 --- a/level_3/fss_identify/c/common.c +++ b/level_3/fss_identify/c/common.c @@ -37,18 +37,17 @@ extern "C" { #endif // _di_fss_identify_setting_delete_ #ifndef _di_fss_identify_setting_load_ - void fss_identify_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_identify_setting_t * const setting, f_state_t * const state) { + void fss_identify_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_identify_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_identify_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); fss_identify_print_line_last_locked(setting, main->error); return; @@ -66,11 +65,11 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_identify_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); fss_identify_print_line_last_locked(setting, main->error); return; @@ -99,11 +98,11 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_identify_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); fss_identify_print_line_last_locked(setting, main->error); return; diff --git a/level_3/fss_identify/c/common.h b/level_3/fss_identify/c/common.h index 3badc66..599739a 100644 --- a/level_3/fss_identify/c/common.h +++ b/level_3/fss_identify/c/common.h @@ -222,7 +222,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -242,14 +242,12 @@ extern "C" { * * @param arguments * The parameters passed to the process (often referred to as command line arguments). - * @param state - * A state for providing flags and handling interrupts during long running operations. * @param main * The main program data. * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). @@ -259,7 +257,7 @@ extern "C" { * @see fll_program_parameter_process_context() */ #ifndef _di_fss_identify_setting_load_ - extern void fss_identify_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, fss_identify_setting_t * const setting); + extern void fss_identify_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_identify_setting_t * const setting); #endif // _di_fss_identify_setting_load_ /** @@ -271,7 +269,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index 868aaf9..051b14a 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -11,8 +11,7 @@ extern "C" { f_status_t status = F_none; - // Load parameters. - status = f_console_parameter_process(arguments, &main->parameters, 0); + status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); if (F_status_is_error(status)) return; { diff --git a/level_3/fss_identify/c/fss_identify.h b/level_3/fss_identify/c/fss_identify.h index a30d43c..1d846bc 100644 --- a/level_3/fss_identify/c/fss_identify.h +++ b/level_3/fss_identify/c/fss_identify.h @@ -69,7 +69,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_true on success when performing verification and verify passed. * F_false on success when performing verification and verify failed. diff --git a/level_3/fss_identify/c/main.c b/level_3/fss_identify/c/main.c index 2017cd2..5ef29a1 100644 --- a/level_3/fss_identify/c/main.c +++ b/level_3/fss_identify/c/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - fss_identify_setting_load(arguments, state, &data, &setting); + fss_identify_setting_load(arguments, &data, &setting); } fss_identify_main(&data, &setting); diff --git a/level_3/fss_identify/c/print.c b/level_3/fss_identify/c/print.c index c3c062e..f98abc1 100644 --- a/level_3/fss_identify/c/print.c +++ b/level_3/fss_identify/c/print.c @@ -61,7 +61,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -76,7 +76,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -91,7 +91,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & (fss_identify_main_flag_verify_e | fss_identify_main_flag_file_to_e)) return F_output_not; } @@ -107,7 +107,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & (fss_identify_main_flag_verify_e | fss_identify_main_flag_file_to_e)) return F_output_not; } diff --git a/level_3/fss_identify/c/print.h b/level_3/fss_identify/c/print.h index aa748e1..34be83b 100644 --- a/level_3/fss_identify/c/print.h +++ b/level_3/fss_identify/c/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -39,7 +39,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -61,7 +61,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -83,7 +83,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -105,7 +105,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/fss_payload_read/c/common.c b/level_3/fss_payload_read/c/common.c index a94cb20..753d519 100644 --- a/level_3/fss_payload_read/c/common.c +++ b/level_3/fss_payload_read/c/common.c @@ -71,18 +71,17 @@ extern "C" { #endif // _di_fss_payload_read_setting_delete_ #ifndef _di_fss_payload_read_setting_load_ - void fss_payload_read_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, fss_payload_read_setting_t * const setting) { + void fss_payload_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_payload_read_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(state, arguments, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_payload_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); fss_payload_read_print_line_last_locked(setting, main->error); return; @@ -100,11 +99,11 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_payload_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); fss_payload_read_print_line_last_locked(setting, main->error); return; @@ -133,11 +132,11 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_payload_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); fss_payload_read_print_line_last_locked(setting, main->error); return; diff --git a/level_3/fss_payload_read/c/common.h b/level_3/fss_payload_read/c/common.h index 8aefedb..6aa5de4 100644 --- a/level_3/fss_payload_read/c/common.h +++ b/level_3/fss_payload_read/c/common.h @@ -379,7 +379,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -404,19 +404,17 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: fll_program_parameter_process_context(). - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @see f_console_parameter_process() * @see fll_program_parameter_process_context() */ #ifndef _di_fss_payload_read_setting_load_ - extern void fss_payload_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_payload_read_setting_t * const setting, f_state_t * const state); + extern void fss_payload_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_payload_read_setting_t * const setting); #endif // _di_fss_payload_read_setting_load_ /** @@ -428,7 +426,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_payload_read/c/fss_payload_read.c b/level_3/fss_payload_read/c/fss_payload_read.c index 2bd62d1..9fac941 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.c +++ b/level_3/fss_payload_read/c/fss_payload_read.c @@ -12,8 +12,7 @@ extern "C" { f_status_t status = F_none; - // Load parameters. - status = f_console_parameter_process(arguments, &main->parameters, 0); + status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); if (F_status_is_error(status)) return; { diff --git a/level_3/fss_payload_read/c/main.c b/level_3/fss_payload_read/c/main.c index ee2685c..1fa6db4 100644 --- a/level_3/fss_payload_read/c/main.c +++ b/level_3/fss_payload_read/c/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - fss_payload_read_setting_load(arguments, state, &data, &setting); + fss_payload_read_setting_load(arguments, &data, &setting); } fss_payload_read_main(&data, &setting); diff --git a/level_3/fss_payload_read/c/print.c b/level_3/fss_payload_read/c/print.c index c1b4828..37766fb 100644 --- a/level_3/fss_payload_read/c/print.c +++ b/level_3/fss_payload_read/c/print.c @@ -130,7 +130,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -145,7 +145,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -160,7 +160,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & (fss_payload_read_main_flag_verify_e | fss_payload_read_main_flag_file_to_e)) return F_output_not; } @@ -176,7 +176,7 @@ extern "C" { if (!setting || print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & (fss_payload_read_main_flag_verify_e | fss_payload_read_main_flag_file_to_e)) return F_output_not; } diff --git a/level_3/fss_payload_read/c/print.h b/level_3/fss_payload_read/c/print.h index a0d8101..d98cdae 100644 --- a/level_3/fss_payload_read/c/print.h +++ b/level_3/fss_payload_read/c/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -39,7 +39,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -61,7 +61,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -83,7 +83,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -105,7 +105,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/fss_write/c/basic/fss_write.c b/level_3/fss_write/c/basic/fss_write.c index 270e2e0..e60e627 100644 --- a/level_3/fss_write/c/basic/fss_write.c +++ b/level_3/fss_write/c/basic/fss_write.c @@ -13,7 +13,7 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->content) { - setting->status = fl_fss_basic_content_write( + setting->state.status = fl_fss_basic_content_write( *setting->content, (setting->flag & fss_write_flag_partial_e) ? f_fss_complete_partial_e @@ -23,8 +23,8 @@ extern "C" { setting->state ); - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); + if (F_status_set_fine(setting->state.status) == F_none_eol) { + setting->state.status = F_status_set_error(F_support_not); fss_write_print_line_first_locked(setting, main->error); fss_write_print_error_unsupported_eol(setting, main->error); @@ -32,7 +32,7 @@ extern "C" { return; } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_content_write)); return; @@ -41,9 +41,9 @@ extern "C" { if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_object_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { if (setting->flag & fss_write_flag_content_end_e) { - setting->status = f_string_dynamic_append(f_fss_basic_close_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_fss_basic_close_s, &setting->buffer); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); } } @@ -68,7 +68,7 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->object) { - setting->status = fl_fss_basic_object_write( + setting->state.status = fl_fss_basic_object_write( *setting->object, setting->quote.used ? setting->quote.string[0] @@ -85,8 +85,8 @@ extern "C" { &setting->buffer ); - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); + if (F_status_set_fine(setting->state.status) == F_none_eol) { + setting->state.status = F_status_set_error(F_support_not); fss_write_print_line_first_locked(setting, main->error); fss_write_print_error_unsupported_eol(setting, main->error); @@ -94,7 +94,7 @@ extern "C" { return; } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_object_write)); return; @@ -103,9 +103,9 @@ extern "C" { if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_content_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { if (setting->flag & fss_write_flag_object_open_e) { - setting->status = f_string_dynamic_append(f_fss_basic_open_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_fss_basic_open_s, &setting->buffer); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); } } diff --git a/level_3/fss_write/c/basic/fss_write.h b/level_3/fss_write/c/basic/fss_write.h index afcffa5..baa2cdc 100644 --- a/level_3/fss_write/c/basic/fss_write.h +++ b/level_3/fss_write/c/basic/fss_write.h @@ -83,7 +83,7 @@ extern "C" { * The main program settings. * Must be of type (fss_write_setting_t *). * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_write/c/basic/print.h b/level_3/fss_write/c/basic/print.h index 491dc41..cd80df2 100644 --- a/level_3/fss_write/c/basic/print.h +++ b/level_3/fss_write/c/basic/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * diff --git a/level_3/fss_write/c/basic_list/fss_write.c b/level_3/fss_write/c/basic_list/fss_write.c index 3ef6b00..44fb415 100644 --- a/level_3/fss_write/c/basic_list/fss_write.c +++ b/level_3/fss_write/c/basic_list/fss_write.c @@ -13,7 +13,7 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->content) { - setting->status = fl_fss_basic_list_content_write( + setting->state.status = fl_fss_basic_list_content_write( *setting->content, (setting->flag & fss_write_flag_partial_e) ? f_fss_complete_partial_e @@ -26,8 +26,8 @@ extern "C" { &setting->buffer ); - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); + if (F_status_set_fine(setting->state.status) == F_none_eol) { + setting->state.status = F_status_set_error(F_support_not); fss_write_print_line_first_locked(setting, main->error); fss_write_print_error_unsupported_eol(setting, main->error); @@ -35,7 +35,7 @@ extern "C" { return; } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_content_write)); return; @@ -44,9 +44,9 @@ extern "C" { if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_object_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { if (setting->flag & fss_write_flag_content_end_e) { - setting->status = f_string_dynamic_append(f_fss_basic_list_close_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_fss_basic_list_close_s, &setting->buffer); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); } } @@ -71,7 +71,7 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->object) { - setting->status = fl_fss_basic_list_object_write( + setting->state.status = fl_fss_basic_list_object_write( *setting->object, (setting->flag & fss_write_flag_partial_e) ? (setting->flag & fss_write_flag_trim_e) @@ -85,8 +85,8 @@ extern "C" { &setting->buffer ); - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); + if (F_status_set_fine(setting->state.status) == F_none_eol) { + setting->state.status = F_status_set_error(F_support_not); fss_write_print_line_first_locked(setting, main->error); fss_write_print_error_unsupported_eol(setting, main->error); @@ -94,7 +94,7 @@ extern "C" { return; } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_object_write)); return; @@ -103,13 +103,13 @@ extern "C" { if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_content_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { if (setting->flag & fss_write_flag_object_open_e) { - setting->status = f_string_dynamic_append(f_fss_basic_list_open_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_fss_basic_list_open_s, &setting->buffer); - if (F_status_is_error_not(setting->status)) { - setting->status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &setting->buffer); + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &setting->buffer); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); } } diff --git a/level_3/fss_write/c/basic_list/fss_write.h b/level_3/fss_write/c/basic_list/fss_write.h index 5279d07..0776a1b 100644 --- a/level_3/fss_write/c/basic_list/fss_write.h +++ b/level_3/fss_write/c/basic_list/fss_write.h @@ -84,7 +84,7 @@ extern "C" { * The main program settings. * Must be of type (fss_write_setting_t *). * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_write/c/basic_list/main.c b/level_3/fss_write/c/basic_list/main.c index e8c38b7..9b44e60 100644 --- a/level_3/fss_write/c/basic_list/main.c +++ b/level_3/fss_write/c/basic_list/main.c @@ -28,7 +28,6 @@ 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); - f_state_t state = f_state_t_initialize; fss_write_setting_load(arguments, state, &data, &setting, 0); } diff --git a/level_3/fss_write/c/basic_list/print.h b/level_3/fss_write/c/basic_list/print.h index 6c93979..7d7c5d3 100644 --- a/level_3/fss_write/c/basic_list/print.h +++ b/level_3/fss_write/c/basic_list/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * diff --git a/level_3/fss_write/c/embedded_list/fss_write.c b/level_3/fss_write/c/embedded_list/fss_write.c index ea90288..81dc2ba 100644 --- a/level_3/fss_write/c/embedded_list/fss_write.c +++ b/level_3/fss_write/c/embedded_list/fss_write.c @@ -13,7 +13,7 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->content) { - setting->status = fl_fss_embedded_list_content_write( + setting->state.status = fl_fss_embedded_list_content_write( *setting->content, (setting->flag & fss_write_flag_partial_e) ? f_fss_complete_partial_e @@ -27,8 +27,8 @@ extern "C" { &setting->buffer ); - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); + if (F_status_set_fine(setting->state.status) == F_none_eol) { + setting->state.status = F_status_set_error(F_support_not); fss_write_print_line_first_locked(setting, main->error); fss_write_print_error_unsupported_eol(setting, main->error); @@ -36,7 +36,7 @@ extern "C" { return; } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_embedded_list_content_write)); return; @@ -45,13 +45,13 @@ extern "C" { if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_object_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { if (setting->flag & fss_write_flag_content_end_e) { - setting->status = f_string_dynamic_append(f_fss_embedded_list_close_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_fss_embedded_list_close_s, &setting->buffer); - if (F_status_is_error_not(setting->status)) { - setting->status = f_string_dynamic_append(f_fss_embedded_list_close_end_s, &setting->buffer); + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = f_string_dynamic_append(f_fss_embedded_list_close_end_s, &setting->buffer); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); } } @@ -76,7 +76,7 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->object) { - setting->status = fl_fss_embedded_list_object_write( + setting->state.status = fl_fss_embedded_list_object_write( *setting->object, (setting->flag & fss_write_flag_partial_e) ? (setting->flag & fss_write_flag_trim_e) @@ -90,8 +90,8 @@ extern "C" { &setting->buffer ); - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); + if (F_status_set_fine(setting->state.status) == F_none_eol) { + setting->state.status = F_status_set_error(F_support_not); fss_write_print_line_first_locked(setting, main->error); fss_write_print_error_unsupported_eol(setting, main->error); @@ -99,7 +99,7 @@ extern "C" { return; } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_embedded_list_object_write)); return; @@ -108,13 +108,13 @@ extern "C" { if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_content_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { if (setting->flag & fss_write_flag_object_open_e) { - setting->status = f_string_dynamic_append(f_fss_embedded_list_open_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_fss_embedded_list_open_s, &setting->buffer); - if (F_status_is_error_not(setting->status)) { - setting->status = f_string_dynamic_append(f_fss_embedded_list_open_end_s, &setting->buffer); + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = f_string_dynamic_append(f_fss_embedded_list_open_end_s, &setting->buffer); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); } } diff --git a/level_3/fss_write/c/embedded_list/fss_write.h b/level_3/fss_write/c/embedded_list/fss_write.h index f4cd0e3..aa08fe9 100644 --- a/level_3/fss_write/c/embedded_list/fss_write.h +++ b/level_3/fss_write/c/embedded_list/fss_write.h @@ -83,7 +83,7 @@ extern "C" { * The main program settings. * Must be of type (fss_write_setting_t *). * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_write/c/embedded_list/main.c b/level_3/fss_write/c/embedded_list/main.c index e956aaa..7e5733b 100644 --- a/level_3/fss_write/c/embedded_list/main.c +++ b/level_3/fss_write/c/embedded_list/main.c @@ -30,7 +30,6 @@ 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); - f_state_t state = f_state_t_initialize; fss_write_setting_load(arguments, state, &data, &setting, 0); } diff --git a/level_3/fss_write/c/embedded_list/print.h b/level_3/fss_write/c/embedded_list/print.h index 41a14ef..955e24e 100644 --- a/level_3/fss_write/c/embedded_list/print.h +++ b/level_3/fss_write/c/embedded_list/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * diff --git a/level_3/fss_write/c/extended/fss_write.c b/level_3/fss_write/c/extended/fss_write.c index ddb6e34..3ef64f7 100644 --- a/level_3/fss_write/c/extended/fss_write.c +++ b/level_3/fss_write/c/extended/fss_write.c @@ -13,7 +13,7 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->content) { - setting->status = fl_fss_extended_content_write( + setting->state.status = fl_fss_extended_content_write( *setting->content, setting->quote.used ? setting->quote.string[0] @@ -28,8 +28,8 @@ extern "C" { &setting->buffer ); - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); + if (F_status_set_fine(setting->state.status) == F_none_eol) { + setting->state.status = F_status_set_error(F_support_not); fss_write_print_line_first_locked(setting, main->error); fss_write_print_error_unsupported_eol(setting, main->error); @@ -37,7 +37,7 @@ extern "C" { return; } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_content_write)); return; @@ -46,16 +46,16 @@ extern "C" { if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_object_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { if (setting->flag & fss_write_flag_content_end_e) { - setting->status = f_string_dynamic_append(f_fss_extended_close_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_fss_extended_close_s, &setting->buffer); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); } } else if (setting->flag & fss_write_flag_content_next_e) { - setting->status = f_string_dynamic_append(f_fss_extended_next_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_fss_extended_next_s, &setting->buffer); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); } } @@ -80,7 +80,7 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->object) { - setting->status = fl_fss_extended_object_write( + setting->state.status = fl_fss_extended_object_write( *setting->object, setting->quote.used ? setting->quote.string[0] @@ -97,8 +97,8 @@ extern "C" { &setting->buffer ); - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); + if (F_status_set_fine(setting->state.status) == F_none_eol) { + setting->state.status = F_status_set_error(F_support_not); fss_write_print_line_first_locked(setting, main->error); fss_write_print_error_unsupported_eol(setting, main->error); @@ -106,7 +106,7 @@ extern "C" { return; } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_object_write)); return; @@ -115,8 +115,8 @@ extern "C" { if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_content_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { if (setting->flag & fss_write_flag_object_open_e) { - setting->status = f_string_dynamic_append(f_fss_extended_open_s, &setting->buffer); - if (F_status_is_error(setting->status)) { + setting->state.status = f_string_dynamic_append(f_fss_extended_open_s, &setting->buffer); + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); } } diff --git a/level_3/fss_write/c/extended/fss_write.h b/level_3/fss_write/c/extended/fss_write.h index f828d59..a30b6e5 100644 --- a/level_3/fss_write/c/extended/fss_write.h +++ b/level_3/fss_write/c/extended/fss_write.h @@ -83,7 +83,7 @@ extern "C" { * The main program settings. * Must be of type (fss_write_setting_t *). * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_write/c/extended/main.c b/level_3/fss_write/c/extended/main.c index 479dcac..34ded57 100644 --- a/level_3/fss_write/c/extended/main.c +++ b/level_3/fss_write/c/extended/main.c @@ -29,7 +29,6 @@ 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); - f_state_t state = f_state_t_initialize; fss_write_setting_load(arguments, state, &data, &setting, 0); } diff --git a/level_3/fss_write/c/extended/print.h b/level_3/fss_write/c/extended/print.h index 9b2977d..5af54d9 100644 --- a/level_3/fss_write/c/extended/print.h +++ b/level_3/fss_write/c/extended/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * diff --git a/level_3/fss_write/c/extended_list/fss_write.c b/level_3/fss_write/c/extended_list/fss_write.c index 28c6f1b..983f42a 100644 --- a/level_3/fss_write/c/extended_list/fss_write.c +++ b/level_3/fss_write/c/extended_list/fss_write.c @@ -13,7 +13,7 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->content) { - setting->status = fl_fss_extended_list_content_write( + setting->state.status = fl_fss_extended_list_content_write( *setting->content, (setting->flag & fss_write_flag_partial_e) ? last @@ -27,8 +27,8 @@ extern "C" { &setting->buffer ); - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); + if (F_status_set_fine(setting->state.status) == F_none_eol) { + setting->state.status = F_status_set_error(F_support_not); fss_write_print_line_first_locked(setting, main->error); fss_write_print_error_unsupported_eol(setting, main->error); @@ -36,7 +36,7 @@ extern "C" { return; } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_list_content_write)); return; @@ -45,13 +45,13 @@ extern "C" { if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_object_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { if (setting->flag & fss_write_flag_content_end_e) { - setting->status = f_string_dynamic_append(f_fss_extended_list_close_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_fss_extended_list_close_s, &setting->buffer); - if (F_status_is_error_not(setting->status)) { - setting->status = f_string_dynamic_append(f_fss_extended_list_close_end_s, &setting->buffer); + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = f_string_dynamic_append(f_fss_extended_list_close_end_s, &setting->buffer); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); } } @@ -76,7 +76,7 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); if (setting->object) { - setting->status = fl_fss_extended_list_object_write( + setting->state.status = fl_fss_extended_list_object_write( *setting->object, (setting->flag & fss_write_flag_partial_e) ? (setting->flag & fss_write_flag_trim_e) @@ -108,13 +108,13 @@ extern "C" { if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_content_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { if (setting->flag & fss_write_flag_object_open_e) { - setting->status = f_string_dynamic_append(f_fss_extended_list_open_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_fss_extended_list_open_s, &setting->buffer); - if (F_status_is_error_not(setting->status)) { - setting->status = f_string_dynamic_append(f_fss_extended_list_open_end_s, &setting->buffer); + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = f_string_dynamic_append(f_fss_extended_list_open_end_s, &setting->buffer); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); } } diff --git a/level_3/fss_write/c/extended_list/fss_write.h b/level_3/fss_write/c/extended_list/fss_write.h index 6b18023..9974e2e 100644 --- a/level_3/fss_write/c/extended_list/fss_write.h +++ b/level_3/fss_write/c/extended_list/fss_write.h @@ -83,7 +83,7 @@ extern "C" { * The main program settings. * Must be of type (fss_write_setting_t *). * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_write/c/extended_list/main.c b/level_3/fss_write/c/extended_list/main.c index b6571be..a88557d 100644 --- a/level_3/fss_write/c/extended_list/main.c +++ b/level_3/fss_write/c/extended_list/main.c @@ -29,7 +29,6 @@ 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); - f_state_t state = f_state_t_initialize; fss_write_setting_load(arguments, state, &data, &setting, 0); } diff --git a/level_3/fss_write/c/extended_list/print.h b/level_3/fss_write/c/extended_list/print.h index dc81d38..824636f 100644 --- a/level_3/fss_write/c/extended_list/print.h +++ b/level_3/fss_write/c/extended_list/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * diff --git a/level_3/fss_write/c/main/common.c b/level_3/fss_write/c/main/common.c index 607a4ad..21316a8 100644 --- a/level_3/fss_write/c/main/common.c +++ b/level_3/fss_write/c/main/common.c @@ -27,10 +27,9 @@ extern "C" { if (!main || !setting) return; - // Load parameters. - setting->status = f_console_parameter_process(state, arguments, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_console_parameter_process)); return; @@ -47,9 +46,9 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fll_program_parameter_process_context)); return; @@ -78,9 +77,9 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fll_program_parameter_process_verbosity)); return; @@ -106,10 +105,10 @@ extern "C" { if (callback) { callback(arguments, main, setting); - if (F_status_is_error(setting->status)) return; + if (F_status_is_error(setting->state.status)) return; - if (setting->status == F_done) { - setting->status = F_none; + if (setting->state.status == F_done) { + setting->state.status = F_none; return; } @@ -120,7 +119,7 @@ extern "C" { if ((main->parameters.array[fss_write_parameter_file_e].result & f_console_result_value_e) && main->parameters.array[fss_write_parameter_file_e].values.used) { if (main->parameters.array[fss_write_parameter_file_e].values.used > 1) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_must_specify_once(main->error, f_console_symbol_long_normal_s, fss_write_long_file_s); @@ -133,9 +132,9 @@ extern "C" { main->output.to.id = -1; main->output.to.stream = 0; - setting->status = f_file_stream_open(main->parameters.arguments.array[index], f_string_empty_s, &main->output.to); + setting->state.status = f_file_stream_open(main->parameters.arguments.array[index], f_string_empty_s, &main->output.to); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error_file(setting, main->error, macro_fss_write_f(f_file_stream_open), main->parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); return; @@ -144,7 +143,7 @@ extern "C" { setting->flag |= fss_write_flag_file_to_e; } else if (main->parameters.array[fss_write_parameter_file_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_write_long_file_s); @@ -157,9 +156,9 @@ extern "C" { setting->objects.used = 0; - setting->status = f_string_dynamics_resize(values->used, &setting->objects); + setting->state.status = f_string_dynamics_resize(values->used, &setting->objects); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_resize)); return; @@ -178,7 +177,7 @@ extern "C" { setting->flag |= fss_write_flag_object_e; } else if (main->parameters.array[fss_write_parameter_object_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_write_long_object_s); @@ -191,7 +190,7 @@ extern "C" { if (setting->flag & fss_write_flag_object_e) { if (!(setting->flag & fss_write_flag_content_multiple_e)) { if (main->parameters.array[fss_write_parameter_content_e].values.used > main->parameters.array[fss_write_parameter_object_e].values.used) { - setting->status = F_status_set_error(F_support_not); + setting->state.status = F_status_set_error(F_support_not); fss_write_print_error_one_content_only(setting, main->error); @@ -210,9 +209,9 @@ extern "C" { setting->contentss.used = 0; - setting->status = f_string_dynamicss_increase_by(values_object->used, &setting->contentss); + setting->state.status = f_string_dynamicss_increase_by(values_object->used, &setting->contentss); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamicss_increase_by)); return; @@ -241,9 +240,9 @@ extern "C" { break; } - setting->status = f_string_dynamics_increase_by(total, &setting->contentss.array[j]); + setting->state.status = f_string_dynamics_increase_by(total, &setting->contentss.array[j]); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase_by)); return; @@ -266,7 +265,7 @@ extern "C" { setting->flag |= fss_write_flag_content_e; } else if (main->parameters.array[fss_write_parameter_content_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_write_long_content_s); @@ -279,9 +278,9 @@ extern "C" { setting->prepend.used = 0; - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->prepend); + setting->state.status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->prepend); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append_nulless)); return; @@ -293,16 +292,16 @@ extern "C" { for (; range.start < main->parameters.arguments.array[index].used; range.start++) { - setting->status = f_fss_is_space(main->parameters.arguments.array[index], range, state); + setting->state.status = f_fss_is_space(main->parameters.arguments.array[index], range, state); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_fss_is_space)); return; } - if (setting->status == F_false) { - setting->status = F_status_set_error(F_parameter); + if (setting->state.status == F_false) { + setting->state.status = F_status_set_error(F_parameter); fss_write_print_error_prepend_only_whitespace(setting, main->error); @@ -314,7 +313,7 @@ extern "C" { setting->flag |= fss_write_flag_prepend_e; } else if (main->parameters.array[fss_write_parameter_prepend_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_write_long_prepend_s); @@ -324,7 +323,7 @@ extern "C" { if ((main->parameters.array[fss_write_parameter_ignore_e].result & f_console_result_value_e) && main->parameters.array[fss_write_parameter_ignore_e].values.used) { if (main->parameters.array[fss_write_parameter_ignore_e].values.used % 2 != 0) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, fss_write_string_two_s); @@ -346,9 +345,9 @@ extern "C" { setting->ignoress.used = 0; - setting->status = f_string_rangess_increase_by(values_data->used, &setting->ignoress); + setting->state.status = f_string_rangess_increase_by(values_data->used, &setting->ignoress); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_rangess_increase_by)); return; @@ -376,9 +375,9 @@ extern "C" { break; } - setting->status = f_string_ranges_increase_by(total, &setting->ignoress.array[j]); + setting->state.status = f_string_ranges_increase_by(total, &setting->ignoress.array[j]); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_ranges_increase_by)); return; @@ -388,9 +387,9 @@ extern "C" { index = values_ignore->array[i++]; - setting->status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->ignoress.array[j].array[setting->ignoress.array[j].used].start); + setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->ignoress.array[j].array[setting->ignoress.array[j].used].start); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_integer_not(main->error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->parameters.arguments.array[index]); @@ -399,9 +398,9 @@ extern "C" { index = values_ignore->array[i++]; - setting->status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->ignoress.array[j].array[setting->ignoress.array[j].used].stop); + setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->ignoress.array[j].array[setting->ignoress.array[j].used].stop); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_integer_not(main->error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->parameters.arguments.array[index]); @@ -409,7 +408,7 @@ extern "C" { } if (setting->ignoress.array[j].array[setting->ignoress.array[j].used].stop > setting->ignoress.array[j].array[setting->ignoress.array[j].used].start) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_range_start_before_stop( @@ -442,9 +441,9 @@ extern "C" { index = main->parameters.array[fss_write_parameter_ignore_e].values.array[i++]; - setting->status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &number.start); + setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &number.start); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_integer_not(main->error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->parameters.arguments.array[index]); @@ -453,9 +452,9 @@ extern "C" { index = main->parameters.array[fss_write_parameter_ignore_e].values.array[i++]; - setting->status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &number.stop); + setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &number.stop); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_integer_not(main->error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->parameters.arguments.array[index]); @@ -463,7 +462,7 @@ extern "C" { } if (number.start > number.stop) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_range_start_before_stop( @@ -480,7 +479,7 @@ extern "C" { } } else if (main->parameters.array[fss_write_parameter_ignore_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_write_long_ignore_s); @@ -535,7 +534,7 @@ extern "C" { if (main->parameters.array[has[i]].result & f_console_result_found_e) { if (setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e)) { if (!(setting->flag & fss_write_flag_partial_e)) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); @@ -556,7 +555,7 @@ extern "C" { } if (main->parameters.array[has_cannots[i][0]].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, has_string[i], has_cannots_string[i][0]); @@ -565,7 +564,7 @@ extern "C" { } if (main->parameters.array[has_cannots[i][1]].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, has_string[i], has_cannots_string[i][1]); @@ -582,7 +581,7 @@ extern "C" { if (setting->flag & fss_write_flag_object_e) { if (setting->flag & fss_write_flag_content_multiple_e) { if (main->parameters.array[fss_write_parameter_object_e].locations_sub.used > main->parameters.array[fss_write_parameter_content_e].locations_sub.used && !(setting->flag & fss_write_flag_partial_e)) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_error_parameter_same_times_at_least(setting, main->error); @@ -592,7 +591,7 @@ extern "C" { if ((setting->flag & fss_write_flag_content_e) && (setting->flag & fss_write_flag_partial_e)) { if (main->parameters.array[fss_write_parameter_content_e].result & f_console_result_value_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_cannot_use_with_xor(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_write_long_partial_s, fss_write_long_object_s, fss_write_long_content_s); @@ -646,7 +645,7 @@ extern "C" { } if (!(setting->flag & (fll_program_data_pipe_input_e | fss_write_flag_content_e | fss_write_parameter_object_e))) { - setting->status = F_data_not; + setting->state.status = F_data_not; } } #endif // _di_fss_write_setting_load_ diff --git a/level_3/fss_write/c/main/common.h b/level_3/fss_write/c/main/common.h index dd0990d..021d5b8 100644 --- a/level_3/fss_write/c/main/common.h +++ b/level_3/fss_write/c/main/common.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -47,7 +47,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_data_not on success but nothing was provided to operate with. * @@ -82,7 +82,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/fss_write/c/main/fss_write.c b/level_3/fss_write/c/main/fss_write.c index 48917a3..7188d29 100644 --- a/level_3/fss_write/c/main/fss_write.c +++ b/level_3/fss_write/c/main/fss_write.c @@ -9,13 +9,13 @@ extern "C" { if (!main || !setting) return; - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_line_last_locked(setting, main->error); return; } - setting->status = F_none; + setting->state.status = F_none; if (setting->flag & fss_write_flag_help_e) { if (setting->process_help) { @@ -45,7 +45,7 @@ extern "C" { } } - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e | fss_write_flag_object_open_e | fss_write_flag_content_next_e | fss_write_flag_content_end_e)) { if (setting->process_normal) { setting->process_normal(main, (void *) setting); @@ -53,11 +53,8 @@ extern "C" { } } - if (F_status_is_error(setting->status)) { - fss_write_print_line_last_locked(setting, main->error); - } - else if (setting->status != F_interrupt) { - fss_write_print_line_last_locked(setting, main->message); + if (F_status_is_error(setting->state.status)) { + fss_write_print_line_last_locked(setting, F_status_set_fine(setting->state.status) == F_interrupt ? main->message : main->error); } } #endif // _di_fss_write_main_ @@ -91,7 +88,7 @@ extern "C" { // @todo replace all signal checks with forked main process that independently checks and assigns main->signal_received. if (!((++main->signal_check) % fss_write_signal_check_d)) { if (fll_program_standard_signal_received(main)) { - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); return; } @@ -112,7 +109,7 @@ extern "C" { } setting->process_set(main, setting); - if (F_status_is_error(setting->status)) break; + if (F_status_is_error(setting->state.status)) break; } // for } else { @@ -158,35 +155,35 @@ extern "C" { uint8_t state = 0; // This is processed in a single set, so there is only ever one Object added. - setting->status = f_string_dynamics_increase(setting->state.step_small, &setting->objects); + setting->state.status = f_string_dynamics_increase(setting->state.step_small, &setting->objects); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); return; } // This is processed in a single set, so there is only ever one Content added. - setting->status = f_string_dynamicss_increase(setting->state.step_small, &setting->contentss); + setting->state.status = f_string_dynamicss_increase(setting->state.step_small, &setting->contentss); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamicss_increase)); return; } - setting->status = f_string_dynamics_increase(setting->state.step_small, setting->contents); + setting->state.status = f_string_dynamics_increase(setting->state.step_small, setting->contents); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); return; } // This is processed in a single set, so there is only ever one Ignores added. - setting->status = f_string_rangess_increase(setting->state.step_small, &setting->ignoress); + setting->state.status = f_string_rangess_increase(setting->state.step_small, &setting->ignoress); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_rangess_increase)); return; @@ -203,7 +200,7 @@ extern "C" { if (fll_program_standard_signal_received(main)) { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); break; } @@ -244,9 +241,9 @@ extern "C" { flag -= flag | 0x4; setting->contents->used = 0; - setting->status = f_string_dynamic_increase_by(setting->block.used, setting->object); + setting->state.status = f_string_dynamic_increase_by(setting->block.used, setting->object); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); break; @@ -288,7 +285,7 @@ extern "C" { setting->object->string[setting->object->used++] = setting->block.string[range.start]; } // for - if (F_status_is_error(setting->status)) break; + if (F_status_is_error(setting->state.status)) break; // If the start of Content is not found, then fetch the next block. if (state == 0x1) continue; @@ -303,16 +300,16 @@ extern "C" { // Check to see if the Content supports multiple Content per Object. if (flag & 0x4) { if (!(setting->flag & fss_write_flag_content_multiple_e)) { - setting->status = F_status_set_error(F_support_not); + setting->state.status = F_status_set_error(F_support_not); fss_write_print_error_one_content_only(setting, main->error); break; } - setting->status = f_string_dynamics_increase(setting->state.step_small, setting->contents); + setting->state.status = f_string_dynamics_increase(setting->state.step_small, setting->contents); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); break; @@ -327,9 +324,9 @@ extern "C" { } if (total) { - setting->status = f_string_dynamic_increase_by(total, &setting->contents->array[setting->contents->used]); + setting->state.status = f_string_dynamic_increase_by(total, &setting->contents->array[setting->contents->used]); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); break; @@ -341,7 +338,7 @@ extern "C" { if (!(flag & 0x2)) { if (setting->block.string[range.start] == fss_write_pipe_content_start_s.string[0]) { if (!(setting->flag & fss_write_flag_content_multiple_e)) { - setting->status = F_status_set_error(F_support_not); + setting->state.status = F_status_set_error(F_support_not); fss_write_print_error_one_content_only(setting, main->error); @@ -361,9 +358,9 @@ extern "C" { // Ignore is enabled. if (flag & 0x2) { - setting->status = f_string_ranges_increase(setting->state.step_small, setting->ignores); + setting->state.status = f_string_ranges_increase(setting->state.step_small, setting->ignores); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_ranges_increase)); break; @@ -386,7 +383,7 @@ extern "C" { setting->contents->array[setting->contents->used].string[setting->contents->array[setting->contents->used].used++] = setting->block.string[range.start]; } // for - if (F_status_is_error(setting->status)) break; + if (F_status_is_error(setting->state.status)) break; ++setting->contents->used; flag |= 0x4; @@ -399,7 +396,7 @@ extern "C" { // End Object or Content set. if (state == 0x3) { setting->process_set(main, void_setting); - if (F_status_is_error(setting->status)) break; + if (F_status_is_error(setting->state.status)) break; state = 0; flag |= 0x1; @@ -414,7 +411,7 @@ extern "C" { } // for // If the pipe ended before finishing, then attempt to wrap up. - if (F_status_is_error_not(setting->status) && status_pipe == F_none_eof && state) { + if (F_status_is_error_not(setting->state.status) && status_pipe == F_none_eof && state) { setting->process_set(main, void_setting); flag |= 0x1; @@ -429,8 +426,8 @@ extern "C" { setting->objects.used = used_objects; setting->contentss.used = used_contentss; - if (F_status_is_error_not(setting->status)) { - setting->status = (flag & 0x1) ? F_none : F_data_not; + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = (flag & 0x1) ? F_none : F_data_not; } } #endif // _di_fss_write_process_pipe_ @@ -457,7 +454,7 @@ extern "C" { if (setting->process_object) { setting->process_object(main, void_setting); - if (F_status_is_error(setting->status)) return; + if (F_status_is_error(setting->state.status)) return; } } @@ -479,14 +476,14 @@ extern "C" { setting->content = &setting->contents->array[i]; setting->process_content(main, void_setting, i + 1 == setting->contents->used); - if (F_status_is_error(setting->status)) return; + if (F_status_is_error(setting->state.status)) return; } // for } else { setting->content = 0; setting->process_content(main, void_setting, F_true); - if (F_status_is_error(setting->status)) return; + if (F_status_is_error(setting->state.status)) return; } } } diff --git a/level_3/fss_write/c/main/fss_write.h b/level_3/fss_write/c/main/fss_write.h index 12b89e3..604f60c 100644 --- a/level_3/fss_write/c/main/fss_write.h +++ b/level_3/fss_write/c/main/fss_write.h @@ -68,7 +68,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_true on success when performing verification and verify passed. * F_false on success when performing verification and verify failed. @@ -89,7 +89,7 @@ extern "C" { * The main program settings. * Must be of type (fss_write_setting_t *). * - * This alters setting.status: + * This alters setting.state.status: * status from fss_write_process_normal_data(). * * Errors (with error bit) from fss_write_process_normal_data(). @@ -109,7 +109,7 @@ extern "C" { * The main program settings. * Must be of type (fss_write_setting_t *). * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_interrupt on (exit) signal received. * @@ -128,7 +128,7 @@ extern "C" { * The main program settings. * Must be of type (fss_write_setting_t *). * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_data_not on success but pipe contained no relevant data. * F_basic on success and the basic has been printed. @@ -149,7 +149,7 @@ extern "C" { * The main program settings. * Must be of type (fss_write_setting_t *). * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_interrupt on (exit) signal received. * diff --git a/level_3/fss_write/c/main/main-print.h b/level_3/fss_write/c/main/main-print.h index e052608..73e9f49 100644 --- a/level_3/fss_write/c/main/main-print.h +++ b/level_3/fss_write/c/main/main-print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param value @@ -38,7 +38,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * diff --git a/level_3/fss_write/c/main/main.c b/level_3/fss_write/c/main/main.c index 1f281e4..bc4cad8 100644 --- a/level_3/fss_write/c/main/main.c +++ b/level_3/fss_write/c/main/main.c @@ -27,7 +27,6 @@ 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); - f_state_t state = f_state_t_initialize; fss_write_setting_load(arguments, state, &data, &setting, &fss_write_main_setting_load_as); } @@ -55,7 +54,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { #ifndef _di_fss_write_main_setting_load_as_ void fss_write_main_setting_load_as(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting, f_state_t * const state) { - if (!main || !setting || F_status_is_error(setting->status) || (setting->flag & fss_write_flag_version_e)) return; + if (!main || !setting || F_status_is_error(setting->state.status) || (setting->flag & fss_write_flag_version_e)) return; setting->standard = fss_write_basic_standard_s; setting->process_content = &fss_write_basic_process_content; @@ -160,22 +159,22 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { } else { if (setting->flag & fss_write_flag_help_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); break; } - if (setting->status != F_status_set_error(F_parameter)) { + if (setting->state.status != F_status_set_error(F_parameter)) { fss_write_print_line_first_locked(setting, main->error); } - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_main_print_error_format_unknown(main->error, argv[index]); } } // for - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { if (setting->flag & fss_write_flag_help_e) { fss_write_main_process_help(main, setting); } @@ -184,7 +183,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { } } else if (main->parameters.array[fss_write_parameter_as_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); if (setting->flag & fss_write_flag_help_e) { fss_write_main_process_help(main, setting); diff --git a/level_3/fss_write/c/main/main.h b/level_3/fss_write/c/main/main.h index b291120..7c230ae 100644 --- a/level_3/fss_write/c/main/main.h +++ b/level_3/fss_write/c/main/main.h @@ -40,7 +40,7 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * The main program settings. * Must be of type (fss_write_setting_t *). * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -66,13 +66,13 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * * This alters setting.process_help, setting.process_normal, and setting.process_pipe. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_interrupt on (exit) signal received. * * F_parameter (with error bit) if main is NULL or setting is NULL. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_data_not on success but nothing was provided to operate with. * @@ -81,8 +81,6 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * Errors (with error bit) from: f_string_dynamics_resize(). * Errors (with error bit) from: fll_program_parameter_process_context(). * Errors (with error bit) from: fll_program_parameter_process_verbosity(). - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @see f_console_parameter_process() * @see f_file_stream_open() @@ -93,7 +91,7 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * @see fss_write_setting_load() */ #ifndef _di_fss_write_main_setting_load_as_ - extern void fss_write_main_setting_load_as(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting, f_state_t * const state); + extern void fss_write_main_setting_load_as(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting); #endif // _di_fss_write_main_setting_load_as_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/main/print.c b/level_3/fss_write/c/main/print.c index e31b9d5..4895822 100644 --- a/level_3/fss_write/c/main/print.c +++ b/level_3/fss_write/c/main/print.c @@ -10,7 +10,7 @@ extern "C" { if (!setting || print.verbosity == f_console_verbosity_quiet_e) return F_output_not; fss_write_print_line_first_locked(setting, print); - fll_error_print(print, F_status_set_fine(setting->status), function, fll_error_file_flag_fallback_e); + fll_error_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e); return F_none; } @@ -22,7 +22,7 @@ extern "C" { if (!setting || print.verbosity == f_console_verbosity_quiet_e) return F_output_not; fss_write_print_line_first_locked(setting, print); - fll_error_file_print(print, F_status_set_fine(setting->status), function, fll_error_file_flag_fallback_e, name, operation, type); + fll_error_file_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e, name, operation, type); return F_none; } @@ -162,7 +162,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & fss_write_flag_file_to_e) return F_output_not; } @@ -178,7 +178,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & fss_write_flag_file_to_e) return F_output_not; } @@ -194,7 +194,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & fss_write_flag_file_to_e) return F_output_not; } @@ -210,7 +210,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & fss_write_flag_file_to_e) return F_output_not; } diff --git a/level_3/fss_write/c/main/print.h b/level_3/fss_write/c/main/print.h index e8f67c4..3ab0bd1 100644 --- a/level_3/fss_write/c/main/print.h +++ b/level_3/fss_write/c/main/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -38,7 +38,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * @param function @@ -67,7 +67,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -87,7 +87,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -105,7 +105,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -123,7 +123,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -143,7 +143,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. */ @@ -159,7 +159,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. */ @@ -175,7 +175,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. */ @@ -193,7 +193,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -215,7 +215,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -237,7 +237,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -259,7 +259,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/fss_write/c/payload/fss_write.c b/level_3/fss_write/c/payload/fss_write.c index ca5b3f9..4f93986 100644 --- a/level_3/fss_write/c/payload/fss_write.c +++ b/level_3/fss_write/c/payload/fss_write.c @@ -45,35 +45,35 @@ extern "C" { uint8_t state = 0; // This is processed in a single set, so there is only ever one Object added. - setting->status = f_string_dynamics_increase(setting->state.step_small, &setting->objects); + setting->state.status = f_string_dynamics_increase(setting->state.step_small, &setting->objects); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); return; } // This is processed in a single set, so there is only ever one Content added. - setting->status = f_string_dynamicss_increase(setting->state.step_small, &setting->contentss); + setting->state.status = f_string_dynamicss_increase(setting->state.step_small, &setting->contentss); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamicss_increase)); return; } - setting->status = f_string_dynamics_increase(setting->state.step_small, setting->contents); + setting->state.status = f_string_dynamics_increase(setting->state.step_small, setting->contents); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); return; } // This is processed in a single set, so there is only ever one Ignores added. - setting->status = f_string_rangess_increase(setting->state.step_small, &setting->ignoress); + setting->state.status = f_string_rangess_increase(setting->state.step_small, &setting->ignoress); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_rangess_increase)); return; @@ -90,7 +90,7 @@ extern "C" { if (fll_program_standard_signal_received(main)) { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); break; } @@ -132,9 +132,9 @@ extern "C" { flag -= flag | 0x4; setting->contents->used = 0; - setting->status = f_string_dynamic_increase_by(setting->block.used, setting->object); + setting->state.status = f_string_dynamic_increase_by(setting->block.used, setting->object); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); break; @@ -176,7 +176,7 @@ extern "C" { setting->object->string[setting->object->used++] = setting->block.string[range.start]; } // for - if (F_status_is_error(setting->status)) break; + if (F_status_is_error(setting->state.status)) break; // If the start of Content was not found, then fetch the next block. if (state == 0x1) continue; @@ -191,16 +191,16 @@ extern "C" { // Check to see if the Content supports multiple Content per Object. if (flag & 0x4) { if (!(setting->flag & fss_write_flag_content_multiple_e)) { - setting->status = F_status_set_error(F_support_not); + setting->state.status = F_status_set_error(F_support_not); fss_write_print_error_one_content_only(setting, main->error); break; } - setting->status = f_string_dynamics_increase(setting->state.step_small, setting->contents); + setting->state.status = f_string_dynamics_increase(setting->state.step_small, setting->contents); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); break; @@ -217,9 +217,9 @@ extern "C" { // When payload is provided, all data at this point is part of the payload until the end of the pipe. if (fl_string_dynamic_compare(f_fss_payload_s, *setting->object) == F_equal_to) { if (total > 1) { - setting->status = f_string_dynamic_increase_by(total, &setting->contents->array[setting->contents->used]); + setting->state.status = f_string_dynamic_increase_by(total, &setting->contents->array[setting->contents->used]); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); break; @@ -241,9 +241,9 @@ extern "C" { } if (total) { - setting->status = f_string_dynamic_increase_by(total, &setting->contents->array[setting->contents->used]); + setting->state.status = f_string_dynamic_increase_by(total, &setting->contents->array[setting->contents->used]); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); break; @@ -254,7 +254,7 @@ extern "C" { // Do not handle start/end while inside an ignore set. if (!(flag & 0x2)) { if (setting->block.string[range.start] == fss_write_pipe_content_start_s.string[0]) { - setting->status = F_status_set_error(F_support_not); + setting->state.status = F_status_set_error(F_support_not); fss_write_print_error_one_content_only(setting, main->error); @@ -286,7 +286,7 @@ extern "C" { setting->contents->array[setting->contents->used].string[setting->contents->array[setting->contents->used].used++] = setting->block.string[range.start]; } // for - if (F_status_is_error(setting->status)) break; + if (F_status_is_error(setting->state.status)) break; ++setting->contents->used; flag |= 0x4; @@ -299,7 +299,7 @@ extern "C" { // End Object or Content set. if (state == 0x3) { fss_write_payload_process_set(main, void_setting); - if (F_status_is_error(setting->status)) break; + if (F_status_is_error(setting->state.status)) break; state = 0; flag |= 0x1; @@ -317,9 +317,9 @@ extern "C" { if (setting->block.used && range.start <= range.stop) { length = (range.stop - range.start) + 1; - setting->status = f_string_dynamic_increase_by(length + 1, &setting->contents->array[setting->contents->used]); + setting->state.status = f_string_dynamic_increase_by(length + 1, &setting->contents->array[setting->contents->used]); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); break; @@ -342,7 +342,7 @@ extern "C" { } // for // If the pipe ended before finishing, then attempt to wrap up. - if (F_status_is_error_not(setting->status) && status_pipe == F_none_eof && state) { + if (F_status_is_error_not(setting->state.status) && status_pipe == F_none_eof && state) { fss_write_payload_process_set(main, void_setting); flag |= 0x1; @@ -357,17 +357,17 @@ extern "C" { setting->contentss.used = used_contentss; setting->ignoress.used = used_ignoress; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (flag & 0x1) { if (flag & 0x8) { - setting->status = F_payload; + setting->state.status = F_payload; } else { - setting->status = F_none; + setting->state.status = F_none; } } else { - setting->status = F_data_not; + setting->state.status = F_data_not; } // Payload. @@ -396,7 +396,7 @@ extern "C" { setting->range.stop = 0; } - setting->status = fll_fss_payload_write( + setting->state.status = fll_fss_payload_write( *setting->object, setting->contents->array[0], (setting->flag & fss_write_flag_trim_e), @@ -407,8 +407,8 @@ extern "C" { &setting->buffer ); - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); + if (F_status_set_fine(setting->state.status) == F_none_eol) { + setting->state.status = F_status_set_error(F_support_not); fss_write_print_line_first_locked(setting, main->error); fss_write_print_error_unsupported_eol(setting, main->error); @@ -416,7 +416,7 @@ extern "C" { return; } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fll_fss_payload_write)); return; @@ -433,7 +433,7 @@ extern "C" { setting->range.stop = 0; } - setting->status = fl_fss_basic_list_object_write( + setting->state.status = fl_fss_basic_list_object_write( *setting->object, (setting->flag & fss_write_flag_partial_e) ? (setting->flag & fss_write_flag_trim_e) @@ -447,8 +447,8 @@ extern "C" { &setting->buffer ); - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); + if (F_status_set_fine(setting->state.status) == F_none_eol) { + setting->state.status = F_status_set_error(F_support_not); fss_write_print_line_first_locked(setting, main->error); fss_write_print_error_unsupported_eol(setting, main->error); @@ -456,7 +456,7 @@ extern "C" { return; } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_object_write)); return; @@ -465,13 +465,13 @@ extern "C" { if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_content_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { if (setting->flag & fss_write_flag_object_open_e) { - setting->status = f_string_dynamic_append(f_fss_basic_list_open_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_fss_basic_list_open_s, &setting->buffer); - if (F_status_is_error_not(setting->status)) { - setting->status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &setting->buffer); + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &setting->buffer); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); return; @@ -493,7 +493,7 @@ extern "C" { prepend = &main->parameters.arguments.array[index]; } - setting->status = fl_fss_basic_list_content_write( + setting->state.status = fl_fss_basic_list_content_write( setting->contents->array[0], setting->object ? f_fss_complete_full_e @@ -504,7 +504,7 @@ extern "C" { &setting->buffer ); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_payload_content_write)); return; @@ -513,9 +513,9 @@ extern "C" { if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_object_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { if (setting->flag & fss_write_flag_content_end_e) { - setting->status = f_string_dynamic_append(f_fss_basic_list_close_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_fss_basic_list_close_s, &setting->buffer); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); return; @@ -525,9 +525,9 @@ extern "C" { } if (!setting->object || !(setting->contents && setting->contents->used)) { - setting->status = f_string_dynamic_append(f_string_eol_s, &setting->buffer); + setting->state.status = f_string_dynamic_append(f_string_eol_s, &setting->buffer); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); return; @@ -537,7 +537,7 @@ extern "C" { fll_print_dynamic(setting->buffer, main->output.to); setting->buffer.used = 0; - setting->status = F_none; + setting->state.status = F_none; } #endif // _di_fss_write_payload_process_set_ @@ -554,7 +554,7 @@ extern "C" { for (f_array_length_t i = 0; i < values->used; ++i) { if (fl_string_dynamic_compare(argv[values->array[i]], fss_write_payload_s) == F_equal_to && i + 1 < values->used) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); fss_write_payload_print_error_payload_not_last(setting, main->error); diff --git a/level_3/fss_write/c/payload/fss_write.h b/level_3/fss_write/c/payload/fss_write.h index 3367711..7882c34 100644 --- a/level_3/fss_write/c/payload/fss_write.h +++ b/level_3/fss_write/c/payload/fss_write.h @@ -65,7 +65,7 @@ extern "C" { * The main program settings. * Must be of type (fss_write_setting_t *). * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -84,7 +84,7 @@ extern "C" { * The main program settings. * Must be of type (fss_write_setting_t *). * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_data_not on success but pipe contained no relevant data. * F_payload on success and the payload has been printed. @@ -105,7 +105,7 @@ extern "C" { * The main program settings. * Must be of type (fss_write_setting_t *). * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_interrupt on (exit) signal received. * @@ -131,23 +131,21 @@ extern "C" { * * This alters setting.process_help, setting.process_normal, and setting.process_pipe. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_interrupt on (exit) signal received. * * F_parameter (with error bit) if main is NULL or setting is NULL. * F_parameter (with error bit) on parameter error. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_data_not on success but nothing was provided to operate with. - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @see fss_write_setting_load() */ #ifndef _di_fss_write_payload_setting_load_ - extern void fss_write_payload_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting, f_state_t * const state); + extern void fss_write_payload_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting); #endif // _di_fss_write_payload_setting_load_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/payload/main.c b/level_3/fss_write/c/payload/main.c index e8bf57b..153ddb7 100644 --- a/level_3/fss_write/c/payload/main.c +++ b/level_3/fss_write/c/payload/main.c @@ -28,7 +28,6 @@ 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); - f_state_t state = f_state_t_initialize; fss_write_setting_load(arguments, state, &data, &setting, &fss_write_payload_setting_load); } diff --git a/level_3/fss_write/c/payload/print.h b/level_3/fss_write/c/payload/print.h index c65bc54..a54ab96 100644 --- a/level_3/fss_write/c/payload/print.h +++ b/level_3/fss_write/c/payload/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -38,7 +38,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * diff --git a/level_3/iki_read/c/main/common.c b/level_3/iki_read/c/main/common.c index 603da31..9bc426e 100644 --- a/level_3/iki_read/c/main/common.c +++ b/level_3/iki_read/c/main/common.c @@ -25,16 +25,15 @@ extern "C" { #endif // _di_iki_read_setting_delete_ #ifndef _di_iki_read_setting_load_ - void iki_read_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, iki_read_setting_t * const setting) { + void iki_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, iki_read_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(f_console_parameter_process)); return; @@ -51,9 +50,9 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(fll_program_parameter_process_context)); return; @@ -82,9 +81,9 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(fll_program_parameter_process_verbosity)); return; @@ -111,7 +110,7 @@ extern "C" { } if (!(main->parameters.remaining.used || (main->pipe & fll_program_data_pipe_input_e))) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_missing_file(main->error); @@ -121,7 +120,7 @@ extern "C" { if (main->parameters.array[iki_read_parameter_at_e].result & f_console_result_value_e) { if (main->parameters.array[iki_read_parameter_whole_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_at_s, iki_read_long_whole_s); @@ -133,10 +132,10 @@ extern "C" { setting->at = 0; - setting->status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->at); + setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->at); - if (F_status_is_error(setting->status)) { - setting->status = F_status_set_error(F_parameter); + if (F_status_is_error(setting->state.status)) { + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_integer_not(main->error, f_console_symbol_long_normal_s, iki_read_long_at_s, main->parameters.arguments.array[index]); @@ -147,7 +146,7 @@ extern "C" { setting->flag |= iki_read_main_flag_at_e; } else if (main->parameters.array[iki_read_parameter_at_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, iki_read_long_at_s); @@ -160,10 +159,10 @@ extern "C" { setting->line = 0; - setting->status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->line); + setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->line); - if (F_status_is_error(setting->status)) { - setting->status = F_status_set_error(F_parameter); + if (F_status_is_error(setting->state.status)) { + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_integer_not(main->error, f_console_symbol_long_normal_s, iki_read_long_line_s, main->parameters.arguments.array[index]); @@ -174,7 +173,7 @@ extern "C" { setting->flag |= iki_read_main_flag_line_e; } else if (main->parameters.array[iki_read_parameter_line_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, iki_read_long_line_s); @@ -185,9 +184,9 @@ extern "C" { if (main->parameters.array[iki_read_parameter_name_e].result & f_console_result_value_e) { setting->names.used = 0; - setting->status = f_string_dynamics_increase_by(main->parameters.array[iki_read_parameter_name_e].values.used, &setting->names); + setting->state.status = f_string_dynamics_increase_by(main->parameters.array[iki_read_parameter_name_e].values.used, &setting->names); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamics_increase_by)); return; @@ -209,16 +208,16 @@ extern "C" { setting->names.array[setting->names.used].used = 0; if (main->parameters.arguments.array[values->array[i]].used) { - setting->status = f_string_dynamics_append(main->parameters.arguments.array[values->array[i]], &setting->names); - if (F_status_is_error(setting->status)) break; + setting->state.status = f_string_dynamics_append(main->parameters.arguments.array[values->array[i]], &setting->names); + if (F_status_is_error(setting->state.status)) break; } else { - setting->status = f_string_dynamics_append(f_string_empty_s, &setting->names); - if (F_status_is_error(setting->status)) break; + setting->state.status = f_string_dynamics_append(f_string_empty_s, &setting->names); + if (F_status_is_error(setting->state.status)) break; } } // for - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamics_append)); return; @@ -227,7 +226,7 @@ extern "C" { setting->flag |= iki_read_main_flag_name_e; } else if (main->parameters.array[iki_read_parameter_name_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, iki_read_long_name_s); @@ -237,7 +236,7 @@ extern "C" { if (main->parameters.array[iki_read_parameter_replace_e].result != f_console_result_none_e) { if ((main->parameters.array[iki_read_parameter_replace_e].result & f_console_result_found_e) || main->parameters.array[iki_read_parameter_replace_e].values.used % 2 != 0) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_normal_s, iki_read_long_replace_s, iki_read_string_two_s); @@ -247,9 +246,9 @@ extern "C" { setting->replace.used = 0; - setting->status = f_string_maps_increase_by(main->parameters.array[iki_read_parameter_replace_e].values.used / 2, &setting->replace); + setting->state.status = f_string_maps_increase_by(main->parameters.array[iki_read_parameter_replace_e].values.used / 2, &setting->replace); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_maps_increase_by)); return; @@ -276,14 +275,14 @@ extern "C" { // Static strings are being used, so if a dynamic string exists (size > 0), then de-allocate it. if (setting->replace.array[at].name.size) { - setting->status = f_string_dynamic_resize(0, &setting->replace.array[at].name); + setting->state.status = f_string_dynamic_resize(0, &setting->replace.array[at].name); } - if (F_status_is_error_not(setting->status) && setting->replace.array[at].value.size) { - setting->status = f_string_dynamic_resize(0, &setting->replace.array[at].value); + if (F_status_is_error_not(setting->state.status) && setting->replace.array[at].value.size) { + setting->state.status = f_string_dynamic_resize(0, &setting->replace.array[at].value); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_resize)); return; @@ -311,17 +310,17 @@ extern "C" { setting->flag |= iki_read_main_flag_reassign_e; } - if (F_status_is_error(setting->status)) return; + if (F_status_is_error(setting->state.status)) return; if (iki_read_setting_load_parameter_substitution(main, setting, main->parameters.array[iki_read_parameter_substitute_e], iki_read_long_substitute_s, &setting->substitute)) { setting->flag |= iki_read_main_flag_substitute_e; } - if (F_status_is_error(setting->status)) return; + if (F_status_is_error(setting->state.status)) return; if (main->parameters.array[iki_read_parameter_wrap_e].result != f_console_result_none_e) { if ((main->parameters.array[iki_read_parameter_wrap_e].result & f_console_result_found_e) || main->parameters.array[iki_read_parameter_wrap_e].values.used % 3 != 0) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_normal_s, iki_read_long_wrap_s, iki_read_string_three_s); @@ -331,9 +330,9 @@ extern "C" { setting->wrap.used = 0; - setting->status = f_string_triples_increase_by(main->parameters.array[iki_read_parameter_wrap_e].values.used / 3, &setting->wrap); + setting->state.status = f_string_triples_increase_by(main->parameters.array[iki_read_parameter_wrap_e].values.used / 3, &setting->wrap); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_triples_increase_by)); return; @@ -360,18 +359,18 @@ extern "C" { // Static strings are being used, so if a dynamic string exists (size > 0), then de-allocate it. if (setting->wrap.array[at].a.size) { - setting->status = f_string_dynamic_resize(0, &setting->wrap.array[at].a); + setting->state.status = f_string_dynamic_resize(0, &setting->wrap.array[at].a); } - if (F_status_is_error_not(setting->status) && setting->wrap.array[at].b.size) { - setting->status = f_string_dynamic_resize(0, &setting->wrap.array[at].b); + if (F_status_is_error_not(setting->state.status) && setting->wrap.array[at].b.size) { + setting->state.status = f_string_dynamic_resize(0, &setting->wrap.array[at].b); } - if (F_status_is_error_not(setting->status) && setting->wrap.array[at].c.size) { - setting->status = f_string_dynamic_resize(0, &setting->wrap.array[at].c); + if (F_status_is_error_not(setting->state.status) && setting->wrap.array[at].c.size) { + setting->state.status = f_string_dynamic_resize(0, &setting->wrap.array[at].c); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_resize)); return; @@ -417,7 +416,7 @@ extern "C" { for (uint8_t i = 0; i < 3; ++i) { if (main->parameters.array[ids[i]].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_literal_s, names[i]); @@ -442,7 +441,7 @@ extern "C" { for (uint8_t i = 0; i < 2; ++i) { if (main->parameters.array[ids[i]].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_object_s, names[i]); @@ -455,7 +454,7 @@ extern "C" { } else if (main->parameters.array[iki_read_parameter_content_e].result & f_console_result_found_e) { if (main->parameters.array[iki_read_parameter_total_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_content_s, iki_read_long_total_s); @@ -467,7 +466,7 @@ extern "C" { } else if (main->parameters.array[iki_read_parameter_total_e].result & f_console_result_found_e) { if (main->parameters.array[iki_read_parameter_whole_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_total_s, iki_read_long_wrap_s); @@ -490,9 +489,9 @@ extern "C" { if (main->parameters.remaining.used) { setting->files.used = 0; - setting->status = f_string_dynamics_resize(main->parameters.remaining.used, &setting->files); + setting->state.status = f_string_dynamics_resize(main->parameters.remaining.used, &setting->files); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamics_resize)); return; @@ -504,9 +503,9 @@ extern "C" { // Static strings are being used, so if a dynamic string exists (size > 0), then de-allocate it. if (setting->files.array[setting->files.used].size) { - setting->status = f_string_dynamic_resize(0, &setting->files.array[setting->files.used]); + setting->state.status = f_string_dynamic_resize(0, &setting->files.array[setting->files.used]); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_resize)); return; @@ -519,11 +518,11 @@ extern "C" { setting->files.array[setting->files.used].used = main->parameters.arguments.array[index].used; setting->files.array[setting->files.used].size = 0; - setting->status = f_file_exists(setting->files.array[setting->files.used], F_true); + setting->state.status = f_file_exists(setting->files.array[setting->files.used], F_true); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_line_first_locked(setting, main->error); - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_exists", fll_error_file_flag_fallback_e, setting->files.array[setting->files.used], f_file_operation_verify_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(setting->state.status), "f_file_exists", fll_error_file_flag_fallback_e, setting->files.array[setting->files.used], f_file_operation_verify_s, fll_error_file_type_file_e); return; } @@ -538,7 +537,7 @@ extern "C" { if (!(parameter.result & f_console_result_found_e)) return F_false; if ((parameter.result & f_console_result_found_e) || parameter.values.used % 3 != 0) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_read_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_normal_s, name, iki_read_string_three_s); @@ -548,9 +547,9 @@ extern "C" { triple->used = 0; - setting->status = f_string_triples_increase_by(parameter.values.used / 3, triple); + setting->state.status = f_string_triples_increase_by(parameter.values.used / 3, triple); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_triples_increase_by)); return F_false; @@ -579,18 +578,18 @@ extern "C" { // Static strings are being used, so if a dynamic string exists (size > 0), then de-allocate it. if (triple->array[at].a.size) { - setting->status = f_string_dynamic_resize(0, &triple->array[at].a); + setting->state.status = f_string_dynamic_resize(0, &triple->array[at].a); } - if (F_status_is_error_not(setting->status) && triple->array[at].b.size) { - setting->status = f_string_dynamic_resize(0, &triple->array[at].b); + if (F_status_is_error_not(setting->state.status) && triple->array[at].b.size) { + setting->state.status = f_string_dynamic_resize(0, &triple->array[at].b); } - if (F_status_is_error_not(setting->status) && triple->array[at].c.size) { - setting->status = f_string_dynamic_resize(0, &triple->array[at].c); + if (F_status_is_error_not(setting->state.status) && triple->array[at].c.size) { + setting->state.status = f_string_dynamic_resize(0, &triple->array[at].c); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_resize)); return F_false; diff --git a/level_3/iki_read/c/main/common.h b/level_3/iki_read/c/main/common.h index a42d0b6..e08e35d 100644 --- a/level_3/iki_read/c/main/common.h +++ b/level_3/iki_read/c/main/common.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -42,14 +42,12 @@ extern "C" { * * @param arguments * The parameters passed to the process (often referred to as command line arguments). - * @param state - * A state for providing flags and handling interrupts during long running operations. * @param main * The main program data. * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). @@ -71,7 +69,7 @@ extern "C" { * @see fll_program_parameter_process_verbosity() */ #ifndef _di_iki_read_setting_load_ - extern void iki_read_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, iki_read_setting_t * const setting); + extern void iki_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, iki_read_setting_t * const setting); #endif // _di_iki_read_setting_load_ /** @@ -84,7 +82,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_string_dynamic_resize(). @@ -115,7 +113,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/iki_read/c/main/iki_read.c b/level_3/iki_read/c/main/iki_read.c index 771f864..78d92e7 100644 --- a/level_3/iki_read/c/main/iki_read.c +++ b/level_3/iki_read/c/main/iki_read.c @@ -11,13 +11,13 @@ extern "C" { if (!main || !setting) return; - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_line_last_locked(setting, main->error); return; } - setting->status = F_none; + setting->state.status = F_none; if (setting->flag & iki_read_main_flag_help_e) { iki_read_print_help(setting, main->message); @@ -44,9 +44,9 @@ extern "C" { setting->buffer.used = 0; - setting->status = f_file_read(file, &setting->buffer); + setting->state.status = f_file_read(file, &setting->buffer); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_read), f_string_ascii_minus_s, f_file_operation_process_s, fll_error_file_type_file_e); } else { @@ -54,7 +54,7 @@ extern "C" { } } - if (F_status_is_error_not(setting->status) && setting->files.used) { + if (F_status_is_error_not(setting->state.status) && setting->files.used) { f_file_t file = f_file_t_initialize; off_t size_block = 0; off_t size_file = 0; @@ -66,7 +66,7 @@ extern "C" { if (fll_program_standard_signal_received(main)) { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); break; } @@ -77,17 +77,17 @@ extern "C" { file.stream = 0; file.id = -1; - setting->status = f_file_stream_open(setting->files.array[i], f_string_empty_s, &file); + setting->state.status = f_file_stream_open(setting->files.array[i], f_string_empty_s, &file); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_stream_open), setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); break; } - setting->status = f_file_descriptor(&file); + setting->state.status = f_file_descriptor(&file); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_descriptor), setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); break; @@ -95,9 +95,9 @@ extern "C" { size_file = 0; - setting->status = f_file_size_by_id(file, &size_file); + setting->state.status = f_file_size_by_id(file, &size_file); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_size_by_id), setting->files.array[i], f_file_operation_analyze_s, fll_error_file_type_file_e); break; @@ -122,9 +122,9 @@ extern "C" { } // Pre-allocate entire file buffer plus space for the terminating NULL. - setting->status = f_string_dynamic_increase_by(size_file + 1, &setting->buffer); + setting->state.status = f_string_dynamic_increase_by(size_file + 1, &setting->buffer); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_string_dynamic_increase_by), setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); break; @@ -136,17 +136,17 @@ extern "C" { if (size_file > iki_read_block_max && fll_program_standard_signal_received(main)) { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); break; } - setting->status = f_file_stream_read_until(file, size_block, &setting->buffer); - if (F_status_is_error(setting->status)) break; + setting->state.status = f_file_stream_read_until(file, size_block, &setting->buffer); + if (F_status_is_error(setting->state.status)) break; } // for - if (F_status_is_error(setting->status)) { - if (F_status_set_fine(setting->status) != F_interrupt) { + if (F_status_is_error(setting->state.status)) { + if (F_status_set_fine(setting->state.status) != F_interrupt) { iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_stream_read_until), setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); } @@ -157,22 +157,19 @@ extern "C" { f_file_stream_close(&file); iki_read_process_buffer(main, setting); - if (F_status_is_error(setting->status)) break; + if (F_status_is_error(setting->state.status)) break; setting->buffer.used = 0; } // for - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { f_file_stream_flush(file); f_file_stream_close(&file); } } - if (F_status_is_error(setting->status)) { - iki_read_print_line_last_locked(setting, main->error); - } - else if (setting->status != F_interrupt) { - iki_read_print_line_last_locked(setting, main->message); + if (F_status_is_error(setting->state.status)) { + iki_read_print_line_last_locked(setting, F_status_set_fine(setting->state.status) == F_interrupt ? main->message : main->error); } } #endif // _di_iki_read_main_ diff --git a/level_3/iki_read/c/main/iki_read.h b/level_3/iki_read/c/main/iki_read.h index 350cbef..3848d5f 100644 --- a/level_3/iki_read/c/main/iki_read.h +++ b/level_3/iki_read/c/main/iki_read.h @@ -77,7 +77,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_true on success when performing verification and verify passed. * F_false on success when performing verification and verify failed. diff --git a/level_3/iki_read/c/main/main.c b/level_3/iki_read/c/main/main.c index 058f37d..36132a1 100644 --- a/level_3/iki_read/c/main/main.c +++ b/level_3/iki_read/c/main/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - iki_read_setting_load(arguments, state, &data, &setting); + iki_read_setting_load(arguments, &data, &setting); } iki_read_main(&data, &setting); diff --git a/level_3/iki_read/c/main/print.c b/level_3/iki_read/c/main/print.c index e667b4f..e062eca 100644 --- a/level_3/iki_read/c/main/print.c +++ b/level_3/iki_read/c/main/print.c @@ -11,7 +11,7 @@ extern "C" { if (print.verbosity < f_console_verbosity_error_e) return F_output_not; iki_read_print_line_first_locked(setting, print); - fll_error_print(print, F_status_set_fine(setting->status), function, fll_error_file_flag_fallback_e); + fll_error_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e); return F_none; } @@ -23,7 +23,7 @@ extern "C" { if (print.verbosity < f_console_verbosity_error_e) return F_output_not; iki_read_print_line_first_locked(setting, print); - fll_error_file_print(print, F_status_set_fine(setting->status), function, fll_error_file_flag_fallback_e, name, operation, type); + fll_error_file_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e, name, operation, type); return F_none; } @@ -129,7 +129,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -144,7 +144,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -159,7 +159,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -174,7 +174,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } diff --git a/level_3/iki_read/c/main/print.h b/level_3/iki_read/c/main/print.h index 8883895..b651fd9 100644 --- a/level_3/iki_read/c/main/print.h +++ b/level_3/iki_read/c/main/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -38,7 +38,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * @param function @@ -67,7 +67,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -88,7 +88,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -110,7 +110,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -132,7 +132,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -154,7 +154,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/iki_read/c/main/private-print.h b/level_3/iki_read/c/main/private-print.h index 4ac7eb3..8369be3 100644 --- a/level_3/iki_read/c/main/private-print.h +++ b/level_3/iki_read/c/main/private-print.h @@ -26,7 +26,7 @@ extern "C" { * The setting.map_wraps is expected to be defined as a valid pointer to an array. * The setting.map_replaces is expected to be defined as a valid pointer to an array. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param index * The index used to identify the desired range in variable, content, and ranges. */ @@ -42,7 +42,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param index * The index within the setting->map_wraps array to print. */ @@ -58,7 +58,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param index * The index within the setting->map_wraps array to print. */ diff --git a/level_3/iki_read/c/main/private-read.c b/level_3/iki_read/c/main/private-read.c index 3d501c8..29145c7 100644 --- a/level_3/iki_read/c/main/private-read.c +++ b/level_3/iki_read/c/main/private-read.c @@ -87,7 +87,7 @@ extern "C" { void iki_read_process_line(fll_program_data_t * const main, iki_read_setting_t * const setting, f_string_range_t *range) { if (!(setting->flag & iki_read_main_flag_line_e)) { - setting->status = F_false; + setting->state.status = F_false; return; } @@ -108,10 +108,10 @@ extern "C" { if (setting->buffer.string[range->stop] == f_string_eol_s.string[0]) break; } // for - setting->status = F_true; + setting->state.status = F_true; } else { - setting->status = F_data_not; + setting->state.status = F_data_not; } } #endif // _di_iki_read_process_line_ @@ -122,8 +122,8 @@ extern "C" { if (setting->flag & iki_read_main_flag_total_e) { iki_read_process_buffer_total(main, setting); - if (F_status_is_error_not(setting->status)) { - setting->status = F_none; + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = F_none; } return; @@ -133,15 +133,15 @@ extern "C" { iki_read_process_line(main, setting, &buffer_range); - if (setting->status == F_true) { + if (setting->state.status == F_true) { if (buffer_range.start > setting->buffer.used) { - setting->status = F_data_not; + setting->state.status = F_data_not; return; } } - else if (setting->status == F_data_not) { - setting->status = F_data_not; + else if (setting->state.status == F_data_not) { + setting->state.status = F_data_not; return; } @@ -153,8 +153,8 @@ extern "C" { iki_read_process_buffer_ranges(main, setting, &buffer_range); } - if (F_status_is_error_not(setting->status)) { - setting->status = F_none; + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = F_none; } } #endif // _di_iki_read_process_buffer_ @@ -165,10 +165,10 @@ extern "C" { { const f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large_d, iki_read_common_allocation_small_d, 0, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); - setting->status = fl_iki_read(&setting->buffer, buffer_range, &setting->data, state); + setting->state.status = fl_iki_read(&setting->buffer, buffer_range, &setting->data, state); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(fl_iki_read)); return; @@ -224,10 +224,10 @@ extern "C" { f_file_stream_unlock(main->output.to); if (unmatched) { - setting->status = F_data_not; + setting->state.status = F_data_not; } else { - setting->status = F_none; + setting->state.status = F_none; } } else { @@ -242,10 +242,10 @@ extern "C" { f_file_stream_unlock(main->output.to); - setting->status = F_none; + setting->state.status = F_none; } else { - setting->status = F_data_not; + setting->state.status = F_data_not; } } else { @@ -260,11 +260,11 @@ extern "C" { f_file_stream_unlock(main->output.to); - setting->status = F_none; + setting->state.status = F_none; } } else { - setting->status = F_data_not; + setting->state.status = F_data_not; } } } @@ -278,10 +278,10 @@ extern "C" { { const f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large_d, iki_read_common_allocation_small_d, 0, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); - setting->status = fl_iki_read(&setting->buffer, &range, &setting->data, state); + setting->state.status = fl_iki_read(&setting->buffer, &range, &setting->data, state); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(fl_iki_read)); return; @@ -296,7 +296,7 @@ extern "C" { if (!setting->data.variable.used) { fll_print_dynamic_partial(setting->buffer, buffer_range, main->output.to); - setting->status = F_none; + setting->state.status = F_none; return; } @@ -361,7 +361,7 @@ extern "C" { f_file_stream_unlock(main->output.to); } - setting->status = F_none; + setting->state.status = F_none; } #endif // _di_iki_read_process_buffer_ranges_whole_ @@ -372,19 +372,19 @@ extern "C" { iki_read_process_line(main, setting, &range); - if (setting->status == F_true) { + if (setting->state.status == F_true) { if (range.start > setting->buffer.used) { fll_print_format("%r%r", main->output.to, f_string_ascii_0_s, f_string_eol_s); - setting->status = F_none; + setting->state.status = F_none; return; } } - else if (setting->status == F_data_not) { + else if (setting->state.status == F_data_not) { fll_print_format("%r%r", main->output.to, f_string_ascii_0_s, f_string_eol_s); - setting->status = F_none; + setting->state.status = F_none; return; } @@ -392,10 +392,10 @@ extern "C" { { f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large_d, iki_read_common_allocation_small_d, 0, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); - setting->status = fl_iki_read(&setting->buffer, &range, &setting->data, state); + setting->state.status = fl_iki_read(&setting->buffer, &range, &setting->data, state); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(fl_iki_read)); return; @@ -424,7 +424,7 @@ extern "C" { f_string_dynamic_resize(0, &name); - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); return; } @@ -435,9 +435,9 @@ extern "C" { index = main->parameters.array[iki_read_parameter_name_e].values.array[i]; name.used = 0; - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &name); + setting->state.status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &name); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_append_nulless)); f_string_dynamic_resize(0, &name); @@ -449,9 +449,9 @@ extern "C" { for (j = 0; j < setting->data.vocabulary.used; ++j) { - setting->status = fl_string_dynamic_partial_compare(name, setting->buffer, range, setting->data.vocabulary.array[j]); + setting->state.status = fl_string_dynamic_partial_compare(name, setting->buffer, range, setting->data.vocabulary.array[j]); - if (setting->status == F_equal_to) ++total; + if (setting->state.status == F_equal_to) ++total; } // for } // for @@ -473,7 +473,7 @@ extern "C" { fll_print_format("%ul%r", main->output.to, total, f_string_eol_s); - setting->status = F_none; + setting->state.status = F_none; } #endif // _di_iki_read_process_buffer_total_ diff --git a/level_3/iki_read/c/main/private-read.h b/level_3/iki_read/c/main/private-read.h index 3d554b9..724fd37 100644 --- a/level_3/iki_read/c/main/private-read.h +++ b/level_3/iki_read/c/main/private-read.h @@ -67,7 +67,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_true is returned if the range is processed. * F_false is returned if the range is not processed. * F_data_not if the range is processed, but the requested line is out of range. @@ -88,7 +88,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_data_not on success, but nothing done. * diff --git a/level_3/iki_write/c/main/common.c b/level_3/iki_write/c/main/common.c index 4e7cbed..b3d9a4d 100644 --- a/level_3/iki_write/c/main/common.c +++ b/level_3/iki_write/c/main/common.c @@ -22,16 +22,15 @@ extern "C" { #endif // _di_iki_write_setting_delete_ #ifndef _di_iki_write_setting_load_ - void iki_write_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, iki_write_setting_t * const setting) { + void iki_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, iki_write_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_write_print_error(setting, main->error, macro_iki_write_f(f_console_parameter_process)); return; @@ -48,9 +47,9 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_write_print_error(setting, main->error, macro_iki_write_f(fll_program_parameter_process_context)); return; @@ -79,9 +78,9 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_write_print_error(setting, main->error, macro_iki_write_f(fll_program_parameter_process_verbosity)); return; @@ -113,7 +112,7 @@ extern "C" { if (main->parameters.array[iki_write_parameter_file_e].result & f_console_result_value_e && main->parameters.array[iki_write_parameter_file_e].values.used) { if (main->parameters.array[iki_write_parameter_file_e].values.used > 1) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_must_specify_once(main->error, f_console_symbol_long_normal_s, iki_write_long_file_s); @@ -126,11 +125,11 @@ extern "C" { main->output.to.id = -1; main->output.to.stream = 0; - setting->status = f_file_stream_open(main->parameters.arguments.array[index], f_string_empty_s, &main->output.to); + setting->state.status = f_file_stream_open(main->parameters.arguments.array[index], f_string_empty_s, &main->output.to); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_write_print_line_first_locked(setting, main->error); - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", fll_error_file_flag_fallback_e, main->parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(setting->state.status), "f_file_stream_open", fll_error_file_flag_fallback_e, main->parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); return; } @@ -138,7 +137,7 @@ extern "C" { setting->flag |= iki_write_main_flag_file_to_e; } else if (main->parameters.array[iki_write_parameter_file_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, iki_write_long_file_s); @@ -151,9 +150,9 @@ extern "C" { setting->objects.used = 0; - setting->status = f_string_dynamics_resize(values->used, &setting->objects); + setting->state.status = f_string_dynamics_resize(values->used, &setting->objects); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamics_resize)); return; @@ -172,7 +171,7 @@ extern "C" { setting->flag |= iki_write_main_flag_object_e; } else if (main->parameters.array[iki_write_parameter_object_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, iki_write_long_object_s); @@ -185,9 +184,9 @@ extern "C" { setting->contents.used = 0; - setting->status = f_string_dynamics_resize(values->used, &setting->contents); + setting->state.status = f_string_dynamics_resize(values->used, &setting->contents); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamics_resize)); return; @@ -206,7 +205,7 @@ extern "C" { setting->flag |= iki_write_main_flag_content_e; } else if (main->parameters.array[iki_write_parameter_content_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_write_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, iki_write_long_content_s); @@ -215,7 +214,7 @@ extern "C" { } if (!(main->pipe & fll_program_data_pipe_input_e) && !(setting->flag & (iki_write_main_flag_content_e | iki_write_parameter_object_e))) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_write_print_line_first_locked(setting, main->error); iki_write_print_error_main_missing(setting, main->error); diff --git a/level_3/iki_write/c/main/common.h b/level_3/iki_write/c/main/common.h index 4378c8c..0b2e49e 100644 --- a/level_3/iki_write/c/main/common.h +++ b/level_3/iki_write/c/main/common.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -47,7 +47,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). @@ -55,8 +55,6 @@ extern "C" { * Errors (with error bit) from: f_string_dynamics_resize(). * Errors (with error bit) from: fll_program_parameter_process_context(). * Errors (with error bit) from: fll_program_parameter_process_verbosity(). - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @see f_console_parameter_process() * @see f_file_stream_open() @@ -65,7 +63,7 @@ extern "C" { * @see fll_program_parameter_process_verbosity() */ #ifndef _di_iki_write_setting_load_ - extern void iki_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, iki_write_setting_t * const setting, f_state_t * const state); + extern void iki_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, iki_write_setting_t * const setting); #endif // _di_iki_write_setting_load_ /** @@ -77,7 +75,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/iki_write/c/main/iki_write.c b/level_3/iki_write/c/main/iki_write.c index bc4c8c4..77fc5a4 100644 --- a/level_3/iki_write/c/main/iki_write.c +++ b/level_3/iki_write/c/main/iki_write.c @@ -11,13 +11,13 @@ extern "C" { if (!main || !setting) return; - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_write_print_line_last_locked(setting, main->error); return; } - setting->status = F_none; + setting->state.status = F_none; if (setting->flag & iki_write_main_flag_help_e) { iki_write_print_help(setting, main->message); @@ -59,7 +59,7 @@ extern "C" { do { if (!((++main->signal_check) % iki_write_signal_check_d)) { if (fll_program_standard_signal_received(main)) { - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); return; } @@ -71,7 +71,7 @@ extern "C" { status = f_file_read(pipe, &setting->buffer); if (F_status_is_error(status)) { - setting->status = F_status_set_error(F_pipe); + setting->state.status = F_status_set_error(F_pipe); iki_write_print_error_file(setting, main->error, macro_iki_write_f(f_file_read), f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); @@ -79,7 +79,7 @@ extern "C" { } if (!setting->buffer.used) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_write_print_line_first_locked(setting, main->error); fll_program_print_error_pipe_missing_content(main->error); @@ -92,20 +92,20 @@ extern "C" { } previous = range.start; - setting->status = f_string_dynamic_seek_to(setting->buffer, f_string_ascii_feed_form_s.string[0], &range); + setting->state.status = f_string_dynamic_seek_to(setting->buffer, f_string_ascii_feed_form_s.string[0], &range); - if (setting->status == F_data_not_stop) { - setting->status = F_status_set_error(F_parameter); + if (setting->state.status == F_data_not_stop) { + setting->state.status = F_status_set_error(F_parameter); } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamic_seek_to)); return; } if (object_ended && previous == range.start) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_write_print_line_first_locked(setting, main->error); fll_program_print_error_pipe_invalid_form_feed(main->error); @@ -121,9 +121,9 @@ extern "C" { setting->content.used = 0; if (setting->buffer.used) { - setting->status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->content); + setting->state.status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->content); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamic_partial_append_nulless)); return; @@ -131,7 +131,7 @@ extern "C" { } iki_write_process(main, setting, setting->object, setting->content); - if (F_status_is_error(setting->status)) return; + if (F_status_is_error(setting->state.status)) return; fll_print_dynamic_raw(f_string_eol_s, main->output.to); @@ -140,9 +140,9 @@ extern "C" { else { setting->object.used = 0; - setting->status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->object); + setting->state.status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->object); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamic_partial_append_nulless)); return; @@ -164,7 +164,7 @@ extern "C" { } while (status != F_none_eof || setting->buffer.used || object_ended); if (object_ended) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); iki_write_print_line_first_locked(setting, main->error); fll_program_print_error_pipe_object_without_content(main->error); @@ -178,7 +178,7 @@ extern "C" { if (!((++main->signal_check) % iki_write_signal_check_d)) { if (fll_program_standard_signal_received(main)) { - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); break; } @@ -187,16 +187,13 @@ extern "C" { } iki_write_process(main, setting, setting->objects.array[i], setting->contents.array[i]); - if (F_status_is_error(setting->status)) break; + if (F_status_is_error(setting->state.status)) break; fll_print_dynamic_raw(f_string_eol_s, main->output.to); } // for - if (F_status_is_error(setting->status)) { - iki_write_print_line_last_locked(setting, main->error); - } - else if (setting->status != F_interrupt) { - iki_write_print_line_last_locked(setting, main->message); + if (F_status_is_error(setting->state.status)) { + iki_write_print_line_last_locked(setting, F_status_set_fine(setting->state.status) == F_interrupt ? main->message : main->error); } } #endif // _di_iki_write_main_ diff --git a/level_3/iki_write/c/main/iki_write.h b/level_3/iki_write/c/main/iki_write.h index 5c1151d..68e4f63 100644 --- a/level_3/iki_write/c/main/iki_write.h +++ b/level_3/iki_write/c/main/iki_write.h @@ -77,7 +77,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_true on success when performing verification and verify passed. * F_false on success when performing verification and verify failed. diff --git a/level_3/iki_write/c/main/main.c b/level_3/iki_write/c/main/main.c index f6fca27..b4dfcf8 100644 --- a/level_3/iki_write/c/main/main.c +++ b/level_3/iki_write/c/main/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - iki_write_setting_load(arguments, state, &data, &setting); + iki_write_setting_load(arguments, &data, &setting); } iki_write_main(&data, &setting); diff --git a/level_3/iki_write/c/main/print.c b/level_3/iki_write/c/main/print.c index 2e16d32..6cfc8ea 100644 --- a/level_3/iki_write/c/main/print.c +++ b/level_3/iki_write/c/main/print.c @@ -11,7 +11,7 @@ extern "C" { if (print.verbosity < f_console_verbosity_error_e) return F_output_not; iki_write_print_line_first_locked(setting, print); - fll_error_print(print, F_status_set_fine(setting->status), function, fll_error_file_flag_fallback_e); + fll_error_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e); return F_none; } @@ -23,7 +23,7 @@ extern "C" { if (print.verbosity < f_console_verbosity_error_e) return F_output_not; iki_write_print_line_first_locked(setting, print); - fll_error_file_print(print, F_status_set_fine(setting->status), function, fll_error_file_flag_fallback_e, name, operation, type); + fll_error_file_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e, name, operation, type); return F_none; } @@ -125,7 +125,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -140,7 +140,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -155,7 +155,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -170,7 +170,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } diff --git a/level_3/iki_write/c/main/print.h b/level_3/iki_write/c/main/print.h index 88f9ff7..2793706 100644 --- a/level_3/iki_write/c/main/print.h +++ b/level_3/iki_write/c/main/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -38,7 +38,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * @param function @@ -67,7 +67,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -85,7 +85,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param object @@ -105,7 +105,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -127,7 +127,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -149,7 +149,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -171,7 +171,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -193,7 +193,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/iki_write/c/main/private-write.c b/level_3/iki_write/c/main/private-write.c index f65dde3..9c77471 100644 --- a/level_3/iki_write/c/main/private-write.c +++ b/level_3/iki_write/c/main/private-write.c @@ -10,7 +10,7 @@ extern "C" { void iki_write_process(fll_program_data_t * const main, iki_write_setting_t * const setting, const f_string_static_t object, const f_string_static_t content) { if (!object.used) { - setting->status = F_status_set_error(F_failure); + setting->state.status = F_status_set_error(F_failure); if (main->error.verbosity != f_console_verbosity_quiet_e) { iki_write_print_line_first_locked(setting, main->error); @@ -20,17 +20,17 @@ extern "C" { return; } - setting->status = f_iki_object_is(object); + setting->state.status = f_iki_object_is(object); - if (setting->status == F_false) { - setting->status = F_status_set_error(F_failure); + if (setting->state.status == F_false) { + setting->state.status = F_status_set_error(F_failure); iki_write_print_error_object_not_valid(setting, main->error, object); return; } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_write_print_error(setting, main->error, macro_iki_write_f(f_iki_object_is)); return; @@ -38,9 +38,9 @@ extern "C" { setting->escaped.used = 0; - setting->status = fll_iki_content_escape(content, setting->quote, &setting->escaped); + setting->state.status = fll_iki_content_escape(content, setting->quote, &setting->escaped); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { iki_write_print_error(setting, main->error, macro_iki_write_f(fll_iki_content_escape)); return; diff --git a/level_3/iki_write/c/main/private-write.h b/level_3/iki_write/c/main/private-write.h index 55051d4..ee23ec1 100644 --- a/level_3/iki_write/c/main/private-write.h +++ b/level_3/iki_write/c/main/private-write.h @@ -20,7 +20,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_iki_object_is(). diff --git a/level_3/status_code/c/fss/main.c b/level_3/status_code/c/fss/main.c index bbd1669..59737c3 100644 --- a/level_3/status_code/c/fss/main.c +++ b/level_3/status_code/c/fss/main.c @@ -25,9 +25,8 @@ 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); - f_state_t state = f_state_t_initialize; - status_code_setting_load(arguments, state, &data, &setting); + status_code_setting_load(arguments, &data, &setting); } status_code_main(&data, &setting); @@ -38,5 +37,5 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { fll_program_standard_set_down(&data); - return (F_status_is_error(setting.status) || setting.status == F_false) ? 1 : 0; + return (F_status_is_error(setting.state.status) || setting.state.status == F_false) ? 1 : 0; } diff --git a/level_3/status_code/c/fss/print.h b/level_3/status_code/c/fss/print.h index 5cb2e92..7efd9a6 100644 --- a/level_3/status_code/c/fss/print.h +++ b/level_3/status_code/c/fss/print.h @@ -22,7 +22,7 @@ extern "C" { * The main program settings. * (Must be of type status_code_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * diff --git a/level_3/status_code/c/main/common-type.h b/level_3/status_code/c/main/common-type.h index 61c4aa9..2e27586 100644 --- a/level_3/status_code/c/main/common-type.h +++ b/level_3/status_code/c/main/common-type.h @@ -145,7 +145,7 @@ extern "C" { #define status_code_setting_t_initialize \ { \ status_code_main_flag_none_e, \ - f_state_initialize_t, \ + f_state_t_initialize, \ f_string_static_t_initialize, \ f_string_static_t_initialize, \ 0, \ diff --git a/level_3/status_code/c/main/common.c b/level_3/status_code/c/main/common.c index 9eb9ad3..6fcb6ee 100644 --- a/level_3/status_code/c/main/common.c +++ b/level_3/status_code/c/main/common.c @@ -14,14 +14,13 @@ extern "C" { #endif // _di_status_code_setting_delete_ #ifndef _di_status_code_setting_load_ - void status_code_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, status_code_setting_t * const setting) { + void status_code_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, status_code_setting_t * const setting) { if (!main || !setting) return; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { status_code_print_error(setting, main->error, macro_status_code_f(f_console_parameter_process)); return; @@ -38,9 +37,9 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { status_code_print_error(setting, main->error, macro_status_code_f(fll_program_parameter_process_context)); return; @@ -69,9 +68,9 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { status_code_print_error(setting, main->error, macro_status_code_f(fll_program_parameter_process_verbosity)); return; @@ -116,7 +115,7 @@ extern "C" { if (setting->flag & status_code_main_flag_error_e) { if (setting->flag & status_code_main_flag_warning_e) { if (!(setting->flag & status_code_main_flag_number_e)) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); status_code_print_line_first_locked(setting, main->error); status_code_print_error_cannot_error_warning_number(setting, main->error); @@ -126,7 +125,7 @@ extern "C" { } if (setting->flag & status_code_main_flag_fine_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); status_code_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, status_code_long_error_s, status_code_long_fine_s); @@ -135,7 +134,7 @@ extern "C" { } } else if (setting->flag & status_code_main_flag_warning_e && setting->flag & status_code_main_flag_fine_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); status_code_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, status_code_long_warning_s, status_code_long_fine_s); @@ -144,7 +143,7 @@ extern "C" { } if (main->parameters.remaining.used == 0 && !(main->pipe & fll_program_data_pipe_input_e)) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); status_code_print_line_first_locked(setting, main->error); status_code_print_error_no_status_codes(setting, main->error); diff --git a/level_3/status_code/c/main/common.h b/level_3/status_code/c/main/common.h index faf1365..701ae32 100644 --- a/level_3/status_code/c/main/common.h +++ b/level_3/status_code/c/main/common.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -47,19 +47,17 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: fll_program_parameter_process_context(). - * @param state - * A state for providing flags and handling interrupts during long running operations. * * @see f_console_parameter_process() * @see fll_program_parameter_process_context() */ #ifndef _di_status_code_setting_load_ - extern void status_code_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, status_code_setting_t * const setting, f_state_t * const state); + extern void status_code_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, status_code_setting_t * const setting); #endif // _di_status_code_setting_load_ /** @@ -71,7 +69,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/status_code/c/main/main.c b/level_3/status_code/c/main/main.c index ad08ffa..185ea77 100644 --- a/level_3/status_code/c/main/main.c +++ b/level_3/status_code/c/main/main.c @@ -23,9 +23,8 @@ 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); - f_state_t state = f_state_t_initialize; - status_code_setting_load(arguments, state, &data, &setting); + status_code_setting_load(arguments, &data, &setting); } status_code_main(&data, &setting); @@ -36,5 +35,5 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { fll_program_standard_set_down(&data); - return (F_status_is_error(setting.status) || setting.status == F_false) ? 1 : 0; + return (F_status_is_error(setting.state.status) || setting.state.status == F_false) ? 1 : 0; } diff --git a/level_3/status_code/c/main/print.c b/level_3/status_code/c/main/print.c index 5e83027..eab0e34 100644 --- a/level_3/status_code/c/main/print.c +++ b/level_3/status_code/c/main/print.c @@ -11,7 +11,7 @@ extern "C" { if (print.verbosity < f_console_verbosity_error_e) return F_output_not; status_code_print_line_first_locked(setting, print); - fll_error_print(print, F_status_set_fine(setting->status), function, fll_error_file_flag_fallback_e); + fll_error_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e); return F_none; } @@ -101,8 +101,8 @@ extern "C" { status_code_program_help_parameters_s ); - if (setting->status_string_help_detail) { - setting->status_string_help_detail(setting, print); + if (setting->state.status_string_help_detail) { + setting->state.status_string_help_detail(setting, print); } f_print_dynamic_raw(setting->line_last, print.to); @@ -138,7 +138,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -153,7 +153,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -168,7 +168,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } @@ -183,7 +183,7 @@ extern "C" { if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; } diff --git a/level_3/status_code/c/main/print.h b/level_3/status_code/c/main/print.h index 9252fbe..b584240 100644 --- a/level_3/status_code/c/main/print.h +++ b/level_3/status_code/c/main/print.h @@ -18,7 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -38,7 +38,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -56,7 +56,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -74,7 +74,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param name @@ -95,7 +95,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -117,7 +117,7 @@ extern "C" { * The main program settings. * (Must be of type status_code_setting_t.) * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * The output structure to print to. * @@ -137,7 +137,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -159,7 +159,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -181,7 +181,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -202,7 +202,7 @@ extern "C" { * * @param setting * The main program settings. - * This does not alter setting.status. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * diff --git a/level_3/status_code/c/main/private-status_code.h b/level_3/status_code/c/main/private-status_code.h index 132cbc0..bfd3a18 100644 --- a/level_3/status_code/c/main/private-status_code.h +++ b/level_3/status_code/c/main/private-status_code.h @@ -20,21 +20,21 @@ extern "C" { * @param value * The parameter value to process. * - * @return - * F_none on success. - * F_data_not if string starts wth a null (length is 0). - * F_parameter (with error bit) if a parameter is invalid. - * F_number (with error bit) if parameter is not a number. - * F_number_negative (with error bit) on negative value. - * F_number_overflow (with error bit) on integer overflow. - * F_complete_not_utf (with error bit) if an incomplete UTF-8 fragment is found. + * This alters setting.state.status: + * F_none on success. + * F_data_not if string starts wth a null (length is 0). + * F_parameter (with error bit) if a parameter is invalid. + * F_number (with error bit) if parameter is not a number. + * F_number_negative (with error bit) on negative value. + * F_number_overflow (with error bit) on integer overflow. + * F_complete_not_utf (with error bit) if an incomplete UTF-8 fragment is found. * - * Errors (with error bit) from: fss_status_code_convert_number(). + * Errors (with error bit) from: fss_status_code_convert_number(). * * @see fss_status_code_convert_number() */ #ifndef _di_status_code_process_check_ - extern f_status_t status_code_process_check(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) F_attribute_visibility_internal_d; + extern void status_code_process_check(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) F_attribute_visibility_internal_d; #endif // _di_status_code_process_check_ /** @@ -45,21 +45,20 @@ extern "C" { * @param value * The parameter value to process. * - * @return - * F_none on success. - * F_data_not if string is empty. - * - * Errors (with error bit) from: fl_console_parameter_to_number_unsigned(). - * Errors (with error bit) from: fll_fss_status_string_to(). - * Errors (with error bit) from: fll_status_string_from(). + * This alters setting.state.status: + * F_none on success. + * F_data_not if string is empty. * + * Errors (with error bit) from: fl_console_parameter_to_number_unsigned(). + * Errors (with error bit) from: fll_fss_status_string_to(). + * Errors (with error bit) from: fll_status_string_from(). * * @see fl_console_parameter_to_number_unsigned() * @see fll_fss_status_string_from() * @see fll_status_string_from() */ #ifndef _di_status_code_process_number_ - extern f_status_t status_code_process_number(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) F_attribute_visibility_internal_d; + extern void status_code_process_number(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) F_attribute_visibility_internal_d; #endif // _di_status_code_process_number_ /** @@ -70,25 +69,25 @@ extern "C" { * @param value * The parameter value to process. * - * @return - * F_none on success. - * F_data_not if string starts wth a null (length is 0). - * F_complete_not_utf (with error bit) if an incomplete UTF-8 fragment is found. - * F_number (with error bit) if parameter is not a number. - * F_number_negative (with error bit) on negative value. - * F_number_overflow (with error bit) on integer overflow. - * F_parameter (with error bit) if a parameter is invalid. + * This alters setting.state.status: + * F_none on success. + * F_data_not if string starts wth a null (length is 0). + * F_complete_not_utf (with error bit) if an incomplete UTF-8 fragment is found. + * F_number (with error bit) if parameter is not a number. + * F_number_negative (with error bit) on negative value. + * F_number_overflow (with error bit) on integer overflow. + * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_status_string_to(). - * Errors (with error bit) from: fll_fss_status_string_to(). - * Errors (with error bit) from: fss_status_code_convert_number(). + * Errors (with error bit) from: f_status_string_to(). + * Errors (with error bit) from: fll_fss_status_string_to(). + * Errors (with error bit) from: fss_status_code_convert_number(). * * @see f_status_string_to() * @see fll_fss_status_string_to() * @see fss_status_code_convert_number() */ #ifndef _di_status_code_process_normal_ - extern f_status_t status_code_process_normal(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) F_attribute_visibility_internal_d; + extern void status_code_process_normal(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) F_attribute_visibility_internal_d; #endif // _di_status_code_process_normal_ /** @@ -102,21 +101,21 @@ extern "C" { * The converted number. * Will not be updated on error. * - * @return - * F_none on success. - * F_data_not if string starts wth a null (length is 0). - * F_complete_not_utf (with error bit) if an incomplete UTF-8 fragment is found. - * F_number (with error bit) if parameter is not a number. - * F_number_negative (with error bit) on negative value. - * F_number_overflow (with error bit) on integer overflow. - * F_parameter (with error bit) if a parameter is invalid. + * This alters setting.state.status: + * F_none on success. + * F_data_not if string starts wth a null (length is 0). + * F_complete_not_utf (with error bit) if an incomplete UTF-8 fragment is found. + * F_number (with error bit) if parameter is not a number. + * F_number_negative (with error bit) on negative value. + * F_number_overflow (with error bit) on integer overflow. + * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: fl_console_parameter_to_number_unsigned(). + * Errors (with error bit) from: fl_console_parameter_to_number_unsigned(). * * @see fl_console_parameter_to_number_unsigned() */ #ifndef _di_status_code_convert_number_ - extern f_status_t status_code_convert_number(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value, f_number_unsigned_t *number) F_attribute_visibility_internal_d; + extern void status_code_convert_number(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value, f_number_unsigned_t *number) F_attribute_visibility_internal_d; #endif // _di_status_code_convert_number_ #ifdef __cplusplus diff --git a/level_3/status_code/c/main/status_code.c b/level_3/status_code/c/main/status_code.c index 2520a46..8d3e864 100644 --- a/level_3/status_code/c/main/status_code.c +++ b/level_3/status_code/c/main/status_code.c @@ -10,28 +10,28 @@ extern "C" { if (!main || !setting) return; - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { status_code_print_line_last_locked(setting, main->error); return; } - if (!setting->status_string_from || !setting->status_string_to) { + if (!setting->state.status_string_from || !setting->state.status_string_to) { - if (!setting->status_string_from) { + if (!setting->state.status_string_from) { status_code_print_error_invalid_callback(setting, main->error, macro_status_code_f(status_string_from)); } - if (!setting->status_string_to) { + if (!setting->state.status_string_to) { status_code_print_error_invalid_callback(setting, main->error, macro_status_code_f(status_string_to)); } - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); return; } - setting->status = F_none; + setting->state.status = F_none; if (setting->flag & status_code_main_flag_help_e) { status_code_print_help(setting, main->message); @@ -69,7 +69,7 @@ extern "C" { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); return; } @@ -79,8 +79,8 @@ extern "C" { status2 = status_code_process_number(main, setting, main->parameters.arguments.array[main->parameters.remaining.array[i]]); - if (F_status_is_error(status2) && setting->status == F_none) { - setting->status = status2; + if (F_status_is_error(status2) && setting->state.status == F_none) { + setting->state.status = status2; } } // for @@ -103,7 +103,7 @@ extern "C" { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); return; } @@ -113,8 +113,8 @@ extern "C" { status2 = status_code_process_check(main, setting, main->parameters.arguments.array[main->parameters.remaining.array[i]]); - if (F_status_is_error(status2) && setting->status == F_none) { - setting->status = status2; + if (F_status_is_error(status2) && setting->state.status == F_none) { + setting->state.status = status2; } } // for @@ -137,7 +137,7 @@ extern "C" { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); return; } @@ -147,8 +147,8 @@ extern "C" { status2 = status_code_process_normal(main, setting, main->parameters.arguments.array[main->parameters.remaining.array[i]]); - if (F_status_is_error(status2) && setting->status == F_none) { - setting->status = status2; + if (F_status_is_error(status2) && setting->state.status == F_none) { + setting->state.status = status2; } } // for @@ -156,11 +156,8 @@ extern "C" { } } - if (F_status_is_error(setting->status)) { - status_code_print_line_last_locked(setting, main->error); - } - else if (setting->status != F_interrupt) { - status_code_print_line_last_locked(setting, main->message); + if (F_status_is_error(setting->state.status)) { + status_code_print_line_last_locked(setting, F_status_set_fine(setting->state.status) == F_interrupt ? main->message : main->error); } } #endif // _di_status_code_main_ diff --git a/level_3/status_code/c/main/status_code.h b/level_3/status_code/c/main/status_code.h index e60584c..250c522 100644 --- a/level_3/status_code/c/main/status_code.h +++ b/level_3/status_code/c/main/status_code.h @@ -68,7 +68,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_true on success when performing verification and verify passed. * F_false on success when performing verification and verify failed. diff --git a/level_3/utf8/c/main/bytesequence.c b/level_3/utf8/c/main/bytesequence.c new file mode 100644 index 0000000..74e9d9b --- /dev/null +++ b/level_3/utf8/c/main/bytesequence.c @@ -0,0 +1,162 @@ +#include "utf8.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_utf8_convert_bytesequence_ + void utf8_convert_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence) { + + if (!main || !setting) return; + + bool valid_not = F_false; + + uint32_t codepoint = 0; + + if (sequence.used) { + setting->state.status = f_utf_unicode_to(sequence.string, sequence.used, &codepoint); + } + else { + setting->state.status = F_status_set_error(F_utf_not); + } + + if (F_status_is_error(setting->state.status)) { + setting->state.status = F_status_set_fine(setting->state.status); + + if (setting->state.status == F_failure || setting->state.status == F_utf_not || setting->state.status == F_complete_not_utf || setting->state.status == F_utf_fragment || setting->state.status == F_valid_not) { + valid_not = F_true; + + utf8_print_character_invalid(setting, main->output, sequence); + } + else { + setting->state.status = F_status_set_error(setting->state.status); + + utf8_print_error_decode(setting, main->error, sequence); + + return; + } + } + else if (!(setting->flag & utf8_main_flag_verify_e)) { + if (setting->mode & utf8_mode_to_bytesequence_e) { + utf8_print_bytesequence(setting, main->output, sequence); + } + else if (setting->mode & utf8_mode_to_codepoint_e) { + utf8_print_codepoint(setting, main->output, codepoint); + } + else { + utf8_print_combining_or_width(setting, main->output, sequence); + } + } + + if (valid_not || F_status_is_error(setting->state.status)) { + setting->state.status = F_utf_not; + } + else { + setting->state.status = F_none; + } + } +#endif // _di_utf8_convert_bytesequence_ + +#ifndef _di_utf8_process_file_bytesequence_ + void utf8_process_file_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_file_t file) { + + if (!main || !setting) return; + + bool valid = F_true; + bool next = F_true; + uint8_t mode_codepoint = utf8_codepoint_mode_ready_e; + + f_array_length_t i = 0; + f_array_length_t j = 0; + + f_char_t block[4] = { 0, 0, 0, 0 }; + f_string_static_t sequence = macro_f_string_static_t_initialize(block, 0, 4); + + do { + setting->state.status = f_file_stream_read_block(file, &setting->buffer); + + if (setting->state.status == F_none_eof && !setting->buffer.used) break; + + for (i = 0; F_status_is_error_not(setting->state.status) && i < setting->buffer.used; ) { + + if (!((++main->signal_check) % utf8_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); + + setting->state.status = F_interrupt; + + break; + } + + main->signal_check = 0; + } + + setting->state.status = F_none; + + // Get the current width only when processing a new block. + if (next) { + sequence.used = macro_f_utf_byte_width(setting->buffer.string[i]); + next = F_false; + } + + for (; j < sequence.used && i < setting->buffer.used; ++j, ++i) { + sequence.string[j] = setting->buffer.string[i]; + } // for + + if (j == sequence.used) { + if (setting->mode & utf8_mode_from_bytesequence_e) { + utf8_convert_bytesequence(main, setting, sequence); + } + else { + utf8_detect_codepoint(main, setting, sequence, &mode_codepoint); + + if (F_status_is_error_not(setting->state.status) && setting->state.status != F_next) { + utf8_convert_codepoint(main, setting, sequence, &mode_codepoint); + } + } + + if (setting->state.status == F_utf_not) { + valid = F_false; + } + + j = 0; + next = F_true; + } + } // for + + i = 0; + setting->buffer.used = 0; + + } while (F_status_is_error_not(setting->state.status) && setting->state.status != F_interrupt); + + // Handle last (incomplete) sequence when the buffer ended before the sequence is supposed to end. + if (F_status_is_error_not(setting->state.status) && setting->state.status != F_interrupt && next == F_false) { + sequence.used = j; + + if (setting->mode & utf8_mode_from_bytesequence_e) { + utf8_convert_bytesequence(main, setting, sequence); + } + else { + utf8_detect_codepoint(main, setting, sequence, &mode_codepoint); + + if (F_status_is_error_not(setting->state.status) && setting->state.status != F_next) { + utf8_convert_codepoint(main, setting, sequence, &mode_codepoint); + } + } + + if (setting->state.status == F_utf_not) { + valid = F_false; + } + } + + setting->buffer.used = 0; + + if (F_status_is_error(setting->state.status) || setting->state.status == F_interrupt) return; + + setting->state.status = valid; + } +#endif // _di_utf8_process_file_bytesequence_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/utf8/c/main/private-utf8_bytesequence.h b/level_3/utf8/c/main/bytesequence.h similarity index 58% rename from level_3/utf8/c/main/private-utf8_bytesequence.h rename to level_3/utf8/c/main/bytesequence.h index cd2c075..857187c 100644 --- a/level_3/utf8/c/main/private-utf8_bytesequence.h +++ b/level_3/utf8/c/main/bytesequence.h @@ -25,16 +25,16 @@ extern "C" { * A byte sequences representing a single character to convert. * This does not stop on NULL and will process all text until sequence.used. * - * @return - * F_none on success. - * F_utf_not on invalid UTF-8 (which is still "success" when verifying). + * This alters setting.state.status: + * F_none on success. + * F_utf_not on invalid UTF-8 (which is still "success" when verifying). * - * F_utf_not (with error bit) if not verifying and + * F_utf_not (with error bit) if not verifying and * - * Errors (with error bit) from: f_utf_unicode_to() + * Errors (with error bit) from: f_utf_unicode_to() */ #ifndef _di_utf8_convert_bytesequence_ - extern f_status_t utf8_convert_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence) F_attribute_visibility_internal_d; + extern void utf8_convert_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence) F_attribute_visibility_internal_d; #endif // _di_utf8_convert_bytesequence_ /** @@ -48,20 +48,20 @@ extern "C" { * The file stream to process. * This file may contain NULLs. * - * @return - * F_true on success and is valid. - * F_false on success and contains invalid sequences. - * F_interrupt on (exit) signal received. + * This alters setting.state.status: + * F_true on success and is valid. + * F_false on success and contains invalid sequences. + * F_interrupt on (exit) signal received. * - * Errors (with error bit) from: utf8_convert_bytesequence() - * Errors (with error bit) from: utf8_detect_codepoint() + * Errors (with error bit) from: utf8_convert_bytesequence() + * Errors (with error bit) from: utf8_detect_codepoint() * * @see fll_program_standard_signal_received() * @see utf8_convert_bytesequence() * @see utf8_detect_codepoint() */ #ifndef _di_utf8_process_file_bytesequence_ - extern f_status_t utf8_process_file_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_file_t file) F_attribute_visibility_internal_d; + extern void utf8_process_file_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_file_t file) F_attribute_visibility_internal_d; #endif // _di_utf8_process_file_bytesequence_ #ifdef __cplusplus diff --git a/level_3/utf8/c/main/private-utf8_codepoint.c b/level_3/utf8/c/main/codepoint.c similarity index 60% rename from level_3/utf8/c/main/private-utf8_codepoint.c rename to level_3/utf8/c/main/codepoint.c index d0fb38e..97a6688 100644 --- a/level_3/utf8/c/main/private-utf8_codepoint.c +++ b/level_3/utf8/c/main/codepoint.c @@ -1,23 +1,22 @@ #include "utf8.h" -#include "private-common.h" -#include "private-utf8.h" -#include "private-utf8_bytesequence.h" -#include "private-utf8_codepoint.h" #ifdef __cplusplus extern "C" { #endif #ifndef _di_utf8_convert_codepoint_ - f_status_t utf8_convert_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t unicode, uint8_t *mode) { + void utf8_convert_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t unicode, uint8_t *mode) { + + if (!main || !setting) return; + + setting->state.status = F_none; - f_status_t status = F_none; bool valid_not = F_false; if (*mode != utf8_codepoint_mode_end_e) { if (setting->text.used + unicode.used >= setting->text.size) { - status = f_string_dynamic_increase_by(utf8_default_allocation_step_d, &setting->text); - if (F_status_is_error(status)) return status; + setting->state.status = f_string_dynamic_increase_by(utf8_default_allocation_step_d, &setting->text); + if (F_status_is_error(setting->state.status)) return; } for (f_array_length_t i = 0; i < unicode.used; ++i) { @@ -28,22 +27,22 @@ extern "C" { if (*mode == utf8_codepoint_mode_end_e) { uint32_t codepoint = 0; - status = f_utf_unicode_string_to(setting->text.string, setting->text.used, &codepoint); + setting->state.status = f_utf_unicode_string_to(setting->text.string, setting->text.used, &codepoint); - if (F_status_is_error(status)) { - status = F_status_set_fine(status); + if (F_status_is_error(setting->state.status)) { + setting->state.status = F_status_set_fine(setting->state.status); - if (status == F_failure || status == F_utf_not || status == F_complete_not_utf || status == F_utf_fragment || status == F_valid_not) { + if (setting->state.status == F_failure || setting->state.status == F_utf_not || setting->state.status == F_complete_not_utf || setting->state.status == F_utf_fragment || setting->state.status == F_valid_not) { valid_not = F_true; utf8_print_character_invalid(setting, main->output, unicode); } else { - status = F_status_set_error(status); + setting->state.status = F_status_set_error(setting->state.status); - utf8_print_error_decode(setting, main->error, status, unicode); + utf8_print_error_decode(setting, main->error, unicode); - return status; + return; } } else if (!(setting->flag & utf8_main_flag_verify_e)) { @@ -54,24 +53,24 @@ extern "C" { f_char_t byte[4] = { 0, 0, 0, 0 }; f_string_static_t unicode = macro_f_string_static_t_initialize(byte, 0, 4); - status = f_utf_unicode_from(codepoint, 4, &unicode.string); + setting->state.status = f_utf_unicode_from(codepoint, 4, &unicode.string); - if (F_status_is_error(status)) { + if (F_status_is_error(setting->state.status)) { if (setting->mode & utf8_mode_to_bytesequence_e) { - utf8_print_error_encode(setting, main->error, status, codepoint); + utf8_print_error_encode(setting, main->error, codepoint); } else { utf8_print_combining_or_width_invalid(setting, main->output); } } else if (setting->mode & utf8_mode_to_bytesequence_e) { - status = F_none; + setting->state.status = F_none; unicode.used = macro_f_utf_byte_width(unicode.string[0]); utf8_print_bytesequence(setting, main->output, unicode); } else { - status = F_none; + setting->state.status = F_none; utf8_print_combining_or_width(setting, main->output, unicode); } @@ -79,35 +78,38 @@ extern "C" { } } else if (*mode == utf8_codepoint_mode_bad_end_e) { - status = F_none; + setting->state.status = F_none; utf8_print_character_invalid(setting, main->output, unicode); } else { - return F_none; + setting->state.status = F_none; + + return; } *mode = utf8_codepoint_mode_ready_e; setting->text.used = 0; - if (valid_not || F_status_is_error(status)) { - return F_utf_not; + if (valid_not || F_status_is_error(setting->state.status)) { + setting->state.status = F_utf_not; } - - return status; } #endif // _di_utf8_convert_codepoint_ #ifndef _di_utf8_convert_raw_ - f_status_t utf8_convert_raw(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t hex, uint8_t *mode) { + void utf8_convert_raw(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t hex, uint8_t *mode) { + + if (!main || !setting) return; + + setting->state.status = F_none; - f_status_t status = F_none; bool valid_not = F_false; if (*mode != utf8_codepoint_mode_raw_end_e) { if (setting->text.used + hex.used >= setting->text.size) { - status = f_string_dynamic_increase_by(utf8_default_allocation_step_d, &setting->text); - if (F_status_is_error(status)) return status; + setting->state.status = f_string_dynamic_increase_by(utf8_default_allocation_step_d, &setting->text); + if (F_status_is_error(setting->state.status)) return; } for (f_array_length_t i = 0; i < hex.used; ++i) { @@ -121,25 +123,25 @@ extern "C" { { f_number_unsigned_t number = 0; - status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, setting->text, &number); + setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, setting->text, &number); raw = (f_utf_char_t) number; } - if (F_status_is_error(status)) { - status = F_status_set_fine(status); + if (F_status_is_error(setting->state.status)) { + setting->state.status = F_status_set_fine(setting->state.status); - if (status == F_number || status == F_utf_not || status == F_complete_not_utf || status == F_utf_fragment || status == F_number_decimal || status == F_number_negative || status == F_number_positive || status == F_number_overflow) { + if (setting->state.status == F_number || setting->state.status == F_utf_not || setting->state.status == F_complete_not_utf || setting->state.status == F_utf_fragment || setting->state.status == F_number_decimal || setting->state.status == F_number_negative || setting->state.status == F_number_positive || setting->state.status == F_number_overflow) { valid_not = F_true; utf8_print_character_invalid(setting, main->output, hex); } else { - status = F_status_set_error(status); + setting->state.status = F_status_set_error(setting->state.status); - utf8_print_error_decode(setting, main->error, status, hex); + utf8_print_error_decode(setting, main->error, hex); - return status; + return; } } else if (!(setting->flag & utf8_main_flag_verify_e)) { @@ -163,34 +165,38 @@ extern "C" { } } else if (*mode == utf8_codepoint_mode_bad_end_e) { - status = F_none; + setting->state.status = F_none; utf8_print_character_invalid(setting, main->output, hex); } else { - return F_none; + setting->state.status = F_none; + + return; } *mode = utf8_codepoint_mode_ready_e; setting->text.used = 0; - if (valid_not || F_status_is_error(status)) { - return F_valid_not; + if (valid_not || F_status_is_error(setting->state.status)) { + setting->state.status = F_valid_not; } - - return status; } #endif // _di_utf8_convert_raw_ #ifndef _di_utf8_detect_codepoint_ - f_status_t utf8_detect_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t unicode, uint8_t *mode) { + void utf8_detect_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t unicode, uint8_t *mode) { + + if (!main || !setting) return; // Skip past NULL. if (!unicode.string[0]) { - return F_next; + setting->state.status = F_next; + + return; } - f_status_t status = F_none; + setting->state.status = F_none; if (unicode.string[0] == f_string_ascii_u_s.string[0] || unicode.string[0] == f_string_ascii_U_s.string[0] || unicode.string[0] == f_string_ascii_plus_s.string[0]) { // Do nothing. @@ -199,50 +205,40 @@ extern "C" { // Do nothing. } else if (unicode.string[0] == f_string_ascii_space_s.string[0]) { - status = F_space; + setting->state.status = F_space; } else if (macro_f_utf_byte_width_is(*unicode.string)) { - status = f_utf_is_whitespace(unicode.string, 4, F_true); + setting->state.status = f_utf_is_whitespace(unicode.string, 4, F_true); - if (F_status_is_error(status)) { - if (F_status_set_fine(status) == F_complete_not_utf || F_status_set_fine(status) == F_utf_fragment) { - status = F_valid_not; + if (F_status_is_error(setting->state.status)) { + if (F_status_set_fine(setting->state.status) == F_complete_not_utf || F_status_set_fine(setting->state.status) == F_utf_fragment) { + setting->state.status = F_valid_not; } else { - return status; + return; } } - if (status == F_true) { - status = F_space; - } - else { - status = F_valid_not; - } + setting->state.status = (setting->state.status == F_true) ? F_space : F_valid_not; } else { if (unicode.string[0] < 0x30 || unicode.string[0] > (0x39 && unicode.string[0] < 0x41) || (unicode.string[0] > 0x46 && unicode.string[0] < 0x61) || unicode.string[0] > 0x66) { - status = f_utf_is_whitespace(unicode.string, 4, F_true); + setting->state.status = f_utf_is_whitespace(unicode.string, 4, F_true); - if (F_status_is_error(status)) { - if (F_status_set_fine(status) == F_complete_not_utf || F_status_set_fine(status) == F_utf_fragment) { - status = F_valid_not; + if (F_status_is_error(setting->state.status)) { + if (F_status_set_fine(setting->state.status) == F_complete_not_utf || F_status_set_fine(setting->state.status) == F_utf_fragment) { + setting->state.status = F_valid_not; } else { - return status; + return; } } - if (status == F_true) { - status = F_space; - } - else { - status = F_none; - } + setting->state.status = (setting->state.status == F_true) ? F_space : F_none; } } - if (status == F_valid_not) { + if (setting->state.status == F_valid_not) { if (*mode != utf8_codepoint_mode_bad_e) { if (*mode == utf8_codepoint_mode_bad_begin_e) { *mode = utf8_codepoint_mode_bad_e; @@ -254,13 +250,13 @@ extern "C" { } else { if (*mode == utf8_codepoint_mode_bad_e) { - if (status == F_space) { + if (setting->state.status == F_space) { *mode = utf8_codepoint_mode_bad_end_e; } } else if (*mode == utf8_codepoint_mode_ready_e) { - if (status == F_space) { - status = F_next; + if (setting->state.status == F_space) { + setting->state.status = F_next; } else if (unicode.string[0] == f_string_ascii_u_s.string[0] || unicode.string[0] == f_string_ascii_U_s.string[0]) { *mode = utf8_codepoint_mode_begin_e; @@ -291,25 +287,26 @@ extern "C" { } } else if (*mode == utf8_codepoint_mode_raw_number_e) { - if (status == F_space) { + if (setting->state.status == F_space) { *mode = utf8_codepoint_mode_raw_end_e; } } else if (*mode == utf8_codepoint_mode_number_e) { - if (status == F_space) { + if (setting->state.status == F_space) { *mode = utf8_codepoint_mode_end_e; } } } - - return status; } #endif // _di_utf8_detect_codepoint_ #ifndef _di_utf8_process_file_codepoint_ - f_status_t utf8_process_file_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_file_t file) { + void utf8_process_file_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_file_t file) { + + if (!main || !setting) return; + + setting->state.status = F_none; - f_status_t status = F_none; bool valid = F_true; bool next = F_true; uint8_t mode_codepoint = utf8_codepoint_mode_ready_e; @@ -321,21 +318,21 @@ extern "C" { f_string_static_t sequence = macro_f_string_static_t_initialize(block, 0, 0); do { - status = f_file_stream_read_block(file, &setting->buffer); + setting->state.status = f_file_stream_read_block(file, &setting->buffer); - if (status == F_none_eof && !setting->buffer.used) { + if (setting->state.status == F_none_eof && !setting->buffer.used) { // Handle complete character, which must be explicitly set to end in this situation. if (mode_codepoint == utf8_codepoint_mode_number_e || mode_codepoint == utf8_codepoint_mode_raw_number_e) { if (mode_codepoint == utf8_codepoint_mode_number_e) { mode_codepoint = utf8_codepoint_mode_end_e; - status = utf8_convert_codepoint(main, setting, sequence, &mode_codepoint); + utf8_convert_codepoint(main, setting, sequence, &mode_codepoint); } else if (mode_codepoint == utf8_codepoint_mode_raw_number_e) { mode_codepoint = utf8_codepoint_mode_raw_end_e; - status = utf8_convert_raw(main, setting, sequence, &mode_codepoint); + utf8_convert_raw(main, setting, sequence, &mode_codepoint); // Raw mode represents an invalid Unicode sequence. valid = F_false; @@ -343,20 +340,20 @@ extern "C" { j = 0; next = F_true; - status = F_none_eof; + setting->state.status = F_none_eof; mode_codepoint = utf8_codepoint_mode_ready_e; } break; } - for (i = 0; F_status_is_fine(status) && i < setting->buffer.used; ) { + for (i = 0; F_status_is_error_not(setting->state.status) && i < setting->buffer.used; ) { if (!((++main->signal_check) % utf8_signal_check_d)) { if (fll_program_standard_signal_received(main)) { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - status = F_interrupt; + setting->state.status = F_status_set_error(F_interrupt); break; } @@ -364,7 +361,7 @@ extern "C" { main->signal_check = 0; } - status = F_none; + setting->state.status = F_none; // Get the current width only when processing a new block. if (next) { @@ -378,25 +375,25 @@ extern "C" { if (j >= sequence.used) { if (setting->mode & utf8_mode_from_bytesequence_e) { - status = utf8_convert_bytesequence(main, setting, sequence); + utf8_convert_bytesequence(main, setting, sequence); } else { - status = utf8_detect_codepoint(main, setting, sequence, &mode_codepoint); + utf8_detect_codepoint(main, setting, sequence, &mode_codepoint); - if (F_status_is_fine(status) && status != F_next) { + if (F_status_is_error_not(setting->state.status) && setting->state.status != F_next) { if (mode_codepoint == utf8_codepoint_mode_raw_begin_e || mode_codepoint == utf8_codepoint_mode_raw_number_e || mode_codepoint == utf8_codepoint_mode_raw_end_e) { - status = utf8_convert_raw(main, setting, sequence, &mode_codepoint); + utf8_convert_raw(main, setting, sequence, &mode_codepoint); // Raw mode represents an invalid Unicode sequence. valid = F_false; } else { - status = utf8_convert_codepoint(main, setting, sequence, &mode_codepoint); + utf8_convert_codepoint(main, setting, sequence, &mode_codepoint); } } } - if (status == F_utf_not) { + if (setting->state.status == F_utf_not) { valid = F_false; } @@ -407,41 +404,41 @@ extern "C" { setting->buffer.used = 0; - } while (F_status_is_fine(status) && status != F_interrupt); + } while (F_status_is_error_not(setting->state.status)); // Handle last (incomplete) character when the buffer ended before the character is supposed to end. - if (F_status_is_error_not(status) && status != F_interrupt && next == F_false) { + if (F_status_is_error_not(setting->state.status) && next == F_false) { sequence.used = j; if (setting->mode & utf8_mode_from_bytesequence_e) { - status = utf8_convert_bytesequence(main, setting, sequence); + utf8_convert_bytesequence(main, setting, sequence); } else { - status = utf8_detect_codepoint(main, setting, sequence, &mode_codepoint); + utf8_detect_codepoint(main, setting, sequence, &mode_codepoint); - if (F_status_is_fine(status) && status != F_next) { + if (F_status_is_error_not(setting->state.status) && setting->state.status != F_next) { if (mode_codepoint == utf8_codepoint_mode_raw_begin_e || mode_codepoint == utf8_codepoint_mode_raw_number_e || mode_codepoint == utf8_codepoint_mode_raw_end_e) { - status = utf8_convert_raw(main, setting, sequence, &mode_codepoint); + utf8_convert_raw(main, setting, sequence, &mode_codepoint); // Raw mode represents an invalid Unicode sequence. valid = F_false; } else { - status = utf8_convert_codepoint(main, setting, sequence, &mode_codepoint); + utf8_convert_codepoint(main, setting, sequence, &mode_codepoint); } } } - if (status == F_utf_not) { + if (setting->state.status == F_utf_not) { valid = F_false; } } setting->buffer.used = 0; - if (F_status_is_error(status) || status == F_interrupt) return status; + if (F_status_is_error(setting->state.status)) return; - return valid; + setting->state.status = valid; } #endif // _di_utf8_process_file_codepoint_ diff --git a/level_3/utf8/c/main/private-utf8_codepoint.h b/level_3/utf8/c/main/codepoint.h similarity index 55% rename from level_3/utf8/c/main/private-utf8_codepoint.h rename to level_3/utf8/c/main/codepoint.h index 60b8ba8..c8e7c7b 100644 --- a/level_3/utf8/c/main/private-utf8_codepoint.h +++ b/level_3/utf8/c/main/codepoint.h @@ -26,18 +26,18 @@ extern "C" { * @param mode * The codepoint mode the text is currently in. * - * @return - * F_none on success. - * F_utf_not on invalid UTF-8 (which is still "success" when verifying). + * This alters setting.state.status: + * F_none on success. + * F_utf_not on invalid UTF-8 (which is still "success" when verifying). * - * F_utf_not (with error bit) if not verifying and the Unicode value is invalid. + * F_utf_not (with error bit) if not verifying and the Unicode value is invalid. * - * Errors (with error bit) from: f_utf_unicode_to() + * Errors (with error bit) from: f_utf_unicode_to() * * @see f_utf_unicode_to() */ #ifndef _di_utf8_convert_codepoint_ - extern f_status_t utf8_convert_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t unicode, uint8_t *mode) F_attribute_visibility_internal_d; + extern void utf8_convert_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t unicode, uint8_t *mode) F_attribute_visibility_internal_d; #endif // _di_utf8_convert_codepoint_ /** @@ -54,18 +54,18 @@ extern "C" { * @param mode * The codepoint mode the text is currently in. * - * @return - * F_none on success. - * F_valid_not on invalid raw (which is still "success" when verifying). + * This alters setting.state.status: + * F_none on success. + * F_valid_not on invalid raw (which is still "success" when verifying). * - * F_valid_not (with error bit) if not verifying and the raw value is invalid. + * F_valid_not (with error bit) if not verifying and the raw value is invalid. * - * Errors (with error bit) from: fl_conversion_dynamic_to_unsigned_detect() + * Errors (with error bit) from: fl_conversion_dynamic_to_unsigned_detect() * * @see fl_conversion_dynamic_to_unsigned_detect() */ #ifndef _di_utf8_convert_raw_ - extern f_status_t utf8_convert_raw(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t hex, uint8_t *mode) F_attribute_visibility_internal_d; + extern void utf8_convert_raw(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t hex, uint8_t *mode) F_attribute_visibility_internal_d; #endif // _di_utf8_convert_raw_ /** @@ -80,15 +80,15 @@ extern "C" { * @param mode * Designate the mode in which the curent state is being processed. * - * @return - * F_none on success. - * F_next on success, but should not be processed (it is white space or NULL). - * F_space on success, but the character is whitespace. + * This alters setting.state.status: + * F_none on success. + * F_next on success, but should not be processed (it is white space or NULL). + * F_space on success, but the character is whitespace. * - * Errors (with error bit) from: f_utf_is_whitespace() + * Errors (with error bit) from: f_utf_is_whitespace() */ #ifndef _di_utf8_detect_codepoint_ - extern f_status_t utf8_detect_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t unicode, uint8_t *mode) F_attribute_visibility_internal_d; + extern void utf8_detect_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t unicode, uint8_t *mode) F_attribute_visibility_internal_d; #endif // _di_utf8_detect_codepoint_ /** @@ -102,20 +102,20 @@ extern "C" { * The file stream to process. * This file may contain NULLs. * - * @return - * F_true on success and is valid. - * F_false on success and contains invalid sequences. - * F_interrupt on (exit) signal received. + * This alters setting.state.status: + * F_true on success and is valid. + * F_false on success and contains invalid sequences. + * F_interrupt on (exit) signal received. * - * Errors (with error bit) from: utf8_convert_bytesequence() - * Errors (with error bit) from: utf8_detect_codepoint() + * Errors (with error bit) from: utf8_convert_bytesequence() + * Errors (with error bit) from: utf8_detect_codepoint() * * @see fll_program_standard_signal_received() * @see utf8_convert_bytesequence() * @see utf8_detect_codepoint() */ #ifndef _di_utf8_process_file_codepoint_ - extern f_status_t utf8_process_file_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_file_t file) F_attribute_visibility_internal_d; + extern void utf8_process_file_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_file_t file) F_attribute_visibility_internal_d; #endif // _di_utf8_process_file_codepoint_ #ifdef __cplusplus diff --git a/level_3/utf8/c/main/common-type.h b/level_3/utf8/c/main/common-type.h index f7e582c..8d618e0 100644 --- a/level_3/utf8/c/main/common-type.h +++ b/level_3/utf8/c/main/common-type.h @@ -91,6 +91,39 @@ extern "C" { #endif // _di_utf8_main_flag_e_ /** + * Codepoint modes for converting to/from binary and codepoint values. + * + * The special "raw" format is used only for reading from codepoint format where that format represents binary character that is not a valid Unicode character. + * This is intended to be used to save and restore the original binary data even if that data is invalid. + * + * private_utf8_codepoint_mode_*: + * - ready: The codepoint has yet to be processed, skip leading spaces until first 'U' is matched. + * - begin: The first 'U' is matched, look for the '+'. + * - number: The '+' is matched, process numbers. + * - end: The last number is reached (at either white space or EOS/EOF). + * - bad: This is not a valid codepoint. + * - bad_begin: This is the beginning of an invalid codepoint. + * - bad_end: The end of bad is detected, which happens on white space or end of buffer. + * - raw_begin: This is the beginning of a potential raw data (matched '0'). + * - raw_number: This is the confirmed beginning of raw data (matched 'X'), process numbers. + * - raw_end: The end of raw data is detected, which happens on white space or end of buffer. + */ +#ifndef _di_utf8_codepoint_modes_ + enum { + utf8_codepoint_mode_ready_e = 1, + utf8_codepoint_mode_begin_e, + utf8_codepoint_mode_number_e, + utf8_codepoint_mode_end_e, + utf8_codepoint_mode_bad_e, + utf8_codepoint_mode_bad_begin_e, + utf8_codepoint_mode_bad_end_e, + utf8_codepoint_mode_raw_begin_e, + utf8_codepoint_mode_raw_number_e, + utf8_codepoint_mode_raw_end_e, + }; // enum +#endif // _di__utf8_codepoint_modes_ + +/** * The main program parameters. */ #ifndef _di_utf8_parameter_e_ @@ -214,7 +247,7 @@ extern "C" { { \ utf8_mode_from_bytesequence_e | utf8_mode_to_codepoint_e, \ utf8_main_flag_none_e, \ - f_state_initialize_t, \ + f_state_t_initialize, \ f_color_set_t_initialize, \ f_color_set_t_initialize, \ f_string_static_t_initialize, \ diff --git a/level_3/utf8/c/main/common.c b/level_3/utf8/c/main/common.c index 4b8a431..22e2c78 100644 --- a/level_3/utf8/c/main/common.c +++ b/level_3/utf8/c/main/common.c @@ -21,16 +21,15 @@ extern "C" { #endif // _di_utf8_setting_delete_ #ifndef _di_utf8_setting_load_ - void utf8_setting_load(const f_console_arguments_t arguments, f_state_t * const state, fll_program_data_t * const main, utf8_setting_t * const setting) { + void utf8_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, utf8_setting_t * const setting) { if (!main || !setting) return; setting->flag = 0; - // Load parameters. - setting->status = f_console_parameter_process(arguments, state, &main->parameters, 0); + f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_error(setting, main->error, macro_utf8_f(f_console_parameter_process)); return; @@ -48,9 +47,9 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); + setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_error(setting, main->error, macro_utf8_f(fll_program_parameter_process_context)); return; @@ -79,9 +78,9 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_error(setting, main->error, macro_utf8_f(fll_program_parameter_process_verbosity)); return; @@ -94,9 +93,9 @@ extern "C" { choices.array = choices_array; choices.used = 2; - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); + setting->state.status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_error(setting, main->error, macro_utf8_f(f_console_parameter_prioritize_right)); return; @@ -119,9 +118,9 @@ extern "C" { choices.used = 4; choice = 1; - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); + setting->state.status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_error(setting, main->error, macro_utf8_f(f_console_parameter_prioritize_right)); return; @@ -186,7 +185,7 @@ extern "C" { if (main->parameters.array[utf8_parameter_to_file_e].result & f_console_result_value_e) { if (main->parameters.array[utf8_parameter_to_file_e].values.used > 1) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); utf8_print_error_parameter_file_to_too_many(setting, main->error); @@ -196,9 +195,9 @@ extern "C" { if (main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]].used) { setting->path_files_to.used = 0; - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); + setting->state.status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_error(setting, main->error, macro_utf8_f(f_string_dynamics_increase_by)); return; @@ -206,9 +205,9 @@ extern "C" { setting->path_files_to.array[setting->path_files_to.used].used = 0; - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); + setting->state.status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_error(setting, main->error, macro_utf8_f(f_string_dynamic_append_nulless)); return; @@ -216,9 +215,9 @@ extern "C" { ++setting->path_files_to.used; - setting->status = f_file_stream_open(main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); + setting->state.status = f_file_stream_open(main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_error_file(setting, main->error, macro_utf8_f(f_file_stream_open), main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); return; @@ -230,13 +229,13 @@ extern "C" { utf8_print_line_first_locked(setting, main->error); utf8_print_error_parameter_file_name_empty(setting, main->error, main->parameters.array[utf8_parameter_to_file_e].values.array[0]); - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); return; } } else if (main->parameters.array[utf8_parameter_to_file_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); utf8_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, utf8_long_to_file_s); @@ -251,9 +250,9 @@ extern "C" { if (main->parameters.array[utf8_parameter_from_file_e].result & f_console_result_value_e) { setting->path_files_from.used = 0; - setting->status = f_string_dynamics_increase_by(main->parameters.array[utf8_parameter_from_file_e].values.used, &setting->path_files_from); + setting->state.status = f_string_dynamics_increase_by(main->parameters.array[utf8_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_error(setting, main->error, macro_utf8_f(f_string_dynamics_increase_by)); return; @@ -269,11 +268,11 @@ extern "C" { index = main->parameters.array[utf8_parameter_from_file_e].values.array[i]; setting->path_files_from.array[i].used = 0; - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); + setting->state.status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), macro_utf8_f(f_string_dynamic_append_nulless), fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), macro_utf8_f(f_string_dynamic_append_nulless), fll_error_file_flag_fallback_e); break; } @@ -282,26 +281,26 @@ extern "C" { if (f_file_exists(main->parameters.arguments.array[index], F_true) != F_true) { utf8_print_error_parameter_file_not_found(setting, main->error, F_true, main->parameters.arguments.array[index]); - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = F_status_set_error(F_file_found_not); } } } else { utf8_print_error_parameter_file_name_empty(setting, main->error, index); - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = F_status_set_error(F_parameter); } } } // for - if (F_status_is_error(setting->status)) return; + if (F_status_is_error(setting->state.status)) return; setting->flag |= utf8_main_flag_file_from_e; } else if (main->parameters.array[utf8_parameter_from_file_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); utf8_print_line_first_locked(setting, main->error); fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, utf8_long_from_file_s); @@ -315,9 +314,9 @@ extern "C" { if (main->parameters.remaining.used) { setting->remaining.used = 0; - setting->status = f_string_dynamics_increase_by(main->parameters.remaining.used, &setting->remaining); + setting->state.status = f_string_dynamics_increase_by(main->parameters.remaining.used, &setting->remaining); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_error(setting, main->error, macro_utf8_f(f_string_dynamics_increase_by)); return; @@ -335,7 +334,7 @@ extern "C" { } if (!(main->parameters.array[utf8_parameter_from_file_e].result & f_console_result_found_e) && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - setting->status = F_status_set_error(F_parameter); + setting->state.status = F_status_set_error(F_parameter); utf8_print_line_first_locked(setting, main->error); utf8_print_error_no_from(setting, main->error); diff --git a/level_3/utf8/c/main/common.h b/level_3/utf8/c/main/common.h index 2a3f294..4eccb9d 100644 --- a/level_3/utf8/c/main/common.h +++ b/level_3/utf8/c/main/common.h @@ -22,7 +22,7 @@ extern "C" { * @param setting * The program main setting data. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. @@ -47,7 +47,7 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). @@ -59,7 +59,7 @@ extern "C" { * @see fll_program_parameter_process_context() */ #ifndef _di_utf8_setting_load_ - extern void utf8_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, utf8_setting_t * const setting, f_state_t * const state); + extern void utf8_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, utf8_setting_t * const setting); #endif // _di_utf8_setting_load_ /** @@ -71,7 +71,7 @@ extern "C" { * The main program settings. * All buffers are deallocated. * - * This does not alter setting.status. + * This does not alter setting.state.status. * * @return * F_none on success. diff --git a/level_3/utf8/c/main/main.c b/level_3/utf8/c/main/main.c index b4a5c32..3739c38 100644 --- a/level_3/utf8/c/main/main.c +++ b/level_3/utf8/c/main/main.c @@ -18,9 +18,8 @@ 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); - f_state_t state = f_state_t_initialize; - utf8_setting_load(arguments, state, &data, &setting); + utf8_setting_load(arguments, &data, &setting); } utf8_main(&data, &setting); @@ -31,5 +30,5 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { fll_program_standard_set_down(&data); - return (F_status_is_error(setting.status) || setting.status == F_false) ? 1 : 0; + return (F_status_is_error(setting.state.status) || setting.state.status == F_false) ? 1 : 0; } diff --git a/level_3/utf8/c/main/print.c b/level_3/utf8/c/main/print.c index afc7098..e980832 100644 --- a/level_3/utf8/c/main/print.c +++ b/level_3/utf8/c/main/print.c @@ -1,5 +1,4 @@ #include "utf8.h" -#include "private-common.h" #ifdef __cplusplus extern "C" { @@ -8,18 +7,20 @@ extern "C" { #ifndef _di_utf8_print_error_ f_status_t utf8_print_error(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function) { + if (!setting) return F_status_set_error(F_output_not); if (print.verbosity < f_console_verbosity_error_e) return F_output_not; utf8_print_line_first_locked(setting, print); - fll_error_print(print, F_status_set_fine(setting->status), function, fll_error_file_flag_fallback_e); + fll_error_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e); return F_none; } #endif // _di_utf8_print_error_ #ifndef _di_utf8_print_error_decode_ - f_status_t utf8_print_error_decode(utf8_setting_t * const setting, const fl_print_t print, const f_status_t status, const f_string_static_t invalid) { + f_status_t utf8_print_error_decode(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t invalid) { + if (!setting) return F_status_set_error(F_output_not); if (print.verbosity < f_console_verbosity_error_e) return F_output_not; if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not; @@ -37,18 +38,18 @@ extern "C" { fl_print_format("%]", print.to, print.set->notable); } - if (F_status_set_fine(status) == F_utf_not) { + if (F_status_set_fine(setting->state.status) == F_utf_not) { fl_print_format("%[', not a valid UTF-8 character sequence.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); } - else if (F_status_set_fine(status) == F_complete_not_utf) { + else if (F_status_set_fine(setting->state.status) == F_complete_not_utf) { fl_print_format("%[', invalid UTF-8 (truncated).%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); } - else if (F_status_set_fine(status) == F_utf_fragment) { + else if (F_status_set_fine(setting->state.status) == F_utf_fragment) { fl_print_format("%[', invalid UTF-8 fragment.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); } else { fl_print_format("%[', error status code%] ", print.to, print.set->error, print.set->error, f_string_eol_s); - fl_print_format("%[%ui%]", print.to, print.set->notable, F_status_set_fine(status), print.set->notable); + fl_print_format("%[%ui%]", print.to, print.set->notable, F_status_set_fine(setting->state.status), print.set->notable); fl_print_format("%[.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); } @@ -57,8 +58,9 @@ extern "C" { #endif // _di_utf8_print_error_decode_ #ifndef _di_utf8_print_error_encode_ - f_status_t utf8_print_error_encode(utf8_setting_t * const setting, const fl_print_t print, const f_status_t status, const uint32_t codepoint) { + f_status_t utf8_print_error_encode(utf8_setting_t * const setting, const fl_print_t print, const uint32_t codepoint) { + if (!setting) return F_status_set_error(F_output_not); if (print.verbosity < f_console_verbosity_error_e) return F_output_not; utf8_print_line_first_unlocked(setting, print); @@ -66,12 +68,12 @@ extern "C" { fl_print_format("%[%QFailed to encode Unicode codepoint '%]", print.to, print.set->error, print.prefix, print.set->error); fl_print_format("%[U+%_U%]", print.to, print.set->notable, codepoint, print.set->notable); - if (F_status_set_fine(status) == F_utf_not) { + if (F_status_set_fine(setting->state.status) == F_utf_not) { fl_print_format("%[', not a valid Unicode codepoint.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); } else { fl_print_format("%[', error status code%] ", print.to, print.set->error, print.set->error, f_string_eol_s); - fl_print_format("%[%ui%]", print.to, print.set->notable, F_status_set_fine(status), print.set->notable); + fl_print_format("%[%ui%]", print.to, print.set->notable, F_status_set_fine(setting->state.status), print.set->notable); fl_print_format("%[.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); } @@ -82,10 +84,11 @@ extern "C" { #ifndef _di_utf8_print_error_file_ f_status_t utf8_print_error_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { + if (!setting) return F_status_set_error(F_output_not); if (print.verbosity < f_console_verbosity_error_e) return F_output_not; utf8_print_line_first_locked(setting, print); - fll_error_file_print(print, F_status_set_fine(setting->status), function, fll_error_file_flag_fallback_e, name, operation, type); + fll_error_file_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e, name, operation, type); return F_none; } @@ -94,6 +97,7 @@ extern "C" { #ifndef _di_utf8_print_error_no_from_ f_status_t utf8_print_error_no_from(utf8_setting_t * const setting, const fl_print_t print) { + if (!setting) return F_status_set_error(F_output_not); if (print.verbosity < f_console_verbosity_error_e) return F_output_not; fll_print_format("%[%QNo from sources are specified, please pipe data, designate a file, or add parameters.%]%r", print.to, print.set->error, print.prefix, print.set->error, f_string_eol_s); @@ -105,6 +109,7 @@ extern "C" { #ifndef _di_utf8_print_error_parameter_file_name_empty_ f_status_t utf8_print_error_parameter_file_name_empty(utf8_setting_t * const setting, const fl_print_t print, const f_array_length_t index) { + if (!setting) 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); @@ -124,6 +129,7 @@ extern "C" { #ifndef _di_utf8_print_error_parameter_file_not_found_ f_status_t utf8_print_error_parameter_file_not_found(utf8_setting_t * const setting, const fl_print_t print, const bool from, const f_string_static_t name) { + if (!setting) 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); @@ -143,6 +149,7 @@ extern "C" { #ifndef _di_utf8_print_error_parameter_file_to_too_many_ f_status_t utf8_print_error_parameter_file_to_too_many(utf8_setting_t * const setting, const fl_print_t print) { + if (!setting) return F_status_set_error(F_output_not); if (print.verbosity < f_console_verbosity_error_e) return F_output_not; utf8_print_line_first_locked(setting, print); @@ -156,6 +163,8 @@ extern "C" { #ifndef _di_utf8_print_bytesequence_ f_status_t utf8_print_bytesequence(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence) { + if (!setting) return F_output_not; + fl_print_format("%r%r%r", print.to, setting->prepend, sequence, setting->append); return F_none; @@ -165,6 +174,7 @@ extern "C" { #ifndef _di_utf8_print_character_invalid_ f_status_t utf8_print_character_invalid(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t invalid) { + if (!setting) return F_output_not; if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not; if (!invalid.used) return F_output_not; @@ -194,6 +204,8 @@ extern "C" { #ifndef _di_utf8_print_codepoint_ f_status_t utf8_print_codepoint(utf8_setting_t * const setting, const fl_print_t print, const uint32_t codepoint) { + if (!setting) return F_output_not; + if (codepoint < 0x10000) { fl_print_format("%rU+%04_U%r", print.to, setting->prepend, codepoint, setting->append); } @@ -211,6 +223,8 @@ extern "C" { #ifndef _di_utf8_print_combining_or_width_ f_status_t utf8_print_combining_or_width(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence) { + if (!setting) return F_output_not; + if (setting->mode & utf8_mode_to_combining_e) { f_status_t status = f_utf_is_combining(sequence.string, sequence.used); @@ -245,6 +259,7 @@ extern "C" { #ifndef _di_utf8_print_combining_or_width_invalid_ f_status_t utf8_print_combining_or_width_invalid(utf8_setting_t * const setting, const fl_print_t print) { + if (!setting) return F_output_not; if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not; fl_print_format("%r%[%r%]%r", print.to, setting->prepend, setting->valid_not, utf8_string_unknown_s, setting->valid_not, setting->append); @@ -256,6 +271,8 @@ extern "C" { #ifndef _di_utf8_print_help_ f_status_t utf8_print_help(utf8_setting_t * const setting, const fl_print_t print) { + if (!setting) return F_output_not; + f_file_stream_lock(print.to); f_print_dynamic_raw(setting->line_first, print.to); @@ -313,9 +330,10 @@ extern "C" { #ifndef _di_utf8_print_line_first_locked_ f_status_t utf8_print_line_first_locked(utf8_setting_t * const setting, const fl_print_t print) { - if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; + if (!setting) return F_status_set_error(F_output_not); + if (print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & (utf8_main_flag_verify_e | utf8_main_flag_file_to_e)) return F_output_not; } @@ -329,9 +347,10 @@ extern "C" { #ifndef _di_utf8_print_line_first_unlocked_ f_status_t utf8_print_line_first_unlocked(utf8_setting_t * const setting, const fl_print_t print) { - if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; + if (!setting) return F_status_set_error(F_output_not); + if (print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & (utf8_main_flag_verify_e | utf8_main_flag_file_to_e)) return F_output_not; } @@ -345,9 +364,10 @@ extern "C" { #ifndef _di_utf8_print_line_last_locked_ f_status_t utf8_print_line_last_locked(utf8_setting_t * const setting, const fl_print_t print) { - if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; + if (!setting) return F_status_set_error(F_output_not); + if (print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & (utf8_main_flag_verify_e | utf8_main_flag_file_to_e)) return F_output_not; } @@ -356,7 +376,7 @@ extern "C" { // Two lines are printed because the normal final end of line is never printed by design. // If this is an error or the header flag is set, then the normal end of line is printed by design so do not print this second new line. - if (F_status_is_error_not(setting->status) && !(setting->flag & utf8_main_flag_header_e)) { + if (F_status_is_error_not(setting->state.status) && !(setting->flag & utf8_main_flag_header_e)) { fll_print_dynamic_raw(setting->line_last, print.to); } @@ -367,9 +387,10 @@ extern "C" { #ifndef _di_utf8_print_line_last_unlocked_ f_status_t utf8_print_line_last_unlocked(utf8_setting_t * const setting, const fl_print_t print) { - if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not; + if (!setting) return F_status_set_error(F_output_not); + if (print.verbosity < f_console_verbosity_error_e) return F_output_not; - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; if (setting->flag & (utf8_main_flag_verify_e | utf8_main_flag_file_to_e)) return F_output_not; } @@ -383,6 +404,7 @@ extern "C" { #ifndef _di_utf8_print_raw_bytesequence_ f_status_t utf8_print_raw_bytesequence(utf8_setting_t * const setting, const fl_print_t print, const f_utf_char_t raw, const uint8_t width) { + if (!setting) return F_output_not; if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not; f_string_static_t character = macro_f_string_static_t_initialize(0, 0, width); @@ -424,6 +446,7 @@ extern "C" { #ifndef _di_utf8_print_raw_codepoint_ f_status_t utf8_print_raw_codepoint(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t raw) { + if (!setting) return F_output_not; if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not; fl_print_format("%r%[%r%]%r", print.to, setting->prepend, setting->valid_not, raw, setting->valid_not, setting->append); @@ -435,6 +458,7 @@ extern "C" { #ifndef _di_utf8_print_raw_combining_or_width_ f_status_t utf8_print_raw_combining_or_width(utf8_setting_t * const setting, const fl_print_t print, const uint8_t width) { + if (!setting) return F_output_not; if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not; if (setting->mode & utf8_mode_to_combining_e) { @@ -474,6 +498,7 @@ extern "C" { #ifndef _di_utf8_print_section_header_file_ f_status_t utf8_print_section_header_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t name, const f_array_length_t index) { + if (!setting) return F_output_not; if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return F_output_not; if (setting->flag & utf8_main_flag_verify_e) return F_output_not; @@ -507,6 +532,7 @@ extern "C" { #ifndef _di_utf8_print_section_header_parameter_ f_status_t utf8_print_section_header_parameter(utf8_setting_t * const setting, const fl_print_t print, const f_array_length_t index) { + if (!setting) return F_output_not; if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return F_output_not; if (setting->flag & utf8_main_flag_verify_e) return F_output_not; @@ -533,6 +559,7 @@ extern "C" { #ifndef _di_utf8_print_section_header_pipe_ f_status_t utf8_print_section_header_pipe(utf8_setting_t * const setting, const fl_print_t print) { + if (!setting) return F_output_not; if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return F_output_not; if (setting->flag & utf8_main_flag_verify_e) return F_output_not; @@ -553,6 +580,9 @@ extern "C" { #ifndef _di_utf8_print_width_ f_status_t utf8_print_width(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence) { + if (!setting) return F_status_set_error(F_output_not); + if (print.verbosity < f_console_verbosity_error_e) return F_output_not; + f_status_t status = f_utf_is_wide(sequence.string, sequence.used); if (status == F_true) { diff --git a/level_3/utf8/c/main/print.h b/level_3/utf8/c/main/print.h index 923f03d..6613f56 100644 --- a/level_3/utf8/c/main/print.h +++ b/level_3/utf8/c/main/print.h @@ -18,9 +18,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @@ -28,6 +26,8 @@ extern "C" { * F_none 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_utf8_print_error_ @@ -42,18 +42,18 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param invalid * The byte sequence string or unicode codepoint string representing a single character to print. * * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_error_decode_ - extern f_status_t utf8_print_error_decode(utf8_setting_t * const setting, const fl_print_t print, const f_status_t status, const f_string_static_t invalid); + extern f_status_t utf8_print_error_decode(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t invalid); #endif // _di_utf8_print_error_decode_ /** @@ -62,9 +62,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param codepoint @@ -73,9 +71,11 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_error_encode_ - extern f_status_t utf8_print_error_encode(utf8_setting_t * const setting, const fl_print_t print, const f_status_t status, const uint32_t codepoint); + extern f_status_t utf8_print_error_encode(utf8_setting_t * const setting, const fl_print_t print, const uint32_t codepoint); #endif // _di_utf8_print_error_encode_ /** @@ -84,9 +84,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * @param function @@ -103,6 +101,8 @@ extern "C" { * F_none 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_utf8_print_error_file_ @@ -115,15 +115,15 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_error_no_from_ extern f_status_t utf8_print_error_no_from(utf8_setting_t * const setting, const fl_print_t print); @@ -135,9 +135,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * @param index @@ -146,6 +144,8 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_error_parameter_file_name_empty_ extern f_status_t utf8_print_error_parameter_file_name_empty(utf8_setting_t * const setting, const fl_print_t print, const f_array_length_t index); @@ -157,9 +157,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * @param from @@ -171,6 +169,8 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_error_parameter_file_not_found_ extern f_status_t utf8_print_error_parameter_file_not_found(utf8_setting_t * const setting, const fl_print_t print, const bool from, const f_string_static_t name); @@ -182,15 +182,15 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_error_parameter_file_to_too_many_ extern f_status_t utf8_print_error_parameter_file_to_too_many(utf8_setting_t * const setting, const fl_print_t print); @@ -202,9 +202,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * @param sequence @@ -213,6 +211,8 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_bytesequence_ extern f_status_t utf8_print_bytesequence(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence); @@ -226,9 +226,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * @param invalid @@ -238,6 +236,8 @@ extern "C" { * F_none on success. * F_output_not on success, but no printing is performed. * + * F_output_not (with error bit) if setting is NULL. + * * @see utf8_print_combining_or_width() */ #ifndef _di_utf8_print_character_invalid_ @@ -250,9 +250,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * @param codepoint @@ -262,6 +260,8 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_codepoint_ extern f_status_t utf8_print_codepoint(utf8_setting_t * const setting, const fl_print_t print, const uint32_t codepoint); @@ -273,9 +273,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * @param sequence @@ -286,6 +284,8 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_combining_or_width_ extern f_status_t utf8_print_combining_or_width(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence); @@ -297,15 +297,15 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates how printing is to be performed. * * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_combining_or_width_invalid_ extern f_status_t utf8_print_combining_or_width_invalid(utf8_setting_t * const setting, const fl_print_t print); @@ -317,15 +317,15 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * The output structure to print to. * * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_help_ extern f_status_t utf8_print_help(utf8_setting_t * const setting, const fl_print_t print); @@ -341,15 +341,15 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_line_first_locked_ extern f_status_t utf8_print_line_first_locked(utf8_setting_t * const setting, const fl_print_t print); @@ -365,15 +365,15 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_line_first_unlocked_ extern f_status_t utf8_print_line_first_unlocked(utf8_setting_t * const setting, const fl_print_t print); @@ -389,15 +389,15 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_line_last_locked_ extern f_status_t utf8_print_line_last_locked(utf8_setting_t * const setting, const fl_print_t print); @@ -413,15 +413,15 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_line_last_unlocked_ extern f_status_t utf8_print_line_last_unlocked(utf8_setting_t * const setting, const fl_print_t print); @@ -433,9 +433,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param raw @@ -446,6 +444,8 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_raw_bytesequence_ extern f_status_t utf8_print_raw_bytesequence(utf8_setting_t * const setting, const fl_print_t print, const f_utf_char_t raw, const uint8_t width); @@ -457,9 +457,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param raw @@ -468,6 +466,8 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_raw_codepoint_ extern f_status_t utf8_print_raw_codepoint(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t raw); @@ -479,9 +479,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param width @@ -491,6 +489,8 @@ extern "C" { * F_none on success. * F_output_not on success, but no printing is performed. * + * F_output_not (with error bit) if setting is NULL. + * * @see utf8_print_width() */ #ifndef _di_utf8_print_raw_combining_or_width_ @@ -503,9 +503,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param name @@ -516,6 +514,8 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_section_header_file_ extern f_status_t utf8_print_section_header_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t name, const f_array_length_t index); @@ -527,9 +527,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param index @@ -538,6 +536,8 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_section_header_parameter_ extern f_status_t utf8_print_section_header_parameter(utf8_setting_t * const setting, const fl_print_t print, const f_array_length_t index); @@ -549,15 +549,15 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_section_header_pipe_ extern f_status_t utf8_print_section_header_pipe(utf8_setting_t * const setting, const fl_print_t print); @@ -569,9 +569,7 @@ extern "C" { * @param setting * The main program settings. * - * This does not alter setting.status. - * - * Assumed to always be non-NULL. + * This does not alter setting.state.status. * @param print * Designates the how and where to print. * @param sequence @@ -580,6 +578,8 @@ extern "C" { * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_utf8_print_width_ extern f_status_t utf8_print_width(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence); diff --git a/level_3/utf8/c/main/private-common.h b/level_3/utf8/c/main/private-common.h index 48dad90..5bf1965 100644 --- a/level_3/utf8/c/main/private-common.h +++ b/level_3/utf8/c/main/private-common.h @@ -12,39 +12,6 @@ extern "C" { #endif -/** - * Codepoint modes for converting to/from binary and codepoint values. - * - * The special "raw" format is used only for reading from codepoint format where that format represents binary character that is not a valid Unicode character. - * This is intended to be used to save and restore the original binary data even if that data is invalid. - * - * private_utf8_codepoint_mode_*: - * - ready: The codepoint has yet to be processed, skip leading spaces until first 'U' is matched. - * - begin: The first 'U' is matched, look for the '+'. - * - number: The '+' is matched, process numbers. - * - end: The last number is reached (at either white space or EOS/EOF). - * - bad: This is not a valid codepoint. - * - bad_begin: This is the beginning of an invalid codepoint. - * - bad_end: The end of bad is detected, which happens on white space or end of buffer. - * - raw_begin: This is the beginning of a potential raw data (matched '0'). - * - raw_number: This is the confirmed beginning of raw data (matched 'X'), process numbers. - * - raw_end: The end of raw data is detected, which happens on white space or end of buffer. - */ -#ifndef _di_utf8_codepoint_modes_ - enum { - utf8_codepoint_mode_ready_e = 1, - utf8_codepoint_mode_begin_e, - utf8_codepoint_mode_number_e, - utf8_codepoint_mode_end_e, - utf8_codepoint_mode_bad_e, - utf8_codepoint_mode_bad_begin_e, - utf8_codepoint_mode_bad_end_e, - utf8_codepoint_mode_raw_begin_e, - utf8_codepoint_mode_raw_number_e, - utf8_codepoint_mode_raw_end_e, - }; -#endif // _di__utf8_codepoint_modes_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/utf8/c/main/private-utf8_bytesequence.c b/level_3/utf8/c/main/private-utf8_bytesequence.c deleted file mode 100644 index dcf6e44..0000000 --- a/level_3/utf8/c/main/private-utf8_bytesequence.c +++ /dev/null @@ -1,162 +0,0 @@ -#include "utf8.h" -#include "private-common.h" -#include "private-utf8.h" -#include "private-utf8_bytesequence.h" -#include "private-utf8_codepoint.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_utf8_convert_bytesequence_ - f_status_t utf8_convert_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence) { - - f_status_t status = F_none; - bool valid_not = F_false; - - uint32_t codepoint = 0; - - if (sequence.used) { - status = f_utf_unicode_to(sequence.string, sequence.used, &codepoint); - } - else { - status = F_status_set_error(F_utf_not); - } - - if (F_status_is_error(status)) { - status = F_status_set_fine(status); - - if (status == F_failure || status == F_utf_not || status == F_complete_not_utf || status == F_utf_fragment || status == F_valid_not) { - valid_not = F_true; - - utf8_print_character_invalid(setting, main->output, sequence); - } - else { - status = F_status_set_error(status); - - utf8_print_error_decode(setting, main->error, status, sequence); - - return status; - } - } - else if (!(setting->flag & utf8_main_flag_verify_e)) { - if (setting->mode & utf8_mode_to_bytesequence_e) { - utf8_print_bytesequence(setting, main->output, sequence); - } - else if (setting->mode & utf8_mode_to_codepoint_e) { - utf8_print_codepoint(setting, main->output, codepoint); - } - else { - utf8_print_combining_or_width(setting, main->output, sequence); - } - } - - if (valid_not || F_status_is_error(status)) return F_utf_not; - - return F_none; - } -#endif // _di_utf8_convert_bytesequence_ - -#ifndef _di_utf8_process_file_bytesequence_ - f_status_t utf8_process_file_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_file_t file) { - - f_status_t status = F_none; - - bool valid = F_true; - bool next = F_true; - uint8_t mode_codepoint = utf8_codepoint_mode_ready_e; - - f_array_length_t i = 0; - f_array_length_t j = 0; - - f_char_t block[4] = { 0, 0, 0, 0 }; - f_string_static_t sequence = macro_f_string_static_t_initialize(block, 0, 4); - - do { - status = f_file_stream_read_block(file, &setting->buffer); - - if (status == F_none_eof && !setting->buffer.used) break; - - for (i = 0; F_status_is_fine(status) && i < setting->buffer.used; ) { - - if (!((++main->signal_check) % utf8_signal_check_d)) { - if (fll_program_standard_signal_received(main)) { - fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - - status = F_interrupt; - - break; - } - - main->signal_check = 0; - } - - status = F_none; - - // Get the current width only when processing a new block. - if (next) { - sequence.used = macro_f_utf_byte_width(setting->buffer.string[i]); - next = F_false; - } - - for (; j < sequence.used && i < setting->buffer.used; ++j, ++i) { - sequence.string[j] = setting->buffer.string[i]; - } // for - - if (j == sequence.used) { - if (setting->mode & utf8_mode_from_bytesequence_e) { - status = utf8_convert_bytesequence(main, setting, sequence); - } - else { - status = utf8_detect_codepoint(main, setting, sequence, &mode_codepoint); - - if (F_status_is_fine(status) && status != F_next) { - status = utf8_convert_codepoint(main, setting, sequence, &mode_codepoint); - } - } - - if (status == F_utf_not) { - valid = F_false; - } - - j = 0; - next = F_true; - } - } // for - - i = 0; - setting->buffer.used = 0; - - } while (F_status_is_fine(status) && status != F_interrupt); - - // Handle last (incomplete) sequence when the buffer ended before the sequence is supposed to end. - if (F_status_is_error_not(status) && status != F_interrupt && next == F_false) { - sequence.used = j; - - if (setting->mode & utf8_mode_from_bytesequence_e) { - status = utf8_convert_bytesequence(main, setting, sequence); - } - else { - status = utf8_detect_codepoint(main, setting, sequence, &mode_codepoint); - - if (F_status_is_fine(status) && status != F_next) { - status = utf8_convert_codepoint(main, setting, sequence, &mode_codepoint); - } - } - - if (status == F_utf_not) { - valid = F_false; - } - } - - setting->buffer.used = 0; - - if (F_status_is_error(status) || status == F_interrupt) return status; - - return valid; - } -#endif // _di_utf8_process_file_bytesequence_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/utf8/c/main/private-utf8.c b/level_3/utf8/c/main/process.c similarity index 66% rename from level_3/utf8/c/main/private-utf8.c rename to level_3/utf8/c/main/process.c index 69d7ef6..b4cc7d6 100644 --- a/level_3/utf8/c/main/private-utf8.c +++ b/level_3/utf8/c/main/process.c @@ -1,19 +1,22 @@ #include "utf8.h" -#include "private-common.h" -#include "private-utf8.h" -#include "private-utf8_bytesequence.h" -#include "private-utf8_codepoint.h" #ifdef __cplusplus extern "C" { #endif #ifndef _di_utf8_process_text_ - f_status_t utf8_process_text(fll_program_data_t * const main, utf8_setting_t * const setting, f_string_static_t text) { + void utf8_process_text(fll_program_data_t * const main, utf8_setting_t * const setting, f_string_static_t text) { - if (!text.used) return F_true; + if (!main || !setting) return; + + if (!text.used) { + setting->state.status = F_true; + + return; + } + + setting->state.status = F_none; - f_status_t status = F_none; bool valid = F_true; uint8_t mode_codepoint = utf8_codepoint_mode_ready_e; @@ -21,13 +24,13 @@ extern "C" { f_file_stream_lock(main->output.to); - for (; text.string[0] && F_status_is_error_not(status); ) { + for (; text.string[0] && F_status_is_error_not(setting->state.status); ) { if (!((++main->signal_check) % utf8_signal_check_d)) { if (fll_program_standard_signal_received(main)) { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); break; } @@ -35,27 +38,27 @@ extern "C" { main->signal_check = 0; } - status = F_none; + setting->state.status = F_none; if (setting->mode & utf8_mode_from_bytesequence_e) { - status = utf8_convert_bytesequence(main, setting, text); + utf8_convert_bytesequence(main, setting, text); } else { - status = utf8_detect_codepoint(main, setting, text, &mode_codepoint); + utf8_detect_codepoint(main, setting, text, &mode_codepoint); - if (F_status_is_error(status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(status), macro_utf8_f(utf8_detect_codepoint), fll_error_file_flag_fallback_e); + fll_error_print(main->error, F_status_set_fine(setting->state.status), macro_utf8_f(utf8_detect_codepoint), fll_error_file_flag_fallback_e); break; } - if (F_status_is_fine(status) && status != F_next) { - status = utf8_convert_codepoint(main, setting, text, &mode_codepoint); + if (F_status_is_error_not(setting->state.status) && setting->state.status != F_next) { + utf8_convert_codepoint(main, setting, text, &mode_codepoint); } } - if (status == F_utf_not) { + if (setting->state.status == F_utf_not) { valid = F_false; } @@ -63,7 +66,7 @@ extern "C" { utf8_process_text_width(&text); } // for - if (F_status_is_error_not(status) && !(setting->mode & utf8_mode_from_bytesequence_e)) { + if (F_status_is_error_not(setting->state.status) && !(setting->mode & utf8_mode_from_bytesequence_e)) { if (mode_codepoint != utf8_codepoint_mode_ready_e && mode_codepoint != utf8_codepoint_mode_end_e && mode_codepoint != utf8_codepoint_mode_bad_end_e && mode_codepoint != utf8_codepoint_mode_raw_end_e) { if (mode_codepoint == utf8_codepoint_mode_number_e) { mode_codepoint = utf8_codepoint_mode_end_e; @@ -79,29 +82,26 @@ extern "C" { text.used = 0; if (mode_codepoint == utf8_codepoint_mode_raw_number_e) { - status = utf8_convert_raw(main, setting, text, &mode_codepoint); + utf8_convert_raw(main, setting, text, &mode_codepoint); } else { - status = utf8_convert_codepoint(main, setting, text, &mode_codepoint); + utf8_convert_codepoint(main, setting, text, &mode_codepoint); } } } - if (F_status_is_error(status)) { - f_file_stream_unlock(main->output.to); - - return status; - } - f_file_stream_unlock(main->output.to); - return valid; + if (F_status_is_error_not(setting->state.status)) { + setting->state.status = valid; + } } #endif // _di_utf8_process_text_ #ifndef _di_utf8_process_text_width_ void utf8_process_text_width(f_string_static_t *text) { + if (!text) return; if (!text->string[0]) return; text->used = 0; diff --git a/level_3/utf8/c/main/private-utf8.h b/level_3/utf8/c/main/process.h similarity index 65% rename from level_3/utf8/c/main/private-utf8.h rename to level_3/utf8/c/main/process.h index 6638f12..81db317 100644 --- a/level_3/utf8/c/main/private-utf8.h +++ b/level_3/utf8/c/main/process.h @@ -5,8 +5,8 @@ * API Version: 0.7 * Licenses: lgpl-2.1-or-later */ -#ifndef _PRIVATE_utf8_h -#define _PRIVATE_utf8_h +#ifndef _utf8_process_h +#define _utf8_process_h #ifdef __cplusplus extern "C" { @@ -23,14 +23,14 @@ extern "C" { * This represent a single text data. * This text is NULL terminated and can therefore not contain any NULLs. * - * @return - * F_true on success and is valid. - * F_false on success and contains invalid sequences. - * F_interrupt on (exit) signal received. + * This alters setting.state.status: + * F_true on success and is valid. + * F_false on success and contains invalid sequences. + * F_interrupt on (exit) signal received. * - * Errors (with error bit) from: utf8_convert_bytesequence() - * Errors (with error bit) from: utf8_convert_codepoint() - * Errors (with error bit) from: utf8_detect_codepoint() + * Errors (with error bit) from: utf8_convert_bytesequence() + * Errors (with error bit) from: utf8_convert_codepoint() + * Errors (with error bit) from: utf8_detect_codepoint() * * @see utf8_convert_bytesequence() * @see utf8_convert_codepoint() @@ -38,7 +38,7 @@ extern "C" { * @see utf8_signal_received() */ #ifndef _di_utf8_process_text_ - extern f_status_t utf8_process_text(fll_program_data_t * const main, utf8_setting_t * const setting, f_string_static_t text) F_attribute_visibility_internal_d; + extern void utf8_process_text(fll_program_data_t * const main, utf8_setting_t * const setting, f_string_static_t text) F_attribute_visibility_internal_d; #endif // _di_utf8_process_text_ /** @@ -58,4 +58,4 @@ extern "C" { } // extern "C" #endif -#endif // _PRIVATE_utf8_h +#endif // _utf8_process_h diff --git a/level_3/utf8/c/main/utf8.c b/level_3/utf8/c/main/utf8.c index 3d9f64c..06ca2c9 100644 --- a/level_3/utf8/c/main/utf8.c +++ b/level_3/utf8/c/main/utf8.c @@ -1,8 +1,4 @@ #include "utf8.h" -#include "private-common.h" -#include "private-utf8.h" -#include "private-utf8_bytesequence.h" -#include "private-utf8_codepoint.h" #ifdef __cplusplus extern "C" { @@ -13,13 +9,13 @@ extern "C" { if (!main || !setting) return; - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_line_last_locked(setting, main->error); return; } - setting->status = F_none; + setting->state.status = F_none; if (setting->flag & utf8_main_flag_help_e) { utf8_print_help(setting, main->message); @@ -51,13 +47,13 @@ extern "C" { utf8_print_section_header_pipe(setting, main->output); if (setting->mode & utf8_mode_from_bytesequence_e) { - setting->status = utf8_process_file_bytesequence(main, setting, file); + utf8_process_file_bytesequence(main, setting, file); } else { - setting->status = utf8_process_file_codepoint(main, setting, file); + utf8_process_file_codepoint(main, setting, file); } - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (setting->mode & utf8_mode_to_bytesequence_e) { if (setting->flag & utf8_main_flag_header_e) { fll_print_dynamic_raw(f_string_eol_s, main->output.to); @@ -68,20 +64,20 @@ extern "C" { } } - if (F_status_is_error(setting->status) && F_status_set_fine(setting->status) != F_utf_fragment && F_status_set_fine(setting->status) != F_complete_not_utf) { + if (F_status_is_error(setting->state.status) && F_status_set_fine(setting->state.status) != F_utf_fragment && F_status_set_fine(setting->state.status) != F_complete_not_utf) { utf8_print_error_file(setting, main->error, setting->mode & utf8_mode_from_bytesequence_e ? macro_utf8_f(utf8_process_file_bytesequence) : macro_utf8_f(utf8_process_file_codepoint), f_string_empty_s, f_file_operation_process_s, fll_error_file_type_pipe_e); } } // Process "from" files. - if (F_status_is_error_not(setting->status) && setting->status != F_interrupt && (setting->flag & utf8_main_flag_file_from_e)) { + if (F_status_is_error_not(setting->state.status) && (setting->flag & utf8_main_flag_file_from_e)) { f_file_t file = macro_f_file_t_initialize(0, -1, F_file_flag_read_only_d, 32768, F_file_default_write_size_d); - for (f_array_length_t i = 0; i < setting->path_files_from.used && setting->status != F_interrupt; ++i) { + for (f_array_length_t i = 0; i < setting->path_files_from.used && F_status_is_error_not(setting->state.status); ++i) { if (!((++main->signal_check) % utf8_signal_check_d)) { if (fll_program_standard_signal_received(main)) { - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); break; } @@ -91,31 +87,31 @@ extern "C" { utf8_print_section_header_file(setting, main->output, setting->path_files_from.array[i], i); - setting->status = f_file_stream_open(setting->path_files_from.array[i], f_string_empty_s, &file); + setting->state.status = f_file_stream_open(setting->path_files_from.array[i], f_string_empty_s, &file); - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { utf8_print_error_file(setting, main->error, macro_utf8_f(f_file_stream_open), setting->path_files_from.array[i], f_file_operation_open_s, fll_error_file_type_file_e); break; } if (setting->mode & utf8_mode_from_bytesequence_e) { - setting->status = utf8_process_file_bytesequence(main, setting, file); + utf8_process_file_bytesequence(main, setting, file); } else { - setting->status = utf8_process_file_codepoint(main, setting, file); + utf8_process_file_codepoint(main, setting, file); } f_file_stream_flush(file); f_file_stream_close(&file); if (setting->flag & utf8_main_flag_verify_e) { - if (setting->status == F_false) { + if (setting->state.status == F_false) { valid = F_false; } } - if (F_status_is_error_not(setting->status)) { + if (F_status_is_error_not(setting->state.status)) { if (setting->mode & utf8_mode_to_bytesequence_e) { if (setting->flag & utf8_main_flag_header_e) { fll_print_dynamic_raw(f_string_eol_s, main->output.to); @@ -133,7 +129,7 @@ extern "C" { } } - if (F_status_is_error(setting->status) && F_status_set_fine(setting->status) != F_utf_fragment && F_status_set_fine(setting->status) != F_complete_not_utf) { + if (F_status_is_error(setting->state.status) && F_status_set_fine(setting->state.status) != F_utf_fragment && F_status_set_fine(setting->state.status) != F_complete_not_utf) { utf8_print_error_file(setting, main->error, setting->mode & utf8_mode_from_bytesequence_e ? macro_utf8_f(utf8_process_file_bytesequence) : macro_utf8_f(utf8_process_file_codepoint), setting->path_files_from.array[i], f_file_operation_process_s, fll_error_file_type_file_e); break; @@ -142,12 +138,12 @@ extern "C" { } // Process remaining parameters. - if (F_status_is_error_not(setting->status) && setting->status != F_interrupt && setting->remaining.used) { - for (f_array_length_t i = 0; F_status_is_error_not(setting->status) && i < setting->remaining.used; ++i) { + if (F_status_is_error_not(setting->state.status) && setting->remaining.used) { + for (f_array_length_t i = 0; F_status_is_error_not(setting->state.status) && i < setting->remaining.used; ++i) { if (!((++main->signal_check) % utf8_signal_check_d)) { if (fll_program_standard_signal_received(main)) { - setting->status = F_status_set_error(F_interrupt); + setting->state.status = F_status_set_error(F_interrupt); break; } @@ -157,31 +153,31 @@ extern "C" { utf8_print_section_header_parameter(setting, main->output, main->parameters.remaining.array[i]); - setting->status = utf8_process_text(main, setting, main->parameters.arguments.array[main->parameters.remaining.array[i]]); + utf8_process_text(main, setting, main->parameters.arguments.array[main->parameters.remaining.array[i]]); if (setting->flag & utf8_main_flag_verify_e) { - if (setting->status == F_false) { + if (setting->state.status == F_false) { valid = F_false; } } } // for } - if (F_status_is_error(setting->status)) { + if (F_status_is_error(setting->state.status)) { + if (F_status_set_fine(setting->state.status) == F_interrupt) return; + utf8_print_line_last_locked(setting, main->error); return; } - if (setting->status == F_interrupt) return; - utf8_print_line_last_locked(setting, main->message); if (setting->flag & utf8_main_flag_verify_e) { - setting->status = valid; + setting->state.status = valid; } else { - setting->status = F_none; + setting->state.status = F_none; } } #endif // _di_utf8_main_ diff --git a/level_3/utf8/c/main/utf8.h b/level_3/utf8/c/main/utf8.h index 525fecc..1f379f2 100644 --- a/level_3/utf8/c/main/utf8.h +++ b/level_3/utf8/c/main/utf8.h @@ -59,7 +59,10 @@ #include #include #include +#include +#include #include +#include #ifdef __cplusplus extern "C" { @@ -81,12 +84,12 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.status: + * This alters setting.state.status: * F_none on success. * F_true on success when performing verification and verify passed. * F_false on success when performing verification and verify failed. - * F_interrupt on (exit) signal received. * + * F_interrupt (with error bit) on (exit) signal received. * F_parameter (with error bit) if main is NULL or setting is NULL. */ #ifndef _di_utf8_main_ diff --git a/level_3/utf8/data/build/settings b/level_3/utf8/data/build/settings index 541ebac..fc11590 100644 --- a/level_3/utf8/data/build/settings +++ b/level_3/utf8/data/build/settings @@ -22,12 +22,11 @@ build_libraries-individual -lfll_error -lfll_print -lfll_program -lfl_conversion build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_library main/common.c main/common-print.c main/common-string.c main/common-type.c main/print.c main/utf8.c -build_sources_library main/private-common.c main/private-utf8.c main/private-utf8_bytesequence.c main/private-utf8_codepoint.c +build_sources_library main/common.c main/common-print.c main/common-string.c main/common-type.c main/bytesequence.c main/codepoint.c main/print.c main/process.c main/utf8.c build_sources_program main/main.c -build_sources_headers main/common.h main/common-print.h main/common-string.h main/common-type.h main/print.h main/utf8.h +build_sources_headers main/common.h main/common-print.h main/common-string.h main/common-type.h main/bytesequence.h main/codepoint.h main/print.h main/process.h main/utf8.h build_sources_documentation man