From f3f5caf43dd58fbef0a3f08d7e12f222e9d2b5f3 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 13 Feb 2025 22:01:26 -0600 Subject: [PATCH] Update: Use f_console_parameters_t as a pointer and document fll_program_parameter_process_context_standard(). Make the use of `f_console_parameters_t` as a pointer for consistency purposes. Some programs did this whereas other programs repeatedly called `main->program.parameters`. This should no longer be the case. The documentation comments should be referencing `fll_program_parameter_process_context_standard()` and now do. --- level_3/byte_dump/c/main/common.c | 56 +++++++------ level_3/example/c/main/common.c | 10 ++- level_3/example/c/main/common.h | 4 +- level_3/fake/c/main/common.h | 4 +- level_3/firewall/c/main/common.c | 56 +++++++------ level_3/firewall/c/main/common.h | 4 +- level_3/fss_identify/c/main/common.c | 50 ++++++------ level_3/fss_identify/c/main/common.h | 4 +- level_3/fss_read/c/main/common.c | 4 +- level_3/fss_read/c/main/common.h | 4 +- level_3/fss_read/c/main/main.c | 32 ++++---- level_3/fss_read/c/main/main.h | 4 +- level_3/fss_write/c/main/common.c | 154 ++++++++++++++++++----------------- level_3/fss_write/c/main/common.h | 4 +- level_3/fss_write/c/main/main.h | 10 --- level_3/iki_read/c/iki/main.c | 1 + level_3/iki_read/c/main/common.c | 4 +- level_3/iki_read/c/main/common.h | 4 +- level_3/iki_write/c/main/common.c | 6 +- level_3/iki_write/c/main/common.h | 4 +- level_3/status_code/c/main/common.c | 20 +++-- level_3/status_code/c/main/common.h | 4 +- level_3/utf8/c/main/common.c | 78 +++++++++--------- level_3/utf8/c/main/common.h | 4 +- 24 files changed, 266 insertions(+), 259 deletions(-) diff --git a/level_3/byte_dump/c/main/common.c b/level_3/byte_dump/c/main/common.c index 95d261d..28cc60b 100644 --- a/level_3/byte_dump/c/main/common.c +++ b/level_3/byte_dump/c/main/common.c @@ -9,9 +9,11 @@ extern "C" { if (!main) return; + f_console_parameters_t * const parameters = &main->program.parameters; + main->setting.state.step_small = byte_dump_allocation_console_d; - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); + f_console_parameter_process(arguments, parameters, &main->setting.state, 0); main->setting.state.step_small = byte_dump_allocation_small_d; @@ -123,19 +125,19 @@ extern "C" { } } - if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { main->setting.flag |= byte_dump_main_flag_help_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { main->setting.flag |= byte_dump_main_flag_version_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { main->setting.flag |= byte_dump_main_flag_copyright_d; return; @@ -151,10 +153,10 @@ extern "C" { main->setting.flag &= ~byte_dump_main_flag_pipe_d; } - if (main->program.parameters.array[byte_dump_parameter_width_e].result & f_console_result_value_e) { - index = main->program.parameters.array[byte_dump_parameter_width_e].values.array[main->program.parameters.array[byte_dump_parameter_width_e].values.used - 1]; + if (parameters->array[byte_dump_parameter_width_e].result & f_console_result_value_e) { + index = parameters->array[byte_dump_parameter_width_e].values.array[parameters->array[byte_dump_parameter_width_e].values.used - 1]; - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &number); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], &number); // Negative numbers are not supported. if (main->setting.state.status == F_number_negative) { @@ -162,14 +164,14 @@ extern "C" { } if (F_status_is_error(main->setting.state.status) || number < 0x1 || number >= 0xfb) { - byte_dump_print_error_parameter_range_out(&main->program.error, byte_dump_long_width_s, 1, 250, main->program.parameters.arguments.array[index]); + byte_dump_print_error_parameter_range_out(&main->program.error, byte_dump_long_width_s, 1, 250, parameters->arguments.array[index]); return; } main->setting.width = (uint8_t) number; } - else if (main->program.parameters.array[byte_dump_parameter_width_e].result & f_console_result_found_e) { + else if (parameters->array[byte_dump_parameter_width_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, byte_dump_long_width_s); @@ -200,10 +202,10 @@ extern "C" { for (uint8_t i = 0; i < 2; ++i) { - if (main->program.parameters.array[indexs[i]].result & f_console_result_value_e) { - index = main->program.parameters.array[indexs[i]].values.array[main->program.parameters.array[indexs[i]].values.used - 1]; + if (parameters->array[indexs[i]].result & f_console_result_value_e) { + index = parameters->array[indexs[i]].values.array[parameters->array[indexs[i]].values.used - 1]; - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &number); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], &number); // Negative numbers are not supported. if (main->setting.state.status == F_number_negative) { @@ -211,7 +213,7 @@ extern "C" { } if (F_status_is_error(main->setting.state.status)) { - byte_dump_print_error_parameter_range_out(&main->program.error, names[i], 0, F_number_t_size_unsigned_d, main->program.parameters.arguments.array[index]); + byte_dump_print_error_parameter_range_out(&main->program.error, names[i], 0, F_number_t_size_unsigned_d, parameters->arguments.array[index]); return; } @@ -219,7 +221,7 @@ extern "C" { *values[i] = number; main->setting.flag |= flags[i]; } - else if (main->program.parameters.array[indexs[i]].result & f_console_result_found_e) { + else if (parameters->array[indexs[i]].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, names[i]); @@ -245,36 +247,36 @@ extern "C" { } } - if (main->program.parameters.array[byte_dump_parameter_text_e].result & f_console_result_found_e) { + if (parameters->array[byte_dump_parameter_text_e].result & f_console_result_found_e) { main->setting.flag |= byte_dump_main_flag_text_d; } else { main->setting.flag &= ~byte_dump_main_flag_text_d; } - if (main->program.parameters.array[byte_dump_parameter_unicode_e].result & f_console_result_found_e) { + if (parameters->array[byte_dump_parameter_unicode_e].result & f_console_result_found_e) { main->setting.flag |= byte_dump_main_flag_unicode_d; } else { main->setting.flag &= ~byte_dump_main_flag_unicode_d; } - if (main->program.parameters.array[byte_dump_parameter_placeholder_e].result & f_console_result_found_e) { + if (parameters->array[byte_dump_parameter_placeholder_e].result & f_console_result_found_e) { main->setting.flag |= byte_dump_main_flag_placeholder_d; } else { main->setting.flag &= ~byte_dump_main_flag_placeholder_d; } - if (main->program.parameters.array[byte_dump_parameter_classic_e].result & f_console_result_found_e) { + if (parameters->array[byte_dump_parameter_classic_e].result & f_console_result_found_e) { main->setting.flag |= byte_dump_main_flag_classic_d; } else { main->setting.flag &= ~byte_dump_main_flag_classic_d; } - if (main->program.parameters.remaining.used) { - main->setting.state.status = f_memory_array_increase_by(main->program.parameters.remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.files.array, &main->setting.files.used, &main->setting.files.size); + if (parameters->remaining.used) { + main->setting.state.status = f_memory_array_increase_by(parameters->remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.files.array, &main->setting.files.used, &main->setting.files.size); if (F_status_is_error(main->setting.state.status)) { byte_dump_print_error(&main->program.error, macro_byte_dump_f(f_memory_array_increase_by)); @@ -284,20 +286,20 @@ extern "C" { f_status_t status_files = F_okay; - for (index = 0; index < main->program.parameters.remaining.used; ++index) { + for (index = 0; index < parameters->remaining.used; ++index) { if (byte_dump_signal_check(main)) return; - number = main->program.parameters.remaining.array[index]; + number = parameters->remaining.array[index]; - if (!main->program.parameters.arguments.array[number].used) continue; + if (!parameters->arguments.array[number].used) continue; // Statically allocate the inner strings. - main->setting.files.array[main->setting.files.used].string = main->program.parameters.arguments.array[number].string; - main->setting.files.array[main->setting.files.used].used = main->program.parameters.arguments.array[number].used; + main->setting.files.array[main->setting.files.used].string = parameters->arguments.array[number].string; + main->setting.files.array[main->setting.files.used].used = parameters->arguments.array[number].used; main->setting.files.array[main->setting.files.used++].size = 0; - main->setting.state.status = f_file_exists(main->program.parameters.arguments.array[number], F_true); + main->setting.state.status = f_file_exists(parameters->arguments.array[number], F_true); if (main->setting.state.status == F_false) { main->setting.state.status = F_status_set_error(F_file_found_not); @@ -308,7 +310,7 @@ extern "C" { status_files = main->setting.state.status; } - byte_dump_print_error_file(&main->program.error, macro_byte_dump_f(f_file_exists), main->program.parameters.arguments.array[number], f_file_operation_find_s, fll_error_file_type_file_e); + byte_dump_print_error_file(&main->program.error, macro_byte_dump_f(f_file_exists), parameters->arguments.array[number], f_file_operation_find_s, fll_error_file_type_file_e); } } // for diff --git a/level_3/example/c/main/common.c b/level_3/example/c/main/common.c index f2c9313..9044499 100644 --- a/level_3/example/c/main/common.c +++ b/level_3/example/c/main/common.c @@ -9,9 +9,11 @@ extern "C" { if (!main) return; + f_console_parameters_t * const parameters = &main->program.parameters; + main->setting.state.step_small = example_allocation_console_d; - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); + f_console_parameter_process(arguments, parameters, &main->setting.state, 0); main->setting.state.step_small = example_allocation_small_d; @@ -37,19 +39,19 @@ extern "C" { return; } - if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { main->setting.flag |= example_main_flag_help_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { main->setting.flag |= example_main_flag_version_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { main->setting.flag |= example_main_flag_copyright_d; return; diff --git a/level_3/example/c/main/common.h b/level_3/example/c/main/common.h index 0dfd7f7..83eeead 100644 --- a/level_3/example/c/main/common.h +++ b/level_3/example/c/main/common.h @@ -32,10 +32,10 @@ extern "C" { * F_okay on success. * * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_context_standard(). * * @see f_console_parameter_process() - * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_context_standard() */ #ifndef _di_example_setting_load_ extern void example_setting_load(const f_console_arguments_t arguments, example_main_t * const main); diff --git a/level_3/fake/c/main/common.h b/level_3/fake/c/main/common.h index a8683ee..be07ce7 100644 --- a/level_3/fake/c/main/common.h +++ b/level_3/fake/c/main/common.h @@ -35,7 +35,7 @@ extern "C" { * Errors (with error bit) from: f_path_directory_cleanup(). * Errors (with error bit) from: f_utf_is_word_dash_plus(). * Errors (with error bit) from: fll_program_parameter_additional_rip(). - * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_context_standard(). * Errors (with error bit) from: fll_program_parameter_process_verbosity_standard(). * * @see f_console_parameter_process() @@ -44,7 +44,7 @@ extern "C" { * @see f_path_directory_cleanup() * @see f_utf_is_word_dash_plus() * @see fll_program_parameter_additional_rip() - * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_context_standard() * @see fll_program_parameter_process_verbosity_standard() */ #ifndef _di_fake_setting_load_ diff --git a/level_3/firewall/c/main/common.c b/level_3/firewall/c/main/common.c index a66e89d..a1adf47 100644 --- a/level_3/firewall/c/main/common.c +++ b/level_3/firewall/c/main/common.c @@ -9,9 +9,11 @@ extern "C" { if (!main) return; + f_console_parameters_t * const parameters = &main->program.parameters; + main->setting.state.step_small = firewall_allocation_console_d; - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); + f_console_parameter_process(arguments, parameters, &main->setting.state, 0); main->setting.state.step_small = firewall_allocation_small_d; @@ -37,19 +39,19 @@ extern "C" { return; } - if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { main->setting.flag |= firewall_main_flag_help_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { main->setting.flag |= firewall_main_flag_version_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { main->setting.flag |= firewall_main_flag_copyright_d; return; @@ -57,49 +59,49 @@ extern "C" { f_number_unsigned_t index = 0; - if (main->program.parameters.array[firewall_parameter_operation_start_e].result & f_console_result_found_e) { + if (parameters->array[firewall_parameter_operation_start_e].result & f_console_result_found_e) { main->setting.flag &= ~firewall_main_flag_operation_d; main->setting.flag |= firewall_main_flag_operation_start_d; - index = main->program.parameters.array[firewall_parameter_operation_start_e].location; + index = parameters->array[firewall_parameter_operation_start_e].location; } - if (main->program.parameters.array[firewall_parameter_operation_stop_e].result & f_console_result_found_e) { - if (!(main->setting.flag & firewall_main_flag_operation_d) || main->program.parameters.array[firewall_parameter_operation_stop_e].location > index) { + if (parameters->array[firewall_parameter_operation_stop_e].result & f_console_result_found_e) { + if (!(main->setting.flag & firewall_main_flag_operation_d) || parameters->array[firewall_parameter_operation_stop_e].location > index) { main->setting.flag &= ~firewall_main_flag_operation_d; main->setting.flag |= firewall_main_flag_operation_stop_d; - index = main->program.parameters.array[firewall_parameter_operation_stop_e].location; + index = parameters->array[firewall_parameter_operation_stop_e].location; } } - if (main->program.parameters.array[firewall_parameter_operation_restart_e].result & f_console_result_found_e) { - if (!(main->setting.flag & firewall_main_flag_operation_d) || main->program.parameters.array[firewall_parameter_operation_restart_e].location > index) { + if (parameters->array[firewall_parameter_operation_restart_e].result & f_console_result_found_e) { + if (!(main->setting.flag & firewall_main_flag_operation_d) || parameters->array[firewall_parameter_operation_restart_e].location > index) { main->setting.flag &= ~firewall_main_flag_operation_d; main->setting.flag |= firewall_main_flag_operation_restart_d; - index = main->program.parameters.array[firewall_parameter_operation_restart_e].location; + index = parameters->array[firewall_parameter_operation_restart_e].location; } } - if (main->program.parameters.array[firewall_parameter_operation_lock_e].result & f_console_result_found_e) { - if (!(main->setting.flag & firewall_main_flag_operation_d) || main->program.parameters.array[firewall_parameter_operation_lock_e].location > index) { + if (parameters->array[firewall_parameter_operation_lock_e].result & f_console_result_found_e) { + if (!(main->setting.flag & firewall_main_flag_operation_d) || parameters->array[firewall_parameter_operation_lock_e].location > index) { main->setting.flag &= ~firewall_main_flag_operation_d; main->setting.flag |= firewall_main_flag_operation_lock_d; - index = main->program.parameters.array[firewall_parameter_operation_lock_e].location; + index = parameters->array[firewall_parameter_operation_lock_e].location; } } - if (main->program.parameters.array[firewall_parameter_operation_show_e].result & f_console_result_found_e) { - if (!(main->setting.flag & firewall_main_flag_operation_d) || main->program.parameters.array[firewall_parameter_operation_show_e].location > index) { + if (parameters->array[firewall_parameter_operation_show_e].result & f_console_result_found_e) { + if (!(main->setting.flag & firewall_main_flag_operation_d) || parameters->array[firewall_parameter_operation_show_e].location > index) { main->setting.flag &= ~firewall_main_flag_operation_d; main->setting.flag |= firewall_main_flag_operation_show_d; } } - if (main->program.parameters.array[firewall_parameter_4_e].result & f_console_result_found_e) { - if (main->program.parameters.array[firewall_parameter_6_e].result & f_console_result_found_e) { + if (parameters->array[firewall_parameter_4_e].result & f_console_result_found_e) { + if (parameters->array[firewall_parameter_6_e].result & f_console_result_found_e) { main->setting.flag |= firewall_main_flag_ipv46_d; } else { @@ -107,7 +109,7 @@ extern "C" { main->setting.flag |= firewall_main_flag_ipv4_d; } } - else if (main->program.parameters.array[firewall_parameter_6_e].result & f_console_result_found_e) { + else if (parameters->array[firewall_parameter_6_e].result & f_console_result_found_e) { main->setting.flag &= ~firewall_main_flag_ipv4_d; main->setting.flag |= firewall_main_flag_ipv6_d; } @@ -120,26 +122,26 @@ extern "C" { } if (main->setting.flag & firewall_main_flag_operation_show_d) { - if (main->program.parameters.remaining.used) { + if (parameters->remaining.used) { main->setting.flag &= ~firewall_main_flag_operation_show_filter_nat_mangle_d; - for (f_number_unsigned_t i = 0; i < main->program.parameters.remaining.used; ++i) { + for (f_number_unsigned_t i = 0; i < parameters->remaining.used; ++i) { if (firewall_signal_check(main)) return; - index = main->program.parameters.remaining.array[i]; + index = parameters->remaining.array[i]; - if (f_compare_dynamic(firewall_show_nat_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + if (f_compare_dynamic(firewall_show_nat_s, parameters->arguments.array[index]) == F_equal_to) { main->setting.flag |= firewall_main_flag_operation_show_nat_d; } - else if (f_compare_dynamic(firewall_show_mangle_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + else if (f_compare_dynamic(firewall_show_mangle_s, parameters->arguments.array[index]) == F_equal_to) { main->setting.flag |= firewall_main_flag_operation_show_mangle_d; } - else if (f_compare_dynamic(firewall_show_filter_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + else if (f_compare_dynamic(firewall_show_filter_s, parameters->arguments.array[index]) == F_equal_to) { main->setting.flag |= firewall_main_flag_operation_show_filter_d; } else { - firewall_print_warning_show_option_unknown(&main->program.warning, main->program.parameters.arguments.array[index]); + firewall_print_warning_show_option_unknown(&main->program.warning, parameters->arguments.array[index]); } } // for } diff --git a/level_3/firewall/c/main/common.h b/level_3/firewall/c/main/common.h index f262d22..27df97d 100644 --- a/level_3/firewall/c/main/common.h +++ b/level_3/firewall/c/main/common.h @@ -32,10 +32,10 @@ extern "C" { * F_okay on success. * * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_context_standard(). * * @see f_console_parameter_process() - * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_context_standard() */ #ifndef _di_firewall_setting_load_ extern void firewall_setting_load(const f_console_arguments_t arguments, firewall_main_t * const main); diff --git a/level_3/fss_identify/c/main/common.c b/level_3/fss_identify/c/main/common.c index 67fd430..06b5029 100644 --- a/level_3/fss_identify/c/main/common.c +++ b/level_3/fss_identify/c/main/common.c @@ -9,9 +9,11 @@ extern "C" { if (!main) return; + f_console_parameters_t * const parameters = &main->program.parameters; + main->setting.state.step_small = fss_identify_allocation_console_d; - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); + f_console_parameter_process(arguments, parameters, &main->setting.state, 0); main->setting.state.step_small = fss_identify_allocation_small_d; @@ -37,19 +39,19 @@ extern "C" { return; } - if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { main->setting.flag |= fss_identify_main_flag_help_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { main->setting.flag |= fss_identify_main_flag_version_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { main->setting.flag |= fss_identify_main_flag_copyright_d; return; @@ -57,31 +59,31 @@ extern "C" { f_number_unsigned_t index = 0; - if (main->program.parameters.array[fss_identify_parameter_content_e].result & f_console_result_found_e) { + if (parameters->array[fss_identify_parameter_content_e].result & f_console_result_found_e) { main->setting.flag |= fss_identify_main_flag_content_d; } else { main->setting.flag &= ~fss_identify_main_flag_content_d; } - if (main->program.parameters.array[fss_identify_parameter_object_e].result & f_console_result_found_e) { + if (parameters->array[fss_identify_parameter_object_e].result & f_console_result_found_e) { main->setting.flag |= fss_identify_main_flag_object_d; } else { main->setting.flag &= ~fss_identify_main_flag_object_d; } - if (main->program.parameters.array[fss_identify_parameter_total_e].result & f_console_result_found_e) { + if (parameters->array[fss_identify_parameter_total_e].result & f_console_result_found_e) { main->setting.flag |= fss_identify_main_flag_total_d; } else { main->setting.flag &= ~fss_identify_main_flag_total_d; } - if (main->program.parameters.array[fss_identify_parameter_line_e].result & f_console_result_value_e) { - index = main->program.parameters.array[fss_identify_parameter_line_e].values.array[main->program.parameters.array[fss_identify_parameter_line_e].values.used - 1]; + if (parameters->array[fss_identify_parameter_line_e].result & f_console_result_value_e) { + index = parameters->array[fss_identify_parameter_line_e].values.array[parameters->array[fss_identify_parameter_line_e].values.used - 1]; - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &main->setting.line); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], &main->setting.line); // Negative numbers are not supported. if (main->setting.state.status == F_number_negative) { @@ -89,14 +91,14 @@ extern "C" { } if (F_status_is_error(main->setting.state.status)) { - fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_identify_long_line_s, main->program.parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_identify_long_line_s, parameters->arguments.array[index]); return; } main->setting.flag |= fss_identify_main_flag_line_d; } - else if (main->program.parameters.array[fss_identify_parameter_line_e].result & f_console_result_found_e) { + else if (parameters->array[fss_identify_parameter_line_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_identify_long_line_s); @@ -107,10 +109,10 @@ extern "C" { main->setting.flag &= ~fss_identify_main_flag_line_d; } - if (main->program.parameters.array[fss_identify_parameter_name_e].result & f_console_result_value_e) { + if (parameters->array[fss_identify_parameter_name_e].result & f_console_result_value_e) { main->setting.names.used = 0; - main->setting.state.status = f_memory_array_increase_by(main->program.parameters.array[fss_identify_parameter_name_e].values.used, sizeof(f_string_dynamic_t), (void **) &main->setting.names.array, &main->setting.names.used, &main->setting.names.size); + main->setting.state.status = f_memory_array_increase_by(parameters->array[fss_identify_parameter_name_e].values.used, sizeof(f_string_dynamic_t), (void **) &main->setting.names.array, &main->setting.names.used, &main->setting.names.size); if (F_status_is_error(main->setting.state.status)) { fss_identify_print_error(&main->program.error, macro_fss_identify_f(f_memory_array_increase_by)); @@ -118,7 +120,7 @@ extern "C" { return; } - main->setting.names.used = main->program.parameters.array[fss_identify_parameter_name_e].values.used; + main->setting.names.used = parameters->array[fss_identify_parameter_name_e].values.used; f_number_unsigned_t i = 0; f_number_unsigned_t j = 0; @@ -128,10 +130,10 @@ extern "C" { if (fss_identify_signal_check(main)) return; - index = main->program.parameters.array[fss_identify_parameter_name_e].values.array[i]; + index = parameters->array[fss_identify_parameter_name_e].values.array[i]; main->setting.names.array[i].used = 0; - main->setting.state.status = f_string_dynamic_append_nulless(main->program.parameters.arguments.array[index], &main->setting.names.array[i]); + main->setting.state.status = f_string_dynamic_append_nulless(parameters->arguments.array[index], &main->setting.names.array[i]); if (F_status_is_error(main->setting.state.status)) { fss_identify_print_error(&main->program.error, macro_fss_identify_f(f_string_dynamic_append_nulless)); @@ -184,7 +186,7 @@ extern "C" { main->setting.flag |= fss_identify_main_flag_name_d; } - else if (main->program.parameters.array[fss_identify_parameter_name_e].result & f_console_result_found_e) { + else if (parameters->array[fss_identify_parameter_name_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_identify_long_name_s); @@ -195,10 +197,10 @@ extern "C" { main->setting.flag &= ~fss_identify_parameter_name_e; } - if (main->program.parameters.remaining.used) { + if (parameters->remaining.used) { main->setting.files.used = 0; - main->setting.state.status = f_memory_array_increase_by(main->program.parameters.remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.files.array, &main->setting.files.used, &main->setting.files.size); + main->setting.state.status = f_memory_array_increase_by(parameters->remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.files.array, &main->setting.files.used, &main->setting.files.size); if (F_status_is_error(main->setting.state.status)) { fss_identify_print_error(&main->program.error, macro_fss_identify_f(f_memory_array_increase_by)); @@ -207,14 +209,14 @@ extern "C" { } // Construct the array without allocating any more memory by setting this as a static string (used > 0, size = 0). - for (f_number_unsigned_t index = 0; main->setting.files.used < main->program.parameters.remaining.used; ) { + for (f_number_unsigned_t index = 0; main->setting.files.used < parameters->remaining.used; ) { if (fss_identify_signal_check(main)) return; - index = main->program.parameters.remaining.array[main->setting.files.used]; + index = parameters->remaining.array[main->setting.files.used]; - main->setting.files.array[main->setting.files.used].string = main->program.parameters.arguments.array[index].string; - main->setting.files.array[main->setting.files.used].used = main->program.parameters.arguments.array[index].used; + main->setting.files.array[main->setting.files.used].string = parameters->arguments.array[index].string; + main->setting.files.array[main->setting.files.used].used = parameters->arguments.array[index].used; main->setting.files.array[main->setting.files.used++].size = 0; } // for diff --git a/level_3/fss_identify/c/main/common.h b/level_3/fss_identify/c/main/common.h index d1a5268..5f6b384 100644 --- a/level_3/fss_identify/c/main/common.h +++ b/level_3/fss_identify/c/main/common.h @@ -32,10 +32,10 @@ extern "C" { * F_okay on success. * * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_context_standard(). * * @see f_console_parameter_process() - * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_context_standard() */ #ifndef _di_fss_identify_setting_load_ extern void fss_identify_setting_load(const f_console_arguments_t arguments, fss_identify_main_t * const main); diff --git a/level_3/fss_read/c/main/common.c b/level_3/fss_read/c/main/common.c index 169c2ea..3552a9c 100644 --- a/level_3/fss_read/c/main/common.c +++ b/level_3/fss_read/c/main/common.c @@ -45,12 +45,12 @@ extern "C" { if (!main) return; + f_console_parameters_t * const parameters = &main->program.parameters; + main->program.output.to.id = F_type_descriptor_output_d; main->program.output.to.stream = F_type_output_d; main->program.output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - f_console_parameters_t * const parameters = &main->program.parameters; - main->setting.state.step_small = fss_read_allocation_console_d; f_console_parameter_process(arguments, parameters, &main->setting.state, 0); diff --git a/level_3/fss_read/c/main/common.h b/level_3/fss_read/c/main/common.h index 4e30712..feed8bb 100644 --- a/level_3/fss_read/c/main/common.h +++ b/level_3/fss_read/c/main/common.h @@ -60,7 +60,7 @@ extern "C" { * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: f_file_stream_open(). - * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_context_standard(). * Errors (with error bit) from: fll_program_parameter_process_verbosity_standard(). * * Errors (with error bit) from: fss_read_setting_load_depth(). @@ -73,7 +73,7 @@ extern "C" { * * @see f_console_parameter_process() * @see f_file_stream_open() - * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_context_standard() * @see fll_program_parameter_process_verbosity_standard() * * @see fss_read_setting_load_depth() diff --git a/level_3/fss_read/c/main/main.c b/level_3/fss_read/c/main/main.c index 886a16a..ce31ce3 100644 --- a/level_3/fss_read/c/main/main.c +++ b/level_3/fss_read/c/main/main.c @@ -97,6 +97,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { if (!main || F_status_is_error(main->setting.state.status) || (main->setting.flag & fss_read_main_flag_version_d)) return; + f_console_parameters_t * const parameters = &main->program.parameters; + // Use the default standard of: FSS-0000 (Basic) main->call.process_help = &fss_read_main_process_help; main->call.process_last_line = &fss_read_process_last_line; @@ -134,9 +136,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.feature |= fss_read_feature_flag_line_single_d; main->setting.feature |= fss_read_feature_flag_quote_content_d | fss_read_feature_flag_quote_object_d; - if (main->program.parameters.array[fss_read_parameter_as_e].result & f_console_result_value_e && main->program.parameters.array[fss_read_parameter_as_e].values.used) { - const f_number_unsigned_t index = main->program.parameters.array[fss_read_parameter_as_e].values.array[main->program.parameters.array[fss_read_parameter_as_e].values.used - 1]; - const f_string_static_t as = main->program.parameters.arguments.array[index]; + if (parameters->array[fss_read_parameter_as_e].result & f_console_result_value_e && parameters->array[fss_read_parameter_as_e].values.used) { + const f_number_unsigned_t index = parameters->array[fss_read_parameter_as_e].values.array[parameters->array[fss_read_parameter_as_e].values.used - 1]; + const f_string_static_t as = parameters->arguments.array[index]; if (f_compare_dynamic(as, fss_read_format_code_short_0000_s) == F_equal_to || f_compare_dynamic(as, fss_read_format_code_long_0000_s) == F_equal_to || @@ -158,7 +160,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.feature |= fss_read_feature_flag_line_single_d; main->setting.feature |= fss_read_feature_flag_quote_content_d | fss_read_feature_flag_quote_object_d; - main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + parameters->array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; main->call.process_at = &fss_read_process_at; main->call.process_at_line = &fss_read_process_at_line; @@ -196,7 +198,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.feature |= fss_read_feature_flag_line_single_d | fss_read_feature_flag_content_multiple_d; main->setting.feature |= fss_read_feature_flag_quote_content_d | fss_read_feature_flag_quote_object_d; - main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + parameters->array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; main->call.process_at = &fss_read_process_at; main->call.process_at_line = &fss_read_process_at_line; @@ -233,7 +235,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.feature |= fss_read_feature_flag_object_as_line_d | fss_read_feature_flag_object_trim_d | fss_read_feature_flag_object_trim_expand_d; - main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + parameters->array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; main->call.process_at = &fss_read_process_at; main->call.process_at_line = &fss_read_process_at_line; @@ -273,7 +275,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.feature |= fss_read_feature_flag_object_align_d; main->setting.feature |= fss_read_feature_flag_object_as_line_d | fss_read_feature_flag_object_trim_d | fss_read_feature_flag_object_trim_expand_d; - main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + parameters->array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; main->call.process_at = &fss_read_process_at; main->call.process_at_line = &fss_read_process_at_line; @@ -312,7 +314,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.feature |= fss_read_feature_flag_depth_multiple_d | fss_read_feature_flag_object_align_d; main->setting.feature |= fss_read_feature_flag_object_as_line_d | fss_read_feature_flag_object_trim_d | fss_read_feature_flag_object_trim_expand_d; - main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + parameters->array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; main->call.process_at = &fss_read_process_at; main->call.process_at_line = &fss_read_process_at_line; @@ -350,7 +352,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.feature |= fss_read_feature_flag_object_trim_d | fss_read_feature_flag_object_trim_expand_d; main->setting.flag |= fss_read_main_flag_payload_error_d; - main->program.parameters.array[fss_read_parameter_payload_e].flag &= ~f_console_flag_disable_e; + parameters->array[fss_read_parameter_payload_e].flag &= ~f_console_flag_disable_e; main->call.process_at = &fss_read_process_at; main->call.process_at_line = &fss_read_process_at_line; @@ -383,7 +385,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.state.step_small = fss_read_allocation_console_d; - main->setting.state.status = f_console_parameter_reset(&main->program.parameters); + main->setting.state.status = f_console_parameter_reset(parameters); if (F_status_is_error(main->setting.state.status)) { if (main->setting.flag & fss_read_main_flag_help_d) { @@ -396,7 +398,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { return; } - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); + f_console_parameter_process(arguments, parameters, &main->setting.state, 0); if (F_status_is_error(main->setting.state.status)) { if (main->setting.flag & fss_read_main_flag_help_d) { @@ -413,23 +415,23 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { // If the --as parameter changed as a result of the re-run of the parameter processing, then something is wrong with the parameters. { - const f_number_unsigned_t index_new = main->program.parameters.array[fss_read_parameter_as_e].values.array[main->program.parameters.array[fss_read_parameter_as_e].values.used - 1]; + const f_number_unsigned_t index_new = parameters->array[fss_read_parameter_as_e].values.array[parameters->array[fss_read_parameter_as_e].values.used - 1]; - if (f_compare_dynamic(as, main->program.parameters.arguments.array[index_new]) != F_equal_to) { + if (f_compare_dynamic(as, parameters->arguments.array[index_new]) != F_equal_to) { main->setting.state.status = F_status_set_error(F_parameter); if (main->setting.flag & fss_read_main_flag_help_d) { fss_read_main_process_help(main); } else { - fss_read_main_print_error_parameter_as_changed(&main->program.error, as, main->program.parameters.arguments.array[index_new]); + fss_read_main_print_error_parameter_as_changed(&main->program.error, as, parameters->arguments.array[index_new]); } return; } } } - else if (main->program.parameters.array[fss_read_parameter_as_e].result & f_console_result_found_e) { + else if (parameters->array[fss_read_parameter_as_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_help_d) { diff --git a/level_3/fss_read/c/main/main.h b/level_3/fss_read/c/main/main.h index e452f3a..04e6d53 100644 --- a/level_3/fss_read/c/main/main.h +++ b/level_3/fss_read/c/main/main.h @@ -71,12 +71,12 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: f_file_stream_open(). - * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_context_standard(). * Errors (with error bit) from: fll_program_parameter_process_verbosity_standard(). * * @see f_console_parameter_process() * @see f_file_stream_open() - * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_context_standard() * @see fll_program_parameter_process_verbosity_standard() * * @see fss_read_setting_load() diff --git a/level_3/fss_write/c/main/common.c b/level_3/fss_write/c/main/common.c index 11def30..cd6d519 100644 --- a/level_3/fss_write/c/main/common.c +++ b/level_3/fss_write/c/main/common.c @@ -11,7 +11,9 @@ extern "C" { main->setting.state.step_small = fss_write_allocation_console_d; - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); + f_console_parameters_t * const parameters = &main->program.parameters; + + f_console_parameter_process(arguments, parameters, &main->setting.state, 0); main->setting.state.step_small = fss_write_allocation_small_d; @@ -41,15 +43,15 @@ extern "C" { main->program.output.to.stream = F_type_output_d; main->program.output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { main->setting.flag |= fss_write_main_flag_help_d; } - if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { main->setting.flag |= fss_write_main_flag_version_d; } - if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { main->setting.flag |= fss_write_main_flag_copyright_d; } @@ -71,11 +73,11 @@ extern "C" { } } - if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) return; - if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) return; + if (parameters->array[f_console_standard_parameter_help_e].result & f_console_result_found_e) return; + if (parameters->array[f_console_standard_parameter_version_e].result & f_console_result_found_e) return; - if ((main->program.parameters.array[fss_write_parameter_file_e].result & f_console_result_value_e) && main->program.parameters.array[fss_write_parameter_file_e].values.used) { - if (main->program.parameters.array[fss_write_parameter_file_e].values.used > 1) { + if ((parameters->array[fss_write_parameter_file_e].result & f_console_result_value_e) && parameters->array[fss_write_parameter_file_e].values.used) { + if (parameters->array[fss_write_parameter_file_e].values.used > 1) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_must_specify_once(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_file_s); @@ -83,22 +85,22 @@ extern "C" { return; } - const f_number_unsigned_t index = main->program.parameters.array[fss_write_parameter_file_e].values.array[0]; + const f_number_unsigned_t index = parameters->array[fss_write_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); + main->setting.state.status = f_file_stream_open(parameters->arguments.array[index], f_string_empty_s, &main->program.output.to); if (F_status_is_error(main->setting.state.status)) { - fss_write_print_error_file(&main->program.error, macro_fss_write_f(f_file_stream_open), main->program.parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); + fss_write_print_error_file(&main->program.error, macro_fss_write_f(f_file_stream_open), parameters->arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); return; } main->setting.flag |= fss_write_main_flag_file_to_d; } - else if (main->program.parameters.array[fss_write_parameter_file_e].result & f_console_result_found_e) { + else if (parameters->array[fss_write_parameter_file_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_file_s); @@ -106,8 +108,8 @@ extern "C" { return; } - if ((main->program.parameters.array[fss_write_parameter_object_e].result & f_console_result_value_e) && main->program.parameters.array[fss_write_parameter_object_e].values.used) { - f_number_unsigneds_t * const values = &main->program.parameters.array[fss_write_parameter_object_e].values; + if ((parameters->array[fss_write_parameter_object_e].result & f_console_result_value_e) && parameters->array[fss_write_parameter_object_e].values.used) { + f_number_unsigneds_t * const values = ¶meters->array[fss_write_parameter_object_e].values; main->setting.objects.used = 0; @@ -124,14 +126,14 @@ extern "C" { 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].string = parameters->arguments.array[index].string; + main->setting.objects.array[main->setting.objects.used].used = parameters->arguments.array[index].used; main->setting.objects.array[main->setting.objects.used++].size = 0; } // for main->setting.flag |= fss_write_main_flag_object_d; } - else if (main->program.parameters.array[fss_write_parameter_object_e].result & f_console_result_found_e) { + else if (parameters->array[fss_write_parameter_object_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_object_s); @@ -139,11 +141,11 @@ extern "C" { return; } - if ((main->program.parameters.array[fss_write_parameter_content_e].result & f_console_result_value_e) && main->program.parameters.array[fss_write_parameter_content_e].values.used) { + if ((parameters->array[fss_write_parameter_content_e].result & f_console_result_value_e) && parameters->array[fss_write_parameter_content_e].values.used) { if (main->setting.flag & fss_write_main_flag_object_d) { if (!(main->setting.flag & fss_write_main_flag_content_multiple_d)) { - if (main->program.parameters.array[fss_write_parameter_content_e].values.used > main->program.parameters.array[fss_write_parameter_object_e].values.used) { + if (parameters->array[fss_write_parameter_content_e].values.used > parameters->array[fss_write_parameter_object_e].values.used) { main->setting.state.status = F_status_set_error(F_support_not); fss_write_print_error_one_content_only(&main->program.error); @@ -156,9 +158,9 @@ extern "C" { f_number_unsigned_t stub_object_array[1] = { 0 }; f_number_unsigneds_t stub_object = macro_f_number_unsigneds_t_initialize_1(stub_object_array, 0, 1); - f_number_unsigneds_t * const values_content = &main->program.parameters.array[fss_write_parameter_content_e].values; - f_number_unsigneds_t * const values_object = main->program.parameters.array[fss_write_parameter_object_e].values.used - ? &main->program.parameters.array[fss_write_parameter_object_e].values + f_number_unsigneds_t * const values_content = ¶meters->array[fss_write_parameter_content_e].values; + f_number_unsigneds_t * const values_object = parameters->array[fss_write_parameter_object_e].values.used + ? ¶meters->array[fss_write_parameter_object_e].values : &stub_object; main->setting.contentss.used = 0; @@ -206,8 +208,8 @@ extern "C" { 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].string = parameters->arguments.array[index].string; + main->setting.contentss.array[j].array[main->setting.contentss.array[j].used].used = parameters->arguments.array[index].used; main->setting.contentss.array[j].array[main->setting.contentss.array[j].used++].size = 0; } // for } // while @@ -218,7 +220,7 @@ extern "C" { main->setting.flag |= fss_write_main_flag_content_d; } - else if (main->program.parameters.array[fss_write_parameter_content_e].result & f_console_result_found_e) { + else if (parameters->array[fss_write_parameter_content_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_content_s); @@ -226,12 +228,12 @@ extern "C" { return; } - if ((main->program.parameters.array[fss_write_parameter_prepend_e].result & f_console_result_value_e) && main->program.parameters.array[fss_write_parameter_prepend_e].values.used) { - const f_number_unsigned_t index = main->program.parameters.array[fss_write_parameter_prepend_e].values.array[main->program.parameters.array[fss_write_parameter_prepend_e].location]; + if ((parameters->array[fss_write_parameter_prepend_e].result & f_console_result_value_e) && parameters->array[fss_write_parameter_prepend_e].values.used) { + const f_number_unsigned_t index = parameters->array[fss_write_parameter_prepend_e].values.array[parameters->array[fss_write_parameter_prepend_e].location]; main->setting.prepend.used = 0; - main->setting.state.status = f_string_dynamic_append_nulless(main->program.parameters.arguments.array[index], &main->setting.prepend); + main->setting.state.status = f_string_dynamic_append_nulless(parameters->arguments.array[index], &main->setting.prepend); if (F_status_is_error(main->setting.state.status)) { fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append_nulless)); @@ -239,12 +241,12 @@ extern "C" { return; } - if (main->program.parameters.arguments.array[index].used) { - f_range_t range = macro_f_range_t_initialize_2(main->program.parameters.arguments.array[index].used); + if (parameters->arguments.array[index].used) { + f_range_t range = macro_f_range_t_initialize_2(parameters->arguments.array[index].used); - for (; range.start < main->program.parameters.arguments.array[index].used; range.start++) { + for (; range.start < parameters->arguments.array[index].used; range.start++) { - if (f_fss_is_space(main->program.parameters.arguments.array[index], range, &main->setting.state) == F_false) { + if (f_fss_is_space(parameters->arguments.array[index], range, &main->setting.state) == F_false) { if (F_status_is_error(main->setting.state.status)) { fss_write_print_error(&main->program.error, macro_fss_write_f(f_fss_is_space)); } @@ -261,7 +263,7 @@ extern "C" { main->setting.flag |= fss_write_main_flag_prepend_d; } - else if (main->program.parameters.array[fss_write_parameter_prepend_e].result & f_console_result_found_e) { + else if (parameters->array[fss_write_parameter_prepend_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_prepend_s); @@ -269,8 +271,8 @@ extern "C" { return; } - if ((main->program.parameters.array[fss_write_parameter_ignore_e].result & f_console_result_value_e) && main->program.parameters.array[fss_write_parameter_ignore_e].values.used) { - if (main->program.parameters.array[fss_write_parameter_ignore_e].values.used % 2) { + if ((parameters->array[fss_write_parameter_ignore_e].result & f_console_result_value_e) && parameters->array[fss_write_parameter_ignore_e].values.used) { + if (parameters->array[fss_write_parameter_ignore_e].values.used % 2) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, fss_write_string_two_s); @@ -283,11 +285,11 @@ extern "C" { f_number_unsigned_t stub_data_array[1] = { 0 }; f_number_unsigneds_t stub_data = macro_f_number_unsigneds_t_initialize_1(stub_data_array, 0, 1); - f_number_unsigneds_t * const values_ignore = &main->program.parameters.array[fss_write_parameter_ignore_e].values; - f_number_unsigneds_t * const values_data = main->program.parameters.array[fss_write_parameter_object_e].values.used - ? &main->program.parameters.array[fss_write_parameter_object_e].values - : main->program.parameters.array[fss_write_parameter_content_e].values.used - ? &main->program.parameters.array[fss_write_parameter_content_e].values + f_number_unsigneds_t * const values_ignore = ¶meters->array[fss_write_parameter_ignore_e].values; + f_number_unsigneds_t * const values_data = parameters->array[fss_write_parameter_object_e].values.used + ? ¶meters->array[fss_write_parameter_object_e].values + : parameters->array[fss_write_parameter_content_e].values.used + ? ¶meters->array[fss_write_parameter_content_e].values : &stub_data; main->setting.ignoress.used = 0; @@ -334,20 +336,20 @@ extern "C" { 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); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, 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)) { - fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->program.parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, 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); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, 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)) { - fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->program.parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, parameters->arguments.array[index]); return; } @@ -359,8 +361,8 @@ extern "C" { &main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, - main->program.parameters.arguments.array[values_ignore->array[i - 1]], - main->program.parameters.arguments.array[index] + parameters->arguments.array[values_ignore->array[i - 1]], + parameters->arguments.array[index] ); return; @@ -381,24 +383,24 @@ extern "C" { f_number_unsigned_t index = 0; f_range_t number = f_range_t_initialize; - while (i < main->program.parameters.array[fss_write_parameter_ignore_e].values.used) { + while (i < parameters->array[fss_write_parameter_ignore_e].values.used) { - index = main->program.parameters.array[fss_write_parameter_ignore_e].values.array[i++]; + index = parameters->array[fss_write_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); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], &number.start); if (F_status_is_error(main->setting.state.status)) { - fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->program.parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, parameters->arguments.array[index]); return; } - index = main->program.parameters.array[fss_write_parameter_ignore_e].values.array[i++]; + index = parameters->array[fss_write_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.stop); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], &number.stop); if (F_status_is_error(main->setting.state.status)) { - fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->program.parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, parameters->arguments.array[index]); return; } @@ -410,8 +412,8 @@ extern "C" { &main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, - main->program.parameters.arguments.array[main->program.parameters.array[fss_write_parameter_ignore_e].values.array[i - 1]], - main->program.parameters.arguments.array[index] + parameters->arguments.array[parameters->array[fss_write_parameter_ignore_e].values.array[i - 1]], + parameters->arguments.array[index] ); return; @@ -419,7 +421,7 @@ extern "C" { } // while } } - else if (main->program.parameters.array[fss_write_parameter_ignore_e].result & f_console_result_found_e) { + else if (parameters->array[fss_write_parameter_ignore_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); @@ -433,7 +435,7 @@ extern "C" { main->setting.flag &= ~fss_write_main_flag_ignore_d; } - if (main->program.parameters.array[fss_write_parameter_partial_e].result & f_console_result_found_e) { + if (parameters->array[fss_write_parameter_partial_e].result & f_console_result_found_e) { main->setting.flag |= fss_write_main_flag_partial_d; } @@ -470,7 +472,7 @@ extern "C" { for (uint8_t i = 0; i < 3; ++i) { - if (main->program.parameters.array[has[i]].result & f_console_result_found_e) { + if (parameters->array[has[i]].result & f_console_result_found_e) { if (main->setting.flag & (fss_write_main_flag_object_d | fss_write_main_flag_content_d)) { if (!(main->setting.flag & fss_write_main_flag_partial_d)) { main->setting.state.status = F_status_set_error(F_parameter); @@ -495,7 +497,7 @@ extern "C" { } } - if (main->program.parameters.array[has_cannots[i][0]].result & f_console_result_found_e) { + if (parameters->array[has_cannots[i][0]].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); 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]); @@ -503,7 +505,7 @@ extern "C" { return; } - if (main->program.parameters.array[has_cannots[i][1]].result & f_console_result_found_e) { + if (parameters->array[has_cannots[i][1]].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); 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]); @@ -519,7 +521,7 @@ extern "C" { if (main->setting.flag & (fss_write_main_flag_object_d | fss_write_main_flag_content_d)) { if (main->setting.flag & fss_write_main_flag_object_d) { if (main->setting.flag & fss_write_main_flag_content_multiple_d) { - if (main->program.parameters.array[fss_write_parameter_object_e].locations_sub.used > main->program.parameters.array[fss_write_parameter_content_e].locations_sub.used && !(main->setting.flag & fss_write_main_flag_partial_d)) { + if (parameters->array[fss_write_parameter_object_e].locations_sub.used > parameters->array[fss_write_parameter_content_e].locations_sub.used && !(main->setting.flag & fss_write_main_flag_partial_d)) { main->setting.state.status = F_status_set_error(F_parameter); fss_write_print_error_parameter_same_times_at_least(&main->program.error); @@ -529,7 +531,7 @@ extern "C" { } if ((main->setting.flag & fss_write_main_flag_content_d) && (main->setting.flag & fss_write_main_flag_partial_d)) { - if (main->program.parameters.array[fss_write_parameter_content_e].result & f_console_result_value_e) { + if (parameters->array[fss_write_parameter_content_e].result & f_console_result_value_e) { main->setting.state.status = F_status_set_error(F_parameter); 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_write_long_partial_s, fss_write_long_object_s, fss_write_long_content_s); @@ -542,43 +544,43 @@ extern "C" { main->setting.quote = f_fss_quote_double_s; - if (main->program.parameters.array[fss_write_parameter_double_e].result & f_console_result_found_e) { - if (main->program.parameters.array[fss_write_parameter_single_e].result & f_console_result_found_e) { - if (main->program.parameters.array[fss_write_parameter_double_e].location < main->program.parameters.array[fss_write_parameter_single_e].location) { + if (parameters->array[fss_write_parameter_double_e].result & f_console_result_found_e) { + if (parameters->array[fss_write_parameter_single_e].result & f_console_result_found_e) { + if (parameters->array[fss_write_parameter_double_e].location < parameters->array[fss_write_parameter_single_e].location) { main->setting.quote = f_fss_quote_single_s; - if (main->program.parameters.array[fss_write_parameter_grave_e].result & f_console_result_found_e) { - if (main->program.parameters.array[fss_write_parameter_single_e].location < main->program.parameters.array[fss_write_parameter_grave_e].location) { + if (parameters->array[fss_write_parameter_grave_e].result & f_console_result_found_e) { + if (parameters->array[fss_write_parameter_single_e].location < parameters->array[fss_write_parameter_grave_e].location) { main->setting.quote = f_fss_quote_grave_s; } } } - else if (main->program.parameters.array[fss_write_parameter_grave_e].result & f_console_result_found_e) { - if (main->program.parameters.array[fss_write_parameter_double_e].location < main->program.parameters.array[fss_write_parameter_grave_e].location) { + else if (parameters->array[fss_write_parameter_grave_e].result & f_console_result_found_e) { + if (parameters->array[fss_write_parameter_double_e].location < parameters->array[fss_write_parameter_grave_e].location) { main->setting.quote = f_fss_quote_grave_s; } } } - else if (main->program.parameters.array[fss_write_parameter_grave_e].result & f_console_result_found_e) { - if (main->program.parameters.array[fss_write_parameter_double_e].location < main->program.parameters.array[fss_write_parameter_grave_e].location) { + else if (parameters->array[fss_write_parameter_grave_e].result & f_console_result_found_e) { + if (parameters->array[fss_write_parameter_double_e].location < parameters->array[fss_write_parameter_grave_e].location) { main->setting.quote = f_fss_quote_grave_s; } } } - else if (main->program.parameters.array[fss_write_parameter_single_e].result & f_console_result_found_e) { + else if (parameters->array[fss_write_parameter_single_e].result & f_console_result_found_e) { main->setting.quote = f_fss_quote_single_s; - if (main->program.parameters.array[fss_write_parameter_grave_e].result & f_console_result_found_e) { - if (main->program.parameters.array[fss_write_parameter_single_e].location < main->program.parameters.array[fss_write_parameter_grave_e].location) { + if (parameters->array[fss_write_parameter_grave_e].result & f_console_result_found_e) { + if (parameters->array[fss_write_parameter_single_e].location < parameters->array[fss_write_parameter_grave_e].location) { main->setting.quote = f_fss_quote_grave_s; } } } - else if (main->program.parameters.array[fss_write_parameter_grave_e].result & f_console_result_found_e) { + else if (parameters->array[fss_write_parameter_grave_e].result & f_console_result_found_e) { main->setting.quote = f_fss_quote_grave_s; } - if (main->program.parameters.array[fss_write_parameter_trim_e].result & f_console_result_found_e) { + if (parameters->array[fss_write_parameter_trim_e].result & f_console_result_found_e) { main->setting.flag |= fss_write_main_flag_trim_d; } diff --git a/level_3/fss_write/c/main/common.h b/level_3/fss_write/c/main/common.h index 48da5fb..9c4e2fc 100644 --- a/level_3/fss_write/c/main/common.h +++ b/level_3/fss_write/c/main/common.h @@ -38,7 +38,7 @@ extern "C" { * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: f_file_stream_open(). - * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_context_standard(). * Errors (with error bit) from: fll_program_parameter_process_verbosity_standard(). * @param load_call * (optional) Designate a function to call after performing the initial processing, but before printing help. @@ -48,7 +48,7 @@ extern "C" { * * @see f_console_parameter_process() * @see f_file_stream_open() - * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_context_standard() * @see fll_program_parameter_process_verbosity_standard() */ #ifndef _di_fss_write_setting_load_ diff --git a/level_3/fss_write/c/main/main.h b/level_3/fss_write/c/main/main.h index 17b8647..4bf474d 100644 --- a/level_3/fss_write/c/main/main.h +++ b/level_3/fss_write/c/main/main.h @@ -73,16 +73,6 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * F_okay on success. * F_data_not on success but nothing was provided to operate with. * - * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: f_file_stream_open(). - * Errors (with error bit) from: fll_program_parameter_process_context(). - * Errors (with error bit) from: fll_program_parameter_process_verbosity_standard(). - * - * @see f_console_parameter_process() - * @see f_file_stream_open() - * @see fll_program_parameter_process_context() - * @see fll_program_parameter_process_verbosity_standard() - * * @see fss_write_setting_load() */ #ifndef _di_fss_write_main_setting_load_as_ diff --git a/level_3/iki_read/c/iki/main.c b/level_3/iki_read/c/iki/main.c index bdd2462..16bf564 100644 --- a/level_3/iki_read/c/iki/main.c +++ b/level_3/iki_read/c/iki/main.c @@ -13,6 +13,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.flag |= iki_read_print_flag_out_d; data.program.message.flag |= iki_read_print_flag_message_d | iki_read_print_flag_out_d; data.program.warning.flag |= iki_read_print_flag_warning_d | iki_read_print_flag_out_d; + data.program.error.custom = (void *) &data; data.program.debug.custom = (void *) &data; data.program.message.custom = (void *) &data; diff --git a/level_3/iki_read/c/main/common.c b/level_3/iki_read/c/main/common.c index eca54c2..2c1b7cd 100644 --- a/level_3/iki_read/c/main/common.c +++ b/level_3/iki_read/c/main/common.c @@ -9,12 +9,12 @@ extern "C" { if (!main) return; + f_console_parameters_t * const parameters = &main->program.parameters; + main->program.output.to.id = F_type_descriptor_output_d; main->program.output.to.stream = F_type_output_d; main->program.output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - f_console_parameters_t * const parameters = &main->program.parameters; - main->setting.state.step_small = iki_read_allocation_console_d; f_console_parameter_process(arguments, parameters, &main->setting.state, 0); diff --git a/level_3/iki_read/c/main/common.h b/level_3/iki_read/c/main/common.h index 2545bf8..dc7bfa4 100644 --- a/level_3/iki_read/c/main/common.h +++ b/level_3/iki_read/c/main/common.h @@ -35,7 +35,7 @@ extern "C" { * Errors (with error bit) from: f_file_exists(). * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_string_dynamic_append(). - * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_context_standard(). * Errors (with error bit) from: fll_program_parameter_process_verbosity_standard(). * @param do_settings_load * (optional) Designate a function to call after performing the initial processing, but before printing help. @@ -47,7 +47,7 @@ extern "C" { * @see f_file_exists() * @see f_memory_array_resize() * @see f_string_dynamic_append() - * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_context_standard() * @see fll_program_parameter_process_verbosity_standard() */ #ifndef _di_iki_read_setting_load_ diff --git a/level_3/iki_write/c/main/common.c b/level_3/iki_write/c/main/common.c index e3b1610..8fd2cf4 100644 --- a/level_3/iki_write/c/main/common.c +++ b/level_3/iki_write/c/main/common.c @@ -9,15 +9,15 @@ extern "C" { if (!main) return; + f_console_parameters_t * const parameters = &main->program.parameters; + main->program.output.to.id = F_type_descriptor_output_d; main->program.output.to.stream = F_type_output_d; main->program.output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - f_console_parameters_t * const parameters = &main->program.parameters; - main->setting.state.step_small = iki_write_allocation_console_d; - f_console_parameter_process(arguments, parameters, &main->setting.state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); main->setting.state.step_small = iki_write_allocation_small_d; diff --git a/level_3/iki_write/c/main/common.h b/level_3/iki_write/c/main/common.h index 1862496..3cedd88 100644 --- a/level_3/iki_write/c/main/common.h +++ b/level_3/iki_write/c/main/common.h @@ -33,7 +33,7 @@ extern "C" { * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: f_file_stream_open(). - * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_context_standard(). * Errors (with error bit) from: fll_program_parameter_process_verbosity_standard(). * @param do_settings_load * (optional) Designate a function to call after performing the initial processing, but before printing help. @@ -43,7 +43,7 @@ extern "C" { * * @see f_console_parameter_process() * @see f_file_stream_open() - * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_context_standard() * @see fll_program_parameter_process_verbosity_standard() */ #ifndef _di_iki_write_setting_load_ diff --git a/level_3/status_code/c/main/common.c b/level_3/status_code/c/main/common.c index 18e7ce5..67ddf6c 100644 --- a/level_3/status_code/c/main/common.c +++ b/level_3/status_code/c/main/common.c @@ -9,9 +9,11 @@ extern "C" { if (!main) return; + f_console_parameters_t * const parameters = &main->program.parameters; + main->setting.state.step_small = status_code_allocation_console_d; - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); + f_console_parameter_process(arguments, parameters, &main->setting.state, 0); main->setting.state.step_small = status_code_allocation_small_d; @@ -37,19 +39,19 @@ extern "C" { return; } - if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { main->setting.flag |= status_code_main_flag_help_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { main->setting.flag |= status_code_main_flag_version_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { main->setting.flag |= status_code_main_flag_copyright_d; return; @@ -62,19 +64,19 @@ extern "C" { main->setting.flag &= ~status_code_main_flag_pipe_d; } - if (main->program.parameters.array[status_code_parameter_error_e].result & f_console_result_found_e) { + if (parameters->array[status_code_parameter_error_e].result & f_console_result_found_e) { main->setting.flag |= status_code_main_flag_error_d; } - if (main->program.parameters.array[status_code_parameter_fine_e].result & f_console_result_found_e) { + if (parameters->array[status_code_parameter_fine_e].result & f_console_result_found_e) { main->setting.flag |= status_code_main_flag_fine_d; } - if (main->program.parameters.array[status_code_parameter_warning_e].result & f_console_result_found_e) { + if (parameters->array[status_code_parameter_warning_e].result & f_console_result_found_e) { main->setting.flag |= status_code_main_flag_warning_d; } - if (main->program.parameters.array[status_code_parameter_number_e].result & f_console_result_found_e) { + if (parameters->array[status_code_parameter_number_e].result & f_console_result_found_e) { main->setting.flag |= status_code_main_flag_number_d; } @@ -105,7 +107,7 @@ extern "C" { return; } - if (main->program.parameters.remaining.used == 0 && !(main->program.pipe & fll_program_data_pipe_input_e)) { + if (parameters->remaining.used == 0 && !(main->program.pipe & fll_program_data_pipe_input_e)) { main->setting.state.status = F_status_set_error(F_parameter); status_code_print_error_no_status_codes(&main->program.error); diff --git a/level_3/status_code/c/main/common.h b/level_3/status_code/c/main/common.h index 7238b27..ae26e83 100644 --- a/level_3/status_code/c/main/common.h +++ b/level_3/status_code/c/main/common.h @@ -32,10 +32,10 @@ extern "C" { * F_okay on success. * * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_context_standard(). * * @see f_console_parameter_process() - * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_context_standard() */ #ifndef _di_status_code_setting_load_ extern void status_code_setting_load(const f_console_arguments_t arguments, status_code_main_t * const main); diff --git a/level_3/utf8/c/main/common.c b/level_3/utf8/c/main/common.c index 0d0df01..5468c61 100644 --- a/level_3/utf8/c/main/common.c +++ b/level_3/utf8/c/main/common.c @@ -9,9 +9,11 @@ extern "C" { if (!main) return; + f_console_parameters_t * const parameters = &main->program.parameters; + main->setting.state.step_small = utf8_allocation_console_d; - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); + f_console_parameter_process(arguments, parameters, &main->setting.state, 0); main->setting.state.step_small = utf8_allocation_small_d; @@ -93,7 +95,7 @@ extern "C" { main->setting.mode &= ~(utf8_mode_to_bytesequence_e | utf8_mode_to_codepoint_e); // --to_width may be specified with --to_combining. - if (main->program.parameters.array[utf8_parameter_to_width_e].result & f_console_result_found_e) { + if (parameters->array[utf8_parameter_to_width_e].result & f_console_result_found_e) { main->setting.mode |= utf8_mode_to_width_e; } @@ -103,7 +105,7 @@ extern "C" { main->setting.mode &= ~(utf8_mode_to_bytesequence_e | utf8_mode_to_codepoint_e); // --to_width may be specified with --to_combining. - if (main->program.parameters.array[utf8_parameter_to_combining_e].result & f_console_result_found_e) { + if (parameters->array[utf8_parameter_to_combining_e].result & f_console_result_found_e) { main->setting.mode |= utf8_mode_to_combining_e; } @@ -112,19 +114,19 @@ extern "C" { } } - if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { main->setting.flag |= utf8_main_flag_help_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { main->setting.flag |= utf8_main_flag_version_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { main->setting.flag |= utf8_main_flag_copyright_d; return; @@ -137,8 +139,8 @@ extern "C" { main->setting.flag &= ~utf8_main_flag_pipe_d; } - if (main->program.parameters.array[utf8_parameter_to_file_e].result & f_console_result_value_e) { - if (main->program.parameters.array[utf8_parameter_to_file_e].values.used > 1) { + if (parameters->array[utf8_parameter_to_file_e].result & f_console_result_value_e) { + if (parameters->array[utf8_parameter_to_file_e].values.used > 1) { main->setting.state.status = F_status_set_error(F_parameter); utf8_print_error_parameter_file_to_too_many(&main->program.error); @@ -146,7 +148,7 @@ extern "C" { return; } - if (main->program.parameters.arguments.array[main->program.parameters.array[utf8_parameter_to_file_e].values.array[0]].used) { + if (parameters->arguments.array[parameters->array[utf8_parameter_to_file_e].values.array[0]].used) { main->setting.path_files_to.used = 0; main->setting.state.status = f_memory_array_increase_by(1, sizeof(f_string_dynamic_t), (void **) &main->setting.path_files_to.array, &main->setting.path_files_to.used, &main->setting.path_files_to.size); @@ -159,7 +161,7 @@ extern "C" { main->setting.path_files_to.array[main->setting.path_files_to.used].used = 0; - main->setting.state.status = f_string_dynamic_append_nulless(main->program.parameters.arguments.array[main->program.parameters.array[utf8_parameter_to_file_e].values.array[0]], &main->setting.path_files_to.array[0]); + main->setting.state.status = f_string_dynamic_append_nulless(parameters->arguments.array[parameters->array[utf8_parameter_to_file_e].values.array[0]], &main->setting.path_files_to.array[0]); if (F_status_is_error(main->setting.state.status)) { utf8_print_error(&main->program.error, macro_utf8_f(f_string_dynamic_append_nulless)); @@ -169,10 +171,10 @@ extern "C" { ++main->setting.path_files_to.used; - main->setting.state.status = f_file_stream_open(main->program.parameters.arguments.array[main->program.parameters.array[utf8_parameter_to_file_e].values.array[0]], f_file_open_mode_write_append_s, &main->program.output.to); + main->setting.state.status = f_file_stream_open(parameters->arguments.array[parameters->array[utf8_parameter_to_file_e].values.array[0]], f_file_open_mode_write_append_s, &main->program.output.to); if (F_status_is_error(main->setting.state.status)) { - utf8_print_error_file(&main->program.error, macro_utf8_f(f_file_stream_open), main->program.parameters.arguments.array[main->program.parameters.array[utf8_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); + utf8_print_error_file(&main->program.error, macro_utf8_f(f_file_stream_open), parameters->arguments.array[parameters->array[utf8_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); return; } @@ -180,14 +182,14 @@ extern "C" { main->setting.flag |= utf8_main_flag_file_to_d; } else { - utf8_print_error_parameter_file_name_empty(&main->program.error, main->program.parameters.array[utf8_parameter_to_file_e].values.array[0]); + utf8_print_error_parameter_file_name_empty(&main->program.error, parameters->array[utf8_parameter_to_file_e].values.array[0]); main->setting.state.status = F_status_set_error(F_parameter); return; } } - else if (main->program.parameters.array[utf8_parameter_to_file_e].result & f_console_result_found_e) { + else if (parameters->array[utf8_parameter_to_file_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, utf8_long_to_file_s); @@ -199,10 +201,10 @@ extern "C" { main->setting.flag &= ~utf8_main_flag_file_to_d; } - if (main->program.parameters.array[utf8_parameter_from_file_e].result & f_console_result_value_e) { + if (parameters->array[utf8_parameter_from_file_e].result & f_console_result_value_e) { main->setting.path_files_from.used = 0; - main->setting.state.status = f_memory_array_increase_by(main->program.parameters.array[utf8_parameter_from_file_e].values.used, sizeof(f_string_dynamic_t), (void **) &main->setting.path_files_from.array, &main->setting.path_files_from.used, &main->setting.path_files_from.size); + main->setting.state.status = f_memory_array_increase_by(parameters->array[utf8_parameter_from_file_e].values.used, sizeof(f_string_dynamic_t), (void **) &main->setting.path_files_from.array, &main->setting.path_files_from.used, &main->setting.path_files_from.size); if (F_status_is_error(main->setting.state.status)) { utf8_print_error(&main->program.error, macro_utf8_f(f_memory_array_increase_by)); @@ -210,17 +212,17 @@ extern "C" { return; } - main->setting.path_files_from.used = main->program.parameters.array[utf8_parameter_from_file_e].values.used; + main->setting.path_files_from.used = parameters->array[utf8_parameter_from_file_e].values.used; f_number_unsigned_t i = 0; f_number_unsigned_t index = 0; for (; i < main->setting.path_files_from.used; ++i) { - index = main->program.parameters.array[utf8_parameter_from_file_e].values.array[i]; + index = parameters->array[utf8_parameter_from_file_e].values.array[i]; main->setting.path_files_from.array[i].used = 0; - main->setting.state.status = f_string_dynamic_append(main->program.parameters.arguments.array[index], &main->setting.path_files_from.array[i]); + main->setting.state.status = f_string_dynamic_append(parameters->arguments.array[index], &main->setting.path_files_from.array[i]); if (F_status_is_error(main->setting.state.status)) { fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_utf8_f(f_string_dynamic_append_nulless), fll_error_file_flag_fallback_e); @@ -228,9 +230,9 @@ extern "C" { break; } - if (main->program.parameters.arguments.array[index].used) { - if (f_file_exists(main->program.parameters.arguments.array[index], F_true) != F_true) { - utf8_print_error_parameter_file_not_found(&main->program.error, F_true, main->program.parameters.arguments.array[index]); + if (parameters->arguments.array[index].used) { + if (f_file_exists(parameters->arguments.array[index], F_true) != F_true) { + utf8_print_error_parameter_file_not_found(&main->program.error, F_true, parameters->arguments.array[index]); if (F_status_is_error_not(main->setting.state.status)) { main->setting.state.status = F_status_set_error(F_file_found_not); @@ -250,7 +252,7 @@ extern "C" { main->setting.flag |= utf8_main_flag_file_from_d; } - else if (main->program.parameters.array[utf8_parameter_from_file_e].result & f_console_result_found_e) { + else if (parameters->array[utf8_parameter_from_file_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, utf8_long_from_file_s); @@ -261,10 +263,10 @@ extern "C" { main->setting.flag &= ~utf8_main_flag_file_from_d; } - if (main->program.parameters.remaining.used) { + if (parameters->remaining.used) { main->setting.remaining.used = 0; - main->setting.state.status = f_memory_array_increase_by(main->program.parameters.remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.remaining.array, &main->setting.remaining.used, &main->setting.remaining.size); + main->setting.state.status = f_memory_array_increase_by(parameters->remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.remaining.array, &main->setting.remaining.used, &main->setting.remaining.size); if (F_status_is_error(main->setting.state.status)) { utf8_print_error(&main->program.error, macro_utf8_f(f_memory_array_increase_by)); @@ -273,17 +275,17 @@ extern "C" { } // Construct the array without allocating any more memory by setting this as a static string (used > 0, size = 0). - for (f_number_unsigned_t index = 0; main->setting.remaining.used < main->program.parameters.remaining.used; ) { + for (f_number_unsigned_t index = 0; main->setting.remaining.used < parameters->remaining.used; ) { - index = main->program.parameters.remaining.array[main->setting.remaining.used]; + index = parameters->remaining.array[main->setting.remaining.used]; - main->setting.remaining.array[main->setting.remaining.used].string = main->program.parameters.arguments.array[index].string; - main->setting.remaining.array[main->setting.remaining.used].used = main->program.parameters.arguments.array[index].used; + main->setting.remaining.array[main->setting.remaining.used].string = parameters->arguments.array[index].string; + main->setting.remaining.array[main->setting.remaining.used].used = parameters->arguments.array[index].used; main->setting.remaining.array[main->setting.remaining.used++].size = 0; } // for } - if (!((main->setting.flag & (utf8_main_flag_pipe_d | utf8_main_flag_file_from_d)) || main->program.parameters.remaining.used)) { + if (!((main->setting.flag & (utf8_main_flag_pipe_d | utf8_main_flag_file_from_d)) || parameters->remaining.used)) { main->setting.state.status = F_status_set_error(F_parameter); utf8_print_error_no_from(&main->program.error); @@ -292,7 +294,7 @@ extern "C" { } if (!(main->setting.mode & utf8_mode_to_bytesequence_e)) { - if ((main->program.parameters.array[utf8_parameter_separate_e].result & f_console_result_found_e) || (main->program.parameters.array[utf8_parameter_headers_e].result & f_console_result_found_e)) { + if ((parameters->array[utf8_parameter_separate_e].result & f_console_result_found_e) || (parameters->array[utf8_parameter_headers_e].result & f_console_result_found_e)) { main->setting.prepend = utf8_string_prepend_padding_s; main->setting.append = f_string_eol_s; } @@ -301,13 +303,13 @@ extern "C" { } } - if (main->program.parameters.array[utf8_parameter_headers_e].result & f_console_result_found_e) { - if (main->program.parameters.array[utf8_parameter_separate_e].result & f_console_result_found_e) { - if (main->program.parameters.array[utf8_parameter_headers_e].location < main->program.parameters.array[utf8_parameter_separate_e].location) { + if (parameters->array[utf8_parameter_headers_e].result & f_console_result_found_e) { + if (parameters->array[utf8_parameter_separate_e].result & f_console_result_found_e) { + if (parameters->array[utf8_parameter_headers_e].location < parameters->array[utf8_parameter_separate_e].location) { main->setting.flag |= utf8_main_flag_separate_d; } - else if (main->program.parameters.array[utf8_parameter_headers_e].location == main->program.parameters.array[utf8_parameter_separate_e].location) { - if (main->program.parameters.array[utf8_parameter_headers_e].location_sub < main->program.parameters.array[utf8_parameter_separate_e].location_sub) { + else if (parameters->array[utf8_parameter_headers_e].location == parameters->array[utf8_parameter_separate_e].location) { + if (parameters->array[utf8_parameter_headers_e].location_sub < parameters->array[utf8_parameter_separate_e].location_sub) { main->setting.flag |= utf8_main_flag_separate_d; } else { @@ -322,11 +324,11 @@ extern "C" { main->setting.flag |= utf8_main_flag_header_d; } } - else if (main->program.parameters.array[utf8_parameter_separate_e].result & f_console_result_found_e) { + else if (parameters->array[utf8_parameter_separate_e].result & f_console_result_found_e) { main->setting.flag |= utf8_main_flag_separate_d; } - if (main->program.parameters.array[utf8_parameter_strip_invalid_e].result & f_console_result_found_e) { + if (parameters->array[utf8_parameter_strip_invalid_e].result & f_console_result_found_e) { main->setting.flag |= utf8_main_flag_strip_invalid_d; } diff --git a/level_3/utf8/c/main/common.h b/level_3/utf8/c/main/common.h index b0b2bcf..c2afabe 100644 --- a/level_3/utf8/c/main/common.h +++ b/level_3/utf8/c/main/common.h @@ -32,10 +32,10 @@ extern "C" { * F_okay on success. * * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_context_standard(). * * @see f_console_parameter_process() - * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_context_standard() */ #ifndef _di_utf8_setting_load_ extern void utf8_setting_load(const f_console_arguments_t arguments, utf8_main_t * const main); -- 1.8.3.1