From: Kevin Day Date: Thu, 22 Aug 2024 04:15:13 +0000 (-0500) Subject: Progress: Begin working on getting FSS Embedded Read working. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=82613d8e3ddf1af42c3adc497df0fc1df26fbc03;p=fll Progress: Begin working on getting FSS Embedded Read working. The FSS Embedded Read is not working because nothing is actually implemented. The problem is that the Nest structure is different from the standard Object and Content structure. Only a single depth is to be processed. This means that I can construct an Objects and Contents from the Nest based on the depth and pass that to the existing functions. The initial work has been started but it is very much incomplete. There is a lot of work to do in this regard. --- diff --git a/level_3/fss_read/c/embedded_list/fss_read.h b/level_3/fss_read/c/embedded_list/fss_read.h index be8f50a..06b66ce 100644 --- a/level_3/fss_read/c/embedded_list/fss_read.h +++ b/level_3/fss_read/c/embedded_list/fss_read.h @@ -60,6 +60,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_read/c/embedded_list/main.c b/level_3/fss_read/c/embedded_list/main.c index 4157326..770b97e 100644 --- a/level_3/fss_read/c/embedded_list/main.c +++ b/level_3/fss_read/c/embedded_list/main.c @@ -25,7 +25,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.process_help = &fss_read_embedded_list_process_help; data.callback.process_last_line = &fss_read_process_last_line; - data.callback.process_normal = &fss_read_process_normal; + data.callback.process_normal = &fss_read_embedded_list_process_normal; data.callback.process_at = &fss_read_process_normal_at; data.callback.process_at_line = &fss_read_process_normal_at_line; @@ -42,7 +42,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_object_end = &fss_read_embedded_list_print_object_end; data.callback.print_object_end_content = &fss_read_embedded_list_print_object_end_content; data.callback.print_object_end_empty = &fss_read_embedded_list_print_object_end_empty; - data.callback.print_set_end = &fss_read_print_set_end; + data.callback.print_set_end = &fss_read_embedded_list_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; diff --git a/level_3/fss_read/c/embedded_list/process_normal.c b/level_3/fss_read/c/embedded_list/process_normal.c new file mode 100644 index 0000000..398bd30 --- /dev/null +++ b/level_3/fss_read/c/embedded_list/process_normal.c @@ -0,0 +1,156 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_embedded_list_process_normal_ + void fss_read_embedded_list_process_normal(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + // The process_load() callback is required to be non-NULL. + if (!main->callback.process_load) return; + + // @todo this now needs to handle this case: main->setting.flag & fss_read_main_flag_depth_multiple_d and this case main->setting.flag & fss_read_main_flag_select_d. + + 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; + + fss_read_embedded_list_process_normal_determine_depth(main); + if (F_status_is_error(main->setting.state.status)) return; + + // @todo everything below here will need to be reviewed and updated. + + const f_number_unsigneds_t * const delimits_object = !(main->setting.flag & fss_read_main_flag_original_d) && fss_read_delimit_object_is(main, 0) ? &main->setting.delimits_object : &fss_read_except_none_c; + const f_number_unsigneds_t * const delimits_content = !(main->setting.flag & fss_read_main_flag_original_d) && fss_read_delimit_content_is(main, 0) ? &main->setting.delimits_content : &fss_read_except_none_c; + + bool names[main->setting.objects.used]; + + if (main->callback.process_name) { + main->callback.process_name(main, names); + if (F_status_is_error(main->setting.state.status)) return; + } + else if (main->setting.objects.used) { + + // If no processing is enabled, then default to F_true to enable all names. + memset(names, F_true, sizeof(bool) * main->setting.objects.used); + } + + if (main->setting.flag & fss_read_main_flag_total_d) { + if (main->callback.process_total) { + main->callback.process_total(main, names); + } + } + else if (main->setting.flag & fss_read_main_flag_at_d) { + if (main->callback.process_at) { + + main->callback.process_at(main, names, *delimits_object, *delimits_content); + } + } + else if (main->setting.flag & fss_read_main_flag_columns_d) { + if (main->callback.process_columns) { + main->callback.process_columns(main, names); + } + } + else { + f_number_unsigned_t i = 0; + + if (main->setting.flag & fss_read_main_flag_line_d) { + if (main->callback.process_at_line) { + f_number_unsigned_t line = 0; + + for (; i < main->setting.contents.used && main->setting.state.status != F_success; ++i) { + + if (!names[i]) continue; + if (fss_read_signal_check(main)) return; + + main->callback.process_at_line(void_main, i, *delimits_object, *delimits_content, &line); + if (F_status_is_error(main->setting.state.status)) return; + } // for + } + } + else if (main->callback.print_at) { + for (; i < main->setting.contents.used; ++i) { + + if (!names[i]) continue; + if (fss_read_signal_check(main)) return; + + main->callback.print_at(&main->program.output, i, *delimits_object, *delimits_content); + } // for + } + } + + if (F_status_is_error(main->setting.state.status)) return; + + main->setting.state.status = F_okay; + } +#endif // _di_fss_read_embedded_list_process_normal_ + +#ifndef _di_fss_read_embedded_list_process_normal_determine_depth_ + void fss_read_embedded_list_process_normal_determine_depth(fss_read_main_t * const main) { + + if (!main) return; + + if (main->setting.flag & fss_read_main_flag_depth_d) { + // @todo determine depth and dynamically construct the objects and therefore content based on any of --at, --depth, and --name. + return; + } + + if (!main->setting.nest.used || !main->setting.nest.depth[0].used) return; + + main->setting.objects.used = 0; + main->setting.contents.used = 0; + + main->setting.state.status = f_memory_array_resize(main->setting.nest.depth[0].used, sizeof(f_range_t), (void **) &main->setting.objects.array, &main->setting.objects.used, &main->setting.objects.size); + if (F_status_is_error(main->setting.state.status)) return; + + main->setting.state.status = f_memory_array_resize(main->setting.nest.depth[0].used, sizeof(f_ranges_t), (void **) &main->setting.contents.array, &main->setting.contents.used, &main->setting.contents.size); + if (F_status_is_error(main->setting.state.status)) return; + + for (; main->setting.objects.used < main->setting.nest.depth[0].used; ++main->setting.objects.used) { + + main->setting.objects.array[main->setting.objects.used] = main->setting.nest.depth[0].array[main->setting.objects.used].object; + + // Use a static array for the inner Content that points to the depth, and so ensure the size is 0 to designate this is not dynamically allocated here. + if (main->setting.nest.depth[0].array[main->setting.objects.used].content.size) { + main->setting.contents.array[main->setting.objects.used].array = main->setting.nest.depth[0].array[main->setting.objects.used].content.array; + main->setting.contents.array[main->setting.objects.used].used = main->setting.nest.depth[0].array[main->setting.objects.used].content.used; + main->setting.contents.array[main->setting.objects.used].size = 0; + main->setting.contents.array[main->setting.objects.used].used = 777; + } + else { + main->setting.contents.array[main->setting.objects.used].array = 0; + main->setting.contents.array[main->setting.objects.used].used = 0; + main->setting.contents.array[main->setting.objects.used].size = 0; + } + } // for + + main->setting.contents.used = main->setting.objects.used; + } +#endif // _di_fss_read_embedded_list_process_normal_determine_depth_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/embedded_list/process_normal.h b/level_3/fss_read/c/embedded_list/process_normal.h new file mode 100644 index 0000000..adc77e4 --- /dev/null +++ b/level_3/fss_read/c/embedded_list/process_normal.h @@ -0,0 +1,65 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides process normal functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_read_embedded_list_process_normal_h +#define _fss_read_embedded_list_process_normal_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Process normally, reading from the input for the Embedded List FSS format. + * + * @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_okay on success. + * + * Errors (with error bit) from: fss_read_signal_check(). + * + * @see fss_read_signal_check() + */ +#ifndef _di_fss_read_embedded_list_process_normal_ + extern void fss_read_embedded_list_process_normal(void * const main); +#endif // _di_fss_read_embedded_list_process_normal_ + +/** + * Determine the depth in which the processing will happen and construct the Objects and Contents mapping based on this. + * + * @param main + * The program and settings data. + * + * Must not be NULL. + * + * This alters main.setting.state.status: + * F_okay on success. + * + * Errors (with error bit) from: fss_read_signal_check(). + * + * @return + * The depth to use. + * + * @see fss_read_signal_check() + */ +#ifndef _di_fss_read_embedded_list_process_normal_determine_depth_ + extern void fss_read_embedded_list_process_normal_determine_depth(fss_read_main_t * const main); +#endif // _di_fss_read_embedded_list_process_normal_determine_depth_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_embedded_list_process_normal_h diff --git a/level_3/fss_read/c/extended_list/main.c b/level_3/fss_read/c/extended_list/main.c index 1b093f7..6d3338b 100644 --- a/level_3/fss_read/c/extended_list/main.c +++ b/level_3/fss_read/c/extended_list/main.c @@ -40,7 +40,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_object = &fss_read_print_object; data.callback.print_object_end = &fss_read_extended_list_print_object_end; data.callback.print_object_end_content = &fss_read_extended_list_print_object_end_content; - data.callback.print_object_end_empty = &fss_read_extended_list_print_object_end; + data.callback.print_object_end_empty = &fss_read_extended_list_print_object_end_empty; 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/main/main.c b/level_3/fss_read/c/main/main.c index 173355f..072ad30 100644 --- a/level_3/fss_read/c/main/main.c +++ b/level_3/fss_read/c/main/main.c @@ -159,8 +159,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + main->callback.process_at = &fss_read_process_normal_at; + main->callback.process_at_line = &fss_read_process_normal_at_line; + main->callback.process_columns = &fss_read_process_normal_columns; main->callback.process_help = &fss_read_basic_process_help; main->callback.process_load = &fss_read_basic_process_load; + main->callback.process_name = &fss_read_process_normal_name; + main->callback.process_normal = &fss_read_process_normal; main->callback.process_total = &fss_read_process_normal_total; main->callback.print_content_ignore = 0; @@ -191,8 +196,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + main->callback.process_at = &fss_read_process_normal_at; + main->callback.process_at_line = &fss_read_process_normal_at_line; + main->callback.process_columns = &fss_read_process_normal_columns; main->callback.process_help = &fss_read_extended_process_help; main->callback.process_load = &fss_read_extended_process_load; + main->callback.process_name = &fss_read_process_normal_name; + main->callback.process_normal = &fss_read_process_normal; main->callback.process_total = &fss_read_process_normal_total; main->callback.print_content_next = &fss_read_extended_print_content_next; @@ -223,8 +233,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + main->callback.process_at = &fss_read_process_normal_at; + main->callback.process_at_line = &fss_read_process_normal_at_line; + main->callback.process_columns = &fss_read_process_normal_columns; main->callback.process_help = &fss_read_basic_list_process_help; main->callback.process_load = &fss_read_basic_list_process_load; + main->callback.process_name = &fss_read_process_normal_name; + main->callback.process_normal = &fss_read_process_normal; main->callback.process_total = &fss_read_process_normal_total_multiple; main->callback.print_content_next = 0; @@ -255,8 +270,14 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + + main->callback.process_at = &fss_read_process_normal_at; + main->callback.process_at_line = &fss_read_process_normal_at_line; + main->callback.process_columns = &fss_read_process_normal_columns; main->callback.process_help = &fss_read_extended_list_process_help; main->callback.process_load = &fss_read_extended_list_process_load; + main->callback.process_name = &fss_read_process_normal_name; + main->callback.process_normal = &fss_read_process_normal; main->callback.process_total = &fss_read_process_normal_total_multiple; main->callback.print_content_next = 0; @@ -287,8 +308,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + main->callback.process_at = &fss_read_process_normal_at; + main->callback.process_at_line = &fss_read_process_normal_at_line; + main->callback.process_columns = &fss_read_process_normal_columns; main->callback.process_help = &fss_read_embedded_list_process_help; main->callback.process_load = &fss_read_embedded_list_process_load; + main->callback.process_name = &fss_read_process_normal_name; + main->callback.process_normal = &fss_read_embedded_list_process_normal; main->callback.process_total = &fss_read_process_normal_total_multiple; main->callback.print_content_next = 0; @@ -318,8 +344,14 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->program.parameters.array[fss_read_parameter_payload_e].flag &= ~f_console_flag_disable_e; + + main->callback.process_at = &fss_read_process_normal_at; + main->callback.process_at_line = &fss_read_process_normal_at_line; + main->callback.process_columns = &fss_read_process_normal_columns; main->callback.process_help = &fss_read_payload_process_help; main->callback.process_load = &fss_read_payload_process_load; + main->callback.process_name = &fss_read_process_normal_name; + main->callback.process_normal = &fss_read_process_normal; main->callback.process_total = &fss_read_process_normal_total_multiple; main->callback.print_content_next = 0; diff --git a/level_3/fss_read/c/main/print/data.c b/level_3/fss_read/c/main/print/data.c index 9476cfc..4521b3e 100644 --- a/level_3/fss_read/c/main/print/data.c +++ b/level_3/fss_read/c/main/print/data.c @@ -63,11 +63,11 @@ extern "C" { print_state &= ~0x8; if (print_state & 0x1) { - if (F_status_set_fine(main->callback.print_object_end_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)) != F_output_not) { + if (F_status_set_fine(main->callback.print_object_end_content(&main->program.output, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content)) != F_output_not) { print_state |= 0x6; } } - else if (F_status_set_fine(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)) != F_output_not) { + else if (F_status_set_fine(main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content)) != F_output_not) { print_state |= 0x2; } @@ -86,7 +86,7 @@ extern "C" { main->callback.print_content_next(&main->program.output); } - 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); + main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content); } } // for } diff --git a/level_3/fss_read/data/build/settings b/level_3/fss_read/data/build/settings index 47800b6..24f122e 100644 --- a/level_3/fss_read/data/build/settings +++ b/level_3/fss_read/data/build/settings @@ -43,7 +43,7 @@ build_libraries-monolithic -lfll build_sources_library main/fss_read.c main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/static.c main/common/string.c main/common/type.c main/print/data.c main/print/error.c main/print/message.c main/process_normal.c main/signal.c main/thread.c build_sources_library basic/fss_read.c basic/common.c basic/print.c build_sources_library basic_list/fss_read.c basic_list/common.c basic_list/print.c -build_sources_library embedded_list/fss_read.c embedded_list/common.c embedded_list/print.c +build_sources_library embedded_list/fss_read.c embedded_list/common.c embedded_list/print.c embedded_list/process_normal.c build_sources_library extended/fss_read.c extended/common.c extended/print.c build_sources_library extended_list/fss_read.c extended_list/common.c extended_list/print.c build_sources_library payload/fss_read.c payload/common.c payload/print.c @@ -51,7 +51,7 @@ build_sources_library payload/fss_read.c payload/common.c payload/print.c build_sources_headers main/fss_read.h main/common.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/static.h main/common/string.h main/common/type.h main/print/data.h main/print/error.h main/print/message.h main/process_normal.h main/signal.h main/thread.h build_sources_headers basic/fss_read.h basic/common.h basic/print.h build_sources_headers basic_list/fss_read.h basic_list/common.h basic_list/print.h -build_sources_headers embedded_list/fss_read.h embedded_list/common.h embedded_list/print.h +build_sources_headers embedded_list/fss_read.h embedded_list/common.h embedded_list/print.h embedded_list/process_normal.h build_sources_headers extended/fss_read.h extended/common.h extended/print.h build_sources_headers extended_list/fss_read.h extended_list/common.h extended_list/print.h build_sources_headers payload/fss_read.h payload/common.h payload/print.h