From 4c0ca86048e431de2025c39a3f5078b7248192eb Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 23 May 2023 22:53:44 -0500 Subject: [PATCH] Progress: Continue work on refactoring fss_*_read into fss_read. The primary focus is on cleaning up the state of the code. I will at some pointer later resume migrating the code. --- level_3/byte_dump/c/byte_dump.c | 6 +- level_3/control/c/control.c | 2 +- level_3/control/c/private-control.c | 6 +- level_3/controller/c/controller.c | 6 +- level_3/controller/c/rule/private-rule.c | 4 +- level_3/fake/c/main/common.c | 2 +- level_3/fake/c/main/fake.c | 2 +- level_3/fss_basic_list_read/c/private-read.c | 2 +- level_3/fss_basic_read/c/private-read.c | 2 +- level_3/fss_embedded_list_read/c/private-read.c | 4 +- level_3/fss_extended_read/c/private-read.c | 2 +- level_3/fss_identify/c/fss_identify.c | 4 +- level_3/fss_payload_read/c/private-read.c | 2 +- level_3/fss_payload_read/c/private-read.h | 4 +- level_3/fss_read/c/basic/fss_read.c | 22 ++--- level_3/fss_read/c/basic/fss_read.h | 4 +- level_3/fss_read/c/basic_list/fss_read.h | 1 + level_3/fss_read/c/embedded_list/fss_read.h | 2 + level_3/fss_read/c/extended/fss_read.h | 2 + level_3/fss_read/c/extended_list/fss_read.h | 2 + level_3/fss_read/c/main/common.c | 114 ++++++++++++------------ level_3/fss_read/c/main/common/define.h | 14 +++ level_3/fss_read/c/main/common/type.c | 13 +-- level_3/fss_read/c/main/common/type.h | 11 ++- level_3/fss_read/c/main/fss_read.c | 36 +++----- level_3/fss_read/c/main/fss_read.h | 8 +- level_3/fss_read/c/main/print/data.c | 44 ++++----- level_3/fss_read/c/main/print/data.h | 2 +- level_3/fss_read/c/main/print/error.c | 40 --------- level_3/fss_read/c/main/print/error.h | 42 --------- level_3/fss_read/c/main/process_normal.c | 37 ++++---- level_3/fss_read/c/main/process_normal.h | 2 +- level_3/fss_read/c/payload/fss_read.c | 37 +++----- level_3/fss_read/c/payload/fss_read.h | 2 + level_3/fss_read/c/payload/main.c | 2 +- level_3/fss_read/data/build/settings | 4 +- level_3/fss_write/c/main/common.c | 2 +- level_3/fss_write/c/payload/fss_write.c | 2 +- level_3/iki_read/c/main/common.c | 4 +- 39 files changed, 214 insertions(+), 283 deletions(-) diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index fa06937..b017991 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -184,7 +184,7 @@ extern "C" { } if (main->parameters.array[byte_dump_parameter_width_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[byte_dump_parameter_width_e].values.array[main->parameters.array[byte_dump_parameter_width_e].values.used - 1]; + const f_array_length_t index = main->parameters.array[byte_dump_parameter_width_e].values.array[main->parameters.array[byte_dump_parameter_width_e].location]; f_number_unsigned_t number = 0; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], &number); @@ -223,7 +223,7 @@ extern "C" { } if (main->parameters.array[byte_dump_parameter_first_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[byte_dump_parameter_first_e].values.array[main->parameters.array[byte_dump_parameter_first_e].values.used - 1]; + const f_array_length_t index = main->parameters.array[byte_dump_parameter_first_e].values.array[main->parameters.array[byte_dump_parameter_first_e].location]; f_number_unsigned_t number = 0; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], &number); @@ -262,7 +262,7 @@ extern "C" { } if (main->parameters.array[byte_dump_parameter_last_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[byte_dump_parameter_last_e].values.array[main->parameters.array[byte_dump_parameter_last_e].values.used - 1]; + const f_array_length_t index = main->parameters.array[byte_dump_parameter_last_e].values.array[main->parameters.array[byte_dump_parameter_last_e].location]; f_number_unsigned_t number = 0; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], &number); diff --git a/level_3/control/c/control.c b/level_3/control/c/control.c index b8d8e4d..87b5db1 100644 --- a/level_3/control/c/control.c +++ b/level_3/control/c/control.c @@ -110,7 +110,7 @@ extern "C" { status = F_status_set_error(F_parameter); } else if (main->parameters.array[ids[i]].result & f_console_result_value_e) { - index = main->parameters.array[ids[i]].values.array[main->parameters.array[ids[i]].values.used - 1]; + index = main->parameters.array[ids[i]].values.array[main->parameters.array[ids[i]].location]; if (!main->parameters.arguments.array[index].used) { control_print_error_parameter_value_empty(main, names[i]); diff --git a/level_3/control/c/private-control.c b/level_3/control/c/private-control.c index df063c0..afbbd50 100644 --- a/level_3/control/c/private-control.c +++ b/level_3/control/c/private-control.c @@ -615,7 +615,7 @@ extern "C" { data->cache.small.used = 0; if (main->parameters.array[control_parameter_settings_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[control_parameter_settings_e].values.array[main->parameters.array[control_parameter_settings_e].values.used - 1]; + const f_array_length_t index = main->parameters.array[control_parameter_settings_e].values.array[main->parameters.array[control_parameter_settings_e].location]; status = f_string_dynamic_append(data->argv[index], &data->cache.small); } @@ -707,7 +707,7 @@ extern "C" { data->cache.small.used = 0; if (main->parameters.array[control_parameter_socket_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[control_parameter_socket_e].values.array[main->parameters.array[control_parameter_socket_e].values.used - 1]; + const f_array_length_t index = main->parameters.array[control_parameter_socket_e].values.array[main->parameters.array[control_parameter_socket_e].location]; status = f_string_dynamic_append(data->argv[index], &data->cache.small); } @@ -772,7 +772,7 @@ extern "C" { for (uint8_t i = 0; i < 3; ++i) { if (append_ids[i] && main->parameters.array[append_ids[i]].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[append_ids[i]].values.array[main->parameters.array[append_ids[i]].values.used - 1]; + const f_array_length_t index = main->parameters.array[append_ids[i]].values.array[main->parameters.array[append_ids[i]].location]; status = f_string_dynamic_append(data->argv[index], &data->cache.small); } diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index 85f2fd3..4b87622 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -144,7 +144,7 @@ extern "C" { status = F_status_set_error(F_parameter); } else if (main->parameters.array[controller_parameter_settings_e].locations.used) { - const f_array_length_t index = main->parameters.array[controller_parameter_settings_e].values.array[main->parameters.array[controller_parameter_settings_e].values.used - 1]; + const f_array_length_t index = main->parameters.array[controller_parameter_settings_e].values.array[main->parameters.array[controller_parameter_settings_e].location]; status = controller_path_canonical_relative(&setting, argv[index], &setting.path_setting); @@ -185,7 +185,7 @@ extern "C" { else if (main->parameters.array[controller_parameter_pid_e].locations.used) { setting.path_pid.used = 0; - const f_array_length_t index = main->parameters.array[controller_parameter_pid_e].values.array[main->parameters.array[controller_parameter_pid_e].values.used - 1]; + const f_array_length_t index = main->parameters.array[controller_parameter_pid_e].values.array[main->parameters.array[controller_parameter_pid_e].location]; if (argv[index].used) { status = controller_path_canonical_relative(&setting, argv[index], &setting.path_pid); @@ -241,7 +241,7 @@ extern "C" { status = F_status_set_error(F_parameter); } else if (main->parameters.array[controller_parameter_cgroup_e].locations.used) { - const f_array_length_t index = main->parameters.array[controller_parameter_cgroup_e].values.array[main->parameters.array[controller_parameter_cgroup_e].values.used - 1]; + const f_array_length_t index = main->parameters.array[controller_parameter_cgroup_e].values.array[main->parameters.array[controller_parameter_cgroup_e].location]; if (argv[index].used) { status = controller_path_canonical_relative(&setting, argv[index], &setting.path_cgroup); diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index dabdae7..9b9b94f 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -2218,7 +2218,7 @@ extern "C" { if (f_compare_dynamic_partial_string(options[i].string, source, options[i].used, content) == F_equal_to) { if (values[i]) { if (parameters->array[codes[i]].result & f_console_result_value_e) { - const f_array_length_t index = parameters->array[codes[i]].values.array[parameters->array[codes[i]].values.used - 1]; + const f_array_length_t index = parameters->array[codes[i]].values.array[parameters->array[codes[i]].location]; status = f_string_dynamic_increase_by(symbols[i].used + expands[i].used + f_string_ascii_space_s.used + argv[index].used + 1, destination); if (F_status_is_error(status)) return status; @@ -2290,7 +2290,7 @@ extern "C" { if (f_compare_dynamic_partial_string(buffer.string, source, buffer.used, content) == F_equal_to) { if (parameters->array[codes[i]].result & f_console_result_value_e) { - const f_array_length_t index = parameters->array[codes[i]].values.array[parameters->array[codes[i]].values.used - 1]; + const f_array_length_t index = parameters->array[codes[i]].values.array[parameters->array[codes[i]].location]; status = f_string_dynamic_append(argv[index], destination); if (F_status_is_error(status)) return status; diff --git a/level_3/fake/c/main/common.c b/level_3/fake/c/main/common.c index 5be6e32..55ae3d9 100644 --- a/level_3/fake/c/main/common.c +++ b/level_3/fake/c/main/common.c @@ -248,7 +248,7 @@ extern "C" { } if (main->program.parameters.array[parameters[i]].result & f_console_result_value_e) { - index = main->program.parameters.array[parameters[i]].values.array[main->program.parameters.array[parameters[i]].values.used - 1]; + index = main->program.parameters.array[parameters[i]].values.array[main->program.parameters.array[parameters[i]].location; if (main->program.parameters.arguments.array[index].used) { if (parameters[i] == fake_parameter_process_e) { diff --git a/level_3/fake/c/main/fake.c b/level_3/fake/c/main/fake.c index f2c4ac5..793eac6 100644 --- a/level_3/fake/c/main/fake.c +++ b/level_3/fake/c/main/fake.c @@ -454,7 +454,7 @@ extern "C" { ]; if (parameter->result & f_console_result_value_e) { - const f_array_length_t index = parameter->values.array[parameter->values.used - 1]; + const f_array_length_t index = parameter->values.array[parameter->location]; if (f_path_is_absolute(main->program.parameters.arguments.array[index]) == F_true || f_path_is_relative_current(main->program.parameters.arguments.array[index]) == F_true) { requireds[1] = F_none; // fake_long_data_s diff --git a/level_3/fss_basic_list_read/c/private-read.c b/level_3/fss_basic_list_read/c/private-read.c index 5eaa402..c594875 100644 --- a/level_3/fss_basic_list_read/c/private-read.c +++ b/level_3/fss_basic_list_read/c/private-read.c @@ -274,7 +274,7 @@ extern "C" { f_status_t fss_basic_list_read_load_number(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; + const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].location]; const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); diff --git a/level_3/fss_basic_read/c/private-read.c b/level_3/fss_basic_read/c/private-read.c index b69d1da..492df15 100644 --- a/level_3/fss_basic_read/c/private-read.c +++ b/level_3/fss_basic_read/c/private-read.c @@ -259,7 +259,7 @@ extern "C" { f_status_t fss_basic_read_load_number(fll_program_data_t * const main, fss_basic_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; + const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].location]; const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); diff --git a/level_3/fss_embedded_list_read/c/private-read.c b/level_3/fss_embedded_list_read/c/private-read.c index b6bd4fb..5264b1b 100644 --- a/level_3/fss_embedded_list_read/c/private-read.c +++ b/level_3/fss_embedded_list_read/c/private-read.c @@ -299,7 +299,7 @@ extern "C" { f_number_unsigned_t select = 0; if (data->main->parameters.array[fss_embedded_list_read_parameter_select_e].result & f_console_result_value_e) { - const f_array_length_t index = data->main->parameters.array[fss_embedded_list_read_parameter_select_e].values.array[data->main->parameters.array[fss_embedded_list_read_parameter_select_e].values.used - 1]; + const f_array_length_t index = data->main->parameters.array[fss_embedded_list_read_parameter_select_e].values.array[data->main->parameters.array[fss_embedded_list_read_parameter_select_e].location]; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->main->parameters.arguments.array[index], &select); @@ -319,7 +319,7 @@ extern "C" { f_array_length_t line = 0; if (data->main->parameters.array[fss_embedded_list_read_parameter_line_e].result & f_console_result_value_e) { - const f_array_length_t index = data->main->parameters.array[fss_embedded_list_read_parameter_line_e].values.array[data->main->parameters.array[fss_embedded_list_read_parameter_line_e].values.used - 1]; + const f_array_length_t index = data->main->parameters.array[fss_embedded_list_read_parameter_line_e].values.array[data->main->parameters.array[fss_embedded_list_read_parameter_line_e].location]; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->main->parameters.arguments.array[index], &line); diff --git a/level_3/fss_extended_read/c/private-read.c b/level_3/fss_extended_read/c/private-read.c index be48d0d..1e52bf3 100644 --- a/level_3/fss_extended_read/c/private-read.c +++ b/level_3/fss_extended_read/c/private-read.c @@ -281,7 +281,7 @@ extern "C" { f_status_t fss_extended_read_load_number(fll_program_data_t * const main, fss_extended_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; + const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].location]; const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index 7e62094..6bc276f 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -103,7 +103,7 @@ extern "C" { status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_identify_parameter_line_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[fss_identify_parameter_line_e].values.array[main->parameters.array[fss_identify_parameter_line_e].values.used - 1]; + const f_array_length_t index = main->parameters.array[fss_identify_parameter_line_e].values.array[main->parameters.array[fss_identify_parameter_line_e].location]; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], &data.line); @@ -143,7 +143,7 @@ extern "C" { status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_identify_parameter_name_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[fss_identify_parameter_name_e].values.array[main->parameters.array[fss_identify_parameter_name_e].values.used - 1]; + const f_array_length_t index = main->parameters.array[fss_identify_parameter_name_e].values.array[main->parameters.array[fss_identify_parameter_name_e].location]; const f_array_length_t length = data.argv[index].used; const f_string_range_t range = macro_f_string_range_t_initialize_2(length); diff --git a/level_3/fss_payload_read/c/private-read.c b/level_3/fss_payload_read/c/private-read.c index 14d0888..d52f087 100644 --- a/level_3/fss_payload_read/c/private-read.c +++ b/level_3/fss_payload_read/c/private-read.c @@ -300,7 +300,7 @@ extern "C" { f_status_t fss_payload_read_load_number(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; + const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].location]; const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); diff --git a/level_3/fss_payload_read/c/private-read.h b/level_3/fss_payload_read/c/private-read.h index 0665a16..0c94992 100644 --- a/level_3/fss_payload_read/c/private-read.h +++ b/level_3/fss_payload_read/c/private-read.h @@ -61,15 +61,15 @@ extern "C" { * * F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal. * + * Errors (with error bit) from: f_rip_dynamic(). * Errors (with error bit) from: f_string_append(). * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect(). - * Errors (with error bit) from: f_rip_dynamic(). * * Errors (with error bit) from: fss_payload_read_depths_resize(). * + * @see f_rip_dynamic() * @see f_string_append() * @see fl_conversion_dynamic_partial_to_unsigned_detect() - * @see f_rip_dynamic() * * @see fss_payload_read_depths_resize() */ diff --git a/level_3/fss_read/c/basic/fss_read.c b/level_3/fss_read/c/basic/fss_read.c index 29b4ea1..de01cdd 100644 --- a/level_3/fss_read/c/basic/fss_read.c +++ b/level_3/fss_read/c/basic/fss_read.c @@ -21,17 +21,19 @@ extern "C" { f_string_range_t input = macro_f_string_range_t_initialize_2(main->setting.buffer.used); - main->setting.delimits.used = 0; - main->setting.quotes.used = 0; + main->setting.delimits_object.used = 0; + main->setting.delimits_content.used = 0; + main->setting.quotes_object.used = 0; + main->setting.quotes_content.used = 0; - fll_fss_basic_read(main->setting.buffer, &input, &main->setting.objects, &main->setting.contents, &main->setting.quotes_object, &main->setting.delimits, 0, &main->setting.state); + fll_fss_basic_read(main->setting.buffer, &input, &main->setting.objects, &main->setting.contents, &main->setting.quotes_object, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.state); - if (F_status_is_error(data.setting.state.status)) { - if (F_status_set_fine(data.setting.state.status) == F_interrupt) return; + if (F_status_is_error(main->setting.state.status)) { + if (F_status_set_fine(main->setting.state.status) == F_interrupt) return; fll_error_file_print( - &main->error, - F_status_set_fine(data.setting.state.status), + &main->program.error, + F_status_set_fine(main->setting.state.status), macro_fss_read_f(fll_fss_basic_read), fll_error_file_flag_fallback_e, fss_read_file_identify(input.start, main->setting.files), @@ -42,15 +44,15 @@ extern "C" { return; } - if (data.setting.state.status == F_data_not_stop || data.setting.state.status == F_data_not_eos) { + if (main->setting.state.status == F_data_not_stop || main->setting.state.status == F_data_not_eos) { if (!(main->setting.flag & fss_read_main_flag_total_e)) { - data.setting.state.status = F_status_set_warning(status); + main->setting.state.status = F_status_set_warning(main->setting.state.status); return; } } - data.setting.state.status = F_none; + main->setting.state.status = F_none; } #endif // _di_fss_read_basic_process_load_ diff --git a/level_3/fss_read/c/basic/fss_read.h b/level_3/fss_read/c/basic/fss_read.h index 11d551d..8775908 100644 --- a/level_3/fss_read/c/basic/fss_read.h +++ b/level_3/fss_read/c/basic/fss_read.h @@ -40,6 +40,7 @@ // FLL-2 includes. #include +#include #include #include @@ -51,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -105,7 +107,7 @@ extern "C" { * @see fss_read_file_identify() */ #ifndef _di_fss_read_basic_process_load_ - extern f_status_t fss_read_basic_process_load(fss_read_main_t * const main); + extern void fss_read_basic_process_load(fss_read_main_t * const main); #endif // _di_fss_read_basic_process_load_ #ifdef __cplusplus diff --git a/level_3/fss_read/c/basic_list/fss_read.h b/level_3/fss_read/c/basic_list/fss_read.h index 2c5a958..08f31a9 100644 --- a/level_3/fss_read/c/basic_list/fss_read.h +++ b/level_3/fss_read/c/basic_list/fss_read.h @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include diff --git a/level_3/fss_read/c/embedded_list/fss_read.h b/level_3/fss_read/c/embedded_list/fss_read.h index 836c18c..a41e739 100644 --- a/level_3/fss_read/c/embedded_list/fss_read.h +++ b/level_3/fss_read/c/embedded_list/fss_read.h @@ -40,6 +40,7 @@ // FLL-2 includes. #include +#include #include #include @@ -51,6 +52,7 @@ #include #include #include +#include #include #include #include diff --git a/level_3/fss_read/c/extended/fss_read.h b/level_3/fss_read/c/extended/fss_read.h index 9d6c8bd..dd5ac86 100644 --- a/level_3/fss_read/c/extended/fss_read.h +++ b/level_3/fss_read/c/extended/fss_read.h @@ -40,6 +40,7 @@ // FLL-2 includes. #include +#include #include #include @@ -51,6 +52,7 @@ #include #include #include +#include #include #include #include diff --git a/level_3/fss_read/c/extended_list/fss_read.h b/level_3/fss_read/c/extended_list/fss_read.h index d05a015..5b0c76d 100644 --- a/level_3/fss_read/c/extended_list/fss_read.h +++ b/level_3/fss_read/c/extended_list/fss_read.h @@ -40,6 +40,7 @@ // FLL-2 includes. #include +#include #include #include @@ -51,6 +52,7 @@ #include #include #include +#include #include #include #include diff --git a/level_3/fss_read/c/main/common.c b/level_3/fss_read/c/main/common.c index f08f251..2e7acb9 100644 --- a/level_3/fss_read/c/main/common.c +++ b/level_3/fss_read/c/main/common.c @@ -140,11 +140,11 @@ extern "C" { fss_read_long_delimit_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_static_t message_positive_number = macro_f_string_static_t_initialize_1("a positive number", 0, 17); + static const f_string_static_t message_string = macro_f_string_static_t_initialize_1("a string", 0, 8); + static const f_string_static_t message_value = macro_f_string_static_t_initialize_1("a value", 0, 7); - static const f_string_t parameter_message[] = { + static const f_string_static_t parameter_message[] = { message_positive_number, message_positive_number, message_positive_number, @@ -173,27 +173,27 @@ extern "C" { for (i = 0; i < 6; ++i) { - if (parameters->array[parameter_code[i]].result & f_console_result_found_e)) { + if (parameters->array[parameter_code[i]].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); } - fss_read_print_error_parameter_requires_message(&main->error, f_console_symbol_long_normal_s, parameter_name[i], parameter_message[i]); + fss_read_print_error_parameter_requires_message(&main->program.error, f_console_symbol_long_normal_s, parameter_name[i], parameter_message[i]); return; } - else if (parameters->array[parameter_code[i]].result & f_console_result_value_e)) { + else if (parameters->array[parameter_code[i]].result & f_console_result_value_e) { main->setting.state.flag |= parameter_flag[i]; if (parameter_value_digit[i]) { - index = parameters->array[parameter_code[i]].values.array[parameters->array[parameter_code[i]].values.used - 1]; + index = parameters->array[parameter_code[i]].values.array[parameters->array[parameter_code[i]].location]; - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], parameter_value_digit_single[i]); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], parameter_value_digit[i]); if (F_status_is_error(main->setting.state.status)) { - fll_error_parameter_integer_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_to_unsigned_detect), F_true, parameter_name[i], parameters->arguments.array[index]); + fll_error_parameter_integer_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_to_unsigned_detect), F_true, parameter_name[i], parameters->arguments.array[index]); return; } @@ -232,12 +232,12 @@ extern "C" { if (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->program.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); } - 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]); + fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_read_long_columns_s, parameter_name[i]); } return; @@ -251,13 +251,13 @@ extern "C" { if ((parameters->array[fss_read_parameter_total_e].result & f_console_result_found_e) || (parameters->array[fss_read_parameter_total_e].result & f_console_result_found_e)) { main->setting.state.status = F_status_set_error(F_parameter); - if (main->error.verbosity > f_console_verbosity_quiet_e) { + if (main->program.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); } fll_program_print_error_parameter_cannot_use_with( - &main->error, f_console_symbol_long_normal_s, + &main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_read_long_pipe_s, (parameters->array[fss_read_parameter_total_e].result & f_console_result_found_e) @@ -290,7 +290,7 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_program_print_error_parameter_empty_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_file_s); + fll_program_print_error_parameter_empty_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_delimit_s); return; } @@ -390,7 +390,7 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - 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, parameters->arguments.array[index]); + fll_error_parameter_integer_print(&main->program.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, parameters->arguments.array[index]); return; } @@ -457,7 +457,7 @@ extern "C" { main->setting.flag |= fss_read_main_flag_trim_e; } - main->setting.state.status = fss_read_setting_load_depth(arguments, main, parameters); + fss_read_setting_load_depth(arguments, main, parameters); if (F_status_is_error(main->setting.state.status)) return; if (parameters->array[fss_read_parameter_select_e].result & f_console_result_found_e) { @@ -467,7 +467,9 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_program_print_error_parameter_integer_not_positive(&main->error, f_console_symbol_long_normal_s, fss_read_long_select_s); + index = parameters->array[fss_read_parameter_select_e].values.array[i]; + + fll_program_print_error_parameter_integer_not_positive(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_select_s, parameters->arguments.array[index]); return; } @@ -478,7 +480,7 @@ extern "C" { f_file_t file = f_file_t_initialize; - if (main->pipe & fll_program_data_pipe_input_e) { + if (main->program.pipe & fll_program_data_pipe_input_e) { file.id = F_type_descriptor_input_d; file.stream = F_type_input_d; @@ -491,7 +493,7 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_stream_read), fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); + fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_stream_read), fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); return; } @@ -533,21 +535,21 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_stream_open), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_stream_open), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); break; } size_file = 0; - main->setting.state.status = f_file_size_by_id(file.id, &size_file); + main->setting.state.status = f_file_size_by_id(file, &size_file); 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_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_size_by_id), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_size_by_id), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -555,15 +557,15 @@ extern "C" { if (size_file) { // Enforce a max block read size to allow for interrupts to be processed between blocks. - if (size_file > fss_basic_list_read_block_max) { - file.size_read = fss_basic_list_read_block_read_large; - size_block = fss_basic_list_read_block_max; + if (size_file > fss_read_allocation_block_max_d) { + file.size_read = fss_read_allocation_block_read_large_d; + size_block = fss_read_allocation_block_max_d; // Pre-allocate entire file buffer plus space for the terminating NULL. f_string_dynamic_increase_by(size_file + (size_block - (size_file % size_block)) + 1, &main->setting.buffer); } else { - file.size_read = fss_basic_list_read_block_read_small; + file.size_read = fss_read_allocation_block_read_small_d; size_block = size_file; // Pre-allocate entire file buffer plus space for the terminating NULL. @@ -575,26 +577,26 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_string_dynamic_increase_by), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_process_s, fll_error_file_type_file_e); + fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_string_dynamic_increase_by), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_process_s, fll_error_file_type_file_e); break; } for (size_read = 0; size_read < size_file; size_read += size_block) { - if (size_file > fss_basic_list_read_block_max && fss_read_signal_check(main)) break; + if (size_file > fss_read_allocation_block_max_d && fss_read_signal_check(main)) break; main->setting.state.status = f_file_stream_read_until(file, size_block, &main->setting.buffer); if (F_status_is_error(main->setting.state.status)) break; } // for if (F_status_is_error(main->setting.state.status)) { - if (F_status_set_fine(status) != F_interrupt) { + if (F_status_set_fine(main->setting.state.status) != F_interrupt) { 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_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_stream_read_until), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_stream_read_until), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_read_s, fll_error_file_type_file_e); } break; @@ -635,8 +637,8 @@ extern "C" { i = parameters->array[fss_read_parameter_depth_e].values.used; } - if (i > data->depths.size) { - main->setting.state.status = fss_read_depths_resize(i, &data->depths); + if (i > main->setting.depths.size) { + main->setting.state.status = fss_read_depths_resize(i, &main->setting.depths); 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) { @@ -649,23 +651,23 @@ extern "C" { } } - data->depths.used = depth_size; + main->setting.depths.used = i; f_array_length_t position_depth = 0; f_array_length_t position_at = 0; f_array_length_t position_name = 0; - for (i = 0; i < data->depths.used; ++i) { + for (i = 0; i < main->setting.depths.used; ++i) { if (fss_read_signal_check(main)) return; - data->depths.array[i].depth = 0; - data->depths.array[i].index_at = 0; - data->depths.array[i].index_name = 0; - data->depths.array[i].value_at = 0; + main->setting.depths.array[i].depth = 0; + main->setting.depths.array[i].index_at = 0; + main->setting.depths.array[i].index_name = 0; + main->setting.depths.array[i].value_at = 0; // This dynamic string is actually a static string, so clear it between loops. - macro_f_string_dynamic_t_clear(data->depths.array[i].value_name); + macro_f_string_dynamic_t_clear(main->setting.depths.array[i].value_name); if (!parameters->array[fss_read_parameter_depth_e].values.used) { position_depth = 0; @@ -673,14 +675,14 @@ extern "C" { else { position_depth = parameters->array[fss_read_parameter_depth_e].values.array[i]; - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[position_depth], &data->depths.array[i].depth); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[position_depth], &main->setting.depths.array[i].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_error_parameter_integer_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_to_unsigned_detect), F_true, fss_read_long_depth_s, data->argv[position_depth]); + fll_error_parameter_integer_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_to_unsigned_detect), F_true, fss_read_long_depth_s, parameters->arguments.array[position_depth]); return; } @@ -693,20 +695,20 @@ extern "C" { continue; } - if (i + 1 < data->depths.used && parameters->array[fss_read_parameter_at_e].values.array[position_at] > parameters->array[fss_read_parameter_depth_e].values.array[i + 1]) { + if (i + 1 < main->setting.depths.used && parameters->array[fss_read_parameter_at_e].values.array[position_at] > parameters->array[fss_read_parameter_depth_e].values.array[i + 1]) { break; } - data->depths.array[i].index_at = parameters->array[fss_read_parameter_at_e].values.array[position_at]; + main->setting.depths.array[i].index_at = parameters->array[fss_read_parameter_at_e].values.array[position_at]; - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[data->depths.array[i].index_at], &data->depths.array[i].value_at); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[main->setting.depths.array[i].index_at], &main->setting.depths.array[i].value_at); 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_error_parameter_integer_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_to_unsigned_detect), F_true, fss_read_long_at_s, data->argv[data->depths.array[i].index_at]); + fll_error_parameter_integer_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_to_unsigned_detect), F_true, fss_read_long_at_s, parameters->arguments.array[main->setting.depths.array[i].index_at]); return; } @@ -720,17 +722,17 @@ extern "C" { continue; } - if (i + 1 < data->depths.used && parameters->array[fss_read_parameter_name_e].values.array[position_name] > parameters->array[fss_read_parameter_depth_e].values.array[i + 1]) { + if (i + 1 < main->setting.depths.used && parameters->array[fss_read_parameter_name_e].values.array[position_name] > parameters->array[fss_read_parameter_depth_e].values.array[i + 1]) { break; } - data->depths.array[i].index_name = parameters->array[fss_read_parameter_name_e].values.array[position_name]; + main->setting.depths.array[i].index_name = parameters->array[fss_read_parameter_name_e].values.array[position_name]; if (parameters->array[fss_read_parameter_trim_e].result & f_console_result_found_e) { - main->setting.state.status = f_rip_dynamic(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); + main->setting.state.status = f_rip_dynamic(parameters->arguments.array[main->setting.depths.array[i].index_name], &main->setting.depths.array[i].value_name); } else { - main->setting.state.status = f_string_dynamic_append(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); + main->setting.state.status = f_string_dynamic_append(parameters->arguments.array[main->setting.depths.array[i].index_name], &main->setting.depths.array[i].value_name); } if (F_status_is_error(main->setting.state.status)) { @@ -748,32 +750,32 @@ extern "C" { f_array_length_t j = 0; - for (i = 0; i < data->depths.used; ++i) { + for (i = 0; i < main->setting.depths.used; ++i) { - for (j = i + 1; j < data->depths.used; ++j) { + for (j = i + 1; j < main->setting.depths.used; ++j) { if (fss_read_signal_check(main)) return; - if (data->depths.array[i].depth == data->depths.array[j].depth) { + if (main->setting.depths.array[i].depth == main->setting.depths.array[j].depth) { 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_value_once_only_number(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_depth_s, data->depths.array[i].depth); + fss_read_print_error_parameter_value_once_only_number(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_depth_s, main->setting.depths.array[i].depth); return; } - if (data->depths.array[i].depth > data->depths.array[j].depth) { + if (main->setting.depths.array[i].depth > main->setting.depths.array[j].depth) { 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_value_before_value_number(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_depth_s, data->depths.array[i].depth, data->depths.array[j].depth); + fss_read_print_error_parameter_value_before_value_number(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_depth_s, main->setting.depths.array[i].depth, main->setting.depths.array[j].depth); return; } diff --git a/level_3/fss_read/c/main/common/define.h b/level_3/fss_read/c/main/common/define.h index e192d83..ecdbeb9 100644 --- a/level_3/fss_read/c/main/common/define.h +++ b/level_3/fss_read/c/main/common/define.h @@ -33,6 +33,20 @@ extern "C" { #endif // _di_fss_read_allocation_d_ /** + * The program allocation block defines. + * + * fss_payload_read_block_*: + * - max: The max block read size before checking for interrupt. + * - read_small: The block read size for small files. + * - read_large: The block read size for large files. + */ +#ifndef _di_fss_read_allocation_d_ + #define fss_read_allocation_block_max_d 16777216 + #define fss_read_allocation_block_read_small_d 8192 + #define fss_read_allocation_block_read_large_d 65536 +#endif // _di_fss_read_allocation_d_ + +/** * The program signal defines. * * fss_read_signal_*_d: diff --git a/level_3/fss_read/c/main/common/type.c b/level_3/fss_read/c/main/common/type.c index a239727..d520513 100644 --- a/level_3/fss_read/c/main/common/type.c +++ b/level_3/fss_read/c/main/common/type.c @@ -22,12 +22,10 @@ extern "C" { f_status_t status = F_none; for (f_array_length_t i = length; i < depths->size; ++i) { - - status = private_f_string_ranges_adjust(0, &depths->array[i]); - if (F_status_is_error(status)) return status; + fss_read_depth_delete(&depths->array[i]); } // for - status = f_memory_adjust(depths->size, length, sizeof(fss_read_file_t), (void **) & depths->array); + status = f_memory_resize(depths->size, length, sizeof(fss_read_file_t), (void **) & depths->array); if (F_status_is_error(status)) return status; depths->size = length; @@ -74,14 +72,11 @@ extern "C" { if (!setting) return F_status_set_error(F_parameter); - f_string_dynamic_resize(0, &setting->escaped); - f_string_dynamic_resize(0, &setting->block); - f_string_dynamic_resize(0, &setting->buffer); - f_string_dynamic_resize(0, &setting->prepend); - fss_read_files_resize(0, &setting->files); fss_read_depths_resize(0, &setting->depths); + f_string_dynamic_resize(0, &setting->buffer); + f_string_ranges_resize(0, &setting->objects); f_string_ranges_resize(0, &setting->comments); f_string_rangess_resize(0, &setting->contents); diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index b14f227..dc18df2 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -123,6 +123,7 @@ extern "C" { * process_last_line: Process printing last line if necessary when loading in a file (or pipe). * process_load_depth: Process loading of the depth related parameters when loading the settings. * process_normal: Process normally (data from parameters and files). + * process_pipe: Process data piped to the program from standard input (stdin). * * process_at: Process at parameter, usually called by the process_normal() callback. * process_columns: Process columns parameter, usually called by the process_normal() callback. @@ -144,6 +145,7 @@ extern "C" { void (*process_last_line)(void * const main); void (*process_load_depth)(const f_console_arguments_t arguments, void * const main); void (*process_normal)(void * const main); + void (*process_pipe)(void * const main); void (*process_at)(void * const main, const bool names[], const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); void (*process_columns)(void * const main, const bool names[]); @@ -154,7 +156,7 @@ extern "C" { void (*print_at)(void * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); void (*print_object)(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits); - void (*print_content)(fl_print_t * const print, const f_array_length_t at, const uint8_t quote, const f_fss_delimits_t delimits); + void (*print_content)(fl_print_t * const print, const f_string_range_t range, const uint8_t quote, const f_fss_delimits_t delimits); void (*print_content_ignore)(fl_print_t * const print); void (*print_object_end)(fl_print_t * const print); void (*print_set_end)(fl_print_t * const print); @@ -293,10 +295,11 @@ extern "C" { * * @param depth * The depth to deallocate. + * * Must not be NULL. */ #ifndef _di_fss_read_depth_delete_ - extern f_status_t fss_read_depth_delete(fss_read_depth_t * const depth); + extern void fss_read_depth_delete(fss_read_depth_t * const depth); #endif // _di_fss_read_depth_delete_ /** @@ -306,6 +309,7 @@ extern "C" { * The new size to use. * @param depths * The depths to resize. + * * Must not be NULL. * * @return @@ -328,6 +332,7 @@ extern "C" { * The new size to use. * @param files * The files to resize. + * * Must not be NULL. * * @return @@ -336,8 +341,10 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_string_ranges_resize(). * * @see f_memory_resize() + * @see f_string_ranges_resize() */ #ifndef _di_fss_read_files_resize_ extern f_status_t fss_read_files_resize(const f_array_length_t length, fss_read_files_t * const files); diff --git a/level_3/fss_read/c/main/fss_read.c b/level_3/fss_read/c/main/fss_read.c index f5e0f51..3053a80 100644 --- a/level_3/fss_read/c/main/fss_read.c +++ b/level_3/fss_read/c/main/fss_read.c @@ -9,21 +9,10 @@ extern "C" { if (!main) return F_false; - if (main->setting.delimit_mode == fss_read_delimit_mode_none_e) { - return F_false; - } - - if (main->setting.delimit_mode == fss_read_delimit_mode_all_e) { - return F_true; - } - - if (depth < main->setting.delimit_depth) { - return main->setting.delimit_mode == fss_read_delimit_mode_content_lesser_e; - } - - if (depth == main->setting.delimit_depth) { - return F_true; - } + if (main->setting.delimit_mode == fss_read_delimit_mode_none_e) return F_false; + if (main->setting.delimit_mode == fss_read_delimit_mode_all_e) return F_true; + if (depth < main->setting.delimit_depth) return main->setting.delimit_mode == fss_read_delimit_mode_content_lesser_e; + if (depth == main->setting.delimit_depth) return F_true; return main->setting.delimit_mode == fss_read_delimit_mode_content_greater_e; } @@ -107,7 +96,7 @@ extern "C" { } if (F_status_is_error_not(main->setting.state.status)) { - if (main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e | fss_read_main_flag_object_open_e | fss_read_main_flag_content_next_e | fss_read_main_flag_content_end_e)) { + if (main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e)) { if (main->callback.process_normal) { main->callback.process_normal(void_main); } @@ -180,7 +169,7 @@ extern "C" { fss_read_print_number(&main->program.output, 1); } else { - fss_read_print_content(&main->program.output, range, main->setting.quotes_content.array[at], delimits_content); + fss_read_print_content(&main->program.output, range, main->setting.quotes_content.array[at].array[0], delimits_content); } main->setting.state.status = F_success; @@ -207,7 +196,7 @@ extern "C" { else { range.stop = main->setting.contents.array[at].array[0].stop; - fss_read_print_content(&main->program.output, range, main->setting.quotes_content.array[at], delimits_content); + fss_read_print_content(&main->program.output, range, main->setting.quotes_content.array[at].array[0], delimits_content); f_print_dynamic_raw(f_string_eol_s, main->program.output.to); } @@ -226,16 +215,11 @@ extern "C" { f_string_static_t fss_read_file_identify(const f_array_length_t at, const fss_read_files_t files) { for (f_array_length_t i = 0; i < files.used; ++i) { - - if (at >= files.array[i].range.start && at <= files.array[i].range.stop) { - return files.array[i].name; - } + if (at >= files.array[i].range.start && at <= files.array[i].range.stop) return files.array[i].name; } // for // When stopped after the end of the buffer, the last file in the list is the correct file. - if (at > files.array[files.used - 1].range.stop) { - return files.array[files.used - 1].name; - } + if (at > files.array[files.used - 1].range.stop) return files.array[files.used - 1].name; return f_string_empty_s; } @@ -255,7 +239,7 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_string_dynamic_append_assure), fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); + fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_string_dynamic_append_assure), fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); } } #endif // _di_fss_read_process_last_line_ diff --git a/level_3/fss_read/c/main/fss_read.h b/level_3/fss_read/c/main/fss_read.h index 25c5f9f..0f57c42 100644 --- a/level_3/fss_read/c/main/fss_read.h +++ b/level_3/fss_read/c/main/fss_read.h @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -81,7 +82,7 @@ extern "C" { * F_false if to not apply delimits (fallback when main is NULL). */ #ifndef _di_fss_read_delimit_content_is_ - extern f_status_t fss_read_delimit_content_is(fss_read_main_t * const main, const f_array_length_t depth) F_attribute_visibility_internal_d; + extern f_status_t fss_read_delimit_content_is(fss_read_main_t * const main, const f_array_length_t depth); #endif // _di_fss_read_delimit_content_is_ /** @@ -101,7 +102,7 @@ extern "C" { * F_false if to not apply delimits (fallback when main is NULL). */ #ifndef _di_fss_read_delimit_object_is_ - extern f_status_t fss_read_delimit_object_is(fss_read_main_t * const main, const f_array_length_t depth) F_attribute_visibility_internal_d; + extern f_status_t fss_read_delimit_object_is(fss_read_main_t * const main, const f_array_length_t depth); #endif // _di_fss_read_delimit_object_is_ /** @@ -161,6 +162,7 @@ extern "C" { * @param line * The current line being processed. * This will be incremented as necessary. + * * Must not be NULL. * * @return @@ -185,7 +187,7 @@ extern "C" { * On failure to identify, an empty string is returned. */ #ifndef _di_fss_read_file_identify_ - extern f_string_static_t fss_read_file_identify(const f_array_length_t at, const fss_read_files_t files) F_attribute_visibility_internal_d; + extern f_string_static_t fss_read_file_identify(const f_array_length_t at, const fss_read_files_t files); #endif // _di_fss_read_file_identify_ /** diff --git a/level_3/fss_read/c/main/print/data.c b/level_3/fss_read/c/main/print/data.c index 1e823f1..8b95673 100644 --- a/level_3/fss_read/c/main/print/data.c +++ b/level_3/fss_read/c/main/print/data.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_fss_read_print_at_ - void fss_read_print_at(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content) { + f_status_t fss_read_print_at(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content) { if (!print || !print->custom) return F_status_set_error(F_output_not); @@ -28,7 +28,7 @@ extern "C" { if ((main->setting.flag & fss_read_main_flag_content_e) && main->setting.contents.array[at].used) { if (main->callback.print_content) { - main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at], delimits_content); + main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at].array[0], delimits_content); } } @@ -48,8 +48,8 @@ extern "C" { fss_read_main_t * const main = (fss_read_main_t *) print->custom; - if (data.callback.print_content_ignore) { - data.callback.print_content_ignore(&main->program.output); + if (main->callback.print_content_ignore) { + main->callback.print_content_ignore(&main->program.output); } if (main->setting.flag & fss_read_main_flag_original_e) { @@ -66,24 +66,26 @@ extern "C" { } } - if (data.callback.print_content_ignore) { - data.callback.print_content_ignore(&main->program.output); + if (main->callback.print_content_ignore) { + main->callback.print_content_ignore(&main->program.output); } return F_none; } -#endif _di_fss_read_print_content_ +#endif // _di_fss_read_print_content_ #ifndef _di_fss_read_print_content_ignore_ - void fss_read_print_content_ignore(fl_print_t * const print) { + f_status_t fss_read_print_content_ignore(fl_print_t * const print) { if (!print || !print->custom) return F_status_set_error(F_output_not); - fss_read_main_t * const main = (fss_read_main_t *) print->custom, + fss_read_main_t * const main = (fss_read_main_t *) print->custom; if (main->setting.flag & fss_read_main_flag_pipe_e) { fll_print_dynamic_raw(fss_read_pipe_content_ignore_s, print->to); } + + return F_none; } #endif // _di_fss_read_print_content_ignore_ @@ -103,40 +105,40 @@ extern "C" { if (!print || !print->custom) return F_status_set_error(F_output_not); - fss_read_main_t * const main = (fss_read_main_t *) print->custom, + fss_read_main_t * const main = (fss_read_main_t *) print->custom; if (at >= main->setting.objects.used) return F_output_not; - if (main->setting.flag & fss_read_data_option_trim_d) { - if (main->setting.flag & fss_read_data_option_original_d) { - if (main->setting.quotes.array[at]) { + if (main->setting.flag & fss_read_main_flag_trim_e) { + if (main->setting.flag & fss_read_main_flag_original_e) { + if (main->setting.quotes_object.array[at]) { fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]); } fll_print_trim_dynamic_partial(main->setting.buffer, main->setting.objects.array[at], main->program.output.to); - if (main->setting.quotes.array[at]) { + if (main->setting.quotes_object.array[at]) { fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]); } } else { - fll_print_trim_except_dynamic_partial(main->setting.buffer, main->setting.objects.array[at], delimits_object, main->program.output.to); + fll_print_trim_except_dynamic_partial(main->setting.buffer, main->setting.objects.array[at], delimits, main->program.output.to); } } else { if (main->setting.flag & fss_read_main_flag_original_e) { - if (main->setting.quotes.array[at]) { + if (main->setting.quotes_object.array[at]) { fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]); } fll_print_dynamic_partial(main->setting.buffer, main->setting.objects.array[at], main->program.output.to); - if (main->setting.quotes.array[at]) { + if (main->setting.quotes_object.array[at]) { fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]); } } else { - fll_print_except_dynamic_partial(main->setting.buffer, main->setting.objects.array[at], delimits_object, main->program.output.to); + fll_print_except_dynamic_partial(main->setting.buffer, main->setting.objects.array[at], delimits, main->program.output.to); } } @@ -149,7 +151,7 @@ extern "C" { if (!print || !print->custom) return F_status_set_error(F_output_not); - fss_read_main_t * const main = (fss_read_main_t *) print->custom, + fss_read_main_t * const main = (fss_read_main_t *) print->custom; if (main->setting.flag & fss_read_main_flag_pipe_e) { fll_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); @@ -168,6 +170,8 @@ extern "C" { } */ } + + return F_none; } #endif // _di_fss_read_print_object_end_ @@ -194,7 +198,7 @@ extern "C" { if (!print || !print->custom) return F_status_set_error(F_output_not); - fss_read_main_t * const main = (fss_read_main_t *) print->custom, + fss_read_main_t * const main = (fss_read_main_t *) print->custom; if (main->setting.flag & fss_read_main_flag_pipe_e) { fll_print_dynamic_raw(fss_read_pipe_content_end_s, print->to); diff --git a/level_3/fss_read/c/main/print/data.h b/level_3/fss_read/c/main/print/data.h index 500a281..da206d2 100644 --- a/level_3/fss_read/c/main/print/data.h +++ b/level_3/fss_read/c/main/print/data.h @@ -89,7 +89,7 @@ extern "C" { * @see main.callback.print_set_end() */ #ifndef _di_fss_read_print_content_ - extern f_status_t fss_read_print_content(fl_print_t * const print, const f_array_length_t at, const uint8_t quote, const f_fss_delimits_t delimits); + extern f_status_t fss_read_print_content(fl_print_t * const print, const f_string_range_t range, const uint8_t quote, const f_fss_delimits_t delimits); #endif // _di_fss_read_print_content_ /** diff --git a/level_3/fss_read/c/main/print/error.c b/level_3/fss_read/c/main/print/error.c index 0faa7f3..7373fa7 100644 --- a/level_3/fss_read/c/main/print/error.c +++ b/level_3/fss_read/c/main/print/error.c @@ -28,28 +28,6 @@ extern "C" { } #endif // _di_fss_read_print_error_file_ -#ifndef _di_fss_read_print_error_parameter_same_times_at_least_ - f_status_t fss_read_print_error_parameter_same_times_at_least(fl_print_t * const print) { - - 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("%[%QMust specify the '%]", print->to, print->context, print->prefix, print->context); - fl_print_format("%[%r%r%]", print->to, print->notable, f_console_symbol_long_normal_s, fss_read_long_content_s, print->notable); - fl_print_format("%[' parameter at least the same number of times as the '%]", print->to, print->context, print->context); - fl_print_format("%[%r%r%]", print->to, print->notable, f_console_symbol_long_normal_s, fss_read_long_object_s, print->notable); - fl_print_format("%[' parameter when not specifying the '%]", print->to, print->context, print->context); - fl_print_format("%[%r%r%]", print->to, print->notable, f_console_symbol_long_normal_s, fss_read_long_partial_s, print->notable); - fl_print_format("%[' parameter.%]%r", print->to, print->context, print->context, f_string_eol_s); - - f_file_stream_unlock(print->to); - - return F_none; - } -#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) { @@ -128,24 +106,6 @@ extern "C" { } #endif // _di_fss_read_print_error_one_content_only_ -#ifndef _fss_read_print_error_prepend_only_whitespace_ - f_status_t fss_read_print_error_prepend_only_whitespace(fl_print_t * const print) { - - 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 value for the parameter '%]", print->to, print->set->error, print->prefix, print->set->error); - fl_print_format("%[%r%r%]", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_prepend_s, print->set->notable); - fl_print_format("%[' must only contain white space.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); - - f_file_stream_unlock(print->to); - - return F_none; - } -#endif // _fss_read_print_error_prepend_only_whitespace_ - #ifndef _di_fss_read_print_error_unsupported_eol_ f_status_t fss_read_print_error_unsupported_eol(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 35ccac4..20666a0 100644 --- a/level_3/fss_read/c/main/print/error.h +++ b/level_3/fss_read/c/main/print/error.h @@ -70,28 +70,6 @@ extern "C" { #endif // _di_fss_read_print_error_file_ /** - * Print an error message about the object and content parameters not being specified at least the same number of times when partial is not requested. - * - * @param print - * The output structure to print to. - * - * The print.custom is expected to be of type fss_read_main_t. - * - * This does not alter print.custom.setting.state.status. - * - * @return - * F_none on success. - * F_output_not on success, but no printing is performed. - * - * F_output_not (with error bit) if a parameter is NULL. - * - * @see fll_error_print() - */ -#ifndef _di_fss_read_print_error_parameter_same_times_at_least_ - extern f_status_t fss_read_print_error_parameter_same_times_at_least(fl_print_t * const print); -#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 @@ -195,26 +173,6 @@ extern "C" { #endif // _di_fss_read_print_error_one_content_only_ /** - * Print error when prepend parameter has something other than white space. - * - * @param print - * The output structure to print to. - * - * The print.custom is expected to be of type fss_read_main_t. - * - * This does not alter print.custom.setting.state.status. - * - * @return - * F_none on success. - * F_output_not on success, but no printing is performed. - * - * F_output_not (with error bit) if a parameter is NULL. - */ -#ifndef _fss_read_print_error_prepend_only_whitespace_ - extern f_status_t fss_read_print_error_prepend_only_whitespace(fl_print_t * const print); -#endif // _fss_read_print_error_prepend_only_whitespace_ - -/** * Print an error message about a parameter New Line character '\n' (U+000A) being unsupported. * * @param print diff --git a/level_3/fss_read/c/main/process_normal.c b/level_3/fss_read/c/main/process_normal.c index 93512c7..f39c25f 100644 --- a/level_3/fss_read/c/main/process_normal.c +++ b/level_3/fss_read/c/main/process_normal.c @@ -16,7 +16,7 @@ extern "C" { // For depth, most standards do not support nesting, so any depth greater than 0 can be predicted without processing the buffer. // For select, most standards do not support multiple select, so any select greater than 0 can be predicted without processing the buffer. - if (!(main->setting.flag & fss_read_main_flag_depth_multiple_e) && main->setting.depths.array[0].depth || !(main->setting.flag & fss_read_main_flag_content_multiple_e) && ((main->setting.flag & fss_read_main_flag_select_e) && data->select)) { + if (!(main->setting.flag & fss_read_main_flag_depth_multiple_e) && main->setting.depths.array[0].depth || !(main->setting.flag & fss_read_main_flag_content_multiple_e) && ((main->setting.flag & fss_read_main_flag_select_e) && main->setting.select)) { if (main->setting.flag & fss_read_main_flag_total_e) { fss_read_print_number(&main->program.output, 0); } @@ -86,7 +86,7 @@ extern "C" { #endif // _di_fss_read_process_normal_ #ifndef _di_fss_read_process_normal_at_ - void fss_read_process_normal_at(void * const main, const bool names[], const f_array_lengths_t delimits_object, f_array_lengths_t delimits_content) { + void fss_read_process_normal_at(void * const void_main, const bool names[], const f_array_lengths_t delimits_object, f_array_lengths_t delimits_content) { if (!void_main) return; @@ -106,7 +106,7 @@ extern "C" { if (main->setting.flag & (fss_read_main_flag_line_e | fss_read_main_flag_line_single_e) == (fss_read_main_flag_line_e | fss_read_main_flag_line_single_e)) { if (main->setting.line) { if (main->setting.flag & fss_read_main_flag_total_e) { - fss_read_print_zero(main); + fss_read_print_number(&main->program.output, 0); } main->setting.state.status = F_none; @@ -135,13 +135,13 @@ extern "C" { line = 0; - if (data->option & fss_basic_list_read_data_option_total_d) { + if (main->setting.flag & fss_read_main_flag_total_e) { // Total is always 1 in this case because "line" parameter forces a single line. fss_read_print_number(&main->program.output, 1); } else { - fss_read_process_at_line(main, data, i, delimits_object, delimits_content, &line); + fss_read_process_at_line(main, i, delimits_object, delimits_content, &line); } if (main->setting.state.status == F_success) { @@ -155,7 +155,7 @@ extern "C" { } else if (main->setting.flag & fss_read_main_flag_total_e) { if (main->setting.flag & fss_read_main_flag_line_single_e) { - fss_read_print_number(main, main->setting.contents.array[i].used ? 1 : 0); + fss_read_print_number(&main->program.output, main->setting.contents.array[i].used ? 1 : 0); } else { total = 0; @@ -201,7 +201,7 @@ extern "C" { #endif // _di_fss_read_process_normal_at_ #ifndef _di_fss_read_process_normal_columns_ - void fss_read_process_normal_columns(void * const main, const bool names[]) { + void fss_read_process_normal_columns(void * const void_main, const bool names[]) { if (!void_main) return; @@ -234,14 +234,12 @@ extern "C" { #endif // _di_fss_read_process_normal_columns_ #ifndef _di_fss_read_process_normal_line_ - void fss_read_process_normal_line(void * const main, const bool names[]) { + void fss_read_process_normal_line(void * const void_main, const bool names[]) { if (!void_main) return; fss_read_main_t * const main = (fss_read_main_t *) void_main; - const f_array_lengths_t * const delimits = !(main->setting.flag & fss_read_main_flag_original_e) && fss_read_delimit_object_is(main, 0) ? &main->setting.delimits : &fss_read_except_none_c; - f_array_length_t line = 0; for (f_array_length_t i = 0; i < main->setting.contents.used; ++i) { @@ -269,7 +267,16 @@ extern "C" { if (line == main->setting.line) { if (main->callback.print_at) { - main->callback.print_at(main, i, *delimits, fss_read_except_none_c); + main->callback.print_at( + main, + i, + !(main->setting.flag & fss_read_main_flag_original_e) && fss_read_delimit_object_is(main, 0) + ? main->setting.delimits_object + : fss_read_except_none_c, + !(main->setting.flag & fss_read_main_flag_original_e) && fss_read_delimit_content_is(main, 0) + ? main->setting.delimits_content + : fss_read_except_none_c + ); } break; @@ -283,7 +290,7 @@ extern "C" { #endif // _di_fss_read_process_normal_line_ #ifndef _di_fss_read_process_normal_name_ - void fss_read_process_normal_name(void * const main, const bool names[]) { + void fss_read_process_normal_name(void * const void_main, bool names[]) { if (!void_main) return; @@ -299,7 +306,7 @@ extern "C" { if (fss_read_signal_check(main)) return; - if (f_compare_dynamic_partial_except_trim_dynamic(main->setting.depths.array[0].value_name, main->setting.buffer, main->setting.objects.array[i], fss_read_except_none_c, main->setting.delimits) == F_equal_to) { + if (f_compare_dynamic_partial_except_trim_dynamic(main->setting.depths.array[0].value_name, main->setting.buffer, main->setting.objects.array[i], fss_read_except_none_c, main->setting.delimits_object) == F_equal_to) { names[i] = F_true; } } // for @@ -309,7 +316,7 @@ extern "C" { if (fss_read_signal_check(main)) return; - if (f_compare_dynamic_partial_except_dynamic(main->setting.depths.array[0].value_name, main->setting.buffer, main->setting.objects.array[i], fss_read_except_none_c, main->setting.delimits) == F_equal_to) { + if (f_compare_dynamic_partial_except_dynamic(main->setting.depths.array[0].value_name, main->setting.buffer, main->setting.objects.array[i], fss_read_except_none_c, main->setting.delimits_object) == F_equal_to) { names[i] = F_true; } } // for @@ -324,7 +331,7 @@ extern "C" { #endif // _di_fss_read_process_normal_name_ #ifndef _di_fss_read_process_normal_total_ - void fss_read_process_normal_total(void * const main, const bool names[]) { + void fss_read_process_normal_total(void * const void_main, const bool names[]) { if (!void_main) return; diff --git a/level_3/fss_read/c/main/process_normal.h b/level_3/fss_read/c/main/process_normal.h index 177a1d7..dfa3e2c 100644 --- a/level_3/fss_read/c/main/process_normal.h +++ b/level_3/fss_read/c/main/process_normal.h @@ -141,7 +141,7 @@ extern "C" { * @see fss_read_signal_check() */ #ifndef _di_fss_read_process_normal_name_ - extern void fss_read_process_normal_name(void * const main, const bool names[]); + extern void fss_read_process_normal_name(void * const main, bool names[]); #endif // _di_fss_read_process_normal_name_ /** diff --git a/level_3/fss_read/c/payload/fss_read.c b/level_3/fss_read/c/payload/fss_read.c index 89685f0..fb2073d 100644 --- a/level_3/fss_read/c/payload/fss_read.c +++ b/level_3/fss_read/c/payload/fss_read.c @@ -30,13 +30,14 @@ extern "C" { f_array_length_t length = 0; f_string_range_t range = f_string_range_t_initialize; + // @todo much of this is copied from fss_write and needs to be updated or removed accordingly. + const f_array_length_t used_objects = main->setting.objects.used; - const f_array_length_t used_contentss = main->setting.contentss.used; - const f_array_length_t used_ignoress = main->setting.ignoress.used; + const f_array_length_t used_contents = main->setting.contents.used; + // @fixme really? why am I setting a pointer to the used position, which may not even be allocated? Review this and perhaps first pre-allocate the space so the used is within the size. main->setting.object = &main->setting.objects.array[used_objects]; - main->setting.contents = &main->setting.contentss.array[used_contentss]; - main->setting.ignores = &main->setting.ignoress.array[used_ignoress]; + main->setting.contents = &main->setting.contents.array[used_contents]; // 0x0 = nothing printed, 0x1 = something printed, 0x2 = ignore enabled, 0x4 = added Content for Object, 0x8 = "payload" matched. uint8_t flag = 0; @@ -70,19 +71,9 @@ extern "C" { return; } - // This is processed in a single set, so there is only ever one Ignores added. - main->setting.state.status = f_string_rangess_increase(main->setting.state.step_small, &main->setting.ignoress); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_rangess_increase)); - - return; - } - // Reset all of the used data before starting the loop. main->setting.object->used = 0; main->setting.contents->used = 0; - main->setting.ignores->used = 0; for (;;) { @@ -297,7 +288,6 @@ extern "C" { // Reset all of the used data for next set. main->setting.object->used = 0; main->setting.contents->used = 0; - main->setting.ignores->used = 0; continue; } @@ -327,7 +317,6 @@ extern "C" { // Reset all of the used data for next set. main->setting.object->used = 0; main->setting.contents->used = 0; - main->setting.ignores->used = 0; } } // for @@ -342,10 +331,8 @@ extern "C" { main->setting.buffer.used = 0; main->setting.object->used = 0; main->setting.contents->used = 0; - main->setting.ignores->used = 0; main->setting.objects.used = used_objects; - main->setting.contentss.used = used_contentss; - main->setting.ignoress.used = used_ignoress; + main->setting.contentss.used = used_contents; if (F_status_is_error_not(main->setting.state.status)) { if (flag & 0x1) { @@ -476,7 +463,7 @@ extern "C" { const f_string_static_t *prepend = 0; if (main->setting.flag & fss_read_main_flag_prepend_e) { - 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]; + 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].location]]; prepend = &main->program.parameters.arguments.array[index]; } @@ -500,14 +487,12 @@ extern "C" { } if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { - if (main->setting.flag & fss_read_main_flag_content_end_e) { - main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_close_s, &main->setting.buffer); + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_close_s, &main->setting.buffer); - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - return; - } + return; } } } diff --git a/level_3/fss_read/c/payload/fss_read.h b/level_3/fss_read/c/payload/fss_read.h index 618b1c4..b68c29b 100644 --- a/level_3/fss_read/c/payload/fss_read.h +++ b/level_3/fss_read/c/payload/fss_read.h @@ -40,6 +40,7 @@ // FLL-2 includes. #include +#include #include #include #include @@ -52,6 +53,7 @@ #include #include #include +#include #include #include #include diff --git a/level_3/fss_read/c/payload/main.c b/level_3/fss_read/c/payload/main.c index a629b5e..c967562 100644 --- a/level_3/fss_read/c/payload/main.c +++ b/level_3/fss_read/c/payload/main.c @@ -19,7 +19,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_payload_standard_s; - // @todo see if there needs to be this: data.callback.process_pipe = &fss_read_payload_process_pipe; + data.callback.process_pipe = &fss_read_payload_process_pipe; data.callback.process_help = &fss_read_payload_process_help; data.callback.process_last_line = &fss_read_process_last_line; //data.callback.process_load_depth = &fss_read_setting_load_depth; diff --git a/level_3/fss_read/data/build/settings b/level_3/fss_read/data/build/settings index fb7a0c2..97dc17c 100644 --- a/level_3/fss_read/data/build/settings +++ b/level_3/fss_read/data/build/settings @@ -37,7 +37,7 @@ build_libraries-individual_thread -lf_thread build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_library main/fss_read.c main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/static.c main/common/string.c main/common/type.c main/print/error.c main/print/message.c main/process_normal.c main/signal.c main/thread.c +build_sources_library main/fss_read.c main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/static.c main/common/string.c main/common/type.c main/print/data.c main/print/error.c main/print/message.c main/process_normal.c main/signal.c main/thread.c build_sources_library basic/fss_read.c basic/common.c basic/print.c build_sources_library basic_list/fss_read.c basic_list/common.c basic_list/print.c build_sources_library embedded_list/fss_read.c embedded_list/common.c embedded_list/print.c @@ -45,7 +45,7 @@ build_sources_library extended/fss_read.c extended/common.c extended/print.c build_sources_library extended_list/fss_read.c extended_list/common.c extended_list/print.c build_sources_library payload/fss_read.c payload/common.c payload/print.c -build_sources_headers main/fss_read.h main/common.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/static.h main/common/string.h main/common/type.h main/print/error.h main/print/message.h main/process_normal.h main/signal.h main/thread.h +build_sources_headers main/fss_read.h main/common.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/static.h main/common/string.h main/common/type.h main/print/data.h main/print/error.h main/print/message.h main/process_normal.h main/signal.h main/thread.h build_sources_headers basic/fss_read.h basic/common.h basic/print.h basic/private-common.h build_sources_headers basic_list/fss_read.h basic_list/common.h basic_list/print.h build_sources_headers embedded_list/fss_read.h embedded_list/common.h embedded_list/print.h diff --git a/level_3/fss_write/c/main/common.c b/level_3/fss_write/c/main/common.c index 26e2484..fed315f 100644 --- a/level_3/fss_write/c/main/common.c +++ b/level_3/fss_write/c/main/common.c @@ -305,7 +305,7 @@ extern "C" { } 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_array_length_t index = main->program.parameters.array[fss_write_parameter_prepend_e].values.array[main->program.parameters.array[fss_write_parameter_prepend_e].values.used - 1]; + const f_array_length_t index = main->program.parameters.array[fss_write_parameter_prepend_e].values.array[main->program.parameters.array[fss_write_parameter_prepend_e].location]; main->setting.prepend.used = 0; diff --git a/level_3/fss_write/c/payload/fss_write.c b/level_3/fss_write/c/payload/fss_write.c index 6b2b4c8..7e2e8c5 100644 --- a/level_3/fss_write/c/payload/fss_write.c +++ b/level_3/fss_write/c/payload/fss_write.c @@ -486,7 +486,7 @@ extern "C" { const f_string_static_t *prepend = 0; if (main->setting.flag & fss_write_main_flag_prepend_e) { - const f_array_length_t index = main->program.parameters.array[fss_write_parameter_prepend_e].values.array[main->program.parameters.array[fss_write_parameter_prepend_e].values.used - 1]; + const f_array_length_t index = main->program.parameters.array[fss_write_parameter_prepend_e].values.array[main->program.parameters.array[fss_write_parameter_prepend_e].location]; prepend = &main->program.parameters.arguments.array[index]; } diff --git a/level_3/iki_read/c/main/common.c b/level_3/iki_read/c/main/common.c index 29aa088..1beaa74 100644 --- a/level_3/iki_read/c/main/common.c +++ b/level_3/iki_read/c/main/common.c @@ -129,7 +129,7 @@ extern "C" { return; } - const f_array_length_t index = main->program.parameters.array[iki_read_parameter_at_e].values.array[main->program.parameters.array[iki_read_parameter_at_e].values.used - 1]; + const f_array_length_t index = main->program.parameters.array[iki_read_parameter_at_e].values.array[main->program.parameters.array[iki_read_parameter_at_e].location]; main->setting.at = 0; @@ -162,7 +162,7 @@ extern "C" { } if (main->program.parameters.array[iki_read_parameter_line_e].result & f_console_result_value_e) { - const f_array_length_t index = main->program.parameters.array[iki_read_parameter_line_e].values.array[main->program.parameters.array[iki_read_parameter_line_e].values.used - 1]; + const f_array_length_t index = main->program.parameters.array[iki_read_parameter_line_e].values.array[main->program.parameters.array[iki_read_parameter_line_e].location]; main->setting.line = 0; -- 1.8.3.1