From: Kevin Day Date: Sat, 26 Sep 2020 05:24:14 +0000 (-0500) Subject: Progress: wrap up most of the print changes. X-Git-Tag: 0.5.1~60 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=64984b1792582852e5c217ac72c863422b754950;p=fll Progress: wrap up most of the print changes. This appears to get most of the changes in regards to printing. There will need to be some testing and reviewing to double check for any mistakes. (With such a massive set of changes, minor/subtle mistakes are likely.) I will resume my work on updating and getting the fss write functions to be more like the iki_write in some of the design practices (in terms of program operations, parameter usages, etc..) where applicable. --- diff --git a/level_2/fll_error/c/error.c b/level_2/fll_error/c/error.c index 40679c9..ba7ed8a 100644 --- a/level_2/fll_error/c/error.c +++ b/level_2/fll_error/c/error.c @@ -110,6 +110,33 @@ extern "C" { return F_false; } + if (status == F_file_open) { + fl_color_print(error.to.stream, error.context, "%s%sUnable to open the file '", error.context.before->string, error.prefix ? error.prefix : ""); + fl_color_print(error.to.stream, error.notable, "%s", file_name); + fl_color_print(error.to.stream, error.context, "'."); + fprintf(error.to.stream, "%c", f_string_eol[0]); + + return F_false; + } + + if (status == F_file_descriptor) { + fl_color_print(error.to.stream, error.context, "%s%sFile descriptor error while trying to open the file '", error.context.before->string, error.prefix ? error.prefix : ""); + fl_color_print(error.to.stream.to.stream, error.notable, "%s", file_name); + fl_color_print(stream, error.context, "'."); + fprintf(error.to.stream, "%c", f_string_eol[0]); + + return F_false; + } + + if (status == F_number_underflow) { + fl_color_print(error.to.stream, error.context, "%s%sInteger underflow while trying to buffer the file '", error.context.before->string, error.prefix ? error.prefix : ""); + fl_color_print(error.to.stream, error.notable, "%s", file_name); + fl_color_print(error.to.stream, error.context, "'."); + fprintf(error.to.stream, "%c", f_string_eol[0]); + + return F_false; + } + if (status == F_file_read) { if (error.verbosity != f_console_verbosity_quiet) { fprintf(error.to.stream, "%c", f_string_eol[0]); diff --git a/level_2/fll_file/c/file.c b/level_2/fll_file/c/file.c index e9fe5a7..94c6811 100644 --- a/level_2/fll_file/c/file.c +++ b/level_2/fll_file/c/file.c @@ -5,75 +5,6 @@ extern "C" { #endif -#ifndef _di_fll_file_error_print_ - f_return_status fll_file_error_print(FILE *stream, 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(stream, context.set.error, "CRITICAL ERROR: Unable to allocate memory."); - fprintf(stream, "%c", f_string_eol[0]); - } - else if (status == F_file_closed) { - fl_color_print(stream, context.set.error, "INTERNAL ERROR: The file '"); - fl_color_print(stream, context.set.notable, "%s", file_name); - fl_color_print(stream, context.set.error, "' is no longer open."); - fprintf(stream, "%c", f_string_eol[0]); - } - else if (status == F_file_seek) { - fl_color_print(stream, context.set.error, "ERROR: A seek error occurred while accessing the file '"); - fl_color_print(stream, context.set.notable, "%s", file_name); - fl_color_print(stream, context.set.error, "'."); - fprintf(stream, "%c", f_string_eol[0]); - } - else if (status == F_file_read) { - fl_color_print(stream, context.set.error, "ERROR: A read error occurred while accessing the file '"); - fl_color_print(stream, context.set.notable, "%s", file_name); - fl_color_print(stream, context.set.error, "'."); - fprintf(stream, "%c", f_string_eol[0]); - } - else if (status == F_file_found_not) { - fl_color_print(stream, context.set.error, "ERROR: Unable to find the file '"); - fl_color_print(stream, context.set.notable, "%s", file_name); - fl_color_print(stream, context.set.error, "'."); - fprintf(stream, "%c", f_string_eol[0]); - } - else if (status == F_file_open) { - fl_color_print(stream, context.set.error, "ERROR: Unable to open the file '"); - fl_color_print(stream, context.set.notable, "%s", file_name); - fl_color_print(stream, context.set.error, "'."); - fprintf(stream, "%c", f_string_eol[0]); - } - else if (status == F_file_descriptor) { - fl_color_print(stream, context.set.error, "ERROR: File descriptor error while trying to open the file '"); - fl_color_print(stream, context.set.notable, "%s", file_name); - fl_color_print(stream, context.set.error, "'."); - fprintf(stream, "%c", f_string_eol[0]); - } - else if (status == F_parameter) { - fl_color_print(stream, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(stream, context.set.notable, "%s()", function_name); - fl_color_print(stream, context.set.error, "."); - fprintf(stream, "%c", f_string_eol[0]); - } - else if (status == F_number_overflow) { - fl_color_print(stream, context.set.error, "ERROR: Integer overflow while trying to buffer the file '"); - fl_color_print(stream, context.set.notable, "%s", file_name); - fl_color_print(stream, context.set.error, "'."); - fprintf(stream, "%c", f_string_eol[0]); - } - else if (status == F_number_underflow) { - fl_color_print(stream, context.set.error, "ERROR: Integer underflow while trying to buffer the file '"); - fl_color_print(stream, context.set.notable, "%s", file_name); - fl_color_print(stream, context.set.error, "'."); - fprintf(stream, "%c", f_string_eol[0]); - } - else { - return F_false; - } - - return F_true; - } -#endif // _di_fll_file_error_print_ - #ifndef _di_fll_file_mode_set_all_ f_return_status fll_file_mode_set_all(const f_string_t path, const mode_t mode, const f_number_unsigned_t depth_max) { #ifndef _di_level_2_parameter_checking_ diff --git a/level_2/fll_file/c/file.h b/level_2/fll_file/c/file.h index 933cd72..42c7b71 100644 --- a/level_2/fll_file/c/file.h +++ b/level_2/fll_file/c/file.h @@ -31,29 +31,6 @@ extern "C" { #endif /** - * Print file error messages. - * - * @param stream - * The file stream to write to, such as f_type_output or f_type_error. - * @param context - * The color context information to use when printing. - * @param function_name - * The name of the function responsible for the error. - * @param file_name - * The name of the file with the error. - * @param status - * The status code representing the error. - * The status code should be passed through F_status_set_fine() if it contains error or warning bits. - * - * @return - * F_true if error message was printed. - * F_false if no error message was printed. - */ -#ifndef _di_fll_file_error_print_ - extern f_return_status fll_file_error_print(FILE *stream, const f_color_context_t context, const f_string_t function_name, const f_string_t file_name, const f_status_t status); -#endif // _di_fll_file_error_print_ - -/** * Change mode of a given file or directory at the specified path. * * This does not set mode based on umask(), be sure to apply umask if so desired. diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index c0bc1c2..c813e4d 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -206,7 +206,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_width); fl_color_print(data->error.to.stream, data->context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); @@ -222,7 +222,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_width); fl_color_print(data->error.to.stream, data->context.set.error, "' value can only be a number between "); fl_color_print(data->error.to.stream, data->context.set.notable, "0"); @@ -238,7 +238,7 @@ extern "C" { } if (data->parameters[byte_dump_parameter_first].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); fl_color_print(data->error.to.stream, data->context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); @@ -254,7 +254,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); fl_color_print(data->error.to.stream, data->context.set.error, "' value can only be a number (inclusively) between "); fl_color_print(data->error.to.stream, data->context.set.notable, "0"); @@ -270,7 +270,7 @@ extern "C" { } if (data->parameters[byte_dump_parameter_last].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); fl_color_print(data->error.to.stream, data->context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); @@ -286,7 +286,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); fl_color_print(data->error.to.stream, data->context.set.error, "' value can only be a number (inclusively) between "); fl_color_print(data->error.to.stream, data->context.set.notable, "0"); @@ -303,7 +303,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); fl_color_print(data->error.to.stream, data->context.set.error, "' value cannot be greater than the parameter '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); @@ -431,7 +431,7 @@ extern "C" { } } else { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: You failed to specify one or more filenames.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sYou failed to specify one or more filenames.%c", fll_error_print_error, f_string_eol[0]); status = F_status_set_error(F_parameter); } diff --git a/level_3/byte_dump/c/private-byte_dump.c b/level_3/byte_dump/c/private-byte_dump.c index 63119c5..885d891 100644 --- a/level_3/byte_dump/c/private-byte_dump.c +++ b/level_3/byte_dump/c/private-byte_dump.c @@ -216,7 +216,7 @@ extern "C" { if (size < 0) { // @todo: determine what the error from read() is and display it. - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: read() failed for '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sread() failed for '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", file_name); fl_color_print(data.error.to.stream, data.context.set.error, "'."); fprintf(data.error.to.stream, "%c%x", f_string_eol[0], f_string_eol[0]); diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index ce71494..42267f7 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -323,7 +323,7 @@ extern "C" { else if (F_status_is_error(status)) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->error.context, "ERROR: The operation '"); + fl_color_print(data->error.to.stream, data->error.context, "%sThe operation '", fll_error_print_error); fl_color_print(data->error.to.stream, data->error.notable, "%s", operations_name); fl_color_print(data->error.to.stream, data->error.context, "' failed.%c", f_string_eol[0]); } @@ -345,7 +345,7 @@ extern "C" { else { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->error.context, "ERROR: You failed to specify an operation.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->error.context, "%sYou failed to specify an operation.%c", fll_error_print_error, f_string_eol[0]); fprintf(data->error.to.stream, "%c", f_string_eol[0]); } diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 8f9fdbf..fd53dbf 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -1151,7 +1151,7 @@ extern "C" { if (names.used + data_build.setting.environment.used > f_array_length_t_size) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The values for the setting '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe values for the setting '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", fake_build_setting_name_environment); fl_color_print(data.error.to.stream, data.context.set.error, "' of setting file '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", data.file_data_build_settings.string); @@ -1341,7 +1341,7 @@ extern "C" { if (!settings[i]->used) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The setting '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe setting '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", names[i]); fl_color_print(data.error.to.stream, data.context.set.error, "' is required but is not specified in the settings file '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", setting_file.used ? path_file : data.file_data_build_settings.string); @@ -1571,7 +1571,7 @@ extern "C" { if (found == F_false) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The specified mode '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe specified mode '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", modes->array[i].string); fl_color_print(data.error.to.stream, data.context.set.error, "' is not a valid mode, according to '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", path_file); @@ -1626,7 +1626,7 @@ extern "C" { if (data.error.verbosity != f_console_verbosity_quiet) { // @todo update FSS functions to return which setting index the problem happened on. fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: A setting in the build setting file '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sA setting in the build setting file '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", path_file); fl_color_print(data.error.to.stream, data.context.set.error, "' is too long.%c", f_string_eol[0]); } @@ -1818,7 +1818,7 @@ extern "C" { if (settings_single_source[i]->used > 1) { if (data.error.verbosity == f_console_verbosity_verbose) { fprintf(data.output.stream, "%c", f_string_eol[0]); - fl_color_print(data.output.stream, data.context.set.warning, "WARNING: the setting '"); + fl_color_print(data.output.stream, data.context.set.warning, "%sthe setting '", fll_error_print_warning); fl_color_print(data.output.stream, data.context.set.notable, "%s", settings_single_name[i]); fl_color_print(data.output.stream, data.context.set.warning, "' in the file '"); fl_color_print(data.output.stream, data.context.set.notable, "%s", path_file); @@ -1840,7 +1840,7 @@ extern "C" { if (data.error.verbosity == f_console_verbosity_verbose) { fprintf(data.output.stream, "%c", f_string_eol[0]); - fl_color_print(data.output.stream, data.context.set.warning, "WARNING: the setting '"); + fl_color_print(data.output.stream, data.context.set.warning, "%sthe setting '", fll_error_print_warning); fl_color_print(data.output.stream, data.context.set.notable, "%s", settings_single_name[i]); fl_color_print(data.output.stream, data.context.set.warning, "' in the file '"); fl_color_print(data.output.stream, data.context.set.notable, "%s", path_file); @@ -1869,7 +1869,7 @@ extern "C" { if (data.error.verbosity == f_console_verbosity_verbose) { fprintf(data.output.stream, "%c", f_string_eol[0]); - fl_color_print(data.output.stream, data.context.set.warning, "WARNING: the setting '"); + fl_color_print(data.output.stream, data.context.set.warning, "%sthe setting '", fll_error_print_warning); fl_color_print(data.output.stream, data.context.set.notable, "%s", settings_single_name[i]); fl_color_print(data.output.stream, data.context.set.warning, "' in the file '"); fl_color_print(data.output.stream, data.context.set.notable, "%s", path_file); @@ -1900,7 +1900,7 @@ extern "C" { if (data.error.verbosity == f_console_verbosity_verbose) { fprintf(data.output.stream, "%c", f_string_eol[0]); - fl_color_print(data.output.stream, data.context.set.warning, "WARNING: the setting '"); + fl_color_print(data.output.stream, data.context.set.warning, "%sthe setting '", fll_error_print_warning); fl_color_print(data.output.stream, data.context.set.notable, "%s", settings_single_name[i]); fl_color_print(data.output.stream, data.context.set.warning, "' in the file '"); fl_color_print(data.output.stream, data.context.set.notable, "%s", path_file); @@ -2035,7 +2035,7 @@ extern "C" { if (data.error.verbosity == f_console_verbosity_verbose) { fprintf(data.output.stream, "%c", f_string_eol[0]); - fl_color_print(data.output.stream, data.context.set.error, "WARNING: the parameters '"); + fl_color_print(data.output.stream, data.context.set.error, "%sthe parameters '", fll_error_print_warning); fl_color_print(data.output.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_shared_disabled); fl_color_print(data.output.stream, data.context.set.error, "' and '"); fl_color_print(data.output.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_shared_enabled); @@ -2074,7 +2074,7 @@ extern "C" { if (data.error.verbosity == f_console_verbosity_verbose) { fprintf(data.output.stream, "%c", f_string_eol[0]); - fl_color_print(data.output.stream, data.context.set.error, "WARNING: the parameters '"); + fl_color_print(data.output.stream, data.context.set.error, "%sthe parameters '", fll_error_print_warning); fl_color_print(data.output.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_static_disabled); fl_color_print(data.output.stream, data.context.set.error, "' and '"); fl_color_print(data.output.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_static_enabled); @@ -2104,7 +2104,7 @@ extern "C" { if (setting->build_shared == F_false && setting->build_static == F_false) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The build settings '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe build settings '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", fake_build_setting_name_build_shared); fl_color_print(data.error.to.stream, data.context.set.error, "' and '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", fake_build_setting_name_build_static); @@ -2359,7 +2359,7 @@ extern "C" { if (*status == F_false) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The path '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe path '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", destination_path.string); fl_color_print(data.error.to.stream, data.context.set.error, "' exists but is not a directory.%c", f_string_eol[0]); } @@ -2373,7 +2373,7 @@ extern "C" { if (F_status_is_error(*status)) { if (F_status_set_fine(*status) == F_file_found_not) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The path '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe path '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", destination_path.string); fl_color_print(data.error.to.stream, data.context.set.error, "' could not be created, a parent directory does not exist.%c", f_string_eol[0]); } diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 24e5a3d..ec581d9 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -61,7 +61,7 @@ extern "C" { if (F_status_set_fine(*status) == F_file_found_not) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Failed to find program '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sFailed to find program '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", program.used ? program.string : ""); fl_color_print(data.error.to.stream, data.context.set.error, "' for executing.%c", f_string_eol[0]); } @@ -644,7 +644,7 @@ extern "C" { if (F_status_is_error(status)) { if (fll_error_print(data->error, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Failed to process the parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to process the parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_process); fl_color_print(data->error.to.stream, data->context.set.error, "'.%c", f_string_eol[0]); } @@ -655,7 +655,7 @@ extern "C" { if (status == F_false) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_process); fl_color_print(data->error.to.stream, data->context.set.error, "' parameters value '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s", arguments.argv[location]); @@ -673,7 +673,7 @@ extern "C" { if (status == F_status_set_error(F_string_too_large)) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); fl_color_print(data->error.to.stream, data->context.set.error, "' is too long.%c", f_string_eol[0]); } @@ -692,7 +692,7 @@ extern "C" { if (length == 0 || status == F_data_not) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); fl_color_print(data->error.to.stream, data->context.set.error, "' must not be empty and must not contain only whitespace.%c", f_string_eol[0]); } @@ -770,7 +770,7 @@ extern "C" { if (F_status_is_error(status)) { if (fll_error_print(data->error, F_status_set_fine(status), "fl_console_parameter_to_string_dynamic_directory", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Failed to process parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to process parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); fl_color_print(data->error.to.stream, data->context.set.error, "'.%c", f_string_eol[0]); } @@ -784,7 +784,7 @@ extern "C" { if (F_status_is_error(status)) { if (fll_error_print(data->error, F_status_set_fine(status), "f_macro_string_dynamic_t_new", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Failed to load default for the parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to load default for the parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); fl_color_print(data->error.to.stream, data->context.set.error, "'.%c", f_string_eol[0]); } @@ -804,7 +804,7 @@ extern "C" { if (F_status_is_error(status)) { if (fll_error_print(data->error, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Failed to process the parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to process the parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_define); fl_color_print(data->error.to.stream, data->context.set.error, "'.%c", f_string_eol[0]); } @@ -827,7 +827,7 @@ extern "C" { if (F_status_is_error(status)) { if (fll_error_print(data->error, F_status_set_fine(status), "f_utf_is_word", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Failed to process the parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to process the parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_define); fl_color_print(data->error.to.stream, data->context.set.error, "'.%c", f_string_eol[0]); } @@ -838,7 +838,7 @@ extern "C" { if (status == F_false) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_define); fl_color_print(data->error.to.stream, data->context.set.error, "' parameters value '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s", data->define.array[i].string); @@ -861,7 +861,7 @@ extern "C" { if (F_status_is_error(status)) { if (fll_error_print(data->error, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Failed to process the parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to process the parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_mode); fl_color_print(data->error.to.stream, data->context.set.error, "'.%c", f_string_eol[0]); } @@ -884,7 +884,7 @@ extern "C" { if (F_status_is_error(status)) { if (fll_error_print(data->error, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_unknown && data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Failed to process the parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to process the parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_mode); fl_color_print(data->error.to.stream, data->context.set.error, "'.%c", f_string_eol[0]); } @@ -895,7 +895,7 @@ extern "C" { if (status == F_false) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fake_long_mode); fl_color_print(data->error.to.stream, data->context.set.error, "' parameters value '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s", data->mode.array[i].string); @@ -1011,7 +1011,7 @@ extern "C" { } else if (parameters_required[i]) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: No valid path for the (required) directory parameter '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sNo valid path for the (required) directory parameter '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, parameters_name[i]); fl_color_print(data.error.to.stream, data.context.set.error, "' was found.%c", f_string_eol[0]); diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index ef21f0c..5c16a3b 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -190,7 +190,7 @@ extern "C" { if (!data_make->buffer.used) { if (data.error.verbosity == f_console_verbosity_verbose) { fprintf(data.output.stream, "%c", f_string_eol[0]); - fl_color_print(data.output.stream, data.context.set.warning, "WARNING: the fakefile '"); + fl_color_print(data.output.stream, data.context.set.warning, "%sthe fakefile '", fll_error_print_warning); fl_color_print(data.output.stream, data.context.set.notable, "%s", data.file_data_build_fakefile.string); fl_color_print(data.output.stream, data.context.set.warning, "' is empty."); } @@ -439,14 +439,14 @@ extern "C" { } else if (data.error.verbosity == f_console_verbosity_verbose) { fprintf(data.output.stream, "%c", f_string_eol[0]); - fl_color_print(data.output.stream, data.context.set.warning, "WARNING: The environment name '"); + fl_color_print(data.output.stream, data.context.set.warning, "%sThe environment name '", fll_error_print_warning); fl_color_print(data.output.stream, data.context.set.notable, "%s", name_define.string); fl_color_print(data.output.stream, data.context.set.warning, "' is already added.%c", f_string_eol[0]); } } else if (data.error.verbosity == f_console_verbosity_verbose) { fprintf(data.output.stream, "%c", f_string_eol[0]); - fl_color_print(data.output.stream, data.context.set.warning, "WARNING: The environment name '"); + fl_color_print(data.output.stream, data.context.set.warning, "%sThe environment name '", fll_error_print_warning); fl_color_print(data.output.stream, data.context.set.notable, "%s", name_define.string); fl_color_print(data.output.stream, data.context.set.warning, "' is invalid, ignoring.%c", f_string_eol[0]); } @@ -701,7 +701,7 @@ extern "C" { else { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Invalid characters in the define setting name '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid characters in the define setting name '", fll_error_print_error); fl_color_print_code(data.error.to.stream, *data.error.notable.before); f_print_dynamic(data.error.to.stream, define.array[i].name); @@ -1113,7 +1113,7 @@ extern "C" { if (F_status_is_error(status_path) && data.error.verbosity == f_console_verbosity_verbose) { fprintf(data.output.stream, "%c", f_string_eol[0]); - fl_color_print(data.output.stream, data.context.set.warning, "WARNING: Failed change back to orignal path '"); + fl_color_print(data.output.stream, data.context.set.warning, "%sFailed change back to orignal path '", fll_error_print_warning); fl_color_print(data.output.stream, data.context.set.notable, "%s", data_make.path.stack.array[0].string); fl_color_print(data.output.stream, data.context.set.warning, "', status code = "); fl_color_print(data.output.stream, data.context.set.notable, "%llu", F_status_set_fine(status_path)); @@ -2524,7 +2524,7 @@ extern "C" { if (F_status_set_fine(*status) == F_file_found_not) { if (data.error.verbosity == f_console_verbosity_verbose) { fprintf(data.output.stream, "%c", f_string_eol[0]); - fl_color_print(data.output.stream, data.context.set.warning, "WARNING: the file '"); + fl_color_print(data.output.stream, data.context.set.warning, "%sthe file '", fll_error_print_warning); fl_color_print(data.output.stream, data.context.set.notable, "%s", arguments.array[i].string); fl_color_print(data.output.stream, data.context.set.warning, "' was not found.%c", f_string_eol[0]); } diff --git a/level_3/fake/c/private-print.c b/level_3/fake/c/private-print.c index 0d52bc1..a78386d 100644 --- a/level_3/fake/c/private-print.c +++ b/level_3/fake/c/private-print.c @@ -15,7 +15,7 @@ extern "C" { if (status == F_file_found_not) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Failed to find '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sFailed to find '", fll_error_print_error); if (f_file_exists(source) == F_true) { fl_color_print(data.error.to.stream, data.context.set.notable, "%s", destination); @@ -41,7 +41,7 @@ extern "C" { if (status == F_parameter) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling ", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", function); fl_color_print(data.error.to.stream, data.context.set.error, "() to %s '", operation); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", source); @@ -60,7 +60,7 @@ extern "C" { if (status == F_name) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Invalid name for '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid name for '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", source); if (destination) { @@ -77,7 +77,7 @@ extern "C" { if (status == F_memory_out) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory, while trying to %s '", operation); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory, while trying to %s '", fll_error_print_error, operation); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", source); if (destination) { @@ -95,7 +95,7 @@ extern "C" { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Overflow while trying to %s '", operation); + fl_color_print(data.error.to.stream, data.context.set.error, "%sOverflow while trying to %s '", fll_error_print_error, operation); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", source); if (destination) { @@ -112,7 +112,7 @@ extern "C" { if (status == F_directory) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Invalid directory while trying to %s '", operation); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid directory while trying to %s '", fll_error_print_error, operation); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", source); if (destination) { @@ -129,7 +129,7 @@ extern "C" { if (status == F_access_denied) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Access denied while trying to %s '", operation); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAccess denied while trying to %s '", fll_error_print_error, operation); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", source); if (destination) { @@ -146,7 +146,7 @@ extern "C" { if (status == F_loop) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Loop while trying to %s '", operation); + fl_color_print(data.error.to.stream, data.context.set.error, "%sLoop while trying to %s '", fll_error_print_error, operation); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", source); if (destination) { @@ -163,7 +163,7 @@ extern "C" { if (status == F_prohibited) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Prohibited by system while trying to %s '", operation); + fl_color_print(data.error.to.stream, data.context.set.error, "%sProhibited by system while trying to %s '", fll_error_print_error, operation); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", source); if (destination) { @@ -180,7 +180,7 @@ extern "C" { if (status == F_directory_found_not) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Failed to %s '", operation); + fl_color_print(data.error.to.stream, data.context.set.error, "%sFailed to %s '", fll_error_print_error, operation); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", source); if (destination) { @@ -197,7 +197,7 @@ extern "C" { if (status == F_failure) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Failed to %s '", operation); + fl_color_print(data.error.to.stream, data.context.set.error, "%sFailed to %s '", fll_error_print_error, operation); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", source); if (destination) { @@ -213,7 +213,7 @@ extern "C" { if (fll_error_print(data.error, status, function, F_false) == F_unknown && fallback && data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "UNKNOWN ERROR: ("); + fl_color_print(data.error.to.stream, data.context.set.error, "UNKNOWN %s(", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%llu", status); fl_color_print(data.error.to.stream, data.context.set.error, ") occurred while trying to %s '", operation); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", source); @@ -236,7 +236,7 @@ extern "C" { if (status == F_file_found_not) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print(data.error.to.stream, data.context.set.error, "%serror occurred on invalid UTF-8 character at stop position (at ", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%d", range.start); fl_color_print(data.error.to.stream, data.context.set.error, " of setting file '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", path_file); @@ -249,7 +249,7 @@ extern "C" { if (status == F_status_set_error(F_incomplete_utf_stop)) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print(data.error.to.stream, data.context.set.error, "%serror occurred on invalid UTF-8 character at end of string (at ", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%d", range.start); fl_color_print(data.error.to.stream, data.context.set.error, " of setting file '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", path_file); @@ -261,7 +261,7 @@ extern "C" { if (fll_error_print(data.error, status, function, F_false) == F_unknown && fallback && data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "UNKNOWN ERROR: ("); + fl_color_print(data.error.to.stream, data.context.set.error, "UNKNOWN %s(", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%llu", status); fl_color_print(data.error.to.stream, data.context.set.error, ") in function "); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", function); @@ -278,7 +278,7 @@ extern "C" { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The parameter '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); fl_color_print(data.error.to.stream, data.context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); @@ -291,7 +291,7 @@ extern "C" { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The parameter '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); fl_color_print(data.error.to.stream, data.context.set.error, "' specified too many times.%c", f_string_eol[0]); @@ -505,7 +505,7 @@ extern "C" { f_fss_count_lines(buffer, operation_name.start, &line); fprintf(error.to.stream, "%c", f_string_eol[0]); - fl_color_print(error.to.stream, data.error.context, "%s: The section operation '", data.error.prefix); + fl_color_print(error.to.stream, data.error.context, "%sThe section operation '", data.error.prefix); fl_color_print_code(error.to.stream, data.context.notable); f_print_dynamic_partial(error.to.stream, buffer, operation_name); @@ -529,7 +529,7 @@ extern "C" { if (F_status_set_fine(status) == F_false) { fprintf(error.to.stream, "%c", f_string_eol[0]); - fl_color_print(error.to.stream, data.error.context, "%s: The path '", data.error.prefix); + fl_color_print(error.to.stream, data.error.context, "%sThe path '", data.error.prefix); fl_color_print(error.to.stream, data.context.set.notable, "%s", path); fl_color_print(error.to.stream, data.error.context, "' is outside the project root.%c", f_string_eol[0]); } @@ -572,7 +572,7 @@ extern "C" { f_fss_count_lines(buffer, operation_name.start, &line); fprintf(error.to.stream, "%c", f_string_eol[0]); - fl_color_print(error.to.stream, data.error.context, "%s: The section operation '", data.error.prefix); + fl_color_print(error.to.stream, data.error.context, "The section operation '", data.error.prefix); fl_color_print_code(error.to.stream, data.context.notable); f_print_dynamic_partial(error.to.stream, buffer, operation_name); @@ -601,7 +601,7 @@ extern "C" { f_fss_count_lines(buffer, operation_name.start, &line); fprintf(error.to.stream, "%c", f_string_eol[0]); - fl_color_print(error.to.stream, data.error.context, "%s: The section operation '", data.error.prefix); + fl_color_print(error.to.stream, data.error.context, "%sThe section operation '", data.error.prefix); fl_color_print_code(error.to.stream, data.context.notable); f_print_dynamic_partial(error.to.stream, buffer, operation_name); @@ -625,7 +625,7 @@ extern "C" { fprintf(data.error.to.stream, "%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.warning, "%sthe fakefile '", fll_error_print_warning); fl_color_print(f_type_warning, data.context.set.notable, "%s", path_file); fl_color_print(f_type_warning, data.context.set.warning, "' has empty content for the '"); fl_color_print(f_type_warning, data.context.set.notable, "%s", settings_name); @@ -645,7 +645,7 @@ extern "C" { fprintf(data.output.stream, "%c", f_string_eol[0]); - fl_color_print(data.output.stream, data.context.set.warning, "WARNING: the fakefile '"); + fl_color_print(data.output.stream, data.context.set.warning, "%sthe fakefile '", fll_error_print_warning); fl_color_print(data.output.stream, data.context.set.notable, "%s", path_file); fl_color_print(data.output.stream, data.context.set.warning, "' has an invalid content '"); @@ -671,7 +671,7 @@ extern "C" { fprintf(data.error.to.stream, "%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.warning, "%sthe setting '", fll_error_print_warning); 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); @@ -686,7 +686,7 @@ extern "C" { fprintf(data.error.to.stream, "%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.warning, "%sthe %s object '", fll_error_print_warning, 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); diff --git a/level_3/fake/c/private-skeleton.c b/level_3/fake/c/private-skeleton.c index ae5a495..6da8a45 100644 --- a/level_3/fake/c/private-skeleton.c +++ b/level_3/fake/c/private-skeleton.c @@ -175,7 +175,7 @@ extern "C" { if (status == F_false) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The path '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe path '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", path.string); fl_color_print(data.error.to.stream, data.context.set.error, "' exists but is not a directory.%c", f_string_eol[0]); } @@ -188,7 +188,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_file_found_not) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The path '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe path '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", path.string); fl_color_print(data.error.to.stream, data.context.set.error, "' could not be created, a parent directory does not exist.%c", f_string_eol[0]); } @@ -260,7 +260,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_file_found_not) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The file '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe file '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s", path.string); fl_color_print(data.error.to.stream, data.context.set.error, "' could not be created, a parent directory does not exist.%c", f_string_eol[0]); } diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index 4ce792c..09fdcd6 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -23,17 +23,9 @@ extern "C" { fll_program_print_help_option(file, 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(file, 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(file, 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(file, 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(file, 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(file, 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(file, 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]); fl_color_print(f_type_output, context.set.important, " Available Commands: "); @@ -68,12 +60,11 @@ extern "C" { f_status_t status = F_none; { - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); + const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, firewall_total_parameters); { 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); status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); @@ -89,6 +80,7 @@ extern "C" { // 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 }; + const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4); f_console_parameter_id_t choice = 0; status = f_console_parameter_prioritize_right(parameters, choices, &choice); @@ -212,7 +204,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(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]); + fl_color_print(f_type_warning, data->context.set.warning, "%s'%s' is not a valid show option%c", fll_error_print_warning, arguments.argv[data->remaining.array[counter]], f_string_eol[0]); } else { show_ports = F_true; @@ -231,7 +223,7 @@ extern "C" { f_macro_string_dynamics_resize(status, parameters, 7); if (F_status_is_error(status)) { - fl_color_print(data->error.to.stream, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); firewall_delete_local_data(&local); firewall_delete_data(data); return status; @@ -321,10 +313,10 @@ extern "C" { status = F_status_set_fine(status); if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data->error.to.stream, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Failed to perform requested %s operation:%c", firewall_tool_iptables, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to perform requested %s operation:%c", fll_error_print_error, firewall_tool_iptables, f_string_eol[0]); fprintf(f_type_error, " "); f_string_length_t i = 0; @@ -371,13 +363,13 @@ extern "C" { status = F_status_set_fine(status); if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data->error.to.stream, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_data_not) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Could not find any network devices%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCould not find any network devices%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_failure) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Failed to read the device directory '%s'%c", network_devices, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to read the device directory '%s'%c", fll_error_print_error, network_devices, f_string_eol[0]); } firewall_delete_local_data(&local); @@ -460,7 +452,7 @@ extern "C" { return status; } else { - fl_color_print(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to perform lock request because the lock instructions are missing from: %s.%c", fll_error_print_error, network_path firewall_file_other, f_string_eol[0]); firewall_delete_local_data(&local); firewall_delete_data(data); @@ -500,7 +492,7 @@ extern "C" { } } else { - fl_color_print(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to perform stop request because the lock instructions are missing from: %s.", fll_error_print_error, network_path firewall_file_other, f_string_eol[0]); firewall_delete_local_data(&local); firewall_delete_data(data); @@ -578,7 +570,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(data->error.to.stream, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); firewall_delete_local_data(&local); firewall_delete_data(data); return status; @@ -692,7 +684,7 @@ extern "C" { firewall_delete_local_data(&local); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: You did not pass a command%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sYou did not pass a command%c", fll_error_print_error, 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 2922ceb..65876b8 100644 --- a/level_3/firewall/c/firewall.h +++ b/level_3/firewall/c/firewall.h @@ -213,10 +213,7 @@ extern "C" { 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_verbosity_debug, firewall_parameter_version, @@ -244,46 +241,25 @@ extern "C" { firewall_action_none_id, }; - #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, 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), \ - f_console_parameter_t_initialize(0, 0, firewall_command_lock, F_false, f_console_type_other), \ - f_console_parameter_t_initialize(0, 0, firewall_command_show, F_false, f_console_type_other), \ - } - - #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, 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), \ - f_console_parameter_t_initialize(0, 0, firewall_command_lock, F_false, f_console_type_other), \ - f_console_parameter_t_initialize(0, 0, firewall_command_show, F_false, f_console_type_other), \ - } - - #define firewall_total_parameters 13 - #endif // _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, 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), \ + f_console_parameter_t_initialize(0, 0, firewall_command_lock, F_false, f_console_type_other), \ + f_console_parameter_t_initialize(0, 0, firewall_command_show, F_false, f_console_type_other), \ + } + + #define firewall_total_parameters 14 #endif // _di_firewall_defines_ #ifndef _di_firewall_data_t_ diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index 57526d5..33c5797 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -72,7 +72,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con if (length >= firewall_chain_length && fl_string_compare(local.buffer.string + local.rule_objects.array[i].start, (f_string_t) firewall_chain, length, firewall_chain_length) == F_equal_to) { if (chain == firewall_chain_custom_id) { // custom chains can only apply to themselves, so silently ignore chain commands specified within a custom chain. - fprintf(f_type_warning, "WARNING: At line %i, the chain option is meaningle ss inside of a custom chain.", i); + fprintf(f_type_warning, "%sAt line %i, the chain option is meaningle ss inside of a custom chain.", fll_error_print_warning, i); continue; } @@ -283,13 +283,13 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con else if (length < firewall_rule_length || fl_string_compare(local.buffer.string + local.rule_objects.array[i].start, (f_string_t) firewall_rule, length, firewall_rule_length) == F_equal_to_not) { if (length > 0) { fl_color_print_code(f_type_warning, data.context.warning); - fprintf(f_type_warning, "WARNING: At line %i, the object '", i); + fprintf(f_type_warning, "%sAt line %i, the object '", fll_error_print_warning, i); f_print(f_type_warning, local.buffer.string + local.rule_objects.array[i].start, length); fprintf(f_type_warning, "' is invalid"); fl_color_print_code(f_type_warning, data.context.reset); } else { - fprintf(f_type_warning, "WARNING: At line %i, the object is missing", i); + fprintf(f_type_warning, "%sAt line %i, the object is missing", fll_error_print_warning, i); } fprintf(f_type_warning, "\n"); @@ -301,7 +301,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con if (length > 0) { fl_color_print_code(f_type_warning, data.context.warning); - fprintf(f_type_warning, "WARNING: At line %i, the object '", i); + fprintf(f_type_warning, "%sAt line %i, the object '", fll_error_print_warning, i); f_print(f_type_warning, local.buffer.string + local.rule_objects.array[i].start, length); fprintf(f_type_warning, "' has invalid content '"); f_print(f_type_warning, local.buffer.string + local.rule_contents.array[i].array[0].start, firewall_macro_structure_size(local.rule_contents.array[i], 0)); @@ -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(f_type_warning, data.context.set.warning, "WARNING: At line %i, the object has no content%c", i, f_string_eol[0]); + fl_color_print(f_type_warning, data.context.set.warning, "%sAt line %i, the object has no content%c", fll_error_print_warning, i, f_string_eol[0]); } continue; @@ -553,7 +553,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con length = firewall_macro_structure_size(local.rule_objects, i); fl_color_print_code(f_type_warning, data.context.warning); - fprintf(f_type_warning, "WARNING: At line %i, the object '", i); + fprintf(f_type_warning, "%sAt line %i, the object '", fll_error_print_warning, i); f_print(f_type_warning, local.buffer.string + local.rule_objects.array[i].start, length); fprintf(f_type_warning, "' has no content"); fl_color_print_code(f_type_warning, data.context.reset); @@ -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(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling f_file_open()%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_file_found_not) { // the file does not have to exist - 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]); + fl_color_print(f_type_warning, data.context.set.warning, "%sCannot find the file '%.*s'%c", fll_error_print_warning, file_path.used, file_path.string, f_string_eol[0]); status = F_none; } else if (status == F_file_open) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Unable to open the file '%.*s'%c", file_path.used, file_path.string, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to open the file '%.*s'%c", fll_error_print_error, file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print(data.error.to.stream, 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]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sFile descriptor error while trying to open the file '%.*s'%c", fll_error_print_error, file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_open()%c", fll_error_print_error, 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(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_read()%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling f_file_read()%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_number_overflow) { - fl_color_print(data.error.to.stream, 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]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInteger overflow while trying to buffer the file '%.*s'%c", fll_error_print_error, file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_file_closed) { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: The file '%.*s' is no longer open%c", file_path.used, file_path.string, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe file '%.*s' is no longer open%c", fll_error_print_error, file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_file_seek) { - fl_color_print(data.error.to.stream, 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]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sA seek error occurred while accessing the file '%.*s'%c", fll_error_print_error, file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_file_read) { - fl_color_print(data.error.to.stream, 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]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sA read error occurred while accessing the file '%.*s'%c", fll_error_print_error, file_path.used, file_path.string, f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_read()%c", status, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_read()%c", fll_error_print_error, 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(data.error.to.stream, 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]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling fll_fss_basic_read() for the file '%.*s'%c", fll_error_print_error, 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(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else { - fl_color_print(data.error.to.stream, 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]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling fll_fss_basic_read() for the file '%.*s'%c", fll_error_print_error, 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(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, 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(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); break; } @@ -731,25 +731,22 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con firewall_macro_append_argument_to_arguments(status, arguments, ip_argument) if (F_status_is_error(status)) break; - // print command when debugging. - #ifdef _en_firewall_debug_ - if (data.parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_type_debug, data.context.warning); - fprintf(f_type_debug, "%s ", current_tool); + if (data.error.verbosity == f_console_verbosity_debug) { + fl_color_print_code(f_type_debug, data.context.warning); + fprintf(f_type_debug, "%s ", current_tool); - for (f_string_length_t i = 0; i < arguments.used; i++) { - fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); - } // for + for (f_string_length_t i = 0; i < arguments.used; i++) { + fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); + } // for - fl_color_print_code(f_type_debug, data.context.reset); - fprintf(f_type_debug, "\n"); - } - #endif // _en_firewall_debug_ + fl_color_print_code(f_type_debug, data.context.reset); + fprintf(f_type_debug, "\n"); + } status = fll_execute_program((f_string_t) current_tool, arguments, 0, &return_code); if (status == F_failure) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Failed to perform requested %s operation:%c", current_tool, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sFailed to perform requested %s operation:%c", fll_error_print_error, current_tool, f_string_eol[0]); fprintf(f_type_error, " "); fl_color_print_code(f_type_error, data.context.error); @@ -769,7 +766,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con break; } else if (status == F_parameter) { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling fll_execute_program()%c", fll_error_print_error, f_string_eol[0]); // remove ip_argument from arguments string. f_macro_string_dynamic_t_delete_simple(arguments.array[arguments.used]); @@ -801,25 +798,22 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con if (status == F_failure || status == F_parameter) break; } else { - // print command when debugging. - #ifdef _en_firewall_debug_ - if (data.parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_type_debug, data.context.warning); - fprintf(f_type_debug, "%s ", current_tool); - - for (f_string_length_t i = 0; i < arguments.used; i++) { - fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); - } // for - - fl_color_print_code(f_type_debug, data.context.reset); - fprintf(f_type_debug, "\n"); - } - #endif // _en_firewall_debug_ + if (data.error.verbosity == f_console_verbosity_debug) { + fl_color_print_code(f_type_debug, data.context.warning); + fprintf(f_type_debug, "%s ", current_tool); + + for (f_string_length_t i = 0; i < arguments.used; i++) { + fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); + } // for + + fl_color_print_code(f_type_debug, data.context.reset); + fprintf(f_type_debug, "\n"); + } status = fll_execute_program(current_tool, arguments, 0, &return_code); if (status == F_failure) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Failed to perform requested %s operation:%c", current_tool, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sFailed to perform requested %s operation:%c", fll_error_print_error, current_tool, f_string_eol[0]); fprintf(f_type_error, " "); fl_color_print_code(f_type_error, data.context.error); @@ -834,7 +828,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con break; } else if (status == F_parameter) { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling fll_execute_program()%c", fll_error_print_error, f_string_eol[0]); break; } } @@ -1042,11 +1036,25 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains_t *reserv } if (create_chain) { - // print command when debugging. - #ifdef _en_firewall_debug_ - if (data->parameters[firewall_parameter_debug].result == f_console_result_found) { + if (data->error.verbosity == f_console_verbosity_debug) { + fl_color_print_code(f_type_debug, data->context.warning); + fprintf(f_type_debug, "%s ", firewall_tool_iptables); + + for (f_string_length_t i = 0; i < arguments.used; i++) { + fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); + } // for + + fl_color_print_code(f_type_debug, data->context.reset); + fprintf(f_type_debug, "\n"); + } + + tool = firewall_program_iptables; + status = fll_execute_program((f_string_t) firewall_tool_iptables, arguments, 0, &return_code); + + if (F_status_is_error_not(status)) { + if (data->error.verbosity == f_console_verbosity_debug) { fl_color_print_code(f_type_debug, data->context.warning); - fprintf(f_type_debug, "%s ", firewall_tool_iptables); + fprintf(f_type_debug, "%s ", firewall_tool_ip6tables); for (f_string_length_t i = 0; i < arguments.used; i++) { fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); @@ -1055,26 +1063,6 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains_t *reserv fl_color_print_code(f_type_debug, data->context.reset); fprintf(f_type_debug, "\n"); } - #endif // _en_firewall_debug_ - - tool = firewall_program_iptables; - status = fll_execute_program((f_string_t) firewall_tool_iptables, arguments, 0, &return_code); - - if (F_status_is_error_not(status)) { - // print command when debugging. - #ifdef _en_firewall_debug_ - if (data->parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_type_debug, data->context.warning); - fprintf(f_type_debug, "%s ", firewall_tool_ip6tables); - - for (f_string_length_t i = 0; i < arguments.used; i++) { - fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); - } // for - - fl_color_print_code(f_type_debug, data->context.reset); - fprintf(f_type_debug, "\n"); - } - #endif // _en_firewall_debug_ tool = firewall_program_ip6tables; status = fll_execute_program((f_string_t) firewall_tool_ip6tables, arguments, 0, &return_code); @@ -1085,10 +1073,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(data->error.to.stream, data->context.set.error, "ERROR: Failed to perform requested %s operation:%c", firewall_tool_iptables, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to perform requested %s operation:%c", fll_error_print_error, firewall_tool_iptables, f_string_eol[0]); } else if (tool == firewall_program_ip6tables) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Failed to perform requested %s operation:%c", firewall_tool_ip6tables, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to perform requested %s operation:%c", fll_error_print_error, firewall_tool_ip6tables, f_string_eol[0]); } fprintf(f_type_error, " "); @@ -1109,10 +1097,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(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling fll_execute_program()%c", fll_error_print_error, f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling fll_execute_program()%c", fll_error_print_error, status, f_string_eol[0]); } f_macro_string_dynamics_t_delete_simple(arguments); @@ -1148,20 +1136,17 @@ f_return_status firewall_delete_chains(const firewall_data_t data) { arguments.size = 1; arguments.used = 1; - // print command when debugging. - #ifdef _en_firewall_debug_ - if (data.parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_type_debug, data.context.warning); - fprintf(f_type_debug, "%s ", tools[i]); + if (data.error.verbosity == f_console_verbosity_debug) { + fl_color_print_code(f_type_debug, data.context.warning); + fprintf(f_type_debug, "%s ", tools[i]); - for (f_string_length_t i = 0; i < arguments.used; i++) { - fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); - } // for + for (f_string_length_t i = 0; i < arguments.used; i++) { + fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); + } // for - fl_color_print_code(f_type_debug, data.context.reset); - fprintf(f_type_debug, "\n"); - } - #endif // _en_firewall_debug_ + fl_color_print_code(f_type_debug, data.context.reset); + fprintf(f_type_debug, "\n"); + } status = fll_execute_program(tools[i], arguments, 0, &return_code); @@ -1169,7 +1154,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(data.error.to.stream, data.context.set.error, "ERROR: Failed to perform requested %s operation:%c", tools[i], f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sFailed to perform requested %s operation:%c", fll_error_print_error, tools[i], f_string_eol[0]); fprintf(f_type_error, " "); fl_color_print_code(f_type_error, data.context.error); @@ -1183,10 +1168,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(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling fll_execute_program()%c", fll_error_print_error, f_string_eol[0]); } else { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()%c", status, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling fll_execute_program()%c", fll_error_print_error, status, f_string_eol[0]); } return status; @@ -1206,20 +1191,17 @@ f_return_status firewall_delete_chains(const firewall_data_t data) { arguments.size = 1; arguments.used = 1; - // print command when debugging. - #ifdef _en_firewall_debug_ - if (data.parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_type_debug, data.context.warning); - fprintf(f_type_debug, "%s ", tools[i]); + if (data.error.verbosity == f_console_verbosity_debug) { + fl_color_print_code(f_type_debug, data.context.warning); + fprintf(f_type_debug, "%s ", tools[i]); - for (f_string_length_t j = 0; j < arguments.used; j++) { - fprintf(f_type_debug, "%.*s ", arguments.array[j].used, arguments.array[j].string); - } // for + for (f_string_length_t j = 0; j < arguments.used; j++) { + fprintf(f_type_debug, "%.*s ", arguments.array[j].used, arguments.array[j].string); + } // for - fl_color_print_code(f_type_debug, data.context.reset); - fprintf(f_type_debug, "\n"); - } - #endif // _en_firewall_debug_ + fl_color_print_code(f_type_debug, data.context.reset); + fprintf(f_type_debug, "\n"); + } status = fll_execute_program(tools[i], arguments, 0, &return_code); @@ -1227,7 +1209,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(data.error.to.stream, data.context.set.error, "ERROR: Failed to perform requested %s operation:%c", tools[i], f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sFailed to perform requested %s operation:%c", fll_error_print_error, tools[i], f_string_eol[0]); fprintf(f_type_error, " "); fl_color_print_code(f_type_error, data.context.error); @@ -1241,10 +1223,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(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling fll_execute_program()%c", fll_error_print_error, f_string_eol[0]); } else { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()%c", status, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling fll_execute_program()%c", fll_error_print_error, status, f_string_eol[0]); } return status; @@ -1286,19 +1268,17 @@ f_return_status firewall_default_lock(const firewall_data_t data) { int return_code = 0; // print command when debugging. - #ifdef _en_firewall_debug_ - if (data.parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_type_debug, data.context.warning); - fprintf(f_type_debug, "%s ", tools[j]); + if (data.error.verbosity == f_console_verbosity_debug) { + fl_color_print_code(f_type_debug, data.context.warning); + fprintf(f_type_debug, "%s ", tools[j]); - for (f_string_length_t k = 0; k < arguments.used; k++) { - fprintf(f_type_debug, "%.*s ", arguments.array[k].used, arguments.array[k].string); - } // for + for (f_string_length_t k = 0; k < arguments.used; k++) { + fprintf(f_type_debug, "%.*s ", arguments.array[k].used, arguments.array[k].string); + } // for - fl_color_print_code(f_type_debug, data.context.reset); - fprintf(f_type_debug, "\n"); - } - #endif // _en_firewall_debug_ + fl_color_print_code(f_type_debug, data.context.reset); + fprintf(f_type_debug, "\n"); + } status = fll_execute_program(tools[j], arguments, 0, &return_code); @@ -1306,7 +1286,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(data.error.to.stream, data.context.set.error, "ERROR: Failed to perform requested %s operation:%c", tools[j], f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sFailed to perform requested %s operation:%c", fll_error_print_error, tools[j], f_string_eol[0]); fprintf(f_type_error, " "); fl_color_print_code(f_type_error, data.context.error); @@ -1320,10 +1300,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(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling fll_execute_program()%c", fll_error_print_error, f_string_eol[0]); } else { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()%c", status, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling fll_execute_program()%c", fll_error_print_error, status, f_string_eol[0]); } return status; @@ -1345,26 +1325,26 @@ f_return_status firewall_buffer_rules(const f_string_t filename, const bool opti if (optional) { if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open().%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling f_file_open().%c", fll_error_print_error, f_string_eol[0]); } else if (status != F_file_found_not && status != F_file_open && status != F_file_descriptor) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_open().%c", fll_error_print_error, status, f_string_eol[0]); } } else { if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open().%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling f_file_open().%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Unable to find the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to find the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Unable to open the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to open the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFile descriptor error while trying to open the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_open().%c", fll_error_print_error, status, f_string_eol[0]); } } @@ -1379,25 +1359,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(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_read().%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling f_file_read().%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_number_overflow) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Integer overflow while trying to buffer the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInteger overflow while trying to buffer the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_file_closed) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: The file '%s' is no longer open.%c", filename, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe file '%s' is no longer open.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_file_seek) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: A seek error occurred while accessing the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sA seek error occurred while accessing the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_file_read) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: A read error occurred while accessing the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sA read error occurred while accessing the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data->error.to.stream, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_read().%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_read().%c", fll_error_print_error, status, f_string_eol[0]); } return status; @@ -1414,16 +1394,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(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling fll_fss_basic_list_read() for the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_data_not_eos || status == F_data_not || status == F_data_not_stop) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: No relevant data was found within the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sNo relevant data was found within the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data->error.to.stream, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.%c", fll_error_print_error, status, filename, f_string_eol[0]); } return status; @@ -1444,13 +1424,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(data->error.to.stream, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_failure) { // the error message has already been displayed. } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling firewall_perform_commands().%c", fll_error_print_error, status, f_string_eol[0]); } f_macro_fss_objects_t_delete_simple(local->rule_objects); diff --git a/level_3/firewall/data/build/defines b/level_3/firewall/data/build/defines index c16fcf9..4f13080 100644 --- a/level_3/firewall/data/build/defines +++ b/level_3/firewall/data/build/defines @@ -1,3 +1 @@ # fss-0000 - -_en_firewall_debug_ Enable '++debug' parameter for outputting firewall commands as they are being executed. 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 2a5ea43..5ea2413 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 @@ -194,7 +194,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_at); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -203,7 +203,7 @@ extern "C" { } if (data->parameters[fss_basic_list_read_parameter_depth].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -212,7 +212,7 @@ extern "C" { } if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -221,7 +221,7 @@ extern "C" { } if (data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a string.%c", f_string_eol[0]); @@ -230,7 +230,7 @@ extern "C" { } if (data->parameters[fss_basic_list_read_parameter_select].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -240,7 +240,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); @@ -251,7 +251,7 @@ extern "C" { } if (data->parameters[fss_basic_list_read_parameter_select].result == f_console_result_additional) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); @@ -264,7 +264,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_total); @@ -281,6 +281,7 @@ extern "C" { f_string_length_t original_size = data->quantity.total; status = fss_basic_list_read_main_preprocess_depth(arguments, *data, &depths); + if (F_status_is_error(status)) { macro_fss_basic_list_read_depths_t_delete_simple(depths); fss_basic_list_read_delete_data(data); @@ -303,7 +304,7 @@ extern "C" { } if (data->parameters[fss_basic_list_read_parameter_select].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter requires a positive number.%c", f_string_eol[0]); @@ -318,8 +319,9 @@ extern "C" { file.id = f_type_descriptor_input; status = f_file_read(file, &data->buffer); + if (F_status_is_error(status)) { - fss_basic_list_read_print_file_error(data->context, "f_file_read", "-", F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read", F_true, "-", "read", fll_error_file_type_file); macro_fss_basic_list_read_depths_t_delete_simple(depths); fss_basic_list_read_delete_data(data); @@ -327,6 +329,7 @@ extern "C" { } status = fss_basic_list_read_main_process_file(arguments, data, "-", depths); + if (F_status_is_error(status)) { macro_fss_basic_list_read_depths_t_delete_simple(depths); fss_basic_list_read_delete_data(data); @@ -348,7 +351,7 @@ extern "C" { data->quantity.total = original_size; if (F_status_is_error(status)) { - fss_basic_list_read_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); macro_fss_basic_list_read_depths_t_delete_simple(depths); fss_basic_list_read_delete_data(data); @@ -358,7 +361,7 @@ extern "C" { if (!data->quantity.total) { status = f_file_size_by_id(file.id, &data->quantity.total); if (F_status_is_error(status)) { - fss_basic_list_read_print_file_error(data->context, "f_file_size_by_id", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments.argv[data->remaining.array[counter]], "read", fll_error_file_type_file); f_file_close(&file.id); @@ -379,13 +382,15 @@ extern "C" { f_file_close(&file.id); if (F_status_is_error(status)) { - fss_basic_list_read_print_file_error(data->context, "f_file_read_until", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read_until", F_true, arguments.argv[data->remaining.array[counter]], "read", fll_error_file_type_file); + macro_fss_basic_list_read_depths_t_delete_simple(depths); fss_basic_list_read_delete_data(data); return status; } status = fss_basic_list_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[counter]], depths); + if (F_status_is_error(status)) { macro_fss_basic_list_read_depths_t_delete_simple(depths); fss_basic_list_read_delete_data(data); @@ -402,7 +407,7 @@ extern "C" { macro_fss_basic_list_read_depths_t_delete_simple(depths); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: You failed to specify one or more files.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sYou failed to specify one or more files.%c", fll_error_print_error, f_string_eol[0]); status = F_status_set_error(F_parameter); } 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 569891c..e8f4f1d 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 @@ -5,83 +5,6 @@ extern "C" { #endif -#ifndef _di_fss_basic_list_read_print_file_error_ - 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(data.error.to.stream, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") has occurred while calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function_name); - fl_color_print(data.error.to.stream, context.set.error, ".%c", f_string_eol[0]); - } - } -#endif // _di_fss_basic_list_read_print_file_error_ - -#ifndef _di_fss_basic_list_read_print_number_argument_error_ - 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(data.error.to.stream, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function_name); - fl_color_print(data.error.to.stream, context.set.error, ".%c", f_string_eol[0]); - } - else if (status == F_number) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is not a valid number for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_underflow) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is too small for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_overflow) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is too large for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_negative) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is negative, which is not allowed for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_positive) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' contains a '"); - fl_color_print(data.error.to.stream, context.set.notable, "+"); - fl_color_print(data.error.to.stream, context.set.error, "', which is not allowed for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_data_not) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "' must not be an empty string.%c", f_string_eol[0]); - } - else { - fl_color_print(data.error.to.stream, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") has occurred while calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function_name); - fl_color_print(data.error.to.stream, context.set.error, "' for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "' with the value '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - } -#endif // _di_fss_basic_list_read_print_number_argument_error_ - #ifndef _di_fss_basic_list_read_main_preprocess_depth_ f_return_status fss_basic_list_read_main_preprocess_depth(const f_console_arguments_t arguments, const fss_basic_list_read_data_t data, fss_basic_list_read_depths_t *depths) { f_status_t status = F_none; @@ -94,8 +17,9 @@ extern "C" { } macro_fss_basic_list_read_depths_t_new(status, (*depths), depth_size); + if (F_status_is_error(status)) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); return status; } @@ -123,8 +47,9 @@ extern "C" { const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[position_depth])); status = fl_conversion_string_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth, range); + if (F_status_is_error(status)) { - fss_basic_list_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_basic_list_read_long_depth, arguments.argv[position_depth], F_status_set_fine(status)); + fll_error_parameter_integer_print(data.error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_depth, arguments.argv[position_depth]); return status; } } @@ -145,8 +70,9 @@ extern "C" { const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[depths->array[i].index_at])); status = fl_conversion_string_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at, range); + if (F_status_is_error(status)) { - fss_basic_list_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_basic_list_read_long_at, arguments.argv[depths->array[i].index_at], F_status_set_fine(status)); + fll_error_parameter_integer_print(data.error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_at, arguments.argv[depths->array[i].index_at]); return status; } } // for @@ -177,10 +103,10 @@ extern "C" { // @todo: move error printing into common function. if (status_code == F_memory_allocation || status_code == F_memory_reallocation) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else if (status_code == f_string_length_t_size) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Unable to process '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to process '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_trim); fl_color_print(data.error.to.stream, data.context.set.error, "' because the maximum buffer size was reached.%c", f_string_eol[0]); } @@ -191,7 +117,7 @@ extern "C" { function = "fl_string_rip"; } - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%u", status_code); fl_color_print(data.error.to.stream, data.context.set.error, ") has occurred while calling "); fl_color_print(data.error.to.stream, data.context.set.notable, "%s()", function); @@ -202,7 +128,7 @@ extern "C" { } if (!depths->array[i].value_name.used) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); fl_color_print(data.error.to.stream, data.context.set.error, "' must not be an empty string.%c", f_string_eol[0]); @@ -217,7 +143,7 @@ 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(data.error.to.stream, data.context.set.error, "ERROR: The value '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe value '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%llu", depths->array[i].depth); fl_color_print(data.error.to.stream, data.context.set.error, "' may only be specified once for the parameter '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); @@ -226,7 +152,7 @@ extern "C" { return F_status_set_error(F_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The parameter '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); fl_color_print(data.error.to.stream, data.context.set.error, "' may not have the value '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%llu", depths->array[i].depth); @@ -259,27 +185,27 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling ", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "fll_fss_basic_list_read()"); fl_color_print(data->error.to.stream, data->context.set.error, " for the file '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s", filename); fl_color_print(data->error.to.stream, data->context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data->error.to.stream, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_incomplete_utf_stop) { - fl_color_print(data->error.to.stream, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print(data->error.to.stream, data->context.set.error, "%sError occurred on invalid UTF-8 character at stop position (at ", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%d", input.start); fl_color_print(data->error.to.stream, data->context.set.error, ").%c", f_string_eol[0]); } else if (status == F_incomplete_utf_eos) { - fl_color_print(data->error.to.stream, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print(data->error.to.stream, data->context.set.error, "%sError occurred on invalid UTF-8 character at end of string (at ", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%d", input.start); fl_color_print(data->error.to.stream, data->context.set.error, ").%c", f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%u", status); fl_color_print(data->error.to.stream, data->context.set.error, ") has occurred while calling "); fl_color_print(data->error.to.stream, data->context.set.notable, "fll_fss_basic_list_read()"); @@ -309,7 +235,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range); if (F_status_is_error(status)) { - fss_basic_list_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_basic_list_read_long_select, arguments.argv[index], F_status_set_fine(status)); + fll_error_parameter_integer_print(data->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_select, arguments.argv[index]); return status; } @@ -328,7 +254,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range); if (F_status_is_error(status)) { - fss_basic_list_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_basic_list_read_long_line, arguments.argv[index], F_status_set_fine(status)); + fll_error_parameter_integer_print(data->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_line, arguments.argv[index]); return status; } } diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h index d27c582..5316302 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h @@ -158,40 +158,6 @@ extern "C" { #endif // _di_fss_basic_list_read_depths_t_ /** - * Print file error messages. - * - * @param context - * The color context information to use when printing. - * @param function_name - * The name of the function responsible for the error. - * @param file_name - * The name of the file with the error. - * @param status - * The status code representing the error. - */ -#ifndef _di_fss_basic_list_read_print_file_error_ - extern 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) f_gcc_attribute_visibility_internal; -#endif // _di_fss_basic_list_read_print_file_error_ - -/** - * Print number parameter argument error messages. - * - * @param context - * The color context information to use when printing. - * @param function_name - * The name of the function responsible for the error. - * @param parameter_name - * The name of the parameter responsible for the error. - * @param argument - * The value of the argument that is invalid. - * @param status - * The status code representing the error. - */ -#ifndef _di_fss_basic_list_read_print_number_argument_error_ - extern 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) f_gcc_attribute_visibility_internal; -#endif // _di_fss_basic_list_read_print_number_argument_error_ - -/** * Pre-process the parameters, parsing out and handling the depth and depth related parameters. * * Will handle depth-sensitive parameter conflicts, such as --name being used with --at (which is not allowed). 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 de2213d..9359dbc 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 @@ -118,19 +118,19 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling f_file_open()%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Unable to find the file '%s'%c", "-", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to find the file '%s'%c", fll_error_print_error, "-", f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Unable to open the file '%s'%c", "-", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to open the file '%s'%c", fll_error_print_error, "-", f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'%c", "-", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFile descriptor error while trying to open the file '%s'%c", fll_error_print_error, "-", f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_open()%c", fll_error_print_error, status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); @@ -231,19 +231,19 @@ extern "C" { f_file_close(&output.id); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling f_file_open()%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to find the file '%s'%c", fll_error_print_error, 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(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to open the file '%s'%c", fll_error_print_error, 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(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFile descriptor error while trying to open the file '%s'%c", fll_error_print_error, arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]], f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_open()%c", fll_error_print_error, status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); @@ -258,13 +258,13 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling f_file_write()%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_file_write) { - fl_color_print(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to write to the file '%s'%c", fll_error_print_error, arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]], f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_write()%c", fll_error_print_error, status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); 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 327379d..f9c78f2 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -194,7 +194,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_at); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -203,7 +203,7 @@ extern "C" { } if (data->parameters[fss_basic_read_parameter_depth].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -212,7 +212,7 @@ extern "C" { } if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -221,7 +221,7 @@ extern "C" { } if (data->parameters[fss_basic_read_parameter_name].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a string.%c", f_string_eol[0]); @@ -230,7 +230,7 @@ extern "C" { } if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -240,7 +240,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); @@ -251,7 +251,7 @@ extern "C" { } if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_additional) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); @@ -264,7 +264,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_total); @@ -303,7 +303,7 @@ extern "C" { } if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter requires a positive number.%c", f_string_eol[0]); @@ -320,7 +320,7 @@ extern "C" { status = f_file_read(file, &data->buffer); if (F_status_is_error(status)) { - fss_basic_read_print_file_error(data->context, "f_file_read", "-", F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read", F_true, "-", "read", fll_error_file_type_file); macro_fss_basic_read_depths_t_delete_simple(depths); fss_basic_read_delete_data(data); @@ -350,7 +350,7 @@ extern "C" { data->quantity.total = original_size; if (F_status_is_error(status)) { - fss_basic_read_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); macro_fss_basic_read_depths_t_delete_simple(depths); fss_basic_read_delete_data(data); @@ -361,7 +361,7 @@ extern "C" { status = f_file_size_by_id(file.id, &data->quantity.total); if (F_status_is_error(status)) { - fss_basic_read_print_file_error(data->context, "f_file_size_by_id", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments.argv[data->remaining.array[counter]], "read", fll_error_file_type_file); f_file_close(&file.id); @@ -382,7 +382,7 @@ extern "C" { f_file_close(&file.id); if (F_status_is_error(status)) { - fss_basic_read_print_file_error(data->context, "f_file_read_until", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read_until", F_true, arguments.argv[data->remaining.array[counter]], "read", fll_error_file_type_file); macro_fss_basic_read_depths_t_delete_simple(depths); fss_basic_read_delete_data(data); @@ -407,7 +407,7 @@ extern "C" { macro_fss_basic_read_depths_t_delete_simple(depths); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: You failed to specify one or more files.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sYou failed to specify one or more files.%c", fll_error_print_error, f_string_eol[0]); status = F_status_set_error(F_parameter); } 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 9549d80..10292f6 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 @@ -5,83 +5,6 @@ extern "C" { #endif -#ifndef _di_fss_basic_read_print_file_error_ - 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(data.error.to.stream, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") has occurred while calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function_name); - fl_color_print(data.error.to.stream, context.set.error, ".%c", f_string_eol[0]); - } - } -#endif // _di_fss_basic_read_print_file_error_ - -#ifndef _di_fss_basic_read_print_number_argument_error_ - 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(data.error.to.stream, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function_name); - fl_color_print(data.error.to.stream, context.set.error, ".%c", f_string_eol[0]); - } - else if (status == F_number) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is not a valid number for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_underflow) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is too small for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_overflow) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is too large for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_negative) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is negative, which is not allowed for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_positive) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' contains a '"); - fl_color_print(data.error.to.stream, context.set.notable, "+"); - fl_color_print(data.error.to.stream, context.set.error, "', which is not allowed for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_data_not) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "' must not be an empty string.%c", f_string_eol[0]); - } - else { - fl_color_print(data.error.to.stream, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") has occurred while calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function_name); - fl_color_print(data.error.to.stream, context.set.error, "' for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "' with the value '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - } -#endif // _di_fss_basic_read_print_number_argument_error_ - #ifndef _di_fss_basic_read_main_preprocess_depth_ f_return_status fss_basic_read_main_preprocess_depth(const f_console_arguments_t arguments, const fss_basic_read_data_t data, fss_basic_read_depths_t *depths) { f_status_t status = F_none; @@ -96,7 +19,7 @@ extern "C" { macro_fss_basic_read_depths_t_new(status, (*depths), depth_size); if (F_status_is_error(status)) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); return status; } @@ -126,7 +49,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth, range); if (F_status_is_error(status)) { - fss_basic_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_basic_read_long_depth, arguments.argv[position_depth], F_status_set_fine(status)); + fll_error_parameter_integer_print(data.error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_depth, arguments.argv[position_depth]); return status; } } @@ -149,7 +72,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at, range); if (F_status_is_error(status)) { - fss_basic_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_basic_read_long_at, arguments.argv[depths->array[i].index_at], F_status_set_fine(status)); + fll_error_parameter_integer_print(data.error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_at, arguments.argv[depths->array[i].index_at]); return status; } } // for @@ -180,10 +103,10 @@ extern "C" { // @todo: move error printing into common function. if (status_code == F_memory_allocation || status_code == F_memory_reallocation) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else if (status_code == f_string_length_t_size) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Unable to process '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to process '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_trim); fl_color_print(data.error.to.stream, data.context.set.error, "' because the maximum buffer size was reached.%c", f_string_eol[0]); } @@ -194,7 +117,7 @@ extern "C" { function = "fl_string_rip"; } - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%u", status_code); fl_color_print(data.error.to.stream, data.context.set.error, ") has occurred while calling "); fl_color_print(data.error.to.stream, data.context.set.notable, "%s()", function); @@ -205,7 +128,7 @@ extern "C" { } if (!depths->array[i].value_name.used) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); fl_color_print(data.error.to.stream, data.context.set.error, "' must not be an empty string.%c", f_string_eol[0]); @@ -220,7 +143,7 @@ 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(data.error.to.stream, data.context.set.error, "ERROR: The value '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe value '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%llu", depths->array[i].depth); fl_color_print(data.error.to.stream, data.context.set.error, "' may only be specified once for the parameter '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); @@ -229,7 +152,7 @@ extern "C" { return F_status_set_error(F_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The parameter '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); fl_color_print(data.error.to.stream, data.context.set.error, "' may not have the value '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%llu", depths->array[i].depth); @@ -262,27 +185,27 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling ", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "fll_fss_basic_list_read()"); fl_color_print(data->error.to.stream, data->context.set.error, " for the file '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s", filename); fl_color_print(data->error.to.stream, data->context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data->error.to.stream, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_incomplete_utf_stop) { - fl_color_print(data->error.to.stream, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print(data->error.to.stream, data->context.set.error, "%sError occurred on invalid UTF-8 character at stop position (at ", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%d", input.start); fl_color_print(data->error.to.stream, data->context.set.error, ").%c", f_string_eol[0]); } else if (status == F_incomplete_utf_eos) { - fl_color_print(data->error.to.stream, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print(data->error.to.stream, data->context.set.error, "%sError occurred on invalid UTF-8 character at end of string (at ", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%d", input.start); fl_color_print(data->error.to.stream, data->context.set.error, ").%c", f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%u", status); fl_color_print(data->error.to.stream, data->context.set.error, ") has occurred while calling "); fl_color_print(data->error.to.stream, data->context.set.notable, "fll_fss_basic_list_read()"); @@ -313,7 +236,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range); if (F_status_is_error(status)) { - fss_basic_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_basic_read_long_select, arguments.argv[index], F_status_set_fine(status)); + fll_error_parameter_integer_print(data->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_select, arguments.argv[index]); return status; } @@ -332,7 +255,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range); if (F_status_is_error(status)) { - fss_basic_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_basic_read_long_line, arguments.argv[index], F_status_set_fine(status)); + fll_error_parameter_integer_print(data->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_line, arguments.argv[index]); return status; } } diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.h b/level_3/fss_basic_read/c/private-fss_basic_read.h index bbb4cee..dd6d371 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.h +++ b/level_3/fss_basic_read/c/private-fss_basic_read.h @@ -158,40 +158,6 @@ extern "C" { #endif // _di_fss_basic_read_depths_t_ /** - * Print file error messages. - * - * @param context - * The color context information to use when printing. - * @param function_name - * The name of the function responsible for the error. - * @param file_name - * The name of the file with the error. - * @param status - * The status code representing the error. - */ -#ifndef _di_fss_basic_read_print_file_error_ - extern 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) f_gcc_attribute_visibility_internal; -#endif // _di_fss_basic_read_print_file_error_ - -/** - * Print number parameter argument error messages. - * - * @param context - * The color context information to use when printing. - * @param function_name - * The name of the function responsible for the error. - * @param parameter_name - * The name of the parameter responsible for the error. - * @param argument - * The value of the argument that is invalid. - * @param status - * The status code representing the error. - */ -#ifndef _di_fss_basic_read_print_number_argument_error_ - extern 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) f_gcc_attribute_visibility_internal; -#endif // _di_fss_basic_read_print_number_argument_error_ - -/** * Pre-process the parameters, parsing out and handling the depth and depth related parameters. * * Will handle depth-sensitive parameter conflicts, such as --name being used with --at (which is not allowed). 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 f8190a3..74cb2fb 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -118,19 +118,19 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling f_file_open()%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Unable to find the file '%s'%c", "-", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to find the file '%s'%c", fll_error_print_error, "-", f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Unable to open the file '%s'%c", "-", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to open the file '%s'%c", fll_error_print_error, "-", f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'%c", "-", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFile descriptor error while trying to open the file '%s'%c", fll_error_print_error, "-", f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_open()%c", fll_error_print_error, status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(input); @@ -220,19 +220,19 @@ extern "C" { f_file_close(&output.id); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling f_file_open()%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to find the file '%s'%c", fll_error_print_error, 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(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to open the file '%s'%c", fll_error_print_error, 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(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFile descriptor error while trying to open the file '%s'%c", fll_error_print_error, arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]], f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_open()%c", fll_error_print_error, status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); @@ -247,13 +247,13 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling f_file_write()%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_file_write) { - fl_color_print(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to write to the file '%s'%c", fll_error_print_error, arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]], f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_write()%c", fll_error_print_error, status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); 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 5acad1b..30d555e 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 @@ -194,7 +194,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_at); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -203,7 +203,7 @@ extern "C" { } if (data->parameters[fss_extended_list_read_parameter_depth].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -212,7 +212,7 @@ extern "C" { } if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -221,7 +221,7 @@ extern "C" { } if (data->parameters[fss_extended_list_read_parameter_name].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a string.%c", f_string_eol[0]); @@ -230,7 +230,7 @@ extern "C" { } if (data->parameters[fss_extended_list_read_parameter_select].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -240,7 +240,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); @@ -251,7 +251,7 @@ extern "C" { } if (data->parameters[fss_extended_list_read_parameter_select].result == f_console_result_additional) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); @@ -264,7 +264,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_total); @@ -289,7 +289,7 @@ extern "C" { } if (data->parameters[fss_extended_list_read_parameter_select].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter requires a positive number.%c", f_string_eol[0]); @@ -306,7 +306,7 @@ extern "C" { status = f_file_read(file, &data->buffer); if (F_status_is_error(status)) { - fss_extended_list_read_print_file_error(data->context, "f_file_read", "-", F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read", F_true, "-", "read", fll_error_file_type_file); macro_fss_extended_list_read_depths_t_delete_simple(depths); fss_extended_list_read_delete_data(data); @@ -335,7 +335,7 @@ extern "C" { data->quantity.total = original_size; if (F_status_is_error(status)) { - fss_extended_list_read_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); macro_fss_extended_list_read_depths_t_delete_simple(depths); fss_extended_list_read_delete_data(data); @@ -345,7 +345,7 @@ extern "C" { if (!data->quantity.total) { status = f_file_size_by_id(file.id, &data->quantity.total); if (F_status_is_error(status)) { - fss_extended_list_read_print_file_error(data->context, "f_file_size_by_id", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments.argv[data->remaining.array[counter]], "read", fll_error_file_type_file); f_file_close(&file.id); @@ -366,7 +366,7 @@ extern "C" { f_file_close(&file.id); if (F_status_is_error(status)) { - fss_extended_list_read_print_file_error(data->context, "f_file_read_until", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read_until", F_true, arguments.argv[data->remaining.array[counter]], "read", fll_error_file_type_file); macro_fss_extended_list_read_depths_t_delete_simple(depths); fss_extended_list_read_delete_data(data); @@ -390,7 +390,7 @@ extern "C" { macro_fss_extended_list_read_depths_t_delete_simple(depths); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: You failed to specify one or more files.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sYou failed to specify one or more files.%c", fll_error_print_error, f_string_eol[0]); status = F_status_set_error(F_parameter); } 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 558e798..3412eb8 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 @@ -5,83 +5,6 @@ extern "C" { #endif -#ifndef _di_fss_extended_list_read_print_file_error_ - 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(data.error.to.stream, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") has occurred while calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function_name); - fl_color_print(data.error.to.stream, context.set.error, ".%c", f_string_eol[0]); - } - } -#endif // _di_fss_extended_list_read_print_file_error_ - -#ifndef _di_fss_extended_list_read_print_number_argument_error_ - 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(data.error.to.stream, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function_name); - fl_color_print(data.error.to.stream, context.set.error, ".%c", f_string_eol[0]); - } - else if (status == F_number) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is not a valid number for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_underflow) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is too small for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_overflow) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is too large for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_negative) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is negative, which is not allowed for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_positive) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' contains a '"); - fl_color_print(data.error.to.stream, context.set.notable, "+"); - fl_color_print(data.error.to.stream, context.set.error, "', which is not allowed for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_data_not) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "' must not be an empty string.%c", f_string_eol[0]); - } - else { - fl_color_print(data.error.to.stream, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") has occurred while calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function_name); - fl_color_print(data.error.to.stream, context.set.error, "' for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "' with the value '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - } -#endif // _di_fss_extended_list_read_print_number_argument_error_ - #ifndef _di_fss_extended_list_read_main_preprocess_depth_ f_return_status fss_extended_list_read_main_preprocess_depth(const f_console_arguments_t arguments, const fss_extended_list_read_data_t data, fss_extended_list_read_depths_t *depths) { f_status_t status = F_none; @@ -96,7 +19,7 @@ extern "C" { macro_fss_extended_list_read_depths_t_new(status, (*depths), depth_size); if (F_status_is_error(status)) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); return status; } @@ -126,7 +49,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth, range); if (F_status_is_error(status)) { - fss_extended_list_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_extended_list_read_long_depth, arguments.argv[position_depth], F_status_set_fine(status)); + fll_error_parameter_integer_print(data.error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_depth, arguments.argv[position_depth]); return status; } } @@ -149,7 +72,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at, range); if (F_status_is_error(status)) { - fss_extended_list_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_extended_list_read_long_at, arguments.argv[depths->array[i].index_at], F_status_set_fine(status)); + fll_error_parameter_integer_print(data.error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_at, arguments.argv[depths->array[i].index_at]); return status; } } // for @@ -180,10 +103,10 @@ extern "C" { // @todo: move error printing into common function. if (status_code == F_memory_allocation || status_code == F_memory_reallocation) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else if (status_code == f_string_length_t_size) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Unable to process '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to process '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_trim); fl_color_print(data.error.to.stream, data.context.set.error, "' because the maximum buffer size was reached.%c", f_string_eol[0]); } @@ -194,7 +117,7 @@ extern "C" { function = "fl_string_rip"; } - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%u", status_code); fl_color_print(data.error.to.stream, data.context.set.error, ") has occurred while calling "); fl_color_print(data.error.to.stream, data.context.set.notable, "%s()", function); @@ -205,7 +128,7 @@ extern "C" { } if (!depths->array[i].value_name.used) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); fl_color_print(data.error.to.stream, data.context.set.error, "' must not be an empty string.%c", f_string_eol[0]); @@ -220,7 +143,7 @@ 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(data.error.to.stream, data.context.set.error, "ERROR: The value '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe value '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%llu", depths->array[i].depth); fl_color_print(data.error.to.stream, data.context.set.error, "' may only be specified once for the parameter '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); @@ -229,7 +152,7 @@ extern "C" { return F_status_set_error(F_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The parameter '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); fl_color_print(data.error.to.stream, data.context.set.error, "' may not have the value '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%llu", depths->array[i].depth); @@ -262,27 +185,27 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling ", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "fll_fss_extended_list_read()"); fl_color_print(data->error.to.stream, data->context.set.error, " for the file '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s", filename); fl_color_print(data->error.to.stream, data->context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data->error.to.stream, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_incomplete_utf_stop) { - fl_color_print(data->error.to.stream, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print(data->error.to.stream, data->context.set.error, "%sError occurred on invalid UTF-8 character at stop position (at ", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%d", input.start); fl_color_print(data->error.to.stream, data->context.set.error, ").%c", f_string_eol[0]); } else if (status == F_incomplete_utf_eos) { - fl_color_print(data->error.to.stream, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print(data->error.to.stream, data->context.set.error, "%sError occurred on invalid UTF-8 character at end of string (at ", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%d", input.start); fl_color_print(data->error.to.stream, data->context.set.error, ").%c", f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%u", status); fl_color_print(data->error.to.stream, data->context.set.error, ") has occurred while calling "); fl_color_print(data->error.to.stream, data->context.set.notable, "fll_fss_extended_list_read()"); @@ -322,7 +245,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range); if (F_status_is_error(status)) { - fss_extended_list_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_extended_list_read_long_select, arguments.argv[index], F_status_set_fine(status)); + fll_error_parameter_integer_print(data->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_select, arguments.argv[index]); return status; } @@ -344,7 +267,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range); if (F_status_is_error(status)) { - fss_extended_list_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_extended_list_read_long_line, arguments.argv[index], F_status_set_fine(status)); + fll_error_parameter_integer_print(data->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_line, arguments.argv[index]); return status; } } diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h index 8d46cd3..5d1c8cd 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h @@ -158,40 +158,6 @@ extern "C" { #endif // _di_fss_extended_list_read_depths_t_ /** - * Print file error messages. - * - * @param context - * The color context information to use when printing. - * @param function_name - * The name of the function responsible for the error. - * @param file_name - * The name of the file with the error. - * @param status - * The status code representing the error. - */ -#ifndef _di_fss_extended_list_read_print_file_error_ - extern 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) f_gcc_attribute_visibility_internal; -#endif // _di_fss_extended_list_read_print_file_error_ - -/** - * Print number parameter argument error messages. - * - * @param context - * The color context information to use when printing. - * @param function_name - * The name of the function responsible for the error. - * @param parameter_name - * The name of the parameter responsible for the error. - * @param argument - * The value of the argument that is invalid. - * @param status - * The status code representing the error. - */ -#ifndef _di_fss_extended_list_read_print_number_argument_error_ - extern 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) f_gcc_attribute_visibility_internal; -#endif // _di_fss_extended_list_read_print_number_argument_error_ - -/** * Pre-process the parameters, parsing out and handling the depth and depth related parameters. * * Will handle depth-sensitive parameter conflicts, such as --name being used with --at (which is not allowed). 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 53f1e50..1476983 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -194,7 +194,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_at); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -203,7 +203,7 @@ extern "C" { } if (data->parameters[fss_extended_read_parameter_depth].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -212,7 +212,7 @@ extern "C" { } if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -221,7 +221,7 @@ extern "C" { } if (data->parameters[fss_extended_read_parameter_name].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a string.%c", f_string_eol[0]); @@ -230,7 +230,7 @@ extern "C" { } if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); @@ -240,7 +240,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); @@ -251,7 +251,7 @@ extern "C" { } if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); @@ -264,7 +264,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_total); @@ -304,7 +304,7 @@ extern "C" { } if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter requires a positive number.%c", f_string_eol[0]); @@ -321,7 +321,7 @@ extern "C" { status = f_file_read(file, &data->buffer); if (F_status_is_error(status)) { - fss_extended_read_print_file_error(data->context, "f_file_read", "-", F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read", F_true, "-", "read", fll_error_file_type_file); macro_fss_extended_read_depths_t_delete_simple(depths); fss_extended_read_delete_data(data); @@ -351,7 +351,7 @@ extern "C" { data->quantity.total = original_size; if (F_status_is_error(status)) { - fss_extended_read_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); macro_fss_extended_read_depths_t_delete_simple(depths); fss_extended_read_delete_data(data); @@ -362,7 +362,7 @@ extern "C" { status = f_file_size_by_id(file.id, &data->quantity.total); if (F_status_is_error(status)) { - fss_extended_read_print_file_error(data->context, "f_file_size_by_id", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments.argv[data->remaining.array[counter]], "read", fll_error_file_type_file); f_file_close(&file.id); @@ -383,7 +383,7 @@ extern "C" { f_file_close(&file.id); if (F_status_is_error(status)) { - fss_extended_read_print_file_error(data->context, "f_file_read_until", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read_until", F_true, arguments.argv[data->remaining.array[counter]], "read", fll_error_file_type_file); macro_fss_extended_read_depths_t_delete_simple(depths); fss_extended_read_delete_data(data); @@ -408,7 +408,7 @@ extern "C" { macro_fss_extended_read_depths_t_delete_simple(depths); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: You failed to specify one or more files.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sYou failed to specify one or more files.%c", fll_error_print_error, f_string_eol[0]); status = F_status_set_error(F_parameter); } 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 ff1a3d4..621ba89 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 @@ -5,83 +5,6 @@ extern "C" { #endif -#ifndef _di_fss_extended_read_print_file_error_ - 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(data.error.to.stream, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") has occurred while calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function_name); - fl_color_print(data.error.to.stream, context.set.error, ".%c", f_string_eol[0]); - } - } -#endif // _di_fss_extended_read_print_file_error_ - -#ifndef _di_fss_extended_read_print_number_argument_error_ - 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(data.error.to.stream, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function_name); - fl_color_print(data.error.to.stream, context.set.error, ".%c", f_string_eol[0]); - } - else if (status == F_number) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is not a valid number for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_underflow) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is too small for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_overflow) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is too large for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_negative) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is negative, which is not allowed for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_positive) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' contains a '"); - fl_color_print(data.error.to.stream, context.set.notable, "+"); - fl_color_print(data.error.to.stream, context.set.error, "', which is not allowed for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_data_not) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "' must not be an empty string.%c", f_string_eol[0]); - } - else { - fl_color_print(data.error.to.stream, context.set.error, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") has occurred while calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function_name); - fl_color_print(data.error.to.stream, context.set.error, "' for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(data.error.to.stream, context.set.error, "' with the value '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - } -#endif // _di_fss_extended_read_print_number_argument_error_ - #ifndef _di_fss_extended_read_main_preprocess_depth_ f_return_status fss_extended_read_main_preprocess_depth(const f_console_arguments_t arguments, const fss_extended_read_data_t data, fss_extended_read_depths_t *depths) { f_status_t status = F_none; @@ -94,8 +17,9 @@ extern "C" { } macro_fss_extended_read_depths_t_new(status, (*depths), depth_size); + if (F_status_is_error(status)) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); return status; } @@ -125,7 +49,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth, range); if (F_status_is_error(status)) { - fss_extended_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_extended_read_long_depth, arguments.argv[position_depth], F_status_set_fine(status)); + fll_error_parameter_integer_print(data.error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_depth, arguments.argv[position_depth]); return status; } } @@ -148,7 +72,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at, range); if (F_status_is_error(status)) { - fss_extended_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_extended_read_long_at, arguments.argv[depths->array[i].index_at], F_status_set_fine(status)); + fll_error_parameter_integer_print(data.error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_at, arguments.argv[depths->array[i].index_at]); return status; } } // for @@ -179,10 +103,10 @@ extern "C" { // @todo: move error printing into common function. if (status_code == F_memory_allocation || status_code == F_memory_reallocation) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else if (status_code == f_string_length_t_size) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Unable to process '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to process '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_trim); fl_color_print(data.error.to.stream, data.context.set.error, "' because the maximum buffer size was reached.%c", f_string_eol[0]); } @@ -193,7 +117,7 @@ extern "C" { function = "fl_string_rip"; } - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%u", status_code); fl_color_print(data.error.to.stream, data.context.set.error, ") has occurred while calling "); fl_color_print(data.error.to.stream, data.context.set.notable, "%s()", function); @@ -204,7 +128,7 @@ extern "C" { } if (!depths->array[i].value_name.used) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); fl_color_print(data.error.to.stream, data.context.set.error, "' must not be an empty string.%c", f_string_eol[0]); @@ -219,7 +143,7 @@ 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(data.error.to.stream, data.context.set.error, "ERROR: The value '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe value '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%llu", depths->array[i].depth); fl_color_print(data.error.to.stream, data.context.set.error, "' may only be specified once for the parameter '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); @@ -228,7 +152,7 @@ extern "C" { return F_status_set_error(F_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The parameter '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); fl_color_print(data.error.to.stream, data.context.set.error, "' may not have the value '"); fl_color_print(data.error.to.stream, data.context.set.notable, "%llu", depths->array[i].depth); @@ -261,27 +185,27 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling ", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "fll_fss_extended_read()"); fl_color_print(data->error.to.stream, data->context.set.error, " for the file '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s", filename); fl_color_print(data->error.to.stream, data->context.set.error, "'.%c", f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data->error.to.stream, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_incomplete_utf_stop) { - fl_color_print(data->error.to.stream, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print(data->error.to.stream, data->context.set.error, "%sError occurred on invalid UTF-8 character at stop position (at ", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%d", input.start); fl_color_print(data->error.to.stream, data->context.set.error, ").%c", f_string_eol[0]); } else if (status == F_incomplete_utf_eos) { - fl_color_print(data->error.to.stream, data->context.set.error, "ENCODING ERROR: Error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print(data->error.to.stream, data->context.set.error, "%sError occurred on invalid UTF-8 character at end of string (at ", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%d", input.start); fl_color_print(data->error.to.stream, data->context.set.error, ").%c", f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%u", status); fl_color_print(data->error.to.stream, data->context.set.error, ") has occurred while calling "); fl_color_print(data->error.to.stream, data->context.set.notable, "fll_fss_extended_read()"); @@ -312,7 +236,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range); if (F_status_is_error(status)) { - fss_extended_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_extended_read_long_select, arguments.argv[index], F_status_set_fine(status)); + fll_error_parameter_integer_print(data->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_select, arguments.argv[index]); return status; } } @@ -326,7 +250,7 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range); if (F_status_is_error(status)) { - fss_extended_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_extended_read_long_line, arguments.argv[index], F_status_set_fine(status)); + fll_error_parameter_integer_print(data->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_line, arguments.argv[index]); return status; } } diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.h b/level_3/fss_extended_read/c/private-fss_extended_read.h index fd2798f..7b89827 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.h +++ b/level_3/fss_extended_read/c/private-fss_extended_read.h @@ -158,40 +158,6 @@ extern "C" { #endif // _di_fss_extended_read_depths_t_ /** - * Print file error messages. - * - * @param context - * The color context information to use when printing. - * @param function_name - * The name of the function responsible for the error. - * @param file_name - * The name of the file with the error. - * @param status - * The status code representing the error. - */ -#ifndef _di_fss_extended_read_print_file_error_ - extern 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) f_gcc_attribute_visibility_internal; -#endif // _di_fss_extended_read_print_file_error_ - -/** - * Print number parameter argument error messages. - * - * @param context - * The color context information to use when printing. - * @param function_name - * The name of the function responsible for the error. - * @param parameter_name - * The name of the parameter responsible for the error. - * @param argument - * The value of the argument that is invalid. - * @param status - * The status code representing the error. - */ -#ifndef _di_fss_extended_read_print_number_argument_error_ - extern 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) f_gcc_attribute_visibility_internal; -#endif // _di_fss_extended_read_print_number_argument_error_ - -/** * Pre-process the parameters, parsing out and handling the depth and depth related parameters. * * Will handle depth-sensitive parameter conflicts, such as --name being used with --at (which is not allowed). 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 3766f86..267f103 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -118,19 +118,19 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling f_file_open()%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Unable to find the file '%s'%c", "-", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to find the file '%s'%c", fll_error_print_error, "-", f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Unable to open the file '%s'%c", "-", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to open the file '%s'%c", fll_error_print_error, "-", f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'%c", "-", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFile descriptor error while trying to open the file '%s'%c", fll_error_print_error, "-", f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_open()%c", fll_error_print_error, status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(input); @@ -272,19 +272,19 @@ extern "C" { f_file_close(&output.id); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling f_file_open()%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to find the file '%s'%c", fll_error_print_error, 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(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to open the file '%s'%c", fll_error_print_error, 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(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFile descriptor error while trying to open the file '%s'%c", fll_error_print_error, arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]], f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_open()%c", fll_error_print_error, status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); @@ -299,13 +299,13 @@ extern "C" { status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sInvalid parameter when calling f_file_write()%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_file_write) { - fl_color_print(data->error.to.stream, 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]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to write to the file '%s'%c", fll_error_print_error, arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]], f_string_eol[0]); } else { - fl_color_print(data->error.to.stream, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()%c", status, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_write()%c", fll_error_print_error, status, f_string_eol[0]); } f_macro_string_dynamic_t_delete_simple(buffer); 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 d781c2e..9675b3c 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -101,7 +101,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_error); fl_color_print(data->error.to.stream, data->context.set.error, "' cannot be used with the parameter "); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_warning); @@ -111,7 +111,7 @@ extern "C" { return F_status_set_error(status); } else if (data->parameters[fss_status_code_parameter_is_fine].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_error); fl_color_print(data->error.to.stream, data->context.set.error, "' cannot be used with the parameter "); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_fine); @@ -122,7 +122,7 @@ extern "C" { } } 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_warning); fl_color_print(data->error.to.stream, data->context.set.error, "' cannot be used with the parameter "); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_fine); @@ -133,7 +133,7 @@ extern "C" { } if (data->remaining.used == 0 && !data->process_pipe) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: You failed to specify an error code.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sYou failed to specify an error code.%c", fll_error_print_error, f_string_eol[0]); fss_status_code_delete_data(data); return F_status_set_error(F_parameter); diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index 21c3d75..5c4d74c 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -105,7 +105,7 @@ extern "C" { data->error.notable = data->context.set.notable; 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); + fll_error_print(data->error, F_status_set_fine(status), "fll_program_parameter_process", F_true); if (data->error.verbosity == f_console_verbosity_verbose) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); @@ -125,7 +125,7 @@ extern "C" { 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); + fll_error_print(data->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true); iki_read_delete_data(data); return status; @@ -166,7 +166,7 @@ extern "C" { if (data->parameters[iki_read_parameter_at].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_at); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); } @@ -182,7 +182,7 @@ extern "C" { 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]); + fll_error_parameter_integer_print(data->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, iki_read_long_at, arguments.argv[index]); status = F_status_set_error(F_parameter); } @@ -192,7 +192,7 @@ extern "C" { if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_at); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); @@ -206,7 +206,7 @@ extern "C" { if (data->parameters[iki_read_parameter_line].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_line); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a positive number.%c", f_string_eol[0]); } @@ -222,7 +222,7 @@ extern "C" { 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]); + fll_error_parameter_integer_print(data->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, iki_read_long_line, arguments.argv[index]); status = F_status_set_error(F_parameter); } @@ -233,7 +233,7 @@ extern "C" { if (data->parameters[iki_read_parameter_name].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_name); fl_color_print(data->error.to.stream, data->context.set.error, "' requires a string.%c", f_string_eol[0]); } @@ -245,7 +245,7 @@ extern "C" { 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) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_substitute); fl_color_print(data->error.to.stream, data->context.set.error, "' requires 3 strings.%c", f_string_eol[0]); } @@ -256,7 +256,7 @@ extern "C" { if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_substitute); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); @@ -271,7 +271,7 @@ extern "C" { if (data->parameters[iki_read_parameter_object].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_literal); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_object); @@ -284,7 +284,7 @@ extern "C" { if (data->parameters[iki_read_parameter_content].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_literal); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_content); @@ -297,7 +297,7 @@ extern "C" { if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_literal); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); @@ -313,7 +313,7 @@ extern "C" { if (data->parameters[iki_read_parameter_content].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_object); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_content); @@ -326,7 +326,7 @@ extern "C" { if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_object); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); @@ -350,7 +350,7 @@ extern "C" { if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Cannot specify the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_whole); fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_read_long_total); @@ -378,7 +378,7 @@ extern "C" { status = f_file_read(file, &data->buffer); 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); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read", F_true, "-", "process", fll_error_file_type_file); } else { status = iki_read_process_buffer(arguments, "-", data); @@ -400,14 +400,14 @@ extern "C" { 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->error.verbosity, F_status_set_fine(status), "f_file_open", arguments.argv[data->remaining.array[i]], "process", F_true, F_true); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_open", F_true, arguments.argv[data->remaining.array[i]], "process", fll_error_file_type_file); break; } status = f_file_size_by_id(file.id, &total); 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); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments.argv[data->remaining.array[i]], "process", fll_error_file_type_file); f_file_close(&file.id); break; @@ -424,7 +424,7 @@ extern "C" { f_file_close(&file.id); 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); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read_until", F_true, arguments.argv[data->remaining.array[i]], "process", fll_error_file_type_file); break; } @@ -439,7 +439,7 @@ extern "C" { else { if (data->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: you failed to specify one or more files.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%syou failed to specify one or more files.%c", fll_error_print_error, f_string_eol[0]); } status = F_status_set_error(F_parameter); diff --git a/level_3/iki_read/c/private-iki_read.c b/level_3/iki_read/c/private-iki_read.c index fd02230..1f8bdc4 100644 --- a/level_3/iki_read/c/private-iki_read.c +++ b/level_3/iki_read/c/private-iki_read.c @@ -5,298 +5,6 @@ extern "C" { #endif -#ifndef _di_iki_read_print_error_ - f_return_status iki_read_print_error(const f_color_context_t context, const uint8_t verbosity, const f_status_t status, const f_string_t function, const bool fallback) { - - if (status == F_parameter) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Invalid parameter when calling function "); - fl_color_print(data.error.to.stream, context.set.notable, "%s", function); - fl_color_print(data.error.to.stream, context.set.error, "().%c", f_string_eol[0]); - } - - return F_none; - } - - if (status == F_memory_allocation || status == F_memory_reallocation) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Unable to allocate memory in function "); - fl_color_print(data.error.to.stream, context.set.notable, "%s", function); - fl_color_print(data.error.to.stream, context.set.error, "().%c", f_string_eol[0]); - } - - return F_none; - } - - if (status == F_buffer_too_large) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Maximum buffer limit reached while processing "); - fl_color_print(data.error.to.stream, context.set.notable, "%s", function); - fl_color_print(data.error.to.stream, context.set.error, "().%c", f_string_eol[0]); - } - - return F_none; - } - - if (status == F_string_too_large) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Maximum string limit reached while processing "); - fl_color_print(data.error.to.stream, context.set.notable, "%s", function); - fl_color_print(data.error.to.stream, context.set.error, "().%c", f_string_eol[0]); - } - - return F_none; - } - - if (fallback && verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") in function "); - fl_color_print(data.error.to.stream, context.set.notable, "%s", function); - fl_color_print(data.error.to.stream, context.set.error, "().%c", f_string_eol[0]); - } - - return F_unknown; - } -#endif // _di_iki_read_print_error_ - -#ifndef _di_iki_read_print_error_file_ - bool iki_read_print_error_file(const f_color_context_t context, const uint8_t verbosity, 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 (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Failed to find %s '", file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_file_found) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The %s '", file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "' already exists.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_parameter) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s", function); - fl_color_print(data.error.to.stream, context.set.error, "() for the %s '", file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_name) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Invalid %s name '", file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_memory_out) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "CRITICAL ERROR: Unable to allocate memory, while trying to %s %s '", operation, file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_number_overflow) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Overflow while trying to %s %s '", operation, file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_directory) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Invalid directory while trying to %s %s '", operation, file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_access_denied) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Access denied while trying to %s %s '", operation, file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_loop) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Loop while trying to %s %s '", operation, file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_prohibited) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Prohibited by system while trying to %s %s '", operation, file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (is_file) { - if (status == F_directory_found_not) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Failed to %s %s '", operation, file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "' due to an invalid directory in the path.%c", f_string_eol[0]); - } - - return F_false; - } - } - else { - if (status == F_directory_found_not) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Failed to %s %s '", operation, file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "' due to an invalid directory in the path.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_failure) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Failed to %s %s '", operation, file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - } - - if (iki_read_print_error(context, verbosity, status, function, F_false) == F_unknown && fallback && verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") occurred while trying to %s %s '", operation, file_or_directory); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_true; - } -#endif // _di_iki_read_print_error_file_ - -#ifndef _di_iki_read_print_error_number_argument_ - 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(data.error.to.stream, "%c", f_string_eol[0]); - - if (status == F_parameter) { - fl_color_print(data.error.to.stream, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function); - fl_color_print(data.error.to.stream, context.set.error, ".%c", f_string_eol[0]); - } - else if (status == F_number) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is not a valid number for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_underflow) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is too small for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_overflow) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is too large for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_negative) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' is negative, which is not allowed for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_number_positive) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The argument '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "' contains a '"); - fl_color_print(data.error.to.stream, context.set.notable, "+"); - fl_color_print(data.error.to.stream, context.set.error, "', which is not allowed for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - else if (status == F_data_not) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print(data.error.to.stream, context.set.error, "' must not be an empty string.%c", f_string_eol[0]); - } - else { - fl_color_print(data.error.to.stream, context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") has occurred while calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s()", function); - fl_color_print(data.error.to.stream, context.set.error, "' for the parameter '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print(data.error.to.stream, context.set.error, "' with the value '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", argument); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - } -#endif // _di_iki_read_print_error_number_argument_ - #ifndef _di_iki_read_process_at_ f_return_status iki_read_process_at(const f_console_arguments_t arguments, const f_string_t file_name, iki_read_data_t *data, f_string_range_t *range) { if (data->parameters[iki_read_parameter_line].result != f_console_result_additional) return F_false; @@ -399,7 +107,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->error.verbosity, F_status_set_fine(status), "fl_iki_read", F_true); + fll_error_print(data->error, F_status_set_fine(status), "fl_iki_read", F_true); return status; } @@ -413,7 +121,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->error.verbosity, F_status_set_fine(status), "iki_read_substitutions_identify", F_true); + fll_error_print(data->error, 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 +147,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->error.verbosity, F_status_set_fine(status), "fl_string_append_nulless", F_true); + fll_error_print(data->error, 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 +221,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->error.verbosity, F_status_set_fine(status), "fl_iki_read", F_true); + fll_error_print(data->error, F_status_set_fine(status), "fl_iki_read", F_true); return status; } @@ -532,7 +240,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->error.verbosity, F_status_set_fine(status), "iki_read_substitutions_identify", F_true); + fll_error_print(data->error, 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]); @@ -572,14 +280,16 @@ 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->error.verbosity, F_status_set_fine(status), "iki_read_process_buffer_ranges_whole", F_true); + fll_error_print(data->error, 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->error.verbosity, F_status_set_fine(status), "fl_string_append_nulless", F_true); + fll_error_print(data->error, F_status_set_fine(status), "fl_string_append_nulless", F_true); break; } @@ -699,7 +409,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->error.verbosity, F_status_set_fine(status), "fl_iki_read", F_true); + fll_error_print(data->error, F_status_set_fine(status), "fl_iki_read", F_true); return status; } @@ -722,7 +432,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->error.verbosity, F_status_set_fine(status), "fl_string_append_nulless", F_true); + fll_error_print(data->error, 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/c/private-iki_read.h b/level_3/iki_read/c/private-iki_read.h index 034cc6a..09b7b5d 100644 --- a/level_3/iki_read/c/private-iki_read.h +++ b/level_3/iki_read/c/private-iki_read.h @@ -13,82 +13,6 @@ extern "C" { #endif /** - * Print generic error messages. - * - * @param context - * The color context. - * @param verbosity - * The verbosity level, which determines if and what should be printed. - * @param status - * The status code representing an error. - * @param function - * The name of the function where the error happened. - * @param fallback - * Set to F_true to print the fallback error message for unknown errors. - * - * @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_iki_read_print_error_ - extern f_return_status iki_read_print_error(const f_color_context_t context, const uint8_t verbosity, const f_status_t status, const f_string_t function, const bool fallback) f_gcc_attribute_visibility_internal; -#endif // _di_iki_read_print_error_ - -/** - * Print file/directory error messages. - * - * @todo the fll_file_error_print() needs to be reviewed and possibly changed. - * - * @param context - * The color context. - * @param verbosity - * The verbosity level, which determines if and what should be printed. - * @param status - * The error status code to report on. - * @param function - * The function call that returned the error. - * @param name - * The name of the file or directory. - * @param operation - * The operation that fails, such as 'create' or 'access'. - * @param is_file - * Set to TRUE if this is a file and FALSE if this is a directory. - * @param fallback - * Set to F_true to print the fallback error message for unknown errors. - * - * @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_iki_read_print_error_file_ - extern bool iki_read_print_error_file(const f_color_context_t context, const uint8_t verbosity, 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_iki_read_print_error_file_ - -/** - * Print number argument errors. - * - * @param context - * The color context. - * @param verbosity - * The verbosity level, which determines if and what should be printed. - * @param status - * The error status code to report on. - * @param function - * The function call that returned the error. - * @param parameter - * The parameter name. - * @param argument - * The argument value. - * - * @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_iki_read_print_error_number_argument_ - extern 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) f_gcc_attribute_visibility_internal; -#endif // _di_iki_read_print_error_number_argument_ - -/** * Determine the range based on the --at parameter. * * If the --at parameter is not specified in the console arguments, then range is untouched. diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index 985153d..30e3808 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -68,9 +68,8 @@ extern "C" { data->error.notable = data->context.set.notable; 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) { + if (data->error.verbosity != f_console_verbosity_quiet) { + fll_error_print(data->error, F_status_set_fine(status), "fll_program_parameter_process", F_true); fprintf(data->error.to.stream, "%c", f_string_eol[0]); } @@ -132,7 +131,7 @@ extern "C" { if (data->parameters[iki_write_parameter_file].result == f_console_result_additional) { if (data->parameters[iki_write_parameter_file].additional.used > 1) { if (data->error.verbosity != f_console_verbosity_quiet) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_file); fl_color_print(data->error.to.stream, data->context.set.error, "' may only be specified once.%c", f_string_eol[0]); } @@ -146,13 +145,13 @@ 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->error.verbosity, F_status_set_fine(status), "f_file_open", arguments.argv[location], "open", 0, F_true); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_open", F_true, arguments.argv[location], "open", fll_error_file_type_file); } } } else if (data->parameters[iki_write_parameter_file].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_file); fl_color_print(data->error.to.stream, data->context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); } @@ -163,7 +162,7 @@ extern "C" { if (F_status_is_fine(status) && data->parameters[iki_write_parameter_object].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_object); fl_color_print(data->error.to.stream, data->context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); } @@ -173,7 +172,7 @@ extern "C" { if (F_status_is_fine(status) && data->parameters[iki_write_parameter_content].result == f_console_result_found) { if (data->error.verbosity != f_console_verbosity_quiet) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_content); fl_color_print(data->error.to.stream, data->context.set.error, "' was specified, but no value was given.%c", f_string_eol[0]); } @@ -185,7 +184,7 @@ extern "C" { 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->error.verbosity != f_console_verbosity_quiet) { fprintf(data->error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: No data provided, either pipe the data or use the '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sNo data provided, either pipe the data or use the '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_object); fl_color_print(data->error.to.stream, data->context.set.error, "' and the '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_content); @@ -199,7 +198,7 @@ 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->error.verbosity != f_console_verbosity_quiet) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameters '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameters '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_content); fl_color_print(data->error.to.stream, data->context.set.error, "' and '"); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, iki_write_long_object); @@ -251,7 +250,7 @@ extern "C" { status_pipe = f_file_read(file, &buffer); if (F_status_is_error(status_pipe)) { - iki_write_print_error_file(data->context, data->error.verbosity, F_status_set_fine(status_pipe), "f_file_read_to", "-", "read", 2, F_true); + fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read_to", F_true, "-", "read", fll_error_file_type_pipe); status = F_status_set_error(F_pipe); break; @@ -259,7 +258,7 @@ extern "C" { if (!buffer.used) { if (data->error.verbosity != f_console_verbosity_quiet) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The pipe has no content.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe pipe has no content.%c", fll_error_print_error, f_string_eol[0]); } status = F_status_set_error(F_parameter); @@ -273,19 +272,20 @@ extern "C" { status = fl_string_dynamic_seek_line(buffer.string, &range); if (F_status_is_error(status)) { - iki_write_print_error(data->context, data->error.verbosity, F_status_set_fine(status), "fl_string_dynamic_seek_line", F_true); + fll_error_print(data->error, 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->error.verbosity, F_parameter, "fl_string_dynamic_seek_line", F_true); + + fll_error_print(data->error, F_parameter, "fl_string_dynamic_seek_line", F_true); break; } if (object_ended && previous == range.start) { if (data->error.verbosity != f_console_verbosity_quiet) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The pipe has incorrectly placed newlines.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe pipe has incorrectly placed newlines.%c", fll_error_print_error, f_string_eol[0]); } status = F_status_set_error(F_parameter); @@ -302,7 +302,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->error.verbosity, F_status_set_fine(status), "fl_string_dynamic_partial_append_nulless", F_true); + fll_error_print(data->error, F_status_set_fine(status), "fl_string_dynamic_partial_append_nulless", F_true); break; } } @@ -320,7 +320,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->error.verbosity, F_status_set_fine(status), "fl_string_dynamic_partial_append_nulless", F_true); + fll_error_print(data->error, F_status_set_fine(status), "fl_string_dynamic_partial_append_nulless", F_true); break; } @@ -342,7 +342,7 @@ extern "C" { if (F_status_is_fine(status) && object_ended) { if (data->error.verbosity != f_console_verbosity_quiet) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The pipe has an object without content.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe pipe has an object without content.%c", fll_error_print_error, f_string_eol[0]); } status = F_status_set_error(F_parameter); diff --git a/level_3/iki_write/c/private-iki_write.c b/level_3/iki_write/c/private-iki_write.c index e99d90f..6dcd094 100644 --- a/level_3/iki_write/c/private-iki_write.c +++ b/level_3/iki_write/c/private-iki_write.c @@ -5,275 +5,13 @@ extern "C" { #endif -#ifndef _di_iki_write_print_error_ - f_return_status iki_write_print_error(const f_color_context_t context, const uint8_t verbosity, const f_status_t status, const f_string_t function, const bool fallback) { - - if (status == F_parameter) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Invalid parameter when calling function "); - fl_color_print(data.error.to.stream, context.set.notable, "%s", function); - fl_color_print(data.error.to.stream, context.set.error, "().%c", f_string_eol[0]); - } - - return F_none; - } - - if (status == F_memory_allocation || status == F_memory_reallocation) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Unable to allocate memory in function "); - fl_color_print(data.error.to.stream, context.set.notable, "%s", function); - fl_color_print(data.error.to.stream, context.set.error, "().%c", f_string_eol[0]); - } - - return F_none; - } - - if (status == F_buffer_too_large) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Maximum buffer limit reached while processing "); - fl_color_print(data.error.to.stream, context.set.notable, "%s", function); - fl_color_print(data.error.to.stream, context.set.error, "().%c", f_string_eol[0]); - } - - return F_none; - } - - if (status == F_string_too_large) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Maximum string limit reached while processing "); - fl_color_print(data.error.to.stream, context.set.notable, "%s", function); - fl_color_print(data.error.to.stream, context.set.error, "().%c", f_string_eol[0]); - } - - return F_none; - } - - if (fallback && verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") in function "); - fl_color_print(data.error.to.stream, context.set.notable, "%s", function); - fl_color_print(data.error.to.stream, context.set.error, "().%c", f_string_eol[0]); - } - - return F_unknown; - } -#endif // _di_iki_write_print_error_ - -#ifndef _di_iki_write_print_error_file_ - bool iki_write_print_error_file(const f_color_context_t context, const uint8_t verbosity, const f_status_t status, const f_string_t function, const f_string_t name, const f_string_t operation, const uint8_t type, const bool fallback) { - f_string_t type_name = "file"; - - if (type == 1) { - type_name = "directory"; - } - else if (type == 2) { - type_name = "pipe"; - } - - if (status == F_file_found_not) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Failed to find %s '", type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_file_closed) { - if (verbosity != f_console_verbosity_quiet) { - fl_color_print(data.error.to.stream, context.set.error, "INTERNAL ERROR: The %s '", type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "' is no longer open.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_file_seek) { - if (verbosity != f_console_verbosity_quiet) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: A seek error occurred while accessing the file '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_file_read) { - if (verbosity != f_console_verbosity_quiet) { - fl_color_print(data.error.to.stream, context.set.error, "ERROR: A read error occurred while accessing the file '"); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_file_found) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: The %s '", type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "' already exists.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_parameter) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(data.error.to.stream, context.set.notable, "%s", function); - fl_color_print(data.error.to.stream, context.set.error, "() for the %s '", type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_name) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Invalid %s name '", type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_memory_out) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "CRITICAL ERROR: Unable to allocate memory, while trying to %s %s '", operation, type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_number_overflow) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Overflow while trying to %s %s '", operation, type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_directory) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Invalid directory while trying to %s %s '", operation, type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_access_denied) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Access denied while trying to %s %s '", operation, type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_loop) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Loop while trying to %s %s '", operation, type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_prohibited) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Prohibited by system while trying to %s %s '", operation, type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - - if (!type) { - if (status == F_directory_found_not) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Failed to %s %s '", operation, type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "' due to an invalid directory in the path.%c", f_string_eol[0]); - } - - return F_false; - } - } - else if (type == 1) { - if (status == F_directory_found_not) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Failed to %s %s '", operation, type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "' due to an invalid directory in the path.%c", f_string_eol[0]); - } - - return F_false; - } - - if (status == F_failure) { - if (verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "ERROR: Failed to %s %s '", operation, type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_false; - } - } - - if (iki_write_print_error(context, verbosity, status, function, F_false) == F_unknown && fallback && verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, context.set.error, "UNKNOWN ERROR: ("); - fl_color_print(data.error.to.stream, context.set.notable, "%llu", status); - fl_color_print(data.error.to.stream, context.set.error, ") occurred while trying to %s %s '", operation, type_name); - fl_color_print(data.error.to.stream, context.set.notable, "%s", name); - fl_color_print(data.error.to.stream, context.set.error, "'.%c", f_string_eol[0]); - } - - return F_true; - } -#endif // _di_iki_write_print_error_file_ - #ifndef _di_iki_write_process_ 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.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The object is missing, it must not have a length of "); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe object is missing, it must not have a length of ", fll_error_print_error); fl_color_print(data.error.to.stream, data.context.set.notable, "0"); fl_color_print(data.error.to.stream, data.context.set.error, ".%c", f_string_eol[0]); } @@ -286,7 +24,7 @@ extern "C" { if (status == F_false) { if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.error.to.stream, "%c", f_string_eol[0]); - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: The object '"); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe object '", fll_error_print_error); fl_color_print_code(f_type_error, data.context.notable); f_print_dynamic(f_type_error, object); @@ -298,8 +36,7 @@ extern "C" { return F_status_set_error(F_failure); } else if (F_status_is_error(status)) { - iki_write_print_error(data.context, data.error.verbosity, F_status_set_fine(status), "f_iki_object_is", F_true); - + fll_error_print(data.error, F_status_set_fine(status), "f_iki_object_is", F_true); return F_status_set_error(F_failure); } @@ -308,7 +45,7 @@ extern "C" { status = fll_iki_content_escape(content, quote, escaped); if (F_status_is_error(status)) { - iki_write_print_error(data.context, data.error.verbosity, F_status_set_fine(status), "fll_iki_content_escape", F_true); + fll_error_print(data.error, 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/c/private-iki_write.h b/level_3/iki_write/c/private-iki_write.h index 0f51e10..4adf626 100644 --- a/level_3/iki_write/c/private-iki_write.h +++ b/level_3/iki_write/c/private-iki_write.h @@ -13,56 +13,6 @@ extern "C" { #endif /** - * Print generic error messages. - * - * @param context - * The color context. - * @param verbosity - * The verbosity level, which determines if and what should be printed. - * @param status - * The status code representing an error. - * @param function - * The name of the function where the error happened. - * @param fallback - * Set to F_true to print the fallback error message for unknown errors. - * - * @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_iki_write_print_error_ - extern f_return_status iki_write_print_error(const f_color_context_t context, const uint8_t verbosity, const f_status_t status, const f_string_t function, const bool fallback) f_gcc_attribute_visibility_internal; -#endif // _di_iki_write_print_error_ - -/** - * Print file/directory error messages. - * - * @param context - * The color context. - * @param verbosity - * The verbosity level, which determines if and what should be printed. - * @param status - * The error status code to report on. - * @param function - * The function call that returned the error. - * @param name - * The name of the file or directory. - * @param operation - * The operation that fails, such as 'create' or 'access'. - * @param type - * Set to 0 for "file", 1 for "directory", and 2 for "pipe". - * @param fallback - * Set to F_true to print the fallback error message for unknown errors. - * - * @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_iki_write_print_error_file_ - extern bool iki_write_print_error_file(const f_color_context_t context, const uint8_t verbosity, const f_status_t status, const f_string_t function, const f_string_t name, const f_string_t operation, const uint8_t type, const bool fallback) f_gcc_attribute_visibility_internal; -#endif // _di_iki_write_print_error_file_ - -/** * Process a given object and content, printing the IKI if valid or an error if invalid. * * @param data diff --git a/level_3/init/c/init.c b/level_3/init/c/init.c index 9d5b074..0ecdf30 100644 --- a/level_3/init/c/init.c +++ b/level_3/init/c/init.c @@ -171,13 +171,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(data->error.to.stream, data->context.set.error, "ERROR: Failed to clone services process (errno = %i).%c", errno, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to clone services process (errno = %i).%c", fll_error_print_error, 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(data->error.to.stream, data->context.set.error, "ERROR: Failed to clone control via file process (errno = %i).%c", errno, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sFailed to clone control via file process (errno = %i).%c", fll_error_print_error, errno, f_string_eol[0]); } */ @@ -205,11 +205,11 @@ extern "C" { continue; } else if (errno != EINTR) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: sigwaitinfo() failed (errno = %i).%c", errno, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%ssigwaitinfo() failed (errno = %i).%c", fll_error_print_error, errno, f_string_eol[0]); signal_problem_count++; if (signal_problem_count > problem_count_max_signal_size) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: Max signal problem count has been reached, sleeping for a period of time.%c", errno, f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sMax signal problem count has been reached, sleeping for a period of time.%c", fll_error_print_error, errno, f_string_eol[0]); sleep(init_panic_signal_sleep_seconds); signal_problem_count = 0; } diff --git a/level_3/init/c/private-init.c b/level_3/init/c/private-init.c index d751ce0..750e946 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(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open().%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling f_file_open().%c", fll_error_print_error, f_string_eol[0]); } else if (status != F_file_found_not && status != F_file_open && status != F_file_descriptor) { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().%c", status, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_open().%c", fll_error_print_error, status, f_string_eol[0]); } } else { if (status == F_parameter) { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open().%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling f_file_open().%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_file_found_not) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Unable to find the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to find the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_file_open) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Unable to open the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to open the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_file_descriptor) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: File descriptor error while trying to open the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sFile descriptor error while trying to open the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().%c", status, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_open().%c", fll_error_print_error, status, f_string_eol[0]); } } @@ -49,19 +49,19 @@ status = F_status_set_fine(status); if (status == F_parameter) { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_read_until().%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling f_file_read_until().%c", fll_error_print_error, f_string_eol[0]); } else if (status == F_number_overflow) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: Integer overflow while trying to buffer the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInteger overflow while trying to buffer the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_file_closed) { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: The file '%s' is no longer open.%c", filename, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sThe file '%s' is no longer open.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_file_seek) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: A seek error occurred while accessing the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sA seek error occurred while accessing the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_file_read) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: A read error occurred while accessing the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sA read error occurred while accessing the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_read_until().%c", status, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling f_file_read_until().%c", fll_error_print_error, 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(data.error.to.stream, 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]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling fll_fss_basic_list_read() for the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_data_not_eos || status == F_data_not || status == F_data_not_stop) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: No relevant data was found within the file '%s'.%c", filename, f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sNo relevant data was found within the file '%s'.%c", fll_error_print_error, filename, f_string_eol[0]); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); } else { - fl_color_print(data.error.to.stream, 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]); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.%c", fll_error_print_error, 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(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.", fll_error_print_error); } else if (status == F_failure) { // the error message has already been displayed. } else { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling firewall_perform_commands().", fll_error_print_error, 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(data.error.to.stream, 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(data.error.to.stream, data.context.set.error, "%sInvalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", fll_error_print_error, init_rule_core_file); } else if (status == F_data_not_eos || status == F_data_not || status == F_data_not_stop) { - fl_color_print(data.error.to.stream, data.context.set.error, "ERROR: No relevant data was found within the file '%s'.", init_rule_core_file); + fl_color_print(data.error.to.stream, data.context.set.error, "%sNo relevant data was found within the file '%s'.", fll_error_print_error, init_rule_core_file); } else if (status == F_memory_allocation || status == F_memory_reallocation) { - fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.", fll_error_print_error); } else { - fl_color_print(data.error.to.stream, 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(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.", fll_error_print_error, 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(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.", fll_error_print_error); } else { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling init_load_main_rule().", status); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling init_load_main_rule().", fll_error_print_error, 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(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.", fll_error_print_error); } else if (status == F_failure) { // the error message has already been displayed. } else { - fl_color_print(data.error.to.stream, data.context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); + fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling firewall_perform_commands().", fll_error_print_error, 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(data.error.to.stream, context.set.error, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print(data.error.to.stream, context.set.error, "%sUnable to allocate memory.", fll_error_print_error); } else { - fl_color_print(data.error.to.stream, context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling init_load_main_rule().", status); + fl_color_print(data.error.to.stream, context.set.error, "%sAn unhandled error (%u) has occurred while calling init_load_main_rule().", fll_error_print_error, status); } } diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index 4e7a2fa..15006f9 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -7,6 +7,7 @@ extern "C" { #ifndef _di_status_code_print_help_ f_return_status status_code_print_help(const f_file_t file, const f_color_context_t context) { + fll_program_print_help_header(file, context, status_code_name_long, status_code_version); fll_program_print_help_option(file, 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."); @@ -100,7 +101,7 @@ 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_error); fl_color_print(data->error.to.stream, data->context.set.error, "' cannot be used with the parameter "); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_warning); @@ -110,7 +111,7 @@ extern "C" { return F_status_set_error(status); } else if (data->parameters[status_code_parameter_is_fine].result == f_console_result_found) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_error); fl_color_print(data->error.to.stream, data->context.set.error, "' cannot be used with the parameter "); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_fine); @@ -121,7 +122,7 @@ extern "C" { } } 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(data->error.to.stream, data->context.set.error, "ERROR: The parameter '"); + fl_color_print(data->error.to.stream, data->context.set.error, "%sThe parameter '", fll_error_print_error); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_warning); fl_color_print(data->error.to.stream, data->context.set.error, "' cannot be used with the parameter "); fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, status_code_long_is_fine); @@ -132,7 +133,7 @@ extern "C" { } if (data->remaining.used == 0 && !data->process_pipe) { - fl_color_print(data->error.to.stream, data->context.set.error, "ERROR: You failed to specify a status code.%c", f_string_eol[0]); + fl_color_print(data->error.to.stream, data->context.set.error, "%sYou failed to specify a status code.%c", fll_error_print_error, f_string_eol[0]); status_code_delete_data(data); return F_status_set_error(F_parameter); @@ -163,6 +164,7 @@ extern "C" { if (data->remaining.used > 0) { for (f_array_length_t i = 0; i < data->remaining.used; i++) { + status2 = status_code_process_number(*data, arguments.argv[data->remaining.array[i]]); if (F_status_is_error(status2) && status == F_none) { @@ -198,6 +200,7 @@ extern "C" { f_string_length_t i = 0; while (i < status_code_total_parameters) { + f_macro_string_lengths_t_delete_simple(data->parameters[i].locations); f_macro_string_lengths_t_delete_simple(data->parameters[i].additional); i++;