From a8ecd50a28cb4dbd7999746b61e60110e8e2af63 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 22 Sep 2020 23:53:50 -0500 Subject: [PATCH] Progress: begin overhauling the printing infrastructure. As part of making the level_3 projects (aka programs) more consistent, I started centralizing the print functions. This started with status/error handling. Then one thing led to the next and I ended up deciding to change the behavior to use file descriptors more consistently everywhere in the FLL project. I also decided to go with the error print structure I original created in the fake program. Verbosity has been moved into this structure. The new level_2 project "fll_error" will store the error messages that are shared between the level_3 projects. Given the size of these changes, I didn't complete the work. This commit is guaranteed to not compile. --- build/level_2/settings | 4 +- build/monolithic/settings | 4 +- level_0/f_color/c/color.h | 5 +- level_0/f_console/c/console-common.h | 8 +- level_0/f_print/c/print.h | 32 +- level_1/fl_color/c/color.c | 126 +++-- level_1/fl_color/c/color.h | 118 +++-- level_1/fl_directory/c/directory.c | 6 +- level_1/fl_directory/c/directory.h | 12 +- level_1/fl_directory/c/private-directory.c | 8 +- level_1/fl_string/c/private-string.h | 2 - level_1/fl_utf/c/private-utf.h | 2 - level_1/fl_utf_file/c/private-utf_file.c | 8 +- level_1/fl_utf_file/c/private-utf_file.h | 8 +- level_2/fll_error/c/error-common.h | 79 +++ level_2/fll_error/c/error.c | 351 ++++++++++++++ level_2/fll_error/c/error.h | 137 ++++++ level_2/fll_error/c/private-error.c | 104 ++++ level_2/fll_error/c/private-error.h | 71 +++ level_2/fll_error/data/build/defines | 2 + level_2/fll_error/data/build/dependencies | 10 + level_2/fll_error/data/build/settings | 54 +++ level_2/fll_file/c/file.c | 30 +- level_2/fll_fss/c/fss.c | 1 + level_2/fll_program/c/program.c | 201 ++------ level_2/fll_program/c/program.h | 68 +-- level_3/byte_dump/c/byte_dump.c | 215 +++++---- level_3/byte_dump/c/byte_dump.h | 17 +- level_3/byte_dump/c/private-byte_dump.c | 81 +--- level_3/byte_dump/c/private-byte_dump.h | 22 - level_3/byte_dump/data/build/dependencies | 1 + level_3/byte_dump/data/build/settings | 2 +- level_3/fake/c/fake.c | 172 +++---- level_3/fake/c/fake.h | 22 +- level_3/fake/c/private-build.c | 300 ++++++------ level_3/fake/c/private-clean.c | 8 +- level_3/fake/c/private-fake.c | 170 +++---- level_3/fake/c/private-fake.h | 12 +- level_3/fake/c/private-make.c | 480 +++++++++--------- level_3/fake/c/private-make.h | 37 +- level_3/fake/c/private-print.c | 380 +++++++-------- level_3/fake/c/private-print.h | 6 +- level_3/fake/c/private-skeleton.c | 44 +- level_3/fake/data/build/dependencies | 3 +- level_3/fake/data/build/settings | 2 +- level_3/firewall/c/firewall.c | 106 ++-- level_3/firewall/c/firewall.h | 47 +- level_3/firewall/c/private-firewall.c | 112 ++--- level_3/firewall/c/private-firewall.h | 2 +- level_3/firewall/data/build/dependencies | 1 + level_3/firewall/data/build/settings | 2 +- .../fss_basic_list_read/c/fss_basic_list_read.c | 156 +++--- .../fss_basic_list_read/c/fss_basic_list_read.h | 19 +- .../c/private-fss_basic_list_read.c | 182 +++---- .../fss_basic_list_read/data/build/dependencies | 1 + level_3/fss_basic_list_read/data/build/settings | 2 +- .../fss_basic_list_write/c/fss_basic_list_write.c | 108 +++-- .../fss_basic_list_write/c/fss_basic_list_write.h | 19 +- .../fss_basic_list_write/data/build/dependencies | 1 + level_3/fss_basic_list_write/data/build/settings | 2 +- level_3/fss_basic_read/c/fss_basic_read.c | 156 +++--- level_3/fss_basic_read/c/fss_basic_read.h | 19 +- level_3/fss_basic_read/c/private-fss_basic_read.c | 182 +++---- level_3/fss_basic_read/data/build/dependencies | 1 + level_3/fss_basic_read/data/build/settings | 2 +- level_3/fss_basic_write/c/fss_basic_write.c | 108 +++-- level_3/fss_basic_write/c/fss_basic_write.h | 19 +- level_3/fss_basic_write/data/build/dependencies | 1 + level_3/fss_basic_write/data/build/settings | 2 +- .../c/fss_extended_list_read.c | 156 +++--- .../c/fss_extended_list_read.h | 19 +- .../c/private-fss_extended_list_read.c | 182 +++---- .../fss_extended_list_read/data/build/dependencies | 1 + level_3/fss_extended_list_read/data/build/settings | 2 +- level_3/fss_extended_read/c/fss_extended_read.c | 156 +++--- level_3/fss_extended_read/c/fss_extended_read.h | 19 +- .../c/private-fss_extended_read.c | 182 +++---- level_3/fss_extended_read/data/build/dependencies | 1 + level_3/fss_extended_read/data/build/settings | 2 +- level_3/fss_extended_write/c/fss_extended_write.c | 108 +++-- level_3/fss_extended_write/c/fss_extended_write.h | 19 +- level_3/fss_extended_write/data/build/dependencies | 1 + level_3/fss_extended_write/data/build/settings | 2 +- level_3/fss_status_code/c/fss_status_code.c | 110 +++-- level_3/fss_status_code/c/fss_status_code.h | 19 +- .../fss_status_code/c/private-fss_status_code.c | 20 +- level_3/fss_status_code/data/build/dependencies | 1 + level_3/fss_status_code/data/build/settings | 2 +- level_3/iki_read/c/iki_read.c | 537 +++++++++++---------- level_3/iki_read/c/iki_read.h | 21 +- level_3/iki_read/c/private-iki_read.c | 268 +++++----- level_3/iki_read/data/build/dependencies | 1 + level_3/iki_read/data/build/settings | 2 +- level_3/iki_write/c/iki_write.c | 192 ++++---- level_3/iki_write/c/iki_write.h | 19 +- level_3/iki_write/c/private-iki_write.c | 204 ++++---- level_3/iki_write/data/build/dependencies | 1 + level_3/iki_write/data/build/settings | 2 +- level_3/init/c/init.c | 92 +++- level_3/init/c/init.h | 29 +- level_3/init/c/private-init.c | 60 +-- level_3/init/data/build/dependencies | 1 + level_3/init/data/build/settings | 2 +- level_3/status_code/c/private-status_code.c | 20 +- level_3/status_code/c/status_code.c | 112 +++-- level_3/status_code/c/status_code.h | 19 +- level_3/status_code/data/build/dependencies | 1 + level_3/status_code/data/build/settings | 2 +- 108 files changed, 4214 insertions(+), 3048 deletions(-) create mode 100644 level_2/fll_error/c/error-common.h create mode 100644 level_2/fll_error/c/error.c create mode 100644 level_2/fll_error/c/error.h create mode 100644 level_2/fll_error/c/private-error.c create mode 100644 level_2/fll_error/c/private-error.h create mode 100644 level_2/fll_error/data/build/defines create mode 100644 level_2/fll_error/data/build/dependencies create mode 100644 level_2/fll_error/data/build/settings diff --git a/build/level_2/settings b/build/level_2/settings index fc68ae1..41af89a 100644 --- a/build/level_2/settings +++ b/build/level_2/settings @@ -20,9 +20,9 @@ build_indexer ar build_language c build_libraries -lc build_libraries-level -lfll_1 -lfll_0 -build_sources_library execute.c private-execute.c file.c private-file.c fss.c private-fss.c fss_basic.c fss_basic_list.c fss_extended.c fss_extended_list.c fss_status.c iki.c private-iki.c path.c program.c status.c +build_sources_library error.c private-error.c execute.c private-execute.c file.c private-file.c fss.c private-fss.c fss_basic.c fss_basic_list.c fss_extended.c fss_extended_list.c fss_status.c iki.c private-iki.c path.c program.c status.c build_sources_program -build_sources_headers execute.h file.h fss.h fss_basic.h fss_basic_list.h fss_extended.h fss_extended_list.h fss_status.h iki.h path.h program.h status.h +build_sources_headers error.h error-common.h execute.h file.h fss.h fss_basic.h fss_basic_list.h fss_extended.h fss_extended_list.h fss_status.h iki.h path.h program.h status.h build_sources_script build_sources_setting build_script yes diff --git a/build/monolithic/settings b/build/monolithic/settings index f113b1e..6fd56c1 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -20,9 +20,9 @@ build_indexer ar build_language c build_libraries -lc build_libraries-monolithic -build_sources_library level_0/account.c level_0/console.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/private-file.c level_0/fss.c level_0/iki.c level_0/private-iki.c level_0/memory.c level_0/path.c level_0/private-path.c level_0/pipe.c level_0/print.c level_0/private-print.c level_0/serialize.c level_0/private-serialize.c level_0/signal.c level_0/socket.c level_0/utf.c level_0/private-utf.c level_1/color.c level_1/console.c level_1/conversion.c level_1/directory.c level_1/private-directory.c level_1/environment.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/iki.c level_1/print.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/private-file.c level_2/fss.c level_2/private-fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/iki.c level_2/private-iki.c level_2/path.c level_2/program.c level_2/status.c +build_sources_library level_0/account.c level_0/console.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/private-file.c level_0/fss.c level_0/iki.c level_0/private-iki.c level_0/memory.c level_0/path.c level_0/private-path.c level_0/pipe.c level_0/print.c level_0/private-print.c level_0/serialize.c level_0/private-serialize.c level_0/signal.c level_0/socket.c level_0/utf.c level_0/private-utf.c level_1/color.c level_1/console.c level_1/conversion.c level_1/directory.c level_1/private-directory.c level_1/environment.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/iki.c level_1/print.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/error.c level_2/private-error.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/private-file.c level_2/fss.c level_2/private-fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/iki.c level_2/private-iki.c level_2/path.c level_2/program.c level_2/status.c build_sources_program -build_sources_headers level_0/account.h level_0/account-common.h level_0/color.h level_0/console.h level_0/console-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/fss-common.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quoted.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/memory.h level_0/memory_structure.h level_0/path.h level_0/path-common.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/type.h level_0/type_array.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_macro.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/iki.h level_2/path.h level_2/program.h level_2/status.h +build_sources_headers level_0/account.h level_0/account-common.h level_0/color.h level_0/console.h level_0/console-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/fss-common.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quoted.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/memory.h level_0/memory_structure.h level_0/path.h level_0/path-common.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/type.h level_0/type_array.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_macro.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/error.h level_2/error-common.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/iki.h level_2/path.h level_2/program.h level_2/status.h build_sources_script build_sources_setting build_script yes diff --git a/level_0/f_color/c/color.h b/level_0/f_color/c/color.h index 70df15d..3fec240 100644 --- a/level_0/f_color/c/color.h +++ b/level_0/f_color/c/color.h @@ -252,14 +252,15 @@ extern "C" { * Provide a set of two colors, a before and an after. * * This is intended to be used for printing, such that the printed code is prefixed with the "before" and postfixed with the "after". + * These color strings should be NULL terminated. * * before: A pointer to the dynamic string representing the before color to assign, set to NULL to disable. * after: A pointer to the dynamic string representing the after color to assign, set to NULL to disable. */ #ifndef _di_f_color_set_t_ typedef struct { - const f_string_dynamic_t *before; - const f_string_dynamic_t *after; + const f_string_static_t *before; + const f_string_static_t *after; } f_color_set_t; #define f_color_set_t_initialize { 0, 0 } diff --git a/level_0/f_console/c/console-common.h b/level_0/f_console/c/console-common.h index 5a90473..57a7176 100644 --- a/level_0/f_console/c/console-common.h +++ b/level_0/f_console/c/console-common.h @@ -250,9 +250,9 @@ extern "C" { * * Designed for passing this to a function as a single argument. * - * parameter: Intended to be populated with an array of f_console_parameter_id_t whose size is defined by the "used" property. - * This is not intended to be dynamically allocated, so there is no "size" property. - * order: + * parameters: Intended to be populated with an array of f_console_parameter_id_t whose size is defined by the "used" property. + * This is not intended to be dynamically allocated, so there is no "size" property. + * length: The total number of parameters in the parameters array. */ #ifndef _di_f_console_parameters_t_ typedef struct { @@ -263,7 +263,7 @@ extern "C" { #define f_console_parameters_t_initialize { 0, 0 } - #define f_macro_console_parameters_t_initialize(parameter, used) { parameter, used } + #define f_macro_console_parameters_t_initialize(parameters, length) { parameters, length } #endif // _di_f_console_parameters_t_ /** diff --git a/level_0/f_print/c/print.h b/level_0/f_print/c/print.h index cb9a234..4d1284c 100644 --- a/level_0/f_print/c/print.h +++ b/level_0/f_print/c/print.h @@ -150,13 +150,12 @@ extern "C" { * * Will not stop at NULL. * Will not print NULL. + * Will print the entire dynamic string. * - * @param id - * The file descriptor to output to. - * @param string + * @param output + * The file to output to, including standard streams such as stdout and stderr. + * @param buffer * The string to output. - * @param length - * The total number of characters to print. * * @return * F_none on success. @@ -172,9 +171,9 @@ extern "C" { * * @see write() */ -#ifndef _di_f_print_dynamic_to_ - extern f_return_status f_print_dynamic_to(const int id, const f_string_t string, const f_string_length_t length); -#endif // _di_f_print_dynamic_to_ +#ifndef _di_f_print_to_dynamic_ + extern f_return_status f_print_to_dynamic(const int id, const f_string_static_t buffer); +#endif // _di_f_print_to_dynamic_ /** * Similar to a c-library dprintf, except that this will only print a specific range in a given dynamic string. @@ -183,13 +182,14 @@ extern "C" { * * Will not stop at NULL. * Will not print NULL. + * Will print the only the buffer range specified by range. * - * @param id - * The file descriptor to output to. - * @param string + * @param output + * The file to output to, including standard streams such as stdout and stderr. + * @param buffer * The string to output. - * @param length - * The total number of characters to print. + * @param range + * The range within the provided string to print. * * @return * F_none on success. @@ -205,9 +205,9 @@ extern "C" { * * @see write() */ -#ifndef _di_f_print_dynamic_partial_to_ - extern f_return_status f_print_dynamic_partial_to(const int id, const f_string_t string, const f_string_length_t length); -#endif // _di_f_print_dynamic_partial_to_ +#ifndef _di_f_print_to_dynamic_partial_ + extern f_return_status f_print_to_dynamic_partial(const int id, const f_string_static_t buffer, const f_string_range_t range); +#endif // _di_f_print_to_dynamic_partial_ #ifdef __cplusplus } // extern "C" diff --git a/level_1/fl_color/c/color.c b/level_1/fl_color/c/color.c index 0184d95..619a25e 100644 --- a/level_1/fl_color/c/color.c +++ b/level_1/fl_color/c/color.c @@ -20,12 +20,34 @@ extern "C" { else if (!color3) fprintf(file, "%s%s%s%s%s", format.begin, color1, format.medium, color2, format.end); else if (!color4) fprintf(file, "%s%s%s%s%s%s%s", format.begin, color1, format.medium, color2, format.medium, color3, format.end); else if (!color5) fprintf(file, "%s%s%s%s%s%s%s%s%s", format.begin, color1, format.medium, color2, format.medium, color3, format.medium, color4, format.end); - else fprintf(file, "%s%s%s%s%s%s%s%s%s%s%s", format.begin, color1, format.medium, color2, format.medium, color3, format.medium, color4, format.medium, color5, format.end); + else fprintf(file, "%s%s%s%s%s%s%s%s%s%s%s", format.begin, color1, format.medium, color2, format.medium, color3, format.medium, color4, format.medium, color5, format.end); return F_none; } #endif // _di_fl_color_set_ +#ifndef _di_fl_color_set_to_ + f_return_status fl_color_set_to(const int id, const f_color_format_t format, const int8_t *color1, const int8_t *color2, const int8_t *color3, const int8_t *color4, const int8_t *color5) { + #ifndef _di_level_1_parameter_checking_ + if (id == -1) return F_status_set_error(F_parameter); + if (!color1) return F_status_set_error(F_parameter); + + // make sure all data is in the proper order + if (!color2 && (color3 != 0 || color4 != 0 || color5 != 0)) return F_status_set_error(F_parameter); + if (!color3 && (color4 != 0 || color5 != 0)) return F_status_set_error(F_parameter); + if (!color4 && color5 != 0) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (!color2) dprintf(id, "%s%s%s", format.begin, color1, format.end); + else if (!color3) dprintf(id, "%s%s%s%s%s", format.begin, color1, format.medium, color2, format.end); + else if (!color4) dprintf(id, "%s%s%s%s%s%s%s", format.begin, color1, format.medium, color2, format.medium, color3, format.end); + else if (!color5) dprintf(id, "%s%s%s%s%s%s%s%s%s", format.begin, color1, format.medium, color2, format.medium, color3, format.medium, color4, format.end); + else dprintf(id, "%s%s%s%s%s%s%s%s%s%s%s", format.begin, color1, format.medium, color2, format.medium, color3, format.medium, color4, format.medium, color5, format.end); + + return F_none; + } +#endif // _di_fl_color_set_to_ + #ifndef _di_fl_color_save_ f_return_status fl_color_save(f_string_dynamic_t *buffer, const f_color_format_t format, const int8_t *color1, const int8_t *color2, const int8_t *color3, const int8_t *color4, const int8_t *color5) { #ifndef _di_level_1_parameter_checking_ @@ -44,7 +66,7 @@ extern "C" { else if (!color3) string_size += strnlen(color1, f_color_max_size) + strnlen(color2, f_color_max_size); else if (!color4) string_size += strnlen(color1, f_color_max_size) + strnlen(color2, f_color_max_size) + strnlen(color3, f_color_max_size); else if (!color5) string_size += strnlen(color1, f_color_max_size) + strnlen(color2, f_color_max_size) + strnlen(color3, f_color_max_size) + strnlen(color4, f_color_max_size); - else string_size += strnlen(color1, f_color_max_size) + strnlen(color2, f_color_max_size) + strnlen(color3, f_color_max_size) + strnlen(color4, f_color_max_size) + strnlen(color5, f_color_max_size); + else string_size += strnlen(color1, f_color_max_size) + strnlen(color2, f_color_max_size) + strnlen(color3, f_color_max_size) + strnlen(color4, f_color_max_size) + strnlen(color5, f_color_max_size); // make sure there is enough allocated space, if not, then allocate some more if (buffer->size - buffer->used - 1 < string_size) { @@ -121,8 +143,7 @@ extern "C" { #endif // _di_level_1_parameter_checking_ if (set.before) { - f_status_t status = f_print_dynamic(file, *set.before); - if (F_status_is_error(status)) return status; + fprintf(file, "%s", set.before->string); } va_list ap; @@ -134,9 +155,7 @@ extern "C" { va_end(ap); if (set.after) { - f_status_t status = f_print_dynamic(file, *set.after); - - if (F_status_is_error(status)) return status; + fprintf(file, "%s", set.after->string); } return F_none; @@ -153,13 +172,11 @@ extern "C" { f_status_t status = F_none; if (set.before) { - status = f_print_dynamic(file, *set.before); - if (F_status_is_error(status)) return status; + fprintf(file, "%s", set.before->string); } if (extra.before) { - status = f_print_dynamic(file, *extra.before); - if (F_status_is_error(status)) return status; + fprintf(file, "%s", extra.before->string); } va_list ap; @@ -171,105 +188,108 @@ extern "C" { va_end(ap); if (set.after) { - status = f_print_dynamic(file, *set.after); - if (F_status_is_error(status)) return status; + fprintf(file, "%s", set.after->string); } if (extra.after) { - status = f_print_dynamic(file, *extra.after); - if (F_status_is_error(status)) return status; + fprintf(file, "%s", extra.after->string); } return F_none; } #endif // _di_fl_color_print2_ -#ifndef _di_fl_color_print_line_ - f_return_status fl_color_print_line(FILE *file, const f_color_set_t set, const f_string_t string, ...) { +#ifndef _di_fl_color_print_code_ + f_return_status fl_color_print_code(FILE *file, const f_string_static_t color) { #ifndef _di_level_1_parameter_checking_ if (!file) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (color.used) { + fprintf(file, "%s", color.string); + } + + return F_none; + } +#endif // _di_fl_color_print_code_ + +#ifndef _di_fl_color_print_code_to_ + f_return_status fl_color_print_code_to(const int id, const f_string_static_t color) { + #ifndef _di_level_1_parameter_checking_ + if (id == -1) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (color.used) { + dprintf(id, "%s", color.string); + } + + return F_none; + } +#endif // _di_fl_color_print_code_to_ + +#ifndef _di_fl_color_print_to_ + f_return_status fl_color_print_to(const int id, const f_color_set_t set, const f_string_t string, ...) { + #ifndef _di_level_1_parameter_checking_ + if (id == -1) return F_status_set_error(F_parameter); if (!string) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ if (set.before) { - f_status_t status = f_print_dynamic(file, *set.before); - if (F_status_is_error(status)) return status; + dprintf(id, "%s", set.before->string); } va_list ap; va_start(ap, string); - vfprintf(file, string, ap); + vdprintf(id, string, ap); va_end(ap); if (set.after) { - f_status_t status = f_print_dynamic(file, *set.after); - if (F_status_is_error(status)) return status; + dprintf(id, "%s", set.after->string); } - // now print the trailing newline, this is done _after_ ending the colors to avoid color wrapping issues that can happen when a color code follows a newline - fprintf(file, "%c", f_string_eol[0]); - return F_none; } -#endif // _di_fl_color_print_line_ +#endif // _di_fl_color_print_to_ -#ifndef _di_fl_color_print2_line_ - f_return_status fl_color_print2_line(FILE *file, const f_color_set_t set, const f_color_set_t extra, const f_string_t string, ...) { +#ifndef _di_fl_color_print2_to_ + f_return_status fl_color_print2_to(const int id, const f_color_set_t set, const f_color_set_t extra, const f_string_t string, ...) { #ifndef _di_level_1_parameter_checking_ - if (!file) return F_status_set_error(F_parameter); + if (id == -1) return F_status_set_error(F_parameter); if (!string) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ f_status_t status = F_none; if (set.before) { - status = f_print_dynamic(file, *set.before); - if (F_status_is_error(status)) return status; + dprintf(id, "%s", set.before->string); } if (extra.before) { - status = f_print_dynamic(file, *extra.before); - if (F_status_is_error(status)) return status; + dprintf(id, "%s", extra.before->string); } va_list ap; va_start(ap, string); - vfprintf(file, string, ap); + vdprintf(id, string, ap); va_end(ap); if (set.after) { - status = f_print_dynamic(file, *set.after); - if (F_status_is_error(status)) return status; + dprintf(id, "%s", set.after->string); } if (extra.after) { - status = f_print_dynamic(file, *extra.after); - if (F_status_is_error(status)) return status; - } - - // now print the trailing newline, this is done _after_ ending the colors to avoid color wrapping issues that can happen when a color code follows a newline - fprintf(file, "%c", f_string_eol[0]); - - return F_none; - } -#endif // _di_fl_color_print2_line_ - -#ifndef _di_fl_color_print_code_ - f_return_status fl_color_print_code(FILE *file, const f_string_static_t color) { - if (color.used) { - f_status_t status = f_print_dynamic(file, color); - if (F_status_is_error(status)) return status; + dprintf(id, "%s", extra.after->string); } return F_none; } -#endif // _di_fl_color_print_code_ +#endif // _di_fl_color_print2_to_ #ifndef _di_fl_color_load_context_ f_return_status fl_color_load_context(f_color_context_t *context, const bool use_light_colors) { diff --git a/level_1/fl_color/c/color.h b/level_1/fl_color/c/color.h index 67890ec..59cde6b 100644 --- a/level_1/fl_color/c/color.h +++ b/level_1/fl_color/c/color.h @@ -7,6 +7,8 @@ * * Provide basic color output support (linux & xterm). * This is the Featureless LINUX Library, so there is no support for non-linux colors at this time. + * + * For simplicity purposes, all color code strings are assumed to be NULL terminated. */ #ifndef _FL_color_h #define _FL_color_h @@ -63,6 +65,40 @@ extern "C" { #endif // _di_fl_color_set_ /** + * Given some file descriptor, and push color information to that descriptor. + * + * Up to 5 colors may be associted with a single color format block. + * + * @param id + * The file descriptor to print to. + * @param format + * The color format parts. + * @param color1 + * A color to assign, set to 0 to disable. + * @param color2 + * A color to assign, set to 0 to disable. + * @param color3 + * A color to assign, set to 0 to disable. + * @param color4 + * A color to assign, set to 0 to disable. + * @param color5 + * A color to assign, set to 0 to disable. + * + * @return + * F_none on success. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_fl_color_set_to_ + extern f_return_status fl_color_set_to(const int id, const f_color_format_t format, const int8_t *color1, const int8_t *color2, const int8_t *color3, const int8_t *color4, const int8_t *color5); + + #define fl_macro_color_set_to_1(id, format, color1) fl_color_set_to(id, format, color1, 0, 0, 0, 0) + #define fl_macro_color_set_to_2(id, format, color1, color2) fl_color_set_to(id, format, color1, color2, 0, 0, 0) + #define fl_macro_color_set_to_3(id, format, color1, color2, color3) fl_color_set_to(id, format, color1, color2, color3, 0, 0) + #define fl_macro_color_set_to_4(id, format, color1, color2, color3, color4) fl_color_set_to(id, format, color1, color2, color3, color4, 0) + #define fl_macro_color_set_to_5(id, format, color1, color2, color3, color4, color5) fl_color_set_to(id, format, color1, color2, color3, color4, color5) +#endif // _di_fl_color_set_to_ + +/** * Save color information to some string. * * Up to 5 colors may be associted with a single color format block. @@ -151,18 +187,14 @@ extern "C" { #endif // _di_fl_color_print2_ /** - * Print a string, wrapped in a given start and stop color, then print an EOL character. + * Print a single color code to the given file or standard io. * - * If the colors strings have nothing used in them, then this will only print the string. + * Be sure to forget to print the color reset when done. * * @param file * The file or standard io. - * @param set - * The color set used for printing. - * @param string - * The string to print to the file or standard io. - * @param ... - * Variable arguments, processed in the same way fprintf() processes them. + * @param start_color + * The color code to print. * * @return * F_none on success. @@ -170,24 +202,39 @@ extern "C" { * * Errors (with error bit) from: f_print_dynamic(). */ -#ifndef _di_fl_color_print_line_ - extern f_return_status fl_color_print_line(FILE *file, const f_color_set_t set, const f_string_t string, ...); -#endif // _di_fl_color_print_line_ +#ifndef _di_fl_color_print_code_ + extern f_return_status fl_color_print_code(FILE *file, const f_string_static_t color); +#endif // _di_fl_color_print_code_ /** - * Print a string, wrapped in a given start, extra, and stop color, then print an EOL character. + * Print a single color code to the given file represented by a file descriptor. * - * If the colors strings have nothing used in them, then this will only print the string. + * Be sure to forget to print the color reset when done. * - * It is common for colors to be bolded. - * This is intended to simplify printing bold colors. + * @param id + * The file descriptor to print to. + * @param start_color + * The color code to print. * - * @param file - * The file or standard io. + * @return + * F_none on success. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_print_to_dynamic(). + */ +#ifndef _di_fl_color_print_code_to_ + extern f_return_status fl_color_print_code_to(const int id, const f_string_static_t color); +#endif // _di_fl_color_print_code_to_ + +/** + * Print a string, wrapped in a given start and stop color. + * + * If the colors strings have nothing used in them, then this will only print the string. + * + * @param id + * The file descriptor to print to. * @param set * The color set used for printing. - * @param extra - * The a second color set used for printing, which gets appended after set.before and set.after, respectively. * @param string * The string to print to the file or standard io. * @param ... @@ -199,19 +246,28 @@ extern "C" { * * Errors (with error bit) from: f_print_dynamic(). */ -#ifndef _di_fl_color_print2_line_ - extern f_return_status fl_color_print2_line(FILE *file, const f_color_set_t set, const f_color_set_t extra, const f_string_t string, ...); -#endif // _di_fl_color_print2_line_ +#ifndef _di_fl_color_print_to_ + extern f_return_status fl_color_print_to(const int id, const f_color_set_t set, const f_string_t string, ...); +#endif // _di_fl_color_print_to_ /** - * Print a single color code to the given file or standard io. + * Print a string, wrapped in a given start, extra, and stop color. * - * Try not to forget to print the color reset when done. + * If the colors strings have nothing used in them, then this will only print the string. * - * @param file - * The file or standard io. - * @param start_color - * The color code to print. + * It is common for colors to be bolded. + * This is intended to simplify printing bold colors. + * + * @param id + * The file descriptor to print to. + * @param set + * The color set used for printing. + * @param extra + * The a second color set used for printing, which gets appended after set.before and set.after, respectively. + * @param string + * The string to print to the file or standard io. + * @param ... + * Variable arguments, processed in the same way fprintf() processes them. * * @return * F_none on success. @@ -219,9 +275,9 @@ extern "C" { * * Errors (with error bit) from: f_print_dynamic(). */ -#ifndef _di_fl_color_print_code_ - extern f_return_status fl_color_print_code(FILE *file, const f_string_static_t color); -#endif // _di_fl_color_print_code_ +#ifndef _di_fl_color_print2_to_ + extern f_return_status fl_color_print2_to(const int id, const f_color_set_t set, const f_color_set_t extra, const f_string_t string, ...); +#endif // _di_fl_color_print2_to_ /** * Load the appropriate colors into the color context. diff --git a/level_1/fl_directory/c/directory.c b/level_1/fl_directory/c/directory.c index c1ae6e2..b9bbb1c 100644 --- a/level_1/fl_directory/c/directory.c +++ b/level_1/fl_directory/c/directory.c @@ -131,7 +131,7 @@ extern "C" { status = private_fl_directory_clone(static_source, static_destination, role, recurse, 1); - if (status == F_none && recurse.output && recurse.verbose) { + if (status == F_none && recurse.output != -1 && recurse.verbose) { recurse.verbose(recurse.output, source, destination); } @@ -197,7 +197,7 @@ extern "C" { status = private_fl_directory_copy(static_source, static_destination, mode, recurse, 1); } - if (status == F_none && recurse.output && recurse.verbose) { + if (status == F_none && recurse.output != -1 && recurse.verbose) { recurse.verbose(recurse.output, source, destination); } @@ -251,7 +251,7 @@ extern "C" { status = private_fl_directory_copy(static_source, static_destination, mode, recurse, 1); } - if (status == F_none && recurse.output && recurse.verbose) { + if (status == F_none && recurse.output != -1 && recurse.verbose) { recurse.verbose(recurse.output, source, destination); } diff --git a/level_1/fl_directory/c/directory.h b/level_1/fl_directory/c/directory.h index ee7cbf4..8412542 100644 --- a/level_1/fl_directory/c/directory.h +++ b/level_1/fl_directory/c/directory.h @@ -58,9 +58,9 @@ extern "C" { * If TRUE, will fail when file already exists. * If FALSE, will not fail if file already exists (existing file will be replaced). * output: - * Set to 0 to not print on successful operation. - * Set to a valid file pointer to print to on successful operation. - * This is passed to the verbose function if that function pointer is not 0. + * Set to -1 to not print on successful operation. + * Set to a valid file descriptor to print to on successful operation. + * This is passed to the verbose function if that function pointer is not -1. * verbose: * Set to 0 to not print on successful operation. * Set to address of a function to be called for printing such that: @@ -78,12 +78,12 @@ extern "C" { f_number_unsigned_t depth_max; f_number_unsigned_t size_block; bool exclusive; - FILE *output; - void (*verbose)(FILE *, const f_string_t, const f_string_t); + int output; + void (*verbose)(const int, const f_string_t, const f_string_t); f_directory_statuss_t *failures; } fl_directory_recurse_t; - #define fl_directory_recurse_t_initialize { fl_directory_recurse_depth_max, f_file_default_read_size, F_false, 0, 0, 0 } + #define fl_directory_recurse_t_initialize { fl_directory_recurse_depth_max, f_file_default_read_size, F_false, -1, 0, 0 } #endif // _di_fl_directory_recurse_t_ /** diff --git a/level_1/fl_directory/c/private-directory.c b/level_1/fl_directory/c/private-directory.c index 07798d0..15edf84 100644 --- a/level_1/fl_directory/c/private-directory.c +++ b/level_1/fl_directory/c/private-directory.c @@ -116,7 +116,7 @@ extern "C" { if (depth < recurse.depth_max) { status = private_fl_directory_clone(source_sub, destination_sub, role, recurse, depth + 1); - if (status == F_none && recurse.output && recurse.verbose) { + if (status == F_none && recurse.output != -1 && recurse.verbose) { recurse.verbose(recurse.output, source_sub.string, destination_sub.string); } } @@ -208,7 +208,7 @@ extern "C" { return F_failure; } - if (recurse.output && recurse.verbose) { + if (recurse.output != -1 && recurse.verbose) { recurse.verbose(recurse.output, path_source, path_destination); } @@ -312,7 +312,7 @@ extern "C" { if (depth < recurse.depth_max) { status = private_fl_directory_copy(source_sub, destination_sub, mode, recurse, depth + 1); - if (status == F_none && recurse.output && recurse.verbose) { + if (status == F_none && recurse.output != -1 && recurse.verbose) { recurse.verbose(recurse.output, source_sub.string, destination_sub.string); } } @@ -405,7 +405,7 @@ extern "C" { return F_failure; } - if (recurse.output && recurse.verbose) { + if (recurse.output != -1 && recurse.verbose) { recurse.verbose(recurse.output, path_source, path_destination); } diff --git a/level_1/fl_string/c/private-string.h b/level_1/fl_string/c/private-string.h index d67d731..2b26e51 100644 --- a/level_1/fl_string/c/private-string.h +++ b/level_1/fl_string/c/private-string.h @@ -5,8 +5,6 @@ * API Version: 0.5 * Licenses: lgplv2.1 * - * Provides basic string manipulation and processing capabilities. - * * These are provided for internal reduction in redundant code. * These should not be exposed/used outside of this project. */ diff --git a/level_1/fl_utf/c/private-utf.h b/level_1/fl_utf/c/private-utf.h index 20c602a..579bc1a 100644 --- a/level_1/fl_utf/c/private-utf.h +++ b/level_1/fl_utf/c/private-utf.h @@ -5,8 +5,6 @@ * API Version: 0.5 * Licenses: lgplv2.1 * - * Provides UTF-8 character manipulation and processing capabilities. - * * These are provided for internal reduction in redundant code. * These should not be exposed/used outside of this project. */ diff --git a/level_1/fl_utf_file/c/private-utf_file.c b/level_1/fl_utf_file/c/private-utf_file.c index 5315848..9503055 100644 --- a/level_1/fl_utf_file/c/private-utf_file.c +++ b/level_1/fl_utf_file/c/private-utf_file.c @@ -5,7 +5,7 @@ extern "C" { #endif -#if !defined(fl_utf_file_read) || !defined(fl_utf_file_read_until) || !defined(fl_utf_file_read_range) +#if !defined(_di_fl_utf_file_read_) || !defined(_di_fl_utf_file_read_until_) || !defined(_di_fl_utf_file_read_range_) void private_fl_utf_file_process_read_buffer(const char *buffer_read, const ssize_t size_read, f_utf_string_dynamic_t *buffer, char buffer_char[], uint8_t *width, int8_t *width_last) { f_utf_character_t character = 0; f_string_length_t i = 0; @@ -67,9 +67,9 @@ extern "C" { } } // for } -#endif // !defined(fl_utf_file_read) || !defined(fl_utf_file_read_until) || !defined(fl_utf_file_read_range) +#endif // !defined(_di_fl_utf_file_read_) || !defined(_di_fl_utf_file_read_until_) || !defined(_di_fl_utf_file_read_range_) -#if !defined(fl_utf_file_write) || !defined(fl_utf_file_write_until) || !defined(fl_utf_file_write_range) +#if !defined(_di_fl_utf_file_write_) || !defined(_di_fl_utf_file_write_until_) || !defined(fl_utf_file_write_range) f_return_status private_fl_utf_file_write_until(const f_file_t file, const f_utf_string_t string, const f_utf_string_length_t total, f_utf_string_length_t *written) { *written = 0; @@ -188,7 +188,7 @@ extern "C" { return F_none; } -#endif // !defined(fl_utf_file_write) || !defined(fl_utf_file_write_until) || !defined(fl_utf_file_write_range) +#endif // !defined(_di_fl_utf_file_write_) || !defined(_di_fl_utf_file_write_until_) || !defined(fl_utf_file_write_range) #ifdef __cplusplus } // extern "C" diff --git a/level_1/fl_utf_file/c/private-utf_file.h b/level_1/fl_utf_file/c/private-utf_file.h index 93e46fa..a43d7ec 100644 --- a/level_1/fl_utf_file/c/private-utf_file.h +++ b/level_1/fl_utf_file/c/private-utf_file.h @@ -38,9 +38,9 @@ extern "C" { * @see fl_utf_file_read_range() * @see fl_utf_file_read_until() */ -#if !defined(fl_utf_file_read) || !defined(fl_utf_file_read_until) || !defined(fl_utf_file_read_range) +#if !defined(_di_fl_utf_file_read_) || !defined(_di_fl_utf_file_read_until_) || !defined(_di_fl_utf_file_read_range_) void private_fl_utf_file_process_read_buffer(const char *buffer_read, const ssize_t size_read, f_utf_string_dynamic_t *buffer, char buffer_char[], uint8_t *width, int8_t *width_last) f_gcc_attribute_visibility_internal; -#endif // !defined(fl_utf_file_read) || !defined(fl_utf_file_read_until) || !defined(fl_utf_file_read_range) +#endif // !defined(_di_fl_utf_file_read_) || !defined(_di_fl_utf_file_read_until_) || !defined(_di_fl_utf_file_read_range_) /** * Private implementation of fl_utf_file_write_until(). @@ -76,9 +76,9 @@ extern "C" { * @see fl_utf_file_write_range() * @see fl_utf_file_write_until() */ -#if !defined(fl_utf_file_write) || !defined(fl_utf_file_write_until) || !defined(fl_utf_file_write_range) +#if !defined(_di_fl_utf_file_write_) || !defined(_di_fl_utf_file_write_until_) || !defined(_di_fl_utf_file_write_range_) extern f_return_status private_fl_utf_file_write_until(const f_file_t file, const f_utf_string_t string, const f_utf_string_length_t total, f_utf_string_length_t *written) f_gcc_attribute_visibility_internal; -#endif // !defined(fl_utf_file_write) || !defined(fl_utf_file_write_until) || !defined(fl_utf_file_write_range) +#endif // !defined(_di_fl_utf_file_write_) || !defined(_di_fl_utf_file_write_until_) || !defined(_di_fl_utf_file_write_range_) #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_error/c/error-common.h b/level_2/fll_error/c/error-common.h new file mode 100644 index 0000000..108f2dc --- /dev/null +++ b/level_2/fll_error/c/error-common.h @@ -0,0 +1,79 @@ +/** + * FLL - Level 2 + * + * Project: Error + * API Version: 0.5 + * Licenses: lgplv2.1 + * + * Defines common data to be used for/by project error. + * + * This is auto-included by error.h and should not need to be explicitly included. + */ +#ifndef _FLL_error_common_h +#define _FLL_error_common_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Error file types. + */ +#ifndef _di_fll_error_file_type_ + enum { + fll_error_file_type_file = 1, + fll_error_file_type_directory, + fll_error_file_type_pipe, + }; + + #define fll_error_file_type_string_directory "directory" + #define fll_error_file_type_string_file "file" + #define fll_error_file_type_string_pipe "pipe" + + #define fll_error_file_type_length_directory 9 + #define fll_error_file_type_length_file 4 + #define fll_error_file_type_length_pipe 4 +#endif // _di_fll_error_file_type_ + +/** + * Structure for facilitating the error printing. + * + * to: The file descriptor to print to. + * verbosity: The verbosity mode. + * prefix: A prefix string to display before the error. + * context: The color codes for the entire error message. + * notable: The color codes for a part of the message to make more visible. + */ +#ifndef _di_fll_error_print_t_ + #define fll_error_print_error "ERROR: " + #define fll_error_print_warning "WARNING: " + + #define fll_error_print_error_length 7 + #define fll_error_print_warning_length 9 + + typedef struct { + int to; + uint8_t verbosity; + + const char *prefix; + + f_color_set_t context; + f_color_set_t notable; + } fll_error_print_t; + + #define fll_error_print_t_initialize { \ + f_type_descriptor_error, \ + f_console_verbosity_normal, \ + fll_error_print_error, \ + f_color_set_t_initialize, \ + f_color_set_t_initialize, \ + } + + #define fll_macro_error_print_t_initialize(to, verbosity, prefix, context, notable) { to, verbosity, prefix, context, notable } +#endif // _di_fll_error_print_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _FLL_error_common_h diff --git a/level_2/fll_error/c/error.c b/level_2/fll_error/c/error.c new file mode 100644 index 0000000..19facd4 --- /dev/null +++ b/level_2/fll_error/c/error.c @@ -0,0 +1,351 @@ +#include "error.h" +#include "private-error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fll_error_print_ + f_return_status fll_error_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback) { + return private_fll_error_print(print, status, function, fallback); + } +#endif // _di_fll_error_print_ + +#ifndef _di_fll_error_file_print_ + f_return_status fll_error_file_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback, const f_string_t name, const f_string_t operation, const uint8_t type) { + const char *type_name = fll_error_file_type_string_file; + + if (type == fll_error_file_type_directory) { + type_name = fll_error_file_type_string_directory; + } + else if (type == fll_error_file_type_pipe) { + type_name = fll_error_file_type_string_pipe; + } + + if (status == F_access_denied) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sAccess denied while trying to %s %s '", print.context.before->string, print.prefix ? print.prefix : "", operation, type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "'.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_access_group) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sCurrrent user is not allowed to use the given group while trying to %s %s '", print.context.before->string, print.prefix ? print.prefix : "", operation, type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "'.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_access_owner) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sCurrrent user is not allowed to use the given owner while trying to %s %s '", print.context.before->string, print.prefix ? print.prefix : "", operation, type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "'.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_directory) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sInvalid directory while trying to %s %s '", print.context.before->string, print.prefix ? print.prefix : "", operation, type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "'.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_directory_empty_not) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sThe %s '", print.context.before->string, print.prefix ? print.prefix : "", type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "' is not empty.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_file_closed) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sThe %s '", print.context.before->string, print.prefix ? print.prefix : "", type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "' is not open.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_file_found) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sThe %s '", print.context.before->string, print.prefix ? print.prefix : "", type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "' already exists.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_file_found_not) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sFailed to find %s '", print.context.before->string, print.prefix ? print.prefix : "", type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "'.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_file_read) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sA read error occurred while accessing the file '", print.context.before->string, print.prefix ? print.prefix : ""); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "'.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_file_seek) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sA seek error occurred while accessing the file '", print.context.before->string, print.prefix ? print.prefix : ""); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "'.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_loop) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sLoop while trying to %s %s '", print.context.before->string, print.prefix ? print.prefix : "", operation, type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "'.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_name) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sInvalid %s name '", print.context.before->string, print.prefix ? print.prefix : "", type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "'.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_number_overflow) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sOverflow while trying to %s %s '", print.context.before->string, print.prefix ? print.prefix : "", operation, type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "'.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_parameter) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sInvalid parameter", print.context.before->string, print.prefix ? print.prefix : ""); + + private_fll_error_print_function(print, function); + + dprintf(print.to, " for the %s '", type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "'.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_prohibited) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sProhibited by system while trying to %s %s '", print.context.before->string, print.prefix ? print.prefix : "", operation, type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "'.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (type == fll_error_file_type_file) { + if (status == F_directory_found_not) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sFailed to %s %s '", print.context.before->string, print.prefix ? print.prefix : "", operation, type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "' due to an invalid directory in the path.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + } + else if (type == fll_error_file_type_directory) { + if (status == F_directory_found_not) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sFailed to %s %s '", print.context.before->string, print.prefix ? print.prefix : "", operation, type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + dprintf(print.to, "' due to an invalid directory in the path.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_failure) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sFailed to %s %s '", print.context.before->string, print.prefix ? print.prefix : "", operation, type_name); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, name, print.notable.after->string); + } + + return F_false; + } + } + + return private_fll_error_print(print, status, function, fallback); + } +#endif // _di_fll_error_file_print_ + +#ifndef _di_fll_error_parameter_print_ + f_return_status fll_error_parameter_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback) { + + if (status == F_data_not) { + if (print.verbosity != f_console_verbosity_quiet) { + // @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 + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sOne of the parameters passed requires an additional argument that was not passed.%s%c", print.context.before->string, print.prefix ? print.prefix : ""); + dprintf(print.to, "' must not be an empty string.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_utf) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sInvalid UTF-8 character in a parameter when calling ", print.context.before->string, print.prefix ? print.prefix : ""); + + private_fll_error_print_function(print, function); + + dprintf(print.to, ".%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + return private_fll_error_print(print, status, function, fallback); + } +#endif // _di_fll_error_parameter_print_ + +#ifndef _di_fll_error_parameter_integer_print_ + f_return_status fll_error_parameter_integer_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback, const f_string_t parameter, const f_string_t argument) { + + if (status == F_data_not) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sThe argument for the parameter '", print.context.before->string, print.prefix ? print.prefix : ""); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, parameter, print.notable.after->string); + dprintf(print.to, "' must not be an empty string.%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_number) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", argument[0]); + dprintf(print.to, "%s%sThe argument '", print.context.before->string, print.prefix ? print.prefix : ""); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, argument, print.notable.after->string); + dprintf(print.to, "' is not a valid number for the parameter '"); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, argument, print.notable.after->string); + dprintf(print.to, "%s%s%s%s%c", print.context.after->string, print.notable.before->string, parameter, print.notable.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_number_negative) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", argument[0]); + dprintf(print.to, "%s%sThe argument '", print.context.before->string, print.prefix ? print.prefix : ""); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, argument, print.notable.after->string); + dprintf(print.to, "' is negative, which is not allowed for the parameter '"); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, argument, print.notable.after->string); + dprintf(print.to, "%s%s%s%s%c", print.context.after->string, print.notable.before->string, parameter, print.notable.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_number_overflow) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", argument[0]); + dprintf(print.to, "%s%sThe argument '", print.context.before->string, print.prefix ? print.prefix : ""); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, argument, print.notable.after->string); + dprintf(print.to, "' is too large for the parameter '"); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, argument, print.notable.after->string); + dprintf(print.to, "%s%s%s%s%c", print.context.after->string, print.notable.before->string, parameter, print.notable.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_number_positive) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", argument[0]); + dprintf(print.to, "%s%sThe argument '", print.context.before->string, print.prefix ? print.prefix : ""); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, argument, print.notable.after->string); + dprintf(print.to, "' is positive, which is not allowed for the parameter '"); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, argument, print.notable.after->string); + dprintf(print.to, "%s%s%s%s%c", print.context.after->string, print.notable.before->string, parameter, print.notable.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_number_underflow) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", argument[0]); + dprintf(print.to, "%s%sThe argument '", print.context.before->string, print.prefix ? print.prefix : ""); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, argument, print.notable.after->string); + dprintf(print.to, "' is too small for the parameter '"); + dprintf(print.to, "%s%s%s%s", print.context.after->string, print.notable.before->string, argument, print.notable.after->string); + dprintf(print.to, "%s%s%s%s%c", print.context.after->string, print.notable.before->string, parameter, print.notable.after->string, f_string_eol[0]); + } + + return F_false; + } + + return private_fll_error_print(print, status, function, fallback); + } +#endif // _di_fll_error_parameter_integer_print_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_2/fll_error/c/error.h b/level_2/fll_error/c/error.h new file mode 100644 index 0000000..0908071 --- /dev/null +++ b/level_2/fll_error/c/error.h @@ -0,0 +1,137 @@ +/** + * FLL - Level 2 + * + * Project: Error + * API Version: 0.5 + * Licenses: lgplv2.1 + * + * Provide functions commonly used by FLL based programs. + */ +#ifndef _FLL_error_h +#define _FLL_error_h + +// libc include +#include + +// fll-0 includes +#include +#include +#include +#include +#include +#include + +// fll-1 includes +#include +#include + +// fll-2 error includes +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print generic error or warning messages. + * + * @param print + * Designates how printing is to be performed. + * @param status + * The status code to process. + * Make sure this has F_status_set_fine() called if the status code has any error or warning bits. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * @param fallback + * Set to F_true to print the fallback error message for unknown errors. + * + * @return + * F_false is returned on successful print of known errors. + * F_true is returned if the status code is unknown. + */ +#ifndef _di_fll_error_print_ + extern f_return_status fll_error_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback); +#endif // _di_fll_error_print_ + +/** + * Print file related error or warning messages. + * + * @param print + * Designates how printing is to be performed. + * @param status + * The status code to process. + * Make sure this has F_status_set_fine() called if the status code has any error or warning bits. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * @param fallback + * Set to F_true to print the fallback error message for unknown errors. + * @param name + * The name of the file or directory. + * @param operation + * The operation that fails, such as 'create' or 'access'. + * @param type + * A valid file type code from the fll_error_file_type enum. + * + * @return + * F_true is returned if the status code has no print message. + * F_false is returned on successful print of known errors. + */ +#ifndef _di_fll_error_file_print_ + extern f_return_status fll_error_file_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback, const f_string_t name, const f_string_t operation, const uint8_t type); +#endif // _di_fll_error_file_print_ + +/** + * Print parameter related error or warning messages. + * + * @param print + * Designates how printing is to be performed. + * @param status + * The status code to process. + * Make sure this has F_status_set_fine() called if the status code has any error or warning bits. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * @param fallback + * Set to F_true to print the fallback error message for unknown errors. + * + * @return + * F_false is returned on successful print of known errors. + * F_true is returned if the status code is unknown. + */ +#ifndef _di_fll_error_parameter_print_ + extern f_return_status fll_error_parameter_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback); +#endif // _di_fll_error_parameter_print_ + +/** + * Print integer related error or warning messages. + * + * @param print + * Designates how printing is to be performed. + * @param status + * The status code to process. + * Make sure this has F_status_set_fine() called if the status code has any error or warning bits. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * @param fallback + * Set to F_true to print the fallback error message for unknown errors. + * @param parameter + * The name of the parameter. + * @param argument + * The argument associated with the given parameter. + * + * @return + * F_true is returned if the status code has no print message. + * F_false is returned on successful print of known errors. + */ +#ifndef _di_fll_error_parameter_integer_print_ + extern f_return_status fll_error_parameter_integer_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback, const f_string_t parameter, const f_string_t argument); +#endif // _di_fll_error_parameter_integer_print_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _FLL_error_h diff --git a/level_2/fll_error/c/private-error.c b/level_2/fll_error/c/private-error.c new file mode 100644 index 0000000..8e983e6 --- /dev/null +++ b/level_2/fll_error/c/private-error.c @@ -0,0 +1,104 @@ +#include "error.h" +#include "private-error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_fll_error_print_) || !defined(_di_fll_error_file_print_) || !defined(_di_fll_error_number_print_) + f_return_status private_fll_error_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback) { + + if (status == F_buffer_too_large) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sMaximum buffer length reached while processing ", print.context.before->string, print.prefix ? print.prefix : ""); + + private_fll_error_print_function(print, function); + + dprintf(print.to, ".%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_memory_allocation || status == F_memory_reallocation || status == F_memory_out) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sUnable to allocate memory in function ", print.context.before->string, print.prefix ? print.prefix : ""); + + private_fll_error_print_function(print, function); + + dprintf(print.to, ".%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_parameter) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sInvalid parameter", print.context.before->string, print.prefix ? print.prefix : ""); + + private_fll_error_print_function(print, function); + + dprintf(print.to, ".%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_string_too_large) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sMaximum string length reached while processing ", print.context.before->string, print.prefix ? print.prefix : ""); + + private_fll_error_print_function(print, function); + + dprintf(print.to, ".%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (status == F_utf) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%sInvalid UTF-8 character while calling ", print.context.before->string, print.prefix ? print.prefix : ""); + + private_fll_error_print_function(print, function); + + dprintf(print.to, ".%s%c", print.context.after->string, f_string_eol[0]); + } + + return F_false; + } + + if (fallback && print.verbosity != f_console_verbosity_quiet) { + if (print.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + dprintf(print.to, "%s%s(%llu)", print.context.before->string, print.prefix ? print.prefix : "", status); + + private_fll_error_print_function(print, function); + + dprintf(print.to, ".%s%c", print.context.after->string, f_string_eol[0]); + } + } + + return F_true; + } +#endif // !defined(_di_fll_error_print_) || !defined(_di_fll_error_file_print_) || !defined(_di_fll_error_number_print_) + +#if !defined(_di_fll_error_print_) || !defined(_di_fll_error_file_print_) || !defined(_di_fll_error_number_print_) + void private_fll_error_print_function(const fll_error_print_t print, const f_string_t function) { + + if (function) { + dprintf(print.to, " when calling function %s", print.context.after->string); + dprintf(print.to, "%s%s%s", print.notable.before->string, function, print.notable.after->string); + dprintf(print.to, "%s()", print.context.before->string); + } + } +#endif // !defined(_di_fll_error_print_) || !defined(_di_fll_error_file_print_) || !defined(_di_fll_error_number_print_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_2/fll_error/c/private-error.h b/level_2/fll_error/c/private-error.h new file mode 100644 index 0000000..1d01a9e --- /dev/null +++ b/level_2/fll_error/c/private-error.h @@ -0,0 +1,71 @@ +/** + * FLL - Level 2 + * + * Project: Error + * API Version: 0.5 + * Licenses: lgplv2.1 + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_FLL_error_h +#define _PRIVATE_FLL_error_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation of private_fll_error_print(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param print + * Designates how printing is to be performed. + * @param status + * The status code to process. + * Make sure this has F_status_set_fine() called if the status code has any error or warning bits. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * @param fallback + * Set to F_true to print the fallback error message for unknown errors. + * + * @return + * F_false is returned on successful print of known errors. + * F_true is returned if the status code is unknown. + * + * @see fll_error_print() + * @see fll_error_file_print() + */ +#if !defined(_di_fll_error_print_) || !defined(_di_fll_error_file_print_) || !defined(_di_fll_error_number_print_) + extern f_return_status private_fll_error_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_fll_error_print_) || !defined(_di_fll_error_file_print_) || !defined(_di_fll_error_number_print_) + +/** + * Special function for printing the "function name". + * + * Intended to be shared to each of the different implementation variations. + * + * @param print + * Designates how printing is to be performed. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * + * @return + * F_false is returned on successful print of known errors. + * F_true is returned if the status code is unknown. + * + * @see fll_error_print() + * @see fll_error_file_print() + */ +#if !defined(_di_fll_error_print_) || !defined(_di_fll_error_file_print_) || !defined(_di_fll_error_number_print_) + void private_fll_error_print_function(const fll_error_print_t print, const f_string_t function) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_fll_error_print_) || !defined(_di_fll_error_file_print_) || !defined(_di_fll_error_number_print_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_FLL_error_h diff --git a/level_2/fll_error/data/build/defines b/level_2/fll_error/data/build/defines new file mode 100644 index 0000000..c665317 --- /dev/null +++ b/level_2/fll_error/data/build/defines @@ -0,0 +1,2 @@ +# fss-0000 + diff --git a/level_2/fll_error/data/build/dependencies b/level_2/fll_error/data/build/dependencies new file mode 100644 index 0000000..6518702 --- /dev/null +++ b/level_2/fll_error/data/build/dependencies @@ -0,0 +1,10 @@ +# fss-0000 + +f_type +f_status +f_memory +f_string +f_utf +f_console +fl_color +fl_string diff --git a/level_2/fll_error/data/build/settings b/level_2/fll_error/data/build/settings new file mode 100644 index 0000000..c71ae99 --- /dev/null +++ b/level_2/fll_error/data/build/settings @@ -0,0 +1,54 @@ +# fss-0001 + +project_name fll_error + +version_major 0 +version_minor 5 +version_micro 1 +version_target major + +environment + +process_pre +process_post + +modes individual +modes_default individual + +build_compiler gcc +build_indexer ar +build_language c +build_libraries -lc +build_libraries-individual -lfl_string -lfl_color -lf_print -lf_file -lf_console -lf_utf -lf_memory +build_sources_library error.c private-error.c +build_sources_program +build_sources_headers error.h error-common.h +build_sources_script +build_sources_setting +build_script yes +build_shared yes +build_static yes + +path_headers level_2 +path_library_script script +path_library_shared shared +path_library_static static +path_program_script script +path_program_shared shared +path_program_static static +path_sources +path_standard yes + +search_exclusive yes +search_shared yes +search_static yes + +defines_all +defines_static +defines_shared + +flags_all -z now -g -fdiagnostics-color=always +flags_shared +flags_static +flags_library -fPIC +flags_program -fPIE diff --git a/level_2/fll_file/c/file.c b/level_2/fll_file/c/file.c index e99cedb..8b55322 100644 --- a/level_2/fll_file/c/file.c +++ b/level_2/fll_file/c/file.c @@ -9,52 +9,62 @@ extern "C" { f_return_status fll_file_error_print(FILE *file, const f_color_context_t context, const f_string_t function_name, const f_string_t file_name, const f_status_t status) { if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(file, context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print(file, context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fprintf(file, "%c", f_string_eol[0]); } else if (status == F_file_closed) { fl_color_print(file, context.set.error, "INTERNAL ERROR: The file '"); fl_color_print(file, context.set.notable, "%s", file_name); - fl_color_print_line(file, context.set.error, "' is no longer open."); + fl_color_print(file, context.set.error, "' is no longer open."); + fprintf(file, "%c", f_string_eol[0]); } else if (status == F_file_seek) { fl_color_print(file, context.set.error, "ERROR: A seek error occurred while accessing the file '"); fl_color_print(file, context.set.notable, "%s", file_name); - fl_color_print_line(file, context.set.error, "'."); + fl_color_print(file, context.set.error, "'."); + fprintf(file, "%c", f_string_eol[0]); } else if (status == F_file_read) { fl_color_print(file, context.set.error, "ERROR: A read error occurred while accessing the file '"); fl_color_print(file, context.set.notable, "%s", file_name); - fl_color_print_line(file, context.set.error, "'."); + fl_color_print(file, context.set.error, "'."); + fprintf(file, "%c", f_string_eol[0]); } else if (status == F_file_found_not) { fl_color_print(file, context.set.error, "ERROR: Unable to find the file '"); fl_color_print(file, context.set.notable, "%s", file_name); - fl_color_print_line(file, context.set.error, "'."); + fl_color_print(file, context.set.error, "'."); + fprintf(file, "%c", f_string_eol[0]); } else if (status == F_file_open) { fl_color_print(file, context.set.error, "ERROR: Unable to open the file '"); fl_color_print(file, context.set.notable, "%s", file_name); - fl_color_print_line(file, context.set.error, "'."); + fl_color_print(file, context.set.error, "'."); + fprintf(file, "%c", f_string_eol[0]); } else if (status == F_file_descriptor) { fl_color_print(file, context.set.error, "ERROR: File descriptor error while trying to open the file '"); fl_color_print(file, context.set.notable, "%s", file_name); - fl_color_print_line(file, context.set.error, "'."); + fl_color_print(file, context.set.error, "'."); + fprintf(file, "%c", f_string_eol[0]); } else if (status == F_parameter) { fl_color_print(file, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); fl_color_print(file, context.set.notable, "%s()", function_name); - fl_color_print_line(file, context.set.error, "."); + fl_color_print(file, context.set.error, "."); + fprintf(file, "%c", f_string_eol[0]); } else if (status == F_number_overflow) { fl_color_print(file, context.set.error, "ERROR: Integer overflow while trying to buffer the file '"); fl_color_print(file, context.set.notable, "%s", file_name); - fl_color_print_line(file, context.set.error, "'."); + fl_color_print(file, context.set.error, "'."); + fprintf(file, "%c", f_string_eol[0]); } else if (status == F_number_underflow) { fl_color_print(file, context.set.error, "ERROR: Integer underflow while trying to buffer the file '"); fl_color_print(file, context.set.notable, "%s", file_name); - fl_color_print_line(file, context.set.error, "'."); + fl_color_print(file, context.set.error, "'."); + fprintf(file, "%c", f_string_eol[0]); } else { return F_false; diff --git a/level_2/fll_fss/c/fss.c b/level_2/fll_fss/c/fss.c index 9a1ff00..48881f8 100644 --- a/level_2/fll_fss/c/fss.c +++ b/level_2/fll_fss/c/fss.c @@ -27,6 +27,7 @@ extern "C" { { f_string_length_t seeked = 0; + if (F_status_is_error(f_file_seek(file->id, SEEK_SET, 0, &seeked))) { return F_status_set_error(F_file_seek); } diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index 0746067..1cb0482 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -5,108 +5,93 @@ extern "C" { #endif #ifndef _di_fll_program_print_help_header_ - f_return_status fll_program_print_help_header(const f_color_context_t context, const f_string_t name, const f_string_t version) { - f_status_t status = F_none; + f_return_status fll_program_print_help_header(const int id, const f_color_context_t context, const f_string_t name, const f_string_t version) { - printf("%c", f_string_eol[0]); - status = fl_color_print(f_type_output, context.set.title, " %s", name); - if (F_status_is_error(status)) return status; + dprintf(id, "%c", f_string_eol[0]); + fl_color_print_to(id, context.set.title, " %s", name); - printf("%c", f_string_eol[0]); - status = fl_color_print(f_type_output, context.set.notable, " Version %s", version); - if (F_status_is_error(status)) return status; + dprintf(id, "%c", f_string_eol[0]); + fl_color_print_to(id, context.set.notable, " Version %s", version); - printf("%c%c", f_string_eol[0], f_string_eol[0]); - status = fl_color_print(f_type_output, context.set.important, " Available Options: "); - if (F_status_is_error(status)) return status; + dprintf(id, "%c%c", f_string_eol[0], f_string_eol[0]); + fl_color_print_to(id, context.set.important, " Available Options: "); return F_none; } #endif // _di_fll_program_print_help_header_ #ifndef _di_fll_program_print_help_option_ - f_return_status fll_program_print_help_option(const f_color_context_t context, const f_string_t option_short, const f_string_t option_long, const f_string_t symbol_short, const f_string_t symbol_long, const f_string_t description) { - f_status_t status = F_none; + f_return_status fll_program_print_help_option(const int id, const f_color_context_t context, const f_string_t option_short, const f_string_t option_long, const f_string_t symbol_short, const f_string_t symbol_long, const f_string_t description) { - printf("%c", f_string_eol[0]); - printf(" %s", symbol_short); - status = fl_color_print(f_type_output, context.set.standout, option_short); - if (F_status_is_error(status)) return status; + dprintf(id, "%c %s", f_string_eol[0], symbol_short); + fl_color_print_to(id, context.set.standout, option_short); - printf(", %s", symbol_long); - status = fl_color_print(f_type_output, context.set.standout, option_long); - if (F_status_is_error(status)) return status; + dprintf(id, ", %s", symbol_long); + fl_color_print_to(id, context.set.standout, option_long); - printf(" %s", description); + dprintf(id, " %s", description); return F_none; } #endif // _di_fll_program_print_help_option_ #ifndef _di_fll_program_print_help_option_long_ - f_return_status fll_program_print_help_option_long(const f_color_context_t context, const f_string_t option_long, const f_string_t symbol_long, const f_string_t description) { - f_status_t status = F_none; + f_return_status fll_program_print_help_option_long(const int id, const f_color_context_t context, const f_string_t option_long, const f_string_t symbol_long, const f_string_t description) { - printf("%c", f_string_eol[0]); - printf(" %s", symbol_long); - status = fl_color_print(f_type_output, context.set.standout, option_long); - if (F_status_is_error(status)) return status; + dprintf(id, "%c %s", f_string_eol[0], symbol_long); + fl_color_print_to(id, context.set.standout, option_long); - printf(" %s", description); + dprintf(id, " %s", description); return F_none; } #endif // _di_fll_program_print_help_option_long_ #ifndef _di_fll_program_print_help_option_other_ - f_return_status fll_program_print_help_option_other(const f_color_context_t context, const f_string_t option_other, const f_string_t description) { + f_return_status fll_program_print_help_option_other(const int id, const f_color_context_t context, const f_string_t option_other, const f_string_t description) { - printf("%c ", f_string_eol[0]); - fl_color_print(f_type_output, context.set.standout, option_other); + dprintf(id, "%c ", f_string_eol[0]); + fl_color_print_to(id, context.set.standout, option_other); - printf(" %s", description); + dprintf(id, " %s", description); return F_none; } #endif // _di_fll_program_print_help_option_other_ #ifndef _di_fll_program_print_help_usage_ - f_return_status fll_program_print_help_usage(const f_color_context_t context, const f_string_t name, const f_string_t parameters) { - f_status_t status = F_none; + f_return_status fll_program_print_help_usage(const int id, const f_color_context_t context, const f_string_t name, const f_string_t parameters) { - printf("%c%c", f_string_eol[0], f_string_eol[0]); - status = fl_color_print(f_type_output, context.set.important, " Usage:"); - if (F_status_is_error(status)) return status; + dprintf(id, "%c%c", f_string_eol[0], f_string_eol[0]); + fl_color_print_to(id, context.set.important, " Usage:"); - printf("%c ", f_string_eol[0]); - status = fl_color_print(f_type_output, context.set.standout, name); - if (F_status_is_error(status)) return status; + dprintf(id, "%c ", f_string_eol[0]); + fl_color_print_to(id, context.set.standout, name); - printf(" "); - status = fl_color_print(f_type_output, context.set.notable, "["); - if (F_status_is_error(status)) return status; + dprintf(id, " "); + fl_color_print_to(id, context.set.notable, "["); - printf(" options "); - status = fl_color_print(f_type_output, context.set.notable, "]"); - if (F_status_is_error(status)) return status; + dprintf(id, " options "); + fl_color_print_to(id, context.set.notable, "]"); if (parameters[0] != '\0') { - printf(" "); - status = fl_color_print(f_type_output, context.set.notable, "["); - if (F_status_is_error(status)) return status; + dprintf(id, " "); + fl_color_print_to(id, context.set.notable, "["); - printf(" %s ", parameters); - status = fl_color_print(f_type_output, context.set.notable, "]"); - if (F_status_is_error(status)) return status; + dprintf(id, " %s ", parameters); + fl_color_print_to(id, context.set.notable, "]"); } - printf("%c%c", f_string_eol[0], f_string_eol[0]); + dprintf(id, "%c%c", f_string_eol[0], f_string_eol[0]); + + return F_none; } #endif // _di_fll_program_print_help_usage_ #ifndef _di_fll_program_print_version_ - f_return_status fll_program_print_version(const f_string_t version) { - printf("%s%c", version, f_string_eol[0]); + f_return_status fll_program_print_version(const int id, const f_string_t version) { + + dprintf(id, "%s%c", version, f_string_eol[0]); return F_none; } @@ -117,92 +102,25 @@ extern "C" { f_status_t status = F_none; status = f_console_parameter_process(arguments, parameters, remaining); - - if (F_status_is_error(status)) { - status = F_status_set_fine(status); - - if (status == F_data_not) { - fl_color_print_line(f_type_error, context->set.error, "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 (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(f_type_error, context->set.error, "CRITICAL ERROR: Unable to allocate memory while calling "); - fl_color_print(f_type_error, context->set.notable, "f_console_parameter_process"); - fl_color_print_line(f_type_error, context->set.error, ")."); - } - else if (status == F_utf) { - fl_color_print(f_type_error, context->set.error, "ENCODING ERROR: Invalid UTF-8 character in parameter when calling "); - fl_color_print(f_type_error, context->set.notable, "f_console_parameter_process()"); - fl_color_print_line(f_type_error, context->set.error, "."); - } - else if (status == F_parameter) { - fl_color_print(f_type_error, context->set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, context->set.notable, "f_console_parameter_process()"); - fl_color_print_line(f_type_error, context->set.error, "."); - } - else { - fl_color_print(f_type_error, context->set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context->set.notable, "%u", status); - fl_color_print(f_type_error, context->set.error, ") has occurred while calling "); - fl_color_print(f_type_error, context->set.notable, "f_console_parameter_process()"); - fl_color_print_line(f_type_error, context->set.error, "."); - } - - return F_status_set_error(status); - } + if (F_status_is_error(status)) return status; f_console_parameter_id_t decision = choices.id[2]; - f_string_t function; - if (right) { - function = "f_console_parameter_prioritize_right"; status = f_console_parameter_prioritize_right(parameters, choices, &decision); } else { - function = "f_console_parameter_prioritize_left"; status = f_console_parameter_prioritize_left(parameters, choices, &decision); } - if (F_status_is_error(status)) { - status = F_status_set_fine(status); - - if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(f_type_error, context->set.error, "CRITICAL ERROR: Unable to allocate memory while calling "); - fl_color_print(f_type_error, context->set.notable, "%s", function); - fl_color_print_line(f_type_error, context->set.error, ")."); - } - else if (status == F_parameter) { - fl_color_print(f_type_error, context->set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, context->set.notable, "%s", function); - fl_color_print_line(f_type_error, context->set.error, "()."); - } - else { - fl_color_print(f_type_error, context->set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context->set.notable, "%u", status); - fl_color_print(f_type_error, context->set.error, ") has occurred while calling "); - fl_color_print(f_type_error, context->set.notable, "%s", function); - fl_color_print_line(f_type_error, context->set.error, "()."); - } - - return F_status_set_error(status); - } + if (F_status_is_error(status)) return status; // load colors unless told not to. if (decision != choices.id[0]) { f_status_t allocation_status = F_none; f_macro_color_context_t_new(allocation_status, (*context)); - - if (F_status_is_error(allocation_status)) { - fl_color_print(f_type_error, context->set.error, "CRITICAL ERROR: Unable to allocate memory while calling "); - fl_color_print(f_type_error, context->set.notable, "f_macro_color_context_t_new"); - fl_color_print_line(f_type_error, context->set.error, "()."); - - return allocation_status; - } + if (F_status_is_error(status)) return status; status = fl_color_load_context(context, decision == choices.id[1]); } @@ -214,39 +132,6 @@ extern "C" { } #endif // _di_fll_program_parameter_process_ -#ifndef _di_fll_program_parameter_process_quietly_ - f_return_status fll_program_parameter_process_quietly(const f_console_arguments_t arguments, f_console_parameters_t parameters, const f_console_parameter_ids_t choices, const bool right, f_string_lengths_t *remaining, f_color_context_t *context) { - f_status_t status = F_none; - - status = f_console_parameter_process(arguments, parameters, remaining); - if (F_status_is_error(status)) return status; - - f_console_parameter_id_t decision = choices.id[2]; - - if (right) { - status = f_console_parameter_prioritize_right(parameters, choices, &decision); - } - else { - status = f_console_parameter_prioritize_left(parameters, choices, &decision); - } - - if (F_status_is_error(status)) return status; - - // load colors unless told not to. - if (decision != choices.id[0]) { - f_status_t allocation_status = F_none; - - f_macro_color_context_t_new(allocation_status, (*context)); - - if (F_status_is_error(allocation_status)) return allocation_status; - - status = fl_color_load_context(context, decision == choices.id[1]); - } - - return status; - } -#endif // _di_fll_program_parameter_process_quietly_ - #ifndef _di_fll_program_parameter_additional_append_ f_return_status fll_program_parameter_additional_append(const f_string_t *argv, const f_string_lengths_t additional, f_string_dynamics_t *destination) { #ifndef _di_level_2_parameter_checking_ diff --git a/level_2/fll_program/c/program.h b/level_2/fll_program/c/program.h index b2a36f4..8495d34 100644 --- a/level_2/fll_program/c/program.h +++ b/level_2/fll_program/c/program.h @@ -7,8 +7,8 @@ * * Provide functions commonly used by FLL based programs. */ -#ifndef _FL_program_h -#define _FL_program_h +#ifndef _FLL_program_h +#define _FLL_program_h // libc include #include @@ -32,6 +32,8 @@ extern "C" { /** * Print standard help header. * + * @param id + * The file descriptor to output to. * @param context * The color context. * @param name @@ -47,12 +49,14 @@ extern "C" { * @param fl_color_print() */ #ifndef _di_fll_program_print_help_header_ - extern f_return_status fll_program_print_help_header(const f_color_context_t context, const f_string_t name, const f_string_t version); + extern f_return_status fll_program_print_help_header(const int id, const f_color_context_t context, const f_string_t name, const f_string_t version); #endif // _di_fll_program_print_help_header_ /** * Print standard help option. * + * @param id + * The file descriptor to output to. * @param context * The color context. * @param option_short @@ -74,12 +78,14 @@ extern "C" { * @param fl_color_print() */ #ifndef _di_fll_program_print_help_option_ - extern f_return_status fll_program_print_help_option(const f_color_context_t context, const f_string_t option_short, const f_string_t option_long, const f_string_t symbol_short, const f_string_t symbol_long, const f_string_t description); + extern f_return_status fll_program_print_help_option(const int id, const f_color_context_t context, const f_string_t option_short, const f_string_t option_long, const f_string_t symbol_short, const f_string_t symbol_long, const f_string_t description); #endif // _di_fll_program_print_help_option_ /** * Print standard help option (long option only). * + * @param id + * The file descriptor to output to. * @param context * The color context. * @param option_long @@ -97,12 +103,14 @@ extern "C" { * @param fl_color_print() */ #ifndef _di_fll_program_print_help_option_long_ - extern f_return_status fll_program_print_help_option_long(const f_color_context_t context, const f_string_t option_long, const f_string_t symbol_long, const f_string_t description); + extern f_return_status fll_program_print_help_option_long(const int id, const f_color_context_t context, const f_string_t option_long, const f_string_t symbol_long, const f_string_t description); #endif // _di_fll_program_print_help_option_long_ /** * Print standard help option (other option only). * + * @param id + * The file descriptor to output to. * @param context * The color context. * @param option_other @@ -118,12 +126,14 @@ extern "C" { * @param fl_color_print() */ #ifndef _di_fll_program_print_help_option_other_ - extern f_return_status fll_program_print_help_option_other(const f_color_context_t context, const f_string_t option_other, const f_string_t description); + extern f_return_status fll_program_print_help_option_other(const int id, const f_color_context_t context, const f_string_t option_other, const f_string_t description); #endif // _di_fll_program_print_help_option_other_ /** * Print standard help usage. * + * @param id + * The file descriptor to output to. * @param context * The color context. * @param name @@ -140,12 +150,14 @@ extern "C" { * @param fl_color_print() */ #ifndef _di_fll_program_print_help_usage_ - extern f_return_status fll_program_print_help_usage(const f_color_context_t context, const f_string_t name, const f_string_t parameters); + extern f_return_status fll_program_print_help_usage(const int id, const f_color_context_t context, const f_string_t name, const f_string_t parameters); #endif // _di_fll_program_print_help_usage_ /** * Print the program version. * + * @param id + * The file descriptor to output to. * @param version * The version number of the program. * @@ -153,11 +165,11 @@ extern "C" { * F_none on success. */ #ifndef _di_fll_program_print_version_ - extern f_return_status fll_program_print_version(const f_string_t version); + extern f_return_status fll_program_print_version(const int id, const f_string_t version); #endif // _di_fll_program_print_version_ /** - * Perform basic parameter loading, including initialization of color context and printing errors. + * Perform basic parameter loading, including initialization of color context. * * @param arguments * The parameters passed to the process. @@ -192,42 +204,6 @@ extern "C" { #ifndef _di_fll_program_parameter_process_ extern f_return_status fll_program_parameter_process(const f_console_arguments_t arguments, f_console_parameters_t parameters, const f_console_parameter_ids_t choices, const bool right, f_string_lengths_t *remaining, f_color_context_t *context); #endif // _di_fll_program_parameter_process_ -/** - * Perform basic parameter loading, including initialization of color context but does not print errors. - * - * @param arguments - * The parameters passed to the process. - * @param parameters - * The console parameters to look for. - * @param choices - * A set of the color options: no-color option, light-color option, dark-color option. - * This must have its used size set to 3 and the ids are expected to be in this order: no_color, light, and dark. - * @param right - * Set to TRUE for right priortization and FALSE for left prioritization. - * @param remaining - * A list of remaining parameters not associated with anything. - * @param context - * The color context. - * - * @return - * F_none on success. - * F_data_not if "additional" parameters were expected but not found. - * F_memory_reallocation (with error bit) on memory reallocation error. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_console_parameter_prioritize_left(). - * Errors (with error bit) from: f_console_parameter_prioritize_right(). - * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: fl_color_load_context(). - * - * @see f_console_parameter_prioritize_left() - * @see f_console_parameter_prioritize_right() - * @see f_console_parameter_process() - * @see fl_color_load_context() - */ -#ifndef _di_fll_program_parameter_process_quietly_ - extern f_return_status fll_program_parameter_process_quietly(const f_console_arguments_t arguments, f_console_parameters_t parameters, const f_console_parameter_ids_t choices, const bool right, f_string_lengths_t *remaining, f_color_context_t *context); -#endif // _di_fll_program_parameter_process_quietly_ /** * Allocate new strings from all of the provided locations. @@ -354,4 +330,4 @@ extern "C" { } // extern "C" #endif -#endif // _FL_program_h +#endif // _FLL_program_h diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index 79d7791..4d5a2ea 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -6,68 +6,70 @@ extern "C" { #endif #ifndef _di_byte_dump_print_help_ - f_return_status byte_dump_print_help(const f_color_context_t context) { + f_return_status byte_dump_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, byte_dump_name_long, byte_dump_version); + fll_program_print_help_header(id, context, byte_dump_name_long, byte_dump_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); - printf("%c", f_string_eol[0]); + dprintf(id, "%c", f_string_eol[0]); - fll_program_print_help_option(context, byte_dump_short_binary, byte_dump_long_binary, f_console_symbol_short_enable, f_console_symbol_long_enable, " Display binary representation."); - fll_program_print_help_option(context, byte_dump_short_decimal, byte_dump_long_decimal, f_console_symbol_short_enable, f_console_symbol_long_enable, " Display decimal representation."); - fll_program_print_help_option(context, byte_dump_short_duodecimal, byte_dump_long_duodecimal, f_console_symbol_short_enable, f_console_symbol_long_enable, " Display duodecimal representation."); - fll_program_print_help_option(context, byte_dump_short_hexidecimal, byte_dump_long_hexidecimal, f_console_symbol_short_enable, f_console_symbol_long_enable, "Display hexadecimal representation."); - fll_program_print_help_option(context, byte_dump_short_octal, byte_dump_long_octal, f_console_symbol_short_enable, f_console_symbol_long_enable, " Display octal representation."); + fll_program_print_help_option(id, context, byte_dump_short_binary, byte_dump_long_binary, f_console_symbol_short_enable, f_console_symbol_long_enable, " Display binary representation."); + fll_program_print_help_option(id, context, byte_dump_short_decimal, byte_dump_long_decimal, f_console_symbol_short_enable, f_console_symbol_long_enable, " Display decimal representation."); + fll_program_print_help_option(id, context, byte_dump_short_duodecimal, byte_dump_long_duodecimal, f_console_symbol_short_enable, f_console_symbol_long_enable, " Display duodecimal representation."); + fll_program_print_help_option(id, context, byte_dump_short_hexidecimal, byte_dump_long_hexidecimal, f_console_symbol_short_enable, f_console_symbol_long_enable, "Display hexadecimal representation."); + fll_program_print_help_option(id, context, byte_dump_short_octal, byte_dump_long_octal, f_console_symbol_short_enable, f_console_symbol_long_enable, " Display octal representation."); - printf("%c", f_string_eol[0]); + dprintf(id, "%c", f_string_eol[0]); - fll_program_print_help_option(context, byte_dump_short_first, byte_dump_long_first, f_console_symbol_short_enable, f_console_symbol_long_enable, " Start reading at this byte offset."); - fll_program_print_help_option(context, byte_dump_short_last, byte_dump_long_last, f_console_symbol_short_enable, f_console_symbol_long_enable, " Stop reading at this (inclusive) byte offset."); - fll_program_print_help_option(context, byte_dump_short_width, byte_dump_long_width, f_console_symbol_short_enable, f_console_symbol_long_enable, " Set number of columns of Bytes to display."); + fll_program_print_help_option(id, context, byte_dump_short_first, byte_dump_long_first, f_console_symbol_short_enable, f_console_symbol_long_enable, " Start reading at this byte offset."); + fll_program_print_help_option(id, context, byte_dump_short_last, byte_dump_long_last, f_console_symbol_short_enable, f_console_symbol_long_enable, " Stop reading at this (inclusive) byte offset."); + fll_program_print_help_option(id, context, byte_dump_short_width, byte_dump_long_width, f_console_symbol_short_enable, f_console_symbol_long_enable, " Set number of columns of Bytes to display."); - printf("%c", f_string_eol[0]); + dprintf(id, "%c", f_string_eol[0]); - fll_program_print_help_option(context, byte_dump_short_text, byte_dump_long_text, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include a column of text when displaying the bytes."); - fll_program_print_help_option(context, byte_dump_short_placeholder, byte_dump_long_placeholder, f_console_symbol_short_enable, f_console_symbol_long_enable, "Use a placeholder character instead of a space for placeholders."); + fll_program_print_help_option(id, context, byte_dump_short_text, byte_dump_long_text, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include a column of text when displaying the bytes."); + fll_program_print_help_option(id, context, byte_dump_short_placeholder, byte_dump_long_placeholder, f_console_symbol_short_enable, f_console_symbol_long_enable, "Use a placeholder character instead of a space for placeholders."); - printf("%c", f_string_eol[0]); + dprintf(id, "%c%c", f_string_eol[0], f_string_eol[0]); - fll_program_print_help_option_long(context, byte_dump_long_normal, f_console_symbol_long_enable, " Display UTF-8 symbols for ASCII control codes."); - fll_program_print_help_option_long(context, byte_dump_long_simple, f_console_symbol_long_enable, " Display spaces for ASCII control codes."); - fll_program_print_help_option_long(context, byte_dump_long_classic, f_console_symbol_long_enable, " Display periods for ASCII control codes."); + fl_color_print_to(id, context.set.important, " Special Options: "); - fll_program_print_help_usage(context, byte_dump_name, "filename(s)"); + fll_program_print_help_option_long(id, context, byte_dump_long_normal, f_console_symbol_long_enable, " Display UTF-8 symbols for ASCII control codes."); + fll_program_print_help_option_long(id, context, byte_dump_long_simple, f_console_symbol_long_enable, " Display spaces for ASCII control codes."); + fll_program_print_help_option_long(id, context, byte_dump_long_classic, f_console_symbol_long_enable, "Display periods for ASCII control codes."); - printf(" When using the "); - fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_text); - printf(" option, some UTF-8 characters may be replaced by your instance and cause display alignment issues."); + fll_program_print_help_usage(id, context, byte_dump_name, "filename(s)"); - printf("%c%c", f_string_eol[0], f_string_eol[0]); + dprintf(id, " When using the "); + fl_color_print_to(id, context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_text); + dprintf(id, " option, some UTF-8 characters may be replaced by your instance and cause display alignment issues."); - printf(" Special UTF-8 characters and non-spacing UTF-8 characters may be replaced with a space (or a placeholder when the "); - fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_placeholder); - printf(" option is used)."); + dprintf(id, "%c%c", f_string_eol[0], f_string_eol[0]); - printf("%c%c", f_string_eol[0], f_string_eol[0]); + dprintf(id, " Special UTF-8 characters and non-spacing UTF-8 characters may be replaced with a space (or a placeholder when the "); + fl_color_print_to(id, context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_placeholder); + dprintf(id, " option is used)."); - printf(" UTF-8 \"Combining\" characters might have a space appended to allow a proper display but this may cause copy and paste issues."); + dprintf(id, "%c%c", f_string_eol[0], f_string_eol[0]); - printf("%c%c", f_string_eol[0], f_string_eol[0]); + dprintf(id, " UTF-8 \"Combining\" characters might have a space appended to allow a proper display but this may cause copy and paste issues."); - printf(" When "); - fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); - printf(" is used, any UTF-8 sequences will still be printed in full should any part is found within the requested range."); + dprintf(id, "%c%c", f_string_eol[0], f_string_eol[0]); - printf("%c%c", f_string_eol[0], f_string_eol[0]); + dprintf(id, " When "); + fl_color_print_to(id, context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); + dprintf(id, " is used, any UTF-8 sequences will still be printed in full should any part is found within the requested range."); + + dprintf(id, "%c%c", f_string_eol[0], f_string_eol[0]); return F_none; } @@ -88,11 +90,11 @@ extern "C" { status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); if (F_status_is_error(status)) { + fll_error_parameter_print(data->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true); + byte_dump_delete_data(data); return F_status_set_error(status); } - - status = F_none; } // Identify priority of verbosity related parameters. @@ -109,16 +111,16 @@ extern "C" { } if (choice == byte_dump_parameter_verbosity_quiet) { - data->verbosity = f_console_verbosity_quiet; + data->error.verbosity = f_console_verbosity_quiet; } else if (choice == byte_dump_parameter_verbosity_normal) { - data->verbosity = f_console_verbosity_normal; + data->error.verbosity = f_console_verbosity_normal; } else if (choice == byte_dump_parameter_verbosity_verbose) { - data->verbosity = f_console_verbosity_verbose; + data->error.verbosity = f_console_verbosity_verbose; } else if (choice == byte_dump_parameter_verbosity_debug) { - data->verbosity = f_console_verbosity_debug; + data->error.verbosity = f_console_verbosity_debug; } } @@ -131,6 +133,8 @@ extern "C" { status = f_console_parameter_prioritize_right(parameters, choices, &choice); if (F_status_is_error(status)) { + fll_error_print(data->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true); + byte_dump_delete_data(data); return F_status_set_error(status); } @@ -180,14 +184,14 @@ extern "C" { } if (data->parameters[byte_dump_parameter_help].result == f_console_result_found) { - byte_dump_print_help(data->context); + byte_dump_print_help(data->output, data->context); byte_dump_delete_data(data); return F_none; } if (data->parameters[byte_dump_parameter_version].result == f_console_result_found) { - fll_program_print_version(byte_dump_version); + fll_program_print_version(data->output, byte_dump_version); byte_dump_delete_data(data); return F_none; @@ -195,9 +199,9 @@ extern "C" { if (data->remaining.used > 0 || data->process_pipe) { if (data->parameters[byte_dump_parameter_width].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_width); - fl_color_print_line(f_type_error, data->context.set.error, "' was specified, but no value was given."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_width); + fl_color_print_to(data->error.to, data->context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); byte_dump_delete_data(data); return F_status_set_error(status); @@ -211,13 +215,13 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range); if (F_status_is_error(status) || number < 1 || number >= 0xfb) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_width); - fl_color_print(f_type_error, data->context.set.error, "' value can only be a number between "); - fl_color_print(f_type_error, data->context.set.notable, "0"); - fl_color_print(f_type_error, data->context.set.error, " and "); - fl_color_print(f_type_error, data->context.set.notable, "251"); - fl_color_print_line(f_type_error, data->context.set.error, "."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_width); + fl_color_print_to(data->error.to, data->context.set.error, "' value can only be a number between "); + fl_color_print_to(data->error.to, data->context.set.notable, "0"); + fl_color_print_to(data->error.to, data->context.set.error, " and "); + fl_color_print_to(data->error.to, data->context.set.notable, "251"); + fl_color_print_to(data->error.to, data->context.set.error, ".%c", f_string_eol[0]); byte_dump_delete_data(data); return F_status_set_error(status); @@ -227,9 +231,9 @@ extern "C" { } if (data->parameters[byte_dump_parameter_first].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); - fl_color_print_line(f_type_error, data->context.set.error, "' was specified, but no value was given."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); + fl_color_print_to(data->error.to, data->context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); byte_dump_delete_data(data); return F_status_set_error(status); @@ -243,13 +247,13 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range); if (F_status_is_error(status) || number > f_number_t_size_unsigned) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); - fl_color_print(f_type_error, data->context.set.error, "' value can only be a number (inclusively) between "); - fl_color_print(f_type_error, data->context.set.notable, "0"); - fl_color_print(f_type_error, data->context.set.error, " and "); - fl_color_print(f_type_error, data->context.set.notable, "%llu", f_number_t_size_unsigned); - fl_color_print_line(f_type_error, data->context.set.error, "."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); + fl_color_print_to(data->error.to, data->context.set.error, "' value can only be a number (inclusively) between "); + fl_color_print_to(data->error.to, data->context.set.notable, "0"); + fl_color_print_to(data->error.to, data->context.set.error, " and "); + fl_color_print_to(data->error.to, data->context.set.notable, "%llu", f_number_t_size_unsigned); + fl_color_print_to(data->error.to, data->context.set.error, ".%c", f_string_eol[0]); byte_dump_delete_data(data); return F_status_set_error(status); @@ -259,9 +263,9 @@ extern "C" { } if (data->parameters[byte_dump_parameter_last].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); - fl_color_print_line(f_type_error, data->context.set.error, "' was specified, but no value was given."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); + fl_color_print_to(data->error.to, data->context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); byte_dump_delete_data(data); return F_status_set_error(status); @@ -275,13 +279,13 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range); if (F_status_is_error(status) || number < 0 || number > f_number_t_size_unsigned) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); - fl_color_print(f_type_error, data->context.set.error, "' value can only be a number (inclusively) between "); - fl_color_print(f_type_error, data->context.set.notable, "0"); - fl_color_print(f_type_error, data->context.set.error, " and "); - fl_color_print(f_type_error, data->context.set.notable, "%llu", f_number_t_size_unsigned); - fl_color_print_line(f_type_error, data->context.set.error, "."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); + fl_color_print_to(data->error.to, data->context.set.error, "' value can only be a number (inclusively) between "); + fl_color_print_to(data->error.to, data->context.set.notable, "0"); + fl_color_print_to(data->error.to, data->context.set.error, " and "); + fl_color_print_to(data->error.to, data->context.set.notable, "%llu", f_number_t_size_unsigned); + fl_color_print_to(data->error.to, data->context.set.error, ".%c", f_string_eol[0]); byte_dump_delete_data(data); return F_status_set_error(status); @@ -292,11 +296,11 @@ extern "C" { if (data->parameters[byte_dump_parameter_first].result == f_console_result_additional && data->parameters[byte_dump_parameter_last].result == f_console_result_additional) { if (data->first > data->last) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); - fl_color_print(f_type_error, data->context.set.error, "' value cannot be greater than the parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); - fl_color_print_line(f_type_error, data->context.set.error, "' value."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); + fl_color_print_to(data->error.to, data->context.set.error, "' value cannot be greater than the parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); + fl_color_print_to(data->error.to, data->context.set.error, "' value.%c", f_string_eol[0]); byte_dump_delete_data(data); return F_status_set_error(status); @@ -312,25 +316,25 @@ extern "C" { file.id = f_type_descriptor_input; printf("%c", f_string_eol[0]); - fl_color_print(f_type_output, data->context.set.title, "Piped Byte Dump: (in "); + fl_color_print_to(data->output, data->context.set.title, "Piped Byte Dump: (in "); if (data->mode == byte_dump_mode_hexidecimal) { - fl_color_print(f_type_output, data->context.set.title, "Hexidecimal"); + fl_color_print_to(data->output, data->context.set.title, "Hexidecimal"); } else if (data->mode == byte_dump_mode_duodecimal) { - fl_color_print(f_type_output, data->context.set.title, "Duodecimal"); + fl_color_print_to(data->output, data->context.set.title, "Duodecimal"); } else if (data->mode == byte_dump_mode_octal) { - fl_color_print(f_type_output, data->context.set.title, "Octal"); + fl_color_print_to(data->output, data->context.set.title, "Octal"); } else if (data->mode == byte_dump_mode_binary) { - fl_color_print(f_type_output, data->context.set.title, "Binary"); + fl_color_print_to(data->output, data->context.set.title, "Binary"); } else if (data->mode == byte_dump_mode_decimal) { - fl_color_print(f_type_output, data->context.set.title, "Decimal"); + fl_color_print_to(data->output, data->context.set.title, "Decimal"); } - fl_color_print_line(f_type_output, data->context.set.title, ")"); + fl_color_print_to(data->output, data->context.set.title, ")%c", f_string_eol[0]); status = byte_dump_file(*data, "-", file); @@ -354,7 +358,7 @@ extern "C" { missing_files = status; } - byte_dump_print_file_error(data->context, "f_file_exists", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_exists", F_true, arguments.argv[data->remaining.array[counter]], "find", fll_error_file_type_file); } } // for @@ -372,33 +376,34 @@ extern "C" { status = f_file_open(arguments.argv[data->remaining.array[counter]], 0, &file); if (F_status_is_error(status)) { - byte_dump_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_open", F_true, arguments.argv[data->remaining.array[counter]], "open", fll_error_file_type_file); + byte_dump_delete_data(data); return status; } printf("%c", f_string_eol[0]); - fl_color_print(f_type_output, data->context.set.title, "Byte Dump of: "); - fl_color_print(f_type_output, data->context.set.notable, "%s", arguments.argv[data->remaining.array[counter]]); - fl_color_print(f_type_output, data->context.set.title, " (in "); + fl_color_print_to(data->output, data->context.set.title, "Byte Dump of: "); + fl_color_print_to(data->output, data->context.set.notable, "%s", arguments.argv[data->remaining.array[counter]]); + fl_color_print_to(data->output, data->context.set.title, " (in "); if (data->mode == byte_dump_mode_hexidecimal) { - fl_color_print(f_type_output, data->context.set.title, "Hexidecimal"); + fl_color_print_to(data->output, data->context.set.title, "Hexidecimal"); } else if (data->mode == byte_dump_mode_duodecimal) { - fl_color_print(f_type_output, data->context.set.title, "Duodecimal"); + fl_color_print_to(data->output, data->context.set.title, "Duodecimal"); } else if (data->mode == byte_dump_mode_octal) { - fl_color_print(f_type_output, data->context.set.title, "Octal"); + fl_color_print_to(data->output, data->context.set.title, "Octal"); } else if (data->mode == byte_dump_mode_binary) { - fl_color_print(f_type_output, data->context.set.title, "Binary"); + fl_color_print_to(data->output, data->context.set.title, "Binary"); } else if (data->mode == byte_dump_mode_decimal) { - fl_color_print(f_type_output, data->context.set.title, "Decimal"); + fl_color_print_to(data->output, data->context.set.title, "Decimal"); } - fl_color_print_line(f_type_output, data->context.set.title, ")"); + fl_color_print_to(data->output, data->context.set.title, ")%c", f_string_eol[0]); status = byte_dump_file(*data, arguments.argv[data->remaining.array[counter]], file); @@ -415,7 +420,7 @@ extern "C" { } } else { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: You failed to specify one or more filenames."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: You failed to specify one or more filenames.%c", f_string_eol[0]); status = F_status_set_error(F_parameter); } diff --git a/level_3/byte_dump/c/byte_dump.h b/level_3/byte_dump/c/byte_dump.h index 88617a7..9d9d2d7 100644 --- a/level_3/byte_dump/c/byte_dump.h +++ b/level_3/byte_dump/c/byte_dump.h @@ -40,6 +40,7 @@ #include // fll-2 includes +#include #include #ifdef __cplusplus @@ -213,13 +214,14 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; uint64_t first; uint64_t last; - uint8_t width; - uint8_t mode; - uint8_t presentation; + uint8_t width; + uint8_t mode; + uint8_t presentation; f_color_context_t context; } byte_dump_data_t; @@ -229,7 +231,8 @@ extern "C" { byte_dump_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ 0, \ 0, \ 8, \ @@ -242,6 +245,8 @@ extern "C" { /** * Print help to standard output. * + * @param id + * The file descriptor to print to. * @param context * The color context settings. * @@ -249,7 +254,7 @@ extern "C" { * F_none on success. */ #ifndef _di_byte_dump_print_help_ - extern f_return_status byte_dump_print_help(const f_color_context_t context); + extern f_return_status byte_dump_print_help(const int id, const f_color_context_t context); #endif // _di_byte_dump_print_help_ /** diff --git a/level_3/byte_dump/c/private-byte_dump.c b/level_3/byte_dump/c/private-byte_dump.c index 65f4153..dddccd1 100644 --- a/level_3/byte_dump/c/private-byte_dump.c +++ b/level_3/byte_dump/c/private-byte_dump.c @@ -208,17 +208,17 @@ extern "C" { fflush(f_type_output); if (found_invalid_utf) { - fl_color_print(f_type_error, data.context.set.error, "Invalid UTF-8 codes were detected for file '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", file_name); - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "Invalid UTF-8 codes were detected for file '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", file_name); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); printf("%c", f_string_eol[0]); } if (size < 0) { // @todo: determine what the error from read() is and display it. - fl_color_print(f_type_error, data.context.set.error, "ERROR: read() failed for '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", file_name); - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: read() failed for '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", file_name); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); printf("%c", f_string_eol[0]); status = F_status_set_error(F_failure); } @@ -826,75 +826,6 @@ extern "C" { } #endif // _di_byte_dump_file_ -#ifndef _di_byte_dump_print_file_error_ - void byte_dump_print_file_error(const f_color_context_t context, const f_string_t function, const f_string_t file_name, const f_status_t status) { - - if (status == F_false) { - fl_color_print(f_type_error, context.set.error, "ERROR: Failed to find file '"); - fl_color_print(f_type_error, context.set.notable, "%s", file_name); - fl_color_print_line(f_type_error, context.set.error, "'."); - return; - } - - if (status == F_parameter) { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: Invalid parameter when calling ", function, file_name); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print(f_type_error, context.set.error, "() for the file '"); - fl_color_print(f_type_error, context.set.notable, "%s", file_name); - fl_color_print_line(f_type_error, context.set.error, "'."); - return; - } - - if (status == F_name) { - fl_color_print(f_type_error, context.set.error, "ERROR: Invalid filename '"); - fl_color_print(f_type_error, context.set.notable, "%s", file_name); - fl_color_print_line(f_type_error, context.set.error, "'."); - return; - } - - if (status == F_memory_out) { - fl_color_print(f_type_error, context.set.error, "CRITICAL ERROR: Unable to allocate memory, while trying to access file '"); - fl_color_print(f_type_error, context.set.notable, "%s", file_name); - fl_color_print_line(f_type_error, context.set.error, "'."); - return; - } - - if (status == F_number_overflow) { - fl_color_print(f_type_error, context.set.error, "ERROR: Overflow while trying to access file '"); - fl_color_print(f_type_error, context.set.notable, "%s", file_name); - fl_color_print_line(f_type_error, context.set.error, "'."); - return; - } - - if (status == F_directory) { - fl_color_print(f_type_error, context.set.error, "ERROR: Invalid directory while trying to access file '"); - fl_color_print(f_type_error, context.set.notable, "%s", file_name); - fl_color_print_line(f_type_error, context.set.error, "'."); - return; - } - - if (status == F_access_denied) { - fl_color_print(f_type_error, context.set.error, "ERROR: Access denied while trying to access file '"); - fl_color_print(f_type_error, context.set.notable, "%s", file_name); - fl_color_print_line(f_type_error, context.set.error, "'."); - return; - } - - if (status == F_loop) { - fl_color_print(f_type_error, context.set.error, "ERROR: Loop while trying to access file '"); - fl_color_print(f_type_error, context.set.notable, "%s", file_name); - fl_color_print_line(f_type_error, context.set.error, "'."); - return; - } - - fl_color_print(f_type_error, context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") occurred for file '"); - fl_color_print(f_type_error, context.set.notable, "%s", file_name); - fl_color_print_line(f_type_error, context.set.error, "'."); - } -#endif // _di_byte_dump_print_file_error_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/byte_dump/c/private-byte_dump.h b/level_3/byte_dump/c/private-byte_dump.h index 7ec2643..91657d3 100644 --- a/level_3/byte_dump/c/private-byte_dump.h +++ b/level_3/byte_dump/c/private-byte_dump.h @@ -136,28 +136,6 @@ extern "C" { extern void byte_dump_print_text(const byte_dump_data_t data, const f_utf_string_static_t characters, const uint8_t invalid[], byte_dump_previous_t *previous, uint8_t *offset) f_gcc_attribute_visibility_internal; #endif // _di_byte_dump_print_text_ -/** - * Print error messages related to a file. - * - * @param context - * The color context codes. - * @param status - * The status code. - * @param function - * The name of the function that failed. - * @param file_name - * The name of the file related to the error. - * @param status - * The status code representing the error. - * - * @param - * F_true if error has been printed. - * F_false if error has not been printed. - */ -#ifndef _di_byte_dump_print_file_error_ - extern void byte_dump_print_file_error(const f_color_context_t context, const f_string_t function, const f_string_t file_name, const f_status_t status) f_gcc_attribute_visibility_internal; -#endif // _di_byte_dump_print_file_error_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/byte_dump/data/build/dependencies b/level_3/byte_dump/data/build/dependencies index 1144d6a..5b7965d 100644 --- a/level_3/byte_dump/data/build/dependencies +++ b/level_3/byte_dump/data/build/dependencies @@ -16,4 +16,5 @@ fl_console fl_conversion fl_string fl_utf +fll_error fll_program diff --git a/level_3/byte_dump/data/build/settings b/level_3/byte_dump/data/build/settings index ca74431..70771e3 100644 --- a/level_3/byte_dump/data/build/settings +++ b/level_3/byte_dump/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfl_utf -lfl_string -lfl_conversion -lfl_console -lfl_color -lf_print -lf_pipe -lf_file -lf_conversion -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_error -lfl_utf -lfl_string -lfl_conversion -lfl_console -lfl_color -lf_print -lf_pipe -lf_file -lf_conversion -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library byte_dump.c private-byte_dump.c diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index afaa554..7a5c766 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -11,88 +11,88 @@ extern "C" { #endif #ifndef _di_fake_print_help_ - f_return_status fake_print_help(const f_color_context_t context) { + f_return_status fake_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, fake_name_long, fake_version); + fll_program_print_help_header(id, context, fake_name_long, fake_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); - printf("%c", f_string_eol[0]); + dprintf(id, "%c", f_string_eol[0]); - fll_program_print_help_option(context, fake_short_define, fake_long_define, f_console_symbol_short_enable, f_console_symbol_long_enable, " Override defines from settings file with this define."); - fll_program_print_help_option(context, fake_short_fakefile, fake_long_fakefile, f_console_symbol_short_enable, f_console_symbol_long_enable, "Use this fakefile."); - fll_program_print_help_option(context, fake_short_mode, fake_long_mode, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use this mode when processing the build settings."); - fll_program_print_help_option(context, fake_short_process, fake_long_process, f_console_symbol_short_enable, f_console_symbol_long_enable, " Process name for storing build states."); - fll_program_print_help_option(context, fake_short_settings, fake_long_settings, f_console_symbol_short_enable, f_console_symbol_long_enable, "Use this settings file."); + fll_program_print_help_option(id, context, fake_short_define, fake_long_define, f_console_symbol_short_enable, f_console_symbol_long_enable, " Override defines from settings file with this define."); + fll_program_print_help_option(id, context, fake_short_fakefile, fake_long_fakefile, f_console_symbol_short_enable, f_console_symbol_long_enable, "Use this fakefile."); + fll_program_print_help_option(id, context, fake_short_mode, fake_long_mode, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use this mode when processing the build settings."); + fll_program_print_help_option(id, context, fake_short_process, fake_long_process, f_console_symbol_short_enable, f_console_symbol_long_enable, " Process name for storing build states."); + fll_program_print_help_option(id, context, fake_short_settings, fake_long_settings, f_console_symbol_short_enable, f_console_symbol_long_enable, "Use this settings file."); - printf("%c", f_string_eol[0]); + dprintf(id, "%c", f_string_eol[0]); - fll_program_print_help_option(context, fake_short_path_build, fake_long_path_build, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a custom build directory."); - fll_program_print_help_option(context, fake_short_path_data, fake_long_path_data, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a custom path to the data files."); - fll_program_print_help_option(context, fake_short_path_sources, fake_long_path_sources, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a custom path to the source files."); - fll_program_print_help_option(context, fake_short_path_work, fake_long_path_work, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use includes/libraries/programs from this directory instead of system."); + fll_program_print_help_option(id, context, fake_short_path_build, fake_long_path_build, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a custom build directory."); + fll_program_print_help_option(id, context, fake_short_path_data, fake_long_path_data, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a custom path to the data files."); + fll_program_print_help_option(id, context, fake_short_path_sources, fake_long_path_sources, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a custom path to the source files."); + fll_program_print_help_option(id, context, fake_short_path_work, fake_long_path_work, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use includes/libraries/programs from this directory instead of system."); - printf("%c%c", f_string_eol[0], f_string_eol[0]); + dprintf(id, "%c%c", f_string_eol[0], f_string_eol[0]); - fl_color_print(f_type_output, context.set.important, " Special Options: "); + fl_color_print_to(id, context.set.important, " Special Options: "); - fll_program_print_help_option_long(context, fake_long_documents_disabled, f_console_symbol_long_enable, " Forcibly do not build documents files."); - fll_program_print_help_option_long(context, fake_long_documents_enabled, f_console_symbol_long_enable, " Forcibly do build documents files."); - fll_program_print_help_option_long(context, fake_long_shared_disabled, f_console_symbol_long_enable, "Forcibly do not build shared files."); - fll_program_print_help_option_long(context, fake_long_shared_enabled, f_console_symbol_long_enable, " Forcibly do build shared files."); - fll_program_print_help_option_long(context, fake_long_static_disabled, f_console_symbol_long_enable, "Forcibly do not build static files."); - fll_program_print_help_option_long(context, fake_long_static_enabled, f_console_symbol_long_enable, " Forcibly do build static files."); + fll_program_print_help_option_long(id, context, fake_long_documents_disabled, f_console_symbol_long_enable, " Forcibly do not build documents files."); + fll_program_print_help_option_long(id, context, fake_long_documents_enabled, f_console_symbol_long_enable, " Forcibly do build documents files."); + fll_program_print_help_option_long(id, context, fake_long_shared_disabled, f_console_symbol_long_enable, "Forcibly do not build shared files."); + fll_program_print_help_option_long(id, context, fake_long_shared_enabled, f_console_symbol_long_enable, " Forcibly do build shared files."); + fll_program_print_help_option_long(id, context, fake_long_static_disabled, f_console_symbol_long_enable, "Forcibly do not build static files."); + fll_program_print_help_option_long(id, context, fake_long_static_enabled, f_console_symbol_long_enable, " Forcibly do build static files."); - printf("%c%c", f_string_eol[0], f_string_eol[0]); + dprintf(id, "%c%c", f_string_eol[0], f_string_eol[0]); - fl_color_print(f_type_output, context.set.important, " Operations: "); + fl_color_print_to(id, context.set.important, " Operations: "); - fll_program_print_help_option_other(context, fake_other_operation_build, " Build or compile the code based on build settings file."); - fll_program_print_help_option_other(context, fake_other_operation_clean, " Delete all build files."); - fll_program_print_help_option_other(context, fake_other_operation_make, " Build or compile the code based on fakefile."); - fll_program_print_help_option_other(context, fake_other_operation_skeleton, "Build a skeleton directory structure."); + fll_program_print_help_option_other(id, context, fake_other_operation_build, " Build or compile the code based on build settings file."); + fll_program_print_help_option_other(id, context, fake_other_operation_clean, " Delete all build files."); + fll_program_print_help_option_other(id, context, fake_other_operation_make, " Build or compile the code based on fakefile."); + fll_program_print_help_option_other(id, context, fake_other_operation_skeleton, "Build a skeleton directory structure."); - fll_program_print_help_usage(context, fake_name, "operation"); + fll_program_print_help_usage(id, context, fake_name, "operation"); - printf(" When performing the "); - fl_color_print(f_type_output, context.set.notable, "%s", fake_other_operation_build); - printf(" operation, the "); - fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_mode); - printf(" parameter specifies a name (limited to alpha-numeric, underscore, and dash) to be used in addition to the global."); - printf("%c", f_string_eol[0]); + dprintf(id, " When performing the "); + fl_color_print_to(id, context.set.notable, "%s", fake_other_operation_build); + dprintf(id, " operation, the "); + fl_color_print_to(id, context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_mode); + dprintf(id, " parameter specifies a name (limited to alpha-numeric, underscore, and dash) to be used in addition to the global."); + dprintf(id, "%c", f_string_eol[0]); - printf(" For example, when a "); - fl_color_print(f_type_output, context.set.notable, "%s", fake_long_mode); - printf(" of 'fll_monolithic' is specified, build libaries from both 'build_libraries' and 'build_libraries-fll_monolithic' are used (but not 'build_libraries-fll_level')."); + dprintf(id, " For example, when a "); + fl_color_print_to(id, context.set.notable, "%s", fake_long_mode); + dprintf(id, " of 'fll_monolithic' is specified, build libaries from both 'build_libraries' and 'build_libraries-fll_monolithic' are used (but not 'build_libraries-fll_level')."); - printf("%c%c", f_string_eol[0], f_string_eol[0]); + dprintf(id, "%c%c", f_string_eol[0], f_string_eol[0]); - printf(" When specifying the "); - fl_color_print(f_type_output, context.set.notable, "%s", fake_long_fakefile); - printf(" or the "); - fl_color_print(f_type_output, context.set.notable, "%s", fake_long_settings); - printf(" parameters, the filenames are relative to the data build directory, unless a path is used."); - printf("%c", f_string_eol[0]); + dprintf(id, " When specifying the "); + fl_color_print_to(id, context.set.notable, "%s", fake_long_fakefile); + dprintf(id, " or the "); + fl_color_print_to(id, context.set.notable, "%s", fake_long_settings); + dprintf(id, " parameters, the filenames are relative to the data build directory, unless a path is used."); + dprintf(id, "%c", f_string_eol[0]); - printf(" For example, with '"); - fl_color_print(f_type_output, context.set.notable, "%s%s my_fakefile", f_console_symbol_long_enable, fake_long_fakefile); - printf("' the fakefile at '"); - fl_color_print(f_type_output, context.set.notable, "./%s%smy_fakefile", fake_default_path_data, fake_default_path_build); - printf(" would be used, however with '"); - fl_color_print(f_type_output, context.set.notable, "%s%s ./my_fakefile", f_console_symbol_long_enable, fake_long_fakefile); - printf("' the fakefile at '"); - fl_color_print(f_type_output, context.set.notable, "./my_fakefile", fake_default_path_data, fake_default_path_build); - printf(" would be used."); + dprintf(id, " For example, with '"); + fl_color_print_to(id, context.set.notable, "%s%s my_fakefile", f_console_symbol_long_enable, fake_long_fakefile); + dprintf(id, "' the fakefile at '"); + fl_color_print_to(id, context.set.notable, "./%s%smy_fakefile", fake_default_path_data, fake_default_path_build); + dprintf(id, " would be used, however with '"); + fl_color_print_to(id, context.set.notable, "%s%s ./my_fakefile", f_console_symbol_long_enable, fake_long_fakefile); + dprintf(id, "' the fakefile at '"); + fl_color_print_to(id, context.set.notable, "./my_fakefile", fake_default_path_data, fake_default_path_build); + dprintf(id, " would be used."); - printf("%c%c", f_string_eol[0], f_string_eol[0]); + dprintf(id, "%c%c", f_string_eol[0], f_string_eol[0]); return F_none; } @@ -121,7 +121,7 @@ extern "C" { // Identify priority of verbosity related parameters. { - f_console_parameter_id_t ids[4] = { fake_parameter_quiet, fake_parameter_normal, fake_parameter_verbose, fake_parameter_debug }; + f_console_parameter_id_t ids[4] = { fake_parameter_verbosity_quiet, fake_parameter_verbosity_normal, fake_parameter_verbosity_verbose, fake_parameter_verbosity_debug }; f_console_parameter_id_t choice = 0; const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); @@ -133,17 +133,17 @@ extern "C" { return status; } - if (choice == fake_parameter_quiet) { - data->verbosity = f_console_verbosity_quiet; + if (choice == fake_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; } - else if (choice == fake_parameter_normal) { - data->verbosity = f_console_verbosity_normal; + else if (choice == fake_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; } - else if (choice == fake_parameter_verbose) { - data->verbosity = f_console_verbosity_verbose; + else if (choice == fake_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; } - else if (choice == fake_parameter_debug) { - data->verbosity = f_console_verbosity_debug; + else if (choice == fake_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; } } @@ -233,14 +233,14 @@ extern "C" { status = F_none; if (data->parameters[fake_parameter_help].result == f_console_result_found) { - fake_print_help(data->context); + fake_print_help(data->output, data->context); fake_delete_data(data); return F_none; } if (data->parameters[fake_parameter_version].result == f_console_result_found) { - fll_program_print_version(fake_version); + fll_program_print_version(data->output, fake_version); fake_delete_data(data); return F_none; @@ -316,11 +316,11 @@ extern "C" { break; } else if (F_status_is_error(status)) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: The operation '"); - fl_color_print(f_type_error, data->context.set.notable, "%s", operations_name); - fl_color_print_line(f_type_error, data->context.set.error, "' failed."); + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The operation '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s", operations_name); + fl_color_print_to(data->error.to, data->context.set.error, "' failed.%c", f_string_eol[0]); } break; @@ -328,20 +328,20 @@ extern "C" { } // for // ensure a newline is always put at the end of the program execution, unless in quiet mode. - if (data->verbosity != f_console_verbosity_quiet) { + if (data->error.verbosity != f_console_verbosity_quiet) { if (F_status_is_error(status) || status == F_signal) { - fprintf(f_type_error, "%c", f_string_eol[0]); + dprintf(data->error.to, "%c", f_string_eol[0]); } else { - fprintf(f_type_output, "%cAll operations complete.%c%c", f_string_eol[0], f_string_eol[0], f_string_eol[0]); + dprintf(data->output, "%cAll operations complete.%c%c", f_string_eol[0], f_string_eol[0], f_string_eol[0]); } } } else { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: You failed to specify an operation."); - fprintf(f_type_error, "%c", f_string_eol[0]); + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: You failed to specify an operation.%c", f_string_eol[0]); + dprintf(data->error.to, "%c", f_string_eol[0]); } status = F_status_set_error(F_parameter); diff --git a/level_3/fake/c/fake.h b/level_3/fake/c/fake.h index 6bc3dc7..2c0e15d 100644 --- a/level_3/fake/c/fake.h +++ b/level_3/fake/c/fake.h @@ -74,6 +74,7 @@ #include // fll-2 includes +#include #include #include #include @@ -298,11 +299,11 @@ extern "C" { fake_parameter_help, fake_parameter_light, fake_parameter_dark, - fake_parameter_debug, fake_parameter_no_color, - fake_parameter_normal, - fake_parameter_quiet, - fake_parameter_verbose, + fake_parameter_verbosity_quiet, + fake_parameter_verbosity_normal, + fake_parameter_verbosity_verbose, + fake_parameter_verbosity_debug, fake_parameter_version, fake_parameter_define, @@ -334,11 +335,11 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, 0, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(fake_short_define, fake_long_define, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fake_short_fakefile, fake_long_fakefile, 0, 1, f_console_type_normal), \ @@ -371,7 +372,9 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; + uint8_t operation; mode_t umask; @@ -439,7 +442,8 @@ extern "C" { fake_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ 0, \ 0, \ f_signal_t_initialize, \ @@ -501,7 +505,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fake_print_help_ - extern f_return_status fake_print_help(const f_color_context_t context); + extern f_return_status fake_print_help(const int id, const f_color_context_t context); #endif // _di_fake_print_help_ /** diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 4ec5453..d373029 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -167,9 +167,9 @@ extern "C" { f_string_dynamic_t path_source = f_string_dynamic_t_initialize; f_string_dynamic_t destination_file = f_string_dynamic_t_initialize; - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_output, data.context.set.important, "Copying %s.", label); + fl_color_print(f_type_output, data.context.set.important, "Copying %s.%c", label, f_string_eol[0]); } f_macro_string_dynamic_t_new(*status, path_source, source.used); @@ -185,8 +185,8 @@ extern "C" { fl_directory_recurse_t recurse = fl_directory_recurse_t_initialize; - if (data.verbosity == f_console_verbosity_verbose) { - recurse.output = f_type_output; + if (data.error.verbosity == f_console_verbosity_verbose) { + recurse.output = f_type_descriptor_output; recurse.verbose = fake_verbose_print_copy; } @@ -226,7 +226,7 @@ extern "C" { *status = fl_directory_copy_content(path_source.string, destination.string, path_source.used, destination.used, mode, recurse); if (F_status_is_error(*status)) { - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { for (f_string_length_t j = 0; j < failures.used; j++) { fake_print_error_build_operation_file(data, F_status_set_fine(*status), "fl_directory_copy_content", "copy contents of", "to", path_source.string, destination.string, F_true); } // for @@ -237,7 +237,7 @@ extern "C" { break; } - else if (data.verbosity != f_console_verbosity_quiet) { + else if (data.error.verbosity != f_console_verbosity_quiet) { fake_print_error_build_operation_file(data, F_status_set_fine(*status), "fl_directory_copy_content", "copy contents of", "to", path_source.string, destination.string, F_true); } @@ -273,7 +273,7 @@ extern "C" { break; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("Copied file '%s' to '%s'.%c", path_source.string, destination_file.string, f_string_eol[0]); } } @@ -345,9 +345,9 @@ extern "C" { &path_headers, }; - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_output, data.context.set.important, "Creating base build directories."); + fl_color_print(f_type_output, data.context.set.important, "Creating base build directories.%c", f_string_eol[0]); } for (uint8_t i = 0; i < 15; i++) { @@ -371,7 +371,7 @@ extern "C" { return; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("Created directory '%s'.%c", directorys[i]->string, f_string_eol[0]); } } // for @@ -412,16 +412,16 @@ extern "C" { } // ensure verbosity level is passed to the scripts so that they can also react to requested verbosity. - if (F_status_is_error_not(*status) && data.verbosity != f_console_verbosity_normal) { + if (F_status_is_error_not(*status) && data.error.verbosity != f_console_verbosity_normal) { char argument[3] = { f_console_symbol_disable, 0, 0 }; - if (data.verbosity == f_console_verbosity_quiet) { + if (data.error.verbosity == f_console_verbosity_quiet) { argument[1] = f_console_standard_short_quiet[0]; } - else if (data.verbosity == f_console_verbosity_verbose) { + else if (data.error.verbosity == f_console_verbosity_verbose) { argument[1] = f_console_standard_short_verbose[0]; } - else if (data.verbosity == f_console_verbosity_debug) { + else if (data.error.verbosity == f_console_verbosity_debug) { argument[1] = f_console_standard_short_debug[0]; } @@ -591,11 +591,11 @@ extern "C" { else { if (F_status_is_error(*status)) { if (F_status_set_fine(*status) == F_failure) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: Failed to execute script: "); - fl_color_print(f_type_error, data.context.set.notable, "%s", path.string); - fl_color_print_line(f_type_error, data.context.set.error, "."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Failed to execute script: "); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", path.string); + fl_color_print_to(data.error.to, data.context.set.error, ".%c", f_string_eol[0]); } } else { @@ -660,9 +660,9 @@ extern "C" { if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true) return; if (!data_build.setting.build_sources_library.used) return; - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_output, data.context.set.important, "Compiling shared library."); + fl_color_print(f_type_output, data.context.set.important, "Compiling shared library.%c", f_string_eol[0]); } f_string_dynamics_t arguments = f_string_dynamics_t_initialize; @@ -883,7 +883,7 @@ extern "C" { *status = f_file_link(parameter_file_name_micro, parameter_file_path); - if (F_status_is_error_not(*status) && data.verbosity == f_console_verbosity_verbose) { + if (F_status_is_error_not(*status) && data.error.verbosity == f_console_verbosity_verbose) { printf("Linked file '%s' to '%s'.%c", parameter_file_path, parameter_file_name_micro, f_string_eol[0]); } else if (F_status_is_error(*status)) { @@ -923,7 +923,7 @@ extern "C" { *status = f_file_link(parameter_file_name_micro, parameter_file_path); } - if (F_status_is_error_not(*status) && data.verbosity == f_console_verbosity_verbose) { + if (F_status_is_error_not(*status) && data.error.verbosity == f_console_verbosity_verbose) { printf("Linked file '%s' to '", parameter_file_path); if (data_build.setting.version_target == fake_build_version_type_major) { @@ -968,9 +968,9 @@ extern "C" { if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true) return; if (!data_build.setting.build_sources_library.used) return; - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_output, data.context.set.important, "Compiling static library."); + fl_color_print(f_type_output, data.context.set.important, "Compiling static library.%c", f_string_eol[0]); } f_string_dynamic_t file_name = f_string_dynamic_t_initialize; @@ -1140,13 +1140,13 @@ extern "C" { if (F_status_is_error_not(*status)) { if (names.used + data_build.setting.environment.used > names.size) { if (names.used + data_build.setting.environment.used > f_array_length_t_size) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The values for the setting '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", fake_build_setting_name_environment); - fl_color_print(f_type_error, data.context.set.error, "' of setting file '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", data.file_data_build_settings.string); - fl_color_print_line(f_type_error, data.context.set.error, "' is too large."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The values for the setting '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", fake_build_setting_name_environment); + fl_color_print_to(data.error.to, data.context.set.error, "' of setting file '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", data.file_data_build_settings.string); + fl_color_print_to(data.error.to, data.context.set.error, "' is too large.%c", f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(part); @@ -1331,12 +1331,12 @@ extern "C" { for (uint8_t i = 0; i < 1; i++) { if (!settings[i]->used) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The setting '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", names[i]); - fl_color_print(f_type_error, data.context.set.error, "' is required but is not specified in the settings file '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", setting_file.used ? path_file : data.file_data_build_settings.string); - fl_color_print_line(f_type_error, data.context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The setting '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", names[i]); + fl_color_print_to(data.error.to, data.context.set.error, "' is required but is not specified in the settings file '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", setting_file.used ? path_file : data.file_data_build_settings.string); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); failed = F_true; } @@ -1560,13 +1560,13 @@ extern "C" { } // for if (found == F_false) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The specified mode '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", modes->array[i].string); - fl_color_print(f_type_error, data.context.set.error, "' is not a valid mode, according to '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", path_file); - fl_color_print_line(f_type_error, data.context.set.error, "'."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The specified mode '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", modes->array[i].string); + fl_color_print_to(data.error.to, data.context.set.error, "' is not a valid mode, according to '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", path_file); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } error_printed = F_true; @@ -1614,12 +1614,12 @@ extern "C" { if (F_status_is_error(*status)) { if (*status == F_status_set_error(F_string_too_large)) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { // @todo update FSS functions to return which setting index the problem happened on. - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: A setting in the build setting file '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", path_file); - fl_color_print_line(f_type_error, data.context.set.error, "' is too long."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: A setting in the build setting file '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", path_file); + fl_color_print_to(data.error.to, data.context.set.error, "' is too long.%c", f_string_eol[0]); } } else if (!error_printed) { @@ -1807,15 +1807,15 @@ extern "C" { if (!settings_single_source[i]->used) continue; if (settings_single_source[i]->used > 1) { - if (data.verbosity == f_console_verbosity_verbose) { - fprintf(f_type_warning, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.set.warning, "WARNING: the setting '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", settings_single_name[i]); - fl_color_print(f_type_warning, data.context.set.warning, "' in the file '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", path_file); - fl_color_print(f_type_warning, data.context.set.warning, "' may only have a single property, only using the first: '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", settings_single_source[i]->array[0].string); - fl_color_print_line(f_type_warning, data.context.set.warning, "'."); + if (data.error.verbosity == f_console_verbosity_verbose) { + dprintf(data.output, "%c", f_string_eol[0]); + fl_color_print_to(data.output, data.context.set.warning, "WARNING: the setting '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", settings_single_name[i]); + fl_color_print_to(data.output, data.context.set.warning, "' in the file '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", path_file); + fl_color_print_to(data.output, data.context.set.warning, "' may only have a single property, only using the first: '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", settings_single_source[i]->array[0].string); + fl_color_print_to(data.output, data.context.set.warning, "'.%c", f_string_eol[0]); } } @@ -1829,19 +1829,19 @@ extern "C" { else { *settings_single_bool[i] = F_true; - if (data.verbosity == f_console_verbosity_verbose) { - fprintf(f_type_warning, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.set.warning, "WARNING: the setting '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", settings_single_name[i]); - fl_color_print(f_type_warning, data.context.set.warning, "' in the file '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", path_file); - fl_color_print(f_type_warning, data.context.set.warning, "' may be either '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", fake_common_setting_bool_yes); - fl_color_print(f_type_warning, data.context.set.warning, "' or '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", fake_common_setting_bool_no); - fl_color_print(f_type_warning, data.context.set.warning, "', defaulting to '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", fake_common_setting_bool_yes); - fl_color_print_line(f_type_warning, data.context.set.warning, "'."); + if (data.error.verbosity == f_console_verbosity_verbose) { + dprintf(data.output, "%c", f_string_eol[0]); + fl_color_print_to(data.output, data.context.set.warning, "WARNING: the setting '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", settings_single_name[i]); + fl_color_print_to(data.output, data.context.set.warning, "' in the file '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", path_file); + fl_color_print_to(data.output, data.context.set.warning, "' may be either '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", fake_common_setting_bool_yes); + fl_color_print_to(data.output, data.context.set.warning, "' or '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", fake_common_setting_bool_no); + fl_color_print_to(data.output, data.context.set.warning, "', defaulting to '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", fake_common_setting_bool_yes); + fl_color_print_to(data.output, data.context.set.warning, "'.%c", f_string_eol[0]); } } } @@ -1858,21 +1858,21 @@ extern "C" { else { *settings_single_language[i] = fake_build_language_type_c; - if (data.verbosity == f_console_verbosity_verbose) { - fprintf(f_type_warning, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.set.warning, "WARNING: the setting '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", settings_single_name[i]); - fl_color_print(f_type_warning, data.context.set.warning, "' in the file '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", path_file); - fl_color_print(f_type_warning, data.context.set.warning, "' may only be one of '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", fake_build_language_bash); - fl_color_print(f_type_warning, data.context.set.warning, "', '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", fake_build_language_c); - fl_color_print(f_type_warning, data.context.set.warning, "', or '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", fake_build_language_cpp); - fl_color_print(f_type_warning, data.context.set.warning, "', defaulting to '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", fake_build_language_c); - fl_color_print_line(f_type_warning, data.context.set.warning, "'."); + if (data.error.verbosity == f_console_verbosity_verbose) { + dprintf(data.output, "%c", f_string_eol[0]); + fl_color_print_to(data.output, data.context.set.warning, "WARNING: the setting '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", settings_single_name[i]); + fl_color_print_to(data.output, data.context.set.warning, "' in the file '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", path_file); + fl_color_print_to(data.output, data.context.set.warning, "' may only be one of '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", fake_build_language_bash); + fl_color_print_to(data.output, data.context.set.warning, "', '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", fake_build_language_c); + fl_color_print_to(data.output, data.context.set.warning, "', or '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", fake_build_language_cpp); + fl_color_print_to(data.output, data.context.set.warning, "', defaulting to '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", fake_build_language_c); + fl_color_print_to(data.output, data.context.set.warning, "'.%c", f_string_eol[0]); } } } @@ -1889,21 +1889,21 @@ extern "C" { else { *settings_single_version[i] = fake_build_version_type_major; - if (data.verbosity == f_console_verbosity_verbose) { - fprintf(f_type_warning, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.set.warning, "WARNING: the setting '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", settings_single_name[i]); - fl_color_print(f_type_warning, data.context.set.warning, "' in the file '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", path_file); - fl_color_print(f_type_warning, data.context.set.warning, "' may only be one of '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", fake_build_version_major); - fl_color_print(f_type_warning, data.context.set.warning, "', '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", fake_build_version_minor); - fl_color_print(f_type_warning, data.context.set.warning, "', or '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", fake_build_version_micro); - fl_color_print(f_type_warning, data.context.set.warning, "', defaulting to '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", fake_build_version_major); - fl_color_print_line(f_type_warning, data.context.set.warning, "'."); + if (data.error.verbosity == f_console_verbosity_verbose) { + dprintf(data.output, "%c", f_string_eol[0]); + fl_color_print_to(data.output, data.context.set.warning, "WARNING: the setting '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", settings_single_name[i]); + fl_color_print_to(data.output, data.context.set.warning, "' in the file '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", path_file); + fl_color_print_to(data.output, data.context.set.warning, "' may only be one of '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", fake_build_version_major); + fl_color_print_to(data.output, data.context.set.warning, "', '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", fake_build_version_minor); + fl_color_print_to(data.output, data.context.set.warning, "', or '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", fake_build_version_micro); + fl_color_print_to(data.output, data.context.set.warning, "', defaulting to '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", fake_build_version_major); + fl_color_print_to(data.output, data.context.set.warning, "'.%c", f_string_eol[0]); } } } @@ -2022,22 +2022,22 @@ extern "C" { setting->search_shared = F_false; } - if (data.verbosity == f_console_verbosity_verbose) { - fprintf(f_type_warning, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.set.error, "WARNING: the parameters '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_shared_disabled); - fl_color_print(f_type_warning, data.context.set.error, "' and '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_shared_enabled); - fl_color_print(f_type_warning, data.context.set.error, "' contradict, defaulting to '"); + if (data.error.verbosity == f_console_verbosity_verbose) { + Dprintf(data.output, "%c", f_string_eol[0]); + fl_color_print_TO(data.output, data.context.set.error, "WARNING: the parameters '"); + fl_color_print_TO(data.output, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_shared_disabled); + fl_color_print_TO(data.output, data.context.set.error, "' and '"); + fl_color_print_TO(data.output, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_shared_enabled); + fl_color_print_TO(data.output, data.context.set.error, "' contradict, defaulting to '"); if (setting->build_shared) { - fl_color_print(f_type_warning, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_shared_enabled); + fl_color_print_to(data.output, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_shared_enabled); } else { - fl_color_print(f_type_warning, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_shared_disabled); + fl_color_print_to(data.output, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_shared_disabled); } - fl_color_print_line(f_type_warning, data.context.set.error, "'."); + fl_color_print_to(data.output, data.context.set.error, "'.%c", f_string_eol[0]); } } else { @@ -2061,22 +2061,22 @@ extern "C" { setting->search_static = F_false; } - if (data.verbosity == f_console_verbosity_verbose) { - fprintf(f_type_warning, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.set.error, "WARNING: the parameters '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_static_disabled); - fl_color_print(f_type_warning, data.context.set.error, "' and '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_static_enabled); - fl_color_print(f_type_warning, data.context.set.error, "' contradict, defaulting to '"); + if (data.error.verbosity == f_console_verbosity_verbose) { + dprintf(data.output, "%c", f_string_eol[0]); + fl_color_print_to(data.output, data.context.set.error, "WARNING: the parameters '"); + fl_color_print_to(data.output, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_static_disabled); + fl_color_print_to(data.output, data.context.set.error, "' and '"); + fl_color_print_to(data.output, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_static_enabled); + fl_color_print_to(data.output, data.context.set.error, "' contradict, defaulting to '"); if (setting->build_static) { - fl_color_print(f_type_warning, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_static_enabled); + fl_color_print_to(data.output, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_static_enabled); } else { - fl_color_print(f_type_warning, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_static_disabled); + fl_color_print_to(data.output, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_static_disabled); } - fl_color_print_line(f_type_warning, data.context.set.error, "'."); + fl_color_print_to(data.output, data.context.set.error, "'.%c", f_string_eol[0]); } } else { @@ -2091,22 +2091,22 @@ extern "C" { if (setting->build_language == fake_build_language_type_c || setting->build_language == fake_build_language_type_cpp) { if (setting->build_shared == F_false && setting->build_static == F_false) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The build settings '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", fake_build_setting_name_build_shared); - fl_color_print(f_type_error, data.context.set.error, "' and '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", fake_build_setting_name_build_static); - fl_color_print(f_type_error, data.context.set.error, "' cannot both be false when using the language '"); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The build settings '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", fake_build_setting_name_build_shared); + fl_color_print_to(data.error.to, data.context.set.error, "' and '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", fake_build_setting_name_build_static); + fl_color_print_to(data.error.to, data.context.set.error, "' cannot both be false when using the language '"); if (setting->build_language == fake_build_language_type_c) { - fl_color_print(f_type_error, data.context.set.notable, "%s", fake_build_language_c); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", fake_build_language_c); } else { - fl_color_print(f_type_error, data.context.set.notable, "%s", fake_build_language_cpp); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", fake_build_language_cpp); } - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -2261,9 +2261,9 @@ extern "C" { if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true) return; if (!data_build.setting.build_sources_library.used) return; - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_output, data.context.set.important, "Compiling static objects."); + fl_color_print(f_type_output, data.context.set.important, "Compiling static objects.%c", f_string_eol[0]); } f_string_dynamic_t file_name = f_string_dynamic_t_initialize; @@ -2346,11 +2346,11 @@ extern "C" { *status = f_directory_exists(destination_path.string); if (*status == F_false) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The path '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination_path.string); - fl_color_print_line(f_type_error, data.context.set.error, "' exists but is not a directory."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The path '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination_path.string); + fl_color_print_to(data.error.to, data.context.set.error, "' exists but is not a directory.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -2361,10 +2361,10 @@ extern "C" { if (F_status_is_error(*status)) { if (F_status_set_fine(*status) == F_file_found_not) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The path '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination_path.string); - fl_color_print_line(f_type_error, data.context.set.error, "' could not be created, a parent directory does not exist."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The path '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination_path.string); + fl_color_print_to(data.error.to, data.context.set.error, "' could not be created, a parent directory does not exist.%c", f_string_eol[0]); } else { fake_print_error_file(data, F_status_set_fine(*status), "f_directory_create", destination_path.string, "create", F_false, F_true); @@ -2373,7 +2373,7 @@ extern "C" { break; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("Directory '%s' created.%c", destination_path.string, f_string_eol[0]); } } @@ -2467,7 +2467,7 @@ extern "C" { fake_build_load_setting(data, setting_file, &data_build.setting, &status); if (F_status_is_fine(status)) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { printf("%c", f_string_eol[0]); fl_color_print(f_type_output, data.context.set.important, "Building project%c", data_build.setting.project_name.used ? ' ' : 0); @@ -2477,7 +2477,7 @@ extern "C" { fl_color_print_code(f_type_output, data.context.reset); } - fl_color_print_line(f_type_output, data.context.set.important, "."); + fl_color_print(f_type_output, data.context.set.important, ".%c", f_string_eol[0]); } } @@ -2591,9 +2591,9 @@ extern "C" { if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true) return; if (!data_build.setting.build_sources_program.used) return; - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_output, data.context.set.important, "Compiling shared program."); + fl_color_print(f_type_output, data.context.set.important, "Compiling shared program.%c", f_string_eol[0]); } f_string_dynamics_t arguments = f_string_dynamics_t_initialize; @@ -2690,9 +2690,9 @@ extern "C" { if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true) return; if (!data_build.setting.build_sources_program.used) return; - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_output, data.context.set.important, "Compiling static program."); + fl_color_print(f_type_output, data.context.set.important, "Compiling static program.%c", f_string_eol[0]); } f_string_dynamics_t arguments = f_string_dynamics_t_initialize; diff --git a/level_3/fake/c/private-clean.c b/level_3/fake/c/private-clean.c index 2766421..788288f 100644 --- a/level_3/fake/c/private-clean.c +++ b/level_3/fake/c/private-clean.c @@ -13,18 +13,18 @@ extern "C" { f_return_status fake_clean_operate(const fake_data_t data) { f_status_t status = F_none; - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { printf("%c", f_string_eol[0]); fl_color_print(f_type_output, data.context.set.important, "Deleting all files within build directory '"); fl_color_print(f_type_output, data.context.set.notable, "%s", data.path_build.string); - fl_color_print_line(f_type_output, data.context.set.important, "'."); + fl_color_print(f_type_output, data.context.set.important, "'.%c", f_string_eol[0]); } if (fake_signal_received(data)) { return F_signal; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { status = f_directory_remove_custom(data.path_build.string, f_directory_descriptors_max, F_true, fake_clean_remove_recursively_verbosely); } else { @@ -32,7 +32,7 @@ extern "C" { } if (F_status_set_fine(status) == F_file_found_not) { - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("The build directory '%s' does not exist.%c", data.path_build.string, f_string_eol[0]); } diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 25845d8..fbafcf4 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -12,7 +12,7 @@ extern "C" { int fake_execute(const fake_data_t data, const fake_environment_t environment, const f_string_static_t program, const f_string_statics_t arguments, f_status_t *status) { if (F_status_is_error(*status)) return 1; - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("%s", program.string); for (f_array_length_t i = 0; i < arguments.used; i++) { @@ -59,11 +59,11 @@ extern "C" { return_code = 1; if (F_status_set_fine(*status) == F_file_found_not) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: Failed to find program '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", program.used ? program.string : ""); - fl_color_print_line(f_type_error, data.context.set.error, "' for executing."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Failed to find program '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", program.used ? program.string : ""); + fl_color_print_to(data.error.to, data.context.set.error, "' for executing.%c", f_string_eol[0]); } } else { @@ -642,24 +642,24 @@ extern "C" { status = f_utf_is_word_dash_plus(arguments.argv[location] + j, width_max, F_false); if (F_status_is_error(status)) { - if (fake_print_error(*data, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_unknown && data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Failed to process the parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_process); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + if (fake_print_error(*data, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to process the parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_process); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } return status; } if (status == F_false) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: The '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_process); - fl_color_print(f_type_error, data->context.set.error, "' parameters value '"); - fl_color_print(f_type_error, data->context.set.notable, "%s", arguments.argv[location]); - fl_color_print_line(f_type_error, data->context.set.error, "' contains non-word, non-dash, and non-plus characters."); + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_process); + fl_color_print_to(data->error.to, data->context.set.error, "' parameters value '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s", arguments.argv[location]); + fl_color_print_to(data->error.to, data->context.set.error, "' contains non-word, non-dash, and non-plus characters.%c", f_string_eol[0]); } return F_status_set_error(F_parameter); @@ -671,11 +671,11 @@ extern "C" { if (F_status_is_error(status)) { if (status == F_status_set_error(F_string_too_large)) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); - fl_color_print_line(f_type_error, data->context.set.error, "' is too long."); + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); + fl_color_print_to(data->error.to, data->context.set.error, "' is too long.%c", f_string_eol[0]); } } else { @@ -690,11 +690,11 @@ extern "C" { } if (length == 0 || status == F_data_not) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); - fl_color_print_line(f_type_error, data->context.set.error, "' must not be empty and must not contain only whitespace."); + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); + fl_color_print_to(data->error.to, data->context.set.error, "' must not be empty and must not contain only whitespace.%c", f_string_eol[0]); } } } @@ -768,11 +768,11 @@ extern "C" { status = fl_console_parameter_to_string_dynamic_directory(arguments.argv[data->parameters[parameters_id[i]].additional.array[0]], parameters_value[i]); if (F_status_is_error(status)) { - if (fake_print_error(*data, F_status_set_fine(status), "fl_console_parameter_to_string_dynamic_directory", F_false) == F_unknown && data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Failed to process parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + if (fake_print_error(*data, F_status_set_fine(status), "fl_console_parameter_to_string_dynamic_directory", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to process parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } return status; @@ -782,11 +782,11 @@ extern "C" { f_macro_string_dynamic_t_new(status, (*parameters_value[i]), parameter_default_lengths[i]); if (F_status_is_error(status)) { - if (fake_print_error(*data, F_status_set_fine(status), "f_macro_string_dynamic_t_new", F_false) == F_unknown && data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Failed to load default for the parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + if (fake_print_error(*data, F_status_set_fine(status), "f_macro_string_dynamic_t_new", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to load default for the parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } return status; @@ -802,11 +802,11 @@ extern "C" { status = fll_program_parameter_additional_rip(arguments.argv, data->parameters[fake_parameter_define].additional, &data->define); if (F_status_is_error(status)) { - if (fake_print_error(*data, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_unknown && data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Failed to process the parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_define); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + if (fake_print_error(*data, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to process the parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_define); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } return status; @@ -825,24 +825,24 @@ extern "C" { status = f_utf_is_word(data->define.array[i].string + j, width_max, F_false); if (F_status_is_error(status)) { - if (fake_print_error(*data, F_status_set_fine(status), "f_utf_is_word", F_false) == F_unknown && data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Failed to process the parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_define); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + if (fake_print_error(*data, F_status_set_fine(status), "f_utf_is_word", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to process the parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_define); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } return status; } if (status == F_false) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: The '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_define); - fl_color_print(f_type_error, data->context.set.error, "' parameters value '"); - fl_color_print(f_type_error, data->context.set.notable, "%s", data->define.array[i].string); - fl_color_print_line(f_type_error, data->context.set.error, "' contains non-word characters."); + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_define); + fl_color_print_to(data->error.to, data->context.set.error, "' parameters value '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s", data->define.array[i].string); + fl_color_print_to(data->error.to, data->context.set.error, "' contains non-word characters.%c", f_string_eol[0]); } return F_status_set_error(F_parameter); @@ -859,11 +859,11 @@ extern "C" { status = fll_program_parameter_additional_rip(arguments.argv, data->parameters[fake_parameter_mode].additional, &data->mode); if (F_status_is_error(status)) { - if (fake_print_error(*data, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_unknown && data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Failed to process the parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_mode); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + if (fake_print_error(*data, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to process the parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_mode); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } return status; @@ -882,24 +882,24 @@ extern "C" { status = f_utf_is_word_dash_plus(data->mode.array[i].string + j, width_max, F_false); if (F_status_is_error(status)) { - if (fake_print_error(*data, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_unknown && data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Failed to process the parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_mode); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + if (fake_print_error(*data, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to process the parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_mode); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } return status; } if (status == F_false) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: The '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_mode); - fl_color_print(f_type_error, data->context.set.error, "' parameters value '"); - fl_color_print(f_type_error, data->context.set.notable, "%s", data->mode.array[i].string); - fl_color_print_line(f_type_error, data->context.set.error, "' contains non-word, non-dash, and non-plus characters."); + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_mode); + fl_color_print_to(data->error.to, data->context.set.error, "' parameters value '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s", data->mode.array[i].string); + fl_color_print_to(data->error.to, data->context.set.error, "' contains non-word, non-dash, and non-plus characters.%c", f_string_eol[0]); } return F_status_set_error(F_parameter); @@ -935,9 +935,9 @@ extern "C" { case F_signal_quit: case F_signal_termination: - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.set.error, "ALERT: An appropriate exit signal has been received, now aborting."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ALERT: An appropriate exit signal has been received, now aborting.%c", f_string_eol[0]); } return F_true; @@ -1009,10 +1009,10 @@ extern "C" { } } else if (parameters_required[i]) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: No valid path for the (required) directory parameter '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); - fl_color_print_line(f_type_error, data.context.set.error, "' was found."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: No valid path for the (required) directory parameter '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); + fl_color_print_to(data.error.to, data.context.set.error, "' was found.%c", f_string_eol[0]); return F_status_set_error(F_directory_found_not); } @@ -1023,20 +1023,20 @@ extern "C" { #endif // _di_fake_validate_parameter_directories_ #ifndef _di_fake_verbose_print_clone_ - void fake_verbose_print_clone(FILE *output, const f_string_t source, const f_string_t destination) { - fprintf(output, "Cloned '%s' to '%s'.%c", source, destination, f_string_eol[0]); + void fake_verbose_print_clone(const int output, const f_string_t source, const f_string_t destination) { + dprintf(output, "Cloned '%s' to '%s'.%c", source, destination, f_string_eol[0]); } #endif // _di_fake_verbose_print_clone_ #ifndef _di_fake_verbose_print_copy_ - void fake_verbose_print_copy(FILE *output, const f_string_t source, const f_string_t destination) { - fprintf(output, "Copied '%s' to '%s'.%c", source, destination, f_string_eol[0]); + void fake_verbose_print_copy(const int output, const f_string_t source, const f_string_t destination) { + dprintf(output, "Copied '%s' to '%s'.%c", source, destination, f_string_eol[0]); } #endif // _di_fake_verbose_print_copy_ #ifndef _di_fake_verbose_print_move_ - void fake_verbose_print_move(FILE *output, const f_string_t source, const f_string_t destination) { - fprintf(output, "Moved '%s' to '%s'.%c", source, destination, f_string_eol[0]); + void fake_verbose_print_move(const int output, const f_string_t source, const f_string_t destination) { + dprintf(output, "Moved '%s' to '%s'.%c", source, destination, f_string_eol[0]); } #endif // _di_fake_verbose_print_move_ diff --git a/level_3/fake/c/private-fake.h b/level_3/fake/c/private-fake.h index 83f2d49..2145ef7 100644 --- a/level_3/fake/c/private-fake.h +++ b/level_3/fake/c/private-fake.h @@ -173,42 +173,42 @@ extern "C" { * Helper function for performing a verbose print for a file clone operation. * * @param output - * A file pointer to print to, such as stdout. + * A file descriptor to print to, such as f_type_desciptor_output. * @param source * The source string. * @param destination * The destination string. */ #ifndef _di_fake_verbose_print_clone_ - extern void fake_verbose_print_clone(FILE *output, const f_string_t source, const f_string_t destination) f_gcc_attribute_visibility_internal; + extern void fake_verbose_print_clone(const int output, const f_string_t source, const f_string_t destination) f_gcc_attribute_visibility_internal; #endif // _di_fake_verbose_print_clone_ /** * Helper function for performing a verbose print for a file copy operation. * * @param output - * A file pointer to print to, such as stdout. + * A file descriptor to print to, such as f_type_desciptor_output. * @param source * The source string. * @param destination * The destination string. */ #ifndef _di_fake_verbose_print_copy_ - extern void fake_verbose_print_copy(FILE *output, const f_string_t source, const f_string_t destination) f_gcc_attribute_visibility_internal; + extern void fake_verbose_print_copy(const int output, const f_string_t source, const f_string_t destination) f_gcc_attribute_visibility_internal; #endif // _di_fake_verbose_print_copy_ /** * Helper function for performing a verbose print for a file move operation. * * @param output - * A file pointer to print to, such as stdout. + * A file descriptor to print to, such as f_type_desciptor_output. * @param source * The source string. * @param destination * The destination string. */ #ifndef _di_fake_verbose_print_move_ - extern void fake_verbose_print_move(FILE *output, const f_string_t source, const f_string_t destination) f_gcc_attribute_visibility_internal; + extern void fake_verbose_print_move(const int output, const f_string_t source, const f_string_t destination) f_gcc_attribute_visibility_internal; #endif // _di_fake_verbose_print_move_ #ifdef __cplusplus diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index ebaa548..a4ff71f 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -44,7 +44,7 @@ extern "C" { #endif // _di_fake_make_assure_inside_project_ #ifndef _di_fake_make_get_id_group_ - f_return_status fake_make_get_id_group(const fake_data_t data, const fake_make_print_t print, const f_string_static_t buffer, gid_t *id) { + f_return_status fake_make_get_id_group(const fake_data_t data, const f_string_static_t buffer, gid_t *id) { const f_string_range_t range = f_macro_string_range_t_initialize(buffer.used); f_number_unsigned_t number = 0; @@ -62,11 +62,11 @@ extern "C" { return F_status_set_error(status); } else if (status == F_exist_not) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(print.to, "%c", f_string_eol[0]); - fl_color_print(print.to, print.context, "%s: The group name '", print.prefix); - fl_color_print(print.to, data.context.set.notable, "%s", buffer.string); - fl_color_print_line(print.to, print.context, "' was not found."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + fl_color_print_to(print.to, print.context, "%s: The group name '", print.prefix); + fl_color_print_to(print.to, data.context.set.notable, "%s", buffer.string); + fl_color_print_to(print.to, print.context, "' was not found.%c", f_string_eol[0]); } return F_status_set_error(F_failure); @@ -79,11 +79,11 @@ extern "C" { return F_status_set_error(status); } else if (number > f_type_size_32_unsigned) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(print.to, "%c", f_string_eol[0]); - fl_color_print(print.to, print.context, "%s: The number '", print.prefix); - fl_color_print(print.to, data.context.set.notable, "%llu", number); - fl_color_print_line(print.to, print.context, "' is too large."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + fl_color_print_to(print.to, print.context, "%s: The number '", print.prefix); + fl_color_print_to(print.to, data.context.set.notable, "%llu", number); + fl_color_print_to(print.to, print.context, "' is too large.%c", f_string_eol[0]); } } @@ -93,7 +93,7 @@ extern "C" { #endif // _di_fake_make_get_id_group_ #ifndef _di_fake_make_get_id_mode_ - f_return_status fake_make_get_id_mode(const fake_data_t data, const fake_make_print_t print, const f_string_static_t buffer, f_file_mode_t *mode, uint8_t *replace) { + f_return_status fake_make_get_id_mode(const fake_data_t data, const f_string_static_t buffer, f_file_mode_t *mode, uint8_t *replace) { if (!buffer.used) { fake_print_message(data, F_parameter, "fake_make_get_id_mode", F_true, print); return F_status_set_error(F_parameter); @@ -102,12 +102,12 @@ extern "C" { f_status_t status = f_file_mode_from_string(buffer.string, data.umask, mode, replace); if (F_status_is_error(status)) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { if (F_status_set_fine(status) == F_syntax) { - fprintf(print.to, "%c", f_string_eol[0]); - fl_color_print(print.to, print.context, "%s: The mode '", print.prefix); - fl_color_print(print.to, data.context.set.notable, "%s", buffer.string); - fl_color_print_line(print.to, print.context, "' is invalid."); + dprintf(print.to, "%c", f_string_eol[0]); + fl_color_print_to(print.to, print.context, "%s: The mode '", print.prefix); + fl_color_print_to(print.to, data.context.set.notable, "%s", buffer.string); + fl_color_print_to(print.to, print.context, "' is invalid.%c", f_string_eol[0]); } else { fake_print_message(data, status, "f_file_mode_from_string", F_true, print); @@ -122,7 +122,7 @@ extern "C" { #endif // _di_fake_make_get_id_mode_ #ifndef _di_fake_make_get_id_owner_ - f_return_status fake_make_get_id_owner(const fake_data_t data, const fake_make_print_t print, const f_string_static_t buffer, uid_t *id) { + f_return_status fake_make_get_id_owner(const fake_data_t data, const f_string_static_t buffer, uid_t *id) { const f_string_range_t range = f_macro_string_range_t_initialize(buffer.used); f_number_unsigned_t number = 0; @@ -140,11 +140,11 @@ extern "C" { return F_status_set_error(status); } else if (status == F_exist_not) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(print.to, "%c", f_string_eol[0]); - fl_color_print(print.to, print.context, "%s: The user name '", print.prefix); - fl_color_print(print.to, data.context.set.notable, "%s", buffer.string); - fl_color_print_line(print.to, print.context, "' was not found."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + fl_color_print_to(print.to, print.context, "%s: The user name '", print.prefix); + fl_color_print_to(print.to, data.context.set.notable, "%s", buffer.string); + fl_color_print_to(print.to, print.context, "' was not found.%c", f_string_eol[0]); } return F_status_set_error(F_failure); @@ -157,11 +157,11 @@ extern "C" { return F_status_set_error(status); } else if (number > f_type_size_32_unsigned) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(print.to, "%c", f_string_eol[0]); - fl_color_print(print.to, print.context, "%s: The number '", print.prefix); - fl_color_print(print.to, data.context.set.notable, "%llu", number); - fl_color_print_line(print.to, print.context, "' is too large."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(print.to, "%c", f_string_eol[0]); + fl_color_print_to(print.to, print.context, "%s: The number '", print.prefix); + fl_color_print_to(print.to, data.context.set.notable, "%llu", number); + fl_color_print_to(print.to, print.context, "' is too large.%c", f_string_eol[0]); } } @@ -188,11 +188,11 @@ extern "C" { } if (!data_make->buffer.used) { - if (data.verbosity == f_console_verbosity_verbose) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.set.warning, "WARNING: the fakefile '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", data.file_data_build_fakefile.string); - fl_color_print(f_type_warning, data.context.set.warning, "' is empty."); + if (data.error.verbosity == f_console_verbosity_verbose) { + dprintf(data.output, "%c", f_string_eol[0]); + fl_color_print_to(data.output, data.context.set.warning, "WARNING: the fakefile '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", data.file_data_build_fakefile.string); + fl_color_print_to(data.output, data.context.set.warning, "' is empty."); } return; @@ -303,13 +303,13 @@ extern "C" { } if (missing_main) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The fakefile '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", data.file_data_build_fakefile.string); - fl_color_print(f_type_error, data.context.set.error, "' is missing the required '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", fake_make_section_main); - fl_color_print_line(f_type_error, data.context.set.error, "' object."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The fakefile '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", data.file_data_build_fakefile.string); + fl_color_print_to(data.error.to, data.context.set.error, "' is missing the required '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", fake_make_section_main); + fl_color_print_to(data.error.to, data.context.set.error, "' object.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -434,18 +434,18 @@ extern "C" { data_make->setting_build.environment.array[data_make->setting_build.environment.used].used--; data_make->setting_build.environment.used++; } - else if (data.verbosity == f_console_verbosity_verbose) { - fprintf(f_type_warning, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.set.warning, "WARNING: The environment name '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", name_define.string); - fl_color_print_line(f_type_warning, data.context.set.warning, "' is already added."); + else if (data.error.verbosity == f_console_verbosity_verbose) { + dprintf(data.output, "%c", f_string_eol[0]); + fl_color_print_to(data.output, data.context.set.warning, "WARNING: The environment name '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", name_define.string); + fl_color_print_to(data.output, data.context.set.warning, "' is already added.%c", f_string_eol[0]); } } - else if (data.verbosity == f_console_verbosity_verbose) { - fprintf(f_type_warning, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.set.warning, "WARNING: The environment name '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", name_define.string); - fl_color_print_line(f_type_warning, data.context.set.warning, "' is invalid, ignoring."); + else if (data.error.verbosity == f_console_verbosity_verbose) { + dprintf(data.output, "%c", f_string_eol[0]); + fl_color_print_to(data.output, data.context.set.warning, "WARNING: The environment name '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", name_define.string); + fl_color_print_to(data.output, data.context.set.warning, "' is invalid, ignoring.%c", f_string_eol[0]); } name_define.used = 0; @@ -695,15 +695,15 @@ extern "C" { } } else { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: Invalid characters in the define setting name '"); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Invalid characters in the define setting name '"); fl_color_print_code(f_type_error, data.context.notable); f_print_dynamic(f_type_error, define.array[i].name); fl_color_print_code(f_type_error, data.context.reset); - fl_color_print_line(f_type_error, data.context.set.error, "', only alpha-numeric ASCII characters and underscore (without a leading digit) is allowed."); + fl_color_print_to(data.error.to, data.context.set.error, "', only alpha-numeric ASCII characters and underscore (without a leading digit) is %c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -784,7 +784,7 @@ extern "C" { } } - if (data.verbosity != f_console_verbosity_normal) { + if (data.error.verbosity != f_console_verbosity_normal) { if (data_make->parameter.verbosity.used >= data_make->parameter.verbosity.size) { *status = fl_string_dynamics_size_increase(f_memory_default_allocation_step, &data_make->parameter.verbosity); @@ -794,11 +794,11 @@ extern "C" { } } - if (data.verbosity == f_console_verbosity_quiet) { - if (data.parameters[fake_parameter_quiet].type == f_console_type_normal) { + if (data.error.verbosity == f_console_verbosity_quiet) { + if (data.parameters[fake_parameter_verbosity_quiet].type == f_console_type_normal) { *status = fl_string_append(f_console_symbol_short_enable, 1, &data_make->parameter.verbosity.array[data_make->parameter.verbosity.used]); } - else if (data.parameters[fake_parameter_quiet].type == f_console_type_inverse) { + else if (data.parameters[fake_parameter_verbosity_quiet].type == f_console_type_inverse) { *status = fl_string_append(f_console_symbol_short_disable, 1, &data_make->parameter.verbosity.array[data_make->parameter.verbosity.used]); } @@ -806,11 +806,11 @@ extern "C" { *status = fl_string_append(f_console_standard_short_quiet, 1, &data_make->parameter.verbosity.array[data_make->parameter.verbosity.used]); } } - else if (data.verbosity == f_console_verbosity_verbose) { - if (data.parameters[fake_parameter_verbose].type == f_console_type_normal) { + else if (data.error.verbosity == f_console_verbosity_verbose) { + if (data.parameters[fake_parameter_verbosity_verbose].type == f_console_type_normal) { *status = fl_string_append(f_console_symbol_short_enable, 1, &data_make->parameter.verbosity.array[data_make->parameter.verbosity.used]); } - else if (data.parameters[fake_parameter_verbose].type == f_console_type_inverse) { + else if (data.parameters[fake_parameter_verbosity_verbose].type == f_console_type_inverse) { *status = fl_string_append(f_console_symbol_short_disable, 1, &data_make->parameter.verbosity.array[data_make->parameter.verbosity.used]); } @@ -818,11 +818,11 @@ extern "C" { *status = fl_string_append(f_console_standard_short_verbose, 1, &data_make->parameter.verbosity.array[data_make->parameter.verbosity.used]); } } - else if (data.verbosity == f_console_verbosity_debug) { - if (data.parameters[fake_parameter_debug].type == f_console_type_normal) { + else if (data.error.verbosity == f_console_verbosity_debug) { + if (data.parameters[fake_parameter_verbosity_debug].type == f_console_type_normal) { *status = fl_string_append(f_console_symbol_short_enable, 1, &data_make->parameter.verbosity.array[data_make->parameter.verbosity.used]); } - else if (data.parameters[fake_parameter_debug].type == f_console_type_inverse) { + else if (data.parameters[fake_parameter_verbosity_debug].type == f_console_type_inverse) { *status = fl_string_append(f_console_symbol_short_disable, 1, &data_make->parameter.verbosity.array[data_make->parameter.verbosity.used]); } @@ -1019,9 +1019,9 @@ extern "C" { return F_signal; } - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_output, data.context.set.important, "Making project."); + fl_color_print(f_type_output, data.context.set.important, "Making project.%c", f_string_eol[0]); } f_status_t status = F_none; @@ -1102,13 +1102,13 @@ extern "C" { { f_status_t status_path = f_path_change_at(data_make.path.top); - if (F_status_is_error(status_path) && data.verbosity == f_console_verbosity_verbose) { - fprintf(f_type_warning, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.set.warning, "WARNING: Failed change back to orignal path '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", data_make.path.stack.array[0].string); - fl_color_print(f_type_warning, data.context.set.warning, "', status code = "); - fl_color_print(f_type_warning, data.context.set.notable, "%llu", F_status_set_fine(status_path)); - fl_color_print_line(f_type_warning, data.context.set.warning, "."); + if (F_status_is_error(status_path) && data.error.verbosity == f_console_verbosity_verbose) { + dprintf(data.output, "%c", f_string_eol[0]); + fl_color_print_to(data.output, data.context.set.warning, "WARNING: Failed change back to orignal path '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", data_make.path.stack.array[0].string); + fl_color_print_to(data.output, data.context.set.warning, "', status code = "); + fl_color_print_to(data.output, data.context.set.notable, "%llu", F_status_set_fine(status_path)); + fl_color_print_to(data.output, data.context.set.warning, ".%c", f_string_eol[0]); } } @@ -1867,7 +1867,7 @@ extern "C" { const f_fss_named_t *section = &data_make->fakefile.array[id_section]; - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { printf("%c", f_string_eol[0]); fl_color_print(f_type_output, data.context.set.important, "Processing Section '"); @@ -1876,7 +1876,7 @@ extern "C" { f_print_dynamic_partial(f_type_output, data_make->buffer, section->name); fl_color_print_code(f_type_output, data.context.reset); - fl_color_print_line(f_type_output, data.context.set.important, "'."); + fl_color_print(f_type_output, data.context.set.important, "'.%c", f_string_eol[0]); } if (!section->objects.used) { @@ -2182,7 +2182,7 @@ extern "C" { if (i == section->objects.used && (operation_if == fake_make_operation_if_type_true_next || operation_if == fake_make_operation_if_type_false_next || operation_if == fake_make_operation_if_type_else_true || operation_if == fake_make_operation_if_type_else_false)) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { const char *type_name = 0; if (operation_if == fake_make_operation_if_type_true_next || operation_if == fake_make_operation_if_type_false_next) { @@ -2195,7 +2195,7 @@ extern "C" { fprintf(data_make->print.to, "%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Incomplete '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", type_name); - fl_color_print_line(data_make->print.to, data_make->print.context, "' at end of section."); + fl_color_print(data_make->print.to, data_make->print.context, "' at end of section.%c", f_string_eol[0]); } fake_print_message_section_operation_failed(data, data_make->buffer, section->name, section->objects.array[section->objects.used - 1], data_make->print); @@ -2243,7 +2243,7 @@ extern "C" { return; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("Breaking as '%s'.", arguments.used ? arguments.array[0].string : fake_make_operation_argument_success); } @@ -2296,8 +2296,8 @@ extern "C" { f_string_length_t destination_length = 0; - if (data.verbosity == f_console_verbosity_verbose) { - recurse.output = f_type_output; + if (data.error.verbosity == f_console_verbosity_verbose) { + recurse.output = f_type_descriptor_output; recurse.verbose = fake_verbose_print_clone; } @@ -2353,7 +2353,7 @@ extern "C" { fake_print_message_file(data, F_status_set_fine(status_file), "f_file_clone", arguments.array[i].string, "clone", F_false, F_true, data_make->print); *status = F_status_set_error(F_failure); } - else if (data.verbosity == f_console_verbosity_verbose) { + else if (data.error.verbosity == f_console_verbosity_verbose) { printf("Cloned '%s' to '%s'.%c", arguments.array[i].string, destination, f_string_eol[0]); } } @@ -2391,8 +2391,8 @@ extern "C" { f_macro_mode_t_set_default_umask(mode, data.umask); - if (data.verbosity == f_console_verbosity_verbose) { - recurse.output = f_type_output; + if (data.error.verbosity == f_console_verbosity_verbose) { + recurse.output = f_type_descriptor_output; recurse.verbose = fake_verbose_print_copy; } @@ -2448,7 +2448,7 @@ extern "C" { fake_print_message_file(data, F_status_set_fine(status_file), "f_file_copy", arguments.array[i].string, "copy", F_false, F_true, data_make->print); *status = F_status_set_error(F_failure); } - else if (data.verbosity == f_console_verbosity_verbose) { + else if (data.error.verbosity == f_console_verbosity_verbose) { printf("Copied '%s' to '%s'.%c", arguments.array[i].string, destination, f_string_eol[0]); } } @@ -2474,7 +2474,7 @@ extern "C" { if (F_status_is_error(*status)) { fake_print_message(data, F_status_set_fine(*status), "f_environment_set", F_true, data_make->print); } - else if (data.verbosity == f_console_verbosity_verbose) { + else if (data.error.verbosity == f_console_verbosity_verbose) { printf("Defined environment variable '%s'.%c", arguments.array[0].string, f_string_eol[0]); } @@ -2492,11 +2492,11 @@ extern "C" { if (F_status_is_error(*status)) { if (F_status_set_fine(*status) == F_file_found_not) { - if (data.verbosity == f_console_verbosity_verbose) { - fprintf(f_type_warning, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.set.warning, "WARNING: the file '"); - fl_color_print(f_type_warning, data.context.set.notable, "%s", arguments.array[i].string); - fl_color_print_line(f_type_warning, data.context.set.warning, "' was not found."); + if (data.error.verbosity == f_console_verbosity_verbose) { + dprintf(data.output, "%c", f_string_eol[0]); + fl_color_print_to(data.output, data.context.set.warning, "WARNING: the file '"); + fl_color_print_to(data.output, data.context.set.notable, "%s", arguments.array[i].string); + fl_color_print_to(data.output, data.context.set.warning, "' was not found.%c", f_string_eol[0]); } *status = F_none; @@ -2507,7 +2507,7 @@ extern "C" { } } else if (f_macro_file_type_is_directory(file_stat.st_mode)) { - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { *status = f_directory_remove_custom(arguments.array[i].string, recursion_max, F_false, fake_clean_remove_recursively_verbosely); } else { @@ -2515,7 +2515,7 @@ extern "C" { } if (F_status_set_fine(*status) == F_file_found_not) { - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("The directory '%s' does not exist.%c", arguments.array[i].string, f_string_eol[0]); } @@ -2526,7 +2526,7 @@ extern "C" { fake_print_message_file(data, F_status_set_fine(*status), "f_directory_remove", arguments.array[i].string, "delete", F_false, F_true, data_make->print); return; } - else if (data.verbosity == f_console_verbosity_verbose) { + else if (data.error.verbosity == f_console_verbosity_verbose) { printf("Removed '%s'.%c", arguments.array[i].string, f_string_eol[0]); } } @@ -2537,7 +2537,7 @@ extern "C" { fake_print_message_file(data, F_status_set_fine(*status), "f_file_remove", arguments.array[i].string, "delete", F_true, F_true, data_make->print); return; } - else if (data.verbosity == f_console_verbosity_verbose) { + else if (data.error.verbosity == f_console_verbosity_verbose) { printf("Removed '%s'.%c", arguments.array[i].string, f_string_eol[0]); } } @@ -2576,7 +2576,7 @@ extern "C" { return; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("Exiting as '%s'.", arguments.used ? arguments.array[0].string : fake_make_operation_argument_success); } @@ -2602,7 +2602,7 @@ extern "C" { data_make->print.to = 0; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("Set failure state to '"); if (data_make->setting_make.fail == fake_make_operation_fail_type_exit) { @@ -2647,7 +2647,7 @@ extern "C" { fake_print_message_file(data, *status, "f_file_role_change", arguments.array[i].string, "change group of", F_true, F_true, data_make->print); } - else if (data.verbosity == f_console_verbosity_verbose) { + else if (data.error.verbosity == f_console_verbosity_verbose) { printf("Changed group of '%s' to %llu.%c", arguments.array[i].string, id, f_string_eol[0]); } } // for @@ -2682,7 +2682,7 @@ extern "C" { fake_print_message_file(data, F_status_set_fine(*status), "fll_file_role_change_all", arguments.array[i].string, "change group of", F_true, F_true, data_make->print); } - else if (data.verbosity == f_console_verbosity_verbose) { + else if (data.error.verbosity == f_console_verbosity_verbose) { printf("Changed group of '%s' to %llu.%c", arguments.array[i].string, id, f_string_eol[0]); } } // for @@ -3143,18 +3143,18 @@ extern "C" { *status = F_status_set_error(F_failure); *operation_if = fake_make_operation_if_type_false_always_next; - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); if ((i == 1 && number_left > f_number_t_size_unsigned) || (i > 1 && number_right > f_number_t_size_unsigned)) { fl_color_print(data_make->print.to, data_make->print.context, "%s: The number '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%c%s", arguments.array[i].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "' may only be between the ranges -%llu to %llu.", f_number_t_size_unsigned, f_number_t_size_unsigned); + fl_color_print(data_make->print.to, data_make->print.context, "' may only be between the ranges -%llu to %llu.%c", f_number_t_size_unsigned, f_number_t_size_unsigned, f_string_eol[0]); } else { fl_color_print(data_make->print.to, data_make->print.context, "%s: Invalid or unsupported number provided '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[i].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } } } @@ -3171,7 +3171,7 @@ extern "C" { if (F_status_is_error(*status)) { fake_print_message_file(data, *status, "f_file_link", arguments.array[1].string, "create link", F_true, F_true, data_make->print); } - else if (data.verbosity == f_console_verbosity_verbose) { + else if (data.error.verbosity == f_console_verbosity_verbose) { printf("Created symbolic link from '%s' to '%s'.%c", arguments.array[1].string, arguments.array[0].string, f_string_eol[0]); } @@ -3212,7 +3212,7 @@ extern "C" { break; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("Changed mode of '%s' to %#o.%c", arguments.array[i].string, mode, f_string_eol[0]); } } // for @@ -3254,7 +3254,7 @@ extern "C" { break; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("Changed mode of '%s' to %#o.%c", arguments.array[i].string, mode, f_string_eol[0]); } } // for @@ -3270,8 +3270,8 @@ extern "C" { f_string_length_t destination_length = 0; - if (data.verbosity == f_console_verbosity_verbose) { - recurse.output = f_type_output; + if (data.error.verbosity == f_console_verbosity_verbose) { + recurse.output = f_type_descriptor_output; recurse.verbose = fake_verbose_print_move; } @@ -3375,7 +3375,7 @@ extern "C" { fake_print_message_file(data, F_status_set_fine(*status), "f_file_role_change", arguments.array[i].string, "change owner of", F_true, F_true, data_make->print); break; } - else if (data.verbosity == f_console_verbosity_verbose) { + else if (data.error.verbosity == f_console_verbosity_verbose) { printf("Changed owner of '%s' to %d.%c", arguments.array[i].string, id, f_string_eol[0]); } } // for @@ -3410,7 +3410,7 @@ extern "C" { fake_print_message_file(data, F_status_set_fine(*status), "fll_file_role_change_all", arguments.array[i].string, "change owner of", F_true, F_true, data_make->print); } - else if (data.verbosity == f_console_verbosity_verbose) { + else if (data.error.verbosity == f_console_verbosity_verbose) { printf("Changed owner of '%s' to %o.%c", arguments.array[i].string, id, f_string_eol[0]); } } // for @@ -3430,7 +3430,7 @@ extern "C" { return; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { *status = fake_make_path_relative(data, data_make->path.stack.array[data_make->path.stack.used - 1], data_make); if (F_status_is_error(*status)) { fake_print_message(data, F_status_set_fine(*status), "fake_make_path_relative", F_true, data_make->print); @@ -3529,7 +3529,7 @@ extern "C" { return; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { *status = fake_make_path_relative(data, data_make->path.stack.array[data_make->path.stack.used], data_make); if (F_status_is_error(*status)) { @@ -3557,7 +3557,7 @@ extern "C" { return; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("Changed to project path ''.%c", f_string_eol[0]); } @@ -3606,7 +3606,7 @@ extern "C" { } } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("Touched %s '", arguments.array[0].string); f_print_dynamic(f_type_output, arguments.array[i]); printf("'.%c", f_string_eol[0]); @@ -3674,7 +3674,7 @@ extern "C" { data_make->environment.values.used++; } // for - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("%s", program.string); for (f_array_length_t i = 0; i < arguments.used; i++) { @@ -3709,11 +3709,11 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_file_found_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { fprintf(data_make->print.to, "%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Failed to find program '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", program.string); - fl_color_print_line(data_make->print.to, data_make->print.context, "' for executing."); + fl_color_print(data_make->print.to, data_make->print.context, "' for executing.%c", f_string_eol[0]); } } else if (F_status_set_fine(status) != F_failure) { @@ -3783,11 +3783,11 @@ extern "C" { return; } - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { fprintf(data_make->print.to, "%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Failed with return code '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", data_make->setting_make.parameter.array[0].value.array[0].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } if (data_make->setting_make.fail == fake_make_operation_fail_type_exit) { @@ -3851,9 +3851,9 @@ extern "C" { if (operation == fake_make_operation_type_index || operation == fake_make_operation_type_run || operation == fake_make_operation_type_shell) { if (!arguments.used) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -3861,11 +3861,11 @@ extern "C" { else if (operation == fake_make_operation_type_index) { if (!data_make->setting_build.build_indexer.used) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { fprintf(data_make->print.to, "%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: No indexer has been specified, cannot perform '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, fake_make_operation_index); - fl_color_print_line(data_make->print.to, data_make->print.context, "' section operation."); + fl_color_print(data_make->print.to, data_make->print.context, "' section operation.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -3877,9 +3877,9 @@ extern "C" { if (operation == fake_make_operation_type_break) { if (arguments.used > 1) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Has too many arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Has too many arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -3888,11 +3888,11 @@ extern "C" { if (fl_string_dynamic_compare_string(fake_make_operation_argument_success, arguments.array[0], fake_make_operation_argument_success_length) == F_equal_to_not) { if (fl_string_dynamic_compare_string(fake_make_operation_argument_failure, arguments.array[0], fake_make_operation_argument_failure_length) == F_equal_to_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Unsupported break type '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[0].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -3905,9 +3905,9 @@ extern "C" { if (operation == fake_make_operation_type_build) { if (arguments.used > 1) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Has too many arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Has too many arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -3924,11 +3924,11 @@ extern "C" { f_status_t status_file = f_file_is(path_file, f_file_type_regular, F_false); if (status_file == F_file_found_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Failed to find file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", path_file); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(status_file); @@ -3938,20 +3938,20 @@ extern "C" { *status = status_file; } else if (!status_file) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: The file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", path_file); - fl_color_print_line(data_make->print.to, data_make->print.context, "' must be a regular file."); + fl_color_print(data_make->print.to, data_make->print.context, "' must be a regular file.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); } } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Filename argument must not be an empty string.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Filename argument must not be an empty string.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -3963,9 +3963,9 @@ extern "C" { if (operation == fake_make_operation_type_clean || operation == fake_make_operation_type_pop || operation == fake_make_operation_type_top || operation == fake_make_operation_type_skeleton) { if (arguments.used) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Has too many arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Has too many arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -3973,9 +3973,9 @@ extern "C" { else if (operation == fake_make_operation_type_pop) { if (data_make->path.stack.used == 1) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Must not attempt to pop project root off of path stack.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Must not attempt to pop project root off of path stack.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4003,11 +4003,11 @@ extern "C" { for (f_array_length_t i = 0; i < arguments.used - 1; i++) { if (f_file_exists(arguments.array[i].string) != F_true) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Failed to find file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[i].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4019,11 +4019,11 @@ extern "C" { f_status_t status_file = f_directory_is(arguments.array[arguments.used - 1].string); if (status_file == F_false || status_file == F_file_found_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: The last file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[arguments.used - 1].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "' must be a valid directory."); + fl_color_print(data_make->print.to, data_make->print.context, "' must be a valid directory.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4041,11 +4041,11 @@ extern "C" { status_file = f_directory_is(arguments.array[1].string); if (status_file == F_false) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: The last file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[arguments.used - 1].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "' must be a valid directory."); + fl_color_print(data_make->print.to, data_make->print.context, "' must be a valid directory.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4054,9 +4054,9 @@ extern "C" { } } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4067,19 +4067,19 @@ extern "C" { if (operation == fake_make_operation_type_compile) { if (!arguments.used) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); } else if (data_make->setting_build.build_compiler.used) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { fprintf(data_make->print.to, "%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: No compiler has been specified, cannot perform '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, fake_make_operation_compile); - fl_color_print_line(data_make->print.to, data_make->print.context, "' section operation."); + fl_color_print(data_make->print.to, data_make->print.context, "' section operation.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4106,11 +4106,11 @@ extern "C" { for (f_array_length_t i = 0; i < arguments.used - 1; i++) { if (f_file_exists(arguments.array[i].string) != F_true) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Failed to find file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[i].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4122,11 +4122,11 @@ extern "C" { f_status_t status_file = f_directory_is(arguments.array[arguments.used - 1].string); if (status_file == F_false || status_file == F_file_found_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: The last file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[arguments.used - 1].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "' must be a valid directory."); + fl_color_print(data_make->print.to, data_make->print.context, "' must be a valid directory.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4144,11 +4144,11 @@ extern "C" { status_file = f_directory_is(arguments.array[1].string); if (status_file == F_false) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: The last file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[arguments.used - 1].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "' must be a valid directory."); + fl_color_print(data_make->print.to, data_make->print.context, "' must be a valid directory.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4157,9 +4157,9 @@ extern "C" { } } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4184,9 +4184,9 @@ extern "C" { } // for } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4200,15 +4200,15 @@ extern "C" { *status = fake_make_operate_validate_define_name(arguments.array[0]); if (*status == F_none) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Define name must not be an empty string.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Define name must not be an empty string.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); } else if (*status == F_false) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { fprintf(data_make->print.to, "%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Invalid characters in the define setting name '", data_make->print.prefix); @@ -4216,16 +4216,16 @@ extern "C" { f_print_dynamic(data_make->print.to, arguments.array[0]); fl_color_print_code(data_make->print.to, data.context.reset); - fl_color_print_line(data_make->print.to, data_make->print.context, "', only alpha-numeric ASCII characters and underscore (without a leading digit) is allowed."); + fl_color_print(data_make->print.to, data_make->print.context, "', only alpha-numeric ASCII characters and underscore (without a leading digit) is allowed.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); } } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4236,11 +4236,11 @@ extern "C" { if (operation == fake_make_operation_type_else) { if (*operation_if == fake_make_operation_if_type_else_true || *operation_if == fake_make_operation_if_type_else_false) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Must not be used after another '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "else"); - fl_color_print_line(data_make->print.to, data_make->print.context, "' section operation."); + fl_color_print(data_make->print.to, data_make->print.context, "' section operation.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4250,11 +4250,11 @@ extern "C" { } if (*operation_if == fake_make_operation_if_type_true || *operation_if == fake_make_operation_if_type_false || *operation_if == fake_make_operation_if_type_false_always) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Must not be used inside an ", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "if"); - fl_color_print_line(data_make->print.to, data_make->print.context, "' section operation."); + fl_color_print(data_make->print.to, data_make->print.context, "' section operation.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4264,9 +4264,9 @@ extern "C" { } if (*operation_if != fake_make_operation_if_type_else_true_next && *operation_if != fake_make_operation_if_type_else_false_next && *operation_if != fake_make_operation_if_type_else_false_next_always) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Has no preceding if condition.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Has no preceding if condition.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4276,9 +4276,9 @@ extern "C" { } if (arguments.used) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Has too many arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Has too many arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4290,9 +4290,9 @@ extern "C" { if (operation == fake_make_operation_type_exit) { if (arguments.used > 1) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Has too many arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Has too many arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4301,11 +4301,11 @@ extern "C" { if (fl_string_dynamic_compare_string(fake_make_operation_argument_success, arguments.array[0], fake_make_operation_argument_success_length) == F_equal_to_not) { if (fl_string_dynamic_compare_string(fake_make_operation_argument_failure, arguments.array[0], fake_make_operation_argument_failure_length) == F_equal_to_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Unsupported exit type '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[0].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4322,11 +4322,11 @@ extern "C" { if (fl_string_dynamic_compare_string(fake_make_operation_argument_warn, arguments.array[0], fake_make_operation_argument_warn_length) == F_equal_to_not) { if (fl_string_dynamic_compare_string(fake_make_operation_argument_ignore, arguments.array[0], fake_make_operation_argument_ignore_length) == F_equal_to_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Unsupported fail type '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[0].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4335,9 +4335,9 @@ extern "C" { } } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4354,17 +4354,17 @@ extern "C" { status_file = f_file_is(arguments.array[i].string, f_file_type_regular, F_false); if (status_file == F_file_found_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Failed to find file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[i].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(status_file); } else if (F_status_is_error(status_file)) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { fake_print_message_file(data, *status, "f_file_is", arguments.array[i].string, "find", F_true, F_true, data_make->print); } @@ -4375,9 +4375,9 @@ extern "C" { return; } - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4387,11 +4387,11 @@ extern "C" { if (operation == fake_make_operation_type_if) { if (*operation_if == fake_make_operation_if_type_true || *operation_if == fake_make_operation_if_type_false || *operation_if == fake_make_operation_if_type_false_always) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Must not be used after another '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "if"); - fl_color_print_line(data_make->print.to, data_make->print.context, "' section operation."); + fl_color_print(data_make->print.to, data_make->print.context, "' section operation.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4480,11 +4480,11 @@ extern "C" { } // for if (i == 14) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Unsupported if type '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[0].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4496,9 +4496,9 @@ extern "C" { if (arguments.used >= if_type_minimum[i]) { if (*operation_if == fake_make_operation_if_type_if_success || *operation_if == fake_make_operation_if_type_if_failure) { if (arguments.used > if_type_minimum[i]) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Has too many arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Has too many arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4513,11 +4513,11 @@ extern "C" { if (*operation_if == fake_make_operation_if_type_if_mode) { if (fl_string_dynamic_compare_string(fake_make_operation_argument_is, arguments.array[1], fake_make_operation_argument_is_length) == F_equal_to_not) { if (fl_string_dynamic_compare_string(fake_make_operation_argument_has, arguments.array[1], fake_make_operation_argument_has_length) == F_equal_to_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Unsupported mode type '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[1].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4588,11 +4588,11 @@ extern "C" { type_file |= 0x40; } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Unsupported file type '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[i].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } type_file |= 0x80; @@ -4659,11 +4659,11 @@ extern "C" { if (fl_string_dynamic_compare_string(fake_make_operation_argument_environment, arguments.array[1], fake_make_operation_argument_environment_length) == F_equal_to_not) { if (fl_string_dynamic_compare_string(fake_make_operation_argument_parameter, arguments.array[1], fake_make_operation_argument_parameter_length) == F_equal_to_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Unsupported define type '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[1].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4675,9 +4675,9 @@ extern "C" { if (*operation_if == fake_make_operation_if_type_if_equal || *operation_if == fake_make_operation_if_type_if_equal_not) { if (arguments.used < 3) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4688,9 +4688,9 @@ extern "C" { if (*operation_if == fake_make_operation_if_type_if_greater || *operation_if == fake_make_operation_if_type_if_greater_equal || *operation_if == fake_make_operation_if_type_if_less || *operation_if == fake_make_operation_if_type_if_less_equal) { if (arguments.used < 3) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4731,18 +4731,18 @@ extern "C" { if (F_status_is_error(status_number)) { *status = F_status_set_error(F_failure); - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); if (number > f_number_t_size_unsigned) { fl_color_print(data_make->print.to, data_make->print.context, "%s: The number '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%c%s", arguments.array[i].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "' may only be between the ranges -%llu to %llu.", f_number_t_size_unsigned, f_number_t_size_unsigned); + fl_color_print(data_make->print.to, data_make->print.context, "' may only be between the ranges -%llu to %llu.%c", f_number_t_size_unsigned, f_number_t_size_unsigned, f_string_eol[0]); } else { fl_color_print(data_make->print.to, data_make->print.context, "%s: Invalid or unsupported number provided '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[i].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } } } @@ -4753,9 +4753,9 @@ extern "C" { } } - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4766,9 +4766,9 @@ extern "C" { if (operation == fake_make_operation_type_link) { if (arguments.used > 2) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Has too many arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Has too many arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4795,9 +4795,9 @@ extern "C" { } } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4824,11 +4824,11 @@ extern "C" { for (f_array_length_t i = 0; i < arguments.used - 1; i++) { if (f_file_exists(arguments.array[i].string) != F_true) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Failed to find file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[i].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4840,11 +4840,11 @@ extern "C" { f_status_t status_file = f_directory_is(arguments.array[arguments.used - 1].string); if (status_file == F_false || status_file == F_file_found_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: The last file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[arguments.used - 1].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "' must be a valid directory."); + fl_color_print(data_make->print.to, data_make->print.context, "' must be a valid directory.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4862,11 +4862,11 @@ extern "C" { status_file = f_directory_is(arguments.array[1].string); if (status_file == F_false) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: The last file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[arguments.used - 1].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "' must be a valid directory."); + fl_color_print(data_make->print.to, data_make->print.context, "' must be a valid directory.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4875,9 +4875,9 @@ extern "C" { } } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4888,9 +4888,9 @@ extern "C" { if (operation == fake_make_operation_type_operate) { if (arguments.used > 1) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Has too many arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Has too many arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4909,7 +4909,7 @@ extern "C" { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: No operation section named '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[0].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "' was found."); + fl_color_print(data_make->print.to, data_make->print.context, "' was found.%c", f_string_eol[0]); } else { for (f_array_length_t i = 0; i < section_stack->used; i++) { @@ -4922,7 +4922,7 @@ extern "C" { f_print_dynamic_partial(data_make->print.to, data_make->buffer, data_make->fakefile.array[id_section].name); fl_color_print_code(data_make->print.to, data.context.reset); - fl_color_print_line(data_make->print.to, data_make->print.context, "' is already in the operation stack, recursion is not allowed."); + fl_color_print(data_make->print.to, data_make->print.context, "' is already in the operation stack, recursion is not allowed.%c", f_string_eol[0]); *status = F_status_set_error(F_failure); break; @@ -4931,9 +4931,9 @@ extern "C" { } } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4943,9 +4943,9 @@ extern "C" { if (operation == fake_make_operation_type_to) { if (arguments.used > 1) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Has too many arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Has too many arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -4955,44 +4955,44 @@ extern "C" { f_status_t status_file = f_file_is(arguments.array[0].string, f_file_type_directory, F_false); if (status_file == F_file_found_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Failed to find file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[0].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(status_file); } else if (F_status_is_error(status_file)) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { fake_print_message_file(data, *status, "f_file_is", data.file_data_build_fakefile.string, "find", F_true, F_true, data_make->print); } *status = status_file; } else if (!status_file) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: The file '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[0].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "' must be a directory file."); + fl_color_print(data_make->print.to, data_make->print.context, "' must be a directory file.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); } } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Filename argument must not be an empty string.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Filename argument must not be an empty string.%c", data_make->print.prefix, f_string_eol[0]); } } } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -5006,11 +5006,11 @@ extern "C" { if (fl_string_dynamic_compare_string(fake_make_operation_argument_file, arguments.array[0], fake_make_operation_argument_file_length) == F_equal_to_not) { if (fl_string_dynamic_compare_string(fake_make_operation_argument_directory, arguments.array[0], fake_make_operation_argument_directory_length) == F_equal_to_not) { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); fl_color_print(data_make->print.to, data_make->print.context, "%s: Unsupported file type '", data_make->print.prefix); fl_color_print(data_make->print.to, data.context.set.notable, "%s", arguments.array[0].string); - fl_color_print_line(data_make->print.to, data_make->print.context, "'."); + fl_color_print(data_make->print.to, data_make->print.context, "'.%c", f_string_eol[0]); } *status = F_status_set_error(F_failure); @@ -5031,9 +5031,9 @@ extern "C" { } // for } else { - if (data.verbosity != f_console_verbosity_quiet && data_make->print.to) { + if (data.error.verbosity != f_console_verbosity_quiet && data_make->print.to) { printf("%c", f_string_eol[0]); - fl_color_print_line(data_make->print.to, data_make->print.context, "%s: Requires more arguments.", data_make->print.prefix); + fl_color_print(data_make->print.to, data_make->print.context, "%s: Requires more arguments.%c", data_make->print.prefix, f_string_eol[0]); } *status = F_status_set_error(F_failure); diff --git a/level_3/fake/c/private-make.h b/level_3/fake/c/private-make.h index 4777664..6d65573 100644 --- a/level_3/fake/c/private-make.h +++ b/level_3/fake/c/private-make.h @@ -348,29 +348,6 @@ extern "C" { f_macro_string_dynamics_t_delete_simple(path.stack) #endif // _di_fake_make_path_t_ -#ifndef _di_fake_make_print_t_ - typedef struct { - const char *prefix; - f_color_set_t context; - - FILE *to; - } fake_make_print_t; - - #define fake_make_print_t_initialize { \ - 0, \ - f_color_set_t_initialize, \ - 0, \ - } - - #define fake_macro_make_print_t_initialize(prefix, context, to) { prefix, context, to } - - #define fake_make_print_error "ERROR" - #define fake_make_print_warning "WARNING" - - #define fake_make_print_error_length 5 - #define fake_make_print_warning_length 7 -#endif // _di_fake_make_print_t_ - #ifndef _di_fake_make_data_t_ typedef struct { fake_build_setting_t setting_build; @@ -380,7 +357,6 @@ extern "C" { fake_make_parameter_t parameter; fake_make_path_t path; - fake_make_print_t print; f_fss_nameds_t fakefile; @@ -396,7 +372,6 @@ extern "C" { fake_environment_t_initialize, \ fake_make_parameter_t_initialize, \ fake_make_path_t_initialize, \ - fake_make_print_t_initialize, \ f_fss_nameds_t_initialize, \ f_string_dynamic_t_initialize, \ f_string_dynamic_t_initialize, \ @@ -440,8 +415,6 @@ extern "C" { * * @param data * The program data. - * @param print - * The error/warning print data. * @param buffer * The string containing the name or number. * @param id @@ -454,7 +427,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_make_get_id_group_ - f_return_status fake_make_get_id_group(const fake_data_t data, const fake_make_print_t print, const f_string_static_t buffer, gid_t *id) f_gcc_attribute_visibility_internal; + f_return_status fake_make_get_id_group(const fake_data_t data, const f_string_static_t buffer, gid_t *id) f_gcc_attribute_visibility_internal; #endif // _di_fake_make_get_id_group_ /** @@ -462,8 +435,6 @@ extern "C" { * * @param data * The program data. - * @param print - * The error/warning print data. * @param buffer * The string containing the name or number. * @param mode @@ -480,7 +451,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_make_get_id_mode_ - f_return_status fake_make_get_id_mode(const fake_data_t data, const fake_make_print_t print, const f_string_static_t buffer, f_file_mode_t *mode, uint8_t *replace) f_gcc_attribute_visibility_internal; + f_return_status fake_make_get_id_mode(const fake_data_t data, const f_string_static_t buffer, f_file_mode_t *mode, uint8_t *replace) f_gcc_attribute_visibility_internal; #endif // _di_fake_make_get_id_mode_ /** @@ -488,8 +459,6 @@ extern "C" { * * @param data * The program data. - * @param print - * The error/warning print data. * @param buffer * The string containing the name or number. * @param id @@ -502,7 +471,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_make_get_id_owner_ - f_return_status fake_make_get_id_owner(const fake_data_t data, const fake_make_print_t print, const f_string_static_t buffer, uid_t *id) f_gcc_attribute_visibility_internal; + f_return_status fake_make_get_id_owner(const fake_data_t data, const f_string_static_t buffer, uid_t *id) f_gcc_attribute_visibility_internal; #endif // _di_fake_make_get_id_owner_ /** diff --git a/level_3/fake/c/private-print.c b/level_3/fake/c/private-print.c index 1ddea84..37883d6 100644 --- a/level_3/fake/c/private-print.c +++ b/level_3/fake/c/private-print.c @@ -13,7 +13,7 @@ extern "C" { f_return_status fake_print_error(const fake_data_t data, const f_status_t status, const f_string_t function, const bool fallback) { const fake_make_print_t print = fake_macro_make_print_t_initialize(fake_make_print_error, data.context.set.error, f_type_error); - return fake_print_message(data, status, function, fallback, print); + return fake_print_message(data, status, function, fallback); } #endif // _di_fake_print_error_ @@ -21,217 +21,217 @@ extern "C" { bool fake_print_error_build_operation_file(const fake_data_t data, const f_status_t status, const f_string_t function, const f_string_t operation, const f_string_t how, const f_string_t source, const f_string_t destination, const bool fallback) { if (status == F_file_found_not) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: Failed to find '"); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Failed to find '"); if (f_file_exists(source) == F_true) { - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } else { - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); } - fl_color_print(f_type_error, data.context.set.error, "' while trying to %s '", operation); - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + fl_color_print_to(data.error.to, data.context.set.error, "' while trying to %s '", operation); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); if (destination) { - fl_color_print(f_type_error, data.context.set.error, "' %s '", how); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.error, "' %s '", how); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_parameter) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, data.context.set.notable, "%s", function); - fl_color_print(f_type_error, data.context.set.error, "() to %s '", operation); - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", function); + fl_color_print_to(data.error.to, data.context.set.error, "() to %s '", operation); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); if (destination) { - fl_color_print(f_type_error, data.context.set.error, "' %s '", how); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.error, "' %s '", how); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_name) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: Invalid name for '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Invalid name for '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); if (destination) { - fl_color_print(f_type_error, data.context.set.error, "' or '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.error, "' or '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_memory_out) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory, while trying to %s '", operation); - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory, while trying to %s '", operation); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); if (destination) { - fl_color_print(f_type_error, data.context.set.error, "' %s '", how); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.error, "' %s '", how); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_number_overflow) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: Overflow while trying to %s '", operation); - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Overflow while trying to %s '", operation); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); if (destination) { - fl_color_print(f_type_error, data.context.set.error, "' %s '", how); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.error, "' %s '", how); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_directory) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: Invalid directory while trying to %s '", operation); - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Invalid directory while trying to %s '", operation); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); if (destination) { - fl_color_print(f_type_error, data.context.set.error, "' %s '", how); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.error, "' %s '", how); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_access_denied) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: Access denied while trying to %s '", operation); - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Access denied while trying to %s '", operation); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); if (destination) { - fl_color_print(f_type_error, data.context.set.error, "' %s '", how); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.error, "' %s '", how); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_loop) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: Loop while trying to %s '", operation); - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Loop while trying to %s '", operation); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); if (destination) { - fl_color_print(f_type_error, data.context.set.error, "' %s '", how); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.error, "' %s '", how); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_prohibited) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: Prohibited by system while trying to %s '", operation); - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Prohibited by system while trying to %s '", operation); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); if (destination) { - fl_color_print(f_type_error, data.context.set.error, "' %s '", how); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.error, "' %s '", how); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_directory_found_not) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: Failed to %s '", operation); - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Failed to %s '", operation); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); if (destination) { - fl_color_print(f_type_error, data.context.set.error, "' %s '", how); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.error, "' %s '", how); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } - fl_color_print_line(f_type_error, data.context.set.error, "' due to an invalid directory in the path."); + fl_color_print_to(data.error.to, data.context.set.error, "' due to an invalid directory in the path.%c", f_string_eol[0]); } return F_false; } if (status == F_failure) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: Failed to %s '", operation); - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Failed to %s '", operation); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); if (destination) { - fl_color_print(f_type_error, data.context.set.error, "' %s '", how); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.error, "' %s '", how); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } return F_false; } - if (fake_print_error(data, status, function, F_false) == F_unknown && fallback && data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, data.context.set.notable, "%llu", status); - fl_color_print(f_type_error, data.context.set.error, ") occurred while trying to %s '", operation); - fl_color_print(f_type_error, data.context.set.notable, "%s", source); + if (fake_print_error(data, status, function, F_false) == F_unknown && fallback && data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "UNKNOWN ERROR: ("); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, data.context.set.error, ") occurred while trying to %s '", operation); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", source); if (destination) { - fl_color_print(f_type_error, data.context.set.error, "' %s '", how); - fl_color_print(f_type_error, data.context.set.notable, "%s", destination); + fl_color_print_to(data.error.to, data.context.set.error, "' %s '", how); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", destination); } - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); } return F_true; @@ -250,38 +250,38 @@ extern "C" { bool fake_print_error_fss(const fake_data_t data, const f_status_t status, const f_string_t function, const f_string_t path_file, const f_string_range_t range, const bool fallback) { if (status == F_file_found_not) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); - fl_color_print(f_type_error, data.context.set.notable, "%d", range.start); - fl_color_print(f_type_error, data.context.set.error, " of setting file '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", path_file); - fl_color_print_line(f_type_error, data.context.set.error, "')."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print_to(data.error.to, data.context.set.notable, "%d", range.start); + fl_color_print_to(data.error.to, data.context.set.error, " of setting file '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", path_file); + fl_color_print_to(data.error.to, data.context.set.error, "').%c", f_string_eol[0]); } return F_false; } if (status == F_status_set_error(F_incomplete_utf_stop)) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); - fl_color_print(f_type_error, data.context.set.notable, "%d", range.start); - fl_color_print(f_type_error, data.context.set.error, " of setting file '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", path_file); - fl_color_print_line(f_type_error, data.context.set.error, "')."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print_to(data.error.to, data.context.set.notable, "%d", range.start); + fl_color_print_to(data.error.to, data.context.set.error, " of setting file '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", path_file); + fl_color_print_to(data.error.to, data.context.set.error, "').%c", f_string_eol[0]); } return F_false; } - if (fake_print_error(data, status, function, F_false) == F_unknown && fallback && data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, data.context.set.notable, "%llu", status); - fl_color_print(f_type_error, data.context.set.error, ") in function "); - fl_color_print(f_type_error, data.context.set.notable, "%s", function); - fl_color_print_line(f_type_error, data.context.set.error, "()."); + if (fake_print_error(data, status, function, F_false) == F_unknown && fallback && data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "UNKNOWN ERROR: ("); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, data.context.set.error, ") in function "); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", function); + fl_color_print_to(data.error.to, data.context.set.error, "().%c", f_string_eol[0]); } return F_true; @@ -290,45 +290,45 @@ extern "C" { #ifndef _di_fake_print_error_parameter_missing_value_ void fake_print_error_parameter_missing_value(const fake_data_t data, const f_string_t parameter) { - if (data.verbosity == f_console_verbosity_quiet) return; + if (data.error.verbosity == f_console_verbosity_quiet) return; - fprintf(f_type_error, "%c", f_string_eol[0]); + dprintf(data.error.to, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print_line(f_type_error, data.context.set.error, "' was specified, but no value was given."); + fl_color_print_to(data.error.to, data.context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); } #endif // _di_fake_print_error_parameter_missing_value_ #ifndef _di_fake_print_error_parameter_too_many_ void fake_print_error_parameter_too_many(const fake_data_t data, const f_string_t parameter) { - if (data.verbosity == f_console_verbosity_quiet) return; + if (data.error.verbosity == f_console_verbosity_quiet) return; - fprintf(f_type_error, "%c", f_string_eol[0]); + dprintf(data.error.to, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print_line(f_type_error, data.context.set.error, "' specified too many times."); + fl_color_print_to(data.error.to, data.context.set.error, "' specified too many times.%c", f_string_eol[0]); } #endif // _di_fake_print_error_parameter_too_many_ #ifndef _di_fake_print_message_ - f_return_status fake_print_message(const fake_data_t data, const f_status_t status, const f_string_t function, const bool fallback, const fake_make_print_t print) { + f_return_status fake_print_message(const fake_data_t data, const f_status_t status, const f_string_t function, const bool fallback) { if (status == F_parameter) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Invalid parameter", print.prefix); if (function) { fl_color_print(print.to, print.context, " when calling function "); fl_color_print(print.to, data.context.set.notable, "%s", function); - fl_color_print_line(print.to, print.context, "()."); + fl_color_print(print.to, print.context, "().%c", f_string_eol[0]); } else { - fl_color_print_line(print.to, print.context, "."); + fl_color_print(print.to, print.context, ".%c", f_string_eol[0]); } } @@ -336,24 +336,24 @@ extern "C" { } if (status == F_memory_allocation || status == F_memory_reallocation) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Unable to allocate memory", print.prefix); if (function) { fl_color_print(print.to, print.context, " in function "); fl_color_print(print.to, data.context.set.notable, "%s", function); - fl_color_print_line(print.to, print.context, "()."); + fl_color_print(print.to, print.context, "().%c", f_string_eol[0]); } else { - fl_color_print_line(print.to, print.context, "."); + fl_color_print(print.to, print.context, ".%c", f_string_eol[0]); } } return F_none; } - if (fallback && data.verbosity != f_console_verbosity_quiet) { + if (fallback && data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "UNKNOWN %s: (", print.prefix); fl_color_print(print.to, data.context.set.notable, "%llu", status); @@ -362,10 +362,10 @@ extern "C" { if (function) { fl_color_print(print.to, print.context, " in function "); fl_color_print(print.to, data.context.set.notable, "%s", function); - fl_color_print_line(print.to, print.context, "()."); + fl_color_print(print.to, print.context, "().%c", f_string_eol[0]); } else { - fl_color_print_line(print.to, print.context, "."); + fl_color_print(print.to, print.context, ".%c", f_string_eol[0]); } } @@ -374,149 +374,149 @@ extern "C" { #endif // _di_fake_print_message_ #ifndef _di_fake_print_message_file_ - bool fake_print_message_file(const fake_data_t data, const f_status_t status, const f_string_t function, const f_string_t name, const f_string_t operation, const bool is_file, const bool fallback, const fake_make_print_t print) { + bool fake_print_message_file(const fake_data_t data, const f_status_t status, const f_string_t function, const f_string_t name, const f_string_t operation, const bool is_file, const bool fallback) { const f_string_t file_or_directory = is_file ? "file" : "directory"; if (status == F_file_found_not) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Failed to find %s '", print.prefix, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_file_found) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: The %s '", print.prefix, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "' already exists."); + fl_color_print(print.to, print.context, "' already exists.%c", f_string_eol[0]); } return F_false; } if (status == F_directory_empty_not) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: The %s '", print.prefix, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "' is not empty."); + fl_color_print(print.to, print.context, "' is not empty.%c", f_string_eol[0]); } return F_false; } if (status == F_parameter) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "INTERNAL %s: Invalid parameter when calling ", print.prefix); fl_color_print(print.to, data.context.set.notable, "%s", function); fl_color_print(print.to, print.context, "() for the %s '", file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_name) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Invalid %s name '", print.prefix, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_memory_out) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "CRITICAL %s: Unable to allocate memory, while trying to %s %s '", print.prefix, operation, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_number_overflow) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Overflow while trying to %s %s '", print.prefix, operation, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_directory) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Invalid directory while trying to %s %s '", print.prefix, operation, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_access_denied) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Access denied while trying to %s %s '", print.prefix, operation, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_loop) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Loop while trying to %s %s '", print.prefix, operation, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_prohibited) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Prohibited by system while trying to %s %s '", print.prefix, operation, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_access_owner) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Currrent user is not allowed to use the given owner while trying to %s %s '", print.prefix, operation, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_false; } if (status == F_access_group) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Currrent user is not allowed to use the given group while trying to %s %s '", print.prefix, operation, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_false; @@ -524,11 +524,11 @@ extern "C" { if (is_file) { if (status == F_directory_found_not) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Failed to %s %s '", print.prefix, operation, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "' due to an invalid directory in the path."); + fl_color_print(print.to, print.context, "' due to an invalid directory in the path.%c", f_string_eol[0]); } return F_false; @@ -536,35 +536,35 @@ extern "C" { } else { if (status == F_directory_found_not) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Failed to %s %s '", print.prefix, operation, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "' due to an invalid directory in the path."); + fl_color_print(print.to, print.context, "' due to an invalid directory in the path.%c", f_string_eol[0]); } return F_false; } if (status == F_failure) { - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: Failed to %s %s '", print.prefix, operation, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_false; } } - if (fake_print_error(data, status, function, F_false) == F_unknown && fallback && data.verbosity != f_console_verbosity_quiet) { + if (fake_print_error(data, status, function, F_false) == F_unknown && fallback && data.error.verbosity != f_console_verbosity_quiet) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "UNKNOWN %s: (", print.prefix); fl_color_print(print.to, data.context.set.notable, "%llu", status); fl_color_print(print.to, print.context, ") occurred while trying to %s %s '", operation, file_or_directory); fl_color_print(print.to, data.context.set.notable, "%s", name); - fl_color_print_line(print.to, print.context, "'."); + fl_color_print(print.to, print.context, "'.%c", f_string_eol[0]); } return F_true; @@ -573,7 +573,7 @@ extern "C" { #ifndef _di_fake_print_message_section_operation_failed_ void fake_print_message_section_operation_failed(const fake_data_t data, const f_string_static_t buffer, const f_string_range_t section_name, const f_string_range_t operation_name, const fake_make_print_t print) { - if (data.verbosity == f_console_verbosity_quiet || !print.to) return; + if (data.error.verbosity == f_console_verbosity_quiet || !print.to) return; f_string_length_t line = 1; @@ -594,19 +594,19 @@ extern "C" { fl_color_print(print.to, print.context, "' on line "); fl_color_print(print.to, data.context.set.notable, "%llu", line); - fl_color_print_line(print.to, print.context, " failed."); + fl_color_print(print.to, print.context, " failed.%c", f_string_eol[0]); } #endif // _di_fake_print_message_section_operation_failed_ #ifndef _di_fake_print_message_section_operation_path_outside_ void fake_print_message_section_operation_path_outside(const fake_data_t data, const f_status_t status, const f_string_t function, const f_string_t path, const fake_make_print_t print) { - if (data.verbosity == f_console_verbosity_quiet || !print.to) return; + if (data.error.verbosity == f_console_verbosity_quiet || !print.to) return; if (F_status_set_fine(status) == F_false) { fprintf(print.to, "%c", f_string_eol[0]); fl_color_print(print.to, print.context, "%s: The path '", print.prefix); fl_color_print(print.to, data.context.set.notable, "%s", path); - fl_color_print_line(print.to, print.context, "' is outside the project root."); + fl_color_print(print.to, print.context, "' is outside the project root.%c", f_string_eol[0]); } else { fake_print_error_file(data, status, function, path, "determine real path of", F_true, F_true); @@ -616,7 +616,7 @@ extern "C" { #ifndef _di_fake_print_message_section_operation_path_stack_max_ void fake_print_message_section_operation_path_stack_max(const fake_data_t data, const f_status_t status, const f_string_t function, const f_string_t path, const fake_make_print_t print) { - if (data.verbosity == f_console_verbosity_quiet || !print.to) return; + if (data.error.verbosity == f_console_verbosity_quiet || !print.to) return; if (status == F_buffer_too_large) { fprintf(print.to, "%c", f_string_eol[0]); @@ -630,7 +630,7 @@ extern "C" { fl_color_print(print.to, print.context, "()"); } - fl_color_print_line(print.to, print.context, "."); + fl_color_print(print.to, print.context, ".%c", f_string_eol[0]); } else { fake_print_message_file(data, status, function, path, "change path to", F_false, F_true, print); @@ -640,7 +640,7 @@ extern "C" { #ifndef _di_fake_print_message_section_operation_stack_max_ void fake_print_message_section_operation_stack_max(const fake_data_t data, const f_string_static_t buffer, const f_string_range_t section_name, const f_string_range_t operation_name, const f_array_length_t stack_max, const fake_make_print_t print) { - if (data.verbosity == f_console_verbosity_quiet || !print.to) return; + if (data.error.verbosity == f_console_verbosity_quiet || !print.to) return; f_string_length_t line = 1; @@ -663,13 +663,13 @@ extern "C" { fl_color_print(print.to, data.context.set.notable, "%llu", line); fl_color_print(print.to, print.context, " cannot be processed because the max stack depth of "); fl_color_print(print.to, data.context.set.notable, "%llu", stack_max); - fl_color_print_line(print.to, print.context, " has been reached."); + fl_color_print(print.to, print.context, " has been reached.%c", f_string_eol[0]); } #endif // _di_fake_print_message_section_operation_stack_max_ #ifndef _di_fake_print_message_section_operation_unknown_ void fake_print_message_section_operation_unknown(const fake_data_t data, const f_string_static_t buffer, const f_string_range_t section_name, const f_string_range_t operation_name, const fake_make_print_t print) { - if (data.verbosity == f_console_verbosity_quiet || !print.to) return; + if (data.error.verbosity == f_console_verbosity_quiet || !print.to) return; f_string_length_t line = 1; @@ -690,15 +690,15 @@ extern "C" { fl_color_print(print.to, print.context, "' on line "); fl_color_print(print.to, data.context.set.notable, "%llu", line); - fl_color_print_line(print.to, print.context, " is not a known operation name."); + fl_color_print(print.to, print.context, " is not a known operation name.%c", f_string_eol[0]); } #endif // _di_fake_print_message_section_operation_unknown_ #ifndef _di_fake_print_warning_settings_content_empty_ void fake_print_warning_settings_content_empty(const fake_data_t data, const f_string_t path_file, const f_string_dynamic_t buffer, const f_string_range_t range_object, const f_string_t settings_name) { - if (data.verbosity == f_console_verbosity_quiet) return; + if (data.error.verbosity == f_console_verbosity_quiet) return; - fprintf(f_type_error, "%c", f_string_eol[0]); + dprintf(data.error.to, "%c", f_string_eol[0]); fl_color_print(f_type_warning, data.context.set.warning, "WARNING: the fakefile '"); fl_color_print(f_type_warning, data.context.set.notable, "%s", path_file); @@ -710,15 +710,15 @@ extern "C" { f_print_dynamic_partial(f_type_warning, buffer, range_object); fl_color_print_code(f_type_warning, data.context.reset); - fl_color_print_line(f_type_warning, data.context.set.warning, "'."); + fl_color_print(f_type_warning, data.context.set.warning, "'.%c", f_string_eol[0]); } #endif // _di_fake_print_warning_settings_content_empty_ #ifndef _di_fake_print_warning_settings_content_invalid_ void fake_print_warning_settings_content_invalid(const fake_data_t data, const f_string_t path_file, const f_string_dynamic_t buffer, const f_string_range_t range_object, const f_string_range_t range_content, const f_string_t settings_name) { - if (data.verbosity == f_console_verbosity_quiet) return; + if (data.error.verbosity == f_console_verbosity_quiet) return; - fprintf(f_type_error, "%c", f_string_eol[0]); + dprintf(data.error.to, "%c", f_string_eol[0]); fl_color_print(f_type_warning, data.context.set.warning, "WARNING: the fakefile '"); fl_color_print(f_type_warning, data.context.set.notable, "%s", path_file); @@ -736,37 +736,37 @@ extern "C" { f_print_dynamic_partial(f_type_warning, buffer, range_object); fl_color_print_code(f_type_warning, data.context.reset); - fl_color_print_line(f_type_warning, data.context.set.warning, "'."); + fl_color_print(f_type_warning, data.context.set.warning, "'.%c", f_string_eol[0]); } #endif // _di_fake_print_warning_settings_content_invalid_ #ifndef _di_fake_print_warning_settings_content_multiple_ void fake_print_warning_settings_content_multiple(const fake_data_t data, const f_string_t path_file, const f_string_t name_object) { - if (data.verbosity != f_console_verbosity_verbose) return; + if (data.error.verbosity != f_console_verbosity_verbose) return; - fprintf(f_type_error, "%c", f_string_eol[0]); + dprintf(data.error.to, "%c", f_string_eol[0]); fl_color_print(f_type_warning, data.context.set.warning, "WARNING: the setting '"); fl_color_print(f_type_warning, data.context.set.notable, "%s", name_object); fl_color_print(f_type_warning, data.context.set.warning, "' in the file '"); fl_color_print(f_type_warning, data.context.set.notable, "%s", path_file); - fl_color_print_line(f_type_warning, data.context.set.warning, "' may only have a single property, only using the first."); + fl_color_print(f_type_warning, data.context.set.warning, "' may only have a single property, only using the first.%c", f_string_eol[0]); } #endif // _di_fake_print_warning_settings_content_multiple_ #ifndef _di_fake_print_warning_settings_object_multiple_ void fake_print_warning_settings_object_multiple(const fake_data_t data, const f_string_t path_file, const f_string_t label, const f_string_t name_object) { - if (data.verbosity != f_console_verbosity_verbose) return; + if (data.error.verbosity != f_console_verbosity_verbose) return; - fprintf(f_type_error, "%c", f_string_eol[0]); + dprintf(data.error.to, "%c", f_string_eol[0]); fl_color_print(f_type_warning, data.context.set.warning, "WARNING: the %s object '", label); fl_color_print(f_type_warning, data.context.set.notable, "%s", name_object); fl_color_print(f_type_warning, data.context.set.warning, "' in the file '"); fl_color_print(f_type_warning, data.context.set.notable, "%s", path_file); - fl_color_print_line(f_type_warning, data.context.set.warning, "' may only be specified once, only using the first."); + fl_color_print(f_type_warning, data.context.set.warning, "' may only be specified once, only using the first.%c", f_string_eol[0]); } #endif // _di_fake_print_warning_settings_object_multiple_ diff --git a/level_3/fake/c/private-print.h b/level_3/fake/c/private-print.h index 95c3759..adc644c 100644 --- a/level_3/fake/c/private-print.h +++ b/level_3/fake/c/private-print.h @@ -153,15 +153,13 @@ extern "C" { * Set to 0 to disable. * @param fallback * Set to F_true to print the fallback error message for unknown errors. - * @param print - * Designates how the section error/warning should be printed. * * @return * F_none is returned on successful print of known errors. * F_unknown is returned if the status code has no print message. */ #ifndef _di_fake_print_message_ - extern f_return_status fake_print_message(const fake_data_t data, const f_status_t status, const f_string_t function, const bool fallback, const fake_make_print_t print) f_gcc_attribute_visibility_internal; + extern f_return_status fake_print_message(const fake_data_t data, const f_status_t status, const f_string_t function, const bool fallback) f_gcc_attribute_visibility_internal; #endif // _di_fake_print_message_ /** @@ -191,7 +189,7 @@ extern "C" { * F_false is returned on successful print of known errors. */ #ifndef _di_fake_print_message_file_ - extern bool fake_print_message_file(const fake_data_t data, const f_status_t status, const f_string_t function, const f_string_t name, const f_string_t operation, const bool is_file, const bool fallback, const fake_make_print_t print) f_gcc_attribute_visibility_internal; + extern bool fake_print_message_file(const fake_data_t data, const f_status_t status, const f_string_t function, const f_string_t name, const f_string_t operation, const bool is_file, const bool fallback) f_gcc_attribute_visibility_internal; #endif // _di_fake_print_message_file_ /** diff --git a/level_3/fake/c/private-skeleton.c b/level_3/fake/c/private-skeleton.c index d837e4b..dcf7b88 100644 --- a/level_3/fake/c/private-skeleton.c +++ b/level_3/fake/c/private-skeleton.c @@ -18,9 +18,9 @@ extern "C" { f_status_t status = F_none; - if (data.verbosity != f_console_verbosity_quiet) { + if (data.error.verbosity != f_console_verbosity_quiet) { printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_output, data.context.set.important, "Generating skeleton structure."); + fl_color_print(f_type_output, data.context.set.important, "Generating skeleton structure.%c", f_string_eol[0]); } { @@ -165,7 +165,7 @@ extern "C" { status = f_directory_exists(path.string); if (status == F_true) { - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("Directory '%s' already exists.%c", path.string, f_string_eol[0]); } @@ -173,11 +173,11 @@ extern "C" { } if (status == F_false) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The path '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", path.string); - fl_color_print_line(f_type_error, data.context.set.error, "' exists but is not a directory."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The path '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", path.string); + fl_color_print_to(data.error.to, data.context.set.error, "' exists but is not a directory.%c", f_string_eol[0]); } return F_status_set_warning(F_failure); @@ -187,10 +187,10 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_file_found_not) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The path '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", path.string); - fl_color_print_line(f_type_error, data.context.set.error, "' could not be created, a parent directory does not exist."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The path '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", path.string); + fl_color_print_to(data.error.to, data.context.set.error, "' could not be created, a parent directory does not exist.%c", f_string_eol[0]); } else { fake_print_error_file(data, F_status_set_fine(status), "f_directory_create", path.string, "create", F_false, F_true); @@ -199,7 +199,7 @@ extern "C" { return status; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("Directory '%s' created.%c", path.string, f_string_eol[0]); } } @@ -221,7 +221,7 @@ extern "C" { status = f_file_is(path.string, f_file_type_regular, F_false); if (status == F_true) { - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("File '%s' already exists.%c", path.string, f_string_eol[0]); } @@ -233,7 +233,7 @@ extern "C" { status = f_file_is(path.string, f_file_type_link, F_false); if (status == F_true) { - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("File '%s' already exists (as a symbolic link).%c", path.string, f_string_eol[0]); } @@ -242,7 +242,7 @@ extern "C" { } if (status == F_false) { - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("File '%s' already exists but is not a regular file (or symbolic link).%c", path.string, f_string_eol[0]); } @@ -259,10 +259,10 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_file_found_not) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The file '"); - fl_color_print(f_type_error, data.context.set.notable, "%s", path.string); - fl_color_print_line(f_type_error, data.context.set.error, "' could not be created, a parent directory does not exist."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The file '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s", path.string); + fl_color_print_to(data.error.to, data.context.set.error, "' could not be created, a parent directory does not exist.%c", f_string_eol[0]); } else { fake_print_error_file(data, F_status_set_fine(status), "f_file_create", path.string, "create", F_true, F_true); @@ -271,7 +271,7 @@ extern "C" { return status; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("File '%s' created.%c", path.string, f_string_eol[0]); } @@ -298,7 +298,7 @@ extern "C" { return status; } - if (data.verbosity == f_console_verbosity_verbose) { + if (data.error.verbosity == f_console_verbosity_verbose) { printf("File '%s' pre-populated.%c", path.string, f_string_eol[0]); } diff --git a/level_3/fake/data/build/dependencies b/level_3/fake/data/build/dependencies index 990498c..04a8d94 100644 --- a/level_3/fake/data/build/dependencies +++ b/level_3/fake/data/build/dependencies @@ -26,8 +26,9 @@ fl_iki fl_status fl_string fl_utf -fll_fss +fll_error fll_execute fll_file +fll_fss fll_path fll_program diff --git a/level_3/fake/data/build/settings b/level_3/fake/data/build/settings index 7ba750d..651782d 100644 --- a/level_3/fake/data/build/settings +++ b/level_3/fake/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfll_path -lfll_file -lfll_execute -lfl_environment -lfll_fss -lfl_utf -lfl_string -lfl_status -lfl_iki -lfl_fss -lfl_directory -lfl_conversion -lfl_console -lfl_color -lf_signal -lf_print -lf_path -lf_iki -lf_file -lf_fss -lf_environment -lf_directory -lf_conversion -lf_console -lf_account -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_path -lfll_fss -lfll_file -lfll_execute -lfl_environment -lfll_error -lfl_utf -lfl_string -lfl_status -lfl_iki -lfl_fss -lfl_directory -lfl_conversion -lfl_console -lfl_color -lf_signal -lf_print -lf_path -lf_iki -lf_file -lf_fss -lf_environment -lf_directory -lf_conversion -lf_console -lf_account -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fake.c private-fake.c private-clean.c private-build.c private-make.c private-print.c private-skeleton.c diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index d197c3e..efe110c 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -12,22 +12,26 @@ extern "C" { #endif #ifndef _di_firewall_print_help_ - f_return_status firewall_print_help(const f_color_context_t context) { + f_return_status firewall_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, firewall_name_long, firewall_version); + fll_program_print_help_header(id, context, firewall_name_long, firewall_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); #ifdef _en_firewall_debug_ - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + #endif // _en_firewall_debug_ + + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + + #ifdef _en_firewall_debug_ + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging."); #endif // _en_firewall_debug_ printf("%c%c", f_string_eol[0], f_string_eol[0]); @@ -53,7 +57,7 @@ extern "C" { fl_color_print(f_type_output, context.set.standout, firewall_command_show); printf(" Show active firewall settings"); - fll_program_print_help_usage(context, firewall_name, "command"); + fll_program_print_help_usage(id, context, firewall_name, "command"); return F_none; } @@ -64,29 +68,59 @@ extern "C" { f_status_t status = F_none; { - f_console_parameter_id_t ids[3] = { firewall_parameter_no_color, firewall_parameter_light, firewall_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, firewall_total_parameters); + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { firewall_parameter_no_color, firewall_parameter_light, firewall_parameter_dark }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); + const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, firewall_total_parameters); - if (F_status_is_error(status)) { - firewall_delete_data(data); - return F_status_set_error(status); + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + firewall_delete_data(data); + return F_status_set_error(status); + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { firewall_parameter_verbosity_quiet, firewall_parameter_verbosity_normal, firewall_parameter_verbosity_verbose, firewall_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + firewall_delete_data(data); + return status; + } + + if (choice == firewall_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == firewall_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == firewall_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == firewall_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } if (data->parameters[firewall_parameter_help].result == f_console_result_found) { - firewall_print_help(data->context); + firewall_print_help(data->output, data->context); firewall_delete_data(data); return F_none; } if (data->parameters[firewall_parameter_version].result == f_console_result_found) { - fll_program_print_version(firewall_version); + fll_program_print_version(data->output, firewall_version); firewall_delete_data(data); return F_none; @@ -175,7 +209,7 @@ extern "C" { if (strncmp("nat", arguments.argv[data->remaining.array[counter]], 4) != 0) { if (strncmp("mangle", arguments.argv[data->remaining.array[counter]], 7) != 0) { if (strncmp("ports", arguments.argv[data->remaining.array[counter]], 6) != 0) { - fl_color_print_line(f_type_warning, data->context.set.warning, "WARNING: '%s' is not a valid show option", arguments.argv[data->remaining.array[counter]]); + fl_color_print(f_type_warning, data->context.set.warning, "WARNING: '%s' is not a valid show option%c", arguments.argv[data->remaining.array[counter]], f_string_eol[0]); } else { show_ports = F_true; @@ -194,7 +228,7 @@ extern "C" { f_macro_string_dynamics_resize(status, parameters, 7); if (F_status_is_error(status)) { - fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data->error.to, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); firewall_delete_local_data(&local); firewall_delete_data(data); return status; @@ -203,7 +237,7 @@ extern "C" { if (show_nat) { fl_color_print(f_type_output, data->context.set.standout, "=========================== "); fl_color_print(f_type_output, data->context.set.title, "NAT"); - fl_color_print_line(f_type_output, data->context.set.standout, " ============================"); + fl_color_print(f_type_output, data->context.set.standout, " ============================%c", f_string_eol[0]); fflush(f_type_output); parameters.used = 6; @@ -231,7 +265,7 @@ extern "C" { if (F_status_is_error_not(status) && show_mangle) { fl_color_print(f_type_output, data->context.set.standout, "========================== "); fl_color_print(f_type_output, data->context.set.title, "MANGLE"); - fl_color_print_line(f_type_output, data->context.set.standout, " =========================="); + fl_color_print(f_type_output, data->context.set.standout, " ==========================%c", f_string_eol[0]); fflush(f_type_output); parameters.used = 6; @@ -259,7 +293,7 @@ extern "C" { if (F_status_is_error_not(status) && show_ports) { fl_color_print(f_type_output, data->context.set.standout, "========================== "); fl_color_print(f_type_output, data->context.set.title, "FILTER"); - fl_color_print_line(f_type_output, data->context.set.standout, " =========================="); + fl_color_print(f_type_output, data->context.set.standout, " ==========================%c", f_string_eol[0]); fflush(f_type_output); parameters.used = 4; @@ -284,10 +318,10 @@ extern "C" { status = F_status_set_fine(status); if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data->error.to, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to perform requested %s operation:", firewall_tool_iptables); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to perform requested %s operation:%c", firewall_tool_iptables, f_string_eol[0]); fprintf(f_type_error, " "); f_string_length_t i = 0; @@ -334,13 +368,13 @@ extern "C" { status = F_status_set_fine(status); if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data->error.to, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else if (status == F_data_not) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Could not find any network devices"); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Could not find any network devices%c", f_string_eol[0]); } else if (status == F_failure) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to read the device directory '%s'", network_devices); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to read the device directory '%s'%c", network_devices, f_string_eol[0]); } firewall_delete_local_data(&local); @@ -423,7 +457,7 @@ extern "C" { return status; } else { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to perform lock request because the lock instructions are missing from: %s.", network_path firewall_file_other); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to perform lock request because the lock instructions are missing from: %s.%c", network_path firewall_file_other, f_string_eol[0]); firewall_delete_local_data(&local); firewall_delete_data(data); @@ -463,7 +497,7 @@ extern "C" { } } else { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to perform stop request because the lock instructions are missing from: %s.", network_path firewall_file_other); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to perform stop request because the lock instructions are missing from: %s.", network_path firewall_file_other, f_string_eol[0]); firewall_delete_local_data(&local); firewall_delete_data(data); @@ -541,7 +575,7 @@ extern "C" { f_macro_string_dynamic_t_resize(status, file_path, network_path_length + data->devices.array[i].used + firewall_file_suffix_length + 1); if (F_status_is_error(status)) { - fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data->error.to, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); firewall_delete_local_data(&local); firewall_delete_data(data); return status; @@ -655,7 +689,7 @@ extern "C" { firewall_delete_local_data(&local); } else { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: You did not pass a command"); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: You did not pass a command%c", f_string_eol[0]); status = F_status_set_error(F_parameter); } diff --git a/level_3/firewall/c/firewall.h b/level_3/firewall/c/firewall.h index a4bb6e9..41a963b 100644 --- a/level_3/firewall/c/firewall.h +++ b/level_3/firewall/c/firewall.h @@ -35,6 +35,7 @@ #include // fll-2 includes +#include #include #include #include @@ -209,12 +210,16 @@ extern "C" { firewall_parameter_light, firewall_parameter_dark, firewall_parameter_no_color, - firewall_parameter_version, + firewall_parameter_verbosity_quiet, + firewall_parameter_verbosity_normal, + firewall_parameter_verbosity_verbose, #ifdef _en_firewall_debug_ firewall_parameter_debug, #endif // _en_firewall_debug_ + firewall_parameter_version, + firewall_parameter_command_start, firewall_parameter_command_stop, firewall_parameter_command_restart, @@ -242,12 +247,15 @@ extern "C" { #ifdef _en_firewall_debug_ #define firewall_console_parameter_t_initialize \ { \ - f_console_parameter_t_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, F_false, f_console_type_normal), \ - f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, 0, f_console_type_normal), \ + f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(0, 0, firewall_command_start, F_false, f_console_type_other), \ f_console_parameter_t_initialize(0, 0, firewall_command_stop, F_false, f_console_type_other), \ f_console_parameter_t_initialize(0, 0, firewall_command_restart, F_false, f_console_type_other), \ @@ -255,15 +263,18 @@ extern "C" { f_console_parameter_t_initialize(0, 0, firewall_command_show, F_false, f_console_type_other), \ } - #define firewall_total_parameters 11 + #define firewall_total_parameters 14 #else #define firewall_console_parameter_t_initialize \ { \ - f_console_parameter_t_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, F_false, f_console_type_normal), \ - f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, 0, f_console_type_normal), \ + f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(0, 0, firewall_command_start, F_false, f_console_type_other), \ f_console_parameter_t_initialize(0, 0, firewall_command_stop, F_false, f_console_type_other), \ f_console_parameter_t_initialize(0, 0, firewall_command_restart, F_false, f_console_type_other), \ @@ -271,7 +282,7 @@ extern "C" { f_console_parameter_t_initialize(0, 0, firewall_command_show, F_false, f_console_type_other), \ } - #define firewall_total_parameters 10 + #define firewall_total_parameters 13 #endif // _en_firewall_debug_ #endif // _di_firewall_defines_ @@ -282,7 +293,8 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; f_string_dynamics_t chains; f_string_dynamics_t devices; @@ -295,7 +307,8 @@ extern "C" { firewall_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ f_string_dynamics_t_initialize, \ f_string_dynamics_t_initialize, \ f_color_context_t_initialize, \ @@ -312,7 +325,7 @@ extern "C" { * F_none on success. */ #ifndef _di_firewall_print_help_ - extern f_return_status firewall_print_help(const f_color_context_t context); + extern f_return_status firewall_print_help(const int id, const f_color_context_t context); #endif // _di_firewall_print_help_ /** diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index c2d271b..e3bf0f7 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -310,7 +310,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con fprintf(f_type_warning, "\n"); } else { - fl_color_print_line(f_type_warning, data.context.set.warning, "WARNING: At line %i, the object has no content", i); + fl_color_print(f_type_warning, data.context.set.warning, "WARNING: At line %i, the object has no content%c", i, f_string_eol[0]); } continue; @@ -587,24 +587,24 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); } else if (status == F_file_found_not) { // the file does not have to exist - fl_color_print_line(f_type_warning, data.context.set.warning, "WARNING: Cannot find the file '%.*s'", file_path.used, file_path.string); + fl_color_print(f_type_warning, data.context.set.warning, "WARNING: Cannot find the file '%.*s'%c", file_path.used, file_path.string, f_string_eol[0]); status = F_none; } else if (status == F_file_open) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: Unable to open the file '%.*s'", file_path.used, file_path.string); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Unable to open the file '%.*s'%c", file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: File descriptor error while trying to open the file '%.*s'", file_path.used, file_path.string); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: File descriptor error while trying to open the file '%.*s'%c", file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); } if (status != F_file_found_not) { @@ -622,25 +622,25 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_read()"); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_read()%c", f_string_eol[0]); } else if (status == F_number_overflow) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: Integer overflow while trying to buffer the file '%.*s'", file_path.used, file_path.string); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Integer overflow while trying to buffer the file '%.*s'%c", file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_file_closed) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: The file '%.*s' is no longer open", file_path.used, file_path.string); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: The file '%.*s' is no longer open%c", file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_file_seek) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: A seek error occurred while accessing the file '%.*s'", file_path.used, file_path.string); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: A seek error occurred while accessing the file '%.*s'%c", file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_file_read) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: A read error occurred while accessing the file '%.*s'", file_path.used, file_path.string); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: A read error occurred while accessing the file '%.*s'%c", file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_read()", status); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_read()%c", status, f_string_eol[0]); } status = F_status_set_error(status); @@ -658,16 +658,16 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_read() for the file '%.*s'", file_path.used, file_path.string); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_read() for the file '%.*s'%c", file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_data_not_eos || status == F_data_not || status == F_data_not_stop) { // empty files are to be silently ignored } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_read() for the file '%.*s'", status, file_path.used, file_path.string); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_read() for the file '%.*s'%c", status, file_path.used, file_path.string, f_string_eol[0]); } status = F_status_set_error(status); @@ -700,7 +700,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con } if (F_status_is_error(status)) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); f_macro_string_dynamic_t_delete_simple(ip_list_action); } @@ -721,7 +721,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con f_macro_string_dynamic_t_new(status, ip_argument, ip_length); if (F_status_is_error(status)) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); break; } @@ -749,7 +749,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con status = fll_execute_program((f_string_t) current_tool, arguments, 0, &return_code); if (status == F_failure) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: Failed to perform requested %s operation:", current_tool); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Failed to perform requested %s operation:%c", current_tool, f_string_eol[0]); fprintf(f_type_error, " "); fl_color_print_code(f_type_error, data.context.error); @@ -769,7 +769,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con break; } else if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()%c", f_string_eol[0]); // remove ip_argument from arguments string. f_macro_string_dynamic_t_delete_simple(arguments.array[arguments.used]); @@ -819,7 +819,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con status = fll_execute_program(current_tool, arguments, 0, &return_code); if (status == F_failure) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: Failed to perform requested %s operation:", current_tool); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Failed to perform requested %s operation:%c", current_tool, f_string_eol[0]); fprintf(f_type_error, " "); fl_color_print_code(f_type_error, data.context.error); @@ -834,7 +834,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con break; } else if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()%c", f_string_eol[0]); break; } } @@ -1085,10 +1085,10 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains_t *reserv if (status == F_failure) { if (tool == firewall_program_iptables) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to perform requested %s operation:", firewall_tool_iptables); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to perform requested %s operation:%c", firewall_tool_iptables, f_string_eol[0]); } else if (tool == firewall_program_ip6tables) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to perform requested %s operation:", firewall_tool_ip6tables); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to perform requested %s operation:%c", firewall_tool_ip6tables, f_string_eol[0]); } fprintf(f_type_error, " "); @@ -1109,10 +1109,10 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains_t *reserv fprintf(f_type_error, "\n"); } else if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()%c", status, f_string_eol[0]); } f_macro_string_dynamics_t_delete_simple(arguments); @@ -1169,7 +1169,7 @@ f_return_status firewall_delete_chains(const firewall_data_t data) { status = F_status_set_fine(status); if (status == F_failure) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: Failed to perform requested %s operation:", tools[i]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Failed to perform requested %s operation:%c", tools[i], f_string_eol[0]); fprintf(f_type_error, " "); fl_color_print_code(f_type_error, data.context.error); @@ -1183,10 +1183,10 @@ f_return_status firewall_delete_chains(const firewall_data_t data) { fprintf(f_type_error, "\n"); } else if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()%c", status, f_string_eol[0]); } return status; @@ -1227,7 +1227,7 @@ f_return_status firewall_delete_chains(const firewall_data_t data) { status = F_status_set_fine(status); if (status == F_failure) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: Failed to perform requested %s operation:", tools[i]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Failed to perform requested %s operation:%c", tools[i], f_string_eol[0]); fprintf(f_type_error, " "); fl_color_print_code(f_type_error, data.context.error); @@ -1241,10 +1241,10 @@ f_return_status firewall_delete_chains(const firewall_data_t data) { fprintf(f_type_error, "\n"); } else if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()%c", status, f_string_eol[0]); } return status; @@ -1306,7 +1306,7 @@ f_return_status firewall_default_lock(const firewall_data_t data) { status = F_status_set_fine(status); if (status == F_failure) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: Failed to perform requested %s operation:", tools[j]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Failed to perform requested %s operation:%c", tools[j], f_string_eol[0]); fprintf(f_type_error, " "); fl_color_print_code(f_type_error, data.context.error); @@ -1320,10 +1320,10 @@ f_return_status firewall_default_lock(const firewall_data_t data) { fprintf(f_type_error, "\n"); } else if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()%c", status, f_string_eol[0]); } return status; @@ -1345,26 +1345,26 @@ f_return_status firewall_buffer_rules(const f_string_t filename, const bool opti if (optional) { if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()."); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open().%c", f_string_eol[0]); } else if (status != F_file_found_not && status != F_file_open && status != F_file_descriptor) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().%c", status, f_string_eol[0]); } } else { if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()."); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open().%c", f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'.", filename); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to find the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'.", filename); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to open the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'.", filename); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'.%c", filename, f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().%c", status, f_string_eol[0]); } } @@ -1379,25 +1379,25 @@ f_return_status firewall_buffer_rules(const f_string_t filename, const bool opti status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_read()."); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_read().%c", f_string_eol[0]); } else if (status == F_number_overflow) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Integer overflow while trying to buffer the file '%s'.", filename); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Integer overflow while trying to buffer the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_file_closed) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: The file '%s' is no longer open.", filename); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: The file '%s' is no longer open.%c", filename, f_string_eol[0]); } else if (status == F_file_seek) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: A seek error occurred while accessing the file '%s'.", filename); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: A seek error occurred while accessing the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_file_read) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: A read error occurred while accessing the file '%s'.", filename); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: A read error occurred while accessing the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data->error.to, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_read().", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_read().%c", status, f_string_eol[0]); } return status; @@ -1414,16 +1414,16 @@ f_return_status firewall_buffer_rules(const f_string_t filename, const bool opti status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", filename); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_data_not_eos || status == F_data_not || status == F_data_not_stop) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: No relevant data was found within the file '%s'.", filename); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: No relevant data was found within the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data->error.to, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.", status, filename); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.%c", status, filename, f_string_eol[0]); } return status; @@ -1444,13 +1444,13 @@ f_return_status firewall_process_rules(f_string_range_t *range, firewall_local_d status = F_status_set_fine(status); if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data->error.to, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else if (status == F_failure) { // the error message has already been displayed. } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().%c", status, f_string_eol[0]); } f_macro_fss_objects_t_delete_simple(local->rule_objects); diff --git a/level_3/firewall/c/private-firewall.h b/level_3/firewall/c/private-firewall.h index 8d3e862..7c7980d 100644 --- a/level_3/firewall/c/private-firewall.h +++ b/level_3/firewall/c/private-firewall.h @@ -85,7 +85,7 @@ typedef struct { (structure.array[index].stop - structure.array[index].start) + 1 // TODO: temporarily added, convert this to a function below. -// TODO: also report: fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); +// TODO: also report: fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); #define firewall_macro_append_argument_to_arguments(status, arguments, argument) \ if (arguments.used == arguments.size) { \ f_macro_string_dynamics_resize(status, arguments, arguments.used + firewall_default_allocation_step); \ diff --git a/level_3/firewall/data/build/dependencies b/level_3/firewall/data/build/dependencies index a44bb21..66e5d36 100644 --- a/level_3/firewall/data/build/dependencies +++ b/level_3/firewall/data/build/dependencies @@ -20,6 +20,7 @@ fl_conversion fl_fss fl_status fl_string +fll_error fll_execute fll_fss fll_program diff --git a/level_3/firewall/data/build/settings b/level_3/firewall/data/build/settings index daddf28..88ff580 100644 --- a/level_3/firewall/data/build/settings +++ b/level_3/firewall/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfll_fss -lfll_execute -lfl_environment -lf_signal -lfl_string -lfl_status -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_path -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_fss -lfll_execute -lfl_environment -lf_signal -lfll_error -lfl_string -lfl_status -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_path -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library firewall.c private-firewall.c diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index 9bcfa58..2e5ec42 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -6,33 +6,33 @@ extern "C" { #endif #ifndef _di_fss_basic_list_read_print_help_ - f_return_status fss_basic_list_read_print_help(const f_color_context_t context) { + f_return_status fss_basic_list_read_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, fss_basic_list_read_name_long, fss_basic_list_read_version); + fll_program_print_help_header(id, context, fss_basic_list_read_name_long, fss_basic_list_read_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, fss_basic_list_read_short_at, fss_basic_list_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); - fll_program_print_help_option(context, fss_basic_list_read_short_depth, fss_basic_list_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); - fll_program_print_help_option(context, fss_basic_list_read_short_empty, fss_basic_list_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); - fll_program_print_help_option(context, fss_basic_list_read_short_line, fss_basic_list_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); - fll_program_print_help_option(context, fss_basic_list_read_short_name, fss_basic_list_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); - fll_program_print_help_option(context, fss_basic_list_read_short_object, fss_basic_list_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); - fll_program_print_help_option(context, fss_basic_list_read_short_select, fss_basic_list_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index."); - fll_program_print_help_option(context, fss_basic_list_read_short_total, fss_basic_list_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines."); - fll_program_print_help_option(context, fss_basic_list_read_short_trim, fss_basic_list_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, " Trim object names on select or print."); + fll_program_print_help_option(id, context, fss_basic_list_read_short_at, fss_basic_list_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); + fll_program_print_help_option(id, context, fss_basic_list_read_short_depth, fss_basic_list_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); + fll_program_print_help_option(id, context, fss_basic_list_read_short_empty, fss_basic_list_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); + fll_program_print_help_option(id, context, fss_basic_list_read_short_line, fss_basic_list_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); + fll_program_print_help_option(id, context, fss_basic_list_read_short_name, fss_basic_list_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); + fll_program_print_help_option(id, context, fss_basic_list_read_short_object, fss_basic_list_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); + fll_program_print_help_option(id, context, fss_basic_list_read_short_select, fss_basic_list_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index."); + fll_program_print_help_option(id, context, fss_basic_list_read_short_total, fss_basic_list_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines."); + fll_program_print_help_option(id, context, fss_basic_list_read_short_trim, fss_basic_list_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, " Trim object names on select or print."); - fll_program_print_help_usage(context, fss_basic_list_read_name, "filename(s)"); + fll_program_print_help_usage(id, context, fss_basic_list_read_name, "filename(s)"); fl_color_print(f_type_output, context.set.important, " Notes:"); @@ -131,29 +131,59 @@ extern "C" { f_status_t status = F_none; { - f_console_parameter_id_t ids[3] = { fss_basic_list_read_parameter_no_color, fss_basic_list_read_parameter_light, fss_basic_list_read_parameter_dark }; - const f_console_parameter_ids_t choices = { ids, 3 }; const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_basic_list_read_total_parameters); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { fss_basic_list_read_parameter_no_color, fss_basic_list_read_parameter_light, fss_basic_list_read_parameter_dark }; + const f_console_parameter_ids_t choices = { ids, 3 }; - if (F_status_is_error(status)) { - fss_basic_list_read_delete_data(data); - return F_status_set_error(status); + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + fss_basic_list_read_delete_data(data); + return F_status_set_error(status); + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { fss_basic_list_read_parameter_verbosity_quiet, fss_basic_list_read_parameter_verbosity_normal, fss_basic_list_read_parameter_verbosity_verbose, fss_basic_list_read_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + fss_basic_list_read_delete_data(data); + return status; + } + + if (choice == fss_basic_list_read_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == fss_basic_list_read_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == fss_basic_list_read_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == fss_basic_list_read_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } if (data->parameters[fss_basic_list_read_parameter_help].result == f_console_result_found) { - fss_basic_list_read_print_help(data->context); + fss_basic_list_read_print_help(data->output, data->context); fss_basic_list_read_delete_data(data); return status; } if (data->parameters[fss_basic_list_read_parameter_version].result == f_console_result_found) { - fll_program_print_version(fss_basic_list_read_version); + fll_program_print_version(data->output, fss_basic_list_read_version); fss_basic_list_read_delete_data(data); return status; @@ -161,45 +191,45 @@ extern "C" { if (data->remaining.used > 0 || data->process_pipe) { if (data->parameters[fss_basic_list_read_parameter_at].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_at); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_at); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_basic_list_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_basic_list_read_parameter_depth].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_basic_list_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_basic_list_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a string."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a string.%c", f_string_eol[0]); fss_basic_list_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_basic_list_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_basic_list_read_delete_data(data); return F_status_set_error(F_parameter); @@ -207,22 +237,22 @@ extern "C" { if (data->parameters[fss_basic_list_read_parameter_object].result == f_console_result_found) { if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); fss_basic_list_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_basic_list_read_parameter_select].result == f_console_result_additional) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); fss_basic_list_read_delete_data(data); return F_status_set_error(F_parameter); @@ -231,11 +261,11 @@ extern "C" { if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) { if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_total); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_total); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); fss_basic_list_read_delete_data(data); return F_status_set_error(F_parameter); @@ -270,9 +300,9 @@ extern "C" { } if (data->parameters[fss_basic_list_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter requires a positive number.%c", f_string_eol[0]); macro_fss_basic_list_read_depths_t_delete_simple(depths); fss_basic_list_read_delete_data(data); @@ -369,7 +399,7 @@ extern "C" { macro_fss_basic_list_read_depths_t_delete_simple(depths); } else { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: You failed to specify one or more files."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: You failed to specify one or more files.%c", f_string_eol[0]); status = F_status_set_error(F_parameter); } diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.h b/level_3/fss_basic_list_read/c/fss_basic_list_read.h index b273479..4d1dd3b 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.h +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.h @@ -39,6 +39,7 @@ #include // fll-2 includes +#include #include #include #include @@ -86,6 +87,10 @@ extern "C" { fss_basic_list_read_parameter_light, fss_basic_list_read_parameter_dark, fss_basic_list_read_parameter_no_color, + fss_basic_list_read_parameter_verbosity_quiet, + fss_basic_list_read_parameter_verbosity_normal, + fss_basic_list_read_parameter_verbosity_verbose, + fss_basic_list_read_parameter_verbosity_debug, fss_basic_list_read_parameter_version, fss_basic_list_read_parameter_at, @@ -105,6 +110,10 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_basic_list_read_short_at, fss_basic_list_read_long_at, 0, F_true, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_read_short_depth, fss_basic_list_read_long_depth, 0, F_true, f_console_type_normal), \ @@ -117,7 +126,7 @@ extern "C" { f_console_parameter_t_initialize(fss_basic_list_read_short_trim, fss_basic_list_read_long_trim, 0, F_false, f_console_type_normal), \ } - #define fss_basic_list_read_total_parameters 14 + #define fss_basic_list_read_total_parameters 18 #endif // _di_fss_basic_list_read_defines_ #ifndef _di_fss_basic_list_read_data_t_ @@ -127,7 +136,8 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; f_string_dynamic_t buffer; f_fss_objects_t objects; @@ -142,7 +152,8 @@ extern "C" { fss_basic_list_read_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ f_string_dynamic_t_initialize, \ f_fss_objects_t_initialize, \ f_fss_contents_t_initialize, \ @@ -161,7 +172,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_basic_list_read_print_help_ - extern f_return_status fss_basic_list_read_print_help(const f_color_context_t context); + extern f_return_status fss_basic_list_read_print_help(const int id, const f_color_context_t context); #endif // _di_fss_basic_list_read_print_help_ /** 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 index 05f6fb7..9d4f0c1 100644 --- 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 @@ -9,11 +9,11 @@ extern "C" { void fss_basic_list_read_print_file_error(const f_color_context_t context, const f_string_t function_name, const f_string_t file_name, const f_status_t status) { if (fll_file_error_print(f_type_error, context, function_name, file_name, status) == F_false) { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function_name); - fl_color_print_line(f_type_error, context.set.error, "."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function_name); + fl_color_print_to(data.error.to, context.set.error, ".%c", f_string_eol[0]); } } #endif // _di_fss_basic_list_read_print_file_error_ @@ -22,62 +22,62 @@ extern "C" { void fss_basic_list_read_print_number_argument_error(const f_color_context_t context, const f_string_t function_name, const f_string_t parameter_name, const f_string_t argument, const f_status_t status) { if (status == F_parameter) { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function_name); - fl_color_print_line(f_type_error, context.set.error, "."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function_name); + fl_color_print_to(data.error.to, context.set.error, ".%c", f_string_eol[0]); } else if (status == F_number) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is not a valid number for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is not a valid number for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_underflow) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is too small for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is too small for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_overflow) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is too large for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is too large for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_negative) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is negative, which is not allowed for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is negative, which is not allowed for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_positive) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' contains a '"); - fl_color_print(f_type_error, context.set.notable, "+"); - fl_color_print(f_type_error, context.set.error, "', which is not allowed for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' contains a '"); + fl_color_print_to(data.error.to, context.set.notable, "+"); + fl_color_print_to(data.error.to, context.set.error, "', which is not allowed for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_data_not) { - fl_color_print(f_type_error, context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "' must not be an empty string."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "' must not be an empty string.%c", f_string_eol[0]); } else { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function_name); - fl_color_print(f_type_error, context.set.error, "' for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(f_type_error, context.set.error, "' with the value '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function_name); + fl_color_print_to(data.error.to, context.set.error, "' for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "' with the value '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } } #endif // _di_fss_basic_list_read_print_number_argument_error_ @@ -95,7 +95,7 @@ extern "C" { macro_fss_basic_list_read_depths_t_new(status, (*depths), depth_size); if (F_status_is_error(status)) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); return status; } @@ -177,12 +177,12 @@ extern "C" { // @todo: move error printing into common function. if (status_code == F_memory_allocation || status_code == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else if (status_code == f_string_length_t_size) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: Unable to process '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_trim); - fl_color_print_line(f_type_error, data.context.set.error, "' because the maximum buffer size was reached."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Unable to process '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_trim); + fl_color_print_to(data.error.to, data.context.set.error, "' because the maximum buffer size was reached.%c", f_string_eol[0]); } else { f_string_t function = "fl_string_append"; @@ -191,20 +191,20 @@ extern "C" { function = "fl_string_rip"; } - fl_color_print(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, data.context.set.notable, "%u", status_code); - fl_color_print(f_type_error, data.context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, data.context.set.notable, "%s()", function); - fl_color_print_line(f_type_error, data.context.set.error, "."); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data.error.to, data.context.set.notable, "%u", status_code); + fl_color_print_to(data.error.to, data.context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, data.context.set.notable, "%s()", function); + fl_color_print_to(data.error.to, data.context.set.error, ".%c", f_string_eol[0]); } return status; } if (!depths->array[i].value_name.used) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: The '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); - fl_color_print_line(f_type_error, data.context.set.error, "' must not be an empty string."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); + fl_color_print_to(data.error.to, data.context.set.error, "' must not be an empty string.%c", f_string_eol[0]); return F_status_set_error(F_parameter); } @@ -217,22 +217,22 @@ extern "C" { for (f_array_length_t j = i + 1; j < depths->used; j++) { if (depths->array[i].depth == depths->array[j].depth) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: The value '"); - fl_color_print(f_type_error, data.context.set.notable, "%llu", depths->array[i].depth); - fl_color_print(f_type_error, data.context.set.error, "' may only be specified once for the parameter '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The value '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", depths->array[i].depth); + fl_color_print_to(data.error.to, data.context.set.error, "' may only be specified once for the parameter '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); return F_status_set_error(F_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); - fl_color_print(f_type_error, data.context.set.error, "' may not have the value '"); - fl_color_print(f_type_error, data.context.set.notable, "%llu", depths->array[i].depth); - fl_color_print(f_type_error, data.context.set.error, "' before the value '"); - fl_color_print(f_type_error, data.context.set.notable, "%llu", depths->array[j].depth); - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); + fl_color_print_to(data.error.to, data.context.set.error, "' may not have the value '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", depths->array[i].depth); + fl_color_print_to(data.error.to, data.context.set.error, "' before the value '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", depths->array[j].depth); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); return F_status_set_error(F_parameter); } @@ -259,33 +259,33 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, data->context.set.notable, "fll_fss_basic_list_read()"); - fl_color_print(f_type_error, data->context.set.error, " for the file '"); - fl_color_print(f_type_error, data->context.set.notable, "%s", filename); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print_to(data->error.to, data->context.set.notable, "fll_fss_basic_list_read()"); + fl_color_print_to(data->error.to, data->context.set.error, " for the file '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s", filename); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data->error.to, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else if (status == F_incomplete_utf_stop) { - fl_color_print(f_type_error, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at stop position (at "); - fl_color_print(f_type_error, data->context.set.notable, "%d", input.start); - fl_color_print_line(f_type_error, data->context.set.error, ")."); + fl_color_print_to(data->error.to, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print_to(data->error.to, data->context.set.notable, "%d", input.start); + fl_color_print_to(data->error.to, data->context.set.error, ").%c", f_string_eol[0]); } else if (status == F_incomplete_utf_eos) { - fl_color_print(f_type_error, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at end of string (at "); - fl_color_print(f_type_error, data->context.set.notable, "%d", input.start); - fl_color_print_line(f_type_error, data->context.set.error, ")."); + fl_color_print_to(data->error.to, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print_to(data->error.to, data->context.set.notable, "%d", input.start); + fl_color_print_to(data->error.to, data->context.set.error, ").%c", f_string_eol[0]); } else { - fl_color_print(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, data->context.set.notable, "%u", status); - fl_color_print(f_type_error, data->context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, data->context.set.notable, "fll_fss_basic_list_read()"); - fl_color_print(f_type_error, data->context.set.error, " for the file '"); - fl_color_print(f_type_error, data->context.set.notable, "%s", filename); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data->error.to, data->context.set.notable, "%u", status); + fl_color_print_to(data->error.to, data->context.set.error, ") has occurred while calling "); + fl_color_print_to(data->error.to, data->context.set.notable, "fll_fss_basic_list_read()"); + fl_color_print_to(data->error.to, data->context.set.error, " for the file '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s", filename); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } return F_status_set_error(status); diff --git a/level_3/fss_basic_list_read/data/build/dependencies b/level_3/fss_basic_list_read/data/build/dependencies index c6ca3bc..4f23c89 100644 --- a/level_3/fss_basic_list_read/data/build/dependencies +++ b/level_3/fss_basic_list_read/data/build/dependencies @@ -20,6 +20,7 @@ fl_fss fl_print fl_status fl_string +fll_error fll_execute fll_file fll_fss diff --git a/level_3/fss_basic_list_read/data/build/settings b/level_3/fss_basic_list_read/data/build/settings index b538209..5671dad 100644 --- a/level_3/fss_basic_list_read/data/build/settings +++ b/level_3/fss_basic_list_read/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfll_error -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_basic_list_read.c private-fss_basic_list_read.c 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 index 2a7e386..b8aac94 100644 --- 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 @@ -5,30 +5,30 @@ extern "C" { #endif #ifndef _di_fss_basic_list_write_print_help_ - f_return_status fss_basic_list_write_print_help(const f_color_context_t context) { + f_return_status fss_basic_list_write_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, fss_basic_list_write_name_long, fss_basic_list_write_version); + fll_program_print_help_header(id, context, fss_basic_list_write_name_long, fss_basic_list_write_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, fss_basic_list_write_short_content, fss_basic_list_write_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " The content to output."); - fll_program_print_help_option(context, fss_basic_list_write_short_double, fss_basic_list_write_long_double, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use double quotes (default)."); - fll_program_print_help_option(context, fss_basic_list_write_short_file, fss_basic_list_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to."); - fll_program_print_help_option(context, fss_basic_list_write_short_object, fss_basic_list_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " The object to output."); - fll_program_print_help_option(context, fss_basic_list_write_short_partial, fss_basic_list_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output end of object/content character."); - fll_program_print_help_option(context, fss_basic_list_write_short_single, fss_basic_list_write_long_single, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use single quotes."); + fll_program_print_help_option(id, context, fss_basic_list_write_short_content, fss_basic_list_write_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " The content to output."); + fll_program_print_help_option(id, context, fss_basic_list_write_short_double, fss_basic_list_write_long_double, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use double quotes (default)."); + fll_program_print_help_option(id, context, fss_basic_list_write_short_file, fss_basic_list_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to."); + fll_program_print_help_option(id, context, fss_basic_list_write_short_object, fss_basic_list_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " The object to output."); + fll_program_print_help_option(id, context, fss_basic_list_write_short_partial, fss_basic_list_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output end of object/content character."); + fll_program_print_help_option(id, context, fss_basic_list_write_short_single, fss_basic_list_write_long_single, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use single quotes."); - fll_program_print_help_usage(context, fss_basic_list_write_name, ""); + fll_program_print_help_usage(id, context, fss_basic_list_write_name, ""); return F_none; } @@ -39,29 +39,59 @@ extern "C" { f_status_t status = F_none; { - f_console_parameter_id_t ids[3] = { fss_basic_list_write_parameter_no_color, fss_basic_list_write_parameter_light, fss_basic_list_write_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_basic_list_write_total_parameters); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { fss_basic_list_write_parameter_no_color, fss_basic_list_write_parameter_light, fss_basic_list_write_parameter_dark }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - if (F_status_is_error(status)) { - fss_basic_list_write_delete_data(data); - return F_status_set_error(status); + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + fss_basic_list_write_delete_data(data); + return F_status_set_error(status); + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { fss_basic_list_write_parameter_verbosity_quiet, fss_basic_list_write_parameter_verbosity_normal, fss_basic_list_write_parameter_verbosity_verbose, fss_basic_list_write_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + fss_basic_list_write_delete_data(data); + return status; + } + + if (choice == fss_basic_list_write_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == fss_basic_list_write_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == fss_basic_list_write_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == fss_basic_list_write_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } if (data->parameters[fss_basic_list_write_parameter_help].result == f_console_result_found) { - fss_basic_list_write_print_help(data->context); + fss_basic_list_write_print_help(data->output, data->context); fss_basic_list_write_delete_data(data); return status; } if (data->parameters[fss_basic_list_write_parameter_version].result == f_console_result_found) { - fll_program_print_version(fss_basic_list_write_version); + fll_program_print_version(data->output, fss_basic_list_write_version); fss_basic_list_write_delete_data(data); return status; @@ -85,19 +115,19 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", "-"); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to find the file '%s'%c", "-", f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", "-"); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to open the file '%s'%c", "-", f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", "-"); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'%c", "-", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); @@ -198,19 +228,19 @@ extern "C" { f_file_close(&output.id); if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to find the file '%s'%c", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]], f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to open the file '%s'%c", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]], f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'%c", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]], f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); @@ -225,13 +255,13 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()"); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()%c", f_string_eol[0]); } else if (status == F_file_write) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to write to the file '%s'%c", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]], f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()%c", status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); 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 index 3d2fc3f..d73b087 100644 --- 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 @@ -33,6 +33,7 @@ #include // fll-2 includes +#include #include #include @@ -72,6 +73,10 @@ extern "C" { fss_basic_list_write_parameter_light, fss_basic_list_write_parameter_dark, fss_basic_list_write_parameter_no_color, + fss_basic_list_write_parameter_verbosity_quiet, + fss_basic_list_write_parameter_verbosity_normal, + fss_basic_list_write_parameter_verbosity_verbose, + fss_basic_list_write_parameter_verbosity_debug, fss_basic_list_write_parameter_version, fss_basic_list_write_parameter_content, @@ -88,6 +93,10 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_basic_list_write_short_content, fss_basic_list_write_long_content, 0, F_true, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_write_short_double, fss_basic_list_write_long_double, 0, F_true, f_console_type_normal), \ @@ -97,7 +106,7 @@ extern "C" { f_console_parameter_t_initialize(fss_basic_list_write_short_single, fss_basic_list_write_long_single, 0, F_true, f_console_type_normal), \ } - #define fss_basic_list_write_total_parameters 11 + #define fss_basic_list_write_total_parameters 15 #endif // _di_fss_basic_list_write_defines_ #ifndef _di_fss_basic_list_write_data_t_ @@ -107,7 +116,8 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; f_color_context_t context; } fss_basic_list_write_data_t; @@ -117,7 +127,8 @@ extern "C" { fss_basic_list_write_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ f_color_context_t_initialize, \ } #endif // _di_fss_basic_list_write_data_t_ @@ -132,7 +143,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_basic_list_write_print_help_ - extern f_return_status fss_basic_list_write_print_help(const f_color_context_t context); + extern f_return_status fss_basic_list_write_print_help(const int id, const f_color_context_t context); #endif // _di_fss_basic_list_write_print_help_ /** diff --git a/level_3/fss_basic_list_write/data/build/dependencies b/level_3/fss_basic_list_write/data/build/dependencies index f7149ed..35c97b5 100644 --- a/level_3/fss_basic_list_write/data/build/dependencies +++ b/level_3/fss_basic_list_write/data/build/dependencies @@ -19,6 +19,7 @@ fl_conversion fl_fss fl_status fl_string +fll_error fll_execute fll_file fll_fss diff --git a/level_3/fss_basic_list_write/data/build/settings b/level_3/fss_basic_list_write/data/build/settings index ce7d296..62e08fb 100644 --- a/level_3/fss_basic_list_write/data/build/settings +++ b/level_3/fss_basic_list_write/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfl_string -lfl_status -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfll_error -lfl_string -lfl_status -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_basic_list_write.c diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 31b4294..c5ae37f 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -6,33 +6,33 @@ extern "C" { #endif #ifndef _di_fss_basic_read_print_help_ - f_return_status fss_basic_read_print_help(const f_color_context_t context) { + f_return_status fss_basic_read_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, fss_basic_read_name_long, fss_basic_read_version); + fll_program_print_help_header(id, context, fss_basic_read_name_long, fss_basic_read_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, fss_basic_read_short_at, fss_basic_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); - fll_program_print_help_option(context, fss_basic_read_short_depth, fss_basic_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); - fll_program_print_help_option(context, fss_basic_read_short_empty, fss_basic_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); - fll_program_print_help_option(context, fss_basic_read_short_line, fss_basic_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); - fll_program_print_help_option(context, fss_basic_read_short_name, fss_basic_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); - fll_program_print_help_option(context, fss_basic_read_short_object, fss_basic_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); - fll_program_print_help_option(context, fss_basic_read_short_select, fss_basic_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index."); - fll_program_print_help_option(context, fss_basic_read_short_total, fss_basic_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines."); - fll_program_print_help_option(context, fss_basic_read_short_trim, fss_basic_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, " Trim object names on select or print."); + fll_program_print_help_option(id, context, fss_basic_read_short_at, fss_basic_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); + fll_program_print_help_option(id, context, fss_basic_read_short_depth, fss_basic_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); + fll_program_print_help_option(id, context, fss_basic_read_short_empty, fss_basic_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); + fll_program_print_help_option(id, context, fss_basic_read_short_line, fss_basic_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); + fll_program_print_help_option(id, context, fss_basic_read_short_name, fss_basic_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); + fll_program_print_help_option(id, context, fss_basic_read_short_object, fss_basic_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); + fll_program_print_help_option(id, context, fss_basic_read_short_select, fss_basic_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index."); + fll_program_print_help_option(id, context, fss_basic_read_short_total, fss_basic_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines."); + fll_program_print_help_option(id, context, fss_basic_read_short_trim, fss_basic_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, " Trim object names on select or print."); - fll_program_print_help_usage(context, fss_basic_read_name, "filename(s)"); + fll_program_print_help_usage(id, context, fss_basic_read_name, "filename(s)"); fl_color_print(f_type_output, context.set.important, " Notes:"); @@ -131,29 +131,59 @@ extern "C" { f_status_t status = F_none; { - f_console_parameter_id_t ids[3] = { fss_basic_read_parameter_no_color, fss_basic_read_parameter_light, fss_basic_read_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_basic_read_total_parameters); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { fss_basic_read_parameter_no_color, fss_basic_read_parameter_light, fss_basic_read_parameter_dark }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - if (F_status_is_error(status)) { - fss_basic_read_delete_data(data); - return F_status_set_error(status); + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + fss_basic_read_delete_data(data); + return F_status_set_error(status); + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { fss_basic_read_parameter_verbosity_quiet, fss_basic_read_parameter_verbosity_normal, fss_basic_read_parameter_verbosity_verbose, fss_basic_read_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + fss_basic_read_delete_data(data); + return status; + } + + if (choice == fss_basic_read_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == fss_basic_read_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == fss_basic_read_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == fss_basic_read_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } if (data->parameters[fss_basic_read_parameter_help].result == f_console_result_found) { - fss_basic_read_print_help(data->context); + fss_basic_read_print_help(data->output, data->context); fss_basic_read_delete_data(data); return status; } if (data->parameters[fss_basic_read_parameter_version].result == f_console_result_found) { - fll_program_print_version(fss_basic_read_version); + fll_program_print_version(data->output, fss_basic_read_version); fss_basic_read_delete_data(data); return status; @@ -161,45 +191,45 @@ extern "C" { if (data->remaining.used > 0 || data->process_pipe) { if (data->parameters[fss_basic_read_parameter_at].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_at); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_at); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_basic_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_basic_read_parameter_depth].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_basic_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_basic_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_basic_read_parameter_name].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a string."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a string.%c", f_string_eol[0]); fss_basic_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_basic_read_delete_data(data); return F_status_set_error(F_parameter); @@ -207,22 +237,22 @@ extern "C" { if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_found) { if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter."); fss_basic_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_additional) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); fss_basic_read_delete_data(data); return F_status_set_error(F_parameter); @@ -231,11 +261,11 @@ extern "C" { if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) { if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_total); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_total); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); fss_basic_read_delete_data(data); return F_status_set_error(F_parameter); @@ -270,9 +300,9 @@ extern "C" { } if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter requires a positive number.%c", f_string_eol[0]); macro_fss_basic_read_depths_t_delete_simple(depths); fss_basic_read_delete_data(data); @@ -374,7 +404,7 @@ extern "C" { macro_fss_basic_read_depths_t_delete_simple(depths); } else { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: You failed to specify one or more files."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: You failed to specify one or more files.%c", f_string_eol[0]); status = F_status_set_error(F_parameter); } diff --git a/level_3/fss_basic_read/c/fss_basic_read.h b/level_3/fss_basic_read/c/fss_basic_read.h index 2b2df2a..c6dcefb 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.h +++ b/level_3/fss_basic_read/c/fss_basic_read.h @@ -39,6 +39,7 @@ #include // fll-2 includes +#include #include #include #include @@ -86,6 +87,10 @@ extern "C" { fss_basic_read_parameter_light, fss_basic_read_parameter_dark, fss_basic_read_parameter_no_color, + fss_basic_read_parameter_verbosity_quiet, + fss_basic_read_parameter_verbosity_normal, + fss_basic_read_parameter_verbosity_verbose, + fss_basic_read_parameter_verbosity_debug, fss_basic_read_parameter_version, fss_basic_read_parameter_at, @@ -105,6 +110,10 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_basic_read_short_at, fss_basic_read_long_at, 0, F_true, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_read_short_depth, fss_basic_read_long_depth, 0, F_true, f_console_type_normal), \ @@ -117,7 +126,7 @@ extern "C" { f_console_parameter_t_initialize(fss_basic_read_short_trim, fss_basic_read_long_trim, 0, F_false, f_console_type_normal), \ } - #define fss_basic_read_total_parameters 14 + #define fss_basic_read_total_parameters 18 #endif // _di_fss_basic_read_defines_ #ifndef _di_fss_basic_read_data_t_ @@ -127,7 +136,8 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; f_string_dynamic_t buffer; f_fss_objects_t objects; @@ -142,7 +152,8 @@ extern "C" { fss_basic_read_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ f_string_dynamic_t_initialize, \ f_fss_objects_t_initialize, \ f_fss_contents_t_initialize, \ @@ -161,7 +172,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_basic_read_print_help_ - extern f_return_status fss_basic_read_print_help(const f_color_context_t context); + extern f_return_status fss_basic_read_print_help(const int id, const f_color_context_t context); #endif // _di_fss_basic_read_print_help_ /** 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 index cc7541b..5884619 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.c +++ b/level_3/fss_basic_read/c/private-fss_basic_read.c @@ -9,11 +9,11 @@ extern "C" { void fss_basic_read_print_file_error(const f_color_context_t context, const f_string_t function_name, const f_string_t file_name, const f_status_t status) { if (fll_file_error_print(f_type_error, context, function_name, file_name, status) == F_false) { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function_name); - fl_color_print_line(f_type_error, context.set.error, "."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function_name); + fl_color_print_to(data.error.to, context.set.error, ".%c", f_string_eol[0]); } } #endif // _di_fss_basic_read_print_file_error_ @@ -22,62 +22,62 @@ extern "C" { void fss_basic_read_print_number_argument_error(const f_color_context_t context, const f_string_t function_name, const f_string_t parameter_name, const f_string_t argument, const f_status_t status) { if (status == F_parameter) { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function_name); - fl_color_print_line(f_type_error, context.set.error, "."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function_name); + fl_color_print_to(data.error.to, context.set.error, ".%c", f_string_eol[0]); } else if (status == F_number) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is not a valid number for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is not a valid number for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_underflow) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is too small for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is too small for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_overflow) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is too large for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is too large for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_negative) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is negative, which is not allowed for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is negative, which is not allowed for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_positive) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' contains a '"); - fl_color_print(f_type_error, context.set.notable, "+"); - fl_color_print(f_type_error, context.set.error, "', which is not allowed for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' contains a '"); + fl_color_print_to(data.error.to, context.set.notable, "+"); + fl_color_print_to(data.error.to, context.set.error, "', which is not allowed for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_data_not) { - fl_color_print(f_type_error, context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "' must not be an empty string."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "' must not be an empty string.%c", f_string_eol[0]); } else { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function_name); - fl_color_print(f_type_error, context.set.error, "' for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(f_type_error, context.set.error, "' with the value '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function_name); + fl_color_print_to(data.error.to, context.set.error, "' for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "' with the value '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } } #endif // _di_fss_basic_read_print_number_argument_error_ @@ -96,7 +96,7 @@ extern "C" { macro_fss_basic_read_depths_t_new(status, (*depths), depth_size); if (F_status_is_error(status)) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); return status; } @@ -180,12 +180,12 @@ extern "C" { // @todo: move error printing into common function. if (status_code == F_memory_allocation || status_code == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else if (status_code == f_string_length_t_size) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: Unable to process '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_trim); - fl_color_print_line(f_type_error, data.context.set.error, "' because the maximum buffer size was reached."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Unable to process '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_trim); + fl_color_print_to(data.error.to, data.context.set.error, "' because the maximum buffer size was reached.%c", f_string_eol[0]); } else { f_string_t function = "fl_string_append"; @@ -194,20 +194,20 @@ extern "C" { function = "fl_string_rip"; } - fl_color_print(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, data.context.set.notable, "%u", status_code); - fl_color_print(f_type_error, data.context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, data.context.set.notable, "%s()", function); - fl_color_print_line(f_type_error, data.context.set.error, "."); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data.error.to, data.context.set.notable, "%u", status_code); + fl_color_print_to(data.error.to, data.context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, data.context.set.notable, "%s()", function); + fl_color_print_to(data.error.to, data.context.set.error, ".%c", f_string_eol[0]); } return status; } if (!depths->array[i].value_name.used) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: The '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); - fl_color_print_line(f_type_error, data.context.set.error, "' must not be an empty string."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); + fl_color_print_to(data.error.to, data.context.set.error, "' must not be an empty string.%c", f_string_eol[0]); return F_status_set_error(F_parameter); } @@ -220,22 +220,22 @@ extern "C" { for (f_array_length_t j = i + 1; j < depths->used; j++) { if (depths->array[i].depth == depths->array[j].depth) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: The value '"); - fl_color_print(f_type_error, data.context.set.notable, "%llu", depths->array[i].depth); - fl_color_print(f_type_error, data.context.set.error, "' may only be specified once for the parameter '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The value '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", depths->array[i].depth); + fl_color_print_to(data.error.to, data.context.set.error, "' may only be specified once for the parameter '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); return F_status_set_error(F_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); - fl_color_print(f_type_error, data.context.set.error, "' may not have the value '"); - fl_color_print(f_type_error, data.context.set.notable, "%llu", depths->array[i].depth); - fl_color_print(f_type_error, data.context.set.error, "' before the value '"); - fl_color_print(f_type_error, data.context.set.notable, "%llu", depths->array[j].depth); - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); + fl_color_print_to(data.error.to, data.context.set.error, "' may not have the value '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", depths->array[i].depth); + fl_color_print_to(data.error.to, data.context.set.error, "' before the value '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", depths->array[j].depth); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); return F_status_set_error(F_parameter); } @@ -262,33 +262,33 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, data->context.set.notable, "fll_fss_basic_list_read()"); - fl_color_print(f_type_error, data->context.set.error, " for the file '"); - fl_color_print(f_type_error, data->context.set.notable, "%s", filename); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print_to(data->error.to, data->context.set.notable, "fll_fss_basic_list_read()"); + fl_color_print_to(data->error.to, data->context.set.error, " for the file '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s", filename); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data->error.to, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else if (status == F_incomplete_utf_stop) { - fl_color_print(f_type_error, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at stop position (at "); - fl_color_print(f_type_error, data->context.set.notable, "%d", input.start); - fl_color_print_line(f_type_error, data->context.set.error, ")."); + fl_color_print_to(data->error.to, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print_to(data->error.to, data->context.set.notable, "%d", input.start); + fl_color_print_to(data->error.to, data->context.set.error, ").%c", f_string_eol[0]); } else if (status == F_incomplete_utf_eos) { - fl_color_print(f_type_error, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at end of string (at "); - fl_color_print(f_type_error, data->context.set.notable, "%d", input.start); - fl_color_print_line(f_type_error, data->context.set.error, ")."); + fl_color_print_to(data->error.to, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print_to(data->error.to, data->context.set.notable, "%d", input.start); + fl_color_print_to(data->error.to, data->context.set.error, ").%c", f_string_eol[0]); } else { - fl_color_print(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, data->context.set.notable, "%u", status); - fl_color_print(f_type_error, data->context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, data->context.set.notable, "fll_fss_basic_list_read()"); - fl_color_print(f_type_error, data->context.set.error, " for the file '"); - fl_color_print(f_type_error, data->context.set.notable, "%s", filename); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data->error.to, data->context.set.notable, "%u", status); + fl_color_print_to(data->error.to, data->context.set.error, ") has occurred while calling "); + fl_color_print_to(data->error.to, data->context.set.notable, "fll_fss_basic_list_read()"); + fl_color_print_to(data->error.to, data->context.set.error, " for the file '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s", filename); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } return F_status_set_error(status); diff --git a/level_3/fss_basic_read/data/build/dependencies b/level_3/fss_basic_read/data/build/dependencies index c6ca3bc..4f23c89 100644 --- a/level_3/fss_basic_read/data/build/dependencies +++ b/level_3/fss_basic_read/data/build/dependencies @@ -20,6 +20,7 @@ fl_fss fl_print fl_status fl_string +fll_error fll_execute fll_file fll_fss diff --git a/level_3/fss_basic_read/data/build/settings b/level_3/fss_basic_read/data/build/settings index 1a718f9..9ba364a 100644 --- a/level_3/fss_basic_read/data/build/settings +++ b/level_3/fss_basic_read/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfll_error -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_basic_read.c private-fss_basic_read.c diff --git a/level_3/fss_basic_write/c/fss_basic_write.c b/level_3/fss_basic_write/c/fss_basic_write.c index 9157a7e..b90e231 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -5,30 +5,30 @@ extern "C" { #endif #ifndef _di_fss_basic_write_print_help_ - f_return_status fss_basic_write_print_help(const f_color_context_t context) { + f_return_status fss_basic_write_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, fss_basic_write_name_long, fss_basic_write_version); + fll_program_print_help_header(id, context, fss_basic_write_name_long, fss_basic_write_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, fss_basic_write_short_content, fss_basic_write_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " The content to output."); - fll_program_print_help_option(context, fss_basic_write_short_double, fss_basic_write_long_double, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use double quotes (default)."); - fll_program_print_help_option(context, fss_basic_write_short_file, fss_basic_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to."); - fll_program_print_help_option(context, fss_basic_write_short_object, fss_basic_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " The object to output."); - fll_program_print_help_option(context, fss_basic_write_short_partial, fss_basic_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output end of object/content character."); - fll_program_print_help_option(context, fss_basic_write_short_single, fss_basic_write_long_single, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use single quotes."); + fll_program_print_help_option(id, context, fss_basic_write_short_content, fss_basic_write_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " The content to output."); + fll_program_print_help_option(id, context, fss_basic_write_short_double, fss_basic_write_long_double, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use double quotes (default)."); + fll_program_print_help_option(id, context, fss_basic_write_short_file, fss_basic_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to."); + fll_program_print_help_option(id, context, fss_basic_write_short_object, fss_basic_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " The object to output."); + fll_program_print_help_option(id, context, fss_basic_write_short_partial, fss_basic_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output end of object/content character."); + fll_program_print_help_option(id, context, fss_basic_write_short_single, fss_basic_write_long_single, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use single quotes."); - fll_program_print_help_usage(context, fss_basic_write_name, ""); + fll_program_print_help_usage(id, context, fss_basic_write_name, ""); return F_none; } @@ -39,29 +39,59 @@ extern "C" { f_status_t status = F_none; { - f_console_parameter_id_t ids[3] = { fss_basic_write_parameter_no_color, fss_basic_write_parameter_light, fss_basic_write_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_basic_write_total_parameters); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { fss_basic_write_parameter_no_color, fss_basic_write_parameter_light, fss_basic_write_parameter_dark }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - if (F_status_is_error(status)) { - fss_basic_write_delete_data(data); - return status; + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + fss_basic_write_delete_data(data); + return status; + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { fss_basic_write_parameter_verbosity_quiet, fss_basic_write_parameter_verbosity_normal, fss_basic_write_parameter_verbosity_verbose, fss_basic_write_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + fss_basic_write_delete_data(data); + return status; + } + + if (choice == fss_basic_write_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == fss_basic_write_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == fss_basic_write_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == fss_basic_write_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } if (data->parameters[fss_basic_write_parameter_help].result == f_console_result_found) { - fss_basic_write_print_help(data->context); + fss_basic_write_print_help(data->output, data->context); fss_basic_write_delete_data(data); return status; } if (data->parameters[fss_basic_write_parameter_version].result == f_console_result_found) { - fll_program_print_version(fss_basic_write_version); + fll_program_print_version(data->output, fss_basic_write_version); fss_basic_write_delete_data(data); return status; @@ -85,19 +115,19 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", "-"); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to find the file '%s'%c", "-", f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", "-"); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to open the file '%s'%c", "-", f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", "-"); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'%c", "-", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(input); @@ -187,19 +217,19 @@ extern "C" { f_file_close(&output.id); if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to find the file '%s'%c", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]], f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to open the file '%s'%c", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]], f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'%c", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]], f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); @@ -214,13 +244,13 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()"); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()%c", f_string_eol[0]); } else if (status == F_file_write) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to write to the file '%s'%c", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]], f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()%c", status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); diff --git a/level_3/fss_basic_write/c/fss_basic_write.h b/level_3/fss_basic_write/c/fss_basic_write.h index 609309f..46e3ae6 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.h +++ b/level_3/fss_basic_write/c/fss_basic_write.h @@ -32,6 +32,7 @@ #include // fll-2 includes +#include #include #include @@ -71,6 +72,10 @@ extern "C" { fss_basic_write_parameter_light, fss_basic_write_parameter_dark, fss_basic_write_parameter_no_color, + fss_basic_write_parameter_verbosity_quiet, + fss_basic_write_parameter_verbosity_normal, + fss_basic_write_parameter_verbosity_verbose, + fss_basic_write_parameter_verbosity_debug, fss_basic_write_parameter_version, fss_basic_write_parameter_content, @@ -87,6 +92,10 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_basic_write_short_content, fss_basic_write_long_content, 0, F_true, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_write_short_double, fss_basic_write_long_double, 0, F_true, f_console_type_normal), \ @@ -96,7 +105,7 @@ extern "C" { f_console_parameter_t_initialize(fss_basic_write_short_single, fss_basic_write_long_single, 0, F_true, f_console_type_normal), \ } - #define fss_basic_write_total_parameters 11 + #define fss_basic_write_total_parameters 15 #endif // _di_fss_basic_write_defines_ #ifndef _di_fss_basic_write_data_ @@ -106,7 +115,8 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; f_color_context_t context; } fss_basic_write_data; @@ -116,7 +126,8 @@ extern "C" { fss_basic_write_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ f_color_context_t_initialize, \ } #endif // _di_fss_basic_write_data_ @@ -131,7 +142,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_basic_write_print_help_ - extern f_return_status fss_basic_write_print_help(const f_color_context_t context); + extern f_return_status fss_basic_write_print_help(const int id, const f_color_context_t context); #endif // _di_fss_basic_write_print_help_ /** diff --git a/level_3/fss_basic_write/data/build/dependencies b/level_3/fss_basic_write/data/build/dependencies index f7149ed..35c97b5 100644 --- a/level_3/fss_basic_write/data/build/dependencies +++ b/level_3/fss_basic_write/data/build/dependencies @@ -19,6 +19,7 @@ fl_conversion fl_fss fl_status fl_string +fll_error fll_execute fll_file fll_fss diff --git a/level_3/fss_basic_write/data/build/settings b/level_3/fss_basic_write/data/build/settings index 3a7ecff..6f07cfa 100644 --- a/level_3/fss_basic_write/data/build/settings +++ b/level_3/fss_basic_write/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfl_string -lfl_status -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfll_error -lfl_string -lfl_status -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_basic_write.c diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index 17efb54..2612c0f 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -6,33 +6,33 @@ extern "C" { #endif #ifndef _di_fss_extended_list_read_print_help_ - f_return_status fss_extended_list_read_print_help(const f_color_context_t context) { + f_return_status fss_extended_list_read_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, fss_extended_list_read_name_long, fss_extended_list_read_version); + fll_program_print_help_header(id, context, fss_extended_list_read_name_long, fss_extended_list_read_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, fss_extended_list_read_short_at, fss_extended_list_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); - fll_program_print_help_option(context, fss_extended_list_read_short_depth, fss_extended_list_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); - fll_program_print_help_option(context, fss_extended_list_read_short_empty, fss_extended_list_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); - fll_program_print_help_option(context, fss_extended_list_read_short_line, fss_extended_list_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); - fll_program_print_help_option(context, fss_extended_list_read_short_name, fss_extended_list_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); - fll_program_print_help_option(context, fss_extended_list_read_short_object, fss_extended_list_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); - fll_program_print_help_option(context, fss_extended_list_read_short_select, fss_extended_list_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index."); - fll_program_print_help_option(context, fss_extended_list_read_short_total, fss_extended_list_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines."); - fll_program_print_help_option(context, fss_extended_list_read_short_trim, fss_extended_list_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, " Trim object names on select or print."); + fll_program_print_help_option(id, context, fss_extended_list_read_short_at, fss_extended_list_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); + fll_program_print_help_option(id, context, fss_extended_list_read_short_depth, fss_extended_list_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); + fll_program_print_help_option(id, context, fss_extended_list_read_short_empty, fss_extended_list_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); + fll_program_print_help_option(id, context, fss_extended_list_read_short_line, fss_extended_list_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); + fll_program_print_help_option(id, context, fss_extended_list_read_short_name, fss_extended_list_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); + fll_program_print_help_option(id, context, fss_extended_list_read_short_object, fss_extended_list_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); + fll_program_print_help_option(id, context, fss_extended_list_read_short_select, fss_extended_list_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index."); + fll_program_print_help_option(id, context, fss_extended_list_read_short_total, fss_extended_list_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines."); + fll_program_print_help_option(id, context, fss_extended_list_read_short_trim, fss_extended_list_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, " Trim object names on select or print."); - fll_program_print_help_usage(context, fss_extended_list_read_name, "filename(s)"); + fll_program_print_help_usage(id, context, fss_extended_list_read_name, "filename(s)"); fl_color_print(f_type_output, context.set.important, " Notes:"); @@ -131,29 +131,59 @@ extern "C" { f_status_t status = F_none; { - f_console_parameter_id_t ids[3] = { fss_extended_list_read_parameter_no_color, fss_extended_list_read_parameter_light, fss_extended_list_read_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_extended_list_read_total_parameters); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { fss_extended_list_read_parameter_no_color, fss_extended_list_read_parameter_light, fss_extended_list_read_parameter_dark }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - if (F_status_is_error(status)) { - fss_extended_list_read_delete_data(data); - return F_status_set_error(status); + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + fss_extended_list_read_delete_data(data); + return F_status_set_error(status); + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { fss_extended_list_read_parameter_verbosity_quiet, fss_extended_list_read_parameter_verbosity_normal, fss_extended_list_read_parameter_verbosity_verbose, fss_extended_list_read_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + fss_extended_list_read_delete_data(data); + return status; + } + + if (choice == fss_extended_list_read_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == fss_extended_list_read_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == fss_extended_list_read_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == fss_extended_list_read_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } if (data->parameters[fss_extended_list_read_parameter_help].result == f_console_result_found) { - fss_extended_list_read_print_help(data->context); + fss_extended_list_read_print_help(data->output, data->context); fss_extended_list_write_delete_data(data); return F_none; } if (data->parameters[fss_extended_list_read_parameter_version].result == f_console_result_found) { - fll_program_print_version(fss_extended_list_read_version); + fll_program_print_version(data->output, fss_extended_list_read_version); fss_extended_list_write_delete_data(data); return F_none; @@ -161,45 +191,45 @@ extern "C" { if (data->remaining.used > 0 || data->process_pipe) { if (data->parameters[fss_extended_list_read_parameter_at].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_at); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_at); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_extended_list_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_extended_list_read_parameter_depth].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_extended_list_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_extended_list_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_extended_list_read_parameter_name].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a string."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a string.%c", f_string_eol[0]); fss_extended_list_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_extended_list_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_extended_list_read_delete_data(data); return F_status_set_error(F_parameter); @@ -207,22 +237,22 @@ extern "C" { if (data->parameters[fss_extended_list_read_parameter_object].result == f_console_result_found) { if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); fss_extended_list_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_extended_list_read_parameter_select].result == f_console_result_additional) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); fss_extended_list_read_delete_data(data); return F_status_set_error(F_parameter); @@ -231,11 +261,11 @@ extern "C" { if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) { if (data->parameters[fss_extended_list_read_parameter_total].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_total); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_total); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); fss_extended_list_read_delete_data(data); return F_status_set_error(F_parameter); @@ -256,9 +286,9 @@ extern "C" { } if (data->parameters[fss_extended_list_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter requires a positive number.%c", f_string_eol[0]); macro_fss_extended_list_read_depths_t_delete_simple(depths); fss_extended_list_read_delete_data(data); @@ -357,7 +387,7 @@ extern "C" { macro_fss_extended_list_read_depths_t_delete_simple(depths); } else { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: You failed to specify one or more files."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: You failed to specify one or more files.%c", f_string_eol[0]); status = F_status_set_error(F_parameter); } diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.h b/level_3/fss_extended_list_read/c/fss_extended_list_read.h index 9c7fed3..72109a8 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.h +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.h @@ -39,6 +39,7 @@ #include // fll-2 includes +#include #include #include #include @@ -86,6 +87,10 @@ extern "C" { fss_extended_list_read_parameter_light, fss_extended_list_read_parameter_dark, fss_extended_list_read_parameter_no_color, + fss_extended_list_read_parameter_verbosity_quiet, + fss_extended_list_read_parameter_verbosity_normal, + fss_extended_list_read_parameter_verbosity_verbose, + fss_extended_list_read_parameter_verbosity_debug, fss_extended_list_read_parameter_version, fss_extended_list_read_parameter_at, @@ -105,6 +110,10 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_extended_list_read_short_at, fss_extended_list_read_long_at, 0, F_true, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_list_read_short_depth, fss_extended_list_read_long_depth, 0, F_true, f_console_type_normal), \ @@ -117,7 +126,7 @@ extern "C" { f_console_parameter_t_initialize(fss_extended_list_read_short_trim, fss_extended_list_read_long_trim, 0, F_false, f_console_type_normal), \ } - #define fss_extended_list_read_total_parameters 14 + #define fss_extended_list_read_total_parameters 18 #endif // _di_fss_extended_list_read_defines_ #ifndef _di_fss_extended_list_read_data_t_ @@ -127,7 +136,8 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; f_string_dynamic_t buffer; f_fss_nest_t nest; @@ -141,7 +151,8 @@ extern "C" { fss_extended_list_read_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ f_string_dynamic_t_initialize, \ f_fss_nest_t_initialize, \ f_string_quantity_t_initialize, \ @@ -159,7 +170,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_extended_list_read_print_help_ - extern f_return_status fss_extended_list_read_print_help(const f_color_context_t context); + extern f_return_status fss_extended_list_read_print_help(const int id, const f_color_context_t context); #endif // _di_fss_extended_list_read_print_help_ /** diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c index e8fa198..2f04be0 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c @@ -9,11 +9,11 @@ extern "C" { void fss_extended_list_read_print_file_error(const f_color_context_t context, const f_string_t function_name, const f_string_t file_name, const f_status_t status) { if (fll_file_error_print(f_type_error, context, function_name, file_name, status) == F_false) { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function_name); - fl_color_print_line(f_type_error, context.set.error, "."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function_name); + fl_color_print_to(data.error.to, context.set.error, ".%c", f_string_eol[0]); } } #endif // _di_fss_extended_list_read_print_file_error_ @@ -22,62 +22,62 @@ extern "C" { void fss_extended_list_read_print_number_argument_error(const f_color_context_t context, const f_string_t function_name, const f_string_t parameter_name, const f_string_t argument, const f_status_t status) { if (status == F_parameter) { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function_name); - fl_color_print_line(f_type_error, context.set.error, "."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function_name); + fl_color_print_to(data.error.to, context.set.error, ".%c", f_string_eol[0]); } else if (status == F_number) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is not a valid number for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is not a valid number for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_underflow) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is too small for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is too small for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_overflow) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is too large for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is too large for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_negative) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is negative, which is not allowed for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is negative, which is not allowed for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_positive) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' contains a '"); - fl_color_print(f_type_error, context.set.notable, "+"); - fl_color_print(f_type_error, context.set.error, "', which is not allowed for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' contains a '"); + fl_color_print_to(data.error.to, context.set.notable, "+"); + fl_color_print_to(data.error.to, context.set.error, "', which is not allowed for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_data_not) { - fl_color_print(f_type_error, context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "' must not be an empty string."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "' must not be an empty string.%c", f_string_eol[0]); } else { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function_name); - fl_color_print(f_type_error, context.set.error, "' for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(f_type_error, context.set.error, "' with the value '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function_name); + fl_color_print_to(data.error.to, context.set.error, "' for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "' with the value '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } } #endif // _di_fss_extended_list_read_print_number_argument_error_ @@ -96,7 +96,7 @@ extern "C" { macro_fss_extended_list_read_depths_t_new(status, (*depths), depth_size); if (F_status_is_error(status)) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); return status; } @@ -180,12 +180,12 @@ extern "C" { // @todo: move error printing into common function. if (status_code == F_memory_allocation || status_code == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else if (status_code == f_string_length_t_size) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: Unable to process '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_trim); - fl_color_print_line(f_type_error, data.context.set.error, "' because the maximum buffer size was reached."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Unable to process '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_trim); + fl_color_print_to(data.error.to, data.context.set.error, "' because the maximum buffer size was reached.%c", f_string_eol[0]); } else { f_string_t function = "fl_string_append"; @@ -194,20 +194,20 @@ extern "C" { function = "fl_string_rip"; } - fl_color_print(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, data.context.set.notable, "%u", status_code); - fl_color_print(f_type_error, data.context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, data.context.set.notable, "%s()", function); - fl_color_print_line(f_type_error, data.context.set.error, "."); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data.error.to, data.context.set.notable, "%u", status_code); + fl_color_print_to(data.error.to, data.context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, data.context.set.notable, "%s()", function); + fl_color_print_to(data.error.to, data.context.set.error, ".%c", f_string_eol[0]); } return status; } if (!depths->array[i].value_name.used) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: The '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); - fl_color_print_line(f_type_error, data.context.set.error, "' must not be an empty string."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); + fl_color_print_to(data.error.to, data.context.set.error, "' must not be an empty string.%c", f_string_eol[0]); return F_status_set_error(F_parameter); } @@ -220,22 +220,22 @@ extern "C" { for (f_array_length_t j = i + 1; j < depths->used; j++) { if (depths->array[i].depth == depths->array[j].depth) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: The value '"); - fl_color_print(f_type_error, data.context.set.notable, "%llu", depths->array[i].depth); - fl_color_print(f_type_error, data.context.set.error, "' may only be specified once for the parameter '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The value '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", depths->array[i].depth); + fl_color_print_to(data.error.to, data.context.set.error, "' may only be specified once for the parameter '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); return F_status_set_error(F_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); - fl_color_print(f_type_error, data.context.set.error, "' may not have the value '"); - fl_color_print(f_type_error, data.context.set.notable, "%llu", depths->array[i].depth); - fl_color_print(f_type_error, data.context.set.error, "' before the value '"); - fl_color_print(f_type_error, data.context.set.notable, "%llu", depths->array[j].depth); - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); + fl_color_print_to(data.error.to, data.context.set.error, "' may not have the value '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", depths->array[i].depth); + fl_color_print_to(data.error.to, data.context.set.error, "' before the value '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", depths->array[j].depth); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); return F_status_set_error(F_parameter); } @@ -262,33 +262,33 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, data->context.set.notable, "fll_fss_extended_list_read()"); - fl_color_print(f_type_error, data->context.set.error, " for the file '"); - fl_color_print(f_type_error, data->context.set.notable, "%s", filename); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print_to(data->error.to, data->context.set.notable, "fll_fss_extended_list_read()"); + fl_color_print_to(data->error.to, data->context.set.error, " for the file '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s", filename); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data->error.to, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else if (status == F_incomplete_utf_stop) { - fl_color_print(f_type_error, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at stop position (at "); - fl_color_print(f_type_error, data->context.set.notable, "%d", input.start); - fl_color_print_line(f_type_error, data->context.set.error, ")."); + fl_color_print_to(data->error.to, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print_to(data->error.to, data->context.set.notable, "%d", input.start); + fl_color_print_to(data->error.to, data->context.set.error, ").%c", f_string_eol[0]); } else if (status == F_incomplete_utf_eos) { - fl_color_print(f_type_error, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at end of string (at "); - fl_color_print(f_type_error, data->context.set.notable, "%d", input.start); - fl_color_print_line(f_type_error, data->context.set.error, ")."); + fl_color_print_to(data->error.to, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print_to(data->error.to, data->context.set.notable, "%d", input.start); + fl_color_print_to(data->error.to, data->context.set.error, ").%c", f_string_eol[0]); } else { - fl_color_print(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, data->context.set.notable, "%u", status); - fl_color_print(f_type_error, data->context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, data->context.set.notable, "fll_fss_extended_list_read()"); - fl_color_print(f_type_error, data->context.set.error, " for the file '"); - fl_color_print(f_type_error, data->context.set.notable, "%s", filename); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data->error.to, data->context.set.notable, "%u", status); + fl_color_print_to(data->error.to, data->context.set.error, ") has occurred while calling "); + fl_color_print_to(data->error.to, data->context.set.notable, "fll_fss_extended_list_read()"); + fl_color_print_to(data->error.to, data->context.set.error, " for the file '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s", filename); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } return F_status_set_error(status); diff --git a/level_3/fss_extended_list_read/data/build/dependencies b/level_3/fss_extended_list_read/data/build/dependencies index c6ca3bc..4f23c89 100644 --- a/level_3/fss_extended_list_read/data/build/dependencies +++ b/level_3/fss_extended_list_read/data/build/dependencies @@ -20,6 +20,7 @@ fl_fss fl_print fl_status fl_string +fll_error fll_execute fll_file fll_fss diff --git a/level_3/fss_extended_list_read/data/build/settings b/level_3/fss_extended_list_read/data/build/settings index 842bd5b..afaaaeb 100644 --- a/level_3/fss_extended_list_read/data/build/settings +++ b/level_3/fss_extended_list_read/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfll_error -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_extended_list_read.c private-fss_extended_list_read.c diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index 790d213..51e7488 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -6,33 +6,33 @@ extern "C" { #endif #ifndef _di_fss_extended_read_print_help_ - f_return_status fss_extended_read_print_help(const f_color_context_t context) { + f_return_status fss_extended_read_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, fss_extended_read_name_long, fss_extended_read_version); + fll_program_print_help_header(id, context, fss_extended_read_name_long, fss_extended_read_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, fss_extended_read_short_at, fss_extended_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); - fll_program_print_help_option(context, fss_extended_read_short_depth, fss_extended_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); - fll_program_print_help_option(context, fss_extended_read_short_empty, fss_extended_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); - fll_program_print_help_option(context, fss_extended_read_short_line, fss_extended_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); - fll_program_print_help_option(context, fss_extended_read_short_name, fss_extended_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); - fll_program_print_help_option(context, fss_extended_read_short_object, fss_extended_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); - fll_program_print_help_option(context, fss_extended_read_short_select, fss_extended_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index."); - fll_program_print_help_option(context, fss_extended_read_short_total, fss_extended_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines."); - fll_program_print_help_option(context, fss_extended_read_short_trim, fss_extended_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, " Trim object names on select or print."); + fll_program_print_help_option(id, context, fss_extended_read_short_at, fss_extended_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); + fll_program_print_help_option(id, context, fss_extended_read_short_depth, fss_extended_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); + fll_program_print_help_option(id, context, fss_extended_read_short_empty, fss_extended_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); + fll_program_print_help_option(id, context, fss_extended_read_short_line, fss_extended_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); + fll_program_print_help_option(id, context, fss_extended_read_short_name, fss_extended_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); + fll_program_print_help_option(id, context, fss_extended_read_short_object, fss_extended_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); + fll_program_print_help_option(id, context, fss_extended_read_short_select, fss_extended_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index."); + fll_program_print_help_option(id, context, fss_extended_read_short_total, fss_extended_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines."); + fll_program_print_help_option(id, context, fss_extended_read_short_trim, fss_extended_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, " Trim object names on select or print."); - fll_program_print_help_usage(context, fss_extended_read_name, "filename(s)"); + fll_program_print_help_usage(id, context, fss_extended_read_name, "filename(s)"); fl_color_print(f_type_output, context.set.important, " Notes:"); @@ -131,29 +131,59 @@ extern "C" { f_status_t status = F_none; { - f_console_parameter_id_t ids[3] = { fss_extended_read_parameter_no_color, fss_extended_read_parameter_light, fss_extended_read_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_extended_read_total_parameters); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { fss_extended_read_parameter_no_color, fss_extended_read_parameter_light, fss_extended_read_parameter_dark }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - if (F_status_is_error(status)) { - fss_extended_read_delete_data(data); - return F_status_set_error(status); + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + fss_extended_read_delete_data(data); + return F_status_set_error(status); + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { fss_extended_read_parameter_verbosity_quiet, fss_extended_read_parameter_verbosity_normal, fss_extended_read_parameter_verbosity_verbose, fss_extended_read_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + fss_extended_read_delete_data(data); + return status; + } + + if (choice == fss_extended_read_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == fss_extended_read_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == fss_extended_read_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == fss_extended_read_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } if (data->parameters[fss_extended_read_parameter_help].result == f_console_result_found) { - fss_extended_read_print_help(data->context); + fss_extended_read_print_help(data->output, data->context); fss_extended_read_delete_data(data); return F_none; } if (data->parameters[fss_extended_read_parameter_version].result == f_console_result_found) { - fll_program_print_version(fss_extended_read_version); + fll_program_print_version(data->output, fss_extended_read_version); fss_extended_read_delete_data(data); return F_none; @@ -161,45 +191,45 @@ extern "C" { if (data->remaining.used > 0 || data->process_pipe) { if (data->parameters[fss_extended_read_parameter_at].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_at); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_at); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_extended_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_extended_read_parameter_depth].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_extended_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_extended_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_extended_read_parameter_name].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a string."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a string.%c", f_string_eol[0]); fss_extended_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); fss_extended_read_delete_data(data); return F_status_set_error(F_parameter); @@ -207,22 +237,22 @@ extern "C" { if (data->parameters[fss_extended_read_parameter_object].result == f_console_result_found) { if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); fss_extended_read_delete_data(data); return F_status_set_error(F_parameter); } if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); fss_extended_read_delete_data(data); return F_status_set_error(F_parameter); @@ -231,11 +261,11 @@ extern "C" { if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) { if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_total); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_total); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); fss_extended_read_delete_data(data); return F_status_set_error(F_parameter); @@ -271,9 +301,9 @@ extern "C" { } if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter requires a positive number."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter requires a positive number.%c", f_string_eol[0]); macro_fss_extended_read_depths_t_delete_simple(depths); fss_extended_read_delete_data(data); @@ -375,7 +405,7 @@ extern "C" { macro_fss_extended_read_depths_t_delete_simple(depths); } else { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: You failed to specify one or more files."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: You failed to specify one or more files.%c", f_string_eol[0]); status = F_status_set_error(F_parameter); } diff --git a/level_3/fss_extended_read/c/fss_extended_read.h b/level_3/fss_extended_read/c/fss_extended_read.h index aa31506..87b37a1 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.h +++ b/level_3/fss_extended_read/c/fss_extended_read.h @@ -39,6 +39,7 @@ #include // fll-2 includes +#include #include #include #include @@ -86,6 +87,10 @@ extern "C" { fss_extended_read_parameter_light, fss_extended_read_parameter_dark, fss_extended_read_parameter_no_color, + fss_extended_read_parameter_verbosity_quiet, + fss_extended_read_parameter_verbosity_normal, + fss_extended_read_parameter_verbosity_verbose, + fss_extended_read_parameter_verbosity_debug, fss_extended_read_parameter_version, fss_extended_read_parameter_at, @@ -105,6 +110,10 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_extended_read_short_at, fss_extended_read_long_at, 0, F_true, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_read_short_depth, fss_extended_read_long_depth, 0, F_true, f_console_type_normal), \ @@ -117,7 +126,7 @@ extern "C" { f_console_parameter_t_initialize(fss_extended_read_short_trim, fss_extended_read_long_trim, 0, F_false, f_console_type_normal), \ } - #define fss_extended_read_total_parameters 14 + #define fss_extended_read_total_parameters 18 #endif // _di_fss_extended_read_defines_ #ifndef _di_fss_extended_read_data_t_ @@ -127,7 +136,8 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; f_string_dynamic_t buffer; f_fss_objects_t objects; @@ -142,7 +152,8 @@ extern "C" { fss_extended_read_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ f_string_dynamic_t_initialize, \ f_fss_objects_t_initialize, \ f_fss_contents_t_initialize, \ @@ -161,7 +172,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_extended_read_print_help_ - extern f_return_status fss_extended_read_print_help(const f_color_context_t context); + extern f_return_status fss_extended_read_print_help(const int id, const f_color_context_t context); #endif // _di_fss_extended_read_print_help_ /** 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 index c090601..937272e 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.c +++ b/level_3/fss_extended_read/c/private-fss_extended_read.c @@ -9,11 +9,11 @@ extern "C" { void fss_extended_read_print_file_error(const f_color_context_t context, const f_string_t function_name, const f_string_t file_name, const f_status_t status) { if (fll_file_error_print(f_type_error, context, function_name, file_name, status) == F_false) { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function_name); - fl_color_print_line(f_type_error, context.set.error, "."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function_name); + fl_color_print_to(data.error.to, context.set.error, ".%c", f_string_eol[0]); } } #endif // _di_fss_extended_read_print_file_error_ @@ -22,62 +22,62 @@ extern "C" { void fss_extended_read_print_number_argument_error(const f_color_context_t context, const f_string_t function_name, const f_string_t parameter_name, const f_string_t argument, const f_status_t status) { if (status == F_parameter) { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function_name); - fl_color_print_line(f_type_error, context.set.error, "."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function_name); + fl_color_print_to(data.error.to, context.set.error, ".%c", f_string_eol[0]); } else if (status == F_number) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is not a valid number for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is not a valid number for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_underflow) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is too small for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is too small for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_overflow) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is too large for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is too large for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_negative) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is negative, which is not allowed for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is negative, which is not allowed for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_positive) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' contains a '"); - fl_color_print(f_type_error, context.set.notable, "+"); - fl_color_print(f_type_error, context.set.error, "', which is not allowed for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' contains a '"); + fl_color_print_to(data.error.to, context.set.notable, "+"); + fl_color_print_to(data.error.to, context.set.error, "', which is not allowed for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_data_not) { - fl_color_print(f_type_error, context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_type_error, context.set.error, "' must not be an empty string."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "' must not be an empty string.%c", f_string_eol[0]); } else { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function_name); - fl_color_print(f_type_error, context.set.error, "' for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(f_type_error, context.set.error, "' with the value '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function_name); + fl_color_print_to(data.error.to, context.set.error, "' for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_to(data.error.to, context.set.error, "' with the value '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } } #endif // _di_fss_extended_read_print_number_argument_error_ @@ -95,7 +95,7 @@ extern "C" { macro_fss_extended_read_depths_t_new(status, (*depths), depth_size); if (F_status_is_error(status)) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); return status; } @@ -179,12 +179,12 @@ extern "C" { // @todo: move error printing into common function. if (status_code == F_memory_allocation || status_code == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else if (status_code == f_string_length_t_size) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: Unable to process '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_trim); - fl_color_print_line(f_type_error, data.context.set.error, "' because the maximum buffer size was reached."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Unable to process '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_trim); + fl_color_print_to(data.error.to, data.context.set.error, "' because the maximum buffer size was reached.%c", f_string_eol[0]); } else { f_string_t function = "fl_string_append"; @@ -193,20 +193,20 @@ extern "C" { function = "fl_string_rip"; } - fl_color_print(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, data.context.set.notable, "%u", status_code); - fl_color_print(f_type_error, data.context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, data.context.set.notable, "%s()", function); - fl_color_print_line(f_type_error, data.context.set.error, "."); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data.error.to, data.context.set.notable, "%u", status_code); + fl_color_print_to(data.error.to, data.context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, data.context.set.notable, "%s()", function); + fl_color_print_to(data.error.to, data.context.set.error, ".%c", f_string_eol[0]); } return status; } if (!depths->array[i].value_name.used) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: The '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); - fl_color_print_line(f_type_error, data.context.set.error, "' must not be an empty string."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); + fl_color_print_to(data.error.to, data.context.set.error, "' must not be an empty string.%c", f_string_eol[0]); return F_status_set_error(F_parameter); } @@ -219,22 +219,22 @@ extern "C" { for (f_array_length_t j = i + 1; j < depths->used; j++) { if (depths->array[i].depth == depths->array[j].depth) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: The value '"); - fl_color_print(f_type_error, data.context.set.notable, "%llu", depths->array[i].depth); - fl_color_print(f_type_error, data.context.set.error, "' may only be specified once for the parameter '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The value '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", depths->array[i].depth); + fl_color_print_to(data.error.to, data.context.set.error, "' may only be specified once for the parameter '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); return F_status_set_error(F_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - fl_color_print(f_type_error, data.context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); - fl_color_print(f_type_error, data.context.set.error, "' may not have the value '"); - fl_color_print(f_type_error, data.context.set.notable, "%llu", depths->array[i].depth); - fl_color_print(f_type_error, data.context.set.error, "' before the value '"); - fl_color_print(f_type_error, data.context.set.notable, "%llu", depths->array[j].depth); - fl_color_print_line(f_type_error, data.context.set.error, "'."); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); + fl_color_print_to(data.error.to, data.context.set.error, "' may not have the value '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", depths->array[i].depth); + fl_color_print_to(data.error.to, data.context.set.error, "' before the value '"); + fl_color_print_to(data.error.to, data.context.set.notable, "%llu", depths->array[j].depth); + fl_color_print_to(data.error.to, data.context.set.error, "'.%c", f_string_eol[0]); return F_status_set_error(F_parameter); } @@ -261,33 +261,33 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, data->context.set.notable, "fll_fss_extended_read()"); - fl_color_print(f_type_error, data->context.set.error, " for the file '"); - fl_color_print(f_type_error, data->context.set.notable, "%s", filename); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print_to(data->error.to, data->context.set.notable, "fll_fss_extended_read()"); + fl_color_print_to(data->error.to, data->context.set.error, " for the file '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s", filename); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data->error.to, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else if (status == F_incomplete_utf_stop) { - fl_color_print(f_type_error, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at stop position (at "); - fl_color_print(f_type_error, data->context.set.notable, "%d", input.start); - fl_color_print_line(f_type_error, data->context.set.error, ")."); + fl_color_print_to(data->error.to, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print_to(data->error.to, data->context.set.notable, "%d", input.start); + fl_color_print_to(data->error.to, data->context.set.error, ").%c", f_string_eol[0]); } else if (status == F_incomplete_utf_eos) { - fl_color_print(f_type_error, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at end of string (at "); - fl_color_print(f_type_error, data->context.set.notable, "%d", input.start); - fl_color_print_line(f_type_error, data->context.set.error, ")."); + fl_color_print_to(data->error.to, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print_to(data->error.to, data->context.set.notable, "%d", input.start); + fl_color_print_to(data->error.to, data->context.set.error, ").%c", f_string_eol[0]); } else { - fl_color_print(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, data->context.set.notable, "%u", status); - fl_color_print(f_type_error, data->context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, data->context.set.notable, "fll_fss_extended_read()"); - fl_color_print(f_type_error, data->context.set.error, " for the file '"); - fl_color_print(f_type_error, data->context.set.notable, "%s", filename); - fl_color_print_line(f_type_error, data->context.set.error, "'."); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print_to(data->error.to, data->context.set.notable, "%u", status); + fl_color_print_to(data->error.to, data->context.set.error, ") has occurred while calling "); + fl_color_print_to(data->error.to, data->context.set.notable, "fll_fss_extended_read()"); + fl_color_print_to(data->error.to, data->context.set.error, " for the file '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s", filename); + fl_color_print_to(data->error.to, data->context.set.error, "'.%c", f_string_eol[0]); } return F_status_set_error(status); diff --git a/level_3/fss_extended_read/data/build/dependencies b/level_3/fss_extended_read/data/build/dependencies index 24804a4..9843cb6 100644 --- a/level_3/fss_extended_read/data/build/dependencies +++ b/level_3/fss_extended_read/data/build/dependencies @@ -20,6 +20,7 @@ fl_fss fl_print fl_status fl_string +fll_error fll_execute fll_file fll_fss diff --git a/level_3/fss_extended_read/data/build/settings b/level_3/fss_extended_read/data/build/settings index 420d296..6a985d7 100644 --- a/level_3/fss_extended_read/data/build/settings +++ b/level_3/fss_extended_read/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_console -lfl_conversion -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfll_error -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_console -lfl_conversion -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_extended_read.c private-fss_extended_read.c diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index 03e586d..1948414 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -5,30 +5,30 @@ extern "C" { #endif #ifndef _di_fss_extended_write_print_help_ - f_return_status fss_extended_write_print_help(const f_color_context_t context) { + f_return_status fss_extended_write_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, fss_extended_write_name_long, fss_extended_write_version); + fll_program_print_help_header(id, context, fss_extended_write_name_long, fss_extended_write_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, fss_extended_write_short_content, fss_extended_write_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " The content to output."); - fll_program_print_help_option(context, fss_extended_write_short_double, fss_extended_write_long_double, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use double quotes (default)."); - fll_program_print_help_option(context, fss_extended_write_short_file, fss_extended_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to."); - fll_program_print_help_option(context, fss_extended_write_short_object, fss_extended_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " The object to output."); - fll_program_print_help_option(context, fss_extended_write_short_partial, fss_extended_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output end of object/content character."); - fll_program_print_help_option(context, fss_extended_write_short_single, fss_extended_write_long_single, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use single quotes."); + fll_program_print_help_option(id, context, fss_extended_write_short_content, fss_extended_write_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " The content to output."); + fll_program_print_help_option(id, context, fss_extended_write_short_double, fss_extended_write_long_double, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use double quotes (default)."); + fll_program_print_help_option(id, context, fss_extended_write_short_file, fss_extended_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to."); + fll_program_print_help_option(id, context, fss_extended_write_short_object, fss_extended_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " The object to output."); + fll_program_print_help_option(id, context, fss_extended_write_short_partial, fss_extended_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output end of object/content character."); + fll_program_print_help_option(id, context, fss_extended_write_short_single, fss_extended_write_long_single, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use single quotes."); - fll_program_print_help_usage(context, fss_extended_write_name, ""); + fll_program_print_help_usage(id, context, fss_extended_write_name, ""); return F_none; } @@ -39,29 +39,59 @@ extern "C" { f_status_t status = F_none; { - f_console_parameter_id_t ids[3] = { fss_extended_write_parameter_no_color, fss_extended_write_parameter_light, fss_extended_write_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_extended_write_total_parameters); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { fss_extended_write_parameter_no_color, fss_extended_write_parameter_light, fss_extended_write_parameter_dark }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - if (F_status_is_error(status)) { - fss_extended_write_delete_data(data); - return status; + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + fss_extended_write_delete_data(data); + return status; + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { fss_extended_write_parameter_verbosity_quiet, fss_extended_write_parameter_verbosity_normal, fss_extended_write_parameter_verbosity_verbose, fss_extended_write_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + fss_extended_write_delete_data(data); + return status; + } + + if (choice == fss_extended_write_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == fss_extended_write_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == fss_extended_write_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == fss_extended_write_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } if (data->parameters[fss_extended_write_parameter_help].result == f_console_result_found) { - fss_extended_write_print_help(data->context); + fss_extended_write_print_help(data->output, data->context); fss_extended_write_delete_data(data); return F_none; } if (data->parameters[fss_extended_write_parameter_version].result == f_console_result_found) { - fll_program_print_version(fss_extended_write_version); + fll_program_print_version(data->output, fss_extended_write_version); fss_extended_write_delete_data(data); return F_none; @@ -85,19 +115,19 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", "-"); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to find the file '%s'%c", "-", f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", "-"); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to open the file '%s'%c", "-", f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", "-"); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'%c", "-", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(input); @@ -239,19 +269,19 @@ extern "C" { f_file_close(&output.id); if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to find the file '%s'%c", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]], f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to open the file '%s'%c", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]], f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'%c", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]], f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); @@ -266,13 +296,13 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()"); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()%c", f_string_eol[0]); } else if (status == F_file_write) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Unable to write to the file '%s'%c", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]], f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()", status); + fl_color_print_to(data->error.to, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()%c", status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); diff --git a/level_3/fss_extended_write/c/fss_extended_write.h b/level_3/fss_extended_write/c/fss_extended_write.h index bd9fcc0..69b43f9 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.h +++ b/level_3/fss_extended_write/c/fss_extended_write.h @@ -32,6 +32,7 @@ #include // fll-2 includes +#include #include #include @@ -71,6 +72,10 @@ extern "C" { fss_extended_write_parameter_light, fss_extended_write_parameter_dark, fss_extended_write_parameter_no_color, + fss_extended_write_parameter_verbosity_quiet, + fss_extended_write_parameter_verbosity_normal, + fss_extended_write_parameter_verbosity_verbose, + fss_extended_write_parameter_verbosity_debug, fss_extended_write_parameter_version, fss_extended_write_parameter_content, @@ -87,6 +92,10 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_extended_write_short_content, fss_extended_write_long_content, 0, F_true, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_write_short_double, fss_extended_write_long_double, 0, F_true, f_console_type_normal), \ @@ -96,7 +105,7 @@ extern "C" { f_console_parameter_t_initialize(fss_extended_write_short_single, fss_extended_write_long_single, 0, F_true, f_console_type_normal), \ } - #define fss_extended_write_total_parameters 11 + #define fss_extended_write_total_parameters 15 #endif // _di_fss_extended_write_defines_ #ifndef _di_fss_extended_write_data_t_ @@ -106,7 +115,8 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; f_color_context_t context; } fss_extended_write_data_t; @@ -116,7 +126,8 @@ extern "C" { fss_extended_write_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ f_color_context_t_initialize, \ } #endif // _di_fss_extended_write_data_t_ @@ -131,7 +142,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_extended_write_print_help_ - extern f_return_status fss_extended_write_print_help(const f_color_context_t context); + extern f_return_status fss_extended_write_print_help(const int id, const f_color_context_t context); #endif // _di_fss_extended_write_print_help_ /** diff --git a/level_3/fss_extended_write/data/build/dependencies b/level_3/fss_extended_write/data/build/dependencies index 5c4b55f..4346cad 100644 --- a/level_3/fss_extended_write/data/build/dependencies +++ b/level_3/fss_extended_write/data/build/dependencies @@ -18,6 +18,7 @@ fl_conversion fl_fss fl_status fl_string +fll_error fll_execute fll_file fll_fss diff --git a/level_3/fss_extended_write/data/build/settings b/level_3/fss_extended_write/data/build/settings index 3a0ed9d..9864920 100644 --- a/level_3/fss_extended_write/data/build/settings +++ b/level_3/fss_extended_write/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfl_string -lfl_status -lfl_fss -lfl_conversion -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfll_error -lfl_string -lfl_status -lfl_fss -lfl_conversion -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_extended_write.c diff --git a/level_3/fss_status_code/c/fss_status_code.c b/level_3/fss_status_code/c/fss_status_code.c index 7e082a1..ef0e7c6 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -6,28 +6,28 @@ extern "C" { #endif #ifndef _di_fss_status_code_print_help_ - f_return_status fss_status_code_print_help(const f_color_context_t context) { + f_return_status fss_status_code_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, fss_status_code_name_long, fss_status_code_version); + fll_program_print_help_header(id, context, fss_status_code_name_long, fss_status_code_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, fss_status_code_short_is_fine, fss_status_code_long_is_fine, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print F_true if the error code is not an error, F_false otherwise."); - fll_program_print_help_option(context, fss_status_code_short_is_warning, fss_status_code_long_is_warning, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print F_true if the error code is a warning, F_false otherwise."); - fll_program_print_help_option(context, fss_status_code_short_is_error, fss_status_code_long_is_error, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print F_true if the error code is an error, F_false otherwise."); - fll_program_print_help_option(context, fss_status_code_short_number, fss_status_code_long_number, f_console_symbol_short_enable, f_console_symbol_long_enable, " Convert status code name to number."); + fll_program_print_help_option(id, context, fss_status_code_short_is_fine, fss_status_code_long_is_fine, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print F_true if the error code is not an error, F_false otherwise."); + fll_program_print_help_option(id, context, fss_status_code_short_is_warning, fss_status_code_long_is_warning, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print F_true if the error code is a warning, F_false otherwise."); + fll_program_print_help_option(id, context, fss_status_code_short_is_error, fss_status_code_long_is_error, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print F_true if the error code is an error, F_false otherwise."); + fll_program_print_help_option(id, context, fss_status_code_short_number, fss_status_code_long_number, f_console_symbol_short_enable, f_console_symbol_long_enable, " Convert status code name to number."); - fll_program_print_help_usage(context, fss_status_code_name, "status code(s)"); + fll_program_print_help_usage(id, context, fss_status_code_name, "status code(s)"); return F_none; } @@ -38,29 +38,59 @@ extern "C" { f_status_t status = F_none; { - f_console_parameter_id_t ids[3] = { fss_status_code_parameter_no_color, fss_status_code_parameter_light, fss_status_code_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_status_code_total_parameters); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { fss_status_code_parameter_no_color, fss_status_code_parameter_light, fss_status_code_parameter_dark }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - if (F_status_is_error(status)) { - fss_status_code_delete_data(data); - return F_status_set_error(status); + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + fss_status_code_delete_data(data); + return F_status_set_error(status); + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { fss_status_code_parameter_verbosity_quiet, fss_status_code_parameter_verbosity_normal, fss_status_code_parameter_verbosity_verbose, fss_status_code_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + fss_status_code_delete_data(data); + return status; + } + + if (choice == fss_status_code_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == fss_status_code_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == fss_status_code_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == fss_status_code_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } if (data->parameters[fss_status_code_parameter_help].result == f_console_result_found) { - fss_status_code_print_help(data->context); + fss_status_code_print_help(data->output, data->context); fss_status_code_delete_data(data); return F_none; } if (data->parameters[fss_status_code_parameter_version].result == f_console_result_found) { - fll_program_print_version(fss_status_code_version); + fll_program_print_version(data->output, fss_status_code_version); fss_status_code_delete_data(data); return F_none; @@ -68,39 +98,39 @@ extern "C" { if (data->parameters[fss_status_code_parameter_is_error].result == f_console_result_found) { if (data->parameters[fss_status_code_parameter_is_warning].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_error); - fl_color_print(f_type_error, data->context.set.error, "' cannot be used with the parameter "); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_warning); - fl_color_print_line(f_type_error, data->context.set.error, "."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_error); + fl_color_print_to(data->error.to, data->context.set.error, "' cannot be used with the parameter "); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_warning); + fl_color_print_to(data->error.to, data->context.set.error, ".%c", f_string_eol[0]); fss_status_code_delete_data(data); return F_status_set_error(status); } else if (data->parameters[fss_status_code_parameter_is_fine].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_error); - fl_color_print(f_type_error, data->context.set.error, "' cannot be used with the parameter "); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_fine); - fl_color_print_line(f_type_error, data->context.set.error, "."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_error); + fl_color_print_to(data->error.to, data->context.set.error, "' cannot be used with the parameter "); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_fine); + fl_color_print_to(data->error.to, data->context.set.error, ".%c", f_string_eol[0]); fss_status_code_delete_data(data); return F_status_set_error(status); } } else if (data->parameters[fss_status_code_parameter_is_warning].result == f_console_result_found && data->parameters[fss_status_code_parameter_is_fine].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_warning); - fl_color_print(f_type_error, data->context.set.error, "' cannot be used with the parameter "); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_fine); - fl_color_print_line(f_type_error, data->context.set.error, "."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_warning); + fl_color_print_to(data->error.to, data->context.set.error, "' cannot be used with the parameter "); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_fine); + fl_color_print_to(data->error.to, data->context.set.error, ".%c", f_string_eol[0]); fss_status_code_delete_data(data); return F_status_set_error(status); } if (data->remaining.used == 0 && !data->process_pipe) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: You failed to specify an error code."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: You failed to specify an error code.%c", f_string_eol[0]); fss_status_code_delete_data(data); return F_status_set_error(F_parameter); diff --git a/level_3/fss_status_code/c/fss_status_code.h b/level_3/fss_status_code/c/fss_status_code.h index 5ed1083..cd87eb2 100644 --- a/level_3/fss_status_code/c/fss_status_code.h +++ b/level_3/fss_status_code/c/fss_status_code.h @@ -33,6 +33,7 @@ #include // fll-2 includes +#include #include #include #include @@ -69,6 +70,10 @@ extern "C" { fss_status_code_parameter_light, fss_status_code_parameter_dark, fss_status_code_parameter_no_color, + fss_status_code_parameter_verbosity_quiet, + fss_status_code_parameter_verbosity_normal, + fss_status_code_parameter_verbosity_verbose, + fss_status_code_parameter_verbosity_debug, fss_status_code_parameter_version, fss_status_code_parameter_is_fine, @@ -83,6 +88,10 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_status_code_short_is_fine, fss_status_code_long_is_fine, 0, F_false, f_console_type_normal), \ f_console_parameter_t_initialize(fss_status_code_short_is_warning, fss_status_code_long_is_warning, 0, F_false, f_console_type_normal), \ @@ -90,7 +99,7 @@ extern "C" { f_console_parameter_t_initialize(fss_status_code_short_number, fss_status_code_long_number, 0, F_false, f_console_type_normal), \ } - #define fss_status_code_total_parameters 9 + #define fss_status_code_total_parameters 13 #endif // _di_fss_status_code_defines_ #ifndef _di_fss_status_code_data_t_ @@ -100,7 +109,8 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; f_color_context_t context; } fss_status_code_data_t; @@ -110,7 +120,8 @@ extern "C" { fss_status_code_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ f_color_context_t_initialize, \ } #endif // _di_fss_status_code_data_t_ @@ -125,7 +136,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_status_code_print_help_ - extern f_return_status fss_status_code_print_help(const f_color_context_t context); + extern f_return_status fss_status_code_print_help(const int id, const f_color_context_t context); #endif // _di_fss_status_code_print_help_ /** diff --git a/level_3/fss_status_code/c/private-fss_status_code.c b/level_3/fss_status_code/c/private-fss_status_code.c index e674dbc..7045191 100644 --- a/level_3/fss_status_code/c/private-fss_status_code.c +++ b/level_3/fss_status_code/c/private-fss_status_code.c @@ -53,13 +53,13 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(value, &number, range); if (status == F_none) { - fl_color_print_line(f_type_output, data.context.set.error, "invalid name"); + fl_color_print(f_type_output, data.context.set.error, "invalid name%c", f_string_eol[0]); return F_status_set_error(F_parameter); } if (status == F_data_not || F_status_set_fine(status) == F_parameter) { - fl_color_print_line(f_type_output, data.context.set.error, "invalid data"); + fl_color_print(f_type_output, data.context.set.error, "invalid data%c", f_string_eol[0]); return status; } @@ -76,10 +76,10 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { - fl_color_print_line(f_type_output, data.context.set.error, "unknown name"); + fl_color_print(f_type_output, data.context.set.error, "unknown name%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_output, data.context.set.error, "failed to convert"); + fl_color_print(f_type_output, data.context.set.error, "failed to convert%c", f_string_eol[0]); } return status; @@ -87,7 +87,7 @@ extern "C" { } if (status == F_data) { - fl_color_print_line(f_type_output, data.context.set.warning, "unknown code"); + fl_color_print(f_type_output, data.context.set.warning, "unknown code%c", f_string_eol[0]); return F_none; } @@ -112,10 +112,10 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { - fl_color_print_line(f_type_output, data.context.set.error, "unknown code"); + fl_color_print(f_type_output, data.context.set.error, "unknown code%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_output, data.context.set.error, "failed to convert"); + fl_color_print(f_type_output, data.context.set.error, "failed to convert%c", f_string_eol[0]); } return status; @@ -134,17 +134,17 @@ extern "C" { f_status_t status = fl_conversion_string_to_number_unsigned(value, number, range); if (*number > F_status_size_max_with_signal) { - fl_color_print_line(f_type_output, data.context.set.error, "out of range"); + fl_color_print(f_type_output, data.context.set.error, "out of range%c", f_string_eol[0]); return status; } if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_number_negative) { - fl_color_print_line(f_type_output, data.context.set.error, "out of range"); + fl_color_print(f_type_output, data.context.set.error, "out of range%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_output, data.context.set.error, "invalid number"); + fl_color_print(f_type_output, data.context.set.error, "invalid number%c", f_string_eol[0]); } return status; diff --git a/level_3/fss_status_code/data/build/dependencies b/level_3/fss_status_code/data/build/dependencies index 528ffcd..eaeb226 100644 --- a/level_3/fss_status_code/data/build/dependencies +++ b/level_3/fss_status_code/data/build/dependencies @@ -21,6 +21,7 @@ fl_fss fl_status fl_string fl_utf +fll_error fll_execute fll_file fll_fss diff --git a/level_3/fss_status_code/data/build/settings b/level_3/fss_status_code/data/build/settings index 56f0188..2f748e8 100644 --- a/level_3/fss_status_code/data/build/settings +++ b/level_3/fss_status_code/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_status -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfl_utf -lfl_string -lfl_status -lfl_fss -lfl_conversion -lfl_console -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_conversion -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_status -lfll_program -lfll_fss -lfll_file -lfl_directory -lfll_execute -lfl_environment -lf_signal -lf_path -lfll_error -lfl_utf -lfl_string -lfl_status -lfl_fss -lfl_conversion -lfl_console -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_conversion -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_status_code.c private-fss_status_code.c diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index a9a406d..e2e0e77 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -6,39 +6,39 @@ extern "C" { #endif #ifndef _di_iki_read_print_help_ - f_return_status iki_read_print_help(const f_color_context_t context) { + f_return_status iki_read_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, iki_read_name_long, iki_read_version); + fll_program_print_help_header(id, context, iki_read_name_long, iki_read_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, iki_read_short_at, iki_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select variable at this numeric index."); - fll_program_print_help_option(context, iki_read_short_line, iki_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the variables at the given line."); - fll_program_print_help_option(context, iki_read_short_name, iki_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select variables with this name."); - fll_program_print_help_option(context, iki_read_short_whole, iki_read_long_whole, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print all of the data instead of just the variable data."); + fll_program_print_help_option(id, context, iki_read_short_at, iki_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select variable at this numeric index."); + fll_program_print_help_option(id, context, iki_read_short_line, iki_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the variables at the given line."); + fll_program_print_help_option(id, context, iki_read_short_name, iki_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select variables with this name."); + fll_program_print_help_option(id, context, iki_read_short_whole, iki_read_long_whole, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print all of the data instead of just the variable data."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, iki_read_short_content, iki_read_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print the variable content (default)."); - fll_program_print_help_option(context, iki_read_short_literal, iki_read_long_literal, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print the entire variable (aka: object, content, and syntax)."); - fll_program_print_help_option(context, iki_read_short_object, iki_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the variable name (aka: object)."); - fll_program_print_help_option(context, iki_read_short_total, iki_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of variables."); + fll_program_print_help_option(id, context, iki_read_short_content, iki_read_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print the variable content (default)."); + fll_program_print_help_option(id, context, iki_read_short_literal, iki_read_long_literal, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print the entire variable (aka: object, content, and syntax)."); + fll_program_print_help_option(id, context, iki_read_short_object, iki_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the variable name (aka: object)."); + fll_program_print_help_option(id, context, iki_read_short_total, iki_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of variables."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, iki_read_short_substitute, iki_read_long_substitute, f_console_symbol_short_enable, f_console_symbol_long_enable, "Substitute the entire variable for the given name and content value with the given string."); + fll_program_print_help_option(id, context, iki_read_short_substitute, iki_read_long_substitute, f_console_symbol_short_enable, f_console_symbol_long_enable, "Substitute the entire variable for the given name and content value with the given string."); - fll_program_print_help_usage(context, iki_read_name, "filename(s)"); + fll_program_print_help_usage(id, context, iki_read_name, "filename(s)"); fl_color_print(f_type_output, context.set.important, " Notes:"); @@ -93,350 +93,359 @@ extern "C" { f_status_t status = F_none; { - f_console_parameter_id_t ids[3] = { iki_read_parameter_no_color, iki_read_parameter_light, iki_read_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, iki_read_total_parameters); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { iki_read_parameter_no_color, iki_read_parameter_light, iki_read_parameter_dark }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - if (F_status_is_error(status)) { - iki_read_print_error(data->context, data->verbosity, F_status_set_fine(status), "fll_program_parameter_process", F_true); + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + iki_read_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "fll_program_parameter_process", F_true); - if (data->verbosity == f_console_verbosity_verbose) { - fprintf(f_type_error, "%c", f_string_eol[0]); + if (data->error.verbosity == f_console_verbosity_verbose) { + dprintf(data->error.to, "%c", f_string_eol[0]); + } + + iki_read_delete_data(data); + return F_status_set_error(status); } + } - iki_read_delete_data(data); - return F_status_set_error(status); + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { iki_read_parameter_verbosity_quiet, iki_read_parameter_verbosity_normal, iki_read_parameter_verbosity_verbose, iki_read_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + iki_read_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true); + + iki_read_delete_data(data); + return status; + } + + if (choice == iki_read_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == iki_read_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == iki_read_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == iki_read_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } if (data->parameters[iki_read_parameter_help].result == f_console_result_found) { - iki_read_print_help(data->context); + iki_read_print_help(data->output, data->context); iki_read_delete_data(data); return F_none; } if (data->parameters[iki_read_parameter_version].result == f_console_result_found) { - fll_program_print_version(iki_read_version); + fll_program_print_version(data->output, iki_read_version); iki_read_delete_data(data); return F_none; } - if (data->parameters[iki_read_parameter_verbose].result == f_console_result_found) { - if (data->parameters[iki_read_parameter_quiet].result == f_console_result_found) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, f_console_standard_long_verbose); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, f_console_standard_long_quiet); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); + if (data->remaining.used > 0 || data->process_pipe) { + if (data->parameters[iki_read_parameter_at].result == f_console_result_found) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_at); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); + } status = F_status_set_error(F_parameter); } + else if (data->parameters[iki_read_parameter_at].result == f_console_result_additional) { + const f_string_length_t index = data->parameters[iki_read_parameter_at].additional.array[data->parameters[iki_read_parameter_at].additional.used - 1]; + const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index])); - data->verbosity = f_console_verbosity_verbose; - } - else if (data->parameters[iki_read_parameter_quiet].result == f_console_result_found) { - data->verbosity = f_console_verbosity_quiet; - } - else { - data->verbosity = f_console_verbosity_normal; - } + f_number_unsigned_t number = 0; - if (F_status_is_fine(status)) { - if (data->remaining.used > 0 || data->process_pipe) { - if (data->parameters[iki_read_parameter_at].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_at); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); - } + status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range); + + if (F_status_is_error(status)) { + iki_read_print_error_number_argument(data->context, data->error.verbosity, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", iki_read_long_line, arguments.argv[index]); status = F_status_set_error(F_parameter); } - else if (data->parameters[iki_read_parameter_at].result == f_console_result_additional) { - const f_string_length_t index = data->parameters[iki_read_parameter_at].additional.array[data->parameters[iki_read_parameter_at].additional.used - 1]; - const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index])); - f_number_unsigned_t number = 0; + data->at = number; - status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range); + if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_at); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter."); + } - if (F_status_is_error(status)) { - iki_read_print_error_number_argument(data->context, data->verbosity, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", iki_read_long_line, arguments.argv[index]); + status = F_status_set_error(F_parameter); + } + } - status = F_status_set_error(F_parameter); - } + if (data->parameters[iki_read_parameter_line].result == f_console_result_found) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_line); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); + } - data->at = number; + status = F_status_set_error(F_parameter); + } + else if (data->parameters[iki_read_parameter_line].result == f_console_result_additional) { + const f_string_length_t index = data->parameters[iki_read_parameter_line].additional.array[data->parameters[iki_read_parameter_line].additional.used - 1]; + const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index])); - if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_at); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); - } + f_number_unsigned_t number = 0; - status = F_status_set_error(F_parameter); - } - } + status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range); - if (data->parameters[iki_read_parameter_line].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_line); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a positive number."); - } + if (F_status_is_error(status)) { + iki_read_print_error_number_argument(data->context, data->error.verbosity, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", iki_read_long_line, arguments.argv[index]); status = F_status_set_error(F_parameter); } - else if (data->parameters[iki_read_parameter_line].result == f_console_result_additional) { - const f_string_length_t index = data->parameters[iki_read_parameter_line].additional.array[data->parameters[iki_read_parameter_line].additional.used - 1]; - const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index])); - f_number_unsigned_t number = 0; + data->line = number; + } - status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range); + if (data->parameters[iki_read_parameter_name].result == f_console_result_found) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_name); + fl_color_print_to(data->error.to, data->context.set.error, "' requires a string.%c", f_string_eol[0]); + } - if (F_status_is_error(status)) { - iki_read_print_error_number_argument(data->context, data->verbosity, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", iki_read_long_line, arguments.argv[index]); + status = F_status_set_error(F_parameter); + } - status = F_status_set_error(F_parameter); + if (data->parameters[iki_read_parameter_substitute].result != f_console_result_none) { + if (data->parameters[iki_read_parameter_substitute].result == f_console_result_found || data->parameters[iki_read_parameter_substitute].additional.used % 3 != 0) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_substitute); + fl_color_print_to(data->error.to, data->context.set.error, "' requires 3 strings.%c", f_string_eol[0]); } - data->line = number; + status = F_status_set_error(F_parameter); } - if (data->parameters[iki_read_parameter_name].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_name); - fl_color_print_line(f_type_error, data->context.set.error, "' requires a string."); + if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_substitute); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); } status = F_status_set_error(F_parameter); } + } - if (data->parameters[iki_read_parameter_substitute].result != f_console_result_none) { - if (data->parameters[iki_read_parameter_substitute].result == f_console_result_found || data->parameters[iki_read_parameter_substitute].additional.used % 3 != 0) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_substitute); - fl_color_print_line(f_type_error, data->context.set.error, "' requires 3 strings."); - } - - status = F_status_set_error(F_parameter); + if (data->parameters[iki_read_parameter_literal].result == f_console_result_found) { + if (data->parameters[iki_read_parameter_object].result == f_console_result_found) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_literal); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); } - if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_substitute); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); - } - - status = F_status_set_error(F_parameter); - } + status = F_status_set_error(F_parameter); } - if (data->parameters[iki_read_parameter_literal].result == f_console_result_found) { - if (data->parameters[iki_read_parameter_object].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_literal); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_object); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); - } - - status = F_status_set_error(F_parameter); + if (data->parameters[iki_read_parameter_content].result == f_console_result_found) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_literal); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_content); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); } - if (data->parameters[iki_read_parameter_content].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_literal); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_content); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); - } - - status = F_status_set_error(F_parameter); - } + status = F_status_set_error(F_parameter); + } - if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_literal); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); - } - - status = F_status_set_error(F_parameter); + if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_literal); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); } - data->mode = iki_read_mode_literal; + status = F_status_set_error(F_parameter); } - else if (data->parameters[iki_read_parameter_object].result == f_console_result_found) { - if (data->parameters[iki_read_parameter_content].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_object); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_content); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); - } - - status = F_status_set_error(F_parameter); - } - if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_object); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); - } - - status = F_status_set_error(F_parameter); + data->mode = iki_read_mode_literal; + } + else if (data->parameters[iki_read_parameter_object].result == f_console_result_found) { + if (data->parameters[iki_read_parameter_content].result == f_console_result_found) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_content); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); } - data->mode = iki_read_mode_object; - } - else if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { - data->mode = iki_read_mode_total; - } - else { - // this is the default behavior, so there is no reason to check for the -c/--content parameter. - data->mode = iki_read_mode_content; + status = F_status_set_error(F_parameter); } - if (data->parameters[iki_read_parameter_whole].result == f_console_result_found) { - if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_whole); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); - } - - status = F_status_set_error(F_parameter); + if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); } + + status = F_status_set_error(F_parameter); } - if (F_status_is_error(status)) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); + data->mode = iki_read_mode_object; + } + else if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { + data->mode = iki_read_mode_total; + } + else { + // this is the default behavior, so there is no reason to check for the -c/--content parameter. + data->mode = iki_read_mode_content; + } + + if (data->parameters[iki_read_parameter_whole].result == f_console_result_found) { + if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_whole); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter with the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); + fl_color_print_to(data->error.to, data->context.set.error, "' parameter.%c", f_string_eol[0]); } - iki_read_delete_data(data); - return F_status_set_error(F_parameter); + status = F_status_set_error(F_parameter); } + } - if (data->process_pipe) { - f_file_t file = f_file_t_initialize; + if (F_status_is_error(status)) { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + } - file.id = f_type_descriptor_input; + iki_read_delete_data(data); + return F_status_set_error(F_parameter); + } - status = f_file_read(file, &data->buffer); + if (data->process_pipe) { + f_file_t file = f_file_t_initialize; - if (F_status_is_error(status)) { - iki_read_print_error_file(data->context, data->verbosity, F_status_set_fine(status), "f_file_read", "-", "process", F_true, F_true); - } - else { - status = iki_read_process_buffer(arguments, "-", data); - } + file.id = f_type_descriptor_input; - // Clear buffers before continuing. - f_macro_string_dynamic_t_delete_simple(data->buffer); - } + status = f_file_read(file, &data->buffer); - if (F_status_is_fine(status) && data->remaining.used > 0) { - f_string_length_t i = 0; - f_string_length_t total = 0; - f_file_t file = f_file_t_initialize; + if (F_status_is_error(status)) { + iki_read_print_error_file(data->context, data->error.verbosity, F_status_set_fine(status), "f_file_read", "-", "process", F_true, F_true); + } + else { + status = iki_read_process_buffer(arguments, "-", data); + } - for (; i < data->remaining.used; i++) { - f_macro_file_t_reset(file); - total = 0; + // Clear buffers before continuing. + f_macro_string_dynamic_t_delete_simple(data->buffer); + } - status = f_file_open(arguments.argv[data->remaining.array[i]], 0, &file); + if (F_status_is_fine(status) && data->remaining.used > 0) { + f_string_length_t i = 0; + f_string_length_t total = 0; + f_file_t file = f_file_t_initialize; - if (F_status_is_error(status)) { - iki_read_print_error_file(data->context, data->verbosity, F_status_set_fine(status), "f_file_open", arguments.argv[data->remaining.array[i]], "process", F_true, F_true); - break; - } + for (; i < data->remaining.used; i++) { + f_macro_file_t_reset(file); + total = 0; - status = f_file_size_by_id(file.id, &total); + status = f_file_open(arguments.argv[data->remaining.array[i]], 0, &file); - if (F_status_is_error(status)) { - iki_read_print_error_file(data->context, data->verbosity, F_status_set_fine(status), "f_file_size_by_id", arguments.argv[data->remaining.array[i]], "process", F_true, F_true); + if (F_status_is_error(status)) { + iki_read_print_error_file(data->context, data->error.verbosity, F_status_set_fine(status), "f_file_open", arguments.argv[data->remaining.array[i]], "process", F_true, F_true); + break; + } - f_file_close(&file.id); - break; - } + status = f_file_size_by_id(file.id, &total); - // Skip past empty files. - if (!total) { - f_file_close(&file.id); - continue; - } + if (F_status_is_error(status)) { + iki_read_print_error_file(data->context, data->error.verbosity, F_status_set_fine(status), "f_file_size_by_id", arguments.argv[data->remaining.array[i]], "process", F_true, F_true); - status = f_file_read_until(file, total, &data->buffer); + f_file_close(&file.id); + break; + } + // Skip past empty files. + if (!total) { f_file_close(&file.id); + continue; + } - if (F_status_is_error(status)) { - iki_read_print_error_file(data->context, data->verbosity, F_status_set_fine(status), "f_file_read_until", arguments.argv[data->remaining.array[i]], "process", F_true, F_true); - break; - } + status = f_file_read_until(file, total, &data->buffer); - status = iki_read_process_buffer(arguments, arguments.argv[data->remaining.array[i]], data); - if (F_status_is_error(status)) break; + f_file_close(&file.id); - // Clear buffers before repeating the loop. - f_macro_string_dynamic_t_delete_simple(data->buffer); - } // for - } - } - else { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: you failed to specify one or more files."); - } + if (F_status_is_error(status)) { + iki_read_print_error_file(data->context, data->error.verbosity, F_status_set_fine(status), "f_file_read_until", arguments.argv[data->remaining.array[i]], "process", F_true, F_true); + break; + } - status = F_status_set_error(F_parameter); + status = iki_read_process_buffer(arguments, arguments.argv[data->remaining.array[i]], data); + if (F_status_is_error(status)) break; + + // Clear buffers before repeating the loop. + f_macro_string_dynamic_t_delete_simple(data->buffer); + } // for + } + } + else { + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: you failed to specify one or more files.%c", f_string_eol[0]); } + + status = F_status_set_error(F_parameter); } // ensure a newline is always put at the end of the program execution, unless in quiet mode. - if (data->verbosity != f_console_verbosity_quiet) { + if (data->error.verbosity != f_console_verbosity_quiet) { if (F_status_is_error(status) || !data->mode) { - fprintf(f_type_error, "%c", f_string_eol[0]); + dprintf(data->error.to, "%c", f_string_eol[0]); } } diff --git a/level_3/iki_read/c/iki_read.h b/level_3/iki_read/c/iki_read.h index 1749355..f2205da 100644 --- a/level_3/iki_read/c/iki_read.h +++ b/level_3/iki_read/c/iki_read.h @@ -42,6 +42,7 @@ #include // fll-2 includes +#include #include #include @@ -94,8 +95,10 @@ extern "C" { iki_read_parameter_light, iki_read_parameter_dark, iki_read_parameter_no_color, - iki_read_parameter_quiet, - iki_read_parameter_verbose, + iki_read_parameter_verbosity_quiet, + iki_read_parameter_verbosity_normal, + iki_read_parameter_verbosity_verbose, + iki_read_parameter_verbosity_debug, iki_read_parameter_version, iki_read_parameter_at, @@ -114,9 +117,10 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, 0, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(iki_read_short_at, iki_read_long_at, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(iki_read_short_content, iki_read_long_content, 0, 0, f_console_type_normal), \ @@ -129,7 +133,7 @@ extern "C" { f_console_parameter_t_initialize(iki_read_short_total, iki_read_long_total, 0, 0, f_console_type_normal), \ } - #define iki_read_total_parameters 16 + #define iki_read_total_parameters 17 #endif // _di_iki_read_defines_ #ifndef _di_iki_read_substitution_t_ @@ -231,7 +235,9 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; + uint8_t mode; f_number_unsigned_t at; @@ -249,7 +255,8 @@ extern "C" { iki_read_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ 0, \ 0, \ 0, \ @@ -269,7 +276,7 @@ extern "C" { * F_none on success. */ #ifndef _di_iki_read_print_help_ - extern f_return_status iki_read_print_help(const f_color_context_t context); + extern f_return_status iki_read_print_help(const int id, const f_color_context_t context); #endif // _di_iki_read_print_help_ /** diff --git a/level_3/iki_read/c/private-iki_read.c b/level_3/iki_read/c/private-iki_read.c index e72eef7..20ae402 100644 --- a/level_3/iki_read/c/private-iki_read.c +++ b/level_3/iki_read/c/private-iki_read.c @@ -10,10 +10,10 @@ extern "C" { if (status == F_parameter) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Invalid parameter when calling function "); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print_line(f_type_error, context.set.error, "()."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Invalid parameter when calling function "); + fl_color_print_to(data.error.to, context.set.notable, "%s", function); + fl_color_print_to(data.error.to, context.set.error, "().%c", f_string_eol[0]); } return F_none; @@ -21,10 +21,10 @@ extern "C" { if (status == F_memory_allocation || status == F_memory_reallocation) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Unable to allocate memory in function "); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print_line(f_type_error, context.set.error, "()."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Unable to allocate memory in function "); + fl_color_print_to(data.error.to, context.set.notable, "%s", function); + fl_color_print_to(data.error.to, context.set.error, "().%c", f_string_eol[0]); } return F_none; @@ -32,10 +32,10 @@ extern "C" { if (status == F_buffer_too_large) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Maximum buffer limit reached while processing "); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print_line(f_type_error, context.set.error, "()."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Maximum buffer limit reached while processing "); + fl_color_print_to(data.error.to, context.set.notable, "%s", function); + fl_color_print_to(data.error.to, context.set.error, "().%c", f_string_eol[0]); } return F_none; @@ -43,22 +43,22 @@ extern "C" { if (status == F_string_too_large) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Maximum string limit reached while processing "); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print_line(f_type_error, context.set.error, "()."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Maximum string limit reached while processing "); + fl_color_print_to(data.error.to, context.set.notable, "%s", function); + fl_color_print_to(data.error.to, context.set.error, "().%c", f_string_eol[0]); } return F_none; } if (fallback && verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") in function "); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print_line(f_type_error, context.set.error, "()."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "UNKNOWN ERROR: ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") in function "); + fl_color_print_to(data.error.to, context.set.notable, "%s", function); + fl_color_print_to(data.error.to, context.set.error, "().%c", f_string_eol[0]); } return F_unknown; @@ -71,10 +71,10 @@ extern "C" { if (status == F_file_found_not) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Failed to find %s '", file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Failed to find %s '", file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -82,10 +82,10 @@ extern "C" { if (status == F_file_found) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: The %s '", file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "' already exists."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The %s '", file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "' already exists.%c", f_string_eol[0]); } return F_false; @@ -93,12 +93,12 @@ extern "C" { if (status == F_parameter) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print(f_type_error, context.set.error, "() for the %s '", file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s", function); + fl_color_print_to(data.error.to, context.set.error, "() for the %s '", file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -106,10 +106,10 @@ extern "C" { if (status == F_name) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Invalid %s name '", file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Invalid %s name '", file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -117,10 +117,10 @@ extern "C" { if (status == F_memory_out) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "CRITICAL ERROR: Unable to allocate memory, while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "CRITICAL ERROR: Unable to allocate memory, while trying to %s %s '", operation, file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -128,10 +128,10 @@ extern "C" { if (status == F_number_overflow) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Overflow while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Overflow while trying to %s %s '", operation, file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -139,10 +139,10 @@ extern "C" { if (status == F_directory) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Invalid directory while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Invalid directory while trying to %s %s '", operation, file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -150,10 +150,10 @@ extern "C" { if (status == F_access_denied) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Access denied while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Access denied while trying to %s %s '", operation, file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -161,10 +161,10 @@ extern "C" { if (status == F_loop) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Loop while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Loop while trying to %s %s '", operation, file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -172,10 +172,10 @@ extern "C" { if (status == F_prohibited) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Prohibited by system while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Prohibited by system while trying to %s %s '", operation, file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -184,10 +184,10 @@ extern "C" { if (is_file) { if (status == F_directory_found_not) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Failed to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "' due to an invalid directory in the path."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Failed to %s %s '", operation, file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "' due to an invalid directory in the path.%c", f_string_eol[0]); } return F_false; @@ -196,10 +196,10 @@ extern "C" { else { if (status == F_directory_found_not) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Failed to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "' due to an invalid directory in the path."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Failed to %s %s '", operation, file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "' due to an invalid directory in the path.%c", f_string_eol[0]); } return F_false; @@ -207,10 +207,10 @@ extern "C" { if (status == F_failure) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Failed to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Failed to %s %s '", operation, file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -218,12 +218,12 @@ extern "C" { } if (iki_read_print_error(context, verbosity, status, function, F_false) == F_unknown && fallback && verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") occurred while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "UNKNOWN ERROR: ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") occurred while trying to %s %s '", operation, file_or_directory); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_true; @@ -234,65 +234,65 @@ extern "C" { void iki_read_print_error_number_argument(const f_color_context_t context, const uint8_t verbosity, const f_status_t status, const f_string_t function, const f_string_t parameter, const f_string_t argument) { if (verbosity == f_console_verbosity_quiet) return; - fprintf(f_type_error, "%c", f_string_eol[0]); + dprintf(data.error.to, "%c", f_string_eol[0]); if (status == F_parameter) { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function); - fl_color_print_line(f_type_error, context.set.error, "."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function); + fl_color_print_to(data.error.to, context.set.error, ".%c", f_string_eol[0]); } else if (status == F_number) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is not a valid number for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is not a valid number for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_underflow) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is too small for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is too small for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_overflow) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is too large for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is too large for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_negative) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' is negative, which is not allowed for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' is negative, which is not allowed for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_number_positive) { - fl_color_print(f_type_error, context.set.error, "ERROR: The argument '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print(f_type_error, context.set.error, "' contains a '"); - fl_color_print(f_type_error, context.set.notable, "+"); - fl_color_print(f_type_error, context.set.error, "', which is not allowed for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The argument '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "' contains a '"); + fl_color_print_to(data.error.to, context.set.notable, "+"); + fl_color_print_to(data.error.to, context.set.error, "', which is not allowed for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_data_not) { - fl_color_print(f_type_error, context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print_line(f_type_error, context.set.error, "' must not be an empty string."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_to(data.error.to, context.set.error, "' must not be an empty string.%c", f_string_eol[0]); } else { - fl_color_print(f_type_error, context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") has occurred while calling "); - fl_color_print(f_type_error, context.set.notable, "%s()", function); - fl_color_print(f_type_error, context.set.error, "' for the parameter '"); - fl_color_print(f_type_error, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print(f_type_error, context.set.error, "' with the value '"); - fl_color_print(f_type_error, context.set.notable, "%s", argument); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "UNKNOWN ERROR: ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") has occurred while calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s()", function); + fl_color_print_to(data.error.to, context.set.error, "' for the parameter '"); + fl_color_print_to(data.error.to, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_to(data.error.to, context.set.error, "' with the value '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", argument); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } } #endif // _di_iki_read_print_error_number_argument_ @@ -399,7 +399,7 @@ extern "C" { status = fl_iki_read(&data->buffer, buffer_range, variable, vocabulary, content); if (F_status_is_error(status)) { - iki_read_print_error(data->context, data->verbosity, F_status_set_fine(status), "fl_iki_read", F_true); + iki_read_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "fl_iki_read", F_true); return status; } @@ -413,7 +413,7 @@ extern "C" { status = iki_read_substitutions_identify(arguments, file_name, data, vocabulary, substitutionss); if (F_status_is_error(status)) { - iki_read_print_error(data->context, data->verbosity, F_status_set_fine(status), "iki_read_substitutions_identify", F_true); + iki_read_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "iki_read_substitutions_identify", F_true); for (f_array_length_t i = 0; i < variable->used; i++) { macro_iki_read_substitutions_t_delete_simple(substitutionss[i]); @@ -439,7 +439,7 @@ extern "C" { status = fl_string_append_nulless(arguments.argv[index], strlen(arguments.argv[index]), &name); if (F_status_is_error(status)) { - iki_read_print_error(data->context, data->verbosity, F_status_set_fine(status), "fl_string_append_nulless", F_true); + iki_read_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "fl_string_append_nulless", F_true); for (f_array_length_t i = 0; i < variable->used; i++) { macro_iki_read_substitutions_t_delete_simple(substitutionss[i]); @@ -513,7 +513,7 @@ extern "C" { status = fl_iki_read(&data->buffer, &range, variable, vocabulary, content); if (F_status_is_error(status)) { - iki_read_print_error(data->context, data->verbosity, F_status_set_fine(status), "fl_iki_read", F_true); + iki_read_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "fl_iki_read", F_true); return status; } @@ -532,7 +532,7 @@ extern "C" { status = iki_read_substitutions_identify(arguments, file_name, data, vocabulary, substitutionss); if (F_status_is_error(status)) { - iki_read_print_error(data->context, data->verbosity, F_status_set_fine(status), "iki_read_substitutions_identify", F_true); + iki_read_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "iki_read_substitutions_identify", F_true); for (f_array_length_t i = 0; i < variable->used; i++) { macro_iki_read_substitutions_t_delete_simple(substitutionss[i]); @@ -573,13 +573,13 @@ extern "C" { if (name_missed) { f_macro_memory_structure_macro_increment(status, names, 1, f_iki_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large); if (F_status_is_error(status)) { - iki_read_print_error(data->context, data->verbosity, F_status_set_fine(status), "iki_read_process_buffer_ranges_whole", F_true); + iki_read_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "iki_read_process_buffer_ranges_whole", F_true); break; } status = fl_string_append_nulless(arguments.argv[index], length_argument, &names.array[names.used]); if (F_status_is_error(status)) { - iki_read_print_error(data->context, data->verbosity, F_status_set_fine(status), "fl_string_append_nulless", F_true); + iki_read_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "fl_string_append_nulless", F_true); break; } @@ -699,7 +699,7 @@ extern "C" { status = fl_iki_read(&data->buffer, &range, variable, vocabulary, content); if (F_status_is_error(status)) { - iki_read_print_error(data->context, data->verbosity, F_status_set_fine(status), "fl_iki_read", F_true); + iki_read_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "fl_iki_read", F_true); return status; } @@ -722,7 +722,7 @@ extern "C" { status = fl_string_append_nulless(arguments.argv[index], strlen(arguments.argv[index]), &name); if (F_status_is_error(status)) { - iki_read_print_error(data->context, data->verbosity, F_status_set_fine(status), "fl_string_append_nulless", F_true); + iki_read_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "fl_string_append_nulless", F_true); f_macro_string_dynamic_t_delete_simple(name); return status; diff --git a/level_3/iki_read/data/build/dependencies b/level_3/iki_read/data/build/dependencies index 960850c..ab00e65 100644 --- a/level_3/iki_read/data/build/dependencies +++ b/level_3/iki_read/data/build/dependencies @@ -17,4 +17,5 @@ fl_console fl_conversion fl_iki fl_string +fll_error fll_program diff --git a/level_3/iki_read/data/build/settings b/level_3/iki_read/data/build/settings index ca8e5ec..6c149cc 100644 --- a/level_3/iki_read/data/build/settings +++ b/level_3/iki_read/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfl_string -lfl_iki -lfl_conversion -lfl_console -lfl_color -lf_print -lf_pipe -lf_iki -lf_file -lf_conversion -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_error -lfl_string -lfl_iki -lfl_conversion -lfl_console -lfl_color -lf_print -lf_pipe -lf_iki -lf_file -lf_conversion -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library iki_read.c private-iki_read.c diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index b6d0726..e0b88b9 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -6,29 +6,29 @@ extern "C" { #endif #ifndef _di_iki_write_print_help_ - f_return_status iki_write_print_help(const f_color_context_t context) { + f_return_status iki_write_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, iki_write_name_long, iki_write_version); + fll_program_print_help_header(id, context, iki_write_name_long, iki_write_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, iki_write_short_file, iki_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to."); - fll_program_print_help_option(context, iki_write_short_content, iki_write_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, "The content to output."); - fll_program_print_help_option(context, iki_write_short_double, iki_write_long_double, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use double quotes (default)."); - fll_program_print_help_option(context, iki_write_short_object, iki_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " The object to output."); - fll_program_print_help_option(context, iki_write_short_single, iki_write_long_single, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use single quotes."); + fll_program_print_help_option(id, context, iki_write_short_file, iki_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to."); + fll_program_print_help_option(id, context, iki_write_short_content, iki_write_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, "The content to output."); + fll_program_print_help_option(id, context, iki_write_short_double, iki_write_long_double, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use double quotes (default)."); + fll_program_print_help_option(id, context, iki_write_short_object, iki_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " The object to output."); + fll_program_print_help_option(id, context, iki_write_short_single, iki_write_long_single, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use single quotes."); - fll_program_print_help_usage(context, iki_write_name, "filename(s)"); + fll_program_print_help_usage(id, context, iki_write_name, "filename(s)"); fl_color_print(f_type_output, context.set.important, " Notes:"); @@ -56,58 +56,70 @@ extern "C" { f_status_t status = F_none; { - f_console_parameter_id_t ids[3] = { iki_write_parameter_no_color, iki_write_parameter_light, iki_write_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, iki_write_total_parameters); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { iki_write_parameter_no_color, iki_write_parameter_light, iki_write_parameter_dark }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - if (F_status_is_error(status)) { - iki_write_print_error(data->context, data->verbosity, F_status_set_fine(status), "fll_program_parameter_process", F_true); + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + iki_write_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "fll_program_parameter_process", F_true); + + if (data->error.verbosity == f_console_verbosity_verbose) { + dprintf(data->error.to, "%c", f_string_eol[0]); + } + + iki_write_delete_data(data); + return F_status_set_error(status); + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { iki_write_parameter_verbosity_quiet, iki_write_parameter_verbosity_normal, iki_write_parameter_verbosity_verbose, iki_write_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); - if (data->verbosity == f_console_verbosity_verbose) { - fprintf(f_type_error, "%c", f_string_eol[0]); + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + iki_write_delete_data(data); + return status; } - iki_write_delete_data(data); - return F_status_set_error(status); + if (choice == iki_write_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == iki_write_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == iki_write_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == iki_write_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } if (data->parameters[iki_write_parameter_help].result == f_console_result_found) { - iki_write_print_help(data->context); + iki_write_print_help(data->output, data->context); iki_write_delete_data(data); return F_none; } if (data->parameters[iki_write_parameter_version].result == f_console_result_found) { - fll_program_print_version(iki_write_version); + fll_program_print_version(data->output, iki_write_version); iki_write_delete_data(data); return F_none; } - if (data->parameters[iki_write_parameter_verbose].result == f_console_result_found) { - if (data->parameters[iki_write_parameter_quiet].result == f_console_result_found) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: Cannot specify the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, f_console_standard_long_verbose); - fl_color_print(f_type_error, data->context.set.error, "' parameter with the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, f_console_standard_long_quiet); - fl_color_print_line(f_type_error, data->context.set.error, "' parameter."); - - status = F_status_set_error(F_parameter); - } - - data->verbosity = f_console_verbosity_verbose; - } - else if (data->parameters[iki_write_parameter_quiet].result == f_console_result_found) { - data->verbosity = f_console_verbosity_quiet; - } - f_file_t output = f_file_t_initialize; output.id = f_type_descriptor_output; @@ -116,10 +128,10 @@ extern "C" { if (F_status_is_fine(status)) { if (data->parameters[iki_write_parameter_file].result == f_console_result_additional) { if (data->parameters[iki_write_parameter_file].additional.used > 1) { - if (data->verbosity != f_console_verbosity_quiet) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_file); - fl_color_print_line(f_type_error, data->context.set.error, "' may only be specified once."); + if (data->error.verbosity != f_console_verbosity_quiet) { + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_file); + fl_color_print_to(data->error.to, data->context.set.error, "' may only be specified once.%c", f_string_eol[0]); } status = F_status_set_error(F_parameter); @@ -131,15 +143,15 @@ extern "C" { status = f_file_open(arguments.argv[location], f_file_mode_all_rw, &output); if (F_status_is_error(status)) { - iki_write_print_error_file(data->context, data->verbosity, F_status_set_fine(status), "f_file_open", arguments.argv[location], "open", 0, F_true); + iki_write_print_error_file(data->context, data->error.verbosity, F_status_set_fine(status), "f_file_open", arguments.argv[location], "open", 0, F_true); } } } else if (data->parameters[iki_write_parameter_file].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_file); - fl_color_print_line(f_type_error, data->context.set.error, "' was specified, but no value was given."); + if (data->error.verbosity != f_console_verbosity_quiet) { + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_file); + fl_color_print_to(data->error.to, data->context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); } status = F_status_set_error(F_parameter); @@ -147,20 +159,20 @@ extern "C" { } if (F_status_is_fine(status) && data->parameters[iki_write_parameter_object].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_object); - fl_color_print_line(f_type_error, data->context.set.error, "' was specified, but no value was given."); + if (data->error.verbosity != f_console_verbosity_quiet) { + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); } status = F_status_set_error(F_parameter); } if (F_status_is_fine(status) && data->parameters[iki_write_parameter_content].result == f_console_result_found) { - if (data->verbosity != f_console_verbosity_quiet) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_content); - fl_color_print_line(f_type_error, data->context.set.error, "' was specified, but no value was given."); + if (data->error.verbosity != f_console_verbosity_quiet) { + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_content); + fl_color_print_to(data->error.to, data->context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); } status = F_status_set_error(F_parameter); @@ -168,13 +180,13 @@ extern "C" { if (F_status_is_fine(status) && !data->process_pipe) { if (data->parameters[iki_write_parameter_object].result != f_console_result_additional && data->parameters[iki_write_parameter_content].result != f_console_result_additional) { - if (data->verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.set.error, "ERROR: No data provided, either pipe the data or use the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_object); - fl_color_print(f_type_error, data->context.set.error, "' and the '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_content); - fl_color_print_line(f_type_error, data->context.set.error, "' parameters."); + if (data->error.verbosity != f_console_verbosity_quiet) { + dprintf(data->error.to, "%c", f_string_eol[0]); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: No data provided, either pipe the data or use the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' and the '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_content); + fl_color_print_to(data->error.to, data->context.set.error, "' parameters.%c", f_string_eol[0]); } status = F_status_set_error(F_parameter); @@ -183,12 +195,12 @@ extern "C" { if (F_status_is_fine(status)) { if (data->parameters[iki_write_parameter_object].additional.used != data->parameters[iki_write_parameter_content].additional.used) { - if (data->verbosity != f_console_verbosity_quiet) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameters '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_content); - fl_color_print(f_type_error, data->context.set.error, "' and '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_object); - fl_color_print_line(f_type_error, data->context.set.error, "' must be specified the same number of times."); + if (data->error.verbosity != f_console_verbosity_quiet) { + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameters '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_content); + fl_color_print_to(data->error.to, data->context.set.error, "' and '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_object); + fl_color_print_to(data->error.to, data->context.set.error, "' must be specified the same number of times.%c", f_string_eol[0]); } status = F_status_set_error(F_parameter); @@ -236,15 +248,15 @@ extern "C" { status_pipe = f_file_read(file, &buffer); if (F_status_is_error(status_pipe)) { - iki_write_print_error_file(data->context, data->verbosity, F_status_set_fine(status_pipe), "f_file_read_to", "-", "read", 2, F_true); + iki_write_print_error_file(data->context, data->error.verbosity, F_status_set_fine(status_pipe), "f_file_read_to", "-", "read", 2, F_true); status = F_status_set_error(F_pipe); break; } if (!buffer.used) { - if (data->verbosity != f_console_verbosity_quiet) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: The pipe has no content."); + if (data->error.verbosity != f_console_verbosity_quiet) { + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The pipe has no content.%c", f_string_eol[0]); } status = F_status_set_error(F_parameter); @@ -258,19 +270,19 @@ extern "C" { status = fl_string_dynamic_seek_line(buffer.string, &range); if (F_status_is_error(status)) { - iki_write_print_error(data->context, data->verbosity, F_status_set_fine(status), "fl_string_dynamic_seek_line", F_true); + iki_write_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "fl_string_dynamic_seek_line", F_true); break; } if (status == F_data_not_stop) { status = F_status_set_error(F_parameter); - iki_write_print_error(data->context, data->verbosity, F_parameter, "fl_string_dynamic_seek_line", F_true); + iki_write_print_error(data->context, data->error.verbosity, F_parameter, "fl_string_dynamic_seek_line", F_true); break; } if (object_ended && previous == range.start) { - if (data->verbosity != f_console_verbosity_quiet) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: The pipe has incorrectly placed newlines."); + if (data->error.verbosity != f_console_verbosity_quiet) { + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The pipe has incorrectly placed newlines.%c", f_string_eol[0]); } status = F_status_set_error(F_parameter); @@ -287,7 +299,7 @@ extern "C" { status = fl_string_dynamic_partial_append_nulless(buffer, range, &content); if (F_status_is_error(status)) { - iki_write_print_error(data->context, data->verbosity, F_status_set_fine(status), "fl_string_dynamic_partial_append_nulless", F_true); + iki_write_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "fl_string_dynamic_partial_append_nulless", F_true); break; } } @@ -305,7 +317,7 @@ extern "C" { status = fl_string_dynamic_partial_append_nulless(buffer, range, &object); if (F_status_is_error(status)) { - iki_write_print_error(data->context, data->verbosity, F_status_set_fine(status), "fl_string_dynamic_partial_append_nulless", F_true); + iki_write_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "fl_string_dynamic_partial_append_nulless", F_true); break; } @@ -326,8 +338,8 @@ extern "C" { } // for if (F_status_is_fine(status) && object_ended) { - if (data->verbosity != f_console_verbosity_quiet) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: The pipe has an object without content."); + if (data->error.verbosity != f_console_verbosity_quiet) { + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The pipe has an object without content.%c", f_string_eol[0]); } status = F_status_set_error(F_parameter); @@ -359,7 +371,7 @@ extern "C" { } // for // ensure there is always a newline at the end, unless in quiet mode. - if (F_status_is_fine(status) && data->verbosity != f_console_verbosity_quiet && data->parameters[iki_write_parameter_file].result == f_console_result_none) { + if (F_status_is_fine(status) && data->error.verbosity != f_console_verbosity_quiet && data->parameters[iki_write_parameter_file].result == f_console_result_none) { fprintf(f_type_output, "%c", f_string_eol[0]); } } @@ -374,9 +386,9 @@ extern "C" { } // ensure a newline is always put at the end of the program execution, unless in quiet mode. - if (data->verbosity != f_console_verbosity_quiet) { + if (data->error.verbosity != f_console_verbosity_quiet) { if (F_status_is_error(status)) { - fprintf(f_type_error, "%c", f_string_eol[0]); + dprintf(data->error.to, "%c", f_string_eol[0]); } } diff --git a/level_3/iki_write/c/iki_write.h b/level_3/iki_write/c/iki_write.h index ab299d1..9232668 100644 --- a/level_3/iki_write/c/iki_write.h +++ b/level_3/iki_write/c/iki_write.h @@ -42,6 +42,7 @@ #include // fll-2 includes +#include #include #include #include @@ -80,8 +81,10 @@ extern "C" { iki_write_parameter_light, iki_write_parameter_dark, iki_write_parameter_no_color, - iki_write_parameter_quiet, - iki_write_parameter_verbose, + iki_write_parameter_verbosity_quiet, + iki_write_parameter_verbosity_normal, + iki_write_parameter_verbosity_verbose, + iki_write_parameter_verbosity_debug, iki_write_parameter_version, iki_write_parameter_file, @@ -98,7 +101,9 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(iki_write_short_file, iki_write_long_file, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(iki_write_short_content, iki_write_long_content, 0, 1, f_console_type_normal), \ @@ -107,7 +112,7 @@ extern "C" { f_console_parameter_t_initialize(iki_write_short_single, iki_write_long_single, 0, 0, f_console_type_normal), \ } - #define iki_write_total_parameters 12 + #define iki_write_total_parameters 14 #endif // _di_iki_write_defines_ #ifndef _di_iki_write_data_t_ @@ -117,7 +122,8 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; f_string_dynamic_t buffer; @@ -129,7 +135,8 @@ extern "C" { iki_write_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ f_string_dynamic_t_initialize, \ f_color_context_t_initialize, \ } @@ -145,7 +152,7 @@ extern "C" { * F_none on success. */ #ifndef _di_iki_write_print_help_ - extern f_return_status iki_write_print_help(const f_color_context_t context); + extern f_return_status iki_write_print_help(const int id, const f_color_context_t context); #endif // _di_iki_write_print_help_ /** diff --git a/level_3/iki_write/c/private-iki_write.c b/level_3/iki_write/c/private-iki_write.c index ec61929..01f1ebf 100644 --- a/level_3/iki_write/c/private-iki_write.c +++ b/level_3/iki_write/c/private-iki_write.c @@ -10,10 +10,10 @@ extern "C" { if (status == F_parameter) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Invalid parameter when calling function "); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print_line(f_type_error, context.set.error, "()."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Invalid parameter when calling function "); + fl_color_print_to(data.error.to, context.set.notable, "%s", function); + fl_color_print_to(data.error.to, context.set.error, "().%c", f_string_eol[0]); } return F_none; @@ -21,10 +21,10 @@ extern "C" { if (status == F_memory_allocation || status == F_memory_reallocation) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Unable to allocate memory in function "); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print_line(f_type_error, context.set.error, "()."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Unable to allocate memory in function "); + fl_color_print_to(data.error.to, context.set.notable, "%s", function); + fl_color_print_to(data.error.to, context.set.error, "().%c", f_string_eol[0]); } return F_none; @@ -32,10 +32,10 @@ extern "C" { if (status == F_buffer_too_large) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Maximum buffer limit reached while processing "); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print_line(f_type_error, context.set.error, "()."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Maximum buffer limit reached while processing "); + fl_color_print_to(data.error.to, context.set.notable, "%s", function); + fl_color_print_to(data.error.to, context.set.error, "().%c", f_string_eol[0]); } return F_none; @@ -43,22 +43,22 @@ extern "C" { if (status == F_string_too_large) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Maximum string limit reached while processing "); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print_line(f_type_error, context.set.error, "()."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Maximum string limit reached while processing "); + fl_color_print_to(data.error.to, context.set.notable, "%s", function); + fl_color_print_to(data.error.to, context.set.error, "().%c", f_string_eol[0]); } return F_none; } if (fallback && verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") in function "); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print_line(f_type_error, context.set.error, "()."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "UNKNOWN ERROR: ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") in function "); + fl_color_print_to(data.error.to, context.set.notable, "%s", function); + fl_color_print_to(data.error.to, context.set.error, "().%c", f_string_eol[0]); } return F_unknown; @@ -78,10 +78,10 @@ extern "C" { if (status == F_file_found_not) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Failed to find %s '", type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Failed to find %s '", type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -89,9 +89,9 @@ extern "C" { if (status == F_file_closed) { if (verbosity != f_console_verbosity_quiet) { - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: The %s '", type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "' is no longer open."); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: The %s '", type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "' is no longer open.%c", f_string_eol[0]); } return F_false; @@ -99,9 +99,9 @@ extern "C" { if (status == F_file_seek) { if (verbosity != f_console_verbosity_quiet) { - fl_color_print(f_type_error, context.set.error, "ERROR: A seek error occurred while accessing the file '"); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: A seek error occurred while accessing the file '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -109,9 +109,9 @@ extern "C" { if (status == F_file_read) { if (verbosity != f_console_verbosity_quiet) { - fl_color_print(f_type_error, context.set.error, "ERROR: A read error occurred while accessing the file '"); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + fl_color_print_to(data.error.to, context.set.error, "ERROR: A read error occurred while accessing the file '"); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -119,10 +119,10 @@ extern "C" { if (status == F_file_found) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: The %s '", type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "' already exists."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: The %s '", type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "' already exists.%c", f_string_eol[0]); } return F_false; @@ -130,12 +130,12 @@ extern "C" { if (status == F_parameter) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, context.set.notable, "%s", function); - fl_color_print(f_type_error, context.set.error, "() for the %s '", type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print_to(data.error.to, context.set.notable, "%s", function); + fl_color_print_to(data.error.to, context.set.error, "() for the %s '", type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -143,10 +143,10 @@ extern "C" { if (status == F_name) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Invalid %s name '", type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Invalid %s name '", type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -154,10 +154,10 @@ extern "C" { if (status == F_memory_out) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "CRITICAL ERROR: Unable to allocate memory, while trying to %s %s '", operation, type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "CRITICAL ERROR: Unable to allocate memory, while trying to %s %s '", operation, type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -165,10 +165,10 @@ extern "C" { if (status == F_number_overflow) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Overflow while trying to %s %s '", operation, type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Overflow while trying to %s %s '", operation, type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -176,10 +176,10 @@ extern "C" { if (status == F_directory) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Invalid directory while trying to %s %s '", operation, type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Invalid directory while trying to %s %s '", operation, type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -187,10 +187,10 @@ extern "C" { if (status == F_access_denied) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Access denied while trying to %s %s '", operation, type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Access denied while trying to %s %s '", operation, type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -198,10 +198,10 @@ extern "C" { if (status == F_loop) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Loop while trying to %s %s '", operation, type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Loop while trying to %s %s '", operation, type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -209,10 +209,10 @@ extern "C" { if (status == F_prohibited) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Prohibited by system while trying to %s %s '", operation, type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Prohibited by system while trying to %s %s '", operation, type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -221,10 +221,10 @@ extern "C" { if (!type) { if (status == F_directory_found_not) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Failed to %s %s '", operation, type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "' due to an invalid directory in the path."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Failed to %s %s '", operation, type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "' due to an invalid directory in the path.%c", f_string_eol[0]); } return F_false; @@ -233,10 +233,10 @@ extern "C" { else if (type == 1) { if (status == F_directory_found_not) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Failed to %s %s '", operation, type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "' due to an invalid directory in the path."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Failed to %s %s '", operation, type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "' due to an invalid directory in the path.%c", f_string_eol[0]); } return F_false; @@ -244,10 +244,10 @@ extern "C" { if (status == F_failure) { if (verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "ERROR: Failed to %s %s '", operation, type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "ERROR: Failed to %s %s '", operation, type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_false; @@ -255,12 +255,12 @@ extern "C" { } if (iki_write_print_error(context, verbosity, status, function, F_false) == F_unknown && fallback && verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.set.notable, "%llu", status); - fl_color_print(f_type_error, context.set.error, ") occurred while trying to %s %s '", operation, type_name); - fl_color_print(f_type_error, context.set.notable, "%s", name); - fl_color_print_line(f_type_error, context.set.error, "'."); + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, context.set.error, "UNKNOWN ERROR: ("); + fl_color_print_to(data.error.to, context.set.notable, "%llu", status); + fl_color_print_to(data.error.to, context.set.error, ") occurred while trying to %s %s '", operation, type_name); + fl_color_print_to(data.error.to, context.set.notable, "%s", name); + fl_color_print_to(data.error.to, context.set.error, "'.%c", f_string_eol[0]); } return F_true; @@ -271,11 +271,11 @@ extern "C" { f_return_status iki_write_process(const iki_write_data_t data, const f_string_static_t object, const f_string_static_t content, const uint8_t quote, const int output, f_string_dynamic_t *escaped) { if (!object.used) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The object is missing, it must not have a length of "); - fl_color_print(f_type_error, data.context.set.notable, "0"); - fl_color_print_line(f_type_error, data.context.set.error, "."); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The object is missing, it must not have a length of "); + fl_color_print_to(data.error.to, data.context.set.notable, "0"); + fl_color_print_to(data.error.to, data.context.set.error, ".%c", f_string_eol[0]); } return F_status_set_error(F_failure); @@ -284,21 +284,21 @@ extern "C" { f_status_t status = f_iki_object_is(object); if (status == F_false) { - if (data.verbosity != f_console_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.set.error, "ERROR: The object '"); + if (data.error.verbosity != f_console_verbosity_quiet) { + dprintf(data.error.to, "%c", f_string_eol[0]); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: The object '"); fl_color_print_code(f_type_error, data.context.notable); f_print_dynamic(f_type_error, object); fl_color_print_code(f_type_error, data.context.reset); - fl_color_print_line(f_type_error, data.context.set.error, "' is not a valid IKI object."); + fl_color_print_to(data.error.to, data.context.set.error, "' is not a valid IKI object.%c", f_string_eol[0]); } return F_status_set_error(F_failure); } else if (F_status_is_error(status)) { - iki_write_print_error(data.context, data.verbosity, F_status_set_fine(status), "f_iki_object_is", F_true); + iki_write_print_error(data.context, data.error.verbosity, F_status_set_fine(status), "f_iki_object_is", F_true); return F_status_set_error(F_failure); } @@ -308,7 +308,7 @@ extern "C" { status = fll_iki_content_escape(content, quote, escaped); if (F_status_is_error(status)) { - iki_write_print_error(data.context, data.verbosity, F_status_set_fine(status), "fll_iki_content_escape", F_true); + iki_write_print_error(data.context, data.error.verbosity, F_status_set_fine(status), "fll_iki_content_escape", F_true); f_macro_string_dynamic_t_delete_simple((*escaped)); return F_status_set_error(F_failure); diff --git a/level_3/iki_write/data/build/dependencies b/level_3/iki_write/data/build/dependencies index 581c7ae..d92f738 100644 --- a/level_3/iki_write/data/build/dependencies +++ b/level_3/iki_write/data/build/dependencies @@ -16,4 +16,5 @@ fl_console fl_iki fl_string fll_iki +fll_error fll_program diff --git a/level_3/iki_write/data/build/settings b/level_3/iki_write/data/build/settings index d6b0190..aa1be1d 100644 --- a/level_3/iki_write/data/build/settings +++ b/level_3/iki_write/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfll_iki -lfl_string -lfl_iki -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_iki -lf_file -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_error -lfll_iki -lfl_string -lfl_iki -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_iki -lf_file -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library iki_write.c private-iki_write.c diff --git a/level_3/init/c/init.c b/level_3/init/c/init.c index 526cc84..096f7c7 100644 --- a/level_3/init/c/init.c +++ b/level_3/init/c/init.c @@ -24,26 +24,26 @@ extern "C" { #endif // _di_init_print_version_ #ifndef _di_init_print_help_ - f_return_status init_print_help(const f_color_context_t context) { + f_return_status init_print_help(const int id, const f_color_context_t context) { - fll_program_print_help_header(context, init_name_long, init_version); + fll_program_print_help_header(id, context, init_name_long, init_version); - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, init_parameter_no_prepare_short_name, init_parameter_no_prepare_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Do not attempt to process kernel command line or perform any boot-time specific preparations."); - fll_program_print_help_option(context, init_parameter_runlevel_short_name, init_parameter_runlevel_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a custom run level, ignoring the kernel command line runlevel argument."); + fll_program_print_help_option(id, context, init_parameter_no_prepare_short_name, init_parameter_no_prepare_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Do not attempt to process kernel command line or perform any boot-time specific preparations."); + fll_program_print_help_option(id, context, init_parameter_runlevel_short_name, init_parameter_runlevel_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a custom run level, ignoring the kernel command line runlevel argument."); - fll_program_print_help_usage(context, init_name, ""); + fll_program_print_help_usage(id, context, init_name, ""); return F_none; } @@ -60,20 +60,64 @@ extern "C" { unsigned short do_socket_port = F_false; { - f_console_parameter_id_t ids[3] = { init_parameter_no_color, init_parameter_light, init_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, init_total_parameters); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { init_parameter_no_color, init_parameter_light, init_parameter_dark }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - if (F_status_is_error(status)) { - // @todo: init_delete_data(data); - return F_status_set_error(status); + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + // @todo: init_delete_data(data); + return F_status_set_error(status); + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { init_parameter_verbosity_quiet, init_parameter_verbosity_normal, init_parameter_verbosity_verbose, init_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + init_delete_data(data); + return status; + } + + if (choice == init_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == init_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == init_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == init_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } + if (data->parameters[init_parameter_help].result == f_console_result_found) { + init_print_help(data->output, data->context); + + init_delete_data(data); + return F_none; + } + + if (data->parameters[init_parameter_version].result == f_console_result_found) { + fll_program_print_version(data->output, init_version); + + init_delete_data(data); + return F_none; + } + if (data->parameters[init_parameter_runlevel].result == f_console_result_found) { const unsigned int parameter_length = strlen(arguments.argv[data->parameters[init_parameter_runlevel].additional.array[0]]); @@ -124,13 +168,13 @@ extern "C" { pid_t pid_services = clone(init_handler_child_services, stack_memory.services + init_stack_size_small_services, init_flags_clone, stack_memory.services); if (pid_services < 0) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to clone services process (errno = %i).", errno); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to clone services process (errno = %i).%c", errno, f_string_eol[0]); } pid_t pid_control_file = clone(init_handler_child_control_file, stack_memory.control_file + init_stack_size_control_file, init_flags_clone, stack_memory.control_file); if (pid_control_file < 0) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to clone control via file process (errno = %i).", errno); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Failed to clone control via file process (errno = %i).%c", errno, f_string_eol[0]); } */ @@ -158,11 +202,11 @@ extern "C" { continue; } else if (errno != EINTR) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: sigwaitinfo() failed (errno = %i).", errno); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: sigwaitinfo() failed (errno = %i).%c", errno, f_string_eol[0]); signal_problem_count++; if (signal_problem_count > problem_count_max_signal_size) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Max signal problem count has been reached, sleeping for a period of time.", errno); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: Max signal problem count has been reached, sleeping for a period of time.%c", errno, f_string_eol[0]); sleep(init_panic_signal_sleep_seconds); signal_problem_count = 0; } diff --git a/level_3/init/c/init.h b/level_3/init/c/init.h index e38fc9d..2cac4e3 100644 --- a/level_3/init/c/init.h +++ b/level_3/init/c/init.h @@ -80,6 +80,7 @@ #include // fll-2 includes +#include #include #include #include @@ -178,12 +179,16 @@ extern "C" { init_parameter_light, init_parameter_dark, init_parameter_no_color, - init_parameter_version, + init_parameter_verbosity_quiet, + init_parameter_verbosity_normal, + init_parameter_verbosity_verbose, #ifdef _en_init_debug_ - init_parameter_debug, + init_parameter_verbosity_debug, #endif // _en_init_debug_ + init_parameter_version, + init_parameter_runlevel, init_parameter_no_prepare, }; @@ -195,13 +200,16 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(init_parameter_runlevel_short_name, init_parameter_runlevel_long_name, 0, F_true, f_console_type_normal), \ f_console_parameter_t_initialize(init_parameter_no_prepare_short_name, init_parameter_no_prepare_long_name, 0, F_true, f_console_type_normal), \ } - #define init_total_parameters 8 + #define init_total_parameters 11 #else #define init_console_parameter_t_initialize \ { \ @@ -209,12 +217,15 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(init_parameter_runlevel_short_name, init_parameter_runlevel_long_name, 0, F_true, f_console_type_normal), \ f_console_parameter_t_initialize(init_parameter_no_prepare_short_name, init_parameter_no_prepare_long_name, 0, F_true, f_console_type_normal), \ } - #define init_total_parameters 7 + #define init_total_parameters 10 #endif // _en_init_debug_ #endif // _di_init_defines_ @@ -225,7 +236,8 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; f_color_context_t context; } init_data_t; @@ -235,7 +247,8 @@ extern "C" { init_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ f_color_context_t_initialize, \ } @@ -290,7 +303,7 @@ extern "C" { * F_none on success. */ #ifndef _di_init_print_help_ - extern f_return_status init_print_help(const f_color_context_t context); + extern f_return_status init_print_help(const int id, const f_color_context_t context); #endif // _di_init_print_help_ /** diff --git a/level_3/init/c/private-init.c b/level_3/init/c/private-init.c index 1921af5..f9678ab 100644 --- a/level_3/init/c/private-init.c +++ b/level_3/init/c/private-init.c @@ -17,21 +17,21 @@ if (optional) { if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()."); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open().%c", f_string_eol[0]); } else if (status != F_file_found_not && status != F_file_open && status != F_file_descriptor) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().", status); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().%c", status, f_string_eol[0]); } } else { if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()."); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open().%c", f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: Unable to find the file '%s'.", filename); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Unable to find the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: Unable to open the file '%s'.", filename); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Unable to open the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: File descriptor error while trying to open the file '%s'.", filename); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: File descriptor error while trying to open the file '%s'.%c", filename, f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().", status); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().%c", status, f_string_eol[0]); } } @@ -49,19 +49,19 @@ status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_read_until()."); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_read_until().%c", f_string_eol[0]); } else if (status == F_number_overflow) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: Integer overflow while trying to buffer the file '%s'.", filename); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: Integer overflow while trying to buffer the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_file_closed) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: The file '%s' is no longer open.", filename); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: The file '%s' is no longer open.%c", filename, f_string_eol[0]); } else if (status == F_file_seek) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: A seek error occurred while accessing the file '%s'.", filename); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: A seek error occurred while accessing the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_file_read) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: A read error occurred while accessing the file '%s'.", filename); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: A read error occurred while accessing the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_read_until().", status); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_read_until().%c", status, f_string_eol[0]); } return F_status_set_error(status); @@ -77,13 +77,13 @@ status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", filename); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_data_not_eos || status == F_data_not || status == F_data_not_stop) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: No relevant data was found within the file '%s'.", filename); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: No relevant data was found within the file '%s'.%c", filename, f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.", status, filename); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.%c", status, filename, f_string_eol[0]); } return F_status_set_error(status); @@ -107,11 +107,11 @@ status = F_status_set_fine(status); if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); } else if (status == F_failure) { // the error message has already been displayed. } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); } f_macro_fss_objects_t_delete_simple(local->rule_objects); @@ -494,13 +494,13 @@ status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", init_rule_core_file); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", init_rule_core_file); } else if (status == F_data_not_eos || status == F_data_not || status == F_data_not_stop) { - fl_color_print_line(f_type_error, data.context.set.error, "ERROR: No relevant data was found within the file '%s'.", init_rule_core_file); + fl_color_print_to(data.error.to, data.context.set.error, "ERROR: No relevant data was found within the file '%s'.", init_rule_core_file); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.", status, init_rule_core_file); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.", status, init_rule_core_file); } f_macro_string_dynamic_t_delete(buffer); @@ -525,10 +525,10 @@ if (F_status_is_error(status_process)) { if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling init_load_main_rule().", status); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling init_load_main_rule().", status); } // @todo: init_delete_data((*data)); @@ -551,11 +551,11 @@ status = F_status_set_fine(status); if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); } else if (status == F_failure) { // the error message has already been displayed. } else { - fl_color_print_line(f_type_error, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); + fl_color_print_to(data.error.to, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); } f_macro_fss_objects_t_delete_simple((*rule_objects)); @@ -565,10 +565,10 @@ } else { if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print_line(f_type_error, context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_to(data.error.to, context.set.error, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_type_error, context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling init_load_main_rule().", status); + fl_color_print_to(data.error.to, context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling init_load_main_rule().", status); } } diff --git a/level_3/init/data/build/dependencies b/level_3/init/data/build/dependencies index 2c1c9af..73d3b85 100644 --- a/level_3/init/data/build/dependencies +++ b/level_3/init/data/build/dependencies @@ -18,6 +18,7 @@ fl_console fl_fss fl_status fl_string +fll_error fll_execute fll_fss fll_program diff --git a/level_3/init/data/build/settings b/level_3/init/data/build/settings index b23ab2c..6d0e79a 100644 --- a/level_3/init/data/build/settings +++ b/level_3/init/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_program -lfll_fss -lfl_conversion -lfll_execute -lfl_environment -lf_signal -lf_path -lfl_string -lfl_status -lfl_fss -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_program -lfll_fss -lfl_conversion -lfll_execute -lfl_environment -lf_signal -lf_path -lfll_error -lfl_string -lfl_status -lfl_fss -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library init.c private-init.c diff --git a/level_3/status_code/c/private-status_code.c b/level_3/status_code/c/private-status_code.c index 0df91e1..c44d8de 100644 --- a/level_3/status_code/c/private-status_code.c +++ b/level_3/status_code/c/private-status_code.c @@ -55,13 +55,13 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(value, &number, range); if (status == F_none) { - fl_color_print_line(f_type_output, data.context.set.error, "invalid name"); + fl_color_print(f_type_output, data.context.set.error, "invalid name%c", f_string_eol[0]); return F_status_set_error(F_parameter); } if (status == F_data_not || F_status_set_fine(status) == F_parameter) { - fl_color_print_line(f_type_output, data.context.set.error, "invalid data"); + fl_color_print(f_type_output, data.context.set.error, "invalid data%c", f_string_eol[0]); return status; } @@ -73,17 +73,17 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { - fl_color_print_line(f_type_output, data.context.set.error, "unknown name"); + fl_color_print(f_type_output, data.context.set.error, "unknown name%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_output, data.context.set.error, "failed to convert"); + fl_color_print(f_type_output, data.context.set.error, "failed to convert%c", f_string_eol[0]); } return status; } if (status == F_data) { - fl_color_print_line(f_type_output, data.context.set.warning, "unknown code"); + fl_color_print(f_type_output, data.context.set.warning, "unknown code%c", f_string_eol[0]); return F_none; } @@ -110,10 +110,10 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { - fl_color_print_line(f_type_output, data.context.set.error, "unknown code"); + fl_color_print(f_type_output, data.context.set.error, "unknown code%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_output, data.context.set.error, "failed to convert"); + fl_color_print(f_type_output, data.context.set.error, "failed to convert%c", f_string_eol[0]); } return status; @@ -132,17 +132,17 @@ extern "C" { f_status_t status = fl_conversion_string_to_number_unsigned(value, number, range); if (*number > F_status_size_max_with_signal) { - fl_color_print_line(f_type_output, data.context.set.error, "out of range"); + fl_color_print(f_type_output, data.context.set.error, "out of range%c", f_string_eol[0]); return status; } if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_number_negative) { - fl_color_print_line(f_type_output, data.context.set.error, "out of range"); + fl_color_print(f_type_output, data.context.set.error, "out of range%c", f_string_eol[0]); } else { - fl_color_print_line(f_type_output, data.context.set.error, "invalid number"); + fl_color_print(f_type_output, data.context.set.error, "invalid number%c", f_string_eol[0]); } return status; diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index f56af78..883001c 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -6,27 +6,27 @@ extern "C" { #endif #ifndef _di_status_code_print_help_ - f_return_status status_code_print_help(const f_color_context_t context) { - fll_program_print_help_header(context, status_code_name_long, status_code_version); - - fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); - fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); - fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); - fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); - fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); + f_return_status status_code_print_help(const int id, const f_color_context_t context) { + fll_program_print_help_header(id, context, status_code_name_long, status_code_version); + + fll_program_print_help_option(id, context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message."); + fll_program_print_help_option(id, context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(id, context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(id, context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output."); + fll_program_print_help_option(id, context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, status_code_short_is_fine, status_code_long_is_fine, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print F_true if the error code is not an error, F_false otherwise."); - fll_program_print_help_option(context, status_code_short_is_warning, status_code_long_is_warning, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print F_true if the error code is a warning, F_false otherwise."); - fll_program_print_help_option(context, status_code_short_is_error, status_code_long_is_error, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print F_true if the error code is an error, F_false otherwise."); - fll_program_print_help_option(context, status_code_short_number, status_code_long_number, f_console_symbol_short_enable, f_console_symbol_long_enable, " Convert status code name to number."); + fll_program_print_help_option(id, context, status_code_short_is_fine, status_code_long_is_fine, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print F_true if the error code is not an error, F_false otherwise."); + fll_program_print_help_option(id, context, status_code_short_is_warning, status_code_long_is_warning, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print F_true if the error code is a warning, F_false otherwise."); + fll_program_print_help_option(id, context, status_code_short_is_error, status_code_long_is_error, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print F_true if the error code is an error, F_false otherwise."); + fll_program_print_help_option(id, context, status_code_short_number, status_code_long_number, f_console_symbol_short_enable, f_console_symbol_long_enable, " Convert status code name to number."); - fll_program_print_help_usage(context, status_code_name, "status code(s)"); + fll_program_print_help_usage(id, context, status_code_name, "status code(s)"); return F_none; } @@ -37,29 +37,59 @@ extern "C" { f_status_t status = F_none; { - f_console_parameter_id_t ids[3] = { status_code_parameter_no_color, status_code_parameter_light, status_code_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, status_code_total_parameters); - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + { + f_console_parameter_id_t ids[3] = { status_code_parameter_no_color, status_code_parameter_light, status_code_parameter_dark }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - if (F_status_is_error(status)) { - status_code_delete_data(data); - return F_status_set_error(status); + status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); + + if (F_status_is_error(status)) { + status_code_delete_data(data); + return F_status_set_error(status); + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id_t ids[4] = { status_code_parameter_verbosity_quiet, status_code_parameter_verbosity_normal, status_code_parameter_verbosity_verbose, status_code_parameter_verbosity_debug }; + f_console_parameter_id_t choice = 0; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + status_code_delete_data(data); + return status; + } + + if (choice == status_code_parameter_verbosity_quiet) { + data->error.verbosity = f_console_verbosity_quiet; + } + else if (choice == status_code_parameter_verbosity_normal) { + data->error.verbosity = f_console_verbosity_normal; + } + else if (choice == status_code_parameter_verbosity_verbose) { + data->error.verbosity = f_console_verbosity_verbose; + } + else if (choice == status_code_parameter_verbosity_debug) { + data->error.verbosity = f_console_verbosity_debug; + } } status = F_none; } if (data->parameters[status_code_parameter_help].result == f_console_result_found) { - status_code_print_help(data->context); + status_code_print_help(data->output, data->context); status_code_delete_data(data); return F_none; } if (data->parameters[status_code_parameter_version].result == f_console_result_found) { - fll_program_print_version(status_code_version); + fll_program_print_version(data->output, status_code_version); status_code_delete_data(data); return F_none; @@ -67,39 +97,39 @@ extern "C" { if (data->parameters[status_code_parameter_is_error].result == f_console_result_found) { if (data->parameters[status_code_parameter_is_warning].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_error); - fl_color_print(f_type_error, data->context.set.error, "' cannot be used with the parameter "); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_warning); - fl_color_print_line(f_type_error, data->context.set.error, "."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_error); + fl_color_print_to(data->error.to, data->context.set.error, "' cannot be used with the parameter "); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_warning); + fl_color_print_to(data->error.to, data->context.set.error, ".%c", f_string_eol[0]); status_code_delete_data(data); return F_status_set_error(status); } else if (data->parameters[status_code_parameter_is_fine].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_error); - fl_color_print(f_type_error, data->context.set.error, "' cannot be used with the parameter "); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_fine); - fl_color_print_line(f_type_error, data->context.set.error, "."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_error); + fl_color_print_to(data->error.to, data->context.set.error, "' cannot be used with the parameter "); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_fine); + fl_color_print_to(data->error.to, data->context.set.error, ".%c", f_string_eol[0]); status_code_delete_data(data); return F_status_set_error(status); } } else if (data->parameters[status_code_parameter_is_warning].result == f_console_result_found && data->parameters[status_code_parameter_is_fine].result == f_console_result_found) { - fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '"); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_warning); - fl_color_print(f_type_error, data->context.set.error, "' cannot be used with the parameter "); - fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_fine); - fl_color_print_line(f_type_error, data->context.set.error, "."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: The parameter '"); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_warning); + fl_color_print_to(data->error.to, data->context.set.error, "' cannot be used with the parameter "); + fl_color_print_to(data->error.to, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_fine); + fl_color_print_to(data->error.to, data->context.set.error, ".%c", f_string_eol[0]); status_code_delete_data(data); return F_status_set_error(status); } if (data->remaining.used == 0 && !data->process_pipe) { - fl_color_print_line(f_type_error, data->context.set.error, "ERROR: You failed to specify a status code."); + fl_color_print_to(data->error.to, data->context.set.error, "ERROR: You failed to specify a status code.%c", f_string_eol[0]); status_code_delete_data(data); return F_status_set_error(F_parameter); diff --git a/level_3/status_code/c/status_code.h b/level_3/status_code/c/status_code.h index 3cd02aa..a22c18d 100644 --- a/level_3/status_code/c/status_code.h +++ b/level_3/status_code/c/status_code.h @@ -33,6 +33,7 @@ #include // fll-2 includes +#include #include #include @@ -68,6 +69,10 @@ extern "C" { status_code_parameter_light, status_code_parameter_dark, status_code_parameter_no_color, + status_code_parameter_verbosity_quiet, + status_code_parameter_verbosity_normal, + status_code_parameter_verbosity_verbose, + status_code_parameter_verbosity_debug, status_code_parameter_version, status_code_parameter_is_fine, @@ -82,6 +87,10 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ + f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \ f_console_parameter_t_initialize(status_code_short_is_fine, status_code_long_is_fine, 0, F_false, f_console_type_normal), \ f_console_parameter_t_initialize(status_code_short_is_warning, status_code_long_is_warning, 0, F_false, f_console_type_normal), \ @@ -89,7 +98,7 @@ extern "C" { f_console_parameter_t_initialize(status_code_short_number, status_code_long_number, 0, F_false, f_console_type_normal), \ } - #define status_code_total_parameters 9 + #define status_code_total_parameters 13 #endif // _di_status_code_defines_ #ifndef _di_status_code_data_t_ @@ -99,7 +108,8 @@ extern "C" { f_string_lengths_t remaining; bool process_pipe; - uint8_t verbosity; + int output; + fll_error_print_t error; f_color_context_t context; } status_code_data_t; @@ -109,7 +119,8 @@ extern "C" { status_code_console_parameter_t_initialize, \ f_string_lengths_t_initialize, \ F_false, \ - f_console_verbosity_normal, \ + f_type_descriptor_output, \ + fll_error_print_t_initialize, \ f_color_context_t_initialize, \ } #endif // _di_status_code_data_t_ @@ -124,7 +135,7 @@ extern "C" { * F_none on success. */ #ifndef _di_status_code_print_help_ - extern f_return_status status_code_print_help(const f_color_context_t context); + extern f_return_status status_code_print_help(const int id, const f_color_context_t context); #endif // _di_status_code_print_help_ /** diff --git a/level_3/status_code/data/build/dependencies b/level_3/status_code/data/build/dependencies index 2614524..9e6b577 100644 --- a/level_3/status_code/data/build/dependencies +++ b/level_3/status_code/data/build/dependencies @@ -17,5 +17,6 @@ fl_conversion fl_status fl_string fl_utf +fll_error fll_program fll_status diff --git a/level_3/status_code/data/build/settings b/level_3/status_code/data/build/settings index 63cb3a2..64bcff2 100644 --- a/level_3/status_code/data/build/settings +++ b/level_3/status_code/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_status -lfll_program -lfl_utf -lfl_string -lfl_status -lfl_conversion -lfl_console -lfl_color -lf_print -lf_pipe -lf_file -lf_conversion -lf_console -lf_utf -lf_memory +build_libraries-individual -lfll_status -lfll_program -lfll_error -lfl_utf -lfl_string -lfl_status -lfl_conversion -lfl_console -lfl_color -lf_print -lf_pipe -lf_file -lf_conversion -lf_console -lf_utf -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library status_code.c private-status_code.c -- 1.8.3.1