From: Kevin Day Date: Wed, 25 Aug 2021 04:30:30 +0000 (-0500) Subject: Progress: Continue string and convert changes. X-Git-Tag: 0.5.5~13 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=fc3eff9b0a2d55f19df92d3f84fa7f238b698603;p=fll Progress: Continue string and convert changes. Convert several FSS write functions. Add -O2 optimization by default. --- 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 802cba1..4e84259 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 @@ -636,9 +636,8 @@ extern "C" { else { range.stop = data->contents.array[at].array[0].stop; - //f_print_except_in_dynamic_partial(main->output.stream, data->buffer, range, delimits_content, data->comments); - //f_print_character(f_string_eol_s[0], main->output.stream); - fl_print_format("%/:;Q%c", main->output.stream, data->buffer, range, delimits_content, data->comments, f_string_eol_s[0]); + f_print_except_in_dynamic_partial(data->buffer, range, delimits_content, data->comments, main->output.stream); + f_print_character(f_string_eol_s[0], main->output.stream); } funlockfile(main->output.stream); 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 09b0e30..6702590 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 @@ -9,6 +9,8 @@ extern "C" { #ifndef _di_fss_basic_list_write_print_help_ f_status_t fss_basic_list_write_print_help(const f_file_t output, const f_color_context_t context) { + flockfile(output.stream); + fll_program_print_help_header(output, context, fss_basic_list_write_name_long, fss_basic_list_write_version); fll_program_print_help_option(output, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); @@ -21,7 +23,7 @@ extern "C" { fll_program_print_help_option(output, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, inceasing verbosity beyond normal output."); fll_program_print_help_option(output, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); - fprintf(output.stream, "%c", f_string_eol_s[0]); + f_print_character(f_string_eol_s[0], output.stream); fll_program_print_help_option(output, context, fss_basic_list_write_short_file, fss_basic_list_write_long_file, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send output to."); fll_program_print_help_option(output, context, fss_basic_list_write_short_content, fss_basic_list_write_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "The Content to output."); @@ -35,52 +37,20 @@ extern "C" { fll_program_print_help_usage(output, context, fss_basic_list_write_name, f_string_empty_s); - fprintf(output.stream, " The pipe uses the Backspace character '"); - f_color_print(output.stream, context.set.notable, "\\b"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+0008"); - fprintf(output.stream, ") to designate the start of a Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, " The pipe uses the Form Feed character '"); - f_color_print(output.stream, context.set.notable, "\\f"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000C"); - fprintf(output.stream, ") to designate the end of the last Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, " The pipe uses the Vertical Line character '"); - f_color_print(output.stream, context.set.notable, "\\v"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000B"); - fprintf(output.stream, ") is used to ignore a Content range, which does nothing in this program.%c", f_string_eol_s[0]); - - fprintf(output.stream, " For the pipe, an Object is terminated by either a Backspace character '"); - f_color_print(output.stream, context.set.notable, "\\b"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+0008"); - fprintf(output.stream, ") or a Form Feed character '"); - f_color_print(output.stream, context.set.notable, "\\f"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000C"); - fprintf(output.stream, ").%c", f_string_eol_s[0]); - - fprintf(output.stream, " The end of the pipe represents the end of any Object or Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); - - fprintf(output.stream, " The FSS-0002 (Basic List) specification does not support quoted names, therefore the parameters '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_single); - fprintf(output.stream, "' and '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_double); - fprintf(output.stream, "' do nothing.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); - - fprintf(output.stream, " This program does not use the parameter '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_ignore); - fprintf(output.stream, "', which therefore does nothing.%c", f_string_eol_s[0]); - fprintf(output.stream, " This parameter requires two values.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); + fl_print_format(" The pipe uses the Backspace character '%[\\b%]' (%[U+0008%]) to designate the start of a Content.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The pipe uses the Form Feed character '%[\\f%]' (%[U+000C%]) to designate the end of the last Content.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The pipe uses the Vertical Line character '%[\\v%]' (%[U+000B%]) is used to ignore a Content range, which does nothing in this program.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" For the pipe, an Object is terminated by either a Backspace character '%[\\b%]' (%[U+0008%])", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable); + fl_print_format(" or a Form Feed character '%[\\f%]' (%[U+000C%]).%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The end of the pipe represents the end of any Object or Content.%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); + + fl_print_format(" The FSS-0002 (Basic List) specification does not support quoted names, therefore the parameters '%[%s%s%]'", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_single, context.set.notable); + fl_print_format(" and '%[%s%s%]' do nothing.%c%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_double, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + + fl_print_format(" This program does not use the parameter '%[%s%s%]', which therefore does nothing.%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_ignore, context.set.notable, f_string_eol_s[0]); + fl_print_format(" This parameter requires two values.%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); + + funlockfile(output.stream); return F_none; } @@ -102,9 +72,12 @@ extern "C" { if (main->context.set.error.before) { main->error.context = main->context.set.error; main->error.notable = main->context.set.notable; + + main->warning.context = main->context.set.warning; + main->warning.notable = main->context.set.notable; } else { - f_color_set_t *sets[] = { &main->error.context, &main->error.notable, 0 }; + f_color_set_t *sets[] = { &main->error.context, &main->error.notable, &main->warning.context, &main->warning.notable, 0 }; fll_program_parameter_process_empty(&main->context, sets); } @@ -130,15 +103,19 @@ extern "C" { if (choice == fss_basic_list_write_parameter_verbosity_quiet) { main->error.verbosity = f_console_verbosity_quiet; + main->warning.verbosity = f_console_verbosity_quiet; } else if (choice == fss_basic_list_write_parameter_verbosity_normal) { main->error.verbosity = f_console_verbosity_normal; + main->warning.verbosity = f_console_verbosity_normal; } else if (choice == fss_basic_list_write_parameter_verbosity_verbose) { main->error.verbosity = f_console_verbosity_verbose; + main->warning.verbosity = f_console_verbosity_verbose; } else if (choice == fss_basic_list_write_parameter_verbosity_debug) { main->error.verbosity = f_console_verbosity_debug; + main->warning.verbosity = f_console_verbosity_debug; } } @@ -169,10 +146,13 @@ extern "C" { if (main->parameters[fss_basic_list_write_parameter_file].result == f_console_result_additional) { if (main->parameters[fss_basic_list_write_parameter_file].values.used > 1) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_file); - f_color_print(main->error.to.stream, main->context.set.error, "' may only be specified once.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_file, main->error.notable); + fl_print_format("%[' may only be specified once.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -213,14 +193,17 @@ extern "C" { else if (main->parameters[fss_basic_list_write_parameter_content].locations.used && main->parameters[fss_basic_list_write_parameter_partial].locations.used) { if (main->parameters[fss_basic_list_write_parameter_content].result == f_console_result_additional) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_partial); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter only allows either the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter or the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter, but not both.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_partial, main->error.notable); + fl_print_format("%[' parameter only allows either the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_object, main->error.notable); + fl_print_format("%[' parameter or the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_content, main->error.notable); + fl_print_format("%[' parameter, but not both.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -242,12 +225,15 @@ extern "C" { if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sEach ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter must be specified before a '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sEach '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_object, main->error.notable); + fl_print_format("%[' parameter must be specified before a '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_content, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -270,12 +256,15 @@ extern "C" { } else if (!main->process_pipe) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThis requires either piped main or the use of the '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThis requires either piped data or the use of the '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_object, main->error.notable); + fl_print_format("%[' parameter with the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_content, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -284,10 +273,13 @@ extern "C" { if (F_status_is_error_not(status) && main->process_pipe) { if (main->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_partial); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter cannot be used when processing a pipe.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThis '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_partial, main->error.notable); + fl_print_format("%[' parameter cannot be used when processing a pipe.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -298,10 +290,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_basic_list_write_parameter_prepend].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_prepend, main->error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -324,10 +319,13 @@ extern "C" { if (status == F_false) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe value for the parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' must only contain whitespace.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe value for the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_prepend, main->error.notable); + fl_print_format("%[' must only contain whitespace.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -337,10 +335,13 @@ extern "C" { } else { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe value for the parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' must not be an empty string.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe value for the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_prepend, main->error.notable); + fl_print_format("%[' must not be an empty string.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -351,10 +352,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_basic_list_write_parameter_ignore].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_ignore); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no values were given.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_ignore, main->error.notable); + fl_print_format("%[' was specified, but no values were given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -364,10 +368,13 @@ extern "C" { const f_array_length_t total_arguments = main->parameters[fss_basic_list_write_parameter_ignore].values.used; if (total_locations * 2 > total_arguments) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_ignore); - f_color_print(main->error.to.stream, main->context.set.error, "' requires two values.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_ignore, main->error.notable); + fl_print_format("%[' requires two values.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); } @@ -401,10 +408,12 @@ extern "C" { if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sWhile processing the ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "input pipe"); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sWhile processing the '%]%[input pipe%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } } } @@ -453,15 +462,18 @@ extern "C" { if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sWhile processing the ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "input arguments"); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sWhile processing the '%]%[input arguments%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } } else if (main->error.verbosity != f_console_verbosity_quiet && main->parameters[fss_basic_list_write_parameter_file].result == f_console_result_none) { + // ensure there is always a newline at the end, unless in quiet mode. - fprintf(main->output.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } } @@ -486,7 +498,7 @@ extern "C" { // ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->error.verbosity != f_console_verbosity_quiet) { if (F_status_is_error(status)) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } } diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.h b/level_3/fss_basic_list_write/c/fss_basic_list_write.h index 44f2eca..9b16929 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.h +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.h @@ -30,12 +30,14 @@ // fll-1 includes #include #include +#include #include #include // fll-2 includes #include #include +#include #include #ifdef __cplusplus @@ -144,6 +146,7 @@ extern "C" { f_file_t output; fll_error_print_t error; + fll_error_print_t warning; f_string_static_t prepend; f_color_context_t context; @@ -156,6 +159,7 @@ extern "C" { F_false, \ macro_f_file_t_initialize2(f_type_output, f_type_descriptor_output, f_file_flag_write_only), \ fll_error_print_t_initialize, \ + macro_fll_error_print_t_initialize_warning(), \ f_string_static_t_initialize, \ f_color_context_t_initialize, \ } diff --git a/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c b/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c index 14bd62f..81c8477 100644 --- a/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c @@ -13,14 +13,17 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sMust specify both the '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_object); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter and the '"); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_content); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter the same number of times when not specifying the "); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_list_write_long_partial); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sMust specify the '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_object, main.error.notable); + fl_print_format("%[' parameter and the '%]", main.error.to.stream, main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_content, main.error.notable); + fl_print_format("%[' parameter the same number of times when not specifying the '%]", main.error.to.stream, main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_partial, main.error.notable); + fl_print_format("%[' parameter.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_basic_list_write_error_parameter_same_times_print_ @@ -31,10 +34,13 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThis standard does not support end of line character '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "\\n"); - f_color_print(main.error.to.stream, main.context.set.error, "' in objects.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sThis standard does not support end of line character '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[\\n%]", main.error.to.stream, main.error.notable, main.error.notable); + fl_print_format("%[' in objects.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_basic_list_write_error_parameter_unsupported_eol_print_ @@ -45,10 +51,13 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", symbol, parameter); - f_color_print(main.error.to.stream, main.context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%S%S%]", main.error.to.stream, main.error.notable, symbol, parameter, main.error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_basic_list_write_error_parameter_value_missing_print_ @@ -118,7 +127,7 @@ extern "C" { } } - f_print_dynamic(output.stream, *buffer); + fll_print_dynamic(*buffer, output.stream); buffer->used = 0; return status; @@ -239,8 +248,7 @@ extern "C" { if (block.string[range.start] == fss_basic_list_write_pipe_content_start) { if (main.error.verbosity != f_console_verbosity_quiet) { - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThis standard only supports one content per object.%c", fll_error_print_error, f_string_eol_s[0]); + fll_print_format("%c%[%sThis standard only supports one content per object.%]%c", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context, f_string_eol_s[0]); } status = F_status_set_error(F_supported_not); diff --git a/level_3/fss_basic_list_write/data/build/dependencies b/level_3/fss_basic_list_write/data/build/dependencies index 00b2c3d..7c8767f 100644 --- a/level_3/fss_basic_list_write/data/build/dependencies +++ b/level_3/fss_basic_list_write/data/build/dependencies @@ -17,8 +17,11 @@ f_print fl_console fl_conversion fl_fss +fl_print fl_status +fl_string fll_error fll_file fll_fss +fll_print fll_program diff --git a/level_3/fss_basic_list_write/data/build/settings b/level_3/fss_basic_list_write/data/build/settings index 356c56f..fc204f9 100644 --- a/level_3/fss_basic_list_write/data/build/settings +++ b/level_3/fss_basic_list_write/data/build/settings @@ -20,7 +20,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_program -lfl_console -lfl_conversion -lfl_directory -lfl_fss -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_console -lfl_conversion -lfl_directory -lfl_fss -lfl_print -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_basic_list_write.c private-common.c private-fss_basic_list_write.c @@ -51,7 +51,7 @@ defines_all defines_static defines_shared -flags_all -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses +flags_all -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses flags_shared flags_static flags_library -fPIC 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 38f5476..03c089b 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -9,6 +9,8 @@ extern "C" { #ifndef _di_fss_basic_write_print_help_ f_status_t fss_basic_write_print_help(const f_file_t output, const f_color_context_t context) { + flockfile(output.stream); + fll_program_print_help_header(output, context, fss_basic_write_name_long, fss_basic_write_version); fll_program_print_help_option(output, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); @@ -21,7 +23,7 @@ extern "C" { fll_program_print_help_option(output, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, inceasing verbosity beyond normal output."); fll_program_print_help_option(output, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); - fprintf(output.stream, "%c", f_string_eol_s[0]); + f_print_character(f_string_eol_s[0], output.stream); fll_program_print_help_option(output, context, fss_basic_write_short_file, fss_basic_write_long_file, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send output to."); fll_program_print_help_option(output, context, fss_basic_write_short_content, fss_basic_write_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "The Content to output."); @@ -35,50 +37,20 @@ extern "C" { fll_program_print_help_usage(output, context, fss_basic_write_name, f_string_empty_s); - fprintf(output.stream, " The pipe uses the Backspace character '"); - f_color_print(output.stream, context.set.notable, "\\b"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+0008"); - fprintf(output.stream, ") to designate the start of a Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, " The pipe uses the Form Feed character '"); - f_color_print(output.stream, context.set.notable, "\\f"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000C"); - fprintf(output.stream, ") to designate the end of the last Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, " The pipe uses the Vertical Line character '"); - f_color_print(output.stream, context.set.notable, "\\v"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000B"); - fprintf(output.stream, ") is used to ignore a Content range, which does nothing in this program.%c", f_string_eol_s[0]); - - fprintf(output.stream, " For the pipe, an Object is terminated by either a Backspace character '"); - f_color_print(output.stream, context.set.notable, "\\b"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+0008"); - fprintf(output.stream, ") or a Form Feed character '"); - f_color_print(output.stream, context.set.notable, "\\f"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000C"); - fprintf(output.stream, ").%c", f_string_eol_s[0]); - - fprintf(output.stream, " The end of the pipe represents the end of any Object or Content.%c", f_string_eol_s[0]); + fl_print_format(" The pipe uses the Backspace character '%[\\b%]' (%[U+0008%]) to designate the start of a Content.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The pipe uses the Form Feed character '%[\\f%]' (%[U+000C%]) to designate the end of the last Content.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The pipe uses the Vertical Line character '%[\\v%]' (%[U+000B%]) is used to ignore a Content range, which does nothing in this program.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" For the pipe, an Object is terminated by either a Backspace character '%[\\b%]' (%[U+0008%])", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable); + fl_print_format(" or a Form Feed character '%[\\f%]' (%[U+000C%]).%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The end of the pipe represents the end of any Object or Content.%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); - fprintf(output.stream, "%c", f_string_eol_s[0]); + fl_print_format(" The FSS-0000 (Basic) specification does not support multi-line Content, therefore the parameter '%[%s%s%]'", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_extended_write_long_prepend, context.set.notable); + fl_print_format(" does nothing.%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); - fprintf(output.stream, " The FSS-0000 (Basic) specification does not support multi-line Content, therefore the parameter '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_prepend); - fprintf(output.stream, "' does nothing.%c", f_string_eol_s[0]); + fl_print_format(" This program does not use the parameter '%[%s%s%]', which therefore does nothing.%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_basic_write_long_ignore, context.set.notable, f_string_eol_s[0]); + fl_print_format(" This parameter requires two values.%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); - fprintf(output.stream, "%c", f_string_eol_s[0]); - - fprintf(output.stream, " This program does not use the parameter '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_ignore); - fprintf(output.stream, "', which therefore does nothing.%c", f_string_eol_s[0]); - fprintf(output.stream, " This parameter requires two values.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); + funlockfile(output.stream); return F_none; } @@ -100,9 +72,12 @@ extern "C" { if (main->context.set.error.before) { main->error.context = main->context.set.error; main->error.notable = main->context.set.notable; + + main->warning.context = main->context.set.warning; + main->warning.notable = main->context.set.notable; } else { - f_color_set_t *sets[] = { &main->error.context, &main->error.notable, 0 }; + f_color_set_t *sets[] = { &main->error.context, &main->error.notable, &main->warning.context, &main->warning.notable, 0 }; fll_program_parameter_process_empty(&main->context, sets); } @@ -128,15 +103,19 @@ extern "C" { if (choice == fss_basic_write_parameter_verbosity_quiet) { main->error.verbosity = f_console_verbosity_quiet; + main->warning.verbosity = f_console_verbosity_quiet; } else if (choice == fss_basic_write_parameter_verbosity_normal) { main->error.verbosity = f_console_verbosity_normal; + main->warning.verbosity = f_console_verbosity_normal; } else if (choice == fss_basic_write_parameter_verbosity_verbose) { main->error.verbosity = f_console_verbosity_verbose; + main->warning.verbosity = f_console_verbosity_verbose; } else if (choice == fss_basic_write_parameter_verbosity_debug) { main->error.verbosity = f_console_verbosity_debug; + main->warning.verbosity = f_console_verbosity_debug; } } @@ -167,10 +146,13 @@ extern "C" { if (main->parameters[fss_basic_write_parameter_file].result == f_console_result_additional) { if (main->parameters[fss_basic_write_parameter_file].values.used > 1) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_file); - f_color_print(main->error.to.stream, main->context.set.error, "' may only be specified once.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_file, main->error.notable); + fl_print_format("%[' may only be specified once.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -211,14 +193,17 @@ extern "C" { else if (main->parameters[fss_basic_write_parameter_content].locations.used && main->parameters[fss_basic_write_parameter_partial].locations.used) { if (main->parameters[fss_basic_write_parameter_content].result == f_console_result_additional) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_partial); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter only allows either the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter or the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter, but not both.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_partial, main->error.notable); + fl_print_format("%[' parameter only allows either the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_object, main->error.notable); + fl_print_format("%[' parameter or the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_content, main->error.notable); + fl_print_format("%[' parameter, but not both.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -240,12 +225,15 @@ extern "C" { if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sEach ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter must be specified before a '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sEach '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_object, main->error.notable); + fl_print_format("%[' parameter must be specified before a '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_content, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -268,12 +256,15 @@ extern "C" { } else if (!main->process_pipe) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThis requires either piped main or the use of the '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThis requires either piped data or the use of the '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_object, main->error.notable); + fl_print_format("%[' parameter with the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_content, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -282,10 +273,13 @@ extern "C" { if (F_status_is_error_not(status) && main->process_pipe) { if (main->parameters[fss_basic_write_parameter_partial].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_partial); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter cannot be used when processing a pipe.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThis '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_partial, main->error.notable); + fl_print_format("%[' parameter cannot be used when processing a pipe.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -296,10 +290,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_basic_write_parameter_prepend].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_prepend, main->error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -320,10 +317,13 @@ extern "C" { if (status == F_false) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe value for the parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' must only contain whitespace.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe value for the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_prepend, main->error.notable); + fl_print_format("%[' must only contain whitespace.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -333,10 +333,13 @@ extern "C" { } else { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe value for the parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' must not be an empty string.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe value for the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_prepend, main->error.notable); + fl_print_format("%[' must not be an empty string.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -347,10 +350,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_basic_write_parameter_ignore].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_ignore); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no values were given.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_ignore, main->error.notable); + fl_print_format("%[' was specified, but no values were given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -360,10 +366,13 @@ extern "C" { const f_array_length_t total_arguments = main->parameters[fss_basic_write_parameter_ignore].values.used; if (total_locations * 2 > total_arguments) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_ignore); - f_color_print(main->error.to.stream, main->context.set.error, "' requires two values.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_ignore, main->error.notable); + fl_print_format("%[' requires two values.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); } @@ -397,10 +406,12 @@ extern "C" { if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sWhile processing the ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "input pipe"); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sWhile processing the '%]%[input pipe%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } } } @@ -452,15 +463,18 @@ extern "C" { if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sWhile processing the ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "input arguments"); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sWhile processing the '%]%[input arguments%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } } else if (main->error.verbosity != f_console_verbosity_quiet && main->parameters[fss_basic_write_parameter_file].result == f_console_result_none) { + // ensure there is always a newline at the end, unless in quiet mode. - fprintf(main->output.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } } @@ -485,7 +499,7 @@ extern "C" { // ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->error.verbosity != f_console_verbosity_quiet) { if (F_status_is_error(status)) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } } diff --git a/level_3/fss_basic_write/c/fss_basic_write.h b/level_3/fss_basic_write/c/fss_basic_write.h index 99198a0..f526aeb 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.h +++ b/level_3/fss_basic_write/c/fss_basic_write.h @@ -30,6 +30,7 @@ // fll-1 includes #include #include +#include #include #include @@ -37,6 +38,7 @@ #include #include #include +#include #include #ifdef __cplusplus @@ -145,6 +147,7 @@ extern "C" { f_file_t output; fll_error_print_t error; + fll_error_print_t warning; f_color_context_t context; } fss_basic_write_main_t; @@ -156,6 +159,7 @@ extern "C" { F_false, \ macro_f_file_t_initialize2(f_type_output, f_type_descriptor_output, f_file_flag_write_only), \ fll_error_print_t_initialize, \ + macro_fll_error_print_t_initialize_warning(), \ f_color_context_t_initialize, \ } #endif // _di_fss_basic_write_data_ diff --git a/level_3/fss_basic_write/c/private-fss_basic_write.c b/level_3/fss_basic_write/c/private-fss_basic_write.c index c5f0b4c..64636af 100644 --- a/level_3/fss_basic_write/c/private-fss_basic_write.c +++ b/level_3/fss_basic_write/c/private-fss_basic_write.c @@ -13,14 +13,17 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sMust specify both the '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_object); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter and the '"); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_content); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter the same number of times when not specifying the "); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_write_long_partial); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sMust specify the '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_object, main.error.notable); + fl_print_format("%[' parameter and the '%]", main.error.to.stream, main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_content, main.error.notable); + fl_print_format("%[' parameter the same number of times when not specifying the '%]", main.error.to.stream, main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_partial, main.error.notable); + fl_print_format("%[' parameter.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_basic_write_error_parameter_same_times_print_ @@ -31,10 +34,13 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", symbol, parameter); - f_color_print(main.error.to.stream, main.context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%S%S%]", main.error.to.stream, main.error.notable, symbol, parameter, main.error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_basic_write_error_parameter_value_missing_print_ @@ -45,10 +51,13 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThis standard does not support end of line character '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "\\n"); - f_color_print(main.error.to.stream, main.context.set.error, "'.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sThis standard does not support end of line character '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[\\n%]", main.error.to.stream, main.error.notable, main.error.notable); + fl_print_format("%[' in objects.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_basic_write_error_parameter_unsupported_eol_print_ @@ -130,7 +139,7 @@ extern "C" { } } - f_print_dynamic(output.stream, *buffer); + fll_print_dynamic(*buffer, output.stream); buffer->used = 0; return status; @@ -251,8 +260,7 @@ extern "C" { if (block.string[range.start] == fss_basic_write_pipe_content_start) { if (main.error.verbosity != f_console_verbosity_quiet) { - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThis standard only supports one content per object.%c", fll_error_print_error, f_string_eol_s[0]); + fll_print_format("%c%[%sThis standard only supports one content per object.%]%c", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context, f_string_eol_s[0]); } status = F_status_set_error(F_supported_not); diff --git a/level_3/fss_basic_write/data/build/dependencies b/level_3/fss_basic_write/data/build/dependencies index 00b2c3d..7c8767f 100644 --- a/level_3/fss_basic_write/data/build/dependencies +++ b/level_3/fss_basic_write/data/build/dependencies @@ -17,8 +17,11 @@ f_print fl_console fl_conversion fl_fss +fl_print fl_status +fl_string fll_error fll_file fll_fss +fll_print fll_program diff --git a/level_3/fss_basic_write/data/build/settings b/level_3/fss_basic_write/data/build/settings index f9e51e1..a9feb7b 100644 --- a/level_3/fss_basic_write/data/build/settings +++ b/level_3/fss_basic_write/data/build/settings @@ -20,7 +20,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_program -lfl_console -lfl_conversion -lfl_directory -lfl_fss -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_console -lfl_conversion -lfl_directory -lfl_fss -lfl_print -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_basic_write.c private-common.c private-fss_basic_write.c @@ -51,7 +51,7 @@ defines_all defines_static defines_shared -flags_all -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses +flags_all -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses flags_shared flags_static flags_library -fPIC diff --git a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c index 64adc71..cd89afa 100644 --- a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c +++ b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c @@ -9,6 +9,8 @@ extern "C" { #ifndef _di_fss_embedded_list_write_print_help_ f_status_t fss_embedded_list_write_print_help(const f_file_t output, const f_color_context_t context) { + flockfile(output.stream); + fll_program_print_help_header(output, context, fss_embedded_list_write_name_long, fss_embedded_list_write_version); fll_program_print_help_option(output, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); @@ -21,7 +23,7 @@ extern "C" { fll_program_print_help_option(output, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, inceasing verbosity beyond normal output."); fll_program_print_help_option(output, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); - fprintf(output.stream, "%c", f_string_eol_s[0]); + f_print_character(f_string_eol_s[0], output.stream); fll_program_print_help_option(output, context, fss_embedded_list_write_short_file, fss_embedded_list_write_long_file, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send output to."); fll_program_print_help_option(output, context, fss_embedded_list_write_short_content, fss_embedded_list_write_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "The Content to output."); @@ -35,58 +37,23 @@ extern "C" { fll_program_print_help_usage(output, context, fss_embedded_list_write_name, f_string_empty_s); - fprintf(output.stream, " The pipe uses the Backspace character '"); - f_color_print(output.stream, context.set.notable, "\\b"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+0008"); - fprintf(output.stream, ") to designate the start of a Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, " The pipe uses the Form Feed character '"); - f_color_print(output.stream, context.set.notable, "\\f"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000C"); - fprintf(output.stream, ") to designate the end of the last Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, " The pipe uses the Vertical Line character '"); - f_color_print(output.stream, context.set.notable, "\\v"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000B"); - fprintf(output.stream, ") is used to ignore a Content range (use this both before and after the range).%c", f_string_eol_s[0]); - - fprintf(output.stream, " For the pipe, an Object is terminated by either a Backspace character '"); - f_color_print(output.stream, context.set.notable, "\\b"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+0008"); - fprintf(output.stream, ") or a Form Feed character '"); - f_color_print(output.stream, context.set.notable, "\\f"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000C"); - fprintf(output.stream, ").%c", f_string_eol_s[0]); - - fprintf(output.stream, " The end of the pipe represents the end of any Object or Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); - - fprintf(output.stream, " The FSS-0008 (Embedded List) specification does not support quoted names, therefore the parameters '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_single); - fprintf(output.stream, "' and '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_double); - fprintf(output.stream, "' do nothing.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); - - fprintf(output.stream, " The parameter '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_ignore); - fprintf(output.stream, "' designates to not escape any valid nested Object or Content within some Content.%c", f_string_eol_s[0]); - fprintf(output.stream, " This parameter requires two values.%c", f_string_eol_s[0]); - fprintf(output.stream, " This parameter is not used for ignoring anything from the input pipe.%c", f_string_eol_s[0]); - fprintf(output.stream, " This parameter must be specified after a '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_content); - fprintf(output.stream, "' parameter and this applies only to the Content represented by that specific '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_content); - fprintf(output.stream, "' parameter.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); + fl_print_format(" The pipe uses the Backspace character '%[\\b%]' (%[U+0008%]) to designate the start of a Content.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The pipe uses the Form Feed character '%[\\f%]' (%[U+000C%]) to designate the end of the last Content.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The pipe uses the Vertical Line character '%[\\v%]' (%[U+000B%]) is used to ignore a Content range (use this both before and after the range).%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" For the pipe, an Object is terminated by either a Backspace character '%[\\b%]' (%[U+0008%])", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable); + fl_print_format(" or a Form Feed character '%[\\f%]' (%[U+000C%]).%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The end of the pipe represents the end of any Object or Content.%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); + + fl_print_format(" The FSS-0008 (Embedded List) specification does not support quoted names, therefore the parameters '%[%s%s%]'", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_single, context.set.notable); + fl_print_format(" and '%[%s%s%]' do nothing.%c%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_double, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + + fl_print_format(" The parameter '%[%s%s%]' designates to not escape any valid nested Object or Content within some Content.%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_ignore, context.set.notable, f_string_eol_s[0]); + fl_print_format(" This parameter requires two values.%c", output.stream, f_string_eol_s[0]); + fl_print_format(" This parameter is not used for ignoring anything from the input pipe.%c", output.stream, f_string_eol_s[0]); + fl_print_format(" This parameter must be specified after a '%[%s%s%]'", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_content, context.set.notable); + fl_print_format(" parameter and this applies only to the Content represented by that specific '%[%s%s%]' parameter.%c%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_content, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + + funlockfile(output.stream); return F_none; } @@ -108,9 +75,12 @@ extern "C" { if (main->context.set.error.before) { main->error.context = main->context.set.error; main->error.notable = main->context.set.notable; + + main->warning.context = main->context.set.warning; + main->warning.notable = main->context.set.notable; } else { - f_color_set_t *sets[] = { &main->error.context, &main->error.notable, 0 }; + f_color_set_t *sets[] = { &main->error.context, &main->error.notable, &main->warning.context, &main->warning.notable, 0 }; fll_program_parameter_process_empty(&main->context, sets); } @@ -136,15 +106,19 @@ extern "C" { if (choice == fss_embedded_list_write_parameter_verbosity_quiet) { main->error.verbosity = f_console_verbosity_quiet; + main->warning.verbosity = f_console_verbosity_quiet; } else if (choice == fss_embedded_list_write_parameter_verbosity_normal) { main->error.verbosity = f_console_verbosity_normal; + main->warning.verbosity = f_console_verbosity_normal; } else if (choice == fss_embedded_list_write_parameter_verbosity_verbose) { main->error.verbosity = f_console_verbosity_verbose; + main->warning.verbosity = f_console_verbosity_verbose; } else if (choice == fss_embedded_list_write_parameter_verbosity_debug) { main->error.verbosity = f_console_verbosity_debug; + main->warning.verbosity = f_console_verbosity_debug; } } @@ -175,10 +149,13 @@ extern "C" { if (main->parameters[fss_embedded_list_write_parameter_file].result == f_console_result_additional) { if (main->parameters[fss_embedded_list_write_parameter_file].values.used > 1) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_file); - f_color_print(main->error.to.stream, main->context.set.error, "' may only be specified once.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_file, main->error.notable); + fl_print_format("%[' may only be specified once.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -219,14 +196,17 @@ extern "C" { else if (main->parameters[fss_embedded_list_write_parameter_content].locations.used && main->parameters[fss_embedded_list_write_parameter_partial].locations.used) { if (main->parameters[fss_embedded_list_write_parameter_content].result == f_console_result_additional) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_partial); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter only allows either the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter or the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter, but not both.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_partial, main->error.notable); + fl_print_format("%[' parameter only allows either the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_object, main->error.notable); + fl_print_format("%[' parameter or the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_content, main->error.notable); + fl_print_format("%[' parameter, but not both.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -248,12 +228,15 @@ extern "C" { if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sEach ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter must be specified before a '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sEach '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_object, main->error.notable); + fl_print_format("%[' parameter must be specified before a '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_content, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -276,12 +259,15 @@ extern "C" { } else if (!main->process_pipe) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThis requires either piped main or the use of the '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThis requires either piped data or the use of the '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_object, main->error.notable); + fl_print_format("%[' parameter with the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_content, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -290,10 +276,13 @@ extern "C" { if (F_status_is_error_not(status) && main->process_pipe) { if (main->parameters[fss_embedded_list_write_parameter_partial].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_partial); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter cannot be used when processing a pipe.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThis '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_partial, main->error.notable); + fl_print_format("%[' parameter cannot be used when processing a pipe.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -304,10 +293,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_embedded_list_write_parameter_prepend].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_prepend, main->error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -330,10 +322,13 @@ extern "C" { if (status == F_false) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe value for the parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' must only contain whitespace.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe value for the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_prepend, main->error.notable); + fl_print_format("%[' must only contain whitespace.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -343,10 +338,13 @@ extern "C" { } else { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe value for the parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' must not be an empty string.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe value for the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_prepend, main->error.notable); + fl_print_format("%[' must not be an empty string.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -357,10 +355,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_embedded_list_write_parameter_ignore].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_ignore); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no values were given.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_ignore, main->error.notable); + fl_print_format("%[' was specified, but no values were given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -370,10 +371,13 @@ extern "C" { const f_array_length_t total_arguments = main->parameters[fss_embedded_list_write_parameter_ignore].values.used; if (total_locations * 2 > total_arguments) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_ignore); - f_color_print(main->error.to.stream, main->context.set.error, "' requires two values.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_ignore, main->error.notable); + fl_print_format("%[' requires two values.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); } @@ -408,10 +412,12 @@ extern "C" { if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sWhile processing the ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "input pipe"); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sWhile processing the '%]%[input pipe%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } } @@ -468,16 +474,18 @@ extern "C" { if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sWhile processing the ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "input arguments"); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sWhile processing the '%]%[input arguments%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } } else if (main->error.verbosity != f_console_verbosity_quiet && main->parameters[fss_embedded_list_write_parameter_file].result == f_console_result_none) { // ensure there is always a newline at the end, unless in quiet mode. - fprintf(main->output.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } } @@ -503,7 +511,7 @@ extern "C" { // ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->error.verbosity != f_console_verbosity_quiet) { if (F_status_is_error(status)) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } } diff --git a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.h b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.h index 6160031..dee8a9e 100644 --- a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.h +++ b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.h @@ -31,12 +31,14 @@ #include #include #include +#include #include #include // fll-2 includes #include #include +#include #include #ifdef __cplusplus @@ -145,6 +147,7 @@ extern "C" { f_file_t output; fll_error_print_t error; + fll_error_print_t warning; f_string_static_t prepend; f_color_context_t context; @@ -157,6 +160,7 @@ extern "C" { F_false, \ macro_f_file_t_initialize2(f_type_output, f_type_descriptor_output, f_file_flag_write_only), \ fll_error_print_t_initialize, \ + macro_fll_error_print_t_initialize_warning(), \ f_string_static_t_initialize, \ f_color_context_t_initialize, \ } diff --git a/level_3/fss_embedded_list_write/c/private-fss_embedded_list_write.c b/level_3/fss_embedded_list_write/c/private-fss_embedded_list_write.c index 0e0bc8e..bf0975e 100644 --- a/level_3/fss_embedded_list_write/c/private-fss_embedded_list_write.c +++ b/level_3/fss_embedded_list_write/c/private-fss_embedded_list_write.c @@ -13,14 +13,17 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sMust specify both the '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_object); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter and the '"); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_content); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter the same number of times when not specifying the "); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_write_long_partial); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sMust specify the '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_object, main.error.notable); + fl_print_format("%[' parameter and the '%]", main.error.to.stream, main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_content, main.error.notable); + fl_print_format("%[' parameter the same number of times when not specifying the '%]", main.error.to.stream, main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_partial, main.error.notable); + fl_print_format("%[' parameter.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_embedded_list_write_error_parameter_same_times_print_ @@ -31,10 +34,13 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThis standard does not support end of line character '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "\\n"); - f_color_print(main.error.to.stream, main.context.set.error, "' in objects.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sThis standard does not support end of line character '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[\\n%]", main.error.to.stream, main.error.notable, main.error.notable); + fl_print_format("%[' in objects.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_embedded_list_write_error_parameter_unsupported_eol_print_ @@ -45,10 +51,13 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", symbol, parameter); - f_color_print(main.error.to.stream, main.context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%S%S%]", main.error.to.stream, main.error.notable, symbol, parameter, main.error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_embedded_list_write_error_parameter_value_missing_print_ @@ -118,7 +127,7 @@ extern "C" { } } - f_print_dynamic(output.stream, *buffer); + fll_print_dynamic(*buffer, output.stream); buffer->used = 0; return status; @@ -244,8 +253,7 @@ extern "C" { if (block.string[range.start] == fss_embedded_list_write_pipe_content_start) { if (main.error.verbosity != f_console_verbosity_quiet) { - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThis standard only supports one content per object.%c", fll_error_print_error, f_string_eol_s[0]); + fll_print_format("%c%[%sThis standard only supports one content per object.%]%c", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context, f_string_eol_s[0]); } status = F_status_set_error(F_supported_not); diff --git a/level_3/fss_embedded_list_write/data/build/dependencies b/level_3/fss_embedded_list_write/data/build/dependencies index 00b2c3d..7c8767f 100644 --- a/level_3/fss_embedded_list_write/data/build/dependencies +++ b/level_3/fss_embedded_list_write/data/build/dependencies @@ -17,8 +17,11 @@ f_print fl_console fl_conversion fl_fss +fl_print fl_status +fl_string fll_error fll_file fll_fss +fll_print fll_program diff --git a/level_3/fss_embedded_list_write/data/build/settings b/level_3/fss_embedded_list_write/data/build/settings index cb3eeac..3efcee9 100644 --- a/level_3/fss_embedded_list_write/data/build/settings +++ b/level_3/fss_embedded_list_write/data/build/settings @@ -20,7 +20,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_program -lfl_console -lfl_conversion -lfl_directory -lfl_fss -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_console -lfl_conversion -lfl_directory -lfl_fss -lfl_print -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_embedded_list_write.c private-common.c private-fss_embedded_list_write.c @@ -51,7 +51,7 @@ defines_all defines_static defines_shared -flags_all -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses +flags_all -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses flags_shared flags_static flags_library -fPIC diff --git a/level_3/fss_extended_list_write/c/fss_extended_list_write.c b/level_3/fss_extended_list_write/c/fss_extended_list_write.c index 2793423..03877f7 100644 --- a/level_3/fss_extended_list_write/c/fss_extended_list_write.c +++ b/level_3/fss_extended_list_write/c/fss_extended_list_write.c @@ -9,6 +9,8 @@ extern "C" { #ifndef _di_fss_extended_list_write_print_help_ f_status_t fss_extended_list_write_print_help(const f_file_t output, const f_color_context_t context) { + flockfile(output.stream); + fll_program_print_help_header(output, context, fss_extended_list_write_name_long, fss_extended_list_write_version); fll_program_print_help_option(output, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); @@ -21,7 +23,7 @@ extern "C" { fll_program_print_help_option(output, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, inceasing verbosity beyond normal output."); fll_program_print_help_option(output, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); - fprintf(output.stream, "%c", f_string_eol_s[0]); + f_print_character(f_string_eol_s[0], output.stream); fll_program_print_help_option(output, context, fss_extended_list_write_short_file, fss_extended_list_write_long_file, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send output to."); fll_program_print_help_option(output, context, fss_extended_list_write_short_content, fss_extended_list_write_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "The Content to output."); @@ -35,58 +37,23 @@ extern "C" { fll_program_print_help_usage(output, context, fss_extended_list_write_name, f_string_empty_s); - fprintf(output.stream, " The pipe uses the Backspace character '"); - f_color_print(output.stream, context.set.notable, "\\b"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+0008"); - fprintf(output.stream, ") to designate the start of a Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, " The pipe uses the Form Feed character '"); - f_color_print(output.stream, context.set.notable, "\\f"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000C"); - fprintf(output.stream, ") to designate the end of the last Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, " The pipe uses the Vertical Line character '"); - f_color_print(output.stream, context.set.notable, "\\v"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000B"); - fprintf(output.stream, ") is used to ignore a Content range (use this both before and after the range).%c", f_string_eol_s[0]); - - fprintf(output.stream, " For the pipe, an Object is terminated by either a Backspace character '"); - f_color_print(output.stream, context.set.notable, "\\b"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+0008"); - fprintf(output.stream, ") or a Form Feed character '"); - f_color_print(output.stream, context.set.notable, "\\f"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000C"); - fprintf(output.stream, ").%c", f_string_eol_s[0]); - - fprintf(output.stream, " The end of the pipe represents the end of any Object or Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); - - fprintf(output.stream, " The FSS-0003 (Extended List) specification does not support quoted names, therefore the parameters '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_single); - fprintf(output.stream, "' and '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_double); - fprintf(output.stream, "' do nothing.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); - - fprintf(output.stream, " The parameter '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_ignore); - fprintf(output.stream, "' designates to not escape any valid nested Object or Content within some Content.%c", f_string_eol_s[0]); - fprintf(output.stream, " This parameter requires two values.%c", f_string_eol_s[0]); - fprintf(output.stream, " This parameter is not used for ignoring anything from the input pipe.%c", f_string_eol_s[0]); - fprintf(output.stream, " This parameter must be specified after a '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_content); - fprintf(output.stream, "' parameter and this applies only to the Content represented by that specific '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_content); - fprintf(output.stream, "' parameter.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); + fl_print_format(" The pipe uses the Backspace character '%[\\b%]' (%[U+0008%]) to designate the start of a Content.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The pipe uses the Form Feed character '%[\\f%]' (%[U+000C%]) to designate the end of the last Content.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The pipe uses the Vertical Line character '%[\\v%]' (%[U+000B%]) is used to ignore a Content range (use this both before and after the range).%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" For the pipe, an Object is terminated by either a Backspace character '%[\\b%]' (%[U+0008%])", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable); + fl_print_format(" or a Form Feed character '%[\\f%]' (%[U+000C%]).%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The end of the pipe represents the end of any Object or Content.%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); + + fl_print_format(" The FSS-0003 (Extended List) specification does not support quoted names, therefore the parameters '%[%s%s%]'", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_single, context.set.notable); + fl_print_format(" and '%[%s%s%]' do nothing.%c%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_double, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + + fl_print_format(" The parameter '%[%s%s%]' designates to not escape any valid nested Object or Content within some Content.%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_ignore, context.set.notable, f_string_eol_s[0]); + fl_print_format(" This parameter requires two values.%c", output.stream, f_string_eol_s[0]); + fl_print_format(" This parameter is not used for ignoring anything from the input pipe.%c", output.stream, f_string_eol_s[0]); + fl_print_format(" This parameter must be specified after a '%[%s%s%]'", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_content, context.set.notable); + fl_print_format(" parameter and this applies only to the Content represented by that specific '%[%s%s%]' parameter.%c%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_content, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + + funlockfile(output.stream); return F_none; } @@ -108,9 +75,12 @@ extern "C" { if (main->context.set.error.before) { main->error.context = main->context.set.error; main->error.notable = main->context.set.notable; + + main->warning.context = main->context.set.warning; + main->warning.notable = main->context.set.notable; } else { - f_color_set_t *sets[] = { &main->error.context, &main->error.notable, 0 }; + f_color_set_t *sets[] = { &main->error.context, &main->error.notable, &main->warning.context, &main->warning.notable, 0 }; fll_program_parameter_process_empty(&main->context, sets); } @@ -136,15 +106,19 @@ extern "C" { if (choice == fss_extended_list_write_parameter_verbosity_quiet) { main->error.verbosity = f_console_verbosity_quiet; + main->warning.verbosity = f_console_verbosity_quiet; } else if (choice == fss_extended_list_write_parameter_verbosity_normal) { main->error.verbosity = f_console_verbosity_normal; + main->warning.verbosity = f_console_verbosity_normal; } else if (choice == fss_extended_list_write_parameter_verbosity_verbose) { main->error.verbosity = f_console_verbosity_verbose; + main->warning.verbosity = f_console_verbosity_verbose; } else if (choice == fss_extended_list_write_parameter_verbosity_debug) { main->error.verbosity = f_console_verbosity_debug; + main->warning.verbosity = f_console_verbosity_debug; } } @@ -175,10 +149,13 @@ extern "C" { if (main->parameters[fss_extended_list_write_parameter_file].result == f_console_result_additional) { if (main->parameters[fss_extended_list_write_parameter_file].values.used > 1) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_file); - f_color_print(main->error.to.stream, main->context.set.error, "' may only be specified once.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_file, main->error.notable); + fl_print_format("%[' may only be specified once.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -219,14 +196,17 @@ extern "C" { else if (main->parameters[fss_extended_list_write_parameter_content].locations.used && main->parameters[fss_extended_list_write_parameter_partial].locations.used) { if (main->parameters[fss_extended_list_write_parameter_content].result == f_console_result_additional) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_partial); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter only allows either the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter or the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter, but not both.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_partial, main->error.notable); + fl_print_format("%[' parameter only allows either the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_object, main->error.notable); + fl_print_format("%[' parameter or the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_content, main->error.notable); + fl_print_format("%[' parameter, but not both.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -248,12 +228,15 @@ extern "C" { if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sEach ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter must be specified before a '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sEach '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_object, main->error.notable); + fl_print_format("%[' parameter must be specified before a '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_content, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -276,12 +259,15 @@ extern "C" { } else if (!main->process_pipe) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThis requires either piped main or the use of the '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThis requires either piped data or the use of the '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_object, main->error.notable); + fl_print_format("%[' parameter with the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_content, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -290,10 +276,13 @@ extern "C" { if (F_status_is_error_not(status) && main->process_pipe) { if (main->parameters[fss_extended_list_write_parameter_partial].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_partial); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter cannot be used when processing a pipe.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThis '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_partial, main->error.notable); + fl_print_format("%[' parameter cannot be used when processing a pipe.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -304,10 +293,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_extended_list_write_parameter_prepend].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_prepend, main->error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -330,10 +322,13 @@ extern "C" { if (status == F_false) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe value for the parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' must only contain whitespace.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe value for the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_prepend, main->error.notable); + fl_print_format("%[' must only contain whitespace.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -343,10 +338,13 @@ extern "C" { } else { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe value for the parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' must not be an empty string.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe value for the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_prepend, main->error.notable); + fl_print_format("%[' must not be an empty string.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -357,10 +355,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_extended_list_write_parameter_ignore].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_ignore); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no values were given.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_ignore, main->error.notable); + fl_print_format("%[' was specified, but no values were given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -370,10 +371,13 @@ extern "C" { const f_array_length_t total_arguments = main->parameters[fss_extended_list_write_parameter_ignore].values.used; if (total_locations * 2 > total_arguments) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_ignore); - f_color_print(main->error.to.stream, main->context.set.error, "' requires two values.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_ignore, main->error.notable); + fl_print_format("%[' requires two values.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); } @@ -408,10 +412,12 @@ extern "C" { if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sWhile processing the ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "input pipe"); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sWhile processing the '%]%[input pipe%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } } @@ -468,16 +474,18 @@ extern "C" { if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sWhile processing the ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "input arguments"); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sWhile processing the '%]%[input arguments%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } } else if (main->error.verbosity != f_console_verbosity_quiet && main->parameters[fss_extended_list_write_parameter_file].result == f_console_result_none) { // ensure there is always a newline at the end, unless in quiet mode. - fprintf(main->output.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } } @@ -503,7 +511,7 @@ extern "C" { // ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->error.verbosity != f_console_verbosity_quiet) { if (F_status_is_error(status)) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } } diff --git a/level_3/fss_extended_list_write/c/fss_extended_list_write.h b/level_3/fss_extended_list_write/c/fss_extended_list_write.h index bed1a57..2dfebcb 100644 --- a/level_3/fss_extended_list_write/c/fss_extended_list_write.h +++ b/level_3/fss_extended_list_write/c/fss_extended_list_write.h @@ -31,12 +31,14 @@ #include #include #include +#include #include #include // fll-2 includes #include #include +#include #include #ifdef __cplusplus @@ -145,6 +147,8 @@ extern "C" { f_file_t output; fll_error_print_t error; + fll_error_print_t warning; + f_string_static_t prepend; f_color_context_t context; @@ -157,6 +161,7 @@ extern "C" { F_false, \ macro_f_file_t_initialize2(f_type_output, f_type_descriptor_output, f_file_flag_write_only), \ fll_error_print_t_initialize, \ + macro_fll_error_print_t_initialize_warning(), \ f_string_static_t_initialize, \ f_color_context_t_initialize, \ } diff --git a/level_3/fss_extended_list_write/c/private-fss_extended_list_write.c b/level_3/fss_extended_list_write/c/private-fss_extended_list_write.c index f99e3c7..462e12d 100644 --- a/level_3/fss_extended_list_write/c/private-fss_extended_list_write.c +++ b/level_3/fss_extended_list_write/c/private-fss_extended_list_write.c @@ -13,14 +13,17 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sMust specify both the '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_object); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter and the '"); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_content); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter the same number of times when not specifying the "); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_list_write_long_partial); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sMust specify the '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_object, main.error.notable); + fl_print_format("%[' parameter and the '%]", main.error.to.stream, main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_content, main.error.notable); + fl_print_format("%[' parameter the same number of times when not specifying the '%]", main.error.to.stream, main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_partial, main.error.notable); + fl_print_format("%[' parameter.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_extended_list_write_error_parameter_same_times_print_ @@ -31,10 +34,13 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThis standard does not support end of line character '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "\\n"); - f_color_print(main.error.to.stream, main.context.set.error, "' in objects.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sThis standard does not support end of line character '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[\\n%]", main.error.to.stream, main.error.notable, main.error.notable); + fl_print_format("%[' in objects.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_extended_list_write_error_parameter_unsupported_eol_print_ @@ -45,10 +51,13 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", symbol, parameter); - f_color_print(main.error.to.stream, main.context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%S%S%]", main.error.to.stream, main.error.notable, symbol, parameter, main.error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_extended_list_write_error_parameter_value_missing_print_ @@ -118,7 +127,7 @@ extern "C" { } } - f_print_dynamic(output.stream, *buffer); + fll_print_dynamic(*buffer, output.stream); buffer->used = 0; return status; @@ -244,8 +253,7 @@ extern "C" { if (block.string[range.start] == fss_extended_list_write_pipe_content_start) { if (main.error.verbosity != f_console_verbosity_quiet) { - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThis standard only supports one content per object.%c", fll_error_print_error, f_string_eol_s[0]); + fll_print_format("%c%[%sThis standard only supports one content per object.%]%c", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context, f_string_eol_s[0]); } status = F_status_set_error(F_supported_not); diff --git a/level_3/fss_extended_list_write/data/build/dependencies b/level_3/fss_extended_list_write/data/build/dependencies index 00b2c3d..7c8767f 100644 --- a/level_3/fss_extended_list_write/data/build/dependencies +++ b/level_3/fss_extended_list_write/data/build/dependencies @@ -17,8 +17,11 @@ f_print fl_console fl_conversion fl_fss +fl_print fl_status +fl_string fll_error fll_file fll_fss +fll_print fll_program diff --git a/level_3/fss_extended_list_write/data/build/settings b/level_3/fss_extended_list_write/data/build/settings index a33eae4..43b4ee1 100644 --- a/level_3/fss_extended_list_write/data/build/settings +++ b/level_3/fss_extended_list_write/data/build/settings @@ -20,7 +20,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_program -lfl_console -lfl_conversion -lfl_directory -lfl_fss -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_console -lfl_conversion -lfl_directory -lfl_fss -lfl_print -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_extended_list_write.c private-common.c private-fss_extended_list_write.c @@ -51,7 +51,7 @@ defines_all defines_static defines_shared -flags_all -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses +flags_all -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses flags_shared flags_static flags_library -fPIC 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 43a49db..e814243 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -9,6 +9,8 @@ extern "C" { #ifndef _di_fss_extended_write_print_help_ f_status_t fss_extended_write_print_help(const f_file_t output, const f_color_context_t context) { + flockfile(output.stream); + fll_program_print_help_header(output, context, fss_extended_write_name_long, fss_extended_write_version); fll_program_print_help_option(output, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); @@ -21,7 +23,7 @@ extern "C" { fll_program_print_help_option(output, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, inceasing verbosity beyond normal output."); fll_program_print_help_option(output, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); - fprintf(output.stream, "%c", f_string_eol_s[0]); + f_print_character(f_string_eol_s[0], output.stream); fll_program_print_help_option(output, context, fss_extended_write_short_file, fss_extended_write_long_file, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send output to."); fll_program_print_help_option(output, context, fss_extended_write_short_content, fss_extended_write_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "The Content to output."); @@ -35,50 +37,20 @@ extern "C" { fll_program_print_help_usage(output, context, fss_extended_write_name, f_string_empty_s); - fprintf(output.stream, " The pipe uses the Backspace character '"); - f_color_print(output.stream, context.set.notable, "\\b"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+0008"); - fprintf(output.stream, ") to designate the start of a Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, " The pipe uses the Form Feed character '"); - f_color_print(output.stream, context.set.notable, "\\f"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000C"); - fprintf(output.stream, ") to designate the end of the last Content.%c", f_string_eol_s[0]); - - fprintf(output.stream, " The pipe uses the Vertical Line character '"); - f_color_print(output.stream, context.set.notable, "\\v"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000B"); - fprintf(output.stream, ") is used to ignore a Content range, which does nothing in this program.%c", f_string_eol_s[0]); - - fprintf(output.stream, " For the pipe, an Object is terminated by either a Backspace character '"); - f_color_print(output.stream, context.set.notable, "\\b"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+0008"); - fprintf(output.stream, ") or a Form Feed character '"); - f_color_print(output.stream, context.set.notable, "\\f"); - fprintf(output.stream, "' ("); - f_color_print(output.stream, context.set.notable, "U+000C"); - fprintf(output.stream, ").%c", f_string_eol_s[0]); - - fprintf(output.stream, " The end of the pipe represents the end of any Object or Content.%c", f_string_eol_s[0]); + fl_print_format(" The pipe uses the Backspace character '%[\\b%]' (%[U+0008%]) to designate the start of a Content.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The pipe uses the Form Feed character '%[\\f%]' (%[U+000C%]) to designate the end of the last Content.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The pipe uses the Vertical Line character '%[\\v%]' (%[U+000B%]) is used to ignore a Content range, which does nothing in this program.%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" For the pipe, an Object is terminated by either a Backspace character '%[\\b%]' (%[U+0008%])", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable); + fl_print_format(" or a Form Feed character '%[\\f%]' (%[U+000C%]).%c", output.stream, context.set.notable, context.set.notable, context.set.notable, context.set.notable, f_string_eol_s[0]); + fl_print_format(" The end of the pipe represents the end of any Object or Content.%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); - fprintf(output.stream, "%c", f_string_eol_s[0]); + fl_print_format(" The FSS-0001 (Extended) specification does not support multi-line Content, therefore the parameter '%[%s%s%]'", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_extended_write_long_prepend, context.set.notable); + fl_print_format(" does nothing.%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); - fprintf(output.stream, " The FSS-0001 (Extended) specification does not support multi-line Content, therefore the parameter '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_prepend); - fprintf(output.stream, "' does nothing.%c", f_string_eol_s[0]); + fl_print_format(" This program does not use the parameter '%[%s%s%]', which therefore does nothing.%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_extended_write_long_ignore, context.set.notable, f_string_eol_s[0]); + fl_print_format(" This parameter requires two values.%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); - fprintf(output.stream, "%c", f_string_eol_s[0]); - - fprintf(output.stream, " This program does not use the parameter '"); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_ignore); - fprintf(output.stream, "', which therefore does nothing.%c", f_string_eol_s[0]); - fprintf(output.stream, " This parameter requires two values.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); + funlockfile(output.stream); return F_none; } @@ -100,9 +72,12 @@ extern "C" { if (main->context.set.error.before) { main->error.context = main->context.set.error; main->error.notable = main->context.set.notable; + + main->warning.context = main->context.set.warning; + main->warning.notable = main->context.set.notable; } else { - f_color_set_t *sets[] = { &main->error.context, &main->error.notable, 0 }; + f_color_set_t *sets[] = { &main->error.context, &main->error.notable, &main->warning.context, &main->warning.notable, 0 }; fll_program_parameter_process_empty(&main->context, sets); } @@ -128,15 +103,19 @@ extern "C" { if (choice == fss_extended_write_parameter_verbosity_quiet) { main->error.verbosity = f_console_verbosity_quiet; + main->warning.verbosity = f_console_verbosity_quiet; } else if (choice == fss_extended_write_parameter_verbosity_normal) { main->error.verbosity = f_console_verbosity_normal; + main->warning.verbosity = f_console_verbosity_normal; } else if (choice == fss_extended_write_parameter_verbosity_verbose) { main->error.verbosity = f_console_verbosity_verbose; + main->warning.verbosity = f_console_verbosity_verbose; } else if (choice == fss_extended_write_parameter_verbosity_debug) { main->error.verbosity = f_console_verbosity_debug; + main->warning.verbosity = f_console_verbosity_debug; } } @@ -167,10 +146,13 @@ extern "C" { if (main->parameters[fss_extended_write_parameter_file].result == f_console_result_additional) { if (main->parameters[fss_extended_write_parameter_file].values.used > 1) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_file); - f_color_print(main->error.to.stream, main->context.set.error, "' may only be specified once.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_file, main->error.notable); + fl_print_format("%[' may only be specified once.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -211,14 +193,17 @@ extern "C" { else if (main->parameters[fss_extended_write_parameter_content].locations.used && main->parameters[fss_extended_write_parameter_partial].locations.used) { if (main->parameters[fss_extended_write_parameter_content].result == f_console_result_additional) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_partial); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter only allows either the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter or the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter, but not both.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_partial, main->error.notable); + fl_print_format("%[' parameter only allows either the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_object, main->error.notable); + fl_print_format("%[' parameter or the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_content, main->error.notable); + fl_print_format("%[' parameter, but not both.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -234,12 +219,15 @@ extern "C" { if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sEach ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter must be specified before a '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sEach '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_object, main->error.notable); + fl_print_format("%[' parameter must be specified before a '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_content, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -252,12 +240,15 @@ extern "C" { if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sEach ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter must have at least one '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sEach '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_object, main->error.notable); + fl_print_format("%[' parameter must have at least one '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_content, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -279,12 +270,15 @@ extern "C" { } else if (!main->process_pipe) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThis requires either piped main or the use of the '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThis requires either piped data or the use of the '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_object, main->error.notable); + fl_print_format("%[' parameter with the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_content, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -293,10 +287,13 @@ extern "C" { if (F_status_is_error_not(status) && main->process_pipe) { if (main->parameters[fss_extended_write_parameter_partial].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_partial); - f_color_print(main->error.to.stream, main->context.set.error, "' parameter cannot be used when processing a pipe.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThis '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_partial, main->error.notable); + fl_print_format("%[' parameter cannot be used when processing a pipe.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -307,10 +304,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_extended_write_parameter_prepend].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_prepend, main->error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -331,10 +331,13 @@ extern "C" { if (status == F_false) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe value for the parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' must only contain whitespace.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe value for the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_prepend, main->error.notable); + fl_print_format("%[' must only contain whitespace.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -344,10 +347,13 @@ extern "C" { } else { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe value for the parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_prepend); - f_color_print(main->error.to.stream, main->context.set.error, "' must not be an empty string.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe value for the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_prepend, main->error.notable); + fl_print_format("%[' must not be an empty string.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -358,10 +364,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_extended_write_parameter_ignore].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_ignore); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no values were given.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_ignore, main->error.notable); + fl_print_format("%[' was specified, but no values were given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -371,10 +380,13 @@ extern "C" { const f_array_length_t total_arguments = main->parameters[fss_extended_write_parameter_ignore].values.used; if (total_locations * 2 > total_arguments) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_ignore); - f_color_print(main->error.to.stream, main->context.set.error, "' requires two values.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_ignore, main->error.notable); + fl_print_format("%[' requires two values.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); } @@ -408,10 +420,12 @@ extern "C" { if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sWhile processing the ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "input pipe"); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sWhile processing the '%]%[input pipe%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } } } @@ -527,15 +541,18 @@ extern "C" { if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sWhile processing the ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "input arguments"); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sWhile processing the '%]%[input arguments%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } } else if (main->error.verbosity != f_console_verbosity_quiet && main->parameters[fss_extended_write_parameter_file].result == f_console_result_none) { + // ensure there is always a newline at the end, unless in quiet mode. - fprintf(main->output.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } } @@ -559,7 +576,7 @@ extern "C" { // ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->error.verbosity != f_console_verbosity_quiet) { if (F_status_is_error(status)) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } } diff --git a/level_3/fss_extended_write/c/fss_extended_write.h b/level_3/fss_extended_write/c/fss_extended_write.h index 3b178be..b63d75f 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.h +++ b/level_3/fss_extended_write/c/fss_extended_write.h @@ -30,12 +30,14 @@ // fll-1 includes #include #include +#include #include // fll-2 includes #include #include #include +#include #include #ifdef __cplusplus @@ -144,6 +146,7 @@ extern "C" { f_file_t output; fll_error_print_t error; + fll_error_print_t warning; f_string_static_t prepend; f_color_context_t context; @@ -156,6 +159,7 @@ extern "C" { F_false, \ macro_f_file_t_initialize2(f_type_output, f_type_descriptor_output, f_file_flag_write_only), \ fll_error_print_t_initialize, \ + macro_fll_error_print_t_initialize_warning(), \ f_string_static_t_initialize, \ f_color_context_t_initialize, \ } diff --git a/level_3/fss_extended_write/c/private-fss_extended_write.c b/level_3/fss_extended_write/c/private-fss_extended_write.c index d56563a..4b0227e 100644 --- a/level_3/fss_extended_write/c/private-fss_extended_write.c +++ b/level_3/fss_extended_write/c/private-fss_extended_write.c @@ -13,14 +13,17 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sMust specify the '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_object); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter at least once and the '"); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_content); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter one or more times when not specifying the "); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_extended_write_long_partial); - f_color_print(main.error.to.stream, main.context.set.error, "' parameter.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sMust specify the '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_object, main.error.notable); + fl_print_format("%[' parameter and the '%]", main.error.to.stream, main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_content, main.error.notable); + fl_print_format("%[' parameter the same number of times when not specifying the '%]", main.error.to.stream, main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%s%s%]", main.error.to.stream, main.error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_partial, main.error.notable); + fl_print_format("%[' parameter.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_extended_write_error_parameter_at_least_once_print_ @@ -31,10 +34,13 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "%s%s", symbol, parameter); - f_color_print(main.error.to.stream, main.context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sThe parameter '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%S%S%]", main.error.to.stream, main.error.notable, symbol, parameter, main.error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_extended_write_error_parameter_value_missing_print_ @@ -45,10 +51,13 @@ extern "C" { return; } - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThis standard does not support end of line character '", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "\\n"); - f_color_print(main.error.to.stream, main.context.set.error, "'.%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sThis standard does not support end of line character '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[\\n%]", main.error.to.stream, main.error.notable, main.error.notable); + fl_print_format("%[' in objects.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } #endif // _di_fss_extended_write_error_parameter_unsupported_eol_print_ @@ -134,7 +143,7 @@ extern "C" { } } - f_print_dynamic(output.stream, *buffer); + fll_print_dynamic(*buffer, output.stream); buffer->used = 0; return status; diff --git a/level_3/fss_extended_write/data/build/dependencies b/level_3/fss_extended_write/data/build/dependencies index 79e2ed9..e9f562b 100644 --- a/level_3/fss_extended_write/data/build/dependencies +++ b/level_3/fss_extended_write/data/build/dependencies @@ -16,8 +16,11 @@ f_pipe f_print fl_conversion fl_fss +fl_print fl_status +fl_string fll_error fll_file fll_fss +fll_print fll_program diff --git a/level_3/fss_extended_write/data/build/settings b/level_3/fss_extended_write/data/build/settings index 4bd55db..2cb1375 100644 --- a/level_3/fss_extended_write/data/build/settings +++ b/level_3/fss_extended_write/data/build/settings @@ -20,7 +20,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_program -lfl_conversion -lfl_directory -lfl_fss -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_conversion -lfl_directory -lfl_fss -lfl_print -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_extended_write.c private-common.c private-fss_extended_write.c @@ -51,7 +51,7 @@ defines_all defines_static defines_shared -flags_all -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses +flags_all -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses flags_shared flags_static flags_library -fPIC