]> Kevux Git Server - fll/commitdiff
Cleanup: move private functions into separate files
authorKevin Day <thekevinday@gmail.com>
Sun, 8 Sep 2019 23:44:14 +0000 (18:44 -0500)
committerKevin Day <thekevinday@gmail.com>
Sun, 8 Sep 2019 23:44:36 +0000 (18:44 -0500)
12 files changed:
level_3/fss_basic_list_read/c/fss_basic_list_read.c
level_3/fss_basic_list_read/c/private-fss_basic_list_read.c [new file with mode: 0644]
level_3/fss_basic_list_read/c/private-fss_basic_list_read.h [new file with mode: 0644]
level_3/fss_basic_list_read/data/build/settings
level_3/fss_basic_read/c/fss_basic_read.c
level_3/fss_basic_read/c/private-fss_basic_read.c [new file with mode: 0644]
level_3/fss_basic_read/c/private-fss_basic_read.h [new file with mode: 0644]
level_3/fss_basic_read/data/build/settings
level_3/fss_extended_read/c/fss_extended_read.c
level_3/fss_extended_read/c/private-fss_extended_read.c [new file with mode: 0644]
level_3/fss_extended_read/c/private-fss_extended_read.h [new file with mode: 0644]
level_3/fss_extended_read/data/build/settings

index 5e44f2322cb6b264ffd5f19191c8d1fcfefc09e8..b8d551e264b3897c1ca7f260025b48764fcf5577 100644 (file)
@@ -1,4 +1,5 @@
 #include <level_3/fss_basic_list_read.h>
+#include "private-fss_basic_list_read.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -30,8 +31,6 @@ extern "C" {
 #endif // _di_fss_basic_list_read_print_help_
 
 #ifndef _di_fss_basic_list_read_main_
