]> Kevux Git Server - fll/commitdiff
Progress: Begin working on getting FSS Embedded Read working.
authorKevin Day <Kevin@kevux.org>
Thu, 22 Aug 2024 04:15:13 +0000 (23:15 -0500)
committerKevin Day <Kevin@kevux.org>
Thu, 22 Aug 2024 04:15:13 +0000 (23:15 -0500)
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.

level_3/fss_read/c/embedded_list/fss_read.h
level_3/fss_read/c/embedded_list/main.c
level_3/fss_read/c/embedded_list/process_normal.c [new file with mode: 0644]
level_3/fss_read/c/embedded_list/process_normal.h [new file with mode: 0644]
level_3/fss_read/c/extended_list/main.c
level_3/fss_read/c/main/main.c
level_3/fss_read/c/main/print/data.c
level_3/fss_read/data/build/settings

index be8f50ac877ed4d4052e3bbf8a88917c1278a578..06b66cee43fe1a1399c110c47be829309d25d75e 100644 (file)
@@ -60,6 +60,7 @@
 #include <program/fss_read/main/thread.h>
 #include <program/fss_read/embedded_list/common.h>
 #include <program/fss_read/embedded_list/print.h>
+#include <program/fss_read/embedded_list/process_normal.h>
 
 #ifdef __cplusplus
 extern "C" {
index 41573263d2d3e6122359ff3a3548beae37d0cfdb..770b97e1cc2a89bd477564f996778e844a277b51 100644 (file)
@@ -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 (file)
index 0000000..398bd30
--- /dev/null
@@ -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 (file)
index 0000000..adc77e4
--- /dev/null
@@ -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
index 1b093f7f24495c5be8deed333f64b14a62000620..6d3338b51783eb58c1b3bf3a9518e59d37c539d7 100644 (file)
@@ -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;
index 173355fbbcfba931bd965b0b6e02dd7844812884..072ad30adc9f4686c8141de8094792057b01439f 100644 (file)
@@ -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;
index 9476cfca21b6013af2d620593ae4ac709db9b2ae..4521b3e50a8179b95a6ba19749c3b9d146bcb332 100644 (file)
@@ -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
         }
index 47800b6ca3d383a140a9d283a51005418b24d074..24f122e6f26db3e2d8f73f7c030bf0193172d832 100644 (file)
@@ -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