]> Kevux Git Server - fll/commitdiff
Update: add level 3 fss * write projects
authorKevin Day <kevin@kevux.org>
Sat, 31 Mar 2012 19:51:55 +0000 (14:51 -0500)
committerKevin Day <kevin@kevux.org>
Sat, 31 Mar 2012 19:51:55 +0000 (14:51 -0500)
12 files changed:
level_3/fss_basic_list_write/c/fss_basic_list_write.c [new file with mode: 0644]
level_3/fss_basic_list_write/c/fss_basic_list_write.h [new file with mode: 0644]
level_3/fss_basic_list_write/c/main.c [new file with mode: 0644]
level_3/fss_basic_list_write/data/build/settings [new file with mode: 0644]
level_3/fss_basic_write/c/fss_basic_write.c [new file with mode: 0644]
level_3/fss_basic_write/c/fss_basic_write.h [new file with mode: 0644]
level_3/fss_basic_write/c/main.c [new file with mode: 0644]
level_3/fss_basic_write/data/build/settings [new file with mode: 0644]
level_3/fss_extended_write/c/fss_extended_write.c [new file with mode: 0644]
level_3/fss_extended_write/c/fss_extended_write.h [new file with mode: 0644]
level_3/fss_extended_write/c/main.c [new file with mode: 0644]
level_3/fss_extended_write/data/build/settings [new file with mode: 0644]

diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.c b/level_3/fss_basic_list_write/c/fss_basic_list_write.c
new file mode 100644 (file)
index 0000000..19a29c1
--- /dev/null
@@ -0,0 +1,304 @@
+/* FLL - Level 3
+ * Project:       FSS
+ * Version:       0.3.x
+ * Licenses:      lgplv2.1
+ * Programmers:   Kevin Day
+ */
+#include <level_3/fss_basic_list_write.h>
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+// version printed may be used by scripts, so this will only print the version number and a newline, no extra information or colors
+#ifndef _di_fss_basic_list_write_print_version_
+  f_return_status fss_basic_list_write_print_version(const fss_basic_list_write_data data) {
+    printf("%s\n", fss_basic_list_write_version);
+
+    return f_none;
+  }
+#endif // _fss_basic_list_write_print_version_
+
+#ifndef _di_fss_basic_list_write_print_help_
+  f_return_status fss_basic_list_write_print_help(const fss_basic_list_write_data data) {
+    printf("\n");
+    fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", fss_basic_list_write_name_long);
+
+    printf("\n");
+    fl_print_color(f_standard_output, data.context.notable, data.context.reset, "  Version %s", fss_basic_list_write_version);
+
+
+    printf("\n\n");
+    fl_print_color(f_standard_output, data.context.important, data.context.reset, " Available Options: ");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_short_help);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_help);
+    printf("      Print this help message");
+
+    printf("\n  %s", f_console_symbol_short_disable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_short_light);
+
+    printf(", %s", f_console_symbol_long_disable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_light);
+    printf("     Output using colors that show up better on light backgrounds");
+
+    printf("\n  %s", f_console_symbol_short_disable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_short_no_color);
+
+    printf(", %s", f_console_symbol_long_disable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_no_color);
+    printf("  Do not output in color");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_short_version);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_version);
+    printf("   Print only the version number");
+
+
+    printf("\n");
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_list_write_short_type);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_list_write_long_type);
+    printf("    Specify a what to write: object or content.");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_list_write_short_output);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_list_write_long_output);
+    printf("  Specify a file to send output to.");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_list_write_short_string);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_list_write_long_string);
+    printf("  Specify a string to convert.");
+
+
+    printf("\n\n");
+    fl_print_color(f_standard_output, data.context.important, data.context.reset, " Usage: ");
+
+    printf("\n  ");
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_list_write_name);
+
+    printf("  ");
+    fl_print_color(f_standard_output, data.context.notable, data.context.reset, "[");
+
+    printf(" options ");
+    fl_print_color(f_standard_output, data.context.notable, data.context.reset, "]");
+
+
+    printf("\n\n");
+
+    return f_none;
+  }
+#endif // _di_fss_basic_list_write_print_help_
+
+#ifndef _di_fss_basic_list_write_main_
+  f_return_status fss_basic_list_write_main(const f_array_length argc, const f_string argv[], fss_basic_list_write_data *data) {
+    f_status status            = f_status_initialize;
+    f_status allocation_status = f_status_initialize;
+
+    status = fl_process_parameters(argc, argv, data->parameters, fss_basic_list_write_total_parameters, &data->remaining);
+
+    // load colors when not told to show no colors
+    if (data->parameters[fss_basic_list_write_parameter_no_color].result == f_console_result_none) {
+      fll_new_color_context(allocation_status, data->context);
+
+      if (allocation_status == f_none) {
+        fll_colors_load_context(&data->context, data->parameters[fss_basic_list_write_parameter_light].result == f_console_result_found);
+      } else {
+        fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
+        fss_basic_list_write_delete_data(data);
+        return allocation_status;
+      }
+    }
+
+    if (status != f_none) {
+      if (status == f_no_data) {
+        fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
+        // TODO: there is a way to identify which parameter is incorrect
+        //       to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
+        //       nothing can be 0 as that represents the program name, unless argv[] is improperly created
+      } else if (f_macro_test_for_allocation_errors(status)) {
+        fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
+      } else if (status == f_invalid_parameter) {
+        fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters().");
+      } else {
+        fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status);
+      }
+
+      fss_basic_list_write_delete_data(data);
+      return status;
+    }
+
+    // execute parameter results
+    if (data->parameters[fss_basic_list_write_parameter_help].result == f_console_result_found) {
+      fss_basic_list_write_print_help(*data);
+    } else if (data->parameters[fss_basic_list_write_parameter_version].result == f_console_result_found) {
+      fss_basic_list_write_print_version(*data);
+    } else if (data->parameters[fss_basic_list_write_parameter_type].result == f_console_result_additional) {
+      f_array_length counter = f_array_length_initialize;
+      f_max_u_short  type    = 0;
+
+      f_dynamic_string  buffer   = f_dynamic_string_initialize;
+      f_string_location location = f_string_location_initialize;
+
+      if (strncmp("object", argv[data->parameters[fss_basic_list_write_parameter_type].additional.array[0]], 7) == 0) {
+        type = fss_basic_list_write_type_object;
+      } else if (strncmp("content", argv[data->parameters[fss_basic_list_write_parameter_type].additional.array[0]], 8) == 0) {
+        type = fss_basic_list_write_type_content;
+      }
+
+      if (data->process_pipe) {
+        f_file           file  = f_file_initialize;
+        f_dynamic_string input = f_dynamic_string_initialize;
+
+        file.file = f_pipe;
+
+        status = fl_file_read_fifo(file, &input);
+
+        if (status != f_none) {
+          if (status == f_invalid_parameter) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
+          } else if (status == f_file_not_found) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", "-");
+          } else if (status == f_file_open_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", "-");
+          } else if (status == f_file_descriptor_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
+          } else {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+          }
+
+          f_delete_dynamic_string(status, input);
+          fss_basic_list_write_delete_data(data);
+          return status;
+        }
+
+        location.start = 0;
+        location.stop = input.used - 1;
+
+        if (type == fss_basic_list_write_type_object) {
+          status = fl_fss_basic_list_object_write(input, &location, &buffer);
+
+          if (f_macro_test_for_no_data_errors(status)) {
+            return status;
+          }
+        } else if (type == fss_basic_list_write_type_content) {
+          status = fl_fss_basic_list_content_write(input, &location, &buffer);
+
+          if (f_macro_test_for_no_data_errors(status)) {
+            return status;
+          }
+        }
+
+        f_delete_dynamic_string(status, input);
+      } else if (data->parameters[fss_basic_list_write_parameter_string].result == f_console_result_additional) {
+        f_dynamic_string input = f_dynamic_string_initialize;
+
+        input.string = argv[data->parameters[fss_basic_list_write_parameter_string].additional.array[0]];
+        input.used = strlen(input.string);
+
+        location.start = 0;
+        location.stop = input.used - 1;
+
+        if (type == fss_basic_list_write_type_object) {
+          status = fl_fss_basic_list_object_write(input, &location, &buffer);
+
+          if (f_macro_test_for_no_data_errors(status)) {
+            return status;
+          }
+        } else if (type == fss_basic_list_write_type_content) {
+          status = fl_fss_basic_list_content_write(input, &location, &buffer);
+
+          if (f_macro_test_for_no_data_errors(status)) {
+            return status;
+          }
+        }
+
+        status = f_none;
+      }
+
+      if (data->parameters[fss_basic_list_write_parameter_output].result == f_console_result_additional) {
+        f_file output = f_file_initialize;
+
+        output.mode = f_file_write_append;
+        status = f_file_open(&output, argv[data->parameters[fss_basic_list_write_parameter_output].additional.array[0]]);
+
+        if (status != f_none) {
+          f_file_close(&output);
+
+          if (status == f_invalid_parameter) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
+          } else if (status == f_file_not_found) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", argv[data->parameters[fss_basic_list_write_parameter_output].additional.array[0]]);
+          } else if (status == f_file_open_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", argv[data->parameters[fss_basic_list_write_parameter_output].additional.array[0]]);
+          } else if (status == f_file_descriptor_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->parameters[fss_basic_list_write_parameter_output].additional.array[0]]);
+          } else {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+          }
+
+          fss_basic_list_write_delete_data(data);
+          return status;
+        }
+
+        status = fl_file_write(output, buffer);
+        f_file_close(&output);
+
+        if (status != f_none) {
+          if (status == f_invalid_parameter) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()");
+          } else if (status == f_file_write_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", argv[data->parameters[fss_basic_list_write_parameter_output].additional.array[0]]);
+          } else {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", status);
+          }
+
+          fss_basic_list_write_delete_data(data);
+          return status;
+        }
+      } else {
+        f_print_dynamic_string(f_standard_output, buffer);
+      }
+    } else {
+      fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you must specify the type to write: object, content, or both.");
+      status = f_invalid_parameter;
+    }
+
+    fss_basic_list_write_delete_data(data);
+    return status;
+  }
+#endif // _di_fss_basic_list_write_main_
+
+#ifndef _di_fss_basic_list_write_delete_data_
+  f_return_status fss_basic_list_write_delete_data(fss_basic_list_write_data *data) {
+    f_status        status = f_status_initialize;
+    f_string_length i      = 0;
+
+    while (i < fss_basic_list_write_total_parameters) {
+      f_delete_string_lengths(status, data->parameters[i].additional);
+      i++;
+    } // while
+
+    f_delete_string_lengths(status, data->remaining);
+    fll_delete_color_context(status, data->context);
+
+    return f_none;
+  }
+#endif // _di_fss_basic_list_write_delete_data_
+
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.h b/level_3/fss_basic_list_write/c/fss_basic_list_write.h
new file mode 100644 (file)
index 0000000..91605d6
--- /dev/null
@@ -0,0 +1,128 @@
+/* FLL - Level 3
+ * Project:       FSS
+ * Version:       0.3.x
+ * Licenses:      lgplv2.1
+ * Programmers:   Kevin Day
+ * Documentation:
+ *
+ * This program provides fss basic list write functionality.
+ */
+#ifndef _fss_basic_list_write_h
+
+// libc includes
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+// fll-0 includes
+#include <level_0/types.h>
+#include <level_0/strings.h>
+#include <level_0/console.h>
+#include <level_0/output.h>
+#include <level_0/pipe.h>
+
+// fll-1 includes
+#include <level_1/colors.h>
+#include <level_1/console.h>
+#include <level_1/strings.h>
+#include <level_1/errors.h>
+
+// fll-2 includes
+#include <level_2/colors.h>
+#include <level_2/fss_errors.h>
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+#ifndef _di_fss_basic_list_write_version_
+  #define fss_basic_list_write_major_version "0"
+  #define fss_basic_list_write_minor_version "3"
+  #define fss_basic_list_write_micro_version "0"
+  #define fss_basic_list_write_version fss_basic_list_write_major_version "." fss_basic_list_write_minor_version "." fss_basic_list_write_micro_version
+#endif // _di_fss_basic_list_write_version_
+
+#ifndef _di_fss_basic_list_write_name_
+  #define fss_basic_list_write_name "fss_basic_list_write"
+  #define fss_basic_list_write_name_long "FSS Basic List Write"
+#endif // _di_fss_basic_list_write_name_
+
+#ifndef _di_fss_basic_list_write_defines_
+  #define fss_basic_list_write_short_type   "t"
+  #define fss_basic_list_write_short_output "o"
+  #define fss_basic_list_write_short_string "s"
+
+  #define fss_basic_list_write_long_type   "type"
+  #define fss_basic_list_write_long_output "output"
+  #define fss_basic_list_write_long_string "string"
+
+  enum {
+    fss_basic_list_write_parameter_help,
+    fss_basic_list_write_parameter_light,
+    fss_basic_list_write_parameter_no_color,
+    fss_basic_list_write_parameter_version,
+
+    fss_basic_list_write_parameter_type,
+    fss_basic_list_write_parameter_output,
+    fss_basic_list_write_parameter_string,
+  };
+
+  enum {
+    fss_basic_list_write_type_object = 1,
+    fss_basic_list_write_type_content,
+  };
+
+  #define f_console_parameter_initialize_fss_basic_list_write \
+    { \
+      f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, 0, f_false, f_console_type_normal, 0), \
+      f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_false, f_console_type_inverse, 0), \
+      f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_false, f_console_type_inverse, 0), \
+      f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_false, f_console_type_normal, 0), \
+      f_console_parameter_initialize(fss_basic_list_write_short_type, fss_basic_list_write_long_type, 0, 0, f_true, f_console_type_normal, 0), \
+      f_console_parameter_initialize(fss_basic_list_write_short_output, fss_basic_list_write_long_output, 0, 0, f_true, f_console_type_normal, 0), \
+      f_console_parameter_initialize(fss_basic_list_write_short_string, fss_basic_list_write_long_string, 0, 0, f_true, f_console_type_normal, 0), \
+    }
+
+  #define fss_basic_list_write_total_parameters 7
+#endif // _di_fss_basic_list_write_defines_
+
+#ifndef _di_fss_basic_list_write_data_
+  typedef struct {
+    f_console_parameter parameters[fss_basic_list_write_total_parameters];
+
+    f_string_lengths remaining;
+    f_bool           process_pipe;
+
+    fll_color_context context;
+  } fss_basic_list_write_data;
+
+  #define fss_basic_list_write_data_initialize \
+    { \
+      f_console_parameter_initialize_fss_basic_list_write, \
+      f_string_lengths_initialize, \
+      f_false, \
+      fll_color_context_initialize, \
+    }
+#endif // _di_fss_basic_list_write_data_
+
+#ifndef _di_fss_basic_list_write_print_version_
+  extern f_return_status fss_basic_list_write_print_version(const fss_basic_list_write_data data);
+#endif // _di_fss_basic_list_write_print_version_
+
+#ifndef _di_fss_basic_list_write_print_help_
+  extern f_return_status fss_basic_list_write_print_help(const fss_basic_list_write_data data);
+#endif // _di_fss_basic_list_write_print_help_
+
+#ifndef _di_fss_basic_list_write_main_
+  extern f_return_status fss_basic_list_write_main(const f_array_length argc, const f_string argv[], fss_basic_list_write_data *data);
+#endif // _di_fss_basic_list_write_main_
+
+#ifndef _di_fss_basic_list_write_delete_data_
+  extern f_return_status fss_basic_list_write_delete_data(fss_basic_list_write_data *data);
+#endif // _di_fss_basic_list_write_delete_data_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _fss_basic_list_write_h
diff --git a/level_3/fss_basic_list_write/c/main.c b/level_3/fss_basic_list_write/c/main.c
new file mode 100644 (file)
index 0000000..e83c8e4
--- /dev/null
@@ -0,0 +1,11 @@
+#include <level_3/fss_basic_list_write.h>
+
+int main(const f_array_length argc, const f_string argv[]) {
+  fss_basic_list_write_data data = fss_basic_list_write_data_initialize;
+
+  if (f_pipe_exists()) {
+    data.process_pipe = f_true;
+  }
+
+  return fss_basic_list_write_main(argc, argv, &data);
+}
diff --git a/level_3/fss_basic_list_write/data/build/settings b/level_3/fss_basic_list_write/data/build/settings
new file mode 100644 (file)
index 0000000..fa1c84b
--- /dev/null
@@ -0,0 +1,21 @@
+# fss-0000
+
+project_name fss_basic_list_write
+project_level 3
+
+version_major 0
+version_minor 3
+version_micro 0
+
+build_compiler gcc
+build_libraries -lc -lf_memory -lf_console -lfl_console -lf_conversion -lf_pipe -lf_output -lf_file -lfl_colors -lfll_colors -lfl_errors -lfl_fss -lfll_fss -lfl_file
+build_sources_library fss_basic_list_write.c
+build_sources_program main.c
+build_sources_headers fss_basic_list_write.h
+build_shared yes
+
+flags_all -z now
+flags_shared
+flags_static
+flags_library -fPIC
+flags_program -fPIE -lfss_basic_list_write
diff --git a/level_3/fss_basic_write/c/fss_basic_write.c b/level_3/fss_basic_write/c/fss_basic_write.c
new file mode 100644 (file)
index 0000000..b420d94
--- /dev/null
@@ -0,0 +1,304 @@
+/* FLL - Level 3
+ * Project:       FSS
+ * Version:       0.3.x
+ * Licenses:      lgplv2.1
+ * Programmers:   Kevin Day
+ */
+#include <level_3/fss_basic_write.h>
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+// version printed may be used by scripts, so this will only print the version number and a newline, no extra information or colors
+#ifndef _di_fss_basic_write_print_version_
+  f_return_status fss_basic_write_print_version(const fss_basic_write_data data) {
+    printf("%s\n", fss_basic_write_version);
+
+    return f_none;
+  }
+#endif // _fss_basic_write_print_version_
+
+#ifndef _di_fss_basic_write_print_help_
+  f_return_status fss_basic_write_print_help(const fss_basic_write_data data) {
+    printf("\n");
+    fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", fss_basic_write_name_long);
+
+    printf("\n");
+    fl_print_color(f_standard_output, data.context.notable, data.context.reset, "  Version %s", fss_basic_write_version);
+
+
+    printf("\n\n");
+    fl_print_color(f_standard_output, data.context.important, data.context.reset, " Available Options: ");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_short_help);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_help);
+    printf("      Print this help message");
+
+    printf("\n  %s", f_console_symbol_short_disable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_short_light);
+
+    printf(", %s", f_console_symbol_long_disable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_light);
+    printf("     Output using colors that show up better on light backgrounds");
+
+    printf("\n  %s", f_console_symbol_short_disable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_short_no_color);
+
+    printf(", %s", f_console_symbol_long_disable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_no_color);
+    printf("  Do not output in color");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_short_version);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_version);
+    printf("   Print only the version number");
+
+
+    printf("\n");
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_write_short_type);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_write_long_type);
+    printf("    Specify a what to write: object or content.");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_write_short_output);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_write_long_output);
+    printf("  Specify a file to send output to.");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_write_short_string);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_write_long_string);
+    printf("  Specify a string to convert.");
+
+
+    printf("\n\n");
+    fl_print_color(f_standard_output, data.context.important, data.context.reset, " Usage: ");
+
+    printf("\n  ");
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_basic_write_name);
+
+    printf("  ");
+    fl_print_color(f_standard_output, data.context.notable, data.context.reset, "[");
+
+    printf(" options ");
+    fl_print_color(f_standard_output, data.context.notable, data.context.reset, "]");
+
+
+    printf("\n\n");
+
+    return f_none;
+  }
+#endif // _di_fss_basic_write_print_help_
+
+#ifndef _di_fss_basic_write_main_
+  f_return_status fss_basic_write_main(const f_array_length argc, const f_string argv[], fss_basic_write_data *data) {
+    f_status status            = f_status_initialize;
+    f_status allocation_status = f_status_initialize;
+
+    status = fl_process_parameters(argc, argv, data->parameters, fss_basic_write_total_parameters, &data->remaining);
+
+    // load colors when not told to show no colors
+    if (data->parameters[fss_basic_write_parameter_no_color].result == f_console_result_none) {
+      fll_new_color_context(allocation_status, data->context);
+
+      if (allocation_status == f_none) {
+        fll_colors_load_context(&data->context, data->parameters[fss_basic_write_parameter_light].result == f_console_result_found);
+      } else {
+        fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
+        fss_basic_write_delete_data(data);
+        return allocation_status;
+      }
+    }
+
+    if (status != f_none) {
+      if (status == f_no_data) {
+        fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
+        // TODO: there is a way to identify which parameter is incorrect
+        //       to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
+        //       nothing can be 0 as that represents the program name, unless argv[] is improperly created
+      } else if (f_macro_test_for_allocation_errors(status)) {
+        fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
+      } else if (status == f_invalid_parameter) {
+        fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters().");
+      } else {
+        fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status);
+      }
+
+      fss_basic_write_delete_data(data);
+      return status;
+    }
+
+    // execute parameter results
+    if (data->parameters[fss_basic_write_parameter_help].result == f_console_result_found) {
+      fss_basic_write_print_help(*data);
+    } else if (data->parameters[fss_basic_write_parameter_version].result == f_console_result_found) {
+      fss_basic_write_print_version(*data);
+    } else if (data->parameters[fss_basic_write_parameter_type].result == f_console_result_additional) {
+      f_array_length counter = f_array_length_initialize;
+      f_max_u_short  type    = 0;
+
+      f_dynamic_string  buffer   = f_dynamic_string_initialize;
+      f_string_location location = f_string_location_initialize;
+
+      if (strncmp("object", argv[data->parameters[fss_basic_write_parameter_type].additional.array[0]], 7) == 0) {
+        type = fss_basic_write_type_object;
+      } else if (strncmp("content", argv[data->parameters[fss_basic_write_parameter_type].additional.array[0]], 8) == 0) {
+        type = fss_basic_write_type_content;
+      }
+
+      if (data->process_pipe) {
+        f_file           file  = f_file_initialize;
+        f_dynamic_string input = f_dynamic_string_initialize;
+
+        file.file = f_pipe;
+
+        status = fl_file_read_fifo(file, &input);
+
+        if (status != f_none) {
+          if (status == f_invalid_parameter) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
+          } else if (status == f_file_not_found) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", "-");
+          } else if (status == f_file_open_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", "-");
+          } else if (status == f_file_descriptor_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
+          } else {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+          }
+
+          f_delete_dynamic_string(status, input);
+          fss_basic_write_delete_data(data);
+          return status;
+        }
+
+        location.start = 0;
+        location.stop = input.used - 1;
+
+        if (type == fss_basic_write_type_object) {
+          status = fl_fss_basic_object_write(input, &location, &buffer);
+
+          if (f_macro_test_for_no_data_errors(status)) {
+            return status;
+          }
+        } else if (type == fss_basic_write_type_content) {
+          status = fl_fss_basic_content_write(input, &location, &buffer);
+
+          if (f_macro_test_for_no_data_errors(status)) {
+            return status;
+          }
+        }
+
+        f_delete_dynamic_string(status, input);
+      } else if (data->parameters[fss_basic_write_parameter_string].result == f_console_result_additional) {
+        f_dynamic_string input = f_dynamic_string_initialize;
+
+        input.string = argv[data->parameters[fss_basic_write_parameter_string].additional.array[0]];
+        input.used = strlen(input.string);
+
+        location.start = 0;
+        location.stop = input.used - 1;
+
+        if (type == fss_basic_write_type_object) {
+          status = fl_fss_basic_object_write(input, &location, &buffer);
+
+          if (f_macro_test_for_no_data_errors(status)) {
+            return status;
+          }
+        } else if (type == fss_basic_write_type_content) {
+          status = fl_fss_basic_content_write(input, &location, &buffer);
+
+          if (f_macro_test_for_no_data_errors(status)) {
+            return status;
+          }
+        }
+
+        status = f_none;
+      }
+
+      if (data->parameters[fss_basic_write_parameter_output].result == f_console_result_additional) {
+        f_file output = f_file_initialize;
+
+        output.mode = f_file_write_append;
+        status = f_file_open(&output, argv[data->parameters[fss_basic_write_parameter_output].additional.array[0]]);
+
+        if (status != f_none) {
+          f_file_close(&output);
+
+          if (status == f_invalid_parameter) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
+          } else if (status == f_file_not_found) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", argv[data->parameters[fss_basic_write_parameter_output].additional.array[0]]);
+          } else if (status == f_file_open_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", argv[data->parameters[fss_basic_write_parameter_output].additional.array[0]]);
+          } else if (status == f_file_descriptor_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->parameters[fss_basic_write_parameter_output].additional.array[0]]);
+          } else {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+          }
+
+          fss_basic_write_delete_data(data);
+          return status;
+        }
+
+        status = fl_file_write(output, buffer);
+        f_file_close(&output);
+
+        if (status != f_none) {
+          if (status == f_invalid_parameter) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()");
+          } else if (status == f_file_write_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", argv[data->parameters[fss_basic_write_parameter_output].additional.array[0]]);
+          } else {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", status);
+          }
+
+          fss_basic_write_delete_data(data);
+          return status;
+        }
+      } else {
+        f_print_dynamic_string(f_standard_output, buffer);
+      }
+    } else {
+      fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you must specify the type to write: object, content, or both.");
+      status = f_invalid_parameter;
+    }
+
+    fss_basic_write_delete_data(data);
+    return status;
+  }
+#endif // _di_fss_basic_write_main_
+
+#ifndef _di_fss_basic_write_delete_data_
+  f_return_status fss_basic_write_delete_data(fss_basic_write_data *data) {
+    f_status        status = f_status_initialize;
+    f_string_length i      = 0;
+
+    while (i < fss_basic_write_total_parameters) {
+      f_delete_string_lengths(status, data->parameters[i].additional);
+      i++;
+    } // while
+
+    f_delete_string_lengths(status, data->remaining);
+    fll_delete_color_context(status, data->context);
+
+    return f_none;
+  }
+#endif // _di_fss_basic_write_delete_data_
+
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
diff --git a/level_3/fss_basic_write/c/fss_basic_write.h b/level_3/fss_basic_write/c/fss_basic_write.h
new file mode 100644 (file)
index 0000000..705f6f5
--- /dev/null
@@ -0,0 +1,128 @@
+/* FLL - Level 3
+ * Project:       FSS
+ * Version:       0.3.x
+ * Licenses:      lgplv2.1
+ * Programmers:   Kevin Day
+ * Documentation:
+ *
+ * This program provides fss basic write functionality.
+ */
+#ifndef _fss_basic_write_h
+
+// libc includes
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+// fll-0 includes
+#include <level_0/types.h>
+#include <level_0/strings.h>
+#include <level_0/console.h>
+#include <level_0/output.h>
+#include <level_0/pipe.h>
+
+// fll-1 includes
+#include <level_1/colors.h>
+#include <level_1/console.h>
+#include <level_1/strings.h>
+#include <level_1/errors.h>
+
+// fll-2 includes
+#include <level_2/colors.h>
+#include <level_2/fss_errors.h>
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+#ifndef _di_fss_basic_write_version_
+  #define fss_basic_write_major_version "0"
+  #define fss_basic_write_minor_version "3"
+  #define fss_basic_write_micro_version "0"
+  #define fss_basic_write_version fss_basic_write_major_version "." fss_basic_write_minor_version "." fss_basic_write_micro_version
+#endif // _di_fss_basic_write_version_
+
+#ifndef _di_fss_basic_write_name_
+  #define fss_basic_write_name "fss_basic_write"
+  #define fss_basic_write_name_long "FSS Basic Write"
+#endif // _di_fss_basic_write_name_
+
+#ifndef _di_fss_basic_write_defines_
+  #define fss_basic_write_short_type   "t"
+  #define fss_basic_write_short_output "o"
+  #define fss_basic_write_short_string "s"
+
+  #define fss_basic_write_long_type   "type"
+  #define fss_basic_write_long_output "output"
+  #define fss_basic_write_long_string "string"
+
+  enum {
+    fss_basic_write_parameter_help,
+    fss_basic_write_parameter_light,
+    fss_basic_write_parameter_no_color,
+    fss_basic_write_parameter_version,
+
+    fss_basic_write_parameter_type,
+    fss_basic_write_parameter_output,
+    fss_basic_write_parameter_string,
+  };
+
+  enum {
+    fss_basic_write_type_object = 1,
+    fss_basic_write_type_content,
+  };
+
+  #define f_console_parameter_initialize_fss_basic_write \
+    { \
+      f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, 0, f_false, f_console_type_normal, 0), \
+      f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_false, f_console_type_inverse, 0), \
+      f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_false, f_console_type_inverse, 0), \
+      f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_false, f_console_type_normal, 0), \
+      f_console_parameter_initialize(fss_basic_write_short_type, fss_basic_write_long_type, 0, 0, f_true, f_console_type_normal, 0), \
+      f_console_parameter_initialize(fss_basic_write_short_output, fss_basic_write_long_output, 0, 0, f_true, f_console_type_normal, 0), \
+      f_console_parameter_initialize(fss_basic_write_short_string, fss_basic_write_long_string, 0, 0, f_true, f_console_type_normal, 0), \
+    }
+
+  #define fss_basic_write_total_parameters 7
+#endif // _di_fss_basic_write_defines_
+
+#ifndef _di_fss_basic_write_data_
+  typedef struct {
+    f_console_parameter parameters[fss_basic_write_total_parameters];
+
+    f_string_lengths remaining;
+    f_bool           process_pipe;
+
+    fll_color_context context;
+  } fss_basic_write_data;
+
+  #define fss_basic_write_data_initialize \
+    { \
+      f_console_parameter_initialize_fss_basic_write, \
+      f_string_lengths_initialize, \
+      f_false, \
+      fll_color_context_initialize, \
+    }
+#endif // _di_fss_basic_write_data_
+
+#ifndef _di_fss_basic_write_print_version_
+  extern f_return_status fss_basic_write_print_version(const fss_basic_write_data data);
+#endif // _di_fss_basic_write_print_version_
+
+#ifndef _di_fss_basic_write_print_help_
+  extern f_return_status fss_basic_write_print_help(const fss_basic_write_data data);
+#endif // _di_fss_basic_write_print_help_
+
+#ifndef _di_fss_basic_write_main_
+  extern f_return_status fss_basic_write_main(const f_array_length argc, const f_string argv[], fss_basic_write_data *data);
+#endif // _di_fss_basic_write_main_
+
+#ifndef _di_fss_basic_write_delete_data_
+  extern f_return_status fss_basic_write_delete_data(fss_basic_write_data *data);
+#endif // _di_fss_basic_write_delete_data_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _fss_basic_write_h
diff --git a/level_3/fss_basic_write/c/main.c b/level_3/fss_basic_write/c/main.c
new file mode 100644 (file)
index 0000000..842b604
--- /dev/null
@@ -0,0 +1,11 @@
+#include <level_3/fss_basic_write.h>
+
+int main(const f_array_length argc, const f_string argv[]) {
+  fss_basic_write_data data = fss_basic_write_data_initialize;
+
+  if (f_pipe_exists()) {
+    data.process_pipe = f_true;
+  }
+
+  return fss_basic_write_main(argc, argv, &data);
+}
diff --git a/level_3/fss_basic_write/data/build/settings b/level_3/fss_basic_write/data/build/settings
new file mode 100644 (file)
index 0000000..8c1425d
--- /dev/null
@@ -0,0 +1,21 @@
+# fss-0000
+
+project_name fss_basic_write
+project_level 3
+
+version_major 0
+version_minor 3
+version_micro 0
+
+build_compiler gcc
+build_libraries -lc -lf_memory -lf_console -lfl_console -lf_conversion -lf_pipe -lf_output -lf_file -lfl_colors -lfll_colors -lfl_errors -lfl_fss -lfll_fss -lfl_file
+build_sources_library fss_basic_write.c
+build_sources_program main.c
+build_sources_headers fss_basic_write.h
+build_shared yes
+
+flags_all -z now
+flags_shared
+flags_static
+flags_library -fPIC
+flags_program -fPIE -lfss_basic_write
diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c
new file mode 100644 (file)
index 0000000..c0ab863
--- /dev/null
@@ -0,0 +1,349 @@
+/* FLL - Level 3
+ * Project:       FSS
+ * Version:       0.3.x
+ * Licenses:      lgplv2.1
+ * Programmers:   Kevin Day
+ */
+#include <level_3/fss_extended_write.h>
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+// version printed may be used by scripts, so this will only print the version number and a newline, no extra information or colors
+#ifndef _di_fss_extended_write_print_version_
+  f_return_status fss_extended_write_print_version(const fss_extended_write_data data) {
+    printf("%s\n", fss_extended_write_version);
+
+    return f_none;
+  }
+#endif // _fss_extended_write_print_version_
+
+#ifndef _di_fss_extended_write_print_help_
+  f_return_status fss_extended_write_print_help(const fss_extended_write_data data) {
+    printf("\n");
+    fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", fss_extended_write_name_long);
+
+    printf("\n");
+    fl_print_color(f_standard_output, data.context.notable, data.context.reset, "  Version %s", fss_extended_write_version);
+
+
+    printf("\n\n");
+    fl_print_color(f_standard_output, data.context.important, data.context.reset, " Available Options: ");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_short_help);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_help);
+    printf("      Print this help message");
+
+    printf("\n  %s", f_console_symbol_short_disable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_short_light);
+
+    printf(", %s", f_console_symbol_long_disable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_light);
+    printf("     Output using colors that show up better on light backgrounds");
+
+    printf("\n  %s", f_console_symbol_short_disable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_short_no_color);
+
+    printf(", %s", f_console_symbol_long_disable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_no_color);
+    printf("  Do not output in color");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_short_version);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_version);
+    printf("   Print only the version number");
+
+
+    printf("\n");
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_extended_write_short_type);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_extended_write_long_type);
+    printf("     Specify a what to write: object or content.");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_extended_write_short_output);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_extended_write_long_output);
+    printf("   Specify a file to send output to.");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_extended_write_short_string);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_extended_write_long_string);
+    printf("   Specify a string to convert.");
+
+    printf("\n  %s", f_console_symbol_short_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_extended_write_short_partial);
+
+    printf(", %s", f_console_symbol_long_enable);
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_extended_write_long_partial);
+    printf("  For 'content', do not output the end of content character.");
+
+
+    printf("\n\n");
+    fl_print_color(f_standard_output, data.context.important, data.context.reset, " Usage: ");
+
+    printf("\n  ");
+    fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_extended_write_name);
+
+    printf("  ");
+    fl_print_color(f_standard_output, data.context.notable, data.context.reset, "[");
+
+    printf(" options ");
+    fl_print_color(f_standard_output, data.context.notable, data.context.reset, "]");
+
+
+    printf("\n\n");
+
+    return f_none;
+  }
+#endif // _di_fss_extended_write_print_help_
+
+#ifndef _di_fss_extended_write_main_
+  f_return_status fss_extended_write_main(const f_array_length argc, const f_string argv[], fss_extended_write_data *data) {
+    f_status status            = f_status_initialize;
+    f_status allocation_status = f_status_initialize;
+
+    status = fl_process_parameters(argc, argv, data->parameters, fss_extended_write_total_parameters, &data->remaining);
+
+    // load colors when not told to show no colors
+    if (data->parameters[fss_extended_write_parameter_no_color].result == f_console_result_none) {
+      fll_new_color_context(allocation_status, data->context);
+
+      if (allocation_status == f_none) {
+        fll_colors_load_context(&data->context, data->parameters[fss_extended_write_parameter_light].result == f_console_result_found);
+      } else {
+        fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
+        fss_extended_write_delete_data(data);
+        return allocation_status;
+      }
+    }
+
+    if (status != f_none) {
+      if (status == f_no_data) {
+        fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
+        // TODO: there is a way to identify which parameter is incorrect
+        //       to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
+        //       nothing can be 0 as that represents the program name, unless argv[] is improperly created
+      } else if (f_macro_test_for_allocation_errors(status)) {
+        fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
+      } else if (status == f_invalid_parameter) {
+        fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters().");
+      } else {
+        fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status);
+      }
+
+      fss_extended_write_delete_data(data);
+      return status;
+    }
+
+    // execute parameter results
+    if (data->parameters[fss_extended_write_parameter_help].result == f_console_result_found) {
+      fss_extended_write_print_help(*data);
+    } else if (data->parameters[fss_extended_write_parameter_version].result == f_console_result_found) {
+      fss_extended_write_print_version(*data);
+    } else if (data->parameters[fss_extended_write_parameter_type].result == f_console_result_additional) {
+      f_array_length counter = f_array_length_initialize;
+      f_max_u_short  type    = 0;
+
+      f_dynamic_string  buffer   = f_dynamic_string_initialize;
+      f_string_location location = f_string_location_initialize;
+
+      if (strncmp("object", argv[data->parameters[fss_extended_write_parameter_type].additional.array[0]], 7) == 0) {
+        type = fss_extended_write_type_object;
+      } else if (strncmp("content", argv[data->parameters[fss_extended_write_parameter_type].additional.array[0]], 8) == 0) {
+        type = fss_extended_write_type_content;
+      }
+
+      if (data->process_pipe) {
+        f_file           file  = f_file_initialize;
+        f_dynamic_string input = f_dynamic_string_initialize;
+
+        file.file = f_pipe;
+
+        status = fl_file_read_fifo(file, &input);
+
+        if (status != f_none) {
+          if (status == f_invalid_parameter) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
+          } else if (status == f_file_not_found) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", "-");
+          } else if (status == f_file_open_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", "-");
+          } else if (status == f_file_descriptor_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
+          } else {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+          }
+
+          f_delete_dynamic_string(status, input);
+          fss_extended_write_delete_data(data);
+          return status;
+        }
+
+        location.start = 0;
+        location.stop = input.used - 1;
+
+        if (type == fss_extended_write_type_object) {
+          status = fl_fss_extended_object_write(input, &location, &buffer);
+
+          if (f_macro_test_for_no_data_errors(status)) {
+            return status;
+          }
+        } else if (type == fss_extended_write_type_content) {
+          status = fl_fss_extended_content_write(input, &location, &buffer);
+
+          if (f_macro_test_for_no_data_errors(status)) {
+            return status;
+          }
+
+          if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_none) {
+            if (buffer.used >= buffer.size) {
+              f_resize_dynamic_string(status, buffer, buffer.used + f_fss_default_allocation_step);
+
+              if (f_macro_test_for_no_data_errors(status)) {
+                return status;
+              }
+            }
+
+            buffer.string[buffer.used] = f_fss_extended_close;
+            buffer.used++;
+          }
+        }
+
+        f_delete_dynamic_string(status, input);
+      } else if (data->parameters[fss_extended_write_parameter_string].result == f_console_result_additional) {
+        f_dynamic_string input = f_dynamic_string_initialize;
+
+        if (type == fss_extended_write_type_object) {
+          input.string = argv[data->parameters[fss_extended_write_parameter_string].additional.array[0]];
+          input.used = strlen(input.string);
+
+          location.start = 0;
+          location.stop = input.used - 1;
+
+          status = fl_fss_extended_object_write(input, &location, &buffer);
+
+          if (f_macro_test_for_no_data_errors(status)) {
+            return status;
+          }
+        } else if (type == fss_extended_write_type_content) {
+          f_string_length i = 0;
+
+          while (i < data->parameters[fss_extended_write_parameter_string].additional.used) {
+            input.string = argv[data->parameters[fss_extended_write_parameter_string].additional.array[i]];
+            input.used = strlen(input.string);
+
+            location.start = 0;
+            location.stop = input.used - 1;
+
+            status = fl_fss_extended_content_write(input, &location, &buffer);
+
+            if (f_macro_test_for_no_data_errors(status)) {
+              return status;
+            }
+
+            i++;
+          } // while
+
+          if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_none) {
+            if (buffer.used >= buffer.size) {
+              f_resize_dynamic_string(status, buffer, buffer.used + f_fss_default_allocation_step);
+
+              if (f_macro_test_for_no_data_errors(status)) {
+                return status;
+              }
+            }
+
+            buffer.string[buffer.used] = f_fss_extended_close;
+            buffer.used++;
+          }
+        }
+
+        status = f_none;
+      }
+
+      if (data->parameters[fss_extended_write_parameter_output].result == f_console_result_additional) {
+        f_file output = f_file_initialize;
+
+        output.mode = f_file_write_append;
+        status = f_file_open(&output, argv[data->parameters[fss_extended_write_parameter_output].additional.array[0]]);
+
+        if (status != f_none) {
+          f_file_close(&output);
+
+          if (status == f_invalid_parameter) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
+          } else if (status == f_file_not_found) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", argv[data->parameters[fss_extended_write_parameter_output].additional.array[0]]);
+          } else if (status == f_file_open_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", argv[data->parameters[fss_extended_write_parameter_output].additional.array[0]]);
+          } else if (status == f_file_descriptor_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->parameters[fss_extended_write_parameter_output].additional.array[0]]);
+          } else {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+          }
+
+          fss_extended_write_delete_data(data);
+          return status;
+        }
+
+        status = fl_file_write(output, buffer);
+        f_file_close(&output);
+
+        if (status != f_none) {
+          if (status == f_invalid_parameter) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()");
+          } else if (status == f_file_write_error) {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", argv[data->parameters[fss_extended_write_parameter_output].additional.array[0]]);
+          } else {
+            fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", status);
+          }
+
+          fss_extended_write_delete_data(data);
+          return status;
+        }
+      } else {
+        f_print_dynamic_string(f_standard_output, buffer);
+      }
+    } else {
+      fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you must specify the type to write: object, content, or both.");
+      status = f_invalid_parameter;
+    }
+
+    fss_extended_write_delete_data(data);
+    return status;
+  }
+#endif // _di_fss_extended_write_main_
+
+#ifndef _di_fss_extended_write_delete_data_
+  f_return_status fss_extended_write_delete_data(fss_extended_write_data *data) {
+    f_status        status = f_status_initialize;
+    f_string_length i      = 0;
+
+    while (i < fss_extended_write_total_parameters) {
+      f_delete_string_lengths(status, data->parameters[i].additional);
+      i++;
+    } // while
+
+    f_delete_string_lengths(status, data->remaining);
+    fll_delete_color_context(status, data->context);
+
+    return f_none;
+  }
+#endif // _di_fss_extended_write_delete_data_
+
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
diff --git a/level_3/fss_extended_write/c/fss_extended_write.h b/level_3/fss_extended_write/c/fss_extended_write.h
new file mode 100644 (file)
index 0000000..5c9adee
--- /dev/null
@@ -0,0 +1,132 @@
+/* FLL - Level 3
+ * Project:       FSS
+ * Version:       0.3.x
+ * Licenses:      lgplv2.1
+ * Programmers:   Kevin Day
+ * Documentation:
+ *
+ * This program provides fss basic write functionality.
+ */
+#ifndef _fss_extended_write_h
+
+// libc includes
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+// fll-0 includes
+#include <level_0/types.h>
+#include <level_0/strings.h>
+#include <level_0/console.h>
+#include <level_0/output.h>
+#include <level_0/pipe.h>
+
+// fll-1 includes
+#include <level_1/colors.h>
+#include <level_1/console.h>
+#include <level_1/strings.h>
+#include <level_1/errors.h>
+
+// fll-2 includes
+#include <level_2/colors.h>
+#include <level_2/fss_errors.h>
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+#ifndef _di_fss_extended_write_version_
+  #define fss_extended_write_major_version "0"
+  #define fss_extended_write_minor_version "3"
+  #define fss_extended_write_micro_version "0"
+  #define fss_extended_write_version fss_extended_write_major_version "." fss_extended_write_minor_version "." fss_extended_write_micro_version
+#endif // _di_fss_extended_write_version_
+
+#ifndef _di_fss_extended_write_name_
+  #define fss_extended_write_name "fss_extended_write"
+  #define fss_extended_write_name_long "FSS Extended Write"
+#endif // _di_fss_extended_write_name_
+
+#ifndef _di_fss_extended_write_defines_
+  #define fss_extended_write_short_type    "t"
+  #define fss_extended_write_short_output  "o"
+  #define fss_extended_write_short_string  "s"
+  #define fss_extended_write_short_partial "p"
+
+  #define fss_extended_write_long_type    "type"
+  #define fss_extended_write_long_output  "output"
+  #define fss_extended_write_long_string  "string"
+  #define fss_extended_write_long_partial "partial"
+
+  enum {
+    fss_extended_write_parameter_help,
+    fss_extended_write_parameter_light,
+    fss_extended_write_parameter_no_color,
+    fss_extended_write_parameter_version,
+
+    fss_extended_write_parameter_type,
+    fss_extended_write_parameter_output,
+    fss_extended_write_parameter_string,
+    fss_extended_write_parameter_partial,
+  };
+
+  enum {
+    fss_extended_write_type_object = 1,
+    fss_extended_write_type_content,
+  };
+
+  #define f_console_parameter_initialize_fss_extended_write \
+    { \
+      f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, 0, f_false, f_console_type_normal, 0), \
+      f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_false, f_console_type_inverse, 0), \
+      f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_false, f_console_type_inverse, 0), \
+      f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_false, f_console_type_normal, 0), \
+      f_console_parameter_initialize(fss_extended_write_short_type, fss_extended_write_long_type, 0, 0, f_true, f_console_type_normal, 0), \
+      f_console_parameter_initialize(fss_extended_write_short_output, fss_extended_write_long_output, 0, 0, f_true, f_console_type_normal, 0), \
+      f_console_parameter_initialize(fss_extended_write_short_string, fss_extended_write_long_string, 0, 0, f_true, f_console_type_normal, 0), \
+      f_console_parameter_initialize(fss_extended_write_short_partial, fss_extended_write_long_partial, 0, 0, f_false, f_console_type_normal, 0), \
+    }
+
+  #define fss_extended_write_total_parameters 8
+#endif // _di_fss_extended_write_defines_
+
+#ifndef _di_fss_extended_write_data_
+  typedef struct {
+    f_console_parameter parameters[fss_extended_write_total_parameters];
+
+    f_string_lengths remaining;
+    f_bool           process_pipe;
+
+    fll_color_context context;
+  } fss_extended_write_data;
+
+  #define fss_extended_write_data_initialize \
+    { \
+      f_console_parameter_initialize_fss_extended_write, \
+      f_string_lengths_initialize, \
+      f_false, \
+      fll_color_context_initialize, \
+    }
+#endif // _di_fss_extended_write_data_
+
+#ifndef _di_fss_extended_write_print_version_
+  extern f_return_status fss_extended_write_print_version(const fss_extended_write_data data);
+#endif // _di_fss_extended_write_print_version_
+
+#ifndef _di_fss_extended_write_print_help_
+  extern f_return_status fss_extended_write_print_help(const fss_extended_write_data data);
+#endif // _di_fss_extended_write_print_help_
+
+#ifndef _di_fss_extended_write_main_
+  extern f_return_status fss_extended_write_main(const f_array_length argc, const f_string argv[], fss_extended_write_data *data);
+#endif // _di_fss_extended_write_main_
+
+#ifndef _di_fss_extended_write_delete_data_
+  extern f_return_status fss_extended_write_delete_data(fss_extended_write_data *data);
+#endif // _di_fss_extended_write_delete_data_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _fss_extended_write_h
diff --git a/level_3/fss_extended_write/c/main.c b/level_3/fss_extended_write/c/main.c
new file mode 100644 (file)
index 0000000..d929719
--- /dev/null
@@ -0,0 +1,11 @@
+#include <level_3/fss_extended_write.h>
+
+int main(const f_array_length argc, const f_string argv[]) {
+  fss_extended_write_data data = fss_extended_write_data_initialize;
+
+  if (f_pipe_exists()) {
+    data.process_pipe = f_true;
+  }
+
+  return fss_extended_write_main(argc, argv, &data);
+}
diff --git a/level_3/fss_extended_write/data/build/settings b/level_3/fss_extended_write/data/build/settings
new file mode 100644 (file)
index 0000000..031006f
--- /dev/null
@@ -0,0 +1,21 @@
+# fss-0000
+
+project_name fss_extended_write
+project_level 3
+
+version_major 0
+version_minor 3
+version_micro 0
+
+build_compiler gcc
+build_libraries -lc -lf_memory -lf_console -lfl_console -lf_conversion -lf_pipe -lf_output -lf_file -lfl_colors -lfll_colors -lfl_errors -lfl_fss -lfll_fss -lfl_file
+build_sources_library fss_extended_write.c
+build_sources_program main.c
+build_sources_headers fss_extended_write.h
+build_shared yes
+
+flags_all -z now
+flags_shared
+flags_static
+flags_library -fPIC
+flags_program -fPIE -lfss_extended_write