-  f_return_status fss_basic_list_read_main_process_file(const f_console_arguments arguments, fss_basic_list_read_data *data, const f_string filename, const f_string_length target) __attribute__((visibility ("internal")));
-
   f_return_status fss_basic_list_read_main(const f_console_arguments arguments, fss_basic_list_read_data *data) {
     f_status status = f_none;
 
@@ -206,290 +205,6 @@ extern "C" {
     fss_basic_list_read_delete_data(data);
     return status;
   }
-
-  f_return_status fss_basic_list_read_main_process_file(const f_console_arguments arguments, fss_basic_list_read_data *data, const f_string filename, const f_string_length target) {
-    f_status status = f_none;
-    f_status status2 = f_none;
-
-    f_string_length current = 0;
-    f_string_length found = 0;
-
-    {
-      f_string_location input = f_string_location_initialize;
-
-      input.start = 0;
-      input.stop  = data->buffer.used - 1;
-
-      status = fll_fss_basic_list_read(&data->buffer, &input, &data->objects, &data->contents);
-
-      if (f_status_is_error(status)) {
-        status = f_status_set_fine(status);
-
-        if (status == f_invalid_parameter) {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", filename);
-        }
-        else if (status == f_allocation_error || status == f_reallocation_error) {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
-        }
-        else if (status == f_incomplete_utf_on_stop) {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at %d).", input.start);
-        }
-        else if (status == f_incomplete_utf_on_eos) {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at %d).", input.start);
-        }
-        else {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'", f_status_set_error(status), filename);
-        }
-
-        fss_basic_list_read_delete_data(data);
-        return f_status_set_error(status);
-      }
-      else if (status == f_no_data_on_stop || status == f_no_data_on_eos) {
-        // clear buffers, then attempt the next file
-        f_macro_fss_contents_delete(status2, data->contents);
-        f_macro_fss_objects_delete(status2, data->objects);
-        f_macro_string_dynamic_delete(status2, data->buffer);
-
-        return f_status_set_warning(status);
-      }
-    }
-
-    // now that all of the files have been read, process the objects and contents
-    if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_none) {
-      fprintf(f_standard_output, "%u\n", (unsigned int) data->objects.used);
-    }
-    else {
-      current = 0;
-
-      if (data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_none) {
-        if (data->parameters[fss_basic_list_read_parameter_object].result == f_console_result_none) {
-          for (; current < data->objects.used; current++) {
-            if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
-
-              if (data->parameters[fss_basic_list_read_parameter_size].result == f_console_result_found) {
-                if (data->contents.array[current].used > 0) {
-                  f_string_length counter = data->contents.array[current].array[0].start;
-                  f_string_length size    = 0;
-
-                  for (; counter <= data->contents.array[current].array[0].stop; counter++) {
-                    if (data->buffer.string[counter] == f_string_eol) size++;
-                  } // for
-
-                  // the last newline is never present
-                  size++;
-
-                  fprintf(f_standard_output, "%u\n", (unsigned int) size);
-                }
-                else {
-                  fprintf(f_standard_output, "0\n");
-                }
-              }
-              else if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) {
-                if (data->contents.array[current].used > 0) {
-                  f_string_length counter = data->contents.array[current].array[0].start;
-                  f_string_length position = 0;
-                  f_string_length target = (f_string_length) atoll(arguments.argv[data->parameters[fss_basic_list_read_parameter_line].additional.array[0]]);
-                  f_string_location range = f_string_location_initialize;
-
-                  // use an invalid range to communicate range not found
-                  range.start = 1;
-                  range.stop  = 0;
-
-                  for (; counter <= data->contents.array[current].array[0].stop; counter++) {
-                    if (position == target) {
-                      range.start = counter;
-
-                      // explicit use of < instead of <= is done here so that the range.stop will always be accurate
-                      for (; counter < data->contents.array[current].array[0].stop; counter++) {
-                        if (data->buffer.string[counter] == f_string_eol) {
-                          break;
-                        }
-                      } // for
-
-                      range.stop = counter;
-                      break;
-                    }
-
-                    if (data->buffer.string[counter] == f_string_eol) {
-                      position++;
-                    }
-                  } // for
-
-                  if (range.start <= range.stop) {
-                    f_print_string_dynamic_partial(f_standard_output, data->buffer, range);
-                  }
-                }
-              }
-              else {
-                if (data->contents.array[current].used > 0) {
-                  f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[current].array[0]);
-                  fprintf(f_standard_output, "\n");
-                }
-              }
-            }
-
-            if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
-              if (found == target) {
-                break;
-              }
-              else {
-                found++;
-              }
-            }
-          } // for
-        }
-        else {
-          for (; current < data->objects.used; current++) {
-            if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
-              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
-              fprintf(f_standard_output, "\n");
-            }
-
-            if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
-              if (found == target) {
-                break;
-              }
-              else {
-                found++;
-              }
-            }
-          } // for
-        }
-      }
-      else {
-        current = 0;
-
-        f_string_length total = 0;
-        f_string_length name_length = 0;
-        f_string_length argv_length = 0;
-
-        if (data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_additional) {
-          argv_length = strlen(arguments.argv[data->parameters[fss_basic_list_read_parameter_name].additional.array[0]]);
-
-          if (data->parameters[fss_basic_list_read_parameter_object].result == f_console_result_none) {
-            for (; current < data->objects.used; current++) {
-              name_length = data->objects.array[current].stop - data->objects.array[current].start + 1;
-
-              if (name_length == argv_length) {
-                if (fl_string_compare(data->buffer.string + data->objects.array[current].start, arguments.argv[data->parameters[fss_basic_list_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
-
-                  if (data->parameters[fss_basic_list_read_parameter_size].result == f_console_result_found) {
-                    if (data->contents.array[current].used > 0) {
-                      f_string_length counter = data->contents.array[current].array[0].start;
-                      f_string_length size    = 0;
-
-                      for (; counter <= data->contents.array[current].array[0].stop; counter++) {
-                        if (data->buffer.string[counter] == f_string_eol) size++;
-                      } // for
-
-                      // the last newline is never present
-                      size++;
-
-                      fprintf(f_standard_output, "%u\n", (unsigned int) size);
-                    }
-                    else {
-                      fprintf(f_standard_output, "0\n");
-                    }
-                  }
-                  else if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) {
-                    if (data->contents.array[current].used > 0) {
-                      f_string_length counter = data->contents.array[current].array[0].start;
-                      f_string_length position = 0;
-                      f_string_length target = (f_string_length) atoll(arguments.argv[data->parameters[fss_basic_list_read_parameter_line].additional.array[0]]);
-                      f_string_location range = f_string_location_initialize;
-
-                      // use an invalid range to communicate range not found
-                      range.start = 1;
-                      range.stop = 0;
-
-                      for (; counter <= data->contents.array[current].array[0].stop; counter++) {
-                        if (position == target) {
-                          range.start = counter;
-
-                          // explicit use of < instead of <= is done here so that the range.stop will always be accurate
-                          for (; counter < data->contents.array[current].array[0].stop; counter++) {
-                            if (data->buffer.string[counter] == f_string_eol) {
-                              break;
-                            }
-                          } // for
-
-                          range.stop = counter;
-                          break;
-                        }
-
-                        if (data->buffer.string[counter] == f_string_eol) {
-                          position++;
-                        }
-                      } // for
-
-                      if (range.start <= range.stop) {
-                        f_print_string_dynamic_partial(f_standard_output, data->buffer, range);
-                      }
-                    }
-                  }
-                  else {
-                    if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
-                      if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) {
-                        total++;
-                      }
-                      else {
-                        if (data->contents.array[current].used > 0) {
-                          f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[current].array[0]);
-                          fprintf(f_standard_output, "\n");
-                        }
-                      }
-                    }
-                  }
-
-                  if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
-                    if (found == target) {
-                      break;
-                    }
-                    else {
-                      found++;
-                    }
-                  }
-                }
-              }
-            } // for
-
-            if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none) {
-              fprintf(f_standard_output, f_string_length_printf "\n", total);
-            }
-          }
-          else {
-            // when and because the object parameter is specified, the name parameter refers to the content instead of the object
-            // therefore, make the search on the content and display the object
-            for (; current < data->contents.used; current++) {
-              if (data->contents.array[current].used > 0) {
-                name_length = data->contents.array[current].array[0].stop - data->contents.array[current].array[0].start + 1;
-
-                if (name_length == argv_length) {
-                  if (fl_string_compare(data->buffer.string + data->contents.array[current].array[0].start, arguments.argv[data->parameters[fss_basic_list_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
-                    if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
-                      f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
-                      fprintf(f_standard_output, "\n");
-                    }
-
-                    if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
-                      if (found == target) {
-                        break;
-                      }
-                      else {
-                        found++;
-                      }
-                    }
-                  }
-                }
-              }
-            } // for
-          }
-        }
-      }
-    }
-
-    return f_none;
-  }
 #endif // _di_fss_basic_list_read_main_
 
 #ifndef _di_fss_basic_list_read_delete_data_
diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c
new file mode 100644 (file)
index 0000000..789eeb4
--- /dev/null
@@ -0,0 +1,288 @@
+#include <level_3/fss_basic_list_read.h>
+#include "private-fss_basic_list_read.h"
+
+#ifndef _di_fss_basic_list_read_main_process_file_
+  f_return_status fss_basic_list_read_main_process_file(const f_console_arguments arguments, fss_basic_list_read_data *data, const f_string filename, const f_string_length target) {
+    f_status status = f_none;
+    f_status status2 = f_none;
+
+    f_string_length current = 0;
+    f_string_length found = 0;
+
+    {
+      f_string_location input = f_string_location_initialize;
+
+      input.start = 0;
+      input.stop  = data->buffer.used - 1;
+
+      status = fll_fss_basic_list_read(&data->buffer, &input, &data->objects, &data->contents);
+
+      if (f_status_is_error(status)) {
+        status = f_status_set_fine(status);
+
+        if (status == f_invalid_parameter) {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", filename);
+        }
+        else if (status == f_allocation_error || status == f_reallocation_error) {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+        }
+        else if (status == f_incomplete_utf_on_stop) {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at %d).", input.start);
+        }
+        else if (status == f_incomplete_utf_on_eos) {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at %d).", input.start);
+        }
+        else {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'", f_status_set_error(status), filename);
+        }
+
+        fss_basic_list_read_delete_data(data);
+        return f_status_set_error(status);
+      }
+      else if (status == f_no_data_on_stop || status == f_no_data_on_eos) {
+        // clear buffers, then attempt the next file
+        f_macro_fss_contents_delete(status2, data->contents);
+        f_macro_fss_objects_delete(status2, data->objects);
+        f_macro_string_dynamic_delete(status2, data->buffer);
+
+        return f_status_set_warning(status);
+      }
+    }
+
+    // now that all of the files have been read, process the objects and contents
+    if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_none) {
+      fprintf(f_standard_output, "%u\n", (unsigned int) data->objects.used);
+    }
+    else {
+      current = 0;
+
+      if (data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_none) {
+        if (data->parameters[fss_basic_list_read_parameter_object].result == f_console_result_none) {
+          for (; current < data->objects.used; current++) {
+            if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
+
+              if (data->parameters[fss_basic_list_read_parameter_size].result == f_console_result_found) {
+                if (data->contents.array[current].used > 0) {
+                  f_string_length counter = data->contents.array[current].array[0].start;
+                  f_string_length size    = 0;
+
+                  for (; counter <= data->contents.array[current].array[0].stop; counter++) {
+                    if (data->buffer.string[counter] == f_string_eol) size++;
+                  } // for
+
+                  // the last newline is never present
+                  size++;
+
+                  fprintf(f_standard_output, "%u\n", (unsigned int) size);
+                }
+                else {
+                  fprintf(f_standard_output, "0\n");
+                }
+              }
+              else if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) {
+                if (data->contents.array[current].used > 0) {
+                  f_string_length counter = data->contents.array[current].array[0].start;
+                  f_string_length position = 0;
+                  f_string_length target = (f_string_length) atoll(arguments.argv[data->parameters[fss_basic_list_read_parameter_line].additional.array[0]]);
+                  f_string_location range = f_string_location_initialize;
+
+                  // use an invalid range to communicate range not found
+                  range.start = 1;
+                  range.stop  = 0;
+
+                  for (; counter <= data->contents.array[current].array[0].stop; counter++) {
+                    if (position == target) {
+                      range.start = counter;
+
+                      // explicit use of < instead of <= is done here so that the range.stop will always be accurate
+                      for (; counter < data->contents.array[current].array[0].stop; counter++) {
+                        if (data->buffer.string[counter] == f_string_eol) {
+                          break;
+                        }
+                      } // for
+
+                      range.stop = counter;
+                      break;
+                    }
+
+                    if (data->buffer.string[counter] == f_string_eol) {
+                      position++;
+                    }
+                  } // for
+
+                  if (range.start <= range.stop) {
+                    f_print_string_dynamic_partial(f_standard_output, data->buffer, range);
+                  }
+                }
+              }
+              else {
+                if (data->contents.array[current].used > 0) {
+                  f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[current].array[0]);
+                  fprintf(f_standard_output, "\n");
+                }
+              }
+            }
+
+            if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
+              if (found == target) {
+                break;
+              }
+              else {
+                found++;
+              }
+            }
+          } // for
+        }
+        else {
+          for (; current < data->objects.used; current++) {
+            if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
+              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
+              fprintf(f_standard_output, "\n");
+            }
+
+            if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
+              if (found == target) {
+                break;
+              }
+              else {
+                found++;
+              }
+            }
+          } // for
+        }
+      }
+      else {
+        current = 0;
+
+        f_string_length total = 0;
+        f_string_length name_length = 0;
+        f_string_length argv_length = 0;
+
+        if (data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_additional) {
+          argv_length = strlen(arguments.argv[data->parameters[fss_basic_list_read_parameter_name].additional.array[0]]);
+
+          if (data->parameters[fss_basic_list_read_parameter_object].result == f_console_result_none) {
+            for (; current < data->objects.used; current++) {
+              name_length = data->objects.array[current].stop - data->objects.array[current].start + 1;
+
+              if (name_length == argv_length) {
+                if (fl_string_compare(data->buffer.string + data->objects.array[current].start, arguments.argv[data->parameters[fss_basic_list_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
+
+                  if (data->parameters[fss_basic_list_read_parameter_size].result == f_console_result_found) {
+                    if (data->contents.array[current].used > 0) {
+                      f_string_length counter = data->contents.array[current].array[0].start;
+                      f_string_length size    = 0;
+
+                      for (; counter <= data->contents.array[current].array[0].stop; counter++) {
+                        if (data->buffer.string[counter] == f_string_eol) size++;
+                      } // for
+
+                      // the last newline is never present
+                      size++;
+
+                      fprintf(f_standard_output, "%u\n", (unsigned int) size);
+                    }
+                    else {
+                      fprintf(f_standard_output, "0\n");
+                    }
+                  }
+                  else if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) {
+                    if (data->contents.array[current].used > 0) {
+                      f_string_length counter = data->contents.array[current].array[0].start;
+                      f_string_length position = 0;
+                      f_string_length target = (f_string_length) atoll(arguments.argv[data->parameters[fss_basic_list_read_parameter_line].additional.array[0]]);
+                      f_string_location range = f_string_location_initialize;
+
+                      // use an invalid range to communicate range not found
+                      range.start = 1;
+                      range.stop = 0;
+
+                      for (; counter <= data->contents.array[current].array[0].stop; counter++) {
+                        if (position == target) {
+                          range.start = counter;
+
+                          // explicit use of < instead of <= is done here so that the range.stop will always be accurate
+                          for (; counter < data->contents.array[current].array[0].stop; counter++) {
+                            if (data->buffer.string[counter] == f_string_eol) {
+                              break;
+                            }
+                          } // for
+
+                          range.stop = counter;
+                          break;
+                        }
+
+                        if (data->buffer.string[counter] == f_string_eol) {
+                          position++;
+                        }
+                      } // for
+
+                      if (range.start <= range.stop) {
+                        f_print_string_dynamic_partial(f_standard_output, data->buffer, range);
+                      }
+                    }
+                  }
+                  else {
+                    if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
+                      if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) {
+                        total++;
+                      }
+                      else {
+                        if (data->contents.array[current].used > 0) {
+                          f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[current].array[0]);
+                          fprintf(f_standard_output, "\n");
+                        }
+                      }
+                    }
+                  }
+
+                  if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
+                    if (found == target) {
+                      break;
+                    }
+                    else {
+                      found++;
+                    }
+                  }
+                }
+              }
+            } // for
+
+            if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none) {
+              fprintf(f_standard_output, f_string_length_printf "\n", total);
+            }
+          }
+          else {
+            // when and because the object parameter is specified, the name parameter refers to the content instead of the object
+            // therefore, make the search on the content and display the object
+            for (; current < data->contents.used; current++) {
+              if (data->contents.array[current].used > 0) {
+                name_length = data->contents.array[current].array[0].stop - data->contents.array[current].array[0].start + 1;
+
+                if (name_length == argv_length) {
+                  if (fl_string_compare(data->buffer.string + data->contents.array[current].array[0].start, arguments.argv[data->parameters[fss_basic_list_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
+                    if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
+                      f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
+                      fprintf(f_standard_output, "\n");
+                    }
+
+                    if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
+                      if (found == target) {
+                        break;
+                      }
+                      else {
+                        found++;
+                      }
+                    }
+                  }
+                }
+              }
+            } // for
+          }
+        }
+      }
+    }
+
+    return f_none;
+  }
+#endif // _di_fss_basic_list_read_main_process_file_
diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h
new file mode 100644 (file)
index 0000000..85709c7
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * FLL - Level 3
+ *
+ * Project: FSS
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ */
+#ifndef _PRIVATE_fss_basic_list_read_h
+#define _PRIVATE_fss_basic_list_read_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#ifndef _di_fss_basic_list_read_main_process_file_
+  extern f_return_status fss_basic_list_read_main_process_file(const f_console_arguments arguments, fss_basic_list_read_data *data, const f_string filename, const f_string_length target) f_gcc_attribute_visibility_internal;
+#endif // _di_fss_basic_list_read_main_process_file_
+
+#endif // _PRIVATE_fss_basic_list_read_h
index 2f6bcb257c1f35fe819536e68ccadac5949516c2..b8d57e26d55b98a57e1bf777588842e4955fd357 100644 (file)
@@ -13,7 +13,7 @@ build_libraries -lc
 build_libraries_fll -lfll_program -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lf_utf -lfl_color -lf_file -lf_print -lf_pipe -lf_console -lf_memory
 #build_libraries_fll-level -lfll_2 -lfll_1 -lfll_0
 #build_libraries_fll-monolithic -lfll
