From 2ae0296f02ab23a4f2eda25c1da468003942a752 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 30 Mar 2022 18:47:13 -0500 Subject: [PATCH] Update: Move the program data into the main for fss_embedded_list_read. Replace fss_embedded_list_read_main_t with fll_program_data_t and fss_embedded_list_read_data_t. Move parameter initialization and deallocation for FLL program data into main.c. --- level_3/fss_embedded_list_read/c/common.c | 15 - level_3/fss_embedded_list_read/c/common.h | 74 ----- .../c/fss_embedded_list_read.c | 125 ++++----- .../c/fss_embedded_list_read.h | 6 +- level_3/fss_embedded_list_read/c/main.c | 8 +- level_3/fss_embedded_list_read/c/private-common.c | 35 ++- level_3/fss_embedded_list_read/c/private-common.h | 58 +++- level_3/fss_embedded_list_read/c/private-print.c | 34 +-- level_3/fss_embedded_list_read/c/private-print.h | 18 +- level_3/fss_embedded_list_read/c/private-read.c | 310 ++++++++++----------- level_3/fss_embedded_list_read/c/private-read.h | 42 +-- 11 files changed, 340 insertions(+), 385 deletions(-) diff --git a/level_3/fss_embedded_list_read/c/common.c b/level_3/fss_embedded_list_read/c/common.c index 97edc75..5379a05 100644 --- a/level_3/fss_embedded_list_read/c/common.c +++ b/level_3/fss_embedded_list_read/c/common.c @@ -59,21 +59,6 @@ extern "C" { const f_string_static_t fss_embedded_list_read_delimit_mode_name_lesser_s = macro_f_string_static_t_initialize(FSS_EMBEDDED_LIST_READ_delimit_mode_name_lesser_s, 0, FSS_EMBEDDED_LIST_READ_delimit_mode_name_lesser_s_length); #endif // _di_fss_embedded_list_read_delimit_mode_ -#ifndef _di_fss_embedded_list_read_main_delete_ - f_status_t fss_embedded_list_read_main_delete(fss_embedded_list_read_main_t * const main) { - - f_console_parameters_delete(&main->parameters); - - macro_f_fss_nest_t_delete_simple(main->nest); - - f_string_dynamic_resize(0, &main->buffer); - - macro_f_color_context_t_delete_simple(main->context); - - return F_none; - } -#endif // _di_fss_embedded_list_read_main_delete_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_embedded_list_read/c/common.h b/level_3/fss_embedded_list_read/c/common.h index 1ce3935..d526eaf 100644 --- a/level_3/fss_embedded_list_read/c/common.h +++ b/level_3/fss_embedded_list_read/c/common.h @@ -269,80 +269,6 @@ extern "C" { }; #endif // _di_fss_embedded_list_read_delimit_modes_ -/** - * The main program data. - * - * parameters: The state of pre-defined parameters passed to the program. - * remaining: The remaining, non-pre-defined parameters, passed to the program. - * process_pipe: Designate whether or not to process the input pipe. - * output: The output file for general printing. - * error: The output file for error printing. - * warning: The output file for warning printing. - * signal: The process signal management structure. - * context: The color context. - */ -#ifndef _di_fss_embedded_list_read_main_t_ - typedef struct { - f_console_parameters_t parameters; - - uint16_t signal_check; - f_array_lengths_t remaining; - bool process_pipe; - - fl_print_t output; - fl_print_t error; - fl_print_t warning; - - f_signal_t signal; - - f_string_dynamic_t buffer; - f_fss_nest_t nest; - f_string_quantity_t quantity; - - uint8_t delimit_mode; - f_array_length_t delimit_depth; - - f_color_context_t context; - } fss_embedded_list_read_main_t; - - #define fss_embedded_list_read_main_t_initialize \ - { \ - f_console_parameters_t_initialize, \ - 0, \ - f_array_lengths_t_initialize, \ - F_false, \ - fl_print_t_initialize, \ - macro_fl_print_t_initialize_error(), \ - macro_fl_print_t_initialize_warning(), \ - f_signal_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_fss_nest_t_initialize, \ - f_string_quantity_t_initialize, \ - fss_embedded_list_read_delimit_mode_all_e, \ - 0, \ - f_color_context_t_initialize, \ - } -#endif // _di_fss_embedded_list_read_main_t_ - -/** - * Deallocate main. - * - * Be sure to call this after executing fss_embedded_list_read_main(). - * - * @param main - * The main program data. - * - * @return - * F_none on success. - * - * Status codes (with error bit) are returned on any problem. - * - * @see fss_embedded_list_read_main() - */ -#ifndef _di_fss_embedded_list_read_main_delete_ - extern f_status_t fss_embedded_list_read_main_delete(fss_embedded_list_read_main_t * const main); -#endif // _di_fss_embedded_list_read_main_delete_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c index 9219ebc..27d91d5 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c @@ -119,14 +119,10 @@ extern "C" { #endif // _di_fss_embedded_list_read_print_help_ #ifndef _di_fss_embedded_list_read_main_ - f_status_t fss_embedded_list_read_main(fss_embedded_list_read_main_t * const main, const f_console_arguments_t *arguments) { + f_status_t fss_embedded_list_read_main(fll_program_data_t * const main, const f_console_arguments_t *arguments) { f_status_t status = F_none; - f_console_parameter_t parameters[] = fss_embedded_list_read_console_parameter_t_initialize; - main->parameters.array = parameters; - main->parameters.used = fss_embedded_list_read_total_parameters_d; - { f_console_parameter_id_t ids[3] = { fss_embedded_list_read_parameter_no_color_e, fss_embedded_list_read_parameter_light_e, fss_embedded_list_read_parameter_dark_e }; const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 3); @@ -153,11 +149,7 @@ extern "C" { fll_program_parameter_process_empty(&main->context, sets); } - if (F_status_is_error(status)) { - fss_embedded_list_read_main_delete(main); - - return F_status_set_error(status); - } + if (F_status_is_error(status)) return status; } // Identify priority of verbosity related parameters. @@ -168,11 +160,7 @@ extern "C" { status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - if (F_status_is_error(status)) { - fss_embedded_list_read_main_delete(main); - - return status; - } + if (F_status_is_error(status)) return status; if (choice == fss_embedded_list_read_parameter_verbosity_quiet_e) { main->output.verbosity = f_console_verbosity_quiet_e; @@ -196,14 +184,16 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; + fss_embedded_list_read_data_t data = fss_embedded_list_read_data_t_initialize; + data.main = main; + data.argv = main->parameters.arguments.array; status = F_none; if (main->parameters.array[fss_embedded_list_read_parameter_help_e].result == f_console_result_found_e) { fss_embedded_list_read_print_help(main->output.to, main->context); - fss_embedded_list_read_main_delete(main); + fss_embedded_list_read_data_delete(&data); return F_none; } @@ -211,7 +201,7 @@ extern "C" { if (main->parameters.array[fss_embedded_list_read_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_embedded_list_read_program_version_s); - fss_embedded_list_read_main_delete(main); + fss_embedded_list_read_data_delete(&data); return F_none; } @@ -339,7 +329,7 @@ extern "C" { } else if (main->parameters.array[fss_embedded_list_read_parameter_delimit_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_embedded_list_read_parameter_delimit_e].values.array[0]; - f_array_length_t length = argv[index].used; + f_array_length_t length = data.argv[index].used; if (!length) { flockfile(main->error.to.stream); @@ -352,23 +342,23 @@ extern "C" { status = F_status_set_error(F_parameter); } - else if (fl_string_dynamic_compare_string(fss_embedded_list_read_delimit_mode_name_none_s.string, argv[index], fss_embedded_list_read_delimit_mode_name_none_s.used) == F_equal_to) { - main->delimit_mode = fss_embedded_list_read_delimit_mode_none_e; + else if (fl_string_dynamic_compare_string(fss_embedded_list_read_delimit_mode_name_none_s.string, data.argv[index], fss_embedded_list_read_delimit_mode_name_none_s.used) == F_equal_to) { + data.delimit_mode = fss_embedded_list_read_delimit_mode_none_e; } - else if (fl_string_dynamic_compare_string(fss_embedded_list_read_delimit_mode_name_all_s.string, argv[index], fss_embedded_list_read_delimit_mode_name_all_s.used) == F_equal_to) { - main->delimit_mode = fss_embedded_list_read_delimit_mode_all_e; + else if (fl_string_dynamic_compare_string(fss_embedded_list_read_delimit_mode_name_all_s.string, data.argv[index], fss_embedded_list_read_delimit_mode_name_all_s.used) == F_equal_to) { + data.delimit_mode = fss_embedded_list_read_delimit_mode_all_e; } else { - main->delimit_mode = fss_embedded_list_read_delimit_mode_depth_e; + data.delimit_mode = fss_embedded_list_read_delimit_mode_depth_e; - if (argv[index].string[length - 1] == fss_embedded_list_read_delimit_mode_name_greater_s.string[0]) { - main->delimit_mode = fss_embedded_list_read_delimit_mode_depth_greater_e; + if (data.argv[index].string[length - 1] == fss_embedded_list_read_delimit_mode_name_greater_s.string[0]) { + data.delimit_mode = fss_embedded_list_read_delimit_mode_depth_greater_e; // Shorten the length to better convert the remainder to a number. --length; } - else if (argv[index].string[length - 1] == fss_embedded_list_read_delimit_mode_name_lesser_s.string[0]) { - main->delimit_mode = fss_embedded_list_read_delimit_mode_depth_lesser_e; + else if (data.argv[index].string[length - 1] == fss_embedded_list_read_delimit_mode_name_lesser_s.string[0]) { + data.delimit_mode = fss_embedded_list_read_delimit_mode_depth_lesser_e; // Shorten the length to better convert the remainder to a number. --length; @@ -377,14 +367,14 @@ extern "C" { f_string_range_t range = macro_f_string_range_t_initialize2(length); // Ignore leading plus sign. - if (argv[index].string[0] == f_string_ascii_plus_s.string[0]) { + if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { ++range.start; } - status = fl_conversion_dynamic_partial_to_number_unsigned(argv[index], range, &main->delimit_depth); + status = fl_conversion_dynamic_partial_to_number_unsigned(data.argv[index], range, &data.delimit_depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_number_unsigned", F_true, fss_embedded_list_read_long_delimit_s, argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_number_unsigned", F_true, fss_embedded_list_read_long_delimit_s, data.argv[index]); } } } @@ -396,10 +386,8 @@ extern "C" { f_fss_delimits_t contents_delimits = f_fss_delimits_t_initialize; f_fss_comments_t comments = f_fss_comments_t_initialize; - const f_array_length_t original_size = main->quantity.total; - if (F_status_is_error_not(status)) { - status = fss_embedded_list_read_main_preprocess_depth(main, &depths); + status = fss_embedded_list_read_main_preprocess_depth(&data, &depths); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "fss_embedded_list_read_main_preprocess_depth", F_true); @@ -423,13 +411,13 @@ extern "C" { file.id = F_type_descriptor_input_d; - status = f_file_read(file, &main->buffer); + status = f_file_read(file, &data.buffer); if (F_status_is_error(status)) { fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); } else { - status = fss_embedded_list_read_main_process_file(main, f_string_ascii_minus_s, depths, &objects_delimits, &contents_delimits, &comments); + status = fss_embedded_list_read_main_process_file(&data, f_string_ascii_minus_s, depths, &objects_delimits, &contents_delimits, &comments); if (F_status_is_error(status)) { fll_error_file_print(main->error, F_status_set_fine(status), "fss_embedded_list_read_main_process_file", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); @@ -437,15 +425,17 @@ extern "C" { } // Clear buffers before continuing. - macro_f_fss_nest_t_delete_simple(main->nest); - f_string_dynamic_resize(0, &main->buffer); + macro_f_fss_nest_t_delete_simple(data.nest); + f_string_dynamic_resize(0, &data.buffer); } if (F_status_is_error_not(status) && main->parameters.remaining.used > 0) { + f_array_length_t total = 0; + for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % fss_embedded_list_read_signal_check_d)) { - if (fss_embedded_list_read_signal_received(main)) { + if (fss_embedded_list_read_signal_received(&data)) { status = F_status_set_error(F_interrupt); break; @@ -456,67 +446,62 @@ extern "C" { f_file_t file = f_file_t_initialize; - status = f_file_open(argv[main->parameters.remaining.array[i]], 0, &file); - - main->quantity.total = original_size; + status = f_file_open(data.argv[main->parameters.remaining.array[i]], 0, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_open", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_open", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); break; } - if (!main->quantity.total) { - status = f_file_size_by_id(file.id, &main->quantity.total); - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); - - f_file_stream_close(F_true, &file); + total = 0; - break; - } + status = f_file_size_by_id(file.id, &total); + if (F_status_is_error(status)) { + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); - // Skip past empty files. - if (!main->quantity.total) { - if (main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { - fll_print_format("%r%r", main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); - } + f_file_stream_close(F_true, &file); - f_file_stream_close(F_true, &file); + break; + } - continue; + // Skip past empty files. + if (!total) { + if (main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { + fll_print_format("%r%r", main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); } + + f_file_stream_close(F_true, &file); + + continue; } - status = f_file_read_until(file, main->quantity.total, &main->buffer); + status = f_file_read_until(file, total, &data.buffer); f_file_stream_close(F_true, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read_until", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read_until", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } - status = fss_embedded_list_read_main_process_file(main, argv[main->parameters.remaining.array[i]], depths, &objects_delimits, &contents_delimits, &comments); + status = fss_embedded_list_read_main_process_file(&data, data.argv[main->parameters.remaining.array[i]], depths, &objects_delimits, &contents_delimits, &comments); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "fss_embedded_list_read_main_process_file", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "fss_embedded_list_read_main_process_file", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } // Clear buffers before repeating the loop. - macro_f_fss_nest_t_delete_simple(main->nest); - f_string_dynamic_resize(0, &main->buffer); + macro_f_fss_nest_t_delete_simple(data.nest); + data.buffer.used = 0; } // for - - if (F_status_is_error(status)) { - macro_f_fss_nest_t_delete_simple(main->nest); - f_string_dynamic_resize(0, &main->buffer); - } } + macro_f_fss_nest_t_delete_simple(data.nest); + f_string_dynamic_resize(0, &data.buffer); macro_fss_embedded_list_read_depths_t_delete_simple(depths); macro_f_fss_delimits_t_delete_simple(objects_delimits); macro_f_fss_delimits_t_delete_simple(contents_delimits); @@ -535,7 +520,7 @@ extern "C" { } } - fss_embedded_list_read_main_delete(main); + fss_embedded_list_read_data_delete(&data); return status; } diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h index b30fdc6..fd830de 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h @@ -72,8 +72,6 @@ extern "C" { /** * Execute main program. * - * Be sure to call fss_embedded_list_read_main_delete() after executing this. - * * If main.signal is non-zero, then this blocks and handles the following signals: * - F_signal_abort * - F_signal_broken_pipe @@ -91,11 +89,9 @@ extern "C" { * F_none on success. * * Status codes (with error bit) are returned on any problem. - * - * @see fss_embedded_list_read_main_delete() */ #ifndef _di_fss_embedded_list_read_main_ - extern f_status_t fss_embedded_list_read_main(fss_embedded_list_read_main_t * const main, const f_console_arguments_t *arguments); + extern f_status_t fss_embedded_list_read_main(fll_program_data_t * const main, const f_console_arguments_t *arguments); #endif // _di_fss_embedded_list_read_main_ #ifdef __cplusplus diff --git a/level_3/fss_embedded_list_read/c/main.c b/level_3/fss_embedded_list_read/c/main.c index f24d161..9ae2ea4 100644 --- a/level_3/fss_embedded_list_read/c/main.c +++ b/level_3/fss_embedded_list_read/c/main.c @@ -3,7 +3,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_embedded_list_read_main_t data = fss_embedded_list_read_main_t_initialize; + fll_program_data_t data = fll_program_data_t_initialize; + + f_console_parameter_t parameters[] = fss_embedded_list_read_console_parameter_t_initialize; + data.parameters.array = parameters; + data.parameters.used = fss_embedded_list_read_total_parameters_d; if (f_pipe_input_exists()) { data.process_pipe = F_true; @@ -13,6 +17,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { const f_status_t status = fss_embedded_list_read_main(&data, &arguments); + fll_program_data_delete(&data); + fll_program_standard_setdown(&data.signal); if (F_status_is_error(status)) return 1; diff --git a/level_3/fss_embedded_list_read/c/private-common.c b/level_3/fss_embedded_list_read/c/private-common.c index 25b950c..2417b65 100644 --- a/level_3/fss_embedded_list_read/c/private-common.c +++ b/level_3/fss_embedded_list_read/c/private-common.c @@ -5,28 +5,39 @@ extern "C" { #endif +#ifndef _di_fss_embedded_list_read_data_delete_ + f_status_t fss_embedded_list_read_data_delete(fss_embedded_list_read_data_t * const data) { + + macro_f_fss_nest_t_delete_simple(data->nest); + + f_string_dynamic_resize(0, &data->buffer); + + return F_none; + } +#endif // _di_fss_embedded_list_read_data_delete_ + #ifndef _di_fss_embedded_list_read_print_signal_received_ - void fss_embedded_list_read_print_signal_received(fss_embedded_list_read_main_t * const main, const f_status_t signal) { + void fss_embedded_list_read_print_signal_received(fss_embedded_list_read_data_t * const data, const f_status_t signal) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (data->main->warning.verbosity != f_console_verbosity_verbose_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. - fflush(main->warning.to.stream); + fflush(data->main->warning.to.stream); - flockfile(main->warning.to.stream); + flockfile(data->main->warning.to.stream); - fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); - fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); + fl_print_format("%]%r%r%[Received signal code %]", data->main->warning.to.stream, data->main->context.set.reset, f_string_eol_s, f_string_eol_s, data->main->context.set.warning, data->main->context.set.warning); + fl_print_format("%[%i%]", data->main->warning.to.stream, data->main->context.set.notable, signal, data->main->context.set.notable); + fl_print_format("%[.%]%r", data->main->warning.to.stream, data->main->context.set.warning, data->main->context.set.warning, f_string_eol_s); - funlockfile(main->warning.to.stream); + funlockfile(data->main->warning.to.stream); } #endif // _di_fss_embedded_list_read_print_signal_received_ #ifndef _di_fss_embedded_list_read_signal_received_ - f_status_t fss_embedded_list_read_signal_received(fss_embedded_list_read_main_t * const main) { + f_status_t fss_embedded_list_read_signal_received(fss_embedded_list_read_data_t * const data) { - if (main->signal.id == -1) { + if (data->main->signal.id == -1) { return F_false; } @@ -34,7 +45,7 @@ extern "C" { memset(&information, 0, sizeof(struct signalfd_siginfo)); - if (f_signal_read(main->signal, 0, &information) == F_signal) { + if (f_signal_read(data->main->signal, 0, &information) == F_signal) { switch (information.ssi_signo) { case F_signal_abort: case F_signal_broken_pipe: @@ -42,7 +53,7 @@ extern "C" { case F_signal_interrupt: case F_signal_quit: case F_signal_termination: - fss_embedded_list_read_print_signal_received(main, information.ssi_signo); + fss_embedded_list_read_print_signal_received(data, information.ssi_signo); return information.ssi_signo; } diff --git a/level_3/fss_embedded_list_read/c/private-common.h b/level_3/fss_embedded_list_read/c/private-common.h index 32a705a..5b1f54a 100644 --- a/level_3/fss_embedded_list_read/c/private-common.h +++ b/level_3/fss_embedded_list_read/c/private-common.h @@ -147,15 +147,61 @@ extern "C" { #endif // _di_fss_embedded_list_read_depths_t_ /** + * The program data. + * + * process_pipe: Designate whether or not to process the input pipe. + * context: The color context. + */ +#ifndef _di_fss_embedded_list_read_data_t_ + typedef struct { + fll_program_data_t *main; + f_string_static_t *argv; + + f_string_dynamic_t buffer; + f_fss_nest_t nest; + + uint8_t delimit_mode; + f_array_length_t delimit_depth; + } fss_embedded_list_read_data_t; + + #define fss_embedded_list_read_data_t_initialize \ + { \ + 0, \ + 0, \ + f_string_dynamic_t_initialize, \ + f_fss_nest_t_initialize, \ + fss_embedded_list_read_delimit_mode_all_e, \ + 0, \ + } +#endif // _di_fss_embedded_list_read_data_t_ + +/** + * Deallocate program data. + * + * @param data + * The program data. + * + * @return + * F_none on success. + * + * Status codes (with error bit) are returned on any problem. + * + * @see fss_embedded_list_read_main() + */ +#ifndef _di_fss_embedded_list_read_data_delete_ + extern f_status_t fss_embedded_list_read_data_delete(fss_embedded_list_read_data_t * const data) F_attribute_visibility_internal_d; +#endif // _di_fss_embedded_list_read_data_delete_ + +/** * Print a message about a process signal being recieved, such as an interrupt signal. * - * @param main - * The main program data. + * @param data + * The program data. * @param signal * The signal received. */ #ifndef _di_fss_embedded_list_read_print_signal_received_ - extern void fss_embedded_list_read_print_signal_received(fss_embedded_list_read_main_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_embedded_list_read_print_signal_received(fss_embedded_list_read_data_t * const data, const f_status_t signal) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_print_signal_received_ /** @@ -163,8 +209,8 @@ extern "C" { * * Only signals that are blocked via main.signal will be received. * - * @param main - * The main program data. + * @param data + * The program data. * * @return * A positive number representing a valid signal on signal received. @@ -173,7 +219,7 @@ extern "C" { * @see f_signal_read() */ #ifndef _di_fss_embedded_list_read_signal_received_ - extern f_status_t fss_embedded_list_read_signal_received(fss_embedded_list_read_main_t * const main) F_attribute_visibility_internal_d; + extern f_status_t fss_embedded_list_read_signal_received(fss_embedded_list_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_signal_received_ #ifdef __cplusplus diff --git a/level_3/fss_embedded_list_read/c/private-print.c b/level_3/fss_embedded_list_read/c/private-print.c index cfe3dd3..959c20c 100644 --- a/level_3/fss_embedded_list_read/c/private-print.c +++ b/level_3/fss_embedded_list_read/c/private-print.c @@ -7,45 +7,45 @@ extern "C" { #endif #ifndef _di_fss_embedded_list_read_print_object_end_ - void fss_embedded_list_read_print_object_end(fss_embedded_list_read_main_t * const main) { + void fss_embedded_list_read_print_object_end(fss_embedded_list_read_data_t * const data) { - if (main->parameters.array[fss_embedded_list_read_parameter_pipe_e].result == f_console_result_found_e) { - f_print_dynamic_raw(fss_embedded_list_read_pipe_content_start_s, main->output.to.stream); + if (data->main->parameters.array[fss_embedded_list_read_parameter_pipe_e].result == f_console_result_found_e) { + f_print_dynamic_raw(fss_embedded_list_read_pipe_content_start_s, data->main->output.to.stream); } else { - if (main->parameters.array[fss_embedded_list_read_parameter_object_e].result == f_console_result_found_e && main->parameters.array[fss_embedded_list_read_parameter_content_e].result == f_console_result_found_e) { - f_print_dynamic_raw(f_fss_embedded_list_open_s, main->output.to.stream); - f_print_dynamic_raw(f_fss_embedded_list_open_end_s, main->output.to.stream); + if (data->main->parameters.array[fss_embedded_list_read_parameter_object_e].result == f_console_result_found_e && data->main->parameters.array[fss_embedded_list_read_parameter_content_e].result == f_console_result_found_e) { + f_print_dynamic_raw(f_fss_embedded_list_open_s, data->main->output.to.stream); + f_print_dynamic_raw(f_fss_embedded_list_open_end_s, data->main->output.to.stream); } else { - f_print_dynamic_raw(f_fss_eol_s, main->output.to.stream); + f_print_dynamic_raw(f_fss_eol_s, data->main->output.to.stream); } } } #endif // _di_fss_embedded_list_read_print_object_end_ #ifndef _di_fss_embedded_list_read_print_content_ignore_ - void fss_embedded_list_read_print_content_ignore(fss_embedded_list_read_main_t * const main) { + void fss_embedded_list_read_print_content_ignore(fss_embedded_list_read_data_t * const data) { - if (main->parameters.array[fss_embedded_list_read_parameter_pipe_e].result == f_console_result_found_e) { - f_print_dynamic_raw(fss_embedded_list_read_pipe_content_ignore_s, main->output.to.stream); + if (data->main->parameters.array[fss_embedded_list_read_parameter_pipe_e].result == f_console_result_found_e) { + f_print_dynamic_raw(fss_embedded_list_read_pipe_content_ignore_s, data->main->output.to.stream); } } #endif // _di_fss_embedded_list_read_print_content_ignore_ #ifndef _di_fss_embedded_list_read_print_set_end_ - void fss_embedded_list_read_print_set_end(fss_embedded_list_read_main_t * const main) { + void fss_embedded_list_read_print_set_end(fss_embedded_list_read_data_t * const data) { - if (main->parameters.array[fss_embedded_list_read_parameter_pipe_e].result == f_console_result_found_e) { - f_print_dynamic_raw(fss_embedded_list_read_pipe_content_end_s, main->output.to.stream); + if (data->main->parameters.array[fss_embedded_list_read_parameter_pipe_e].result == f_console_result_found_e) { + f_print_dynamic_raw(fss_embedded_list_read_pipe_content_end_s, data->main->output.to.stream); } else { - if (main->parameters.array[fss_embedded_list_read_parameter_object_e].result == f_console_result_found_e && main->parameters.array[fss_embedded_list_read_parameter_content_e].result == f_console_result_found_e) { - f_print_dynamic_raw(f_fss_embedded_list_close_s, main->output.to.stream); - f_print_dynamic_raw(f_fss_embedded_list_close_end_s, main->output.to.stream); + if (data->main->parameters.array[fss_embedded_list_read_parameter_object_e].result == f_console_result_found_e && data->main->parameters.array[fss_embedded_list_read_parameter_content_e].result == f_console_result_found_e) { + f_print_dynamic_raw(f_fss_embedded_list_close_s, data->main->output.to.stream); + f_print_dynamic_raw(f_fss_embedded_list_close_end_s, data->main->output.to.stream); } else { - f_print_dynamic_raw(f_fss_eol_s, main->output.to.stream); + f_print_dynamic_raw(f_fss_eol_s, data->main->output.to.stream); } } } diff --git a/level_3/fss_embedded_list_read/c/private-print.h b/level_3/fss_embedded_list_read/c/private-print.h index 635c005..2f2beea 100644 --- a/level_3/fss_embedded_list_read/c/private-print.h +++ b/level_3/fss_embedded_list_read/c/private-print.h @@ -17,31 +17,31 @@ extern "C" { * * This is only used in pipe output mode. * - * @param main - * The main program data. + * @param data + * The program data. */ #ifndef _di_fss_embedded_list_read_print_content_ignore_ - extern void fss_embedded_list_read_print_content_ignore(fss_embedded_list_read_main_t * const main) F_attribute_visibility_internal_d; + extern void fss_embedded_list_read_print_content_ignore(fss_embedded_list_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_print_content_ignore_ /** * Print the end of an object (which is essentially the start of a content). * - * @param main - * The main program data. + * @param data + * The program data. */ #ifndef _di_fss_embedded_list_read_print_object_end_ - extern void fss_embedded_list_read_print_object_end(fss_embedded_list_read_main_t * const main) F_attribute_visibility_internal_d; + extern void fss_embedded_list_read_print_object_end(fss_embedded_list_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_print_object_end_ /** * Print the end of an object/content set. * - * @param main - * The main program data. + * @param data + * The program data. */ #ifndef _di_fss_embedded_list_read_print_set_end_ - extern void fss_embedded_list_read_print_set_end(fss_embedded_list_read_main_t * const main) F_attribute_visibility_internal_d; + extern void fss_embedded_list_read_print_set_end(fss_embedded_list_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_print_set_end_ #ifdef __cplusplus 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 0ca3263..8c531e2 100644 --- a/level_3/fss_embedded_list_read/c/private-read.c +++ b/level_3/fss_embedded_list_read/c/private-read.c @@ -8,11 +8,11 @@ extern "C" { #endif #ifndef _di_fss_embedded_list_read_main_preprocess_depth_ - f_status_t fss_embedded_list_read_main_preprocess_depth(fss_embedded_list_read_main_t * const main, fss_embedded_list_read_depths_t *depths) { + f_status_t fss_embedded_list_read_main_preprocess_depth(fss_embedded_list_read_data_t * const data, fss_embedded_list_read_depths_t *depths) { f_status_t status = F_none; - const f_array_length_t values_total = main->parameters.array[fss_embedded_list_read_parameter_depth_e].values.used + main->parameters.array[fss_embedded_list_read_parameter_at_e].values.used + main->parameters.array[fss_embedded_list_read_parameter_name_e].values.used; + const f_array_length_t values_total = data->main->parameters.array[fss_embedded_list_read_parameter_depth_e].values.used + data->main->parameters.array[fss_embedded_list_read_parameter_at_e].values.used + data->main->parameters.array[fss_embedded_list_read_parameter_name_e].values.used; f_array_length_t values_order[values_total]; f_array_length_t values_type[values_total]; @@ -27,24 +27,24 @@ extern "C" { f_array_length_t k = 0; f_array_length_t l = 0; - for (; j < main->parameters.array[fss_embedded_list_read_parameter_depth_e].values.used; ++j) { + for (; j < data->main->parameters.array[fss_embedded_list_read_parameter_depth_e].values.used; ++j) { - values_order[i] = main->parameters.array[fss_embedded_list_read_parameter_depth_e].values.array[j]; + values_order[i] = data->main->parameters.array[fss_embedded_list_read_parameter_depth_e].values.array[j]; values_type[i++] = fss_embedded_list_read_parameter_depth_e; } // for if (i) { - for (j = 0; j < main->parameters.array[fss_embedded_list_read_parameter_at_e].values.used; ++j) { + for (j = 0; j < data->main->parameters.array[fss_embedded_list_read_parameter_at_e].values.used; ++j) { for (k = 0; k < i; ++k) { - if (values_order[k] > main->parameters.array[fss_embedded_list_read_parameter_at_e].values.array[j]) { + if (values_order[k] > data->main->parameters.array[fss_embedded_list_read_parameter_at_e].values.array[j]) { for (l = i; l > k; --l) { values_order[l] = values_order[l - 1]; values_type[l] = values_type[l - 1]; } // for - values_order[k] = main->parameters.array[fss_embedded_list_read_parameter_at_e].values.array[j]; + values_order[k] = data->main->parameters.array[fss_embedded_list_read_parameter_at_e].values.array[j]; values_type[k] = fss_embedded_list_read_parameter_at_e; i++; @@ -53,31 +53,31 @@ extern "C" { } // for if (k == i) { - values_order[i] = main->parameters.array[fss_embedded_list_read_parameter_at_e].values.array[j]; + values_order[i] = data->main->parameters.array[fss_embedded_list_read_parameter_at_e].values.array[j]; values_type[i++] = fss_embedded_list_read_parameter_at_e; } } // for } else { - for (; j < main->parameters.array[fss_embedded_list_read_parameter_at_e].values.used; ++j) { + for (; j < data->main->parameters.array[fss_embedded_list_read_parameter_at_e].values.used; ++j) { - values_order[i] = main->parameters.array[fss_embedded_list_read_parameter_at_e].values.array[j]; + values_order[i] = data->main->parameters.array[fss_embedded_list_read_parameter_at_e].values.array[j]; values_type[i++] = fss_embedded_list_read_parameter_at_e; } // for } if (i) { - for (j = 0; j < main->parameters.array[fss_embedded_list_read_parameter_name_e].values.used; ++j) { + for (j = 0; j < data->main->parameters.array[fss_embedded_list_read_parameter_name_e].values.used; ++j) { for (k = 0; k < i; ++k) { - if (values_order[k] > main->parameters.array[fss_embedded_list_read_parameter_name_e].values.array[j]) { + if (values_order[k] > data->main->parameters.array[fss_embedded_list_read_parameter_name_e].values.array[j]) { for (l = i; l > k; --l) { values_order[l] = values_order[l - 1]; values_type[l] = values_type[l - 1]; } // for - values_order[k] = main->parameters.array[fss_embedded_list_read_parameter_name_e].values.array[j]; + values_order[k] = data->main->parameters.array[fss_embedded_list_read_parameter_name_e].values.array[j]; values_type[k] = fss_embedded_list_read_parameter_name_e; i++; @@ -86,15 +86,15 @@ extern "C" { } // for if (k == i) { - values_order[i] = main->parameters.array[fss_embedded_list_read_parameter_name_e].values.array[j]; + values_order[i] = data->main->parameters.array[fss_embedded_list_read_parameter_name_e].values.array[j]; values_type[i++] = fss_embedded_list_read_parameter_name_e; } } // for } else { - for (; j < main->parameters.array[fss_embedded_list_read_parameter_name_e].values.used; ++j) { + for (; j < data->main->parameters.array[fss_embedded_list_read_parameter_name_e].values.used; ++j) { - values_order[i] = main->parameters.array[fss_embedded_list_read_parameter_name_e].values.array[j]; + values_order[i] = data->main->parameters.array[fss_embedded_list_read_parameter_name_e].values.array[j]; values_type[i++] = fss_embedded_list_read_parameter_name_e; } // for } @@ -103,14 +103,14 @@ extern "C" { { i = 1; - if (main->parameters.array[fss_embedded_list_read_parameter_depth_e].result == f_console_result_additional_e) { - i = main->parameters.array[fss_embedded_list_read_parameter_depth_e].values.used + 1; + if (data->main->parameters.array[fss_embedded_list_read_parameter_depth_e].result == f_console_result_additional_e) { + i = data->main->parameters.array[fss_embedded_list_read_parameter_depth_e].values.used + 1; } macro_fss_embedded_list_read_depths_t_resize(status, (*depths), i); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fss_embedded_list_read_main_preprocess_depth", F_true); + fll_error_print(data->main->error, F_status_set_fine(status), "fss_embedded_list_read_main_preprocess_depth", F_true); return status; } @@ -123,25 +123,25 @@ extern "C" { depths->array[0].value_at = 0; { - f_string_static_t * const argv = main->parameters.arguments.array; + f_string_static_t * const argv = data->main->parameters.arguments.array; f_number_unsigned_t number = 0; bool first_depth = F_true; for (i = 0; i < values_total; ++i) { - if (!((++main->signal_check) % fss_embedded_list_read_signal_check_d)) { - if (fss_embedded_list_read_signal_received(main)) { + if (!((++data->main->signal_check) % fss_embedded_list_read_signal_check_d)) { + if (fss_embedded_list_read_signal_received(data)) { return F_status_set_error(F_interrupt); } - main->signal_check = 0; + data->main->signal_check = 0; } if (values_type[i] == fss_embedded_list_read_parameter_depth_e || values_type[i] == fss_embedded_list_read_parameter_at_e) { status = fl_conversion_dynamic_to_number_unsigned(argv[values_order[i]], &number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_number_unsigned", F_true, fss_embedded_list_read_long_depth_s, argv[values_order[i]]); + fll_error_parameter_integer_print(data->main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_number_unsigned", F_true, fss_embedded_list_read_long_depth_s, argv[values_order[i]]); return status; } @@ -174,11 +174,11 @@ extern "C" { depths->array[depths->used].index_name = values_order[i]; depths->array[depths->used].value_name.used = 0; - if (main->parameters.array[fss_embedded_list_read_parameter_trim_e].result == f_console_result_found_e) { + if (data->main->parameters.array[fss_embedded_list_read_parameter_trim_e].result == f_console_result_found_e) { status = fl_string_dynamic_rip(argv[values_order[i]], &depths->array[depths->used].value_name); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fl_string_dynamic_rip", F_true); + fll_error_print(data->main->error, F_status_set_fine(status), "fl_string_dynamic_rip", F_true); return status; } @@ -187,7 +187,7 @@ extern "C" { status = f_string_dynamic_append(argv[values_order[i]], &depths->array[depths->used].value_name); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); + fll_error_print(data->main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); return status; } @@ -203,30 +203,30 @@ extern "C" { for (j = i + 1; j < depths->used; ++j) { if (depths->array[i].depth == depths->array[j].depth) { - flockfile(main->error.to.stream); + flockfile(data->main->error.to.stream); - fl_print_format("%r%[%QThe value '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, depths->array[i].depth, main->error.notable); - fl_print_format("%[' may only be specified once for the parameter '%]", main->error.to.stream, main->error.notable, main->error.notable); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_read_long_depth_s, main->error.notable); - fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); + fl_print_format("%r%[%QThe value '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); + fl_print_format("%[%ul%]", data->main->error.to.stream, data->main->error.notable, depths->array[i].depth, data->main->error.notable); + fl_print_format("%[' may only be specified once for the parameter '%]", data->main->error.to.stream, data->main->error.notable, data->main->error.notable); + fl_print_format("%[%r%r%]", data->main->error.to.stream, data->main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_read_long_depth_s, data->main->error.notable); + fl_print_format("%['.%]%r", data->main->error.to.stream, data->main->error.context, data->main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + funlockfile(data->main->error.to.stream); return F_status_set_error(F_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - flockfile(main->error.to.stream); + flockfile(data->main->error.to.stream); - fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_read_long_depth_s, main->error.notable); - fl_print_format("%[' may not have the value '%]", main->error.to.stream, main->error.notable, main->error.notable); - fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, depths->array[i].depth, main->error.notable); - fl_print_format("%[' before the value '%]", main->error.to.stream, main->error.notable, main->error.notable); - fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, depths->array[j].depth, main->error.notable); - fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); + fl_print_format("%r%[%QThe parameter '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); + fl_print_format("%[%r%r%]", data->main->error.to.stream, data->main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_read_long_depth_s, data->main->error.notable); + fl_print_format("%[' may not have the value '%]", data->main->error.to.stream, data->main->error.notable, data->main->error.notable); + fl_print_format("%[%ul%]", data->main->error.to.stream, data->main->error.notable, depths->array[i].depth, data->main->error.notable); + fl_print_format("%[' before the value '%]", data->main->error.to.stream, data->main->error.notable, data->main->error.notable); + fl_print_format("%[%ul%]", data->main->error.to.stream, data->main->error.notable, depths->array[j].depth, data->main->error.notable); + fl_print_format("%['.%]%r", data->main->error.to.stream, data->main->error.context, data->main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + funlockfile(data->main->error.to.stream); return F_status_set_error(F_parameter); } @@ -238,30 +238,30 @@ extern "C" { #endif // _di_fss_embedded_list_read_main_preprocess_depth_ #ifndef _di_fss_embedded_list_read_main_process_file_ - f_status_t fss_embedded_list_read_main_process_file(fss_embedded_list_read_main_t * const main, const f_string_static_t filename, const fss_embedded_list_read_depths_t depths, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) { + f_status_t fss_embedded_list_read_main_process_file(fss_embedded_list_read_data_t * const data, const f_string_static_t filename, const fss_embedded_list_read_depths_t depths, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) { f_status_t status = F_none; { f_state_t state = macro_f_state_t_initialize(fss_embedded_list_read_common_allocation_large_d, fss_embedded_list_read_common_allocation_small_d, 0, 0, 0, 0, 0); - f_string_range_t input = macro_f_string_range_t_initialize2(main->buffer.used); + f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); objects_delimits->used = 0; contents_delimits->used = 0; comments->used = 0; - status = fll_fss_embedded_list_read(main->buffer, state, &input, &main->nest, objects_delimits, contents_delimits, comments); + status = fll_fss_embedded_list_read(data->buffer, state, &input, &data->nest, objects_delimits, contents_delimits, comments); if (F_status_is_error(status)) { // @todo detect and replace fll_error_file_type_file_e with fll_error_file_type_pipe_e as appropriate. - fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_embedded_list_read", F_true, filename, f_file_operation_process_s, fll_error_file_type_file_e); + fll_error_file_print(data->main->error, F_status_set_fine(status), "fll_fss_embedded_list_read", F_true, filename, f_file_operation_process_s, fll_error_file_type_file_e); } else if (status == F_data_not_stop || status == F_data_not_eos) { - macro_f_fss_nest_t_delete_simple(main->nest); - f_string_dynamic_resize(0, &main->buffer); + macro_f_fss_nest_t_delete_simple(data->nest); + f_string_dynamic_resize(0, &data->buffer); - if (main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { - fll_print_format("%r%r", main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); + if (data->main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { + fll_print_format("%r%r", data->main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); return F_none; } @@ -270,8 +270,8 @@ extern "C" { } if (F_status_is_error(status)) { - macro_f_fss_nest_t_delete_simple(main->nest); - f_string_dynamic_resize(0, &main->buffer); + macro_f_fss_nest_t_delete_simple(data->nest); + f_string_dynamic_resize(0, &data->buffer); return status; } @@ -283,15 +283,15 @@ extern "C" { for (; i < comments->used; ++i) { for (j = comments->array[i].start; j <= comments->array[i].stop; ++j) { - main->buffer.string[j] = f_fss_delimit_placeholder_s.string[0]; + data->buffer.string[j] = f_fss_delimit_placeholder_s.string[0]; } // for } // for } // Requested depths cannot be greater than contents depth. - if (depths.used > main->nest.used) { - if (main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { - fll_print_format("%r%r", main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); + if (depths.used > data->nest.used) { + if (data->main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { + fll_print_format("%r%r", data->main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); return F_none; } @@ -302,13 +302,13 @@ extern "C" { { f_number_unsigned_t select = 0; - if (main->parameters.array[fss_embedded_list_read_parameter_select_e].result == f_console_result_additional_e) { - const f_array_length_t index = main->parameters.array[fss_embedded_list_read_parameter_select_e].values.array[main->parameters.array[fss_embedded_list_read_parameter_select_e].values.used - 1]; + if (data->main->parameters.array[fss_embedded_list_read_parameter_select_e].result == f_console_result_additional_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]; - status = fl_conversion_dynamic_to_number_unsigned(main->parameters.arguments.array[index], &select); + status = fl_conversion_dynamic_to_number_unsigned(data->main->parameters.arguments.array[index], &select); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_number_unsigned", F_true, fss_embedded_list_read_long_select_s, main->parameters.arguments.array[index]); + fll_error_parameter_integer_print(data->main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_number_unsigned", F_true, fss_embedded_list_read_long_select_s, data->main->parameters.arguments.array[index]); return status; } @@ -322,37 +322,37 @@ extern "C" { f_array_length_t line = 0; - if (main->parameters.array[fss_embedded_list_read_parameter_line_e].result == f_console_result_additional_e) { - const f_array_length_t index = main->parameters.array[fss_embedded_list_read_parameter_line_e].values.array[main->parameters.array[fss_embedded_list_read_parameter_line_e].values.used - 1]; + if (data->main->parameters.array[fss_embedded_list_read_parameter_line_e].result == f_console_result_additional_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]; - status = fl_conversion_dynamic_to_number_unsigned(main->parameters.arguments.array[index], &line); + status = fl_conversion_dynamic_to_number_unsigned(data->main->parameters.arguments.array[index], &line); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_number_unsigned", F_true, fss_embedded_list_read_long_line_s, main->parameters.arguments.array[index]); + fll_error_parameter_integer_print(data->main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_number_unsigned", F_true, fss_embedded_list_read_long_line_s, data->main->parameters.arguments.array[index]); return status; } } - fss_embedded_list_read_process_delimits(main, objects_delimits, contents_delimits); + fss_embedded_list_read_process_delimits(data, objects_delimits, contents_delimits); const fss_embedded_list_read_skip_t parents = fss_embedded_list_read_skip_t_initialize; - if (main->parameters.array[fss_embedded_list_read_parameter_raw_e].result == f_console_result_found_e) { + if (data->main->parameters.array[fss_embedded_list_read_parameter_raw_e].result == f_console_result_found_e) { f_fss_delimits_t except_none = f_fss_delimits_t_initialize; - return fss_embedded_list_read_main_process_for_depth(main, filename, depths, 0, line, parents, &except_none, &except_none); + return fss_embedded_list_read_main_process_for_depth(data, filename, depths, 0, line, parents, &except_none, &except_none); } - return fss_embedded_list_read_main_process_for_depth(main, filename, depths, 0, line, parents, objects_delimits, contents_delimits); + return fss_embedded_list_read_main_process_for_depth(data, filename, depths, 0, line, parents, objects_delimits, contents_delimits); } #endif // _di_fss_embedded_list_read_main_process_file_ #ifndef _di_fss_embedded_list_read_main_process_for_depth_ - f_status_t fss_embedded_list_read_main_process_for_depth(fss_embedded_list_read_main_t * const main, const f_string_static_t filename, const fss_embedded_list_read_depths_t depths, const f_array_length_t depths_index, const f_array_length_t line, const fss_embedded_list_read_skip_t parents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) { + f_status_t fss_embedded_list_read_main_process_for_depth(fss_embedded_list_read_data_t * const data, const f_string_static_t filename, const fss_embedded_list_read_depths_t depths, const f_array_length_t depths_index, const f_array_length_t line, const fss_embedded_list_read_skip_t parents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) { - f_fss_items_t *items = &main->nest.depth[depths.array[depths_index].depth]; + f_fss_items_t *items = &data->nest.depth[depths.array[depths_index].depth]; bool skip[items->used]; @@ -376,7 +376,7 @@ extern "C" { if (!depths.array[depths_index].index_name || (depths.array[depths_index].index_at && depths.array[depths_index].index_at < depths.array[depths_index].index_name)) { - // all other non-"at" parameters must be FALSE. + // All other non-"at" parameters must be FALSE. for (; i < items->used; ++i) { if (skip[i]) continue; @@ -391,14 +391,14 @@ extern "C" { if (depths.array[depths_index].value_at < items->used && !skip[depths.array[depths_index].value_at]) { if (depths.array[depths_index].index_name) { - if (main->parameters.array[fss_embedded_list_read_parameter_trim_e].result == f_console_result_found_e) { + if (data->main->parameters.array[fss_embedded_list_read_parameter_trim_e].result == f_console_result_found_e) { - if (fl_string_dynamic_partial_compare_except_trim_dynamic(depths.array[depths_index].value_name, main->buffer, items->array[depths.array[depths_index].value_at].object, except_none, *objects_delimits) != F_equal_to) { + if (fl_string_dynamic_partial_compare_except_trim_dynamic(depths.array[depths_index].value_name, data->buffer, items->array[depths.array[depths_index].value_at].object, except_none, *objects_delimits) != F_equal_to) { skip[depths.array[depths_index].value_at] = F_true; } } else { - if (fl_string_dynamic_partial_compare_except_dynamic(depths.array[depths_index].value_name, main->buffer, items->array[depths.array[depths_index].value_at].object, except_none, *objects_delimits) != F_equal_to) { + if (fl_string_dynamic_partial_compare_except_dynamic(depths.array[depths_index].value_name, data->buffer, items->array[depths.array[depths_index].value_at].object, except_none, *objects_delimits) != F_equal_to) { skip[depths.array[depths_index].value_at] = F_true; } } @@ -406,12 +406,12 @@ extern "C" { } } else { - if (main->parameters.array[fss_embedded_list_read_parameter_trim_e].result == f_console_result_found_e) { + if (data->main->parameters.array[fss_embedded_list_read_parameter_trim_e].result == f_console_result_found_e) { for (i = 0; i < items->used; ++i) { if (skip[i]) continue; - if (fl_string_dynamic_partial_compare_except_trim_dynamic(depths.array[depths_index].value_name, main->buffer, items->array[i].object, except_none, *objects_delimits) != F_equal_to) { + if (fl_string_dynamic_partial_compare_except_trim_dynamic(depths.array[depths_index].value_name, data->buffer, items->array[i].object, except_none, *objects_delimits) != F_equal_to) { skip[i] = F_true; } } // for @@ -421,7 +421,7 @@ extern "C" { if (skip[i]) continue; - if (fl_string_dynamic_partial_compare_except_dynamic(depths.array[depths_index].value_name, main->buffer, items->array[i].object, except_none, *objects_delimits) != F_equal_to) { + if (fl_string_dynamic_partial_compare_except_dynamic(depths.array[depths_index].value_name, data->buffer, items->array[i].object, except_none, *objects_delimits) != F_equal_to) { skip[i] = F_true; } } // for @@ -446,7 +446,7 @@ extern "C" { // If the current depth is not the final depth, then recurse into the next depth. if (depths_index + 1 < depths.used) { - bool skip_next[main->nest.depth[depths.array[depths_index + 1].depth - 1].used]; + bool skip_next[data->nest.depth[depths.array[depths_index + 1].depth - 1].used]; fss_embedded_list_read_skip_t parents_next = fss_embedded_list_read_skip_t_initialize; @@ -459,11 +459,11 @@ extern "C" { const f_array_length_t depth_next = depths.array[depths_index + 1].depth; parents_next.skip = skip_next; - parents_next.used = main->nest.depth[parents_depth].used; + parents_next.used = data->nest.depth[parents_depth].used; memset(skip_next, F_true, sizeof(skip_next) * parents_next.used); - f_fss_items_t *items_next = &main->nest.depth[depth_next]; + f_fss_items_t *items_next = &data->nest.depth[depth_next]; f_fss_items_t *items_previous = 0; f_fss_item_t *item_previous = 0; @@ -475,12 +475,12 @@ extern "C" { j = depth_next; item_previous = &items_next->array[i]; - items_previous = &main->nest.depth[--j]; + items_previous = &data->nest.depth[--j]; while (j > depths.array[depths_index].depth) { item_previous = &items_previous->array[item_previous->parent]; - items_previous = &main->nest.depth[--j]; + items_previous = &data->nest.depth[--j]; } // while if (skip[item_previous->parent]) { @@ -492,15 +492,15 @@ extern "C" { } // for } - return fss_embedded_list_read_main_process_for_depth(main, filename, depths, depths_index + 1, line, parents_next, objects_delimits, contents_delimits); + return fss_embedded_list_read_main_process_for_depth(data, filename, depths, depths_index + 1, line, parents_next, objects_delimits, contents_delimits); } // Process objects. f_array_length_t i = 0; f_array_length_t j = 0; - if (main->parameters.array[fss_embedded_list_read_parameter_object_e].result == f_console_result_found_e) { - if (main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { + if (data->main->parameters.array[fss_embedded_list_read_parameter_object_e].result == f_console_result_found_e) { + if (data->main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { f_array_length_t total = 0; for (i = 0; i < items->used; ++i) { @@ -509,37 +509,37 @@ extern "C" { ++total; } // for - fll_print_format("%ul%r", main->output.to.stream, total, f_string_eol_s); + fll_print_format("%ul%r", data->main->output.to.stream, total, f_string_eol_s); return F_none; } f_status_t (*print_object)(const f_string_static_t, const f_string_range_t, const f_array_lengths_t, FILE *) = &f_print_except_dynamic_partial; - if (main->parameters.array[fss_embedded_list_read_parameter_trim_e].result == f_console_result_found_e) { + if (data->main->parameters.array[fss_embedded_list_read_parameter_trim_e].result == f_console_result_found_e) { print_object = &fl_print_trim_except_dynamic_partial; } - flockfile(main->output.to.stream); + flockfile(data->main->output.to.stream); for (i = 0; i < items->used; ++i) { if (skip[i]) continue; - print_object(main->buffer, items->array[i].object, *objects_delimits, main->output.to.stream); + print_object(data->buffer, items->array[i].object, *objects_delimits, data->main->output.to.stream); - if (main->parameters.array[fss_embedded_list_read_parameter_content_e].result == f_console_result_found_e) { - fss_embedded_list_read_print_object_end(main); + if (data->main->parameters.array[fss_embedded_list_read_parameter_content_e].result == f_console_result_found_e) { + fss_embedded_list_read_print_object_end(data); if (items->array[i].content.used) { - f_print_except_dynamic_partial(main->buffer, items->array[i].content.array[0], *contents_delimits, main->output.to.stream); + f_print_except_dynamic_partial(data->buffer, items->array[i].content.array[0], *contents_delimits, data->main->output.to.stream); } } - fss_embedded_list_read_print_set_end(main); + fss_embedded_list_read_print_set_end(data); } // for - funlockfile(main->output.to.stream); + funlockfile(data->main->output.to.stream); return F_none; } @@ -547,23 +547,23 @@ extern "C" { // Process contents. bool include_empty = 0; - if (main->parameters.array[fss_embedded_list_read_parameter_empty_e].result == f_console_result_found_e) { + if (data->main->parameters.array[fss_embedded_list_read_parameter_empty_e].result == f_console_result_found_e) { include_empty = 1; } - if (main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { + if (data->main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { f_array_length_t total = 0; for (i = 0; i < items->used; ++i) { if (skip[i]) continue; - if (!((++main->signal_check) % fss_embedded_list_read_signal_check_d)) { - if (fss_embedded_list_read_signal_received(main)) { + if (!((++data->main->signal_check) % fss_embedded_list_read_signal_check_d)) { + if (fss_embedded_list_read_signal_received(data)) { return F_status_set_error(F_interrupt); } - main->signal_check = 0; + data->main->signal_check = 0; } if (!items->array[i].content.used) { @@ -576,23 +576,23 @@ extern "C" { for (j = items->array[i].content.array[0].start; j <= items->array[i].content.array[0].stop; ++j) { - if (!main->buffer.string[j]) continue; + if (!data->buffer.string[j]) continue; - if (main->buffer.string[j] == f_string_eol_s.string[0]) { + if (data->buffer.string[j] == f_string_eol_s.string[0]) { ++total; } } // for } // for - fll_print_format("%ul%r", main->output.to.stream, total, f_string_eol_s); + fll_print_format("%ul%r", data->main->output.to.stream, total, f_string_eol_s); return F_none; } - if (main->parameters.array[fss_embedded_list_read_parameter_line_e].result == f_console_result_additional_e) { + if (data->main->parameters.array[fss_embedded_list_read_parameter_line_e].result == f_console_result_additional_e) { f_array_length_t line_current = 0; - flockfile(main->output.to.stream); + flockfile(data->main->output.to.stream); for (; i < items->used; ++i) { @@ -601,7 +601,7 @@ extern "C" { if (!items->array[i].content.used) { if (include_empty) { if (line_current == line) { - fss_embedded_list_read_print_set_end(main); + fss_embedded_list_read_print_set_end(data); break; } @@ -617,7 +617,7 @@ extern "C" { if (line_current != line) { for (; j <= items->array[i].content.array[0].stop; ++j) { - if (main->buffer.string[j] == f_string_eol_s.string[0]) { + if (data->buffer.string[j] == f_string_eol_s.string[0]) { ++line_current; if (line_current == line) { @@ -634,27 +634,27 @@ extern "C" { for (; j <= items->array[i].content.array[0].stop; ++j) { - if (!main->buffer.string[j]) continue; + if (!data->buffer.string[j]) continue; - if (main->buffer.string[j] == f_string_eol_s.string[0]) { - f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); + if (data->buffer.string[j] == f_string_eol_s.string[0]) { + f_print_dynamic_raw(f_string_eol_s, data->main->output.to.stream); break; } - f_print_character(main->buffer.string[j], main->output.to.stream); + f_print_character(data->buffer.string[j], data->main->output.to.stream); } // for break; } } // for - funlockfile(main->output.to.stream); + funlockfile(data->main->output.to.stream); return F_none; } - flockfile(main->output.to.stream); + flockfile(data->main->output.to.stream); for (i = 0; i < items->used; ++i) { @@ -662,44 +662,44 @@ extern "C" { if (!items->array[i].content.used) { if (include_empty) { - fss_embedded_list_read_print_set_end(main); + fss_embedded_list_read_print_set_end(data); } continue; } - f_print_except_dynamic_partial(main->buffer, items->array[i].content.array[0], *contents_delimits, main->output.to.stream); + f_print_except_dynamic_partial(data->buffer, items->array[i].content.array[0], *contents_delimits, data->main->output.to.stream); - if (main->parameters.array[fss_embedded_list_read_parameter_pipe_e].result == f_console_result_found_e) { - f_print_dynamic_raw(fss_embedded_list_read_pipe_content_end_s, main->output.to.stream); + if (data->main->parameters.array[fss_embedded_list_read_parameter_pipe_e].result == f_console_result_found_e) { + f_print_dynamic_raw(fss_embedded_list_read_pipe_content_end_s, data->main->output.to.stream); } } // for - funlockfile(main->output.to.stream); + funlockfile(data->main->output.to.stream); return F_none; } #endif // _di_fss_embedded_list_read_main_process_for_depth_ #ifndef _di_fss_embedded_list_read_process_delimits_ - void fss_embedded_list_read_process_delimits(fss_embedded_list_read_main_t * const main, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) { + void fss_embedded_list_read_process_delimits(fss_embedded_list_read_data_t * const data, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) { - if (!main->nest.used) return; + if (!data->nest.used) return; - if ((!objects_delimits->used && !contents_delimits->used) || main->delimit_mode == fss_embedded_list_read_delimit_mode_all_e) return; + if ((!objects_delimits->used && !contents_delimits->used) || data->delimit_mode == fss_embedded_list_read_delimit_mode_all_e) return; - if (main->delimit_mode == fss_embedded_list_read_delimit_mode_depth_lesser_e && main->nest.used < main->delimit_depth) return; - if (main->delimit_mode == fss_embedded_list_read_delimit_mode_depth_greater_e && main->delimit_depth == 0) return; + if (data->delimit_mode == fss_embedded_list_read_delimit_mode_depth_lesser_e && data->nest.used < data->delimit_depth) return; + if (data->delimit_mode == fss_embedded_list_read_delimit_mode_depth_greater_e && data->delimit_depth == 0) return; - if (main->delimit_mode == fss_embedded_list_read_delimit_mode_none_e) { + if (data->delimit_mode == fss_embedded_list_read_delimit_mode_none_e) { objects_delimits->used = 0; contents_delimits->used = 0; return; } - if (main->delimit_mode == fss_embedded_list_read_delimit_mode_depth_e || main->delimit_mode == fss_embedded_list_read_delimit_mode_depth_greater_e) { - if (main->delimit_depth >= main->nest.used) { + if (data->delimit_mode == fss_embedded_list_read_delimit_mode_depth_e || data->delimit_mode == fss_embedded_list_read_delimit_mode_depth_greater_e) { + if (data->delimit_depth >= data->nest.used) { objects_delimits->used = 0; contents_delimits->used = 0; @@ -719,36 +719,36 @@ extern "C" { objects_delimits->used = 0; contents_delimits->used = 0; - if (main->delimit_mode == fss_embedded_list_read_delimit_mode_depth_e) { + if (data->delimit_mode == fss_embedded_list_read_delimit_mode_depth_e) { // Only depth 0 objects are stored in objects_delimits. - if (main->delimit_depth) { - fss_embedded_list_read_process_delimits_objects(main, main->delimit_depth, original_contents_delimits, original_contents_used, contents_delimits); + if (data->delimit_depth) { + fss_embedded_list_read_process_delimits_objects(data, data->delimit_depth, original_contents_delimits, original_contents_used, contents_delimits); } else { - fss_embedded_list_read_process_delimits_objects(main, main->delimit_depth, original_objects_delimits, original_objects_used, objects_delimits); + fss_embedded_list_read_process_delimits_objects(data, data->delimit_depth, original_objects_delimits, original_objects_used, objects_delimits); } - fss_embedded_list_read_process_delimits_contents(main, main->delimit_depth, original_contents_delimits, original_contents_used, contents_delimits); + fss_embedded_list_read_process_delimits_contents(data, data->delimit_depth, original_contents_delimits, original_contents_used, contents_delimits); } else { - if (main->delimit_mode == fss_embedded_list_read_delimit_mode_depth_lesser_e) { + if (data->delimit_mode == fss_embedded_list_read_delimit_mode_depth_lesser_e) { - // only depth 0 objects are stored in objects_delimits. - fss_embedded_list_read_process_delimits_objects(main, 0, original_objects_delimits, original_objects_used, objects_delimits); - fss_embedded_list_read_process_delimits_contents(main, 0, original_contents_delimits, original_contents_used, contents_delimits); + // Only depth 0 objects are stored in objects_delimits. + fss_embedded_list_read_process_delimits_objects(data, 0, original_objects_delimits, original_objects_used, objects_delimits); + fss_embedded_list_read_process_delimits_contents(data, 0, original_contents_delimits, original_contents_used, contents_delimits); - for (f_array_length_t i = 1; i <= main->delimit_depth && i < main->nest.used; ++i) { + for (f_array_length_t i = 1; i <= data->delimit_depth && i < data->nest.used; ++i) { - fss_embedded_list_read_process_delimits_objects(main, i, original_contents_delimits, original_contents_used, contents_delimits); - fss_embedded_list_read_process_delimits_contents(main, i, original_contents_delimits, original_contents_used, contents_delimits); + fss_embedded_list_read_process_delimits_objects(data, i, original_contents_delimits, original_contents_used, contents_delimits); + fss_embedded_list_read_process_delimits_contents(data, i, original_contents_delimits, original_contents_used, contents_delimits); } // for } - else if (main->delimit_mode == fss_embedded_list_read_delimit_mode_depth_greater_e) { - for (f_array_length_t i = main->delimit_depth; i < main->nest.used; ++i) { + else if (data->delimit_mode == fss_embedded_list_read_delimit_mode_depth_greater_e) { + for (f_array_length_t i = data->delimit_depth; i < data->nest.used; ++i) { - fss_embedded_list_read_process_delimits_objects(main, i, original_contents_delimits, original_contents_used, contents_delimits); - fss_embedded_list_read_process_delimits_contents(main, i, original_contents_delimits, original_contents_used, contents_delimits); + fss_embedded_list_read_process_delimits_objects(data, i, original_contents_delimits, original_contents_used, contents_delimits); + fss_embedded_list_read_process_delimits_contents(data, i, original_contents_delimits, original_contents_used, contents_delimits); } // for } } @@ -756,11 +756,11 @@ extern "C" { #endif // _di_fss_embedded_list_read_process_delimits_ #ifndef _di_fss_embedded_list_read_process_delimits_contents_ - void fss_embedded_list_read_process_delimits_contents(fss_embedded_list_read_main_t * const main, const f_array_length_t depth, const f_array_length_t original_delimits[], const f_array_length_t original_used, f_fss_delimits_t *delimits) { + void fss_embedded_list_read_process_delimits_contents(fss_embedded_list_read_data_t * const data, const f_array_length_t depth, const f_array_length_t original_delimits[], const f_array_length_t original_used, f_fss_delimits_t *delimits) { if (!original_used) return; - f_fss_items_t *items = &main->nest.depth[depth]; + f_fss_items_t *items = &data->nest.depth[depth]; if (!items->used) return; @@ -789,7 +789,7 @@ extern "C" { delimits->array[m] = delimits->array[m - 1]; } // for - if (fss_embedded_list_read_process_delimits_within_greater(main, depth, original_delimits[j]) == F_false) { + if (fss_embedded_list_read_process_delimits_within_greater(data, depth, original_delimits[j]) == F_false) { delimits->array[l] = original_delimits[j]; ++delimits->used; } @@ -797,7 +797,7 @@ extern "C" { break; } // for } - else if (fss_embedded_list_read_process_delimits_within_greater(main, depth, original_delimits[j]) == F_false) { + else if (fss_embedded_list_read_process_delimits_within_greater(data, depth, original_delimits[j]) == F_false) { delimits->array[0] = original_delimits[j]; delimits->used = 1; } @@ -809,11 +809,11 @@ extern "C" { #endif // _di_fss_embedded_list_read_process_delimits_contents_ #ifndef _di_fss_embedded_list_read_process_delimits_objects_ - void fss_embedded_list_read_process_delimits_objects(fss_embedded_list_read_main_t * const main, const f_array_length_t depth, const f_array_length_t original_delimits[], const f_array_length_t original_used, f_fss_delimits_t *delimits) { + void fss_embedded_list_read_process_delimits_objects(fss_embedded_list_read_data_t * const data, const f_array_length_t depth, const f_array_length_t original_delimits[], const f_array_length_t original_used, f_fss_delimits_t *delimits) { if (!original_used) return; - f_fss_items_t *items = &main->nest.depth[depth]; + f_fss_items_t *items = &data->nest.depth[depth]; if (!items->used) return; @@ -828,7 +828,7 @@ extern "C" { if (original_delimits[j] >= items->array[i].object.start && original_delimits[j] <= items->array[i].object.stop) { - // preserve linear order when adding back delimits. + // Preserve linear order when adding back delimits. if (delimits->used) { for (k = 0; k < delimits->used; ++k) { @@ -839,7 +839,7 @@ extern "C" { delimits->array[l] = delimits->array[l - 1]; } // for - if (fss_embedded_list_read_process_delimits_within_greater(main, depth, original_delimits[j]) == F_false) { + if (fss_embedded_list_read_process_delimits_within_greater(data, depth, original_delimits[j]) == F_false) { delimits->array[k] = original_delimits[j]; ++delimits->used; } @@ -847,7 +847,7 @@ extern "C" { break; } // for } - else if (fss_embedded_list_read_process_delimits_within_greater(main, depth, original_delimits[j]) == F_false) { + else if (fss_embedded_list_read_process_delimits_within_greater(data, depth, original_delimits[j]) == F_false) { delimits->array[0] = original_delimits[j]; delimits->used = 1; } @@ -858,17 +858,17 @@ extern "C" { #endif // _di_fss_embedded_list_read_process_delimits_objects_ #ifndef _di_fss_embedded_list_read_process_delimits_within_greater_ - f_status_t fss_embedded_list_read_process_delimits_within_greater(fss_embedded_list_read_main_t * const main, const f_array_length_t depth, const f_array_length_t location) { + f_status_t fss_embedded_list_read_process_delimits_within_greater(fss_embedded_list_read_data_t * const data, const f_array_length_t depth, const f_array_length_t location) { - if (depth + 1 >= main->nest.used) return F_false; + if (depth + 1 >= data->nest.used) return F_false; f_fss_items_t *items = 0; f_array_length_t i = 0; f_array_length_t j = 0; - for (f_array_length_t d = depth + 1; d < main->nest.used; ++d) { - items = &main->nest.depth[d]; + for (f_array_length_t d = depth + 1; d < data->nest.used; ++d) { + items = &data->nest.depth[d]; for (i = 0; i < items->used; ++i) { diff --git a/level_3/fss_embedded_list_read/c/private-read.h b/level_3/fss_embedded_list_read/c/private-read.h index e747ddb..f270708 100644 --- a/level_3/fss_embedded_list_read/c/private-read.h +++ b/level_3/fss_embedded_list_read/c/private-read.h @@ -17,8 +17,8 @@ extern "C" { * * Will handle depth-sensitive parameter conflicts, such as --name being used with --at (which is not allowed). * - * @param main - * The main program data. + * @param data + * The program data. * @param depths * This stores the pre-processed depth parameters. * @@ -28,14 +28,14 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fss_embedded_list_read_main_preprocess_depth_ - extern f_status_t fss_embedded_list_read_main_preprocess_depth(fss_embedded_list_read_main_t * const main, fss_embedded_list_read_depths_t *depths) F_attribute_visibility_internal_d; + extern f_status_t fss_embedded_list_read_main_preprocess_depth(fss_embedded_list_read_data_t * const data, fss_embedded_list_read_depths_t *depths) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_main_preprocess_depth_ /** * Process a given file. * - * @param main - * The main program data. + * @param data + * The program data. * @param file_name * The name of the file being processed. * @param depths @@ -57,7 +57,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fss_embedded_list_read_main_process_file_ - extern f_status_t fss_embedded_list_read_main_process_file(fss_embedded_list_read_main_t * const main, const f_string_static_t file_name, const fss_embedded_list_read_depths_t depths, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) F_attribute_visibility_internal_d; + extern f_status_t fss_embedded_list_read_main_process_file(fss_embedded_list_read_data_t * const data, const f_string_static_t file_name, const fss_embedded_list_read_depths_t depths, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_main_process_file_ /** @@ -65,8 +65,8 @@ extern "C" { * * This will recursively continue down the depth chain until the final depth is reached. * - * @param main - * The main program data. + * @param data + * The program data. * @param file_name * The name of the file being processed. * @param depths @@ -91,14 +91,14 @@ extern "C" { * @see fss_embedded_list_read_main_process_file() */ #ifndef _di_fss_embedded_list_read_main_process_for_depth_ - extern f_status_t fss_embedded_list_read_main_process_for_depth(fss_embedded_list_read_main_t * const main, const f_string_static_t filename, const fss_embedded_list_read_depths_t depths, const f_array_length_t depths_index, const f_array_length_t line, const fss_embedded_list_read_skip_t parents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) F_attribute_visibility_internal_d; + extern f_status_t fss_embedded_list_read_main_process_for_depth(fss_embedded_list_read_data_t * const data, const f_string_static_t filename, const fss_embedded_list_read_depths_t depths, const f_array_length_t depths_index, const f_array_length_t line, const fss_embedded_list_read_skip_t parents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_main_process_for_depth_ /** * Rewrite the object and content delimit ranges to be within the given depth range. * - * @param main - * The main program data. + * @param data + * The program data. * @param objects_delimits * An array of delimits detected during processing, for top-level objects. * @param contents_delimits @@ -107,14 +107,14 @@ extern "C" { * @see fss_embedded_list_read_main_process_file() */ #ifndef _di_fss_embedded_list_read_process_delimits_ - extern void fss_embedded_list_read_process_delimits(fss_embedded_list_read_main_t * const main, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) F_attribute_visibility_internal_d; + extern void fss_embedded_list_read_process_delimits(fss_embedded_list_read_data_t * const data, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_process_delimits_ /** * Write the given delimits at the given depth back into the new delimits array, specifically for contents. * - * @param main - * The main program data. + * @param data + * The program data. * @param depth * The depth in which to process. * @param original_delimits @@ -127,14 +127,14 @@ extern "C" { * @see fss_embedded_list_read_process_delimits() */ #ifndef _di_fss_embedded_list_read_process_delimits_contents_ - extern void fss_embedded_list_read_process_delimits_contents(fss_embedded_list_read_main_t * const main, const f_array_length_t depth, const f_array_length_t original_delimits[], const f_array_length_t original_used, f_fss_delimits_t *delimits) F_attribute_visibility_internal_d; + extern void fss_embedded_list_read_process_delimits_contents(fss_embedded_list_read_data_t * const data, const f_array_length_t depth, const f_array_length_t original_delimits[], const f_array_length_t original_used, f_fss_delimits_t *delimits) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_process_delimits_contents_ /** * Write the given delimits at the given depth back into the new delimits array, specifically for objects. * - * @param main - * The main program data. + * @param data + * The program data. * @param depth * The depth in which to process. * @param original_delimits @@ -147,14 +147,14 @@ extern "C" { * @see fss_embedded_list_read_process_delimits() */ #ifndef _di_fss_embedded_list_read_process_delimits_objects_ - extern void fss_embedded_list_read_process_delimits_objects(fss_embedded_list_read_main_t * const main, const f_array_length_t depth, const f_array_length_t original_delimits[], const f_array_length_t original_used, f_fss_delimits_t *delimits) F_attribute_visibility_internal_d; + extern void fss_embedded_list_read_process_delimits_objects(fss_embedded_list_read_data_t * const data, const f_array_length_t depth, const f_array_length_t original_delimits[], const f_array_length_t original_used, f_fss_delimits_t *delimits) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_process_delimits_objects_ /** * Determine if the given location is actually within another depth. * - * @param main - * The main program data. + * @param data + * The program data. * @param depth * The depth in which to process. * @param location @@ -168,7 +168,7 @@ extern "C" { * @see fss_embedded_list_read_process_delimits_contents() */ #ifndef _di_fss_embedded_list_read_process_delimits_within_greater_ - extern f_status_t fss_embedded_list_read_process_delimits_within_greater(fss_embedded_list_read_main_t * const main, const f_array_length_t depth, const f_array_length_t location) F_attribute_visibility_internal_d; + extern f_status_t fss_embedded_list_read_process_delimits_within_greater(fss_embedded_list_read_data_t * const data, const f_array_length_t depth, const f_array_length_t location) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_process_delimits_within_greater_ #ifdef __cplusplus -- 1.8.3.1