From 8491b4d8acad6487a49eb05f7155dfd304458d3b Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 30 Apr 2023 22:02:04 -0500 Subject: [PATCH] Progress: Continue work on fss_read, making relevant changes in other projects. Start using "static" where it is safe to do so and easy for me to identify such cases. I would note that a static array of const f_string_static_t does not work. --- level_2/fll_program/c/program/print.c | 20 + level_2/fll_program/c/program/print.h | 30 + level_3/byte_dump/c/common.c | 4 +- level_3/control/c/common.c | 4 +- level_3/controller/c/common.c | 4 +- level_3/fake/c/main/build/load.c | 4 +- level_3/fake/c/main/common.c | 16 +- level_3/fake/c/main/fake/path_generate.c | 6 +- level_3/fake/c/main/make/operate.c | 4 +- level_3/fake/c/main/make/operate_validate_type.c | 4 +- level_3/firewall/c/common.c | 4 +- level_3/fss_basic_list_read/c/common.c | 4 +- level_3/fss_basic_read/c/common.c | 4 +- level_3/fss_embedded_list_read/c/common.c | 4 +- level_3/fss_extended_list_read/c/common.c | 4 +- level_3/fss_extended_read/c/common.c | 4 +- level_3/fss_identify/c/common.c | 4 +- level_3/fss_identify/c/fss_identify.c | 4 +- level_3/fss_payload_read/c/common.c | 4 +- level_3/fss_read/c/main/common.c | 699 +++++++---------------- level_3/fss_read/c/main/common.h | 6 +- level_3/fss_read/c/main/common/enumeration.h | 35 +- level_3/fss_read/c/main/common/print.c | 2 + level_3/fss_read/c/main/common/print.h | 2 + level_3/fss_read/c/main/common/type.h | 118 ++-- level_3/fss_read/c/main/print/error.c | 18 + level_3/fss_read/c/main/print/error.h | 19 + level_3/fss_write/c/main/common.c | 10 +- level_3/fss_write/c/main/common/type.h | 2 +- level_3/iki_read/c/main/common.c | 8 +- level_3/iki_write/c/main/common.c | 4 +- level_3/status_code/c/main/common.c | 4 +- level_3/utf8/c/main/common.c | 4 +- 33 files changed, 453 insertions(+), 610 deletions(-) diff --git a/level_2/fll_program/c/program/print.c b/level_2/fll_program/c/program/print.c index 6cbfa58..1205bf3 100644 --- a/level_2/fll_program/c/program/print.c +++ b/level_2/fll_program/c/program/print.c @@ -210,6 +210,26 @@ extern "C" { } #endif // _di_fll_program_print_error_parameter_cannot_use_with_xor_ +#ifndef _di_fll_program_print_error_parameter_empty_value_ + f_status_t fll_program_print_error_parameter_empty_value(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name) { + #ifndef _di_level_2_parameter_checking_ + if (!print) return F_status_set_error(F_parameter); + #endif // _di_level_2_parameter_checking_ + + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe parameter%] ", print->to, print->set->error, print->prefix, print->set->error); + fl_print_format("%[%Q%Q%]", print->to, print->set->notable, symbol, name, print->set->notable); + fl_print_format(" %[is specified as an empty string, but an empty string is not allowed.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fll_program_print_error_parameter_empty_value_ + #ifndef _di_fll_program_print_error_parameter_integer_not_ f_status_t fll_program_print_error_parameter_integer_not(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_string_static_t value) { #ifndef _di_level_2_parameter_checking_ diff --git a/level_2/fll_program/c/program/print.h b/level_2/fll_program/c/program/print.h index 47a6135..f0ac8a4 100644 --- a/level_2/fll_program/c/program/print.h +++ b/level_2/fll_program/c/program/print.h @@ -305,6 +305,36 @@ extern "C" { #endif // _di_fll_program_print_error_parameter_allows_either_xor_ /** + * Print message about parameter the parameter value being an empty string. + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * @param symbol + * The symbol string prepended to both parameters. + * This locks, uses, and unlocks the file stream. + * This is usually f_console_symbol_long_normal_s. + * @param name + * The parameter name. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_fll_program_print_error_parameter_empty_value_ + extern f_status_t fll_program_print_error_parameter_empty_value(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name); +#endif // _di_fll_program_print_error_parameter_empty_value_ + +/** * Print message about parameter not being a valid integer. * * This is only printed when verbosity is not set to quiet. diff --git a/level_3/byte_dump/c/common.c b/level_3/byte_dump/c/common.c index 5e57f08..daeaba4 100644 --- a/level_3/byte_dump/c/common.c +++ b/level_3/byte_dump/c/common.c @@ -122,7 +122,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -143,7 +143,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/control/c/common.c b/level_3/control/c/common.c index a6f6032..9c59be5 100644 --- a/level_3/control/c/common.c +++ b/level_3/control/c/common.c @@ -225,7 +225,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -246,7 +246,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/controller/c/common.c b/level_3/controller/c/common.c index 7c3a0ee..58c6e0f 100644 --- a/level_3/controller/c/common.c +++ b/level_3/controller/c/common.c @@ -657,7 +657,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -678,7 +678,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/fake/c/main/build/load.c b/level_3/fake/c/main/build/load.c index 2b4e3ca..82e862d 100644 --- a/level_3/fake/c/main/build/load.c +++ b/level_3/fake/c/main/build/load.c @@ -948,7 +948,7 @@ extern "C" { &setting->version_target, // version_target }; - const uint8_t settings_single_version_default[] = { + static const uint8_t settings_single_version_default[] = { 0, // build_compiler 0, // build_indexer 0, // build_language @@ -1035,7 +1035,7 @@ extern "C" { }; // 1 = "yes" or "no", 2 = path/, 3 = literal, 4 = "bash", "c", or "c++", 5 = "major", "minor", "micro", or "nano". - const uint8_t settings_single_type[] = { + static const uint8_t settings_single_type[] = { 3, // build_compiler 3, // build_indexer 4, // build_language diff --git a/level_3/fake/c/main/common.c b/level_3/fake/c/main/common.c index de56b30..5be6e32 100644 --- a/level_3/fake/c/main/common.c +++ b/level_3/fake/c/main/common.c @@ -59,7 +59,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -80,7 +80,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); @@ -121,19 +121,19 @@ extern "C" { uint8_t i = 0; { - const uint8_t enables[] = { + static const uint8_t enables[] = { fake_parameter_documents_enable_e, fake_parameter_shared_enable_e, fake_parameter_static_enable_e, }; - const uint8_t disables[] = { + static const uint8_t disables[] = { fake_parameter_documents_enable_e, fake_parameter_shared_enable_e, fake_parameter_static_enable_e, }; - const uint16_t flags[] = { + static const uint16_t flags[] = { fake_main_flag_enable_documents_e, fake_main_flag_enable_shared_e, fake_main_flag_enable_static_e, @@ -161,7 +161,7 @@ extern "C" { } { - const f_array_length_t parameters[] = { + static const f_array_length_t parameters[] = { fake_parameter_build_e, fake_parameter_data_e, fake_parameter_documents_e, @@ -219,7 +219,7 @@ extern "C" { fake_default_work_s, }; - const bool cleanups[] = { + static const bool cleanups[] = { F_true, // fake_parameter_build_e F_true, // fake_parameter_data_e F_true, // fake_parameter_documents_e @@ -363,7 +363,7 @@ extern "C" { } { - const f_array_length_t parameters[] = { + static const f_array_length_t parameters[] = { fake_parameter_define_e, fake_parameter_mode_e, }; diff --git a/level_3/fake/c/main/fake/path_generate.c b/level_3/fake/c/main/fake/path_generate.c index 34c870d..7f9dbfb 100644 --- a/level_3/fake/c/main/fake/path_generate.c +++ b/level_3/fake/c/main/fake/path_generate.c @@ -22,7 +22,7 @@ extern "C" { main->setting.data, }; - const uint8_t parameters_size[] = { + static const uint8_t parameters_size[] = { 9, 3, }; @@ -121,7 +121,7 @@ extern "C" { data->path_documents, }; - const uint8_t parameters_size[] = { + static const uint8_t parameters_size[] = { 3, 3, 3, @@ -293,7 +293,7 @@ extern "C" { data->path_work_programs, }; - const uint8_t parameters_size[] = { + static const uint8_t parameters_size[] = { 3, 3, }; diff --git a/level_3/fake/c/main/make/operate.c b/level_3/fake/c/main/make/operate.c index 58a04d1..eb160a8 100644 --- a/level_3/fake/c/main/make/operate.c +++ b/level_3/fake/c/main/make/operate.c @@ -1043,7 +1043,7 @@ extern "C" { data_make->setting_build.modes_default, }; - const uint8_t dynamics_flag[] = { + static const uint8_t dynamics_flag[] = { 0, // build_libraries 0, // build_libraries_shared 0, // build_libraries_static @@ -1306,7 +1306,7 @@ extern "C" { fake_make_operation_write_s, }; - const uint8_t operations_type[] = { + static const uint8_t operations_type[] = { fake_make_operation_type_and_e, fake_make_operation_type_break_e, fake_make_operation_type_build_e, diff --git a/level_3/fake/c/main/make/operate_validate_type.c b/level_3/fake/c/main/make/operate_validate_type.c index 0e86982..fbc0a16 100644 --- a/level_3/fake/c/main/make/operate_validate_type.c +++ b/level_3/fake/c/main/make/operate_validate_type.c @@ -253,7 +253,7 @@ extern "C" { fake_make_operation_argument_if_success_s, }; - const uint8_t if_type_codes[] = { + static const uint8_t if_type_codes[] = { fake_make_operation_if_type_if_define_e, fake_make_operation_if_type_if_equal_e, fake_make_operation_if_type_if_equal_not_e, @@ -289,7 +289,7 @@ extern "C" { fake_make_operation_argument_if_parameter_s, }; - const uint8_t if_not_type_codes[] = { + static const uint8_t if_not_type_codes[] = { fake_make_operation_if_type_if_not_define_e, fake_make_operation_if_type_if_not_exist_e, fake_make_operation_if_type_if_not_group_e, diff --git a/level_3/firewall/c/common.c b/level_3/firewall/c/common.c index 65a4c26..795ff42 100644 --- a/level_3/firewall/c/common.c +++ b/level_3/firewall/c/common.c @@ -156,7 +156,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -177,7 +177,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/fss_basic_list_read/c/common.c b/level_3/fss_basic_list_read/c/common.c index 9c75267..5bca369 100644 --- a/level_3/fss_basic_list_read/c/common.c +++ b/level_3/fss_basic_list_read/c/common.c @@ -116,7 +116,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -137,7 +137,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/fss_basic_read/c/common.c b/level_3/fss_basic_read/c/common.c index aac5610..9b99afd 100644 --- a/level_3/fss_basic_read/c/common.c +++ b/level_3/fss_basic_read/c/common.c @@ -115,7 +115,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -136,7 +136,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/fss_embedded_list_read/c/common.c b/level_3/fss_embedded_list_read/c/common.c index 69baf61..cfa6775 100644 --- a/level_3/fss_embedded_list_read/c/common.c +++ b/level_3/fss_embedded_list_read/c/common.c @@ -114,7 +114,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -135,7 +135,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/fss_extended_list_read/c/common.c b/level_3/fss_extended_list_read/c/common.c index 88ec05d..f7465ca 100644 --- a/level_3/fss_extended_list_read/c/common.c +++ b/level_3/fss_extended_list_read/c/common.c @@ -122,7 +122,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -143,7 +143,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/fss_extended_read/c/common.c b/level_3/fss_extended_read/c/common.c index 0f52cfc..93de956 100644 --- a/level_3/fss_extended_read/c/common.c +++ b/level_3/fss_extended_read/c/common.c @@ -115,7 +115,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -136,7 +136,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/fss_identify/c/common.c b/level_3/fss_identify/c/common.c index 5cd74c1..dd2e5bc 100644 --- a/level_3/fss_identify/c/common.c +++ b/level_3/fss_identify/c/common.c @@ -82,7 +82,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -103,7 +103,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index 2544d2c..7e62094 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -29,7 +29,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -50,7 +50,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/fss_payload_read/c/common.c b/level_3/fss_payload_read/c/common.c index 698b8ac..db2f7e6 100644 --- a/level_3/fss_payload_read/c/common.c +++ b/level_3/fss_payload_read/c/common.c @@ -116,7 +116,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -137,7 +137,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/fss_read/c/main/common.c b/level_3/fss_read/c/main/common.c index e4c66e3..4108faa 100644 --- a/level_3/fss_read/c/main/common.c +++ b/level_3/fss_read/c/main/common.c @@ -116,623 +116,310 @@ extern "C" { if (main->program.parameters.array[fss_read_parameter_help_e].result & f_console_result_found_e) return; if (main->program.parameters.array[fss_read_parameter_version_e].result & f_console_result_found_e) return; - if (main->program.parameters.array[fss_read_parameter_strip_invalid_e].result & f_console_result_found_e) { - main->setting.flag |= fss_read_main_flag_strip_invalid_e; - } - - if ((main->program.parameters.array[fss_read_parameter_file_e].result & f_console_result_value_e) && main->program.parameters.array[fss_read_parameter_file_e].values.used) { - if (main->program.parameters.array[fss_read_parameter_file_e].values.used > 1) { - main->setting.state.status = F_status_set_error(F_parameter); - - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } - - fll_program_print_error_parameter_must_specify_once(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_file_s); - - return; - } - - const f_array_length_t index = main->program.parameters.array[fss_read_parameter_file_e].values.array[0]; - - main->program.output.to.id = -1; - main->program.output.to.stream = 0; - - main->setting.state.status = f_file_stream_open(main->program.parameters.arguments.array[index], f_string_empty_s, &main->program.output.to); - - if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } - - fss_read_print_error_file(&main->program.error, macro_fss_read_f(f_file_stream_open), main->program.parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } + f_array_length_t i = 0; - main->setting.flag |= fss_read_main_flag_file_to_e; - } - else if (main->program.parameters.array[fss_read_parameter_file_e].result & f_console_result_found_e) { - main->setting.state.status = F_status_set_error(F_parameter); + { + static const f_array_length_t parameter_code[] = { + fss_read_parameter_at_e, + fss_read_parameter_depth_e, + fss_read_parameter_line_e, + fss_read_parameter_select_e, + fss_read_parameter_name_e, + fss_read_parameter_delimit_e, + }; - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } + const f_string_static_t parameter_name[] = { + fss_read_long_at_s, + fss_read_long_depth_s, + fss_read_long_line_s, + fss_read_long_select_s, + fss_read_long_name_s, + fss_read_long_delimit_s, + }; - fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_file_s); + static const f_string_t message_positive_number = "a positive number"; + static const f_string_t message_string = "a string"; + static const f_string_t message_value = "a value"; + + static const f_string_t parameter_message[] = { + message_positive_number, + message_positive_number, + message_positive_number, + message_positive_number, + message_string, + message_value, + }; - return; - } + for (i = 0; i < 6; ++i) { - if ((main->program.parameters.array[fss_read_parameter_object_e].result & f_console_result_value_e) && main->program.parameters.array[fss_read_parameter_object_e].values.used) { - f_array_lengths_t * const values = &main->program.parameters.array[fss_read_parameter_object_e].values; + if (main->program.parameters.array[parameter_code[i]].result & f_console_result_found_e)) { + main->setting.state.status = F_status_set_error(F_parameter); - main->setting.objects.used = 0; + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } - main->setting.state.status = f_string_dynamics_resize(values->used, &main->setting.objects); + fss_read_print_error_parameter_requires_message(&main->error, f_console_symbol_long_normal_s, parameter_name[i], parameter_message[i]); - if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + return; } - - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_resize)); - - return; - } - - // Construct the array without allocating any more memory for the string data by setting this as a static string (used > 0, size = 0). - for (f_array_length_t index = 0; main->setting.objects.used < values->used; ) { - - index = values->array[main->setting.objects.used]; - - main->setting.objects.array[main->setting.objects.used].string = main->program.parameters.arguments.array[index].string; - main->setting.objects.array[main->setting.objects.used].used = main->program.parameters.arguments.array[index].used; - main->setting.objects.array[main->setting.objects.used++].size = 0; } // for - - main->setting.flag |= fss_read_main_flag_object_e; } - else if (main->program.parameters.array[fss_read_parameter_object_e].result & f_console_result_found_e) { - main->setting.state.status = F_status_set_error(F_parameter); - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } + if (main->parameters.array[fss_read_parameter_columns_e].result & f_console_result_found_e) { + static const f_array_length_t parameter_code[] = { + fss_read_parameter_depth_e, + fss_read_parameter_line_e, + fss_read_parameter_pipe_e, + fss_read_parameter_select_e, + fss_read_parameter_total_e, + }; - fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_object_s); + const f_string_static_t parameter_name[] = { + fss_read_long_depth_s, + fss_read_long_line_s, + fss_read_long_pipe_s, + fss_read_long_select_s, + fss_read_long_total_s, + }; - return; - } + const uint8_t parameter_match[] = { + f_console_result_value_e, + f_console_result_value_e, + f_console_result_found_e, + f_console_result_value_e, + f_console_result_found_e, + }; - if ((main->program.parameters.array[fss_read_parameter_content_e].result & f_console_result_value_e) && main->program.parameters.array[fss_read_parameter_content_e].values.used) { + for (i = 0; i < 5; ++i) { - if (main->setting.flag & fss_read_main_flag_object_e) { - if (!(main->setting.flag & fss_read_main_flag_content_multiple_e)) { - if (main->program.parameters.array[fss_read_parameter_content_e].values.used > main->program.parameters.array[fss_read_parameter_object_e].values.used) { - main->setting.state.status = F_status_set_error(F_support_not); + if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { + main->setting.state.status = F_status_set_error(F_parameter); + if (main->error.verbosity > f_console_verbosity_quiet_e) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fss_read_print_error_one_content_only(&main->program.error); - - return; + fll_program_print_error_parameter_cannot_use_with(&main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_read_long_columns_s, parameter_name[i]); } - } - } - - f_array_length_t stub_object_array[1] = { 0 }; - f_array_lengths_t stub_object = macro_f_array_lengths_t_initialize_1(stub_object_array, 0, 1); - - f_array_lengths_t * const values_content = &main->program.parameters.array[fss_read_parameter_content_e].values; - f_array_lengths_t * const values_object = main->program.parameters.array[fss_read_parameter_object_e].values.used - ? &main->program.parameters.array[fss_read_parameter_object_e].values - : &stub_object; - - main->setting.contentss.used = 0; - - main->setting.state.status = f_string_dynamicss_increase_by(values_object->used, &main->setting.contentss); - - if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } - - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamicss_increase_by)); - - return; - } - - f_array_length_t i = 0; // For Contents. - f_array_length_t j = 0; // For Objects. - f_array_length_t k = 0; - f_array_length_t total = 0; - f_array_length_t index = 0; - - // Construct the array without allocating any more memory for the string data by setting this as a static string (used > 0, size = 0). - while (i < values_content->used) { - // Determine the total Content associated with the given Object. - for (total = 0; i + total < values_content->used && (j + 1 >= values_object->used || values_content->array[i + total] < values_object->array[j + 1]); ++total) { - // Do nothing. - } // for - - - if (!total) { - ++main->setting.contentss.used; - - if (++j < values_object->used) continue; - - break; + return; } + } // for + } - main->setting.state.status = f_string_dynamics_increase_by(total, &main->setting.contentss.array[j]); + if (main->parameters.array[fss_read_parameter_pipe_e].result & f_console_result_found_e) { + if ((main->parameters.array[fss_read_parameter_total_e].result & f_console_result_found_e) || (main->parameters.array[fss_read_parameter_total_e].result & f_console_result_found_e)) { + main->setting.state.status = F_status_set_error(F_parameter); - if (F_status_is_error(main->setting.state.status)) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase_by)); - - return; - } - - for (k = 0; k < total; ++k) { - - index = values_content->array[i++]; - - main->setting.contentss.array[j].array[main->setting.contentss.array[j].used].string = main->program.parameters.arguments.array[index].string; - main->setting.contentss.array[j].array[main->setting.contentss.array[j].used].used = main->program.parameters.arguments.array[index].used; - main->setting.contentss.array[j].array[main->setting.contentss.array[j].used++].size = 0; - } // for - } // while - - if (total) { - ++main->setting.contentss.used; - } - - main->setting.flag |= fss_read_main_flag_content_e; - } - else if (main->program.parameters.array[fss_read_parameter_content_e].result & f_console_result_found_e) { - main->setting.state.status = F_status_set_error(F_parameter); - - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } - - fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_content_s); - - return; - } - - if ((main->program.parameters.array[fss_read_parameter_prepend_e].result & f_console_result_value_e) && main->program.parameters.array[fss_read_parameter_prepend_e].values.used) { - const f_array_length_t index = main->program.parameters.array[fss_read_parameter_prepend_e].values.array[main->program.parameters.array[fss_read_parameter_prepend_e].values.used - 1]; - - main->setting.prepend.used = 0; - - main->setting.state.status = f_string_dynamic_append_nulless(main->program.parameters.arguments.array[index], &main->setting.prepend); - - if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + fll_program_print_error_parameter_cannot_use_with( + &main->error, f_console_symbol_long_normal_s, + f_console_symbol_long_normal_s, + fss_read_long_pipe_s, + (main->parameters.array[fss_read_parameter_total_e].result & f_console_result_found_e) + ? fss_read_long_total_s + : fss_read_long_line_s + ); } - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append_nulless)); - return; } + } - if (main->program.parameters.arguments.array[index].used) { - f_string_range_t range = macro_f_string_range_t_initialize_2(main->program.parameters.arguments.array[index].used); + if (main->parameters.array[fss_read_parameter_delimit_e].result & f_console_result_value_e) { + f_array_length_t index = 0; + f_array_length_t length = 0; - for (; range.start < main->program.parameters.arguments.array[index].used; range.start++) { + // Set the value to 0 to allow for detecting mode based on what is provided. + main->setting.delimit_mode = 0; - if (f_fss_is_space(main->program.parameters.arguments.array[index], range, &main->setting.state) == F_false) { - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } + for (i = 0; i < main->parameters.array[fss_read_parameter_delimit_e].values.used; ++i) { - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_fss_is_space)); - } - else { - main->setting.state.status = F_status_set_error(F_parameter); + if (!((++main->signal_check) % fss_read_signal_check_d)) { + if (fll_program_standard_signal_received(&main->program)) { + fll_program_print_signal_received(main->warning, main->signal_received); - fss_read_print_error_prepend_only_whitespace(&main->program.error); - } + main->setting.state.status = F_status_set_error(F_interrupt); return; } - } // for - } - main->setting.flag |= fss_read_main_flag_prepend_e; - } - else if (main->program.parameters.array[fss_read_parameter_prepend_e].result & f_console_result_found_e) { - main->setting.state.status = F_status_set_error(F_parameter); - - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } - - fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_prepend_s); - - return; - } - - if ((main->program.parameters.array[fss_read_parameter_ignore_e].result & f_console_result_value_e) && main->program.parameters.array[fss_read_parameter_ignore_e].values.used) { - if (main->program.parameters.array[fss_read_parameter_ignore_e].values.used % 2 != 0) { - main->setting.state.status = F_status_set_error(F_parameter); - - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + main->signal_check = 0; } - fll_program_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_ignore_s, fss_read_string_two_s); - - return; - } - - // Only process if the standard designates that the ingore is supported. - if (main->setting.flag & fss_read_main_flag_ignore_e) { - f_array_length_t stub_data_array[1] = { 0 }; - f_array_lengths_t stub_data = macro_f_array_lengths_t_initialize_1(stub_data_array, 0, 1); - - f_array_lengths_t * const values_ignore = &main->program.parameters.array[fss_read_parameter_ignore_e].values; - f_array_lengths_t * const values_data = main->program.parameters.array[fss_read_parameter_object_e].values.used - ? &main->program.parameters.array[fss_read_parameter_object_e].values - : main->program.parameters.array[fss_read_parameter_content_e].values.used - ? &main->program.parameters.array[fss_read_parameter_content_e].values - : &stub_data; + index = main->parameters.array[fss_read_parameter_delimit_e].values.array[i]; + length = main->program.parameters.arguments.array[index].used; - main->setting.ignoress.used = 0; + if (!length) { + main->setting.state.status = F_status_set_error(F_parameter); - main->setting.state.status = f_string_rangess_increase_by(values_data->used, &main->setting.ignoress); - - if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_rangess_increase_by)); + fll_program_print_error_parameter_empty_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_file_s); return; } - f_array_length_t i = 0; // For Ignores. - f_array_length_t j = 0; // For Objects/Contents. - f_array_length_t k = 0; - f_array_length_t total = 0; - f_array_length_t index = 0; + if (f_compare_dynamic(fss_read_delimit_mode_name_none_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + main->setting.delimit_mode = fss_read_delimit_mode_none_e; + } + else if (f_compare_dynamic(fss_read_delimit_mode_name_all_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + main->setting.delimit_mode = fss_read_delimit_mode_all_e; + } + else if (f_compare_dynamic(fss_read_delimit_mode_name_object_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + switch (main->setting.delimit_mode) { + case fss_read_delimit_mode_auto_e: + main->setting.delimit_mode = fss_read_delimit_mode_object_e; - // Construct the array without allocating any more memory for the string data by setting this as a static string (used > 0, size = 0). - while (i < values_ignore->used) { + break; - // Determine the total Ignore associated with the given Object/Content. - for (total = 0; i + total < values_ignore->used && (j + 1 >= values_data->used || values_ignore->array[i + total] < values_data->array[j + 1]); ++total) { - // Do nothing. - } // for + case fss_read_delimit_mode_none_e: + case fss_read_delimit_mode_all_e: + case fss_read_delimit_mode_content_greater_object_e: + case fss_read_delimit_mode_content_lesser_object_e: + case fss_read_delimit_mode_object_e: + break; - if (!total) { - ++main->setting.ignoress.used; + case fss_read_delimit_mode_content_e: + main->setting.delimit_mode = fss_read_delimit_mode_content_object_e; - if (++j < values_data->used) continue; + break; - break; - } + case fss_read_delimit_mode_content_greater_e: + main->setting.delimit_mode = fss_read_delimit_mode_content_greater_object_e; - main->setting.state.status = f_string_ranges_increase_by(total, &main->setting.ignoress.array[j]); + break; - if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } + case fss_read_delimit_mode_content_lesser_e: + main->setting.delimit_mode = fss_read_delimit_mode_content_lesser_object_e; - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_ranges_increase_by)); + break; - return; + default: + break; + } + } + else { + if (!main->setting.delimit_mode) { + main->setting.delimit_mode = fss_read_delimit_mode_content_e; + } + else if (main->setting.delimit_mode == fss_read_delimit_mode_object_e) { + main->setting.delimit_mode = fss_read_delimit_mode_content_object_e; } - for (k = 0; k < total; ++k) { - - index = values_ignore->array[i++]; - - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &main->setting.ignoress.array[j].array[main->setting.ignoress.array[j].used].start); - - if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + if (main->program.parameters.arguments.array[index].string[length - 1] == fss_read_delimit_mode_name_greater_s.string[0]) { + if (!(main->setting.delimit_mode == fss_read_delimit_mode_none_e || main->setting.delimit_mode == fss_read_delimit_mode_all_e)) { + if (main->setting.delimit_mode == fss_read_delimit_mode_content_object_e) { + main->setting.delimit_mode = fss_read_delimit_mode_content_greater_object_e; } - - fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_ignore_s, main->program.parameters.arguments.array[index]); - - return; - } - - index = values_ignore->array[i++]; - - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &main->setting.ignoress.array[j].array[main->setting.ignoress.array[j].used].stop); - - if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + else { + main->setting.delimit_mode = fss_read_delimit_mode_content_greater_e; } - - fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_ignore_s, main->program.parameters.arguments.array[index]); - - return; } - if (main->setting.ignoress.array[j].array[main->setting.ignoress.array[j].used].stop > main->setting.ignoress.array[j].array[main->setting.ignoress.array[j].used].start) { - main->setting.state.status = F_status_set_error(F_parameter); - - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + // Shorten the length to better convert the remainder to a number. + --length; + } + else if (main->program.parameters.arguments.array[index].string[length - 1] == fss_read_delimit_mode_name_lesser_s.string[0]) { + if (!(main->setting.delimit_mode == fss_read_delimit_mode_none_e || main->setting.delimit_mode == fss_read_delimit_mode_all_e)) { + if (main->setting.delimit_mode == fss_read_delimit_mode_content_object_e) { + main->setting.delimit_mode = fss_read_delimit_mode_content_lesser_object_e; + } + else { + main->setting.delimit_mode = fss_read_delimit_mode_content_lesser_e; } - - fll_program_print_error_parameter_range_start_before_stop( - &main->program.error, - f_console_symbol_long_normal_s, - fss_read_long_ignore_s, - main->program.parameters.arguments.array[values_ignore->array[i - 1]], - main->program.parameters.arguments.array[index] - ); - - return; - } - - ++main->setting.ignoress.array[j].used; - } // for - } // while - - if (total) { - ++main->setting.ignoress.used; - } - } - else { - - // Still validate the parameters, even if not being used. - f_array_length_t i = 0; - f_array_length_t index = 0; - f_string_range_t number = f_string_range_t_initialize; - - while (i < main->program.parameters.array[fss_read_parameter_ignore_e].values.used) { - - index = main->program.parameters.array[fss_read_parameter_ignore_e].values.array[i++]; - - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &number.start); - - if (F_status_is_error(main->setting.state.status)) { - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_ignore_s, main->program.parameters.arguments.array[index]); + // Shorten the length to better convert the remainder to a number. + --length; + } - return; + if (length) { + main->setting.range.start = 0; + main->setting.range.stop = length - 1; + } + else { + main->setting.range.start = 1; + main->setting.range.stop = 0; } - index = main->program.parameters.array[fss_read_parameter_ignore_e].values.array[i++]; + // Ignore leading plus sign. + if (main->program.parameters.arguments.array[index].string[0] == f_string_ascii_plus_s.string[0]) { + ++main->setting.range.start; + } - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &number.stop); + main->setting.state.status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], main->setting.range, &main->setting.delimit_depth); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_ignore_s, main->program.parameters.arguments.array[index]); + fll_error_parameter_integer_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_partial_to_unsigned_detect), F_true, fss_read_long_delimit_s, main->program.parameters.arguments.array[index]); return; } - if (number.start > number.stop) { - main->setting.state.status = F_status_set_error(F_parameter); - - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + // There can be nothing smaller than 0, so replace '0-' logic with just '0' logic. + if (main->setting.delimit_mode == fss_read_delimit_mode_content_lesser_e || main->setting.delimit_mode == fss_read_delimit_mode_content_lesser_object_e) { + if (!main->setting.delimit_depth) { + if (main->setting.delimit_mode == fss_read_delimit_mode_content_lesser_e) { + main->setting.delimit_mode = fss_read_delimit_mode_content_e; + } + else { + main->setting.delimit_mode = fss_read_delimit_mode_content_object_e; + } } - - fll_program_print_error_parameter_range_start_before_stop( - &main->program.error, - f_console_symbol_long_normal_s, - fss_read_long_ignore_s, - main->program.parameters.arguments.array[main->program.parameters.array[fss_read_parameter_ignore_e].values.array[i - 1]], - main->program.parameters.arguments.array[index] - ); - - return; } - } // while + } + } // for + + // Guarantee the default value is "all". + if (!main->setting.delimit_mode) { + main->setting.delimit_mode = fss_read_delimit_mode_all_e; } } - else if (main->program.parameters.array[fss_read_parameter_ignore_e].result & f_console_result_found_e) { - main->setting.state.status = F_status_set_error(F_parameter); + main->setting.state.status = fss_read_depth_process(main, &data); + + if (F_status_is_error(main->setting.state.status) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_ignore_s); + fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_depth_process)); return; } - else { - - // There is no Object or Content, so remove ignores if set. - if (main->setting.flag & fss_read_main_flag_ignore_e) { - main->setting.flag -= fss_read_main_flag_ignore_e; - } - } - - if (main->program.parameters.array[fss_read_parameter_partial_e].result & f_console_result_found_e) { - main->setting.flag |= fss_read_main_flag_partial_e; - } - - { - const uint32_t has[] = { - fss_read_parameter_content_end_e, - fss_read_parameter_content_next_e, - fss_read_parameter_object_open_e, - }; - - const uint16_t has_flag[] = { - fss_read_main_flag_content_end_e, - fss_read_main_flag_content_next_e, - fss_read_main_flag_object_open_e, - }; - - const f_string_static_t has_string[] = { - fss_read_long_content_end_s, - fss_read_long_content_next_s, - fss_read_long_object_open_s, - }; - - const uint16_t has_cannots[][2] = { - { fss_read_parameter_content_next_e, fss_read_parameter_object_open_e }, - { fss_read_parameter_content_end_e, fss_read_parameter_object_open_e }, - { fss_read_parameter_content_end_e, fss_read_parameter_content_next_e }, - }; - const f_string_static_t has_cannots_string[][2] = { - { fss_read_long_content_next_s, fss_read_long_object_open_s }, - { fss_read_long_content_end_s, fss_read_long_object_open_s }, - { fss_read_long_content_end_s, fss_read_long_content_next_s }, - }; + // @todo: Some standards do not support nesting, so any depth greater than 0 can be predicted without processing the file, this check needs to happen in the program specific settings processing function. + // if (data.depths.array[0].depth) { ... - for (uint8_t i = 0; i < 3; ++i) { - - if (main->program.parameters.array[has[i]].result & f_console_result_found_e) { - if (main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e)) { - if (!(main->setting.flag & fss_read_main_flag_partial_e)) { - main->setting.state.status = F_status_set_error(F_parameter); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error.to); - } - - fll_program_print_error_parameter_cannot_use_with_without( - &main->program.error, - f_console_symbol_long_normal_s, - f_console_symbol_long_normal_s, - f_console_symbol_long_normal_s, - has_string[i], - (main->setting.flag & fss_read_main_flag_object_e) - ? fss_read_long_object_s - : fss_read_long_content_s, - fss_read_long_partial_s - ); - - return; - } - } - - if (main->program.parameters.array[has_cannots[i][0]].result & f_console_result_found_e) { - main->setting.state.status = F_status_set_error(F_parameter); - - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } - - fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, has_string[i], has_cannots_string[i][0]); - - return; - } - - if (main->program.parameters.array[has_cannots[i][1]].result & f_console_result_found_e) { - main->setting.state.status = F_status_set_error(F_parameter); - - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } - - fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, has_string[i], has_cannots_string[i][1]); - - return; - } - - main->setting.flag |= has_flag[i]; - } - } // for - } - - if (main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e)) { - if (main->setting.flag & fss_read_main_flag_object_e) { - if (main->setting.flag & fss_read_main_flag_content_multiple_e) { - if (main->program.parameters.array[fss_read_parameter_object_e].locations_sub.used > main->program.parameters.array[fss_read_parameter_content_e].locations_sub.used && !(main->setting.flag & fss_read_main_flag_partial_e)) { - main->setting.state.status = F_status_set_error(F_parameter); - - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } - - fss_read_print_error_parameter_same_times_at_least(&main->program.error); - - return; - } - } - - if ((main->setting.flag & fss_read_main_flag_content_e) && (main->setting.flag & fss_read_main_flag_partial_e)) { - if (main->program.parameters.array[fss_read_parameter_content_e].result & f_console_result_value_e) { - main->setting.state.status = F_status_set_error(F_parameter); - - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } - - fll_program_print_error_parameter_cannot_use_with_xor(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_read_long_partial_s, fss_read_long_object_s, fss_read_long_content_s); + if (main->parameters.array[fss_read_parameter_select_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - return; - } - } + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - } - - main->setting.quote = f_fss_quote_double_s; - if (main->program.parameters.array[fss_read_parameter_double_e].result & f_console_result_found_e) { - if (main->program.parameters.array[fss_read_parameter_single_e].result & f_console_result_found_e) { - if (main->program.parameters.array[fss_read_parameter_double_e].location < main->program.parameters.array[fss_read_parameter_single_e].location) { - main->setting.quote = f_fss_quote_single_s; - - if (main->program.parameters.array[fss_read_parameter_backtick_e].result & f_console_result_found_e) { - if (main->program.parameters.array[fss_read_parameter_single_e].location < main->program.parameters.array[fss_read_parameter_backtick_e].location) { - main->setting.quote = f_fss_quote_backtick_s; - } - } - } - else if (main->program.parameters.array[fss_read_parameter_backtick_e].result & f_console_result_found_e) { - if (main->program.parameters.array[fss_read_parameter_double_e].location < main->program.parameters.array[fss_read_parameter_backtick_e].location) { - main->setting.quote = f_fss_quote_backtick_s; - } - } - } - else if (main->program.parameters.array[fss_read_parameter_backtick_e].result & f_console_result_found_e) { - if (main->program.parameters.array[fss_read_parameter_double_e].location < main->program.parameters.array[fss_read_parameter_backtick_e].location) { - main->setting.quote = f_fss_quote_backtick_s; - } - } - } - else if (main->program.parameters.array[fss_read_parameter_single_e].result & f_console_result_found_e) { - main->setting.quote = f_fss_quote_single_s; + fll_program_print_error_parameter_integer_not_positive(&main->error, f_console_symbol_long_normal_s, fss_read_long_select_s); - if (main->program.parameters.array[fss_read_parameter_backtick_e].result & f_console_result_found_e) { - if (main->program.parameters.array[fss_read_parameter_single_e].location < main->program.parameters.array[fss_read_parameter_backtick_e].location) { - main->setting.quote = f_fss_quote_backtick_s; - } - } - } - else if (main->program.parameters.array[fss_read_parameter_backtick_e].result & f_console_result_found_e) { - main->setting.quote = f_fss_quote_backtick_s; + return; } if (main->program.parameters.array[fss_read_parameter_trim_e].result & f_console_result_found_e) { main->setting.flag |= fss_read_main_flag_trim_e; } + // @fixme this is from fss_write, but doing some sort of file check, such as no pipe and no files may be a good idea here. Replace this with such logic if deemed desirable. if (!(main->setting.flag & (fll_program_data_pipe_input_e | fss_read_main_flag_content_e | fss_read_parameter_object_e))) { main->setting.state.status = F_data_not; } diff --git a/level_3/fss_read/c/main/common.h b/level_3/fss_read/c/main/common.h index c7324e0..d2188fe 100644 --- a/level_3/fss_read/c/main/common.h +++ b/level_3/fss_read/c/main/common.h @@ -27,10 +27,10 @@ extern "C" { * 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: + * This alters main.setting.range. + * + * This alters main.setting.state.status: * F_none on success. * F_data_not on success but nothing was provided to operate with. * diff --git a/level_3/fss_read/c/main/common/enumeration.h b/level_3/fss_read/c/main/common/enumeration.h index 8d93568..034dbb3 100644 --- a/level_3/fss_read/c/main/common/enumeration.h +++ b/level_3/fss_read/c/main/common/enumeration.h @@ -21,20 +21,40 @@ extern "C" { * * fss_read_main_flag_*_e: * - none: No flags set. + * - at: The object at the given position is being selected (Think of this as select a row for some Object). + * - columns: The total columns found and selected is printed instead of the Content. + * - content: The Content is to be printed. * - copyright: Print copyright. + * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). * - help: Print help. + * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). + * - name: A specific Object name has been requested. + * - object: The Object is to be printed. + * - original: Enable original printing, where the quotes are printed and no delimits are applied. * - print_first: When set, print new line to message output on program begin after loading settings. * - print_last: When set, print new line to message output on program end. - * - trim: Trim Object names. + * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). + * - total: The total lines found and selected is printed instead of the Content. + * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). * - version: Print version. */ #ifndef _di_fss_read_main_flag_e_ enum { fss_read_main_flag_none_e = 0x0, - fss_read_main_flag_copyright_e = 0x10, - fss_read_main_flag_help_e = 0x40, - fss_read_main_flag_print_first_e = 0x1000, - fss_read_main_flag_print_last_e = 0x2000, + fss_read_main_flag_at_d = 0x1, + fss_read_main_flag_columns_d = 0x2, + fss_read_main_flag_content_d = 0x4, + fss_read_main_flag_copyright_e = 0x8, + fss_read_main_flag_empty_d = 0x10, + fss_read_main_flag_help_e = 0x20, + fss_read_main_flag_line_d = 0x40, + fss_read_main_flag_name_d = 0x80, + fss_read_main_flag_object_d = 0x100, + fss_read_main_flag_original_d = 0x200, + fss_read_main_flag_print_first_e = 0x400, + fss_read_main_flag_print_last_e = 0x800, + fss_read_main_flag_select_d = 0x1000, + fss_read_main_flag_total_d = 0x2000, fss_read_main_flag_trim_e = 0x4000, fss_read_main_flag_version_e = 0x8000, }; // enum @@ -127,6 +147,8 @@ extern "C" { * FSS Delimit Parameter enumerations. * * fss_read_delimit_mode_*_e: + * - auto: Delimit mode is automatically set. + * - none: Delimit mode is set to none. * - all: All delimits are to be applied. * - content: Content are to have delimits applied. * - content_greater: Content at this number or higher are to have delimits applied. @@ -138,7 +160,8 @@ extern "C" { */ #ifndef _di_fss_read_delimit_mode_e_ enum { - fss_read_delimit_mode_none_e = 0, + fss_read_delimit_mode_auto_e = 0, + fss_read_delimit_mode_none_e, fss_read_delimit_mode_all_e, fss_read_delimit_mode_content_e, fss_read_delimit_mode_content_greater_e, diff --git a/level_3/fss_read/c/main/common/print.c b/level_3/fss_read/c/main/common/print.c index 65862b9..5b0dc16 100644 --- a/level_3/fss_read/c/main/common/print.c +++ b/level_3/fss_read/c/main/common/print.c @@ -24,6 +24,7 @@ extern "C" { "f_string_rangess_increase_by", "f_string_read_block_increase", "f_thread_create", + "fl_conversion_dynamic_partial_to_unsigned_detect", "fl_fss_basic_content_read", "fl_fss_basic_list_content_read", "fl_fss_basic_list_object_read", @@ -38,6 +39,7 @@ extern "C" { "fll_program_parameter_process_context", "fll_program_parameter_process_verbosity", "fll_fss_payload_read", + "fss_read_depth_process", }; #endif // _di_fss_read_f_a_ diff --git a/level_3/fss_read/c/main/common/print.h b/level_3/fss_read/c/main/common/print.h index f55bb14..7c63948 100644 --- a/level_3/fss_read/c/main/common/print.h +++ b/level_3/fss_read/c/main/common/print.h @@ -57,6 +57,7 @@ extern "C" { fss_read_f_f_string_rangess_increase_by_e, fss_read_f_f_string_read_block_increase_e, fss_read_f_f_thread_create_e, + fss_read_f_fl_conversion_dynamic_partial_to_unsigned_detect_e, fss_read_f_fl_fss_basic_content_read_e, fss_read_f_fl_fss_basic_list_content_read_e, fss_read_f_fl_fss_basic_list_object_read_e, @@ -71,6 +72,7 @@ extern "C" { fss_read_f_fll_program_parameter_process_context_e, fss_read_f_fll_program_parameter_process_verbosity_e, fss_read_f_fll_fss_payload_read_e, + fss_rerad_f_fss_read_depth_process_e, }; // enum #endif // _di_fss_read_f_e_ diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index dcecf1c..5f3af40 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -17,6 +17,47 @@ extern "C" { #endif /** + * A structure for designating where within the buffer a particular file exists, using a statically allocated array. + * + * name: The name of the file representing the range. + * range: A range within the buffer representing the file. + */ +#ifndef _di_fss_read_file_t_ + typedef struct { + f_string_static_t name; + f_string_range_t range; + } fss_read_file_t; + + #define fss_read_file_t_initialize \ + { \ + f_string_static_t_initialize, \ + f_string_range_t_initialize, \ + } +#endif // _di_fss_read_file_t_ + +/** + * An array of files. + * + * This is intended to be defined and used statically allocated and as such no dynamic allocation or dynamic deallocation methods are provided. + * + * The STDIN pipe is reserved for index 0 and as such the first index must be reserved and the used should be set to at least 1. + * + * array: The array of depths. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_fss_read_files_t_ + typedef struct { + fss_read_file_t *array; + + f_array_length_t size; + f_array_length_t used; + } fss_read_files_t; + + #define fss_read_files_t_initialize { 0, 0, 0 } +#endif // _di_fss_read_files_t_ + +/** * The fss read main program settings. * * This is passed to the program-specific main entry point to designate program settings. @@ -24,28 +65,29 @@ extern "C" { * * For all function pointers on this structure, the main variable must be of type fss_read_main_t. * - * flag: Flags passed to the main function. + * flag: Flags passed to the main function. + * delimit_mode: The delimit mode. * * status_thread: A status used eclusively by the threaded signal handler. * state: The state data used when processing the FSS data. * - * range: A range used as a buffer during processing. + * delimit_depth: The delimit depth. + * select: The Content to select (column number). + * line: The Content to select (row number). * - * quote: This holds the quote used during processing. - * standard: A human-friendly string describing the standard in use, such as "FSS-0000 (Basic)". + * range: A range used in conjunction with some buffer during processing. * - * escaped: A buffer used for escaping strings during processing. - * block: A buffer used to storing one or more blocks while processing a file line by line. - * buffer: A buffer used during processing the file. - * prepend: A string to prepend to each multi-line Content. + * files: A statically allocated array of files for designating where in the buffer a file is represented. + * depths: The array of parameters for each given depth. * - * ignoress: An array of range sets passed as values to the "--ignore" parameter or via the input pipe. - * objects: An array of objects passed as values to the "--object" parameter or via the input pipe. - * contentss: An array of content sets passed as values to the "--content" parameter or via the input pipe. + * standard: A human-friendly string describing the standard in use, such as "FSS-0000 (Basic)". + * buffer: The buffer containing all loaded files (and STDIN pipe). * - * object: A pointer to a specific Object used during processing. - * content: A pointer to a specific Content used during processing. - * contents: A pointer to a specific set of Content used during processing. + * objects: The positions within the buffer representing Objects. + * contents: The positions within the buffer representing Contents. + * delimits_object: The positions within the buffer representing Object character delimits. + * delimits_content: The positions within the buffer representing Content character delimits. + * comments: The positions within the buffer representing comments. * * process_content: Process a single Content. * process_help: Process help (generally printing help). @@ -57,28 +99,28 @@ extern "C" { #ifndef _di_fss_read_setting_t_ typedef struct { uint16_t flag; + uint8_t delimit_mode; f_status_t status_thread; f_state_t state; + f_array_length_t delimit_depth; + f_number_unsigned_t select; + f_number_unsigned_t line; + f_string_range_t range; - f_string_static_t quote; - f_string_static_t standard; + fss_read_files_t files; + fss_read_depths_t depths; - f_string_dynamic_t escaped; - f_string_dynamic_t block; + f_string_static_t standard; f_string_dynamic_t buffer; - f_string_dynamic_t prepend; - - f_string_rangess_t ignoress; - f_string_dynamics_t objects; - f_string_dynamicss_t contentss; - f_string_ranges_t *ignores; - f_string_static_t *object; - f_string_static_t *content; - f_string_statics_t *contents; + f_fss_objects_t objects; + f_fss_contents_t contents; + f_fss_delimits_t delimits_object; + f_fss_delimits_t delimits_content; + f_fss_comments_t comments; void (*process_content)(void * const main, const bool last); void (*process_help)(void * const main); @@ -91,22 +133,22 @@ extern "C" { #define fss_read_setting_t_initialize \ { \ fss_read_main_flag_none_e, \ + fss_read_delimit_mode_all_e, \ F_none, \ macro_f_state_t_initialize_1(fss_read_allocation_large_d, fss_read_allocation_small_d, F_none, 0, 0, &fll_program_standard_signal_handle, 0, 0, 0, 0), \ - f_string_range_t_initialize, \ - f_string_static_t_initialize, \ - f_string_static_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_rangess_t_initialize, \ - f_string_dynamics_t_initialize, \ - f_string_dynamicss_t_initialize, \ - 0, \ 0, \ 0, \ 0, \ + f_string_range_t_initialize, \ + fss_read_files_t_initialize, \ + fss_read_depths_t_initialize, \ + f_string_static_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_fss_objects_t_initialize, \ + f_fss_contents_t_initialize, \ + f_fss_delimits_t_initialize, \ + f_fss_delimits_t_initialize, \ + f_fss_comments_t_initialize, \ 0, \ 0, \ 0, \ diff --git a/level_3/fss_read/c/main/print/error.c b/level_3/fss_read/c/main/print/error.c index 9333887..024bf13 100644 --- a/level_3/fss_read/c/main/print/error.c +++ b/level_3/fss_read/c/main/print/error.c @@ -50,6 +50,24 @@ extern "C" { } #endif // _di_fss_read_print_error_parameter_same_times_at_least_ +#ifndef _di_fss_read_print_error_parameter_requires_message_ + f_status_t fss_read_print_error_parameter_requires_message(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_string_static_t message) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe parameter '%]", print->to, print->context, print->prefix, print->context); + fl_print_format("%[%r%r%]", print->to, print->notable, symbol, name, print->notable); + fl_print_format("%[' requires %s.%]%r", print->to, print->context, message, print->context, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_print_error_parameter_requires_message_ + #ifndef _di_fss_read_print_error_one_content_only_ f_status_t fss_read_print_error_one_content_only(fl_print_t * const print) { diff --git a/level_3/fss_read/c/main/print/error.h b/level_3/fss_read/c/main/print/error.h index e823560..1d1e115 100644 --- a/level_3/fss_read/c/main/print/error.h +++ b/level_3/fss_read/c/main/print/error.h @@ -86,6 +86,25 @@ extern "C" { #endif // _di_fss_read_print_error_parameter_same_times_at_least_ /** + * Print an error message about the parameter requires something that is explained by the message parameter. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * @param symbol + * The symbol string prepended to the first parameter. + * This is usually f_console_symbol_long_normal_s. + * @param name + * The parameter name. + * @param message + * The message to print regarding why the message should be displayed. + */ +#ifndef _di_fss_read_print_error_parameter_requires_message_ + extern f_status_t fss_read_print_error_parameter_requires_message(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_string_static_t message); +#endif // _di_fss_read_print_error_parameter_requires_message_ + +/** * Print an message about a multiple Content being unsupported for a particular standard. * * @param print diff --git a/level_3/fss_write/c/main/common.c b/level_3/fss_write/c/main/common.c index c4e3396..26e2484 100644 --- a/level_3/fss_write/c/main/common.c +++ b/level_3/fss_write/c/main/common.c @@ -49,7 +49,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -70,7 +70,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); @@ -569,13 +569,13 @@ extern "C" { } { - const uint32_t has[] = { + static const uint32_t has[] = { fss_write_parameter_content_end_e, fss_write_parameter_content_next_e, fss_write_parameter_object_open_e, }; - const uint16_t has_flag[] = { + static const uint16_t has_flag[] = { fss_write_main_flag_content_end_e, fss_write_main_flag_content_next_e, fss_write_main_flag_object_open_e, @@ -587,7 +587,7 @@ extern "C" { fss_write_long_object_open_s, }; - const uint16_t has_cannots[][2] = { + static const uint16_t has_cannots[][2] = { { fss_write_parameter_content_next_e, fss_write_parameter_object_open_e }, { fss_write_parameter_content_end_e, fss_write_parameter_object_open_e }, { fss_write_parameter_content_end_e, fss_write_parameter_content_next_e }, diff --git a/level_3/fss_write/c/main/common/type.h b/level_3/fss_write/c/main/common/type.h index 2985fea..4a290bd 100644 --- a/level_3/fss_write/c/main/common/type.h +++ b/level_3/fss_write/c/main/common/type.h @@ -29,7 +29,7 @@ extern "C" { * status_thread: A status used eclusively by the threaded signal handler. * state: The state data used when processing the FSS data. * - * range: A range used as a buffer during processing. + * range: A range used in conjunction with some buffer during processing. * * quote: This holds the quote used during processing. * standard: A human-friendly string describing the standard in use, such as "FSS-0000 (Basic)". diff --git a/level_3/iki_read/c/main/common.c b/level_3/iki_read/c/main/common.c index 988f847..29aa088 100644 --- a/level_3/iki_read/c/main/common.c +++ b/level_3/iki_read/c/main/common.c @@ -49,7 +49,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -70,7 +70,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); @@ -447,7 +447,7 @@ extern "C" { } if (main->program.parameters.array[iki_read_parameter_literal_e].result & f_console_result_found_e) { - const uint8_t ids[3] = { + static const uint8_t ids[3] = { iki_read_parameter_object_e, iki_read_parameter_content_e, iki_read_parameter_total_e, @@ -477,7 +477,7 @@ extern "C" { main->setting.flag |= iki_read_main_flag_literal_e; } else if (main->program.parameters.array[iki_read_parameter_object_e].result & f_console_result_found_e) { - const uint8_t ids[2] = { + static const uint8_t ids[2] = { iki_read_parameter_content_e, iki_read_parameter_total_e, }; diff --git a/level_3/iki_write/c/main/common.c b/level_3/iki_write/c/main/common.c index c6d7c03..cd0fc22 100644 --- a/level_3/iki_write/c/main/common.c +++ b/level_3/iki_write/c/main/common.c @@ -49,7 +49,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -70,7 +70,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/status_code/c/main/common.c b/level_3/status_code/c/main/common.c index c205e09..e3fae1a 100644 --- a/level_3/status_code/c/main/common.c +++ b/level_3/status_code/c/main/common.c @@ -49,7 +49,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -70,7 +70,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); diff --git a/level_3/utf8/c/main/common.c b/level_3/utf8/c/main/common.c index 371d799..f2aad01 100644 --- a/level_3/utf8/c/main/common.c +++ b/level_3/utf8/c/main/common.c @@ -50,7 +50,7 @@ extern "C" { choices.array = choices_array; choices.used = 3; - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); @@ -71,7 +71,7 @@ extern "C" { choices.array = choices_array; choices.used = 5; - 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 }; + static 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 }; main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); -- 1.8.3.1