-build_sources_library fss_basic_list_read.c
+build_sources_library fss_basic_list_read.c private-fss_basic_list_read.c
 build_sources_program main.c
 build_sources_headers fss_basic_list_read.h
 build_sources_bash
index fe7b1f7a7a8c08d95be45573c5bbc3197135f116..a552a3102eae38844128328645152b68434750cd 100644 (file)
@@ -1,4 +1,5 @@
 #include <level_3/fss_basic_read.h>
+#include "private-fss_basic_read.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -28,8 +29,6 @@ extern "C" {
 #endif // _di_fss_basic_read_print_help_
 
 #ifndef _di_fss_basic_read_main_
-  f_return_status fss_basic_read_main_process_file(const f_console_arguments arguments, fss_basic_read_data *data, const f_string filename, const f_string_length target) f_gcc_attribute_visibility_internal;
-
   f_return_status fss_basic_read_main(const f_console_arguments arguments, fss_basic_read_data *data) {
     f_status status = f_none;
 
@@ -212,185 +211,6 @@ extern "C" {
     fss_basic_read_delete_data(data);
     return status;
   }
-
-  f_return_status fss_basic_read_main_process_file(const f_console_arguments arguments, fss_basic_read_data *data, const f_string filename, const f_string_length target) {
-    f_status status = f_none;
-    f_status status2 = f_none;
-
-    f_string_length current = 0;
-    f_string_length found = 0;
-
-    {
-      f_string_location input = f_string_location_initialize;
-
-      input.start = 0;
-      input.stop  = data->buffer.used - 1;
-
-      status = fll_fss_basic_read(&data->buffer, &input, &data->objects, &data->contents);
-
-      if (f_status_is_error(status)) {
-        status = f_status_set_fine(status);
-
-        if (status == f_invalid_parameter) {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", filename);
-        }
-        else if (status == f_allocation_error || status == f_reallocation_error) {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
-        }
-        else if (status == f_incomplete_utf_on_stop) {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at %d).", input.start);
-        }
-        else if (status == f_incomplete_utf_on_eos) {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at %d).", input.start);
-        }
-        else {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'", f_status_set_error(status), filename);
-        }
-
-        fss_basic_read_delete_data(data);
-        return f_status_set_error(status);
-      }
-      else if (status == f_no_data_on_stop || status == f_no_data_on_eos) {
-        // clear buffers, then attempt the next file
-        f_macro_fss_contents_delete(status2, data->contents);
-        f_macro_fss_objects_delete(status2, data->objects);
-        f_macro_string_dynamic_delete(status2, data->buffer);
-
-        return f_status_set_warning(status);
-      }
-    }
-
-    // now that the file has been read, process the objects and contents
-    if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_name].result == f_console_result_none) {
-      fprintf(f_standard_output, "%u\n", (unsigned int) data->objects.used);
-    }
-    else {
-      current = 0;
-
-      if (data->parameters[fss_basic_read_parameter_name].result == f_console_result_none) {
-        if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_none) {
-          for (; current < data->objects.used; current++) {
-            if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
-              if (data->contents.array[current].used > 0) {
-                f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[current].array[0]);
-                fprintf(f_standard_output, "\n");
-              }
-              else {
-                // for all objects with no data, print a newline
-                fprintf(f_standard_output, "\n");
-              }
-            }
-
-            if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
-              if (found == target) {
-                break;
-              }
-              else {
-                found++;
-              }
-            }
-          } // for
-        }
-        else {
-          for (; current < data->objects.used; current++) {
-            if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
-              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
-              fprintf(f_standard_output, "\n");
-            }
-
-            if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
-              if (found == target) {
-                break;
-              }
-              else {
-                found++;
-              }
-            }
-          } // for
-        }
-      }
-      else {
-        current = 0;
-
-        f_string_length total = 0;
-        f_string_length name_length = 0;
-        f_string_length argv_length = 0;
-
-        if (data->parameters[fss_basic_read_parameter_name].result == f_console_result_additional) {
-          argv_length = strlen(arguments.argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]]);
-
-          if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_none) {
-            for (; current < data->objects.used; current++) {
-              name_length = data->objects.array[current].stop - data->objects.array[current].start + 1;
-
-              if (name_length == argv_length) {
-                if (fl_string_compare(data->buffer.string + data->objects.array[current].start, arguments.argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
-
-                  if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
-                    if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
-                      total++;
-                    }
-                    else {
-                      if (data->contents.array[current].used > 0) {
-                        f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[current].array[0]);
-                        fprintf(f_standard_output, "\n");
-                      }
-                      else {
-                        // for all objects with no data, print a newline
-                        fprintf(f_standard_output, "\n");
-                      }
-                    }
-                  }
-
-                  if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
-                    if (found == target) {
-                      break;
-                    }
-                    else {
-                      found++;
-                    }
-                  }
-                }
-              }
-            } // for
-
-            if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_count].result == f_console_result_none) {
-              fprintf(f_standard_output, f_string_length_printf "\n", total);
-            }
-          }
-          else {
-            // when and because the object parameter is specified, the name parameter refers to the content instead of the object
-            // therefore, make the search on the content and display the object
-            for (; current < data->contents.used; current++) {
-              if (data->contents.array[current].used > 0) {
-                name_length = data->contents.array[current].array[0].stop - data->contents.array[current].array[0].start + 1;
-
-                if (name_length == argv_length) {
-                  if (fl_string_compare(data->buffer.string + data->contents.array[current].array[0].start, arguments.argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
-                    if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
-                      f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
-                      fprintf(f_standard_output, "\n");
-                    }
-
-                    if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
-                      if (found == target) {
-                        break;
-                      }
-                      else {
-                        found++;
-                      }
-                    }
-                  }
-                }
-              }
-            } // for
-          }
-        }
-      }
-    }
-
-    return f_none;
-  }
 #endif // _di_fss_basic_read_main_
 
 #ifndef _di_fss_basic_read_delete_data_
diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.c b/level_3/fss_basic_read/c/private-fss_basic_read.c
new file mode 100644 (file)
index 0000000..6c75279
--- /dev/null
@@ -0,0 +1,183 @@
+#include <level_3/fss_basic_read.h>
+#include "private-fss_basic_read.h"
+
+#ifndef _di_fss_basic_read_main_process_file_
+  f_return_status fss_basic_read_main_process_file(const f_console_arguments arguments, fss_basic_read_data *data, const f_string filename, const f_string_length target) {
+    f_status status = f_none;
+    f_status status2 = f_none;
+
+    f_string_length current = 0;
+    f_string_length found = 0;
+
+    {
+      f_string_location input = f_string_location_initialize;
+
+      input.start = 0;
+      input.stop  = data->buffer.used - 1;
+
+      status = fll_fss_basic_read(&data->buffer, &input, &data->objects, &data->contents);
+
+      if (f_status_is_error(status)) {
+        status = f_status_set_fine(status);
+
+        if (status == f_invalid_parameter) {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", filename);
+        }
+        else if (status == f_allocation_error || status == f_reallocation_error) {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+        }
+        else if (status == f_incomplete_utf_on_stop) {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at %d).", input.start);
+        }
+        else if (status == f_incomplete_utf_on_eos) {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at %d).", input.start);
+        }
+        else {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'", f_status_set_error(status), filename);
+        }
+
+        fss_basic_read_delete_data(data);
+        return f_status_set_error(status);
+      }
+      else if (status == f_no_data_on_stop || status == f_no_data_on_eos) {
+        // clear buffers, then attempt the next file
+        f_macro_fss_contents_delete(status2, data->contents);
+        f_macro_fss_objects_delete(status2, data->objects);
+        f_macro_string_dynamic_delete(status2, data->buffer);
+
+        return f_status_set_warning(status);
+      }
+    }
+
+    // now that the file has been read, process the objects and contents
+    if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_name].result == f_console_result_none) {
+      fprintf(f_standard_output, "%u\n", (unsigned int) data->objects.used);
+    }
+    else {
+      current = 0;
+
+      if (data->parameters[fss_basic_read_parameter_name].result == f_console_result_none) {
+        if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_none) {
+          for (; current < data->objects.used; current++) {
+            if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
+              if (data->contents.array[current].used > 0) {
+                f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[current].array[0]);
+                fprintf(f_standard_output, "\n");
+              }
+              else {
+                // for all objects with no data, print a newline
+                fprintf(f_standard_output, "\n");
+              }
+            }
+
+            if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
+              if (found == target) {
+                break;
+              }
+              else {
+                found++;
+              }
+            }
+          } // for
+        }
+        else {
+          for (; current < data->objects.used; current++) {
+            if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
+              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
+              fprintf(f_standard_output, "\n");
+            }
+
+            if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
+              if (found == target) {
+                break;
+              }
+              else {
+                found++;
+              }
+            }
+          } // for
+        }
+      }
+      else {
+        current = 0;
+
+        f_string_length total = 0;
+        f_string_length name_length = 0;
+        f_string_length argv_length = 0;
+
+        if (data->parameters[fss_basic_read_parameter_name].result == f_console_result_additional) {
+          argv_length = strlen(arguments.argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]]);
+
+          if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_none) {
+            for (; current < data->objects.used; current++) {
+              name_length = data->objects.array[current].stop - data->objects.array[current].start + 1;
+
+              if (name_length == argv_length) {
+                if (fl_string_compare(data->buffer.string + data->objects.array[current].start, arguments.argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
+
+                  if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
+                    if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
+                      total++;
+                    }
+                    else {
+                      if (data->contents.array[current].used > 0) {
+                        f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[current].array[0]);
+                        fprintf(f_standard_output, "\n");
+                      }
+                      else {
+                        // for all objects with no data, print a newline
+                        fprintf(f_standard_output, "\n");
+                      }
+                    }
+                  }
+
+                  if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
+                    if (found == target) {
+                      break;
+                    }
+                    else {
+                      found++;
+                    }
+                  }
+                }
+              }
+            } // for
+
+            if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_count].result == f_console_result_none) {
+              fprintf(f_standard_output, f_string_length_printf "\n", total);
+            }
+          }
+          else {
+            // when and because the object parameter is specified, the name parameter refers to the content instead of the object
+            // therefore, make the search on the content and display the object
+            for (; current < data->contents.used; current++) {
+              if (data->contents.array[current].used > 0) {
+                name_length = data->contents.array[current].array[0].stop - data->contents.array[current].array[0].start + 1;
+
+                if (name_length == argv_length) {
+                  if (fl_string_compare(data->buffer.string + data->contents.array[current].array[0].start, arguments.argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
+                    if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
+                      f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
+                      fprintf(f_standard_output, "\n");
+                    }
+
+                    if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
+                      if (found == target) {
+                        break;
+                      }
+                      else {
+                        found++;
+                      }
+                    }
+                  }
+                }
+              }
+            } // for
+          }
+        }
+      }
+    }
+
+    return f_none;
+  }
+#endif // _di_fss_basic_read_main_process_file_
diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.h b/level_3/fss_basic_read/c/private-fss_basic_read.h
new file mode 100644 (file)
index 0000000..8958e15
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * FLL - Level 3
+ *
+ * Project: FSS
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ */
+#ifndef _PRIVATE_fss_basic_read_h
+#define _PRIVATE_fss_basic_read_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#ifndef _di_fss_basic_read_main_process_file_
+  extern f_return_status fss_basic_read_main_process_file(const f_console_arguments arguments, fss_basic_read_data *data, const f_string filename, const f_string_length target) f_gcc_attribute_visibility_internal;
+#endif // _di_fss_basic_read_main_process_file_
+
+#endif // _PRIVATE_fss_basic_read_h
index 9743404d91f381bd5be3b555816cd94502d961f0..a64586612f839ae059dce3974727d8a7a8c874b9 100644 (file)
@@ -13,7 +13,7 @@ build_libraries -lc
 build_libraries_fll -lfll_program -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lf_utf -lfl_color -lf_file -lf_print -lf_pipe -lf_console -lf_memory
 #build_libraries_fll-level -lfll_2 -lfll_1 -lfll_0
 #build_libraries_fll-monolithic -lfll
