From f77e6b26ccbddecba18c968e8173ad590b653b71 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 29 May 2023 00:09:23 -0500 Subject: [PATCH] Progress: Continue work on refactoring fss_*_read into fss_read, focusing on fixing issues. Get the programs into better working state. I found several problems resulting from the way in which I migrated and refactored the code. I think the next thing to do is to instead start writing some runtime tests that can better find problems. Of particular note, I found problems with the comments being printed properly (which generally means not printed). Some parameter handling problems are also fixed. The payload and embedded list need special handling and are very much not implemented. --- level_3/fss_read/c/basic/fss_read.c | 16 --- level_3/fss_read/c/basic/main.c | 3 +- level_3/fss_read/c/basic/print.c | 20 ++++ level_3/fss_read/c/basic/print.h | 24 ++++ level_3/fss_read/c/basic_list/fss_read.c | 16 --- level_3/fss_read/c/basic_list/main.c | 3 +- level_3/fss_read/c/embedded_list/fss_read.c | 16 --- level_3/fss_read/c/embedded_list/main.c | 5 +- level_3/fss_read/c/embedded_list/print.c | 28 +++++ level_3/fss_read/c/embedded_list/print.h | 26 +++++ level_3/fss_read/c/extended/fss_read.c | 16 --- level_3/fss_read/c/extended/main.c | 5 +- level_3/fss_read/c/extended/print.c | 54 ++++----- level_3/fss_read/c/extended/print.h | 51 ++++---- level_3/fss_read/c/extended_list/fss_read.c | 16 --- level_3/fss_read/c/extended_list/main.c | 5 +- level_3/fss_read/c/extended_list/print.c | 28 +++++ level_3/fss_read/c/extended_list/print.h | 28 ++++- level_3/fss_read/c/main/common.c | 28 ++--- level_3/fss_read/c/main/common/type.h | 3 + level_3/fss_read/c/main/fss_read.c | 6 +- level_3/fss_read/c/main/main.c | 41 ++++--- level_3/fss_read/c/main/print/data.c | 28 ++--- level_3/fss_read/c/main/print/data.h | 27 +---- level_3/fss_read/c/main/print/error.c | 2 +- level_3/fss_read/c/main/process_normal.c | 173 ++++++++++++++++++++++++---- level_3/fss_read/c/main/process_normal.h | 29 +++++ level_3/fss_read/c/payload/fss_read.c | 2 + level_3/fss_read/c/payload/main.c | 2 +- level_3/fss_read/c/payload/print.c | 29 +++++ level_3/fss_read/c/payload/print.h | 26 +++++ 31 files changed, 518 insertions(+), 238 deletions(-) diff --git a/level_3/fss_read/c/basic/fss_read.c b/level_3/fss_read/c/basic/fss_read.c index b0cadec..6e7a635 100644 --- a/level_3/fss_read/c/basic/fss_read.c +++ b/level_3/fss_read/c/basic/fss_read.c @@ -21,22 +21,6 @@ extern "C" { fss_read_main_t * const main = (fss_read_main_t *) void_main; - if (main->setting.buffer.used) { - main->setting.range.start = 0; - main->setting.range.stop = main->setting.buffer.used; - } - else { - main->setting.range.start = 1; - main->setting.range.stop = 0; - } - - main->setting.comments.used = 0; - main->setting.delimits_object.used = 0; - main->setting.delimits_content.used = 0; - main->setting.nest.used = 0; - main->setting.quotes_object.used = 0; - main->setting.quotes_content.used = 0; - fll_fss_basic_read(main->setting.buffer, &main->setting.range, &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(main->setting.state.status)) { diff --git a/level_3/fss_read/c/basic/main.c b/level_3/fss_read/c/basic/main.c index 21da79a..ecd2a53 100644 --- a/level_3/fss_read/c/basic/main.c +++ b/level_3/fss_read/c/basic/main.c @@ -36,9 +36,10 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; + data.callback.print_content_next = 0; data.callback.print_content_ignore = 0; data.callback.print_object = &fss_read_print_object; - data.callback.print_object_end = &fss_read_print_object_end; + data.callback.print_object_end = &fss_read_basic_print_object_end; data.callback.print_set_end = &fss_read_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; diff --git a/level_3/fss_read/c/basic/print.c b/level_3/fss_read/c/basic/print.c index e71324a..788c332 100644 --- a/level_3/fss_read/c/basic/print.c +++ b/level_3/fss_read/c/basic/print.c @@ -34,6 +34,26 @@ extern "C" { } #endif // _di_fss_read_basic_print_help_ +#ifndef _di_fss_read_basic_print_object_end_ + f_status_t fss_read_basic_print_object_end(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; + + if (main->setting.flag & fss_read_main_flag_content_e) { + if (main->setting.flag & fss_read_main_flag_pipe_e) { + fll_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); + } + else { + fll_print_dynamic_raw(f_fss_basic_open_s, print->to); + } + } + + return F_none; + } +#endif // _di_fss_read_basic_print_object_end_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/basic/print.h b/level_3/fss_read/c/basic/print.h index d153b6e..40c5c3f 100644 --- a/level_3/fss_read/c/basic/print.h +++ b/level_3/fss_read/c/basic/print.h @@ -30,6 +30,30 @@ extern "C" { extern f_status_t fss_read_basic_print_help(fl_print_t * const print); #endif // _di_fss_read_basic_print_help_ +/** + * Print the end of an Object (which is often the start of Content). + * + * This locks, uses, and unlocks the file stream. + * + * @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_print_dynamic_raw() + */ +#ifndef _di_fss_read_basic_print_object_end_ + extern f_status_t fss_read_basic_print_object_end(fl_print_t * const print); +#endif // _di_fss_read_basic_print_object_end_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/basic_list/fss_read.c b/level_3/fss_read/c/basic_list/fss_read.c index fbdc775..6d6e4bf 100644 --- a/level_3/fss_read/c/basic_list/fss_read.c +++ b/level_3/fss_read/c/basic_list/fss_read.c @@ -21,22 +21,6 @@ extern "C" { fss_read_main_t * const main = (fss_read_main_t *) void_main; - if (main->setting.buffer.used) { - main->setting.range.start = 0; - main->setting.range.stop = main->setting.buffer.used; - } - else { - main->setting.range.start = 1; - main->setting.range.stop = 0; - } - - main->setting.comments.used = 0; - main->setting.delimits_object.used = 0; - main->setting.delimits_content.used = 0; - main->setting.nest.used = 0; - main->setting.quotes_object.used = 0; - main->setting.quotes_content.used = 0; - fll_fss_basic_list_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state); if (F_status_is_error(main->setting.state.status)) { diff --git a/level_3/fss_read/c/basic_list/main.c b/level_3/fss_read/c/basic_list/main.c index 3004244..a2fac6f 100644 --- a/level_3/fss_read/c/basic_list/main.c +++ b/level_3/fss_read/c/basic_list/main.c @@ -29,10 +29,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.process_line = &fss_read_process_normal_line; data.callback.process_load = &fss_read_basic_list_process_load; data.callback.process_name = &fss_read_process_normal_name; - data.callback.process_total = &fss_read_process_normal_total; + data.callback.process_total = &fss_read_process_normal_total_multiple; data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; + data.callback.print_content_next = 0; data.callback.print_content_ignore = &fss_read_print_content_ignore; data.callback.print_object = &fss_read_print_object; data.callback.print_object_end = &fss_read_basic_list_print_object_end; diff --git a/level_3/fss_read/c/embedded_list/fss_read.c b/level_3/fss_read/c/embedded_list/fss_read.c index 9cb2529..1725b21 100644 --- a/level_3/fss_read/c/embedded_list/fss_read.c +++ b/level_3/fss_read/c/embedded_list/fss_read.c @@ -21,22 +21,6 @@ extern "C" { fss_read_main_t * const main = (fss_read_main_t *) void_main; - if (main->setting.buffer.used) { - main->setting.range.start = 0; - main->setting.range.stop = main->setting.buffer.used; - } - else { - main->setting.range.start = 1; - main->setting.range.stop = 0; - } - - main->setting.comments.used = 0; - main->setting.delimits_object.used = 0; - main->setting.delimits_content.used = 0; - main->setting.nest.used = 0; - main->setting.quotes_object.used = 0; - main->setting.quotes_content.used = 0; - fll_fss_embedded_list_read(main->setting.buffer, &main->setting.range, &main->setting.nest, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state); if (F_status_is_error(main->setting.state.status)) { diff --git a/level_3/fss_read/c/embedded_list/main.c b/level_3/fss_read/c/embedded_list/main.c index 0abcb9f..089e154 100644 --- a/level_3/fss_read/c/embedded_list/main.c +++ b/level_3/fss_read/c/embedded_list/main.c @@ -31,13 +31,14 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.process_line = &fss_read_process_normal_line; data.callback.process_load = &fss_read_embedded_list_process_load; data.callback.process_name = &fss_read_process_normal_name; - data.callback.process_total = &fss_read_process_normal_total; + data.callback.process_total = &fss_read_process_normal_total_multiple; data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; + data.callback.print_content_next = 0; data.callback.print_content_ignore = &fss_read_print_content_ignore; data.callback.print_object = &fss_read_print_object; - data.callback.print_object_end = &fss_read_print_object_end; + data.callback.print_object_end = &fss_read_embedded_list_print_object_end; data.callback.print_set_end = &fss_read_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; diff --git a/level_3/fss_read/c/embedded_list/print.c b/level_3/fss_read/c/embedded_list/print.c index 5ea1df9..da4b651 100644 --- a/level_3/fss_read/c/embedded_list/print.c +++ b/level_3/fss_read/c/embedded_list/print.c @@ -34,6 +34,34 @@ extern "C" { } #endif // _di_fss_read_embedded_list_print_help_ +#ifndef _di_fss_read_embedded_list_print_object_end_ + f_status_t fss_read_embedded_list_print_object_end(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; + + f_file_stream_lock(print->to); + + if (main->setting.flag & fss_read_main_flag_pipe_e) { + f_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); + } + else { + if (main->setting.flag & fss_read_main_flag_content_e) { + f_print_dynamic_raw(f_fss_embedded_list_open_s, print->to); + f_print_dynamic_raw(f_fss_embedded_list_open_end_s, print->to); + } + else { + f_print_dynamic_raw(f_fss_eol_s, print->to); + } + } + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_embedded_list_print_object_end_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/embedded_list/print.h b/level_3/fss_read/c/embedded_list/print.h index 39efef1..f871663 100644 --- a/level_3/fss_read/c/embedded_list/print.h +++ b/level_3/fss_read/c/embedded_list/print.h @@ -30,6 +30,32 @@ extern "C" { extern f_status_t fss_read_embedded_list_print_help(fl_print_t * const print); #endif // _di_fss_read_embedded_list_print_help_ +/** + * Print the end of an Object (which is often the start of Content). + * + * This locks, uses, and unlocks the file stream. + * + * @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 f_file_stream_lock() + * @see f_file_stream_unlock() + * @see f_print_dynamic_raw() + */ +#ifndef _di_fss_read_embedded_list_print_object_end_ + extern f_status_t fss_read_embedded_list_print_object_end(fl_print_t * const print); +#endif // _di_fss_read_embedded_list_print_object_end_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/extended/fss_read.c b/level_3/fss_read/c/extended/fss_read.c index 2dc5405..0489d89 100644 --- a/level_3/fss_read/c/extended/fss_read.c +++ b/level_3/fss_read/c/extended/fss_read.c @@ -21,22 +21,6 @@ extern "C" { fss_read_main_t * const main = (fss_read_main_t *) void_main; - if (main->setting.buffer.used) { - main->setting.range.start = 0; - main->setting.range.stop = main->setting.buffer.used; - } - else { - main->setting.range.start = 1; - main->setting.range.stop = 0; - } - - main->setting.comments.used = 0; - main->setting.delimits_object.used = 0; - main->setting.delimits_content.used = 0; - main->setting.nest.used = 0; - main->setting.quotes_object.used = 0; - main->setting.quotes_content.used = 0; - fll_fss_extended_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.quotes_object, &main->setting.quotes_content, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.state); if (F_status_is_error(main->setting.state.status)) { diff --git a/level_3/fss_read/c/extended/main.c b/level_3/fss_read/c/extended/main.c index 46410f5..673b2c1 100644 --- a/level_3/fss_read/c/extended/main.c +++ b/level_3/fss_read/c/extended/main.c @@ -34,11 +34,12 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.process_name = &fss_read_process_normal_name; data.callback.process_total = &fss_read_process_normal_total; - data.callback.print_at = &fss_read_extended_print_at; + data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; data.callback.print_content_ignore = &fss_read_print_content_ignore; + data.callback.print_content_next = &fss_read_extended_print_content_next; data.callback.print_object = &fss_read_print_object; - data.callback.print_object_end = &fss_read_print_object_end; + data.callback.print_object_end = &fss_read_extended_print_object_end; data.callback.print_set_end = &fss_read_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; diff --git a/level_3/fss_read/c/extended/print.c b/level_3/fss_read/c/extended/print.c index 43b4c21..fc49463 100644 --- a/level_3/fss_read/c/extended/print.c +++ b/level_3/fss_read/c/extended/print.c @@ -4,44 +4,20 @@ extern "C" { #endif -#ifndef _di_fss_read_extended_print_at_ - f_status_t fss_read_extended_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) { +#ifndef _di_fss_read_extended_print_content_next_ + f_status_t fss_read_extended_print_content_next(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; - if (at >= main->setting.contents.used) return F_output_not; - - // @todo This is copied from fss_read_print_at() and needs to be updated to handle multiple content. - - if ((main->setting.flag & fss_read_main_flag_object_e) || (main->setting.flag & fss_read_main_flag_content_e) && (main->setting.contents.array[at].used || (main->setting.flag & fss_read_main_flag_empty_e))) { - if (main->setting.flag & fss_read_main_flag_object_e) { - if (main->callback.print_object) { - main->callback.print_object(&main->program.output, at, delimits_object); - } - - if (main->setting.flag & fss_read_main_flag_content_e) { - if (main->callback.print_object_end) { - main->callback.print_object_end(&main->program.output); - } - } - } - - 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].used ? main->setting.quotes_content.array[at].array[0] : 0, delimits_content); - } - } - - if (main->callback.print_set_end) { - main->callback.print_set_end(&main->program.output); - } + if (main->setting.flag & fss_read_main_flag_content_e) { + fll_print_dynamic_raw((main->setting.flag & fss_read_main_flag_pipe_e) ? fss_read_pipe_content_start_s : f_fss_extended_next_s, print->to); } return F_none; } -#endif // _di_fss_read_extended_print_at_ +#endif // _di_fss_read_extended_print_content_next_ #ifndef _di_fss_read_extended_print_help_ f_status_t fss_read_extended_print_help(fl_print_t * const print) { @@ -73,6 +49,26 @@ extern "C" { } #endif // _di_fss_read_extended_print_help_ +#ifndef _di_fss_read_extended_print_object_end_ + f_status_t fss_read_extended_print_object_end(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; + + if (main->setting.flag & fss_read_main_flag_content_e) { + if (main->setting.flag & fss_read_main_flag_pipe_e) { + fll_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); + } + else { + fll_print_dynamic_raw(f_fss_extended_open_s, print->to); + } + } + + return F_none; + } +#endif // _di_fss_read_extended_print_object_end_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/extended/print.h b/level_3/fss_read/c/extended/print.h index 51d60a9..8d7d834 100644 --- a/level_3/fss_read/c/extended/print.h +++ b/level_3/fss_read/c/extended/print.h @@ -13,24 +13,18 @@ extern "C" { #endif /** - * Process printing the buffer according to "at" position and given delimits. + * Print the next part of a Content. * * This locks, uses, and unlocks the file stream. * + * This is not the Content set end. + * * @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. - * @param at - * The "at" position to be printed. - * @param delimits_object - * The delimits array representing a delimited Object. - * This represents the positions within the current Object at the "at" position. - * @param delimits_content - * The delimits array representing a delimited Content. - * This represents the positions within the current Content at the "at" position. * * @return * F_none on success. @@ -38,18 +32,11 @@ extern "C" { * * F_output_not (with error bit) if a parameter is NULL. * - * @see fll_print_dynamic_partial() - * @see fll_print_except_dynamic_partial() - * @see fll_print_trim_dynamic_partial() - * @see fll_print_trim_except_dynamic_partial() - * - * @see main.callback.print_object() - * @see main.callback.print_object_end() - * @see main.callback.print_set_end() + * @see fll_print_dynamic_raw() */ -#ifndef _di_fss_read_extended_print_at_ - extern f_status_t fss_read_extended_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); -#endif // _di_fss_read_extended_print_at_ +#ifndef _di_fss_read_extended_print_content_next_ + extern f_status_t fss_read_extended_print_content_next(fl_print_t * const print); +#endif // _di_fss_read_extended_print_content_next_ /** * Print help for FSS-0001 (Extended). @@ -69,6 +56,30 @@ extern "C" { extern f_status_t fss_read_extended_print_help(fl_print_t * const print); #endif // _di_fss_read_extended_print_help_ +/** + * Print the end of an Object (which is often the start of Content). + * + * This locks, uses, and unlocks the file stream. + * + * @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_print_dynamic_raw() + */ +#ifndef _di_fss_read_extended_print_object_end_ + extern f_status_t fss_read_extended_print_object_end(fl_print_t * const print); +#endif // _di_fss_read_extended_print_object_end_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/extended_list/fss_read.c b/level_3/fss_read/c/extended_list/fss_read.c index 6989420..6c130e5 100644 --- a/level_3/fss_read/c/extended_list/fss_read.c +++ b/level_3/fss_read/c/extended_list/fss_read.c @@ -21,22 +21,6 @@ extern "C" { fss_read_main_t * const main = (fss_read_main_t *) void_main; - if (main->setting.buffer.used) { - main->setting.range.start = 0; - main->setting.range.stop = main->setting.buffer.used; - } - else { - main->setting.range.start = 1; - main->setting.range.stop = 0; - } - - main->setting.comments.used = 0; - main->setting.delimits_object.used = 0; - main->setting.delimits_content.used = 0; - main->setting.nest.used = 0; - main->setting.quotes_object.used = 0; - main->setting.quotes_content.used = 0; - fll_fss_extended_list_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state); if (F_status_is_error(main->setting.state.status)) { diff --git a/level_3/fss_read/c/extended_list/main.c b/level_3/fss_read/c/extended_list/main.c index 555bfa3..270ca22 100644 --- a/level_3/fss_read/c/extended_list/main.c +++ b/level_3/fss_read/c/extended_list/main.c @@ -29,13 +29,14 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.process_line = &fss_read_process_normal_line; data.callback.process_load = &fss_read_extended_list_process_load; data.callback.process_name = &fss_read_process_normal_name; - data.callback.process_total = &fss_read_process_normal_total; + data.callback.process_total = &fss_read_process_normal_total_multiple; data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; + data.callback.print_content_next = 0; data.callback.print_content_ignore = &fss_read_print_content_ignore; data.callback.print_object = &fss_read_print_object; - data.callback.print_object_end = &fss_read_print_object_end; + data.callback.print_object_end = &fss_read_extended_list_print_object_end; data.callback.print_set_end = &fss_read_extended_list_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; diff --git a/level_3/fss_read/c/extended_list/print.c b/level_3/fss_read/c/extended_list/print.c index 391a1e3..68ae81e 100644 --- a/level_3/fss_read/c/extended_list/print.c +++ b/level_3/fss_read/c/extended_list/print.c @@ -34,6 +34,34 @@ extern "C" { } #endif // _di_fss_read_extended_list_print_help_ +#ifndef _di_fss_read_extended_list_print_object_end_ + f_status_t fss_read_extended_list_print_object_end(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; + + f_file_stream_lock(print->to); + + if (main->setting.flag & fss_read_main_flag_pipe_e) { + f_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); + } + else { + if (main->setting.flag & fss_read_main_flag_content_e) { + f_print_dynamic_raw(f_fss_extended_list_open_s, print->to); + f_print_dynamic_raw(f_fss_extended_list_open_end_s, print->to); + } + else { + f_print_dynamic_raw(f_fss_eol_s, print->to); + } + } + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_extended_list_print_object_end_ + #ifndef _di_fss_read_extended_list_print_set_end_ f_status_t fss_read_extended_list_print_set_end(fl_print_t * const print) { diff --git a/level_3/fss_read/c/extended_list/print.h b/level_3/fss_read/c/extended_list/print.h index c3d655d..823832e 100644 --- a/level_3/fss_read/c/extended_list/print.h +++ b/level_3/fss_read/c/extended_list/print.h @@ -31,7 +31,7 @@ extern "C" { #endif // _di_fss_read_extended_list_print_help_ /** - * Print the end of an Object/Content set. + * Print the end of an Object (which is often the start of Content). * * This locks, uses, and unlocks the file stream. * @@ -50,6 +50,32 @@ extern "C" { * * @see fll_print_dynamic_raw() */ +#ifndef _di_fss_read_extended_list_print_object_end_ + extern f_status_t fss_read_extended_list_print_object_end(fl_print_t * const print); +#endif // _di_fss_read_extended_list_print_object_end_ + +/** + * Print the end of an Object/Content set. + * + * This locks, uses, and unlocks the file stream. + * + * @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 f_file_stream_lock() + * @see f_file_stream_unlock() + * @see f_print_dynamic_raw() + */ #ifndef _di_fss_read_extended_list_print_set_end_ extern f_status_t fss_read_extended_list_print_set_end(fl_print_t * const print); #endif // _di_fss_read_extended_list_print_set_end_ diff --git a/level_3/fss_read/c/main/common.c b/level_3/fss_read/c/main/common.c index 79008c1..0194308 100644 --- a/level_3/fss_read/c/main/common.c +++ b/level_3/fss_read/c/main/common.c @@ -190,22 +190,11 @@ extern "C" { for (i = 0; i < 6; ++i) { - 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->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) { - main->setting.state.flag |= parameter_flag[i]; + if (parameters->array[parameter_code[i]].result & f_console_result_value_e) { + main->setting.flag |= parameter_flag[i]; if (parameter_value_digit[i]) { - index = parameters->array[parameter_code[i]].values.array[parameters->array[parameter_code[i]].location]; + index = parameters->array[parameter_code[i]].values.array[parameters->array[parameter_code[i]].values.used - 1]; main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], parameter_value_digit[i]); @@ -216,6 +205,17 @@ extern "C" { } } } + else 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->program.error, f_console_symbol_long_normal_s, parameter_name[i], parameter_message[i]); + + return; + } } // for } diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index b759328..b574f42 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -134,6 +134,7 @@ extern "C" { * print_object: Print the Object, usually called by the process_normal() callback. * print_content: Print the Content, usually called by the process_normal() callback. * print_content_ignore: Print the Content ignore character, usually called by several callbacks within the process_normal() callback for a pipe. + * print_content_next: Print the Content next (content separator), usually called by several callbacks within the process_normal() callback. * print_object_end: Print the Object end, usually called by several callbacks within the process_normal() callback. * print_set_end: Print the Content set end, usually called by several callbacks within the process_normal() callback. */ @@ -154,6 +155,7 @@ extern "C" { f_status_t (*print_object)(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits); f_status_t (*print_content)(fl_print_t * const print, const f_string_range_t range, const uint8_t quote, const f_fss_delimits_t delimits); f_status_t (*print_content_ignore)(fl_print_t * const print); + f_status_t (*print_content_next)(fl_print_t * const print); f_status_t (*print_object_end)(fl_print_t * const print); f_status_t (*print_set_end)(fl_print_t * const print); } fss_read_callback_t; @@ -175,6 +177,7 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ } #endif // _di_fss_read_callback_t_ diff --git a/level_3/fss_read/c/main/fss_read.c b/level_3/fss_read/c/main/fss_read.c index 5c2d4c8..5ff1439 100644 --- a/level_3/fss_read/c/main/fss_read.c +++ b/level_3/fss_read/c/main/fss_read.c @@ -117,10 +117,8 @@ extern "C" { main->callback.print_object(&main->program.output, at, delimits_object); } - if (main->setting.flag & fss_read_main_flag_content_e) { - if (main->callback.print_object_end) { - main->callback.print_object_end(&main->program.output); - } + if (main->callback.print_object_end) { + main->callback.print_object_end(&main->program.output); } } diff --git a/level_3/fss_read/c/main/main.c b/level_3/fss_read/c/main/main.c index 25d0bbf..2544099 100644 --- a/level_3/fss_read/c/main/main.c +++ b/level_3/fss_read/c/main/main.c @@ -107,14 +107,15 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_line = &fss_read_process_normal_line; main->callback.process_load = 0; main->callback.process_name = &fss_read_process_normal_name; - main->callback.process_total = &fss_read_process_normal_total; + main->callback.process_total = 0; main->callback.print_at = &fss_read_print_at; main->callback.print_content = &fss_read_print_content; + main->callback.print_content_next = 0; main->callback.print_content_ignore = &fss_read_print_content_ignore; main->callback.print_object = &fss_read_print_object; - main->callback.print_object_end = &fss_read_print_object_end; - main->callback.print_set_end = &fss_read_print_set_end; + main->callback.print_object_end = 0; + main->callback.print_set_end = 0; if (main->program.parameters.array[fss_read_parameter_as_e].result & f_console_result_value_e && main->program.parameters.array[fss_read_parameter_as_e].values.used) { @@ -142,9 +143,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_help = &fss_read_basic_process_help; main->callback.process_load = &fss_read_basic_process_load; - main->callback.print_set_end = &fss_read_print_set_end; + main->callback.process_total = &fss_read_process_normal_total; - main->callback.print_object_end = &fss_read_print_object_end; + main->callback.print_content_next = 0; + main->callback.print_object_end = &fss_read_basic_print_object_end; + main->callback.print_set_end = &fss_read_print_set_end; } else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0001_s) == F_equal_to || f_compare_dynamic(argv[index], fss_read_format_code_long_0001_s) == F_equal_to || @@ -162,9 +165,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_help = &fss_read_extended_process_help; main->callback.process_load = &fss_read_extended_process_load; - main->callback.print_set_end = &fss_read_print_set_end_no_eol; + main->callback.process_total = &fss_read_process_normal_total; - main->callback.print_object_end = &fss_read_print_object_end; + main->callback.print_content_next = &fss_read_extended_print_content_next; + main->callback.print_object_end = &fss_read_extended_print_object_end; + main->callback.print_set_end = &fss_read_print_set_end_no_eol; } else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0002_s) == F_equal_to || f_compare_dynamic(argv[index], fss_read_format_code_long_0002_s) == F_equal_to || @@ -182,9 +187,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_help = &fss_read_basic_list_process_help; main->callback.process_load = &fss_read_basic_list_process_load; - main->callback.print_set_end = &fss_read_print_set_end; + main->callback.process_total = &fss_read_process_normal_total_multiple; + main->callback.print_content_next = 0; main->callback.print_object_end = &fss_read_basic_list_print_object_end; + main->callback.print_set_end = &fss_read_print_set_end; } else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0003_s) == F_equal_to || f_compare_dynamic(argv[index], fss_read_format_code_long_0003_s) == F_equal_to || @@ -202,9 +209,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_help = &fss_read_extended_list_process_help; main->callback.process_load = &fss_read_extended_list_process_load; - main->callback.print_set_end = &fss_read_print_set_end; + main->callback.process_total = &fss_read_process_normal_total_multiple; - main->callback.print_object_end = &fss_read_print_object_end; + main->callback.print_content_next = 0; + main->callback.print_object_end = &fss_read_extended_list_print_object_end; + main->callback.print_set_end = &fss_read_print_set_end; } else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0008_s) == F_equal_to || f_compare_dynamic(argv[index], fss_read_format_code_long_0008_s) == F_equal_to || @@ -222,9 +231,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_help = &fss_read_embedded_list_process_help; main->callback.process_load = &fss_read_embedded_list_process_load; - main->callback.print_set_end = &fss_read_print_set_end; + main->callback.process_total = &fss_read_process_normal_total_multiple; - main->callback.print_object_end = &fss_read_print_object_end; + main->callback.print_content_next = 0; + main->callback.print_object_end = &fss_read_embedded_list_print_object_end; + main->callback.print_set_end = &fss_read_print_set_end; } else if (f_compare_dynamic(argv[index], fss_read_format_code_short_000e_s) == F_equal_to || f_compare_dynamic(argv[index], fss_read_format_code_long_000e_s) == F_equal_to || @@ -242,9 +253,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_help = &fss_read_payload_process_help; main->callback.process_load = &fss_read_payload_process_load; - main->callback.print_set_end = &fss_read_print_set_end; + main->callback.process_total = &fss_read_process_normal_total_multiple; - main->callback.print_object_end = &fss_read_print_object_end; + main->callback.print_content_next = 0; + main->callback.print_object_end = &fss_read_payload_print_object_end; + main->callback.print_set_end = &fss_read_print_set_end; } else { if (main->setting.flag & fss_read_main_flag_help_e) { diff --git a/level_3/fss_read/c/main/print/data.c b/level_3/fss_read/c/main/print/data.c index cf612bd..4f28b4d 100644 --- a/level_3/fss_read/c/main/print/data.c +++ b/level_3/fss_read/c/main/print/data.c @@ -19,16 +19,21 @@ extern "C" { main->callback.print_object(&main->program.output, at, delimits_object); } - if (main->setting.flag & fss_read_main_flag_content_e) { - if (main->callback.print_object_end) { - main->callback.print_object_end(&main->program.output); - } + if (main->callback.print_object_end) { + main->callback.print_object_end(&main->program.output); } } 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].used ? main->setting.quotes_content.array[at].array[0] : 0, delimits_content); + for (f_array_length_t i = 0; i < main->setting.contents.array[at].used; ++i) { + + main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content); + + if (main->callback.print_content_next && i + 1 < main->setting.contents.array[at].used) { + main->callback.print_content_next(&main->program.output); + } + } // for } } @@ -146,19 +151,6 @@ extern "C" { } #endif // _di_fss_read_print_object_ -#ifndef _di_fss_read_print_object_end_ - f_status_t fss_read_print_object_end(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; - - fll_print_dynamic_raw((main->setting.flag & fss_read_main_flag_pipe_e) ? fss_read_pipe_content_start_s : f_fss_space_s, print->to); - - return F_none; - } -#endif // _di_fss_read_print_object_end_ - #ifndef _di_fss_read_print_quote_ f_status_t fss_read_print_quote(fl_print_t * const print, const uint8_t type) { diff --git a/level_3/fss_read/c/main/print/data.h b/level_3/fss_read/c/main/print/data.h index d013f09..8430f65 100644 --- a/level_3/fss_read/c/main/print/data.h +++ b/level_3/fss_read/c/main/print/data.h @@ -21,6 +21,8 @@ extern "C" { * * This locks, uses, and unlocks the file stream. * + * This processes multiple Content ranges and calls main.callback.print_content() for each individual Content range. + * * @param print * The output structure to print to. * @@ -61,6 +63,7 @@ extern "C" { * * This locks, uses, and unlocks the file stream. * + * This processes single Content range. * This does not print a new line after the Content. * * @param print @@ -178,30 +181,6 @@ extern "C" { #endif // _di_fss_read_print_object_ /** - * Print the end of an Object (which is often the start of Content). - * - * This locks, uses, and unlocks the file stream. - * - * @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_print_dynamic_raw() - */ -#ifndef _di_fss_read_print_object_end_ - extern f_status_t fss_read_print_object_end(fl_print_t * const print); -#endif // _di_fss_read_print_object_end_ - -/** * Print the Object at the given position. * * This locks, uses, and unlocks the file stream. diff --git a/level_3/fss_read/c/main/print/error.c b/level_3/fss_read/c/main/print/error.c index 7373fa7..d2eb25d 100644 --- a/level_3/fss_read/c/main/print/error.c +++ b/level_3/fss_read/c/main/print/error.c @@ -38,7 +38,7 @@ extern "C" { fl_print_format("%[%QThe parameter '%]", print->to, print->context, print->prefix, print->context); fl_print_format("%[%r%r%]", print->to, print->notable, symbol, name, print->notable); - fl_print_format("%[' requires %s.%]%r", print->to, print->context, message, print->context, f_string_eol_s); + fl_print_format("%[' requires %Q.%]%r", print->to, print->context, message, print->context, f_string_eol_s); f_file_stream_unlock(print->to); diff --git a/level_3/fss_read/c/main/process_normal.c b/level_3/fss_read/c/main/process_normal.c index 09ac7da..1880e7a 100644 --- a/level_3/fss_read/c/main/process_normal.c +++ b/level_3/fss_read/c/main/process_normal.c @@ -29,6 +29,24 @@ extern "C" { // The process_load() callback is required to be non-NULL. if (!main->callback.process_load) return; + if (main->setting.buffer.used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.buffer.used; + } + else { + main->setting.range.start = 1; + main->setting.range.stop = 0; + } + + main->setting.objects.used = 0; + main->setting.contents.used = 0; + main->setting.comments.used = 0; + main->setting.delimits_object.used = 0; + main->setting.delimits_content.used = 0; + main->setting.nest.used = 0; + main->setting.quotes_object.used = 0; + main->setting.quotes_content.used = 0; + main->callback.process_load(main); if (F_status_is_error(main->setting.state.status)) return; @@ -47,26 +65,34 @@ extern "C" { memset(names, F_true, sizeof(bool) * main->setting.objects.used); } - if (main->callback.process_at) { - main->callback.process_at(main, names, *delimits_object, *delimits_content); + if (main->setting.flag & fss_read_main_flag_at_e) { + if (main->callback.process_at) { + main->callback.process_at(main, names, *delimits_object, *delimits_content); + } return; } - if ((main->setting.flag & fss_read_main_flag_columns_e) && main->callback.process_columns) { - main->callback.process_columns(main, names); + if (main->setting.flag & fss_read_main_flag_columns_e) { + if (main->callback.process_columns) { + main->callback.process_columns(main, names); + } return; } - if ((main->setting.flag & fss_read_main_flag_total_e) && main->callback.process_total) { - main->callback.process_total(main, names); + if (main->setting.flag & fss_read_main_flag_total_e) { + if (main->callback.process_total) { + main->callback.process_total(main, names); + } return; } - if ((main->setting.flag & fss_read_main_flag_line_e) && main->callback.process_line) { - main->callback.process_line(main, names); + if (main->setting.flag & fss_read_main_flag_line_e) { + if (main->callback.process_line) { + main->callback.process_line(main, names); + } return; } @@ -118,9 +144,11 @@ extern "C" { f_array_length_t i = 0; f_array_length_t j = 0; f_array_length_t k = 0; + f_array_length_t l = 0; f_array_length_t at = 0; f_array_length_t line = 0; f_array_length_t total = 0; + f_string_range_t range = f_string_range_t_initialize; for (; i < main->setting.objects.used; ++i) { @@ -130,25 +158,39 @@ extern "C" { if (at == main->setting.depths.array[0].value_at) { if (main->setting.flag & fss_read_main_flag_line_e) { - // For standards that only support one line per Object so when using "--at", then the only valid line is line 0. - if (main->setting.flag & fss_read_main_flag_line_single_e) break; + // If using "--at" for standards that only support one line per Object, then the only valid line is line 0. + if ((main->setting.flag & fss_read_main_flag_line_single_e) && !at) break; line = 0; if (main->setting.flag & fss_read_main_flag_total_e) { + total = 0; + l = 0; + + for (j = 0; j < main->setting.contents.array[i].used; ++j) { + + if (main->setting.contents.array[i].array[j].start > main->setting.contents.array[i].array[j].stop) continue; - // Total is always 1 in this case because "line" parameter forces a single line. - fss_read_print_number(&main->program.output, 1); + if (l < main->setting.comments.used) { + while (main->setting.comments.array[l].stop < k) ++l; + + if (k >= main->setting.comments.array[l].start && k <= main->setting.comments.array[l].stop) { + k = main->setting.comments.array[l++].stop; + + continue; + } + } + + total = 1; + + break; + } // for + + fss_read_print_number(&main->program.output, total); } else { fss_read_process_at_line(main, i, delimits_object, delimits_content, &line); } - - if (main->setting.state.status == F_success) { - main->setting.state.status = F_none; - - return; - } } else if (main->setting.flag & fss_read_main_flag_columns_e) { fss_read_print_number(&main->program.output, main->setting.contents.array[i].used); @@ -159,15 +201,28 @@ extern "C" { } else { total = 0; - k = 0; + l = 0; - // Count each new line. for (j = 0; j < main->setting.contents.array[i].used; ++j) { - if (main->setting.contents.array[i].array[j].start > main->setting.contents.array[i].array[j].stop) continue; - if (main->setting.contents.array[i].array[j].start > main->setting.buffer.used) continue; + range.start = main->setting.contents.array[i].array[j].start; + range.stop = main->setting.contents.array[i].array[j].stop; + + // This content has no data, do not even check "include empty" because it cannot be counted as a line. + if (range.start > range.stop) continue; + + for (k = range.start; k <= range.stop; ++k) { + + if (l < main->setting.comments.used) { + while (main->setting.comments.array[l].stop < k) ++l; + + if (k >= main->setting.comments.array[l].start && k <= main->setting.comments.array[l].stop) { + k = main->setting.comments.array[l++].stop; + + continue; + } + } - for (k = main->setting.contents.array[i].array[j].start; k <= main->setting.contents.array[i].array[j].stop && k < main->setting.buffer.used; ++k) { if (main->setting.buffer.string[k] == f_string_eol_s.string[0]) ++total; } // for } // for @@ -357,7 +412,7 @@ extern "C" { if (!names[i]) continue; if (fss_read_signal_check(main)) return; - if (!(main->setting.flag & fss_read_main_flag_object_e) && main->setting.flag & fss_read_main_flag_content_e) { + if (!(main->setting.flag & fss_read_main_flag_object_e) && (main->setting.flag & fss_read_main_flag_content_e)) { if (!(main->setting.contents.array[i].used || (main->setting.flag & fss_read_main_flag_empty_e))) continue; } @@ -375,6 +430,76 @@ extern "C" { } #endif // _di_fss_read_process_normal_total_ +#ifndef _di_fss_read_process_normal_total_multiple_ + void fss_read_process_normal_total_multiple(void * const void_main, const bool names[]) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + f_array_length_t total = 0; + f_string_range_t range = f_string_range_t_initialize; + f_array_length_t i = 0; + f_array_length_t j = 0; + f_array_length_t k = 0; + + for (f_array_length_t at = 0; at < main->setting.contents.used; ++at) { + + if (!names[at]) continue; + if (fss_read_signal_check(main)) return; + + if (main->setting.flag & fss_read_main_flag_object_e) { + ++total; + } + + if (main->setting.flag & fss_read_main_flag_content_e) { + + if (!main->setting.contents.array[at].used) continue; + + for (i = 0; i < main->setting.contents.array[at].used; ++i) { + + range.start = main->setting.contents.array[at].array[i].start; + range.stop = main->setting.contents.array[at].array[i].stop; + + // This content has no data, do not even check "include empty" because it cannot be counted as a line. + if (range.start > range.stop) continue; + + for (j = range.start; j <= range.stop; ++j) { + + if (k < main->setting.comments.used) { + while (main->setting.comments.array[k].stop < j) ++k; + + if (j >= main->setting.comments.array[k].start && j <= main->setting.comments.array[k].stop) { + j = main->setting.comments.array[k++].stop; + + continue; + } + } + + if (main->setting.buffer.string[j] == f_string_eol_s.string[0]) ++total; + } // for + } // for + + // If Content does not end with a newline, it still must be treated as the last line. + if (i) { + j = main->setting.contents.array[at].array[i - 1].stop; + + if (main->setting.buffer.string[j] != f_string_eol_s.string[0]) ++total; + } + } + } // for + + fss_read_print_number( + &main->program.output, + main->setting.flag & fss_read_main_flag_line_e + ? main->setting.line < total ? 1 : 0 + : total + ); + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_process_normal_total_multiple_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/main/process_normal.h b/level_3/fss_read/c/main/process_normal.h index dfa3e2c..911301a 100644 --- a/level_3/fss_read/c/main/process_normal.h +++ b/level_3/fss_read/c/main/process_normal.h @@ -48,6 +48,8 @@ extern "C" { /** * Process buffer according to "at" parameter rules. * + * This handles only a single depth (index 0 of the depth array). + * * @param main * The program and settings data. * @@ -147,6 +149,8 @@ extern "C" { /** * Process buffer according to "total" parameter rules. * + * This processes single line Content only. + * * @param main * The program and settings data. * @@ -167,6 +171,31 @@ extern "C" { extern void fss_read_process_normal_total(void * const main, const bool names[]); #endif // _di_fss_read_process_normal_total_ +/** + * Process buffer according to "total" parameter rules. + * + * This processes multi-line Content only. + * + * @param main + * The program and settings data. + * + * Must not be NULL. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * + * Errors (with error bit) from: fss_read_signal_check(). + * @param names + * An array of booleans representing if the name at a given index is enabled. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * + * @see fss_read_signal_check() + */ +#ifndef _di_fss_read_process_normal_total_multiple_ + extern void fss_read_process_normal_total_multiple(void * const main, const bool names[]); +#endif // _di_fss_read_process_normal_total_multiple_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/payload/fss_read.c b/level_3/fss_read/c/payload/fss_read.c index 4331a30..35cb7f8 100644 --- a/level_3/fss_read/c/payload/fss_read.c +++ b/level_3/fss_read/c/payload/fss_read.c @@ -30,6 +30,8 @@ extern "C" { main->setting.range.stop = 0; } + main->setting.objects.used = 0; + main->setting.contents.used = 0; main->setting.comments.used = 0; main->setting.delimits_object.used = 0; main->setting.delimits_content.used = 0; diff --git a/level_3/fss_read/c/payload/main.c b/level_3/fss_read/c/payload/main.c index 034df72..60ab238 100644 --- a/level_3/fss_read/c/payload/main.c +++ b/level_3/fss_read/c/payload/main.c @@ -35,7 +35,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_content = &fss_read_print_content; data.callback.print_content_ignore = &fss_read_print_content_ignore; data.callback.print_object = &fss_read_print_object; - data.callback.print_object_end = &fss_read_print_object_end; + data.callback.print_object_end = &fss_read_payload_print_object_end; data.callback.print_set_end = &fss_read_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; diff --git a/level_3/fss_read/c/payload/print.c b/level_3/fss_read/c/payload/print.c index 2b5ccca..d502b78 100644 --- a/level_3/fss_read/c/payload/print.c +++ b/level_3/fss_read/c/payload/print.c @@ -56,6 +56,35 @@ extern "C" { } #endif // _di_fss_read_payload_print_help_ +#ifndef _di_fss_read_payload_print_object_end_ + f_status_t fss_read_payload_print_object_end(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; + + + f_file_stream_lock(print->to); + + if (main->setting.flag & fss_read_main_flag_pipe_e) { + f_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); + } + else { + if (main->setting.flag & fss_read_main_flag_content_e) { + f_print_dynamic_raw(f_fss_payload_list_open_s, print->to); + f_print_dynamic_raw(f_fss_payload_list_open_end_s, print->to); + } + else { + f_print_dynamic_raw(f_fss_eol_s, print->to); + } + } + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_payload_print_object_end_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/payload/print.h b/level_3/fss_read/c/payload/print.h index a2240d6..cd97707 100644 --- a/level_3/fss_read/c/payload/print.h +++ b/level_3/fss_read/c/payload/print.h @@ -50,6 +50,32 @@ extern "C" { extern f_status_t fss_read_payload_print_help(fl_print_t * const print); #endif // _di_fss_read_payload_print_help_ +/** + * Print the end of an Object (which is often the start of Content). + * + * This locks, uses, and unlocks the file stream. + * + * @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 f_file_stream_lock() + * @see f_file_stream_unlock() + * @see f_print_dynamic_raw() + */ +#ifndef _di_fss_read_payload_print_object_end_ + extern f_status_t fss_read_payload_print_object_end(fl_print_t * const print); +#endif // _di_fss_read_payload_print_object_end_ + #ifdef __cplusplus } // extern "C" #endif -- 1.8.3.1