-build_sources_library fss_basic_read.c
+build_sources_library fss_basic_read.c private-fss_basic_read.c
 build_sources_program main.c
 build_sources_headers fss_basic_read.h
 build_sources_bash
index 87aeeb6fd9d29bcd7e9802aaf012683853eca777..cc080caee80c662debaf527eaffe6f6d86b6fdee 100644 (file)
@@ -1,4 +1,5 @@
 #include <level_3/fss_extended_read.h>
+#include "private-fss_extended_read.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -29,8 +30,6 @@ extern "C" {
 #endif // _di_fss_extended_read_print_help_
 
 #ifndef _di_fss_extended_read_main_
-  f_return_status fss_extended_read_main_process_file(const f_console_arguments arguments, fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) f_gcc_attribute_visibility_internal;
-
   f_return_status fss_extended_read_main(const f_console_arguments arguments, fss_extended_read_data *data) {
     f_status status = f_none;
 
@@ -211,188 +210,6 @@ extern "C" {
     fss_extended_read_delete_data(data);
     return status;
   }
-
-  f_return_status fss_extended_read_main_process_file(const f_console_arguments arguments, fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) {
-    f_status status = f_none;
-    f_status status2 = f_none;
-
-    f_string_length current = 0;
-    f_string_length found = 0;
-
-    {
-      f_string_location input = f_string_location_initialize;
-
-      input.start = 0;
-      input.stop = data->buffer.used - 1;
-
-      status = fll_fss_extended_read(&data->buffer, &input, &data->objects, &data->contents);
-
-      if (f_status_is_error(status)) {
-        status = f_status_set_fine(status);
-
-        if (status == f_invalid_parameter) {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_extended_read() for the file '%s'", filename);
-        }
-        else if (status == f_allocation_error || status == f_reallocation_error) {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
-        }
-        else if (status == f_incomplete_utf_on_stop) {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at %d).", input.start);
-        }
-        else if (status == f_incomplete_utf_on_eos) {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at %d).", input.start);
-        }
-        else {
-          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_extended_read() for the file '%s'", f_status_set_error(status), filename);
-        }
-
-        fss_extended_read_delete_data(data);
-        return f_status_set_error(status);
-      }
-      else if (status == f_no_data_on_stop || status == f_no_data_on_eos) {
-        // clear buffers, then attempt the next file
-        f_macro_fss_contents_delete(status2, data->contents);
-        f_macro_fss_objects_delete(status2, data->objects);
-        f_macro_string_dynamic_delete(status2, data->buffer);
-
-        return f_status_set_warning(status);
-      }
-    }
-
-    // now that all of the files have been read, process the objects and contents
-    if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found && data->parameters[fss_extended_read_parameter_name].result == f_console_result_none) {
-      fprintf(f_standard_output, "%u\n", (unsigned int) data->objects.used);
-    }
-    else {
-      current = 0;
-
-      if (data->parameters[fss_extended_read_parameter_name].result == f_console_result_none) {
-        if (data->parameters[fss_extended_read_parameter_object].result == f_console_result_none) {
-          for (; current < data->objects.used; current++) {
-            if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
-              if (data->contents.array[current].used > select) {
-                f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[current].array[select]);
-                fprintf(f_standard_output, "\n");
-              }
-              else {
-                // for all objects with no data, print a newline
-                fprintf(f_standard_output, "\n");
-              }
-            }
-
-            if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
-              if (found == target) {
-                break;
-              }
-              else {
-                found++;
-              }
-            }
-          } // for
-        }
-        else {
-          for (; current < data->objects.used; current++) {
-            if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
-              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
-              fprintf(f_standard_output, "\n");
-            }
-
-            if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
-              if (found == target) {
-                break;
-              }
-              else {
-                found++;
-              }
-            }
-          } // for
-        }
-      } else {
-        current = 0;
-
-        f_string_length total = 0;
-        f_string_length name_length = 0;
-        f_string_length argv_length = 0;
-
-        if (data->parameters[fss_extended_read_parameter_name].result == f_console_result_additional) {
-          argv_length = strlen(arguments.argv[data->parameters[fss_extended_read_parameter_name].additional.array[0]]);
-
-          if (data->parameters[fss_extended_read_parameter_object].result == f_console_result_none) {
-            for (; current < data->objects.used; current++) {
-              name_length = data->objects.array[current].stop - data->objects.array[current].start + 1;
-
-              if (name_length == argv_length) {
-                if (fl_string_compare(data->buffer.string + data->objects.array[current].start, arguments.argv[data->parameters[fss_extended_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
-
-                  if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
-                    if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
-                      total++;
-                    }
-                    else {
-                      if (data->contents.array[current].used > select) {
-                        f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[current].array[select]);
-                        fprintf(f_standard_output, "\n");
-                      }
-                      else {
-                        // for all objects with no data, print a newline
-                        fprintf(f_standard_output, "\n");
-                      }
-                    }
-                  }
-
-                  if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
-                    if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
-                      total = data->contents.array[current].used;
-                    }
-
-                    if (found == target) {
-                      break;
-                    }
-                    else {
-                      found++;
-                    }
-                  }
-                }
-              }
-            } // for
-
-            if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
-              fprintf(f_standard_output, f_string_length_printf "\n", total);
-            }
-          }
-          else {
-            // when and because the object parameter is specified, the name parameter refers to the content instead of the object
-            // therefore, make the search on the content and display the object
-            for (; current < data->contents.used; current++) {
-              if (data->contents.array[current].used > select) {
-                name_length = data->contents.array[current].array[select].stop - data->contents.array[current].array[select].start + 1;
-
-                if (name_length == argv_length) {
-                  if (fl_string_compare(data->buffer.string + data->contents.array[current].array[select].start, arguments.argv[data->parameters[fss_extended_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
-                    if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
-                      f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
-                      fprintf(f_standard_output, "\n");
-                    }
-
-                    if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
-                      if (found == target) {
-                        break;
-                      }
-                      else {
-                        found++;
-                      }
-                    }
-                  }
-                }
-              }
-            } // for
-          }
-        }
-      }
-    }
-
-    return f_none;
-  }
 #endif // _di_fss_extended_read_main_
 
 #ifndef _di_fss_extended_read_delete_data_
diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.c b/level_3/fss_extended_read/c/private-fss_extended_read.c
new file mode 100644 (file)
index 0000000..343be0d
--- /dev/null
@@ -0,0 +1,186 @@
+#include <level_3/fss_extended_read.h>
+#include "private-fss_extended_read.h"
+
+#ifndef _di_fss_extended_read_main_process_file_
+  f_return_status fss_extended_read_main_process_file(const f_console_arguments arguments, fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) {
+    f_status status = f_none;
+    f_status status2 = f_none;
+
+    f_string_length current = 0;
+    f_string_length found = 0;
+
+    {
+      f_string_location input = f_string_location_initialize;
+
+      input.start = 0;
+      input.stop = data->buffer.used - 1;
+
+      status = fll_fss_extended_read(&data->buffer, &input, &data->objects, &data->contents);
+
+      if (f_status_is_error(status)) {
+        status = f_status_set_fine(status);
+
+        if (status == f_invalid_parameter) {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_extended_read() for the file '%s'", filename);
+        }
+        else if (status == f_allocation_error || status == f_reallocation_error) {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+        }
+        else if (status == f_incomplete_utf_on_stop) {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at %d).", input.start);
+        }
+        else if (status == f_incomplete_utf_on_eos) {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at %d).", input.start);
+        }
+        else {
+          fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_extended_read() for the file '%s'", f_status_set_error(status), filename);
+        }
+
+        fss_extended_read_delete_data(data);
+        return f_status_set_error(status);
+      }
+      else if (status == f_no_data_on_stop || status == f_no_data_on_eos) {
+        // clear buffers, then attempt the next file
+        f_macro_fss_contents_delete(status2, data->contents);
+        f_macro_fss_objects_delete(status2, data->objects);
+        f_macro_string_dynamic_delete(status2, data->buffer);
+
+        return f_status_set_warning(status);
+      }
+    }
+
+    // now that all of the files have been read, process the objects and contents
+    if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found && data->parameters[fss_extended_read_parameter_name].result == f_console_result_none) {
+      fprintf(f_standard_output, "%u\n", (unsigned int) data->objects.used);
+    }
+    else {
+      current = 0;
+
+      if (data->parameters[fss_extended_read_parameter_name].result == f_console_result_none) {
+        if (data->parameters[fss_extended_read_parameter_object].result == f_console_result_none) {
+          for (; current < data->objects.used; current++) {
+            if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
+              if (data->contents.array[current].used > select) {
+                f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[current].array[select]);
+                fprintf(f_standard_output, "\n");
+              }
+              else {
+                // for all objects with no data, print a newline
+                fprintf(f_standard_output, "\n");
+              }
+            }
+
+            if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
+              if (found == target) {
+                break;
+              }
+              else {
+                found++;
+              }
+            }
+          } // for
+        }
+        else {
+          for (; current < data->objects.used; current++) {
+            if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
+              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
+              fprintf(f_standard_output, "\n");
+            }
+
+            if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
+              if (found == target) {
+                break;
+              }
+              else {
+                found++;
+              }
+            }
+          } // for
+        }
+      } else {
+        current = 0;
+
+        f_string_length total = 0;
+        f_string_length name_length = 0;
+        f_string_length argv_length = 0;
+
+        if (data->parameters[fss_extended_read_parameter_name].result == f_console_result_additional) {
+          argv_length = strlen(arguments.argv[data->parameters[fss_extended_read_parameter_name].additional.array[0]]);
+
+          if (data->parameters[fss_extended_read_parameter_object].result == f_console_result_none) {
+            for (; current < data->objects.used; current++) {
+              name_length = data->objects.array[current].stop - data->objects.array[current].start + 1;
+
+              if (name_length == argv_length) {
+                if (fl_string_compare(data->buffer.string + data->objects.array[current].start, arguments.argv[data->parameters[fss_extended_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
+
+                  if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
+                    if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
+                      total++;
+                    }
+                    else {
+                      if (data->contents.array[current].used > select) {
+                        f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[current].array[select]);
+                        fprintf(f_standard_output, "\n");
+                      }
+                      else {
+                        // for all objects with no data, print a newline
+                        fprintf(f_standard_output, "\n");
+                      }
+                    }
+                  }
+
+                  if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
+                    if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
+                      total = data->contents.array[current].used;
+                    }
+
+                    if (found == target) {
+                      break;
+                    }
+                    else {
+                      found++;
+                    }
+                  }
+                }
+              }
+            } // for
+
+            if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
+              fprintf(f_standard_output, f_string_length_printf "\n", total);
+            }
+          }
+          else {
+            // when and because the object parameter is specified, the name parameter refers to the content instead of the object
+            // therefore, make the search on the content and display the object
+            for (; current < data->contents.used; current++) {
+              if (data->contents.array[current].used > select) {
+                name_length = data->contents.array[current].array[select].stop - data->contents.array[current].array[select].start + 1;
+
+                if (name_length == argv_length) {
+                  if (fl_string_compare(data->buffer.string + data->contents.array[current].array[select].start, arguments.argv[data->parameters[fss_extended_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
+                    if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
+                      f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[current]);
+                      fprintf(f_standard_output, "\n");
+                    }
+
+                    if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
+                      if (found == target) {
+                        break;
+                      }
+                      else {
+                        found++;
+                      }
+                    }
+                  }
+                }
+              }
+            } // for
+          }
+        }
+      }
+    }
+
+    return f_none;
+  }
+#endif // _di_fss_extended_read_main_process_file_
diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.h b/level_3/fss_extended_read/c/private-fss_extended_read.h
new file mode 100644 (file)
index 0000000..fb6f99c
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * FLL - Level 3
+ *
+ * Project: FSS
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ */
+#ifndef _PRIVATE_fss_extended_read_h
+#define _PRIVATE_fss_extended_read_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_fss_extended_read_main_process_file_
+  extern f_return_status fss_extended_read_main_process_file(const f_console_arguments arguments, fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) f_gcc_attribute_visibility_internal;
+#endif // _di_fss_extended_read_main_process_file_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _PRIVATE_fss_extended_read_h
index 554b231c9a975c3f288e4ea5cf3c788ffa17e305..1b4a0fab725bad0444e8a65e1798f2aec6a56007 100644 (file)
@@ -13,7 +13,7 @@ build_libraries -lc
 build_libraries_fll -lfll_program -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lf_utf -lfl_color -lf_file -lf_print -lf_pipe -lf_console -lf_memory
 #build_libraries_fll-level -lfll_2 -lfll_1 -lfll_0
 #build_libraries_fll-monolithic -lfll
-build_sources_library fss_extended_read.c
+build_sources_library fss_extended_read.c private-fss_extended_read.c
 build_sources_program main.c
 build_sources_headers fss_extended_read.h
 build_sources_bash