From b4b7bf09c581b8b801a521d30d09c6453b0b081f Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 16 Aug 2021 21:43:00 -0500 Subject: [PATCH] Progress: Continue string and convert changes, fixing bugs. The f_conversion_character_* functions should accept uint8_t instead of f_number_unsigned_t. Implement the "/" character to designate the a partial range. The "*_except*" string processing functions must accept an offset. I was really hoping to avoid adding additional parameters but then I realized that I have to have a start offset. The "except" positions and ranges are relative to the actual start and not the offset start. The previous behavior of applying an offset to the string before passing results in the entire except positions and ranges to be invalid for any offset greater than 0. Have F_eos (with error bit set) returned for when end of string is reached while calling fl_print_string_convert(). Rewrite the static/dynamic string argument printing logic. Update private_fl_print_convert_number() to use bitwise operations rather than comparisons. Convert the controller program. Add missing "controller_string_value" and related to controller program. --- level_0/f_conversion/c/conversion.c | 10 +- level_0/f_conversion/c/conversion.h | 10 +- level_0/f_print/c/print-common.h | 16 +- level_0/f_print/c/print.c | 24 +- level_0/f_print/c/print.h | 34 +- level_0/f_print/c/private-print.c | 4 +- level_1/fl_conversion/c/conversion.c | 50 +- level_1/fl_print/c/print.c | 54 +- level_1/fl_print/c/print.h | 56 +- level_1/fl_print/c/private-print.c | 439 ++++++++----- level_1/fl_print/c/private-print.h | 15 +- level_2/fll_error/c/private-error.c | 8 +- level_2/fll_print/c/print.c | 48 +- level_2/fll_print/c/print.h | 48 +- level_3/controller/c/controller.c | 126 ++-- level_3/controller/c/private-common.c | 1 + level_3/controller/c/private-common.h | 3 + level_3/controller/c/private-controller.c | 340 +++++----- level_3/controller/c/private-entry.c | 282 ++++---- level_3/controller/c/private-entry.h | 4 +- level_3/controller/c/private-rule.c | 1023 ++++++++++++++++------------- level_3/controller/c/private-rule.h | 23 +- level_3/controller/c/private-thread.c | 44 +- 23 files changed, 1482 insertions(+), 1180 deletions(-) diff --git a/level_0/f_conversion/c/conversion.c b/level_0/f_conversion/c/conversion.c index 10d80ea..72c180e 100644 --- a/level_0/f_conversion/c/conversion.c +++ b/level_0/f_conversion/c/conversion.c @@ -75,7 +75,7 @@ extern "C" { #endif // _di_f_conversion_character_is_octal_ #ifndef _di_f_conversion_character_to_binary_ - f_status_t f_conversion_character_to_binary(const char character, f_number_unsigned_t *number) { + f_status_t f_conversion_character_to_binary(const char character, uint8_t *number) { #ifndef _di_level_0_parameter_checking_ if (!number) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -93,7 +93,7 @@ extern "C" { #endif // _di_f_conversion_character_to_binary_ #ifndef _di_f_conversion_character_to_decimal_ - f_status_t f_conversion_character_to_decimal(const char character, f_number_unsigned_t *number) { + f_status_t f_conversion_character_to_decimal(const char character, uint8_t *number) { #ifndef _di_level_0_parameter_checking_ if (!number) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -109,7 +109,7 @@ extern "C" { #endif // _di_f_conversion_character_to_decimal_ #ifndef _di_f_conversion_character_to_duodecimal_ - f_status_t f_conversion_character_to_duodecimal(const char character, f_number_unsigned_t *number) { + f_status_t f_conversion_character_to_duodecimal(const char character, uint8_t *number) { #ifndef _di_level_0_parameter_checking_ if (!number) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -131,7 +131,7 @@ extern "C" { #endif // _di_f_conversion_character_to_duodecimal_ #ifndef _di_f_conversion_character_to_hexidecimal_ - f_status_t f_conversion_character_to_hexidecimal(const char character, f_number_unsigned_t *number) { + f_status_t f_conversion_character_to_hexidecimal(const char character, uint8_t *number) { #ifndef _di_level_0_parameter_checking_ if (!number) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -153,7 +153,7 @@ extern "C" { #endif // _di_f_conversion_character_to_hexidecimal_ #ifndef _di_f_conversion_character_to_octal_ - f_status_t f_conversion_character_to_octal(const char character, f_number_unsigned_t *number) { + f_status_t f_conversion_character_to_octal(const char character, uint8_t *number) { #ifndef _di_level_0_parameter_checking_ if (!number) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ diff --git a/level_0/f_conversion/c/conversion.h b/level_0/f_conversion/c/conversion.h index b39a601..b6c7626 100644 --- a/level_0/f_conversion/c/conversion.h +++ b/level_0/f_conversion/c/conversion.h @@ -118,7 +118,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_conversion_character_to_binary_ - extern f_status_t f_conversion_character_to_binary(const char character, f_number_unsigned_t *number); + extern f_status_t f_conversion_character_to_binary(const char character, uint8_t *number); #endif // _di_f_conversion_character_to_binary_ /** @@ -137,7 +137,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_conversion_character_to_decimal_ - extern f_status_t f_conversion_character_to_decimal(const char character, f_number_unsigned_t *number); + extern f_status_t f_conversion_character_to_decimal(const char character, uint8_t *number); #endif // _di_f_conversion_character_to_decimal_ /** @@ -156,7 +156,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_conversion_character_to_duodecimal_ - extern f_status_t f_conversion_character_to_duodecimal(const char character, f_number_unsigned_t *number); + extern f_status_t f_conversion_character_to_duodecimal(const char character, uint8_t *number); #endif // _di_f_conversion_character_to_duodecimal_ /** @@ -175,7 +175,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_conversion_character_to_hexidecimal_ - extern f_status_t f_conversion_character_to_hexidecimal(const char character, f_number_unsigned_t *number); + extern f_status_t f_conversion_character_to_hexidecimal(const char character, uint8_t *number); #endif // _di_f_conversion_character_to_hexidecimal_ /** @@ -194,7 +194,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_conversion_character_to_octal_ - extern f_status_t f_conversion_character_to_octal(const char character, f_number_unsigned_t *number); + extern f_status_t f_conversion_character_to_octal(const char character, uint8_t *number); #endif // _di_f_conversion_character_to_octal_ /** diff --git a/level_0/f_print/c/print-common.h b/level_0/f_print/c/print-common.h index 49ff407..29153af 100644 --- a/level_0/f_print/c/print-common.h +++ b/level_0/f_print/c/print-common.h @@ -120,12 +120,15 @@ extern "C" { /** * Provide basic format flags. * + * @todo be sure to document that the "/", ";", and ":" use pre-defined orders, so "%/;:Q" and "%:/;Q" would be processed in the same (pre-defined) order (which is 1: static/dynamic string, 2: partial range, 3: ignore ats, 4: ignore ins). + * * f_print_format_flag_*: * - align_left: "-", Use left-justification. * - convert: "#", Use alternate form conversion (prefixing 0b/0B, 0o/0O, 0t/0T, 0d/0D, 0x/0X). * - ignore_index: ";", Ignore characters in the given positions from a f_array_length_t (only applies to static/dynamic string arguments but not character arguments). * - ignore_range: ":", Ignore characters in the given ranges from a f_string_range_t (only applies to static/dynamic string arguments but not character arguments). * - precision: Designates that a precision is in use. + * - range: "/", Print only the given range of a string, specified by f_string_range_t (only applies to static/dynamic string arguments but not character arguments). * - sign_always: "+", Always show the signs (+ or -). * - sign_pad: " ", Add a space where a sign would be if the sign is not displayed. * - trim: "=", Trim leading and trailing whitespaces (only applies to static/dynamic string arguments but not character arguments). @@ -141,12 +144,13 @@ extern "C" { #define f_print_format_flag_ignore_index 0x4 #define f_print_format_flag_ignore_range 0x8 #define f_print_format_flag_precision 0x10 - #define f_print_format_flag_sign_always 0x20 - #define f_print_format_flag_sign_pad 0x40 - #define f_print_format_flag_trim 0x80 - #define f_print_format_flag_uppercase 0x100 - #define f_print_format_flag_width 0x200 - #define f_print_format_flag_zeros_leading 0x400 + #define f_print_format_flag_range 0x20 + #define f_print_format_flag_sign_always 0x40 + #define f_print_format_flag_sign_pad 0x80 + #define f_print_format_flag_trim 0x100 + #define f_print_format_flag_uppercase 0x200 + #define f_print_format_flag_width 0x400 + #define f_print_format_flag_zeros_leading 0x800 #endif // _di_f_print_format_flags_ /** diff --git a/level_0/f_print/c/print.c b/level_0/f_print/c/print.c index 41be8f8..e11cc2e 100644 --- a/level_0/f_print/c/print.c +++ b/level_0/f_print/c/print.c @@ -159,7 +159,7 @@ extern "C" { #endif // _di_f_print_dynamic_partial_safely_ #ifndef _di_f_print_except_ - f_status_t f_print_except(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { + f_status_t f_print_except(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { #ifndef _di_level_0_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -168,12 +168,12 @@ extern "C" { return F_data_not; } - return private_f_print_except(string, 0, length, except, output); + return private_f_print_except(string, offset, length, except, output); } #endif // _di_f_print_except_ #ifndef _di_f_print_except_raw_ - f_status_t f_print_except_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { + f_status_t f_print_except_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { #ifndef _di_level_0_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -182,12 +182,12 @@ extern "C" { return F_data_not; } - return private_f_print_except_raw(string, 0, length, except, output); + return private_f_print_except_raw(string, offset, length, except, output); } #endif // _di_f_print_except_raw_ #ifndef _di_f_print_except_safely_ - f_status_t f_print_except_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { + f_status_t f_print_except_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { #ifndef _di_level_0_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -196,7 +196,7 @@ extern "C" { return F_data_not; } - return private_f_print_except_safely(string, 0, length, except, output); + return private_f_print_except_safely(string, offset, length, except, output); } #endif // _di_f_print_except_safely_ @@ -237,7 +237,7 @@ extern "C" { #endif // _di_f_print_except_dynamic_safely_ #ifndef _di_f_print_except_in_ - f_status_t f_print_except_in(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t f_print_except_in(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { #ifndef _di_level_0_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -246,12 +246,12 @@ extern "C" { return F_data_not; } - return private_f_print_except_in(string, 0, length, except_at, except_in, output); + return private_f_print_except_in(string, offset, length, except_at, except_in, output); } #endif // _di_f_print_except_in_ #ifndef _di_f_print_except_in_raw_ - f_status_t f_print_except_in_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t f_print_except_in_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { #ifndef _di_level_0_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -260,12 +260,12 @@ extern "C" { return F_data_not; } - return private_f_print_except_in_raw(string, 0, length, except_at, except_in, output); + return private_f_print_except_in_raw(string, offset, length, except_at, except_in, output); } #endif // _di_f_print_except_in_raw_ #ifndef _di_f_print_except_in_safely_ - f_status_t f_print_except_in_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t f_print_except_in_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { #ifndef _di_level_0_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -274,7 +274,7 @@ extern "C" { return F_data_not; } - return private_f_print_except_in_safely(string, 0, length, except_at, except_in, output); + return private_f_print_except_in_safely(string, offset, length, except_at, except_in, output); } #endif // _di_f_print_except_in_safely_ diff --git a/level_0/f_print/c/print.h b/level_0/f_print/c/print.h index 0993ae9..2cb5fe2 100644 --- a/level_0/f_print/c/print.h +++ b/level_0/f_print/c/print.h @@ -320,6 +320,8 @@ extern "C" { /** * Similar to a c-library printf, except that this will only print a specific range. * + * An offset is provided because the except position is expected to be relative to the start position, without the offset applied. + * * Will not stop at NULL. * Will not print NULL. * Will not print any 1-byte character at a location specified in except array. @@ -329,6 +331,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except @@ -347,12 +351,14 @@ extern "C" { * @see fwrite_unlocked() */ #ifndef _di_f_print_except_ - extern f_status_t f_print_except(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output); + extern f_status_t f_print_except(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output); #endif // _di_f_print_except_ /** * Similar to a c-library printf, except that this will only print a specific range. * + * An offset is provided because the except position is expected to be relative to the start position, without the offset applied. + * * Will not stop at NULL. * Will print NULL. * Will not print any 1-byte character at a location specified in except array. @@ -364,6 +370,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except @@ -382,7 +390,7 @@ extern "C" { * @see fwrite_unlocked() */ #ifndef _di_f_print_except_raw_ - extern f_status_t f_print_except_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output); + extern f_status_t f_print_except_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output); #endif // _di_f_print_except_raw_ /** @@ -400,6 +408,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except @@ -420,7 +430,7 @@ extern "C" { * @see f_utf_is_valid() */ #ifndef _di_f_print_except_safely_ - extern f_status_t f_print_except_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output); + extern f_status_t f_print_except_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output); #endif // _di_f_print_except_safely_ /** @@ -526,6 +536,8 @@ extern "C" { /** * Similar to a c-library printf, except that this will only print a specific range. * + * An offset is provided because the except_at/except_int positions are expected to be relative to the start position, without the offset applied. + * * Will not stop at NULL. * Will not print NULL. * Will not print any 1-byte character at a location specified in except_at array. @@ -536,6 +548,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -557,12 +571,14 @@ extern "C" { * @see fwrite_unlocked() */ #ifndef _di_f_print_except_in_ - extern f_status_t f_print_except_in(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); + extern f_status_t f_print_except_in(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); #endif // _di_f_print_except_in_ /** * Similar to a c-library printf, except that this will only print a specific range. * + * An offset is provided because the except_at/except_int positions are expected to be relative to the start position, without the offset applied. + * * Will not stop at NULL. * Will print NULL. * Will not print any 1-byte character at a location specified in except_at array. @@ -575,6 +591,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -596,7 +614,7 @@ extern "C" { * @see fwrite_unlocked() */ #ifndef _di_f_print_except_in_raw_ - extern f_status_t f_print_except_in_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); + extern f_status_t f_print_except_in_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); #endif // _di_f_print_except_in_raw_ /** @@ -605,6 +623,8 @@ extern "C" { * Control characters are converted to the Unicode control character symbols, including NULL. * UTF-8 sequences with invalid widths are converted to the unknown character '�'. * + * An offset is provided because the except_at/except_int positions are expected to be relative to the start position, without the offset applied. + * * Will not stop at NULL. * Will print NULL (as a control character symbol). * Will not print any 1-byte character at a location specified in except_at array. @@ -615,6 +635,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -638,7 +660,7 @@ extern "C" { * @see f_utf_is_valid() */ #ifndef _di_f_print_except_in_safely_ - extern f_status_t f_print_except_in_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); + extern f_status_t f_print_except_in_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); #endif // _di_f_print_except_in_safely_ /** diff --git a/level_0/f_print/c/private-print.c b/level_0/f_print/c/private-print.c index 03d1b78..345972a 100644 --- a/level_0/f_print/c/private-print.c +++ b/level_0/f_print/c/private-print.c @@ -13,7 +13,7 @@ extern "C" { for (register f_array_length_t i = 0; i < length; ) { - total = strlen(string + start); + total = strnlen(string + start, length - start); if (total) { if (fwrite_unlocked(string + start, 1, total, output) == -1) { @@ -123,7 +123,7 @@ extern "C" { for (register f_array_length_t i = 0; i < length; ) { - total = strlen(string + start); + total = strnlen(string + start, length - start); if (total) { if (fwrite_unlocked(string + start, 1, total, output) == -1) { diff --git a/level_1/fl_conversion/c/conversion.c b/level_1/fl_conversion/c/conversion.c index 763ebad..b3800e6 100644 --- a/level_1/fl_conversion/c/conversion.c +++ b/level_1/fl_conversion/c/conversion.c @@ -17,7 +17,7 @@ extern "C" { } uint8_t digits = 0; - f_number_unsigned_t digit = 0; + uint8_t digit = 0; f_number_unsigned_t converted = 0; for (f_array_length_t i = range.start; i <= range.stop; ++i) { @@ -47,10 +47,10 @@ extern "C" { digits = 1; if (negative) { - converted = 0 - digit; + converted = (f_number_unsigned_t) (0 - digit); } else { - converted = digit; + converted = (f_number_unsigned_t) digit; } } } @@ -77,7 +77,7 @@ extern "C" { } uint8_t digits = 0; - f_number_unsigned_t digit = 0; + uint8_t digit = 0; f_number_unsigned_t converted = 0; for (f_array_length_t i = range.start; i <= range.stop; ++i) { @@ -95,7 +95,7 @@ extern "C" { } else if (digit) { digits = 1; - converted = digit; + converted = (f_number_unsigned_t) digit; } } else if (string[i]) { @@ -121,7 +121,7 @@ extern "C" { } uint8_t digits = 0; - f_number_unsigned_t digit = 0; + uint8_t digit = 0; f_number_unsigned_t converted = 0; for (f_array_length_t i = range.start; i <= range.stop; ++i) { @@ -156,10 +156,10 @@ extern "C" { digits = 1; if (negative) { - converted = 0 - digit; + converted = (f_number_unsigned_t) (0 - digit); } else { - converted = digit; + converted = (f_number_unsigned_t) digit; } } } @@ -186,7 +186,7 @@ extern "C" { } uint8_t digits = 0; - f_number_unsigned_t digit = 0; + uint8_t digit = 0; f_number_unsigned_t converted = 0; for (f_array_length_t i = range.start; i <= range.stop; ++i) { @@ -207,7 +207,7 @@ extern "C" { } else if (digit) { digits = 1; - converted = digit; + converted = (f_number_unsigned_t) digit; } } else if (string[i]) { @@ -233,7 +233,7 @@ extern "C" { } uint8_t digits = 0; - f_number_unsigned_t digit = 0; + uint8_t digit = 0; f_number_unsigned_t converted = 0; for (f_array_length_t i = range.start; i <= range.stop; ++i) { @@ -268,10 +268,10 @@ extern "C" { digits = 1; if (negative) { - converted = 0 - digit; + converted = (f_number_unsigned_t) (0 - digit); } else { - converted = digit; + converted = (f_number_unsigned_t) digit; } } } @@ -298,7 +298,7 @@ extern "C" { } uint8_t digits = 0; - f_number_unsigned_t digit = 0; + uint8_t digit = 0; f_number_unsigned_t converted = 0; for (f_array_length_t i = range.start; i <= range.stop; ++i) { @@ -319,7 +319,7 @@ extern "C" { } else if (digit) { digits = 1; - converted = digit; + converted = (f_number_unsigned_t) digit; } } else if (string[i]) { @@ -345,7 +345,7 @@ extern "C" { } uint8_t digits = 0; - f_number_unsigned_t digit = 0; + uint8_t digit = 0; f_number_unsigned_t converted = 0; for (f_array_length_t i = range.start; i <= range.stop; ++i) { @@ -380,10 +380,10 @@ extern "C" { digits = 1; if (negative) { - converted = 0 - digit; + converted = (f_number_unsigned_t) (0 - digit); } else { - converted = digit; + converted = (f_number_unsigned_t) digit; } } } @@ -410,7 +410,7 @@ extern "C" { } uint8_t digits = 0; - f_number_unsigned_t digit = 0; + uint8_t digit = 0; f_number_unsigned_t converted = 0; for (f_array_length_t i = range.start; i <= range.stop; ++i) { @@ -431,7 +431,7 @@ extern "C" { } else if (digit) { digits = 1; - converted = digit; + converted = (f_number_unsigned_t) digit; } } else if (string[i]) { @@ -457,7 +457,7 @@ extern "C" { } uint8_t digits = 0; - f_number_unsigned_t digit = 0; + uint8_t digit = 0; f_number_unsigned_t converted = 0; for (f_array_length_t i = range.start; i <= range.stop; ++i) { @@ -492,10 +492,10 @@ extern "C" { digits = 1; if (negative) { - converted = 0 - digit; + converted = (f_number_unsigned_t) (0 - digit); } else { - converted = digit; + converted = (f_number_unsigned_t) digit; } } } @@ -522,7 +522,7 @@ extern "C" { } uint8_t digits = 0; - f_number_unsigned_t digit = 0; + uint8_t digit = 0; f_number_unsigned_t converted = 0; for (f_array_length_t i = range.start; i <= range.stop; ++i) { @@ -543,7 +543,7 @@ extern "C" { } else if (digit) { digits = 1; - converted = digit; + converted = (f_number_unsigned_t) digit; } } else if (string[i]) { diff --git a/level_1/fl_print/c/print.c b/level_1/fl_print/c/print.c index 923aa38..ce2d2a5 100644 --- a/level_1/fl_print/c/print.c +++ b/level_1/fl_print/c/print.c @@ -310,7 +310,7 @@ extern "C" { #endif // _di_fl_print_trim_dynamic_partial_safely_ #ifndef _di_fl_print_trim_except_ - f_status_t fl_print_trim_except(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { + f_status_t fl_print_trim_except(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, FILE *output) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -321,12 +321,12 @@ extern "C" { const f_string_ranges_t except_in = f_string_ranges_t_initialize; - return private_fl_print_trim_except_in(string, length, except, except_in, output); + return private_fl_print_trim_except_in(string, offset, length, except_at, except_in, output); } #endif // _di_fl_print_trim_except_ #ifndef _di_fl_print_trim_except_raw_ - f_status_t fl_print_trim_except_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { + f_status_t fl_print_trim_except_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, FILE *output) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -337,12 +337,12 @@ extern "C" { const f_string_ranges_t except_in = f_string_ranges_t_initialize; - return private_fl_print_trim_except_in_raw(string, length, except, except_in, output); + return private_fl_print_trim_except_in_raw(string, offset, length, except_at, except_in, output); } #endif // _di_fl_print_trim_except_raw_ #ifndef _di_fl_print_trim_except_safely_ - f_status_t fl_print_trim_except_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { + f_status_t fl_print_trim_except_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, FILE *output) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -353,12 +353,12 @@ extern "C" { const f_string_ranges_t except_in = f_string_ranges_t_initialize; - return private_fl_print_trim_except_in_safely(string, length, except, except_in, output); + return private_fl_print_trim_except_in_safely(string, offset, length, except_at, except_in, output); } #endif // _di_fl_print_trim_except_safely_ #ifndef _di_fl_print_trim_except_dynamic_ - f_status_t fl_print_trim_except_dynamic(const f_string_static_t buffer, const f_array_lengths_t except, FILE *output) { + f_status_t fl_print_trim_except_dynamic(const f_string_static_t buffer, const f_array_lengths_t except_at, FILE *output) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -369,12 +369,12 @@ extern "C" { const f_string_ranges_t except_in = f_string_ranges_t_initialize; - return private_fl_print_trim_except_in(buffer.string, buffer.used, except, except_in, output); + return private_fl_print_trim_except_in(buffer.string, 0, buffer.used, except_at, except_in, output); } #endif // _di_fl_print_trim_except_dynamic_ #ifndef _di_fl_print_trim_except_dynamic_raw_ - f_status_t fl_print_trim_except_dynamic_raw(const f_string_static_t buffer, const f_array_lengths_t except, FILE *output) { + f_status_t fl_print_trim_except_dynamic_raw(const f_string_static_t buffer, const f_array_lengths_t except_at, FILE *output) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -385,12 +385,12 @@ extern "C" { const f_string_ranges_t except_in = f_string_ranges_t_initialize; - return private_fl_print_trim_except_in_raw(buffer.string, buffer.used, except, except_in, output); + return private_fl_print_trim_except_in_raw(buffer.string, 0, buffer.used, except_at, except_in, output); } #endif // _di_fl_print_trim_except_dynamic_raw_ #ifndef _di_fl_print_trim_except_dynamic_safely_ - f_status_t fl_print_trim_except_dynamic_safely(const f_string_static_t buffer, const f_array_lengths_t except, FILE *output) { + f_status_t fl_print_trim_except_dynamic_safely(const f_string_static_t buffer, const f_array_lengths_t except_at, FILE *output) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -401,12 +401,12 @@ extern "C" { const f_string_ranges_t except_in = f_string_ranges_t_initialize; - return private_fl_print_trim_except_in_safely(buffer.string, buffer.used, except, except_in, output); + return private_fl_print_trim_except_in_safely(buffer.string, 0, buffer.used, except_at, except_in, output); } #endif // _di_fl_print_trim_except_dynamic_safely_ #ifndef _di_fl_print_trim_except_in_ - f_status_t fl_print_trim_except_in(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t fl_print_trim_except_in(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -415,12 +415,12 @@ extern "C" { return F_data_not; } - return private_fl_print_trim_except_in(string, length, except_at, except_in, output); + return private_fl_print_trim_except_in(string, offset, length, except_at, except_in, output); } #endif // _di_fl_print_trim_except_in_ #ifndef _di_fl_print_trim_except_in_raw_ - f_status_t fl_print_trim_except_in_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t fl_print_trim_except_in_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -429,12 +429,12 @@ extern "C" { return F_data_not; } - return private_fl_print_trim_except_in_raw(string, length, except_at, except_in, output); + return private_fl_print_trim_except_in_raw(string, offset, length, except_at, except_in, output); } #endif // _di_fl_print_trim_except_in_raw_ #ifndef _di_fl_print_trim_except_in_safely_ - f_status_t fl_print_trim_except_in_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t fl_print_trim_except_in_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -443,7 +443,7 @@ extern "C" { return F_data_not; } - return private_fl_print_trim_except_in_safely(string, length, except_at, except_in, output); + return private_fl_print_trim_except_in_safely(string, offset, length, except_at, except_in, output); } #endif // _di_fl_print_trim_except_in_safely_ @@ -457,7 +457,7 @@ extern "C" { return F_data_not; } - return private_fl_print_trim_except_in(buffer.string, buffer.used, except_at, except_in, output); + return private_fl_print_trim_except_in(buffer.string, 0, buffer.used, except_at, except_in, output); } #endif // _di_fl_print_trim_except_in_dynamic_ @@ -471,7 +471,7 @@ extern "C" { return F_data_not; } - return private_fl_print_trim_except_in_raw(buffer.string, buffer.used, except_at, except_in, output); + return private_fl_print_trim_except_in_raw(buffer.string, 0, buffer.used, except_at, except_in, output); } #endif // _di_fl_print_trim_except_in_dynamic_raw_ @@ -485,7 +485,7 @@ extern "C" { return F_data_not; } - return private_fl_print_trim_except_in_safely(buffer.string, buffer.used, except_at, except_in, output); + return private_fl_print_trim_except_in_safely(buffer.string, 0, buffer.used, except_at, except_in, output); } #endif // _di_fl_print_trim_except_in_dynamic_safely_ @@ -505,7 +505,7 @@ extern "C" { length = buffer.used - range.start; } - return private_fl_print_trim_except_in(buffer.string + range.start, length, except_at, except_in, output); + return private_fl_print_trim_except_in(buffer.string, range.start, length, except_at, except_in, output); } #endif // _di_fl_print_trim_except_in_dynamic_partial_ @@ -525,7 +525,7 @@ extern "C" { length = buffer.used - range.start; } - return private_fl_print_trim_except_in_raw(buffer.string + range.start, length, except_at, except_in, output); + return private_fl_print_trim_except_in_raw(buffer.string, range.start, length, except_at, except_in, output); } #endif // _di_fl_print_trim_except_in_dynamic_partial_raw_ @@ -545,7 +545,7 @@ extern "C" { length = buffer.used - range.start; } - return private_fl_print_trim_except_in_safely(buffer.string + range.start, length, except_at, except_in, output); + return private_fl_print_trim_except_in_safely(buffer.string, range.start, length, except_at, except_in, output); } #endif // _di_fl_print_trim_except_in_dynamic_partial_safely_ @@ -567,7 +567,7 @@ extern "C" { const f_string_ranges_t except_in = f_string_ranges_t_initialize; - return private_fl_print_trim_except_in(buffer.string + range.start, length, except, except_in, output); + return private_fl_print_trim_except_in(buffer.string, range.start, length, except, except_in, output); } #endif // _di_fl_print_trim_except_dynamic_partial_ @@ -589,7 +589,7 @@ extern "C" { const f_string_ranges_t except_in = f_string_ranges_t_initialize; - return private_fl_print_trim_except_in_raw(buffer.string + range.start, length, except, except_in, output); + return private_fl_print_trim_except_in_raw(buffer.string, range.start, length, except, except_in, output); } #endif // _di_fl_print_trim_except_dynamic_partial_raw_ @@ -611,7 +611,7 @@ extern "C" { const f_string_ranges_t except_in = f_string_ranges_t_initialize; - return private_fl_print_trim_except_in_safely(buffer.string + range.start, length, except, except_in, output); + return private_fl_print_trim_except_in_safely(buffer.string, range.start, length, except, except_in, output); } #endif // _di_fl_print_trim_except_dynamic_partial_safely_ diff --git a/level_1/fl_print/c/print.h b/level_1/fl_print/c/print.h index 0e3c809..c3a6140 100644 --- a/level_1/fl_print/c/print.h +++ b/level_1/fl_print/c/print.h @@ -616,7 +616,7 @@ extern "C" { * * Will not stop at NULL. * Will not print NULL. - * Will not print any 1-byte character at a location specified in except array. + * Will not print any 1-byte character at a location specified in except_at array. * * NULL characters are treated as whitespace for the purpose of trimming. * @@ -624,9 +624,11 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. - * @param except + * @param except_at * An array of locations within the given string to not print. * The array of locations is required/assumed to be in linear order. * @param output @@ -647,7 +649,7 @@ extern "C" { * @see fputc_unlocked() */ #ifndef _di_fl_print_trim_except_ - extern f_status_t fl_print_trim_except(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output); + extern f_status_t fl_print_trim_except(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, FILE *output); #endif // _di_fl_print_trim_except_ /** @@ -657,7 +659,7 @@ extern "C" { * * Will not stop at NULL. * Will print NULL. - * Will not print any 1-byte character at a location specified in except array. + * Will not print any 1-byte character at a location specified in except_at array. * * All UTF-8 characters, invalid or not, are printed as is, except for trimmed characters. * Invalid UTF-8 characters are not considered whitespace for the purpose of trimming. @@ -668,9 +670,11 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. - * @param except + * @param except_at * An array of locations within the given string to not print. * The array of locations is required/assumed to be in linear order. * @param output @@ -689,7 +693,7 @@ extern "C" { * @see fputc_unlocked() */ #ifndef _di_fl_print_trim_except_raw_ - extern f_status_t fl_print_trim_except_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output); + extern f_status_t fl_print_trim_except_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, FILE *output); #endif // _di_fl_print_trim_except_raw_ /** @@ -700,7 +704,7 @@ extern "C" { * * Will not stop at NULL. * Will print NULL (as a control character symbol). - * Will not print any 1-byte character at a location specified in except array. + * Will not print any 1-byte character at a location specified in except_at array. * * NULL characters are treated as whitespace for the purpose of trimming. * @@ -708,9 +712,11 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. - * @param except + * @param except_at * An array of locations within the given string to not print. * The array of locations is required/assumed to be in linear order. * @param output @@ -730,7 +736,7 @@ extern "C" { * @see fputc_unlocked() */ #ifndef _di_fl_print_trim_except_safely_ - extern f_status_t fl_print_trim_except_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output); + extern f_status_t fl_print_trim_except_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, FILE *output); #endif // _di_fl_print_trim_except_safely_ /** @@ -741,7 +747,7 @@ extern "C" { * Will not stop at NULL. * Will not print NULL. * Will print the entire dynamic string, except for leading/trailing whitespace. - * Will not print any 1-byte character at a location specified in except array. + * Will not print any 1-byte character at a location specified in except_at array. * * NULL characters are treated as whitespace for the purpose of trimming. * @@ -749,7 +755,7 @@ extern "C" { * * @param buffer * The string to output. - * @param except + * @param except_at * An array of locations within the given string to not print. * The array of locations is required/assumed to be in linear order. * @param output @@ -770,7 +776,7 @@ extern "C" { * @see fputc_unlocked() */ #ifndef _di_fl_print_trim_except_dynamic_ - extern f_status_t fl_print_trim_except_dynamic(const f_string_static_t buffer, const f_array_lengths_t except, FILE *output); + extern f_status_t fl_print_trim_except_dynamic(const f_string_static_t buffer, const f_array_lengths_t except_at, FILE *output); #endif // _di_fl_print_trim_except_dynamic_ /** @@ -781,7 +787,7 @@ extern "C" { * Will not stop at NULL. * Will print NULL. * Will print the entire dynamic string, except for leading/trailing whitespace. - * Will not print any 1-byte character at a location specified in except array. + * Will not print any 1-byte character at a location specified in except_at array. * * All UTF-8 characters, invalid or not, are printed as is, except for trimmed characters. * Invalid UTF-8 characters are not considered whitespace for the purpose of trimming. @@ -792,7 +798,7 @@ extern "C" { * * @param buffer * The string to output. - * @param except + * @param except_at * An array of locations within the given string to not print. * The array of locations is required/assumed to be in linear order. * @param output @@ -811,7 +817,7 @@ extern "C" { * @see fputc_unlocked() */ #ifndef _di_fl_print_trim_except_dynamic_raw_ - extern f_status_t fl_print_trim_except_dynamic_raw(const f_string_static_t buffer, const f_array_lengths_t except, FILE *output); + extern f_status_t fl_print_trim_except_dynamic_raw(const f_string_static_t buffer, const f_array_lengths_t except_at, FILE *output); #endif // _di_fl_print_trim_except_dynamic_raw_ /** @@ -823,7 +829,7 @@ extern "C" { * Will not stop at NULL. * Will print NULL (as a control character symbol). * Will print the entire dynamic string, except for leading/trailing whitespace. - * Will not print any 1-byte character at a location specified in except array. + * Will not print any 1-byte character at a location specified in except_at array. * * NULL characters are treated as whitespace for the purpose of trimming. * @@ -831,7 +837,7 @@ extern "C" { * * @param buffer * The string to output. - * @param except + * @param except_at * An array of locations within the given string to not print. * The array of locations is required/assumed to be in linear order. * @param output @@ -851,7 +857,7 @@ extern "C" { * @see fputc_unlocked() */ #ifndef _di_fl_print_trim_except_dynamic_safely_ - extern f_status_t fl_print_trim_except_dynamic_safely(const f_string_static_t buffer, const f_array_lengths_t except, FILE *output); + extern f_status_t fl_print_trim_except_dynamic_safely(const f_string_static_t buffer, const f_array_lengths_t except_at, FILE *output); #endif // _di_fl_print_trim_except_dynamic_safely_ /** @@ -870,6 +876,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -896,7 +904,7 @@ extern "C" { * @see fputc_unlocked() */ #ifndef _di_fl_print_trim_except_in_ - extern f_status_t fl_print_trim_except_in(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); + extern f_status_t fl_print_trim_except_in(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); #endif // _di_fl_print_trim_except_in_ /** @@ -918,6 +926,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -942,7 +952,7 @@ extern "C" { * @see fputc_unlocked() */ #ifndef _di_fl_print_trim_except_in_raw_ - extern f_status_t fl_print_trim_except_in_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); + extern f_status_t fl_print_trim_except_in_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); #endif // _di_fl_print_trim_except_in_raw_ /** @@ -962,6 +972,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -987,7 +999,7 @@ extern "C" { * @see fputc_unlocked() */ #ifndef _di_fl_print_trim_except_in_safely_ - extern f_status_t fl_print_trim_except_in_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); + extern f_status_t fl_print_trim_except_in_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); #endif // _di_fl_print_trim_except_in_safely_ /** @@ -1007,6 +1019,8 @@ extern "C" { * * @param buffer * The string to output. + * @param offset + * The inclusive start point to start printing. * @param except_at * An array of locations within the given string to not print. * The array of locations is required/assumed to be in linear order. diff --git a/level_1/fl_print/c/private-print.c b/level_1/fl_print/c/private-print.c index 63c07bc..bd3c154 100644 --- a/level_1/fl_print/c/private-print.c +++ b/level_1/fl_print/c/private-print.c @@ -12,7 +12,8 @@ extern "C" { // An unpaired '%' character must not be at the end of the string. if (!*string) { - *status = F_status_set_error(F_valid_not); + *status = F_status_set_error(F_eos); + return string; } @@ -54,11 +55,13 @@ extern "C" { // The first percent found represents a literal '%' to be printed, otherwise return as invalid. if (string == start) { if (!fputc_unlocked(f_string_ascii_percent_s[0], output)) { - return string; + *status = F_status_set_error(F_output); } } + else { + *status = F_status_set_error(F_valid_not); + } - *status = F_status_set_error(F_valid_not); return string; } else if (*string == f_string_ascii_ampersand_s[0]) { @@ -77,6 +80,7 @@ extern "C" { } else { *status = F_status_set_error(F_valid_not); + return string; } } @@ -88,7 +92,8 @@ extern "C" { } else if (*string == f_string_ascii_period_s[0]) { if (!*(string + 1)) { - *status = F_status_set_error(F_valid_not); + *status = F_status_set_error(F_eos); + return string; } @@ -96,6 +101,7 @@ extern "C" { if (*string < 0x30 || *string > 0x39) { *status = F_status_set_error(F_valid_not); + return string; } @@ -106,6 +112,11 @@ extern "C" { continue; } + else if (*string == f_string_ascii_slash_forward_s[0]) { + flag |= f_print_format_flag_range; + + continue; + } else if (*string > 0x2f && *string < 0x3a) { if (!(flag & f_print_format_flag_width)) { if (*string == f_string_ascii_0_s[0]) { @@ -125,6 +136,7 @@ extern "C" { } else { *status = F_status_set_error(F_valid_not); + return string; } } @@ -150,6 +162,7 @@ extern "C" { } else { *status = F_status_set_error(F_valid_not); + return string; } } @@ -193,67 +206,117 @@ extern "C" { else if (*string == f_string_ascii_Q_s[0]) { const f_string_static_t value = va_arg(*ap, f_string_static_t); - if (flag & f_print_format_flag_trim) { + if (flag & f_print_format_flag_range) { + const f_string_range_t partial = va_arg(*ap, f_string_range_t); + if (flag & f_print_format_flag_ignore_index) { + const f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); + f_string_ranges_t except_in = f_string_ranges_t_initialize; + if (flag & f_print_format_flag_ignore_range) { - f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); - f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); + except_in = va_arg(*ap, f_string_ranges_t); + } - *status = private_fl_print_trim_except_in_safely(value.string, value.used, except_at, except_in, output); + if (partial.start > partial.start) { + *status = F_data_not; return string; } - f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); - f_string_ranges_t except_in = f_string_ranges_t_initialize; + f_array_length_t length = (partial.stop - partial.start) + 1; - *status = private_fl_print_trim_except_in_safely(value.string, value.used, except_at, except_in, output); + if (length + partial.start > value.used) { + length = value.used - partial.start; + } - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_except_in_safely(value.string, partial.start, length, except_at, except_in, output); + } + else { + *status = f_print_except_in_safely(value.string, partial.start, length, except_at, except_in, output); + } } + else if (flag & f_print_format_flag_ignore_range) { + const f_array_lengths_t except_at = f_array_lengths_t_initialize; + const f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); - if (flag & f_print_format_flag_ignore_range) { - f_array_lengths_t except_at = f_array_lengths_t_initialize; - f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); + if (partial.start > partial.start) { + *status = F_data_not; + + return string; + } + + f_array_length_t length = (partial.stop - partial.start) + 1; - *status = private_fl_print_trim_except_in_safely(value.string, value.used, except_at, except_in, output); + if (length + partial.start > value.used) { + length = value.used - partial.start; + } - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_except_in_safely(value.string, partial.start, length, except_at, except_in, output); + } + else { + *status = f_print_except_in_safely(value.string, partial.start, length, except_at, except_in, output); + } } + else { + const f_array_lengths_t except_at = f_array_lengths_t_initialize; + const f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); - *status = private_fl_print_trim_safely(value.string, value.used, output); + if (partial.start > partial.start) { + *status = F_data_not; - return string; - } + return string; + } - if (flag & f_print_format_flag_ignore_index) { - if (flag & f_print_format_flag_ignore_range) { - f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); - f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); + f_array_length_t length = (partial.stop - partial.start) + 1; - *status = f_print_except_in_safely(value.string, value.used, except_at, except_in, output); + if (length + partial.start > value.used) { + length = value.used - partial.start; + } - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_safely(value.string + partial.start, length, output); + } + else { + *status = f_print_safely(value.string + partial.start, length, output); + } } - - f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); + } + else if (flag & f_print_format_flag_ignore_index) { + const f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); f_string_ranges_t except_in = f_string_ranges_t_initialize; - *status = f_print_except_in_safely(value.string, value.used, except_at, except_in, output); + if (flag & f_print_format_flag_ignore_range) { + except_in = va_arg(*ap, f_string_ranges_t); + } - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_except_in_safely(value.string, 0, value.used, except_at, except_in, output); + } + else { + *status = f_print_except_in_dynamic_safely(value, except_at, except_in, output); + } } + else if (flag & f_print_format_flag_ignore_range) { + const f_array_lengths_t except_at = f_array_lengths_t_initialize; + const f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); - if (flag & f_print_format_flag_ignore_range) { - f_array_lengths_t except_at = f_array_lengths_t_initialize; - f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); - - *status = f_print_except_in_safely(value.string, value.used, except_at, except_in, output); - - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_except_in_safely(value.string, 0, value.used, except_at, except_in, output); + } + else { + *status = f_print_except_in_dynamic_safely(value, except_at, except_in, output); + } + } + else { + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_safely(value.string, value.used, output); + } + else { + *status = f_print_dynamic_safely(value, output); + } } - - *status = f_print_dynamic_safely(value, output); return string; } @@ -295,6 +358,7 @@ extern "C" { } else { *status = F_status_set_error(F_valid_not); + return string; } } @@ -333,6 +397,7 @@ extern "C" { } else { *status = F_status_set_error(F_valid_not); + return string; } } @@ -376,142 +441,241 @@ extern "C" { else if (*string == f_string_ascii_q_s[0]) { const f_string_static_t value = va_arg(*ap, f_string_static_t); - if (flag & f_print_format_flag_trim) { + if (flag & f_print_format_flag_range) { + const f_string_range_t partial = va_arg(*ap, f_string_range_t); + if (flag & f_print_format_flag_ignore_index) { + const f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); + f_string_ranges_t except_in = f_string_ranges_t_initialize; + if (flag & f_print_format_flag_ignore_range) { - f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); - f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); + except_in = va_arg(*ap, f_string_ranges_t); + } - *status = private_fl_print_trim_except_in(value.string, value.used, except_at, except_in, output); + if (partial.start > partial.start) { + *status = F_data_not; return string; } - f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); - f_string_ranges_t except_in = f_string_ranges_t_initialize; + f_array_length_t length = (partial.stop - partial.start) + 1; - *status = private_fl_print_trim_except_in(value.string, value.used, except_at, except_in, output); + if (length + partial.start > value.used) { + length = value.used - partial.start; + } - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_except_in(value.string, partial.start, length, except_at, except_in, output); + } + else { + *status = f_print_except_in(value.string, partial.start, length, except_at, except_in, output); + } } + else if (flag & f_print_format_flag_ignore_range) { + const f_array_lengths_t except_at = f_array_lengths_t_initialize; + const f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); - if (flag & f_print_format_flag_ignore_range) { - f_array_lengths_t except_at = f_array_lengths_t_initialize; - f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); + if (partial.start > partial.start) { + *status = F_data_not; - *status = private_fl_print_trim_except_in(value.string, value.used, except_at, except_in, output); + return string; + } - return string; + f_array_length_t length = (partial.stop - partial.start) + 1; + + if (length + partial.start > value.used) { + length = value.used - partial.start; + } + + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_except_in(value.string, partial.start, length, except_at, except_in, output); + } + else { + *status = f_print_except_in(value.string, partial.start, length, except_at, except_in, output); + } } + else { + const f_array_lengths_t except_at = f_array_lengths_t_initialize; + const f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); - *status = private_fl_print_trim(value.string, value.used, output); + if (partial.start > partial.start) { + *status = F_data_not; - return string; - } + return string; + } - if (flag & f_print_format_flag_ignore_index) { - if (flag & f_print_format_flag_ignore_range) { - f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); - f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); + f_array_length_t length = (partial.stop - partial.start) + 1; - *status = f_print_except_in(value.string, value.used, except_at, except_in, output); + if (length + partial.start > value.used) { + length = value.used - partial.start; + } - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim(value.string + partial.start, length, output); + } + else { + *status = f_print(value.string + partial.start, length, output); + } } - - f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); + } + else if (flag & f_print_format_flag_ignore_index) { + const f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); f_string_ranges_t except_in = f_string_ranges_t_initialize; - *status = f_print_except_in(value.string, value.used, except_at, except_in, output); + if (flag & f_print_format_flag_ignore_range) { + except_in = va_arg(*ap, f_string_ranges_t); + } - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_except_in(value.string, 0, value.used, except_at, except_in, output); + } + else { + *status = f_print_except_in_dynamic(value, except_at, except_in, output); + } } + else if (flag & f_print_format_flag_ignore_range) { + const f_array_lengths_t except_at = f_array_lengths_t_initialize; + const f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); - if (flag & f_print_format_flag_ignore_range) { - f_array_lengths_t except_at = f_array_lengths_t_initialize; - f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); - - *status = f_print_except_in(value.string, value.used, except_at, except_in, output); - - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_except_in(value.string, 0, value.used, except_at, except_in, output); + } + else { + *status = f_print_except_in_dynamic(value, except_at, except_in, output); + } + } + else { + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim(value.string, value.used, output); + } + else { + *status = f_print_dynamic(value, output); + } } - - *status = f_print_dynamic(value, output); return string; } else { *status = F_status_set_error(F_valid_not); + return string; } } else { if (*string == f_string_ascii_r_s[0]) { - - // raw static/dynamic string. const f_string_static_t value = va_arg(*ap, f_string_static_t); - if (flag & f_print_format_flag_trim) { + if (flag & f_print_format_flag_range) { + const f_string_range_t partial = va_arg(*ap, f_string_range_t); + if (flag & f_print_format_flag_ignore_index) { + const f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); + f_string_ranges_t except_in = f_string_ranges_t_initialize; + if (flag & f_print_format_flag_ignore_range) { - f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); - f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); + except_in = va_arg(*ap, f_string_ranges_t); + } - *status = private_fl_print_trim_except_in_raw(value.string, value.used, except_at, except_in, output); + if (partial.start > partial.start) { + *status = F_data_not; return string; } - f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); - f_string_ranges_t except_in = f_string_ranges_t_initialize; + f_array_length_t length = (partial.stop - partial.start) + 1; - *status = private_fl_print_trim_except_in_raw(value.string, value.used, except_at, except_in, output); + if (length + partial.start > value.used) { + length = value.used - partial.start; + } - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_except_in_raw(value.string, partial.start, length, except_at, except_in, output); + } + else { + *status = f_print_except_in_raw(value.string, partial.start, length, except_at, except_in, output); + } } + else if (flag & f_print_format_flag_ignore_range) { + const f_array_lengths_t except_at = f_array_lengths_t_initialize; + const f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); - if (flag & f_print_format_flag_ignore_range) { - f_array_lengths_t except_at = f_array_lengths_t_initialize; - f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); + if (partial.start > partial.start) { + *status = F_data_not; + + return string; + } + + f_array_length_t length = (partial.stop - partial.start) + 1; - *status = private_fl_print_trim_except_in_raw(value.string, value.used, except_at, except_in, output); + if (length + partial.start > value.used) { + length = value.used - partial.start; + } - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_except_in_raw(value.string, partial.start, length, except_at, except_in, output); + } + else { + *status = f_print_except_in_raw(value.string, partial.start, length, except_at, except_in, output); + } } + else { + const f_array_lengths_t except_at = f_array_lengths_t_initialize; + const f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); - *status = private_fl_print_trim_raw(value.string, value.used, output); + if (partial.start > partial.start) { + *status = F_data_not; - return string; - } + return string; + } - if (flag & f_print_format_flag_ignore_index) { - if (flag & f_print_format_flag_ignore_range) { - f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); - f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); + f_array_length_t length = (partial.stop - partial.start) + 1; - *status = f_print_except_in_raw(value.string, value.used, except_at, except_in, output); + if (length + partial.start > value.used) { + length = value.used - partial.start; + } - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_raw(value.string + partial.start, length, output); + } + else { + *status = f_print_raw(value.string + partial.start, length, output); + } } - - f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); + } + else if (flag & f_print_format_flag_ignore_index) { + const f_array_lengths_t except_at = va_arg(*ap, f_array_lengths_t); f_string_ranges_t except_in = f_string_ranges_t_initialize; - *status = f_print_except_in_raw(value.string, value.used, except_at, except_in, output); + if (flag & f_print_format_flag_ignore_range) { + except_in = va_arg(*ap, f_string_ranges_t); + } - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_except_in_raw(value.string, 0, value.used, except_at, except_in, output); + } + else { + *status = f_print_except_in_dynamic_raw(value, except_at, except_in, output); + } } + else if (flag & f_print_format_flag_ignore_range) { + const f_array_lengths_t except_at = f_array_lengths_t_initialize; + const f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); - if (flag & f_print_format_flag_ignore_range) { - f_array_lengths_t except_at = f_array_lengths_t_initialize; - f_string_ranges_t except_in = va_arg(*ap, f_string_ranges_t); - - *status = f_print_except_in_raw(value.string, value.used, except_at, except_in, output); - - return string; + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_except_in_raw(value.string, 0, value.used, except_at, except_in, output); + } + else { + *status = f_print_except_in_dynamic_raw(value, except_at, except_in, output); + } + } + else { + if (flag & f_print_format_flag_trim) { + *status = private_fl_print_trim_raw(value.string, value.used, output); + } + else { + *status = f_print_dynamic_raw(value, output); + } } - - *status = f_print_dynamic_raw(value, output); return string; } @@ -555,6 +719,7 @@ extern "C" { } else { *status = F_status_set_error(F_valid_not); + return string; } } @@ -644,6 +809,7 @@ extern "C" { } // for *status = F_status_set_error(F_valid_not); + return string; } #endif // !defined(_di_fl_print_string_convert_) || !defined(_di_fl_print_string_) @@ -653,44 +819,9 @@ extern "C" { for (*number = 0; *string; string += 1) { - if (*string == f_string_ascii_0_s[0]) { - *number *= 10; - } - else if (*string == f_string_ascii_1_s[0]) { - *number *= 10; - *number += 1; - } - else if (*string == f_string_ascii_2_s[0]) { - *number *= 10; - *number += 2; - } - else if (*string == f_string_ascii_3_s[0]) { - *number *= 10; - *number += 3; - } - else if (*string == f_string_ascii_4_s[0]) { - *number *= 10; - *number += 4; - } - else if (*string == f_string_ascii_5_s[0]) { + if (*string > 0x29 && *string < 0x40) { *number *= 10; - *number += 5; - } - else if (*string == f_string_ascii_6_s[0]) { - *number *= 10; - *number += 6; - } - else if (*string == f_string_ascii_7_s[0]) { - *number *= 10; - *number += 7; - } - else if (*string == f_string_ascii_8_s[0]) { - *number *= 10; - *number += 8; - } - else if (*string == f_string_ascii_9_s[0]) { - *number *= 10; - *number += 9; + *number += 0xf & *string; } else if (*string == f_string_ascii_asterisk_s[0]) { *number = va_arg(*ap, unsigned int); @@ -707,9 +838,9 @@ extern "C" { #endif // !defined(_di_fl_print_string_convert_) || !defined(_di_fl_print_string_) #if !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) || !defined(_di_fl_print_trim_except_in_) || !defined(_di_fl_print_trim_except_in_dynamic_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_) - f_status_t private_fl_print_trim_except_in(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t private_fl_print_trim_except_in(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { - f_array_length_t i = 0; + f_array_length_t i = offset; f_array_length_t j = 0; f_array_length_t at = 0; f_array_length_t at2 = 0; @@ -961,9 +1092,9 @@ extern "C" { #endif // !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) || !defined(_di_fl_print_trim_except_in_) || !defined(_di_fl_print_trim_except_in_dynamic_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_) #if !defined(_di_fl_print_trim_except_raw_) || !defined(_di_fl_print_trim_except_dynamic_raw_) || !defined(_di_fl_print_trim_except_dynamic_partial_raw_) || !defined(_di_fl_print_trim_except_in_raw_) || !defined(_di_fl_print_trim_except_in_dynamic_raw_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_raw_) - f_status_t private_fl_print_trim_except_in_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t private_fl_print_trim_except_in_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { - f_array_length_t i = 0; + f_array_length_t i = offset; f_array_length_t j = 0; f_array_length_t at = 0; f_array_length_t at2 = 0; @@ -1158,9 +1289,9 @@ extern "C" { #endif // !defined(_di_fl_print_trim_except_raw_) || !defined(_di_fl_print_trim_except_dynamic_raw_) || !defined(_di_fl_print_trim_except_dynamic_partial_raw_) || !defined(_di_fl_print_trim_except_in_raw_) || !defined(_di_fl_print_trim_except_in_dynamic_raw_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_raw_) #if !defined(_di_fl_print_trim_except_safely_) || !defined(_di_fl_print_trim_except_dynamic_safely_) || !defined(_di_fl_print_trim_except_dynamic_partial_safely_) || !defined(_di_fl_print_trim_except_in_safely_) || !defined(_di_fl_print_trim_except_in_dynamic_safely_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_safely_) - f_status_t private_fl_print_trim_except_in_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t private_fl_print_trim_except_in_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { - f_array_length_t i = 0; + f_array_length_t i = offset; f_array_length_t j = 0; f_array_length_t at = 0; f_array_length_t at2 = 0; diff --git a/level_1/fl_print/c/private-print.h b/level_1/fl_print/c/private-print.h index 7ee0112..6ca6928 100644 --- a/level_1/fl_print/c/private-print.h +++ b/level_1/fl_print/c/private-print.h @@ -38,10 +38,11 @@ extern "C" { * * F_none on success. * + * F_eos (with error bit) on failure because end of string found and cannot process further. * F_output (with error bit) on failure to print to the output file. * F_parameter (with error bit) if a parameter is invalid. * F_utf_not (with error bit) if character is an invalid UTF-8 character. - * F_valid_not (with error bit) on invalid syntax (such as terminating the string on a single '%'). + * F_valid_not (with error bit) on invalid syntax. * * Success from: f_print_dynamic(). * Success from: f_print_dynamic_raw(). @@ -104,6 +105,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -137,7 +140,7 @@ extern "C" { * @see fl_print_trim_except_in_dynamic_partial() */ #if !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) || !defined(_di_fl_print_trim_except_in_) || !defined(_di_fl_print_trim_except_in_dynamic_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_) - extern f_status_t private_fl_print_trim_except_in(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) f_attribute_visibility_internal; + extern f_status_t private_fl_print_trim_except_in(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) f_attribute_visibility_internal; #endif // !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) || !defined(_di_fl_print_trim_except_in_) || !defined(_di_fl_print_trim_except_in_dynamic_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_) /** @@ -147,6 +150,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -178,7 +183,7 @@ extern "C" { * @see fl_print_trim_except_in_dynamic_partial_raw() */ #if !defined(_di_fl_print_trim_except_raw_) || !defined(_di_fl_print_trim_except_dynamic_raw_) || !defined(_di_fl_print_trim_except_dynamic_partial_raw_) || !defined(_di_fl_print_trim_except_in_raw_) || !defined(_di_fl_print_trim_except_in_dynamic_raw_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_raw_) - extern f_status_t private_fl_print_trim_except_in_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) f_attribute_visibility_internal; + extern f_status_t private_fl_print_trim_except_in_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) f_attribute_visibility_internal; #endif // !defined(_di_fl_print_trim_except_raw_) || !defined(_di_fl_print_trim_except_dynamic_raw_) || !defined(_di_fl_print_trim_except_dynamic_partial_raw_) || !defined(_di_fl_print_trim_except_in_raw_) || !defined(_di_fl_print_trim_except_in_dynamic_raw_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_raw_) /** @@ -188,6 +193,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -220,7 +227,7 @@ extern "C" { * @see fl_print_trim_except_in_dynamic_partial_safely() */ #if !defined(_di_fl_print_trim_except_safely_) || !defined(_di_fl_print_trim_except_dynamic_safely_) || !defined(_di_fl_print_trim_except_dynamic_partial_safely_) || !defined(_di_fl_print_trim_except_in_safely_) || !defined(_di_fl_print_trim_except_in_dynamic_safely_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_safely_) - extern f_status_t private_fl_print_trim_except_in_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) f_attribute_visibility_internal; + extern f_status_t private_fl_print_trim_except_in_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) f_attribute_visibility_internal; #endif // !defined(_di_fl_print_trim_except_safely_) || !defined(_di_fl_print_trim_except_dynamic_safely_) || !defined(_di_fl_print_trim_except_dynamic_partial_safely_) || !defined(_di_fl_print_trim_except_in_safely_) || !defined(_di_fl_print_trim_except_in_dynamic_safely_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_safely_) /** diff --git a/level_2/fll_error/c/private-error.c b/level_2/fll_error/c/private-error.c index 928ceb5..5c29287 100644 --- a/level_2/fll_error/c/private-error.c +++ b/level_2/fll_error/c/private-error.c @@ -164,12 +164,12 @@ extern "C" { if (print.verbosity != f_console_verbosity_quiet) { flockfile(print.to.stream); - fl_print_string("%c%[%S(", print.to.stream, f_string_eol_s[0], print.context, print.prefix); - fl_print_string("%[%ui%]%[", print.to.stream, print.notable, status, print.notable, print.context); + fl_print_string("%c%[%S(%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, print.context); + fl_print_string("%[%ui%]%[)", print.to.stream, print.notable, status, print.notable, print.context); private_fll_error_print_function(print, function); - fl_print_string(").%]%c", print.to.stream, print.context, f_string_eol_s[0]); + fl_print_string(".%]%c", print.to.stream, print.context, f_string_eol_s[0]); funlockfile(print.to.stream); } @@ -183,7 +183,7 @@ extern "C" { void private_fll_error_print_function(const fll_error_print_t print, const f_string_t function) { if (function) { - fl_print_string(" when calling function %]", print.to.stream, print.context); + fl_print_string(" when calling function%] ", print.to.stream, print.context); fl_print_string("%[%S%]", print.to.stream, print.notable, function, print.notable); fl_print_string("%[()", print.to.stream, print.context); } diff --git a/level_2/fll_print/c/print.c b/level_2/fll_print/c/print.c index 0314831..4873880 100644 --- a/level_2/fll_print/c/print.c +++ b/level_2/fll_print/c/print.c @@ -235,11 +235,11 @@ extern "C" { #endif // _di_fll_print_dynamic_partial_safely_ #ifndef _di_fll_print_except_ - f_status_t fll_print_except(const f_string_t buffer, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { + f_status_t fll_print_except(const f_string_t buffer, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { flockfile(output); - const f_status_t status = f_print_except(buffer, length, except, output); + const f_status_t status = f_print_except(buffer, offset, length, except, output); funlockfile(output); @@ -248,11 +248,11 @@ extern "C" { #endif // _di_fll_print_except_ #ifndef _di_fll_print_except_raw_ - f_status_t fll_print_except_raw(const f_string_t buffer, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { + f_status_t fll_print_except_raw(const f_string_t buffer, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { flockfile(output); - const f_status_t status = f_print_except_raw(buffer, length, except, output); + const f_status_t status = f_print_except_raw(buffer, offset, length, except, output); funlockfile(output); @@ -261,11 +261,11 @@ extern "C" { #endif // _di_fll_print_except_raw_ #ifndef _di_fll_print_except_safely_ - f_status_t fll_print_except_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { + f_status_t fll_print_except_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { flockfile(output); - const f_status_t status = f_print_except_safely(string, length, except, output); + const f_status_t status = f_print_except_safely(string, offset, length, except, output); funlockfile(output); @@ -313,11 +313,11 @@ extern "C" { #endif // _di_fll_print_except_dynamic_safely_ #ifndef _di_fll_print_except_in_ - f_status_t fll_print_except_in(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t fll_print_except_in(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { flockfile(output); - const f_status_t status = f_print_except_in(string, length, except_at, except_in, output); + const f_status_t status = f_print_except_in(string, offset, length, except_at, except_in, output); funlockfile(output); @@ -326,11 +326,11 @@ extern "C" { #endif // _di_fll_print_except_in_ #ifndef _di_fll_print_except_in_raw_ - f_status_t fll_print_except_in_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t fll_print_except_in_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { flockfile(output); - const f_status_t status = f_print_except_in_raw(string, length, except_at, except_in, output); + const f_status_t status = f_print_except_in_raw(string, offset, length, except_at, except_in, output); funlockfile(output); @@ -339,11 +339,11 @@ extern "C" { #endif // _di_fll_print_except_in_raw_ #ifndef _di_fll_print_except_in_safely_ - f_status_t fll_print_except_in_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t fll_print_except_in_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { flockfile(output); - const f_status_t status = f_print_except_in_safely(string, length, except_at, except_in, output); + const f_status_t status = f_print_except_in_safely(string, offset, length, except_at, except_in, output); funlockfile(output); @@ -683,11 +683,11 @@ extern "C" { #endif // _di_fll_print_trim_dynamic_partial_safely_ #ifndef _di_fll_print_trim_except_ - f_status_t fll_print_trim_except(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { + f_status_t fll_print_trim_except(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { flockfile(output); - const f_status_t status = fl_print_trim_except(string, length, except, output); + const f_status_t status = fl_print_trim_except(string, offset, length, except, output); funlockfile(output); @@ -696,11 +696,11 @@ extern "C" { #endif // _di_fll_print_trim_except_ #ifndef _di_fll_print_trim_except_raw_ - f_status_t fll_print_trim_except_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { + f_status_t fll_print_trim_except_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { flockfile(output); - const f_status_t status = fl_print_trim_except_raw(string, length, except, output); + const f_status_t status = fl_print_trim_except_raw(string, offset, length, except, output); funlockfile(output); @@ -709,11 +709,11 @@ extern "C" { #endif // _di_fll_print_trim_except_raw_ #ifndef _di_fll_print_trim_except_safely_ - f_status_t fll_print_trim_except_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { + f_status_t fll_print_trim_except_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output) { flockfile(output); - const f_status_t status = fl_print_trim_except_safely(string, length, except, output); + const f_status_t status = fl_print_trim_except_safely(string, offset, length, except, output); funlockfile(output); @@ -761,11 +761,11 @@ extern "C" { #endif // _di_fll_print_trim_except_dynamic_safely_ #ifndef _di_fll_print_trim_except_in_ - f_status_t fll_print_trim_except_in(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t fll_print_trim_except_in(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { flockfile(output); - const f_status_t status = fl_print_trim_except_in(string, length, except_at, except_in, output); + const f_status_t status = fl_print_trim_except_in(string, offset, length, except_at, except_in, output); funlockfile(output); @@ -774,11 +774,11 @@ extern "C" { #endif // _di_fll_print_trim_except_in_ #ifndef _di_fll_print_trim_except_in_raw_ - f_status_t fll_print_trim_except_in_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t fll_print_trim_except_in_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { flockfile(output); - const f_status_t status = fl_print_trim_except_in_raw(string, length, except_at, except_in, output); + const f_status_t status = fl_print_trim_except_in_raw(string, offset, length, except_at, except_in, output); funlockfile(output); @@ -787,11 +787,11 @@ extern "C" { #endif // _di_fll_print_trim_except_in_raw_ #ifndef _di_fll_print_trim_except_in_safely_ - f_status_t fll_print_trim_except_in_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { + f_status_t fll_print_trim_except_in_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output) { flockfile(output); - const f_status_t status = fl_print_trim_except_in_safely(string, length, except_at, except_in, output); + const f_status_t status = fl_print_trim_except_in_safely(string, offset, length, except_at, except_in, output); funlockfile(output); diff --git a/level_2/fll_print/c/print.h b/level_2/fll_print/c/print.h index 30938e3..3c51ae5 100644 --- a/level_2/fll_print/c/print.h +++ b/level_2/fll_print/c/print.h @@ -320,6 +320,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except @@ -339,7 +341,7 @@ extern "C" { * @see f_print_except() */ #ifndef _di_fll_print_except_ - extern f_status_t fll_print_except(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output); + extern f_status_t fll_print_except(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output); #endif // _di_fll_print_except_ /** @@ -347,6 +349,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except @@ -366,7 +370,7 @@ extern "C" { * @see f_print_except_raw() */ #ifndef _di_fll_print_except_raw_ - extern f_status_t fll_print_except_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output); + extern f_status_t fll_print_except_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output); #endif // _di_fll_print_except_raw_ /** @@ -374,6 +378,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except @@ -393,7 +399,7 @@ extern "C" { * @see f_print_except_safely() */ #ifndef _di_fll_print_except_safely_ - extern f_status_t fll_print_except_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output); + extern f_status_t fll_print_except_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output); #endif // _di_fll_print_except_safely_ /** @@ -476,6 +482,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -498,7 +506,7 @@ extern "C" { * @see f_print_except_in() */ #ifndef _di_fll_print_except_in_ - extern f_status_t fll_print_except_in(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); + extern f_status_t fll_print_except_in(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); #endif // _di_fll_print_except_in_ /** @@ -506,6 +514,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -528,7 +538,7 @@ extern "C" { * @see f_print_except_in_raw() */ #ifndef _di_fll_print_except_in_raw_ - extern f_status_t fll_print_except_in_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); + extern f_status_t fll_print_except_in_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); #endif // _di_fll_print_except_in_raw_ /** @@ -536,6 +546,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -558,7 +570,7 @@ extern "C" { * @see f_print_except_in_safely() */ #ifndef _di_fll_print_except_in_safely_ - extern f_status_t fll_print_except_in_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); + extern f_status_t fll_print_except_in_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); #endif // _di_fll_print_except_in_safely_ /** @@ -1277,6 +1289,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except @@ -1296,7 +1310,7 @@ extern "C" { * @see fl_print_trim_except() */ #ifndef _di_fll_print_trim_except_ - extern f_status_t fll_print_trim_except(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output); + extern f_status_t fll_print_trim_except(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output); #endif // _di_fll_print_trim_except_ /** @@ -1304,6 +1318,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except @@ -1323,7 +1339,7 @@ extern "C" { * @see fl_print_trim_except_raw() */ #ifndef _di_fll_print_trim_except_raw_ - extern f_status_t fll_print_trim_except_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output); + extern f_status_t fll_print_trim_except_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output); #endif // _di_fll_print_trim_except_raw_ /** @@ -1331,6 +1347,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except @@ -1350,7 +1368,7 @@ extern "C" { * @see fl_print_trim_except_safely() */ #ifndef _di_fll_print_trim_except_safely_ - extern f_status_t fll_print_trim_except_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except, FILE *output); + extern f_status_t fll_print_trim_except_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, FILE *output); #endif // _di_fll_print_trim_except_safely_ /** @@ -1433,6 +1451,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -1455,7 +1475,7 @@ extern "C" { * @see fl_print_trim_except_in() */ #ifndef _di_fll_print_trim_except_in_ - extern f_status_t fll_print_trim_except_in(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); + extern f_status_t fll_print_trim_except_in(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); #endif // _di_fll_print_trim_except_in_ /** @@ -1463,6 +1483,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -1485,7 +1507,7 @@ extern "C" { * @see fl_print_trim_except_in_raw() */ #ifndef _di_fll_print_trim_except_in_raw_ - extern f_status_t fll_print_trim_except_in_raw(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); + extern f_status_t fll_print_trim_except_in_raw(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); #endif // _di_fll_print_trim_except_in_raw_ /** @@ -1493,6 +1515,8 @@ extern "C" { * * @param string * The string to output. + * @param offset + * The inclusive start point to start printing. * @param length * The total number of characters to print. * @param except_at @@ -1515,7 +1539,7 @@ extern "C" { * @see fl_print_trim_except_in_safely() */ #ifndef _di_fll_print_trim_except_in_safely_ - extern f_status_t fll_print_trim_except_in_safely(const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); + extern f_status_t fll_print_trim_except_in_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, FILE *output); #endif // _di_fll_print_trim_except_in_safely_ /** diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index 7e17166..dc74c1f 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -173,7 +173,7 @@ extern "C" { flockfile(main->error.to.stream); fl_print_string("%c%[%SThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context); - fl_print_string("%[%s%s%]", main->error.to.stream, main->context.notable, f_console_symbol_long_enable_s, controller_long_settings, main->context.notable); + fl_print_string("%[%s%s%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_settings, main->context.set.notable); fl_print_string("%[' 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); @@ -203,44 +203,46 @@ extern "C" { } } - if (main->parameters[controller_parameter_pid].result == f_console_result_found) { - if (main->error.verbosity != f_console_verbosity_quiet) { - flockfile(main->error.to.stream); + if (F_status_is_error_not(status)) { + if (main->parameters[controller_parameter_pid].result == f_console_result_found) { + if (main->error.verbosity != f_console_verbosity_quiet) { + flockfile(main->error.to.stream); - fl_print_string("%c%[%SThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context); - fl_print_string("%[%s%s%]", main->error.to.stream, main->context.notable, f_console_symbol_long_enable_s, controller_long_pid, main->context.notable); - fl_print_string("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + fl_print_string("%c%[%SThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context); + fl_print_string("%[%s%s%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_pid, main->context.set.notable); + fl_print_string("%[' 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); - } + funlockfile(main->error.to.stream); + } - status = F_status_set_error(F_parameter); - } - else if (main->parameters[controller_parameter_pid].locations.used) { - const f_array_length_t location = main->parameters[controller_parameter_pid].values.array[main->parameters[controller_parameter_pid].values.used - 1]; + status = F_status_set_error(F_parameter); + } + else if (main->parameters[controller_parameter_pid].locations.used) { + const f_array_length_t location = main->parameters[controller_parameter_pid].values.array[main->parameters[controller_parameter_pid].values.used - 1]; - if (strnlen(arguments.argv[location], f_console_parameter_size)) { - status = fll_path_canonical(arguments.argv[location], &setting.path_pid); + if (strnlen(arguments.argv[location], f_console_parameter_size)) { + status = fll_path_canonical(arguments.argv[location], &setting.path_pid); - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_path_canonical", F_true); + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "fll_path_canonical", F_true); + } } - } - else { - if (main->warning.verbosity == f_console_verbosity_debug) { - flockfile(main->warning.to.stream); + else { + if (main->warning.verbosity == f_console_verbosity_debug) { + flockfile(main->warning.to.stream); - fl_print_string("%c%[%SThe parameter '%]", main->warning.to.stream, f_string_eol_s[0], main->warning.context, main->warning.prefix ? main->warning.prefix : f_string_empty_s, main->warning.context); - fl_print_string("%[%s%s%]", main->warning.to.stream, main->context.notable, f_console_symbol_long_enable_s, controller_long_pid, main->context.notable); - fl_print_string("%[' must be a file path but instead is an empty string, falling back to the default.%]%c", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s[0]); + fl_print_string("%c%[%SThe parameter '%]", main->warning.to.stream, f_string_eol_s[0], main->warning.context, main->warning.prefix ? main->warning.prefix : f_string_empty_s, main->warning.context); + fl_print_string("%[%s%s%]", main->warning.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_pid, main->context.set.notable); + fl_print_string("%[' must be a file path but instead is an empty string, falling back to the default.%]%c", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s[0]); - funlockfile(main->warning.to.stream); + funlockfile(main->warning.to.stream); + } } } } // a pid file path is required. - if (!setting.path_pid.used) { + if (F_status_is_error_not(status) && !setting.path_pid.used) { if (main->parameters[controller_parameter_init].result == f_console_result_found) { status = f_string_append(controller_path_pid_init, controller_path_pid_init_length, &setting.path_pid); @@ -262,64 +264,66 @@ extern "C" { } } - if (main->parameters[controller_parameter_control].result == f_console_result_found) { - if (main->error.verbosity != f_console_verbosity_quiet) { - flockfile(main->error.to.stream); - - fl_print_string("%c%[%SThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context); - fl_print_string("%[%s%s%]", main->error.to.stream, main->context.notable, f_console_symbol_long_enable_s, controller_long_control, main->context.notable); - fl_print_string("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + if (F_status_is_error_not(status)) { + if (main->parameters[controller_parameter_control].result == f_console_result_found) { + if (main->error.verbosity != f_console_verbosity_quiet) { + flockfile(main->error.to.stream); - funlockfile(main->error.to.stream); - } + fl_print_string("%c%[%SThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context); + fl_print_string("%[%s%s%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_control, main->context.set.notable); + fl_print_string("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); - status = F_status_set_error(F_parameter); - } - else if (main->parameters[controller_parameter_control].locations.used) { - const f_array_length_t location = main->parameters[controller_parameter_control].values.array[main->parameters[controller_parameter_control].values.used - 1]; + funlockfile(main->error.to.stream); + } - if (strnlen(arguments.argv[location], f_console_parameter_size)) { - status = fll_path_canonical(arguments.argv[location], &setting.path_control); + status = F_status_set_error(F_parameter); + } + else if (main->parameters[controller_parameter_control].locations.used) { + const f_array_length_t location = main->parameters[controller_parameter_control].values.array[main->parameters[controller_parameter_control].values.used - 1]; - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_path_canonical", F_true); - } - else { - status = f_string_append_assure(f_path_separator, 1, &setting.path_control); + if (strnlen(arguments.argv[location], f_console_parameter_size)) { + status = fll_path_canonical(arguments.argv[location], &setting.path_control); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append_assure", F_true); + fll_error_print(main->error, F_status_set_fine(status), "fll_path_canonical", F_true); } else { - status = f_string_dynamic_terminate_after(&setting.path_control); + status = f_string_append_assure(f_path_separator, 1, &setting.path_control); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_append_assure", F_true); + } + else { + status = f_string_dynamic_terminate_after(&setting.path_control); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true); + } } } } - } - else { - if (main->warning.verbosity == f_console_verbosity_debug) { - flockfile(main->warning.to.stream); + else { + if (main->warning.verbosity == f_console_verbosity_debug) { + flockfile(main->warning.to.stream); - fl_print_string("%c%[%SThe parameter '%]", main->warning.to.stream, f_string_eol_s[0], main->warning.context, main->warning.prefix ? main->warning.prefix : f_string_empty_s, main->warning.context); - fl_print_string("%[%s%s%]", main->warning.to.stream, main->context.notable, f_console_symbol_long_enable_s, controller_long_control, main->context.notable); - fl_print_string("%[' must be a file directory path but instead is an empty string, falling back to the default.%]%c", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s[0]); + fl_print_string("%c%[%SThe parameter '%]", main->warning.to.stream, f_string_eol_s[0], main->warning.context, main->warning.prefix ? main->warning.prefix : f_string_empty_s, main->warning.context); + fl_print_string("%[%s%s%]", main->warning.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_control, main->context.set.notable); + fl_print_string("%[' must be a file directory path but instead is an empty string, falling back to the default.%]%c", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s[0]); - funlockfile(main->warning.to.stream); + funlockfile(main->warning.to.stream); + } } } } - if (main->parameters[controller_parameter_daemon].result == f_console_result_found) { + if (F_status_is_error_not(status) && main->parameters[controller_parameter_daemon].result == f_console_result_found) { if (main->parameters[controller_parameter_validate].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { flockfile(main->error.to.stream); fl_print_string("%c%[%SThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context); fl_print_string("%[' must not be specified with the parameter '%]", main->error.to.stream, main->error.context, main->error.context); - fl_print_string("%[%s%s%]", main->error.to.stream, main->context.notable, f_console_symbol_long_enable_s, controller_long_daemon, main->context.notable); + fl_print_string("%[%s%s%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_daemon, main->context.set.notable); fl_print_string("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); funlockfile(main->error.to.stream); @@ -376,10 +380,10 @@ extern "C" { status = controller_thread_main(main, &setting); } - // ensure a newline is always put at the end of the program execution, unless in quiet mode. + // Ensure a newline is always put at the end of the program execution, unless in quiet mode. if (!(status == F_child || status == F_signal)) { if (F_status_is_error(status) && main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); + f_print_terminated(f_string_eol_s, main->error.to.stream); } } diff --git a/level_3/controller/c/private-common.c b/level_3/controller/c/private-common.c index 271fc31..e773aca 100644 --- a/level_3/controller/c/private-common.c +++ b/level_3/controller/c/private-common.c @@ -97,6 +97,7 @@ extern "C" { const f_string_t controller_string_use_s = controller_string_use; const f_string_t controller_string_user_s = controller_string_user; const f_string_t controller_string_utility_s = controller_string_utility; + const f_string_t controller_string_value_s = controller_string_value; const f_string_t controller_string_wait_s = controller_string_wait; const f_string_t controller_string_want_s = controller_string_want; const f_string_t controller_string_wish_s = controller_string_wish; diff --git a/level_3/controller/c/private-common.h b/level_3/controller/c/private-common.h index 4725868..4413b70 100644 --- a/level_3/controller/c/private-common.h +++ b/level_3/controller/c/private-common.h @@ -107,6 +107,7 @@ extern "C" { #define controller_string_use "use" #define controller_string_user "user" #define controller_string_utility "utility" + #define controller_string_value "value" #define controller_string_wait "wait" #define controller_string_want "want" #define controller_string_wish "wish" @@ -201,6 +202,7 @@ extern "C" { #define controller_string_use_length 3 #define controller_string_user_length 4 #define controller_string_utility_length 7 + #define controller_string_value_length 5 #define controller_string_wait_length 4 #define controller_string_want_length 4 #define controller_string_wish_length 4 @@ -296,6 +298,7 @@ extern "C" { extern const f_string_t controller_string_use_s; extern const f_string_t controller_string_user_s; extern const f_string_t controller_string_utility_s; + extern const f_string_t controller_string_value_s; extern const f_string_t controller_string_wait_s; extern const f_string_t controller_string_want_s; extern const f_string_t controller_string_wish_s; diff --git a/level_3/controller/c/private-controller.c b/level_3/controller/c/private-controller.c index c965ccd..647fa65 100644 --- a/level_3/controller/c/private-controller.c +++ b/level_3/controller/c/private-controller.c @@ -194,7 +194,7 @@ extern "C" { status = f_file_stream_open(path.string, f_file_open_mode_truncate_s, &file); if (F_status_is_error(status)) return status; - fprintf(file.stream, "%d%c", pid, f_string_eol_s[0]); + fll_print_string("%i%c", file.stream, pid, f_string_eol_s[0]); f_file_stream_close(F_true, &file); @@ -532,13 +532,16 @@ extern "C" { if (global.main->warning.verbosity == f_console_verbosity_debug) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->warning.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->warning.to.stream, "%s%sMultiple '", global.main->warning.context.before->string, global.main->warning.prefix ? global.main->warning.prefix : f_string_empty_s); - fprintf(global.main->warning.to.stream, "%s%s%s%s", global.main->warning.context.after->string, global.main->warning.notable.before->string, controller_string_ready_s, global.main->warning.notable.after->string); - fprintf(global.main->warning.to.stream, "%s' %s item actions detected; only the first will be used.%s%c", global.main->warning.context.before->string, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->warning.context.after->string, f_string_eol_s[0]); + flockfile(global.main->warning.to.stream); + + fl_print_string("%c%[%sMultiple '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context); + fl_print_string("%[%s%]", global.main->warning.to.stream, global.main->warning.notable, controller_string_ready_s, global.main->warning.notable); + fl_print_string("%[' %s item actions detected; only the first will be used.%]%c", global.main->warning.to.stream, global.main->warning.context, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->warning.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global.main->warning, cache->action); + funlockfile(global.main->warning.to.stream); + controller_print_unlock_flush(global.main->warning.to.stream, &global.thread->lock.print); } } @@ -568,17 +571,16 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s item named '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - f_print_safely_terminated(global.main->error.to.stream, entry->items.array[i].name.string); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); + flockfile(global.main->error.to.stream); - fprintf(global.main->error.to.stream, "%s' cannot be executed because recursion is not allowed.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + fl_print_string("%c%[%sThe %s item named '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, entry->items.array[i].name, global.main->error.notable); + fl_print_string("%[' cannot be executed because recursion is not allowed.%]%c", global.main->error.to.stream, global.main->error.context, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global.main->error, cache->action); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -635,17 +637,16 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s item named '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - f_print_safely_terminated(global.main->error.to.stream, actions->array[cache->ats.array[at_j]].parameters.array[0].string); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); + flockfile(global.main->error.to.stream); - fprintf(global.main->error.to.stream, "%s' does not exist.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + fl_print_string("%c%[%sThe %s item named '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, actions->array[cache->ats.array[at_j]].parameters.array[0], global.main->error.notable); + fl_print_string("%[' does not exist.%]%c", global.main->error.to.stream, global.main->error.context, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global.main->error, cache->action); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -765,14 +766,12 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->output.stream, "Processing %s%s item '", (failsafe ? "failsafe " : ""), is_entry ? controller_string_entry_s : controller_string_exit_s); + flockfile(global->main->output.stream); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - f_print_safely_terminated(global.main->error.to.stream, cache->action.name_item.string); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); + fl_print_string("%cProcessing %s%s item '", global->main->output.stream, f_string_eol_s[0], failsafe ? "failsafe " : "", is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_string("%[%Q%]'.%c", global->main->output.stream, global->main->context.set.notable, cache->action.name_item, global->main->context.set.notable, f_string_eol_s[0]); - fprintf(global->main->output.stream, "'.%c", f_string_eol_s[0]); + funlockfile(global->main->output.stream); controller_print_unlock_flush(global->main->output.stream, &global->thread->lock.print); } @@ -803,111 +802,92 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->output.stream, "The %s item action '", is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.title.before->string, cache->action.name_action.string, global->main->context.set.title.after->string); + flockfile(global->main->output.stream); + + fl_print_string("%cThe %s item action '", global->main->output.stream, f_string_eol_s[0], is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_string("%[%Q%]", global->main->output.stream, global->main->context.set.title, cache->action.name_action, global->main->context.set.title); if (entry_action->parameters.used) { - fprintf(global->main->output.stream, "%s", f_string_space_s); - fprintf(global->main->output.stream, "%s", global->main->context.set.notable.before->string); + fl_print_string(" %[", global->main->output.stream, global->main->context.set.notable); + controller_entry_action_parameters_print(global->main->output.stream, entry_actions->array[cache->ats.array[at_j]]); - fprintf(global->main->output.stream, "%s", global->main->context.set.notable.after->string); + + fl_print_string("%]", global->main->output.stream, global->main->context.set.notable); } - fprintf(global->main->output.stream, "' is %s and is in a %sfailed%s state, skipping execution.%c", entry_action->code & controller_entry_rule_code_require ? "required" : "optional", global->main->error.context.before->string, global->main->error.context.after->string, f_string_eol_s[0]); + fl_print_string("' is %s and is in a %[failed%] state, skipping execution.%c", global->main->output.stream, entry_action->code & controller_entry_rule_code_require ? "required" : "optional", f_string_eol_s[0]); + + funlockfile(global->main->output.stream); controller_print_unlock_flush(global->main->output.stream, &global->thread->lock.print); } } - else if (entry_action->code & controller_entry_rule_code_require) { - if (global->main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global->thread->lock.print); - - fprintf(global->main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->error.to.stream, "%s%sThe %s item action '", global->main->error.context.before->string, global->main->error.prefix ? global->main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->error.to.stream, "%s%s%s", global->main->error.context.after->string, global->main->error.notable.before->string, cache->action.name_action.string); - - if (entry_action->parameters.used) { - fprintf(global->main->error.to.stream, "%s", f_string_space_s); - controller_entry_action_parameters_print(global->main->error.to.stream, entry_actions->array[cache->ats.array[at_j]]); - } - - fprintf(global->main->error.to.stream, "%s%s' is ", global->main->error.notable.after->string, global->main->error.context.before->string); - fprintf(global->main->error.to.stream, "%s%srequired%s", global->main->error.context.after->string, global->main->error.notable.before->string, global->main->error.notable.after->string); - fprintf(global->main->error.to.stream, "%s and is in a ", global->main->error.context.before->string); - fprintf(global->main->error.to.stream, "%s%sfailed%s", global->main->error.context.after->string, global->main->error.notable.before->string, global->main->error.notable.after->string); - fprintf(global->main->error.to.stream, "%s state, skipping execution.%s%c", global->main->error.context.before->string, global->main->error.context.after->string, f_string_eol_s[0]); - - controller_entry_error_print_cache(is_entry, global->main->error, cache->action); + else if ((entry_action->code & controller_entry_rule_code_require) && global->main->error.verbosity != f_console_verbosity_quiet || global->main->warning.verbosity == f_console_verbosity_verbose || global->main->warning.verbosity == f_console_verbosity_debug) { + fll_error_print_t *output = 0; - controller_print_unlock_flush(global->main->error.to.stream, &global->thread->lock.print); + if (entry_action->code & controller_entry_rule_code_require) { + output = &global->main->error; + } + else { + output = &global->main->warning; } - return F_status_is_error(F_require); - } - else if (global->main->warning.verbosity == f_console_verbosity_verbose || global->main->warning.verbosity == f_console_verbosity_debug) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->warning.to.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->warning.to.stream, "%s%sThe %s item action '", global->main->warning.context.before->string, global->main->warning.prefix ? global->main->warning.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->warning.to.stream, "%s%s%s", global->main->warning.context.after->string, global->main->warning.notable.before->string, cache->action.name_action.string); + flockfile(output->to.stream); + + fl_print_string("%c%[%SThe %s item action '%]", output->to.stream, f_string_eol_s[0], output->prefix ? output->prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_string("%[%Q%]", output->to.stream, output->notable, cache->action.name_action, output->notable); if (entry_action->parameters.used) { - fprintf(global->main->warning.to.stream, "%s", f_string_space_s); - controller_entry_action_parameters_print(global->main->warning.to.stream, entry_actions->array[cache->ats.array[at_j]]); + fl_print_string(" %[%S%]", output->to.stream, output->notable, entry_actions->array[cache->ats.array[at_j]], output->notable); } - fprintf(global->main->warning.to.stream, "%s%s' is ", global->main->warning.notable.after->string, global->main->warning.context.before->string); - fprintf(global->main->warning.to.stream, "%s%srequired%s", global->main->warning.context.after->string, global->main->warning.notable.before->string, global->main->warning.notable.after->string); - fprintf(global->main->warning.to.stream, "%s and is in a ", global->main->warning.context.before->string); - fprintf(global->main->warning.to.stream, "%s%sfailed%s", global->main->warning.context.after->string, global->main->warning.notable.before->string, global->main->warning.notable.after->string); - fprintf(global->main->warning.to.stream, "%s state, skipping execution.%s%c", global->main->warning.context.before->string, global->main->warning.context.after->string, f_string_eol_s[0]); + fl_print_string("%[' is%] %[required%]", output->to.stream, output->context, output->context, output->notable, output->notable); + fl_print_string(" %[and is in a%] %[failed%]", output->to.stream, output->context, output->context, output->notable, output->notable); + fl_print_string(" %[state, skipping execution.%]%c", output->to.stream, output->context, output->context, f_string_eol_s[0]); - controller_entry_error_print_cache(is_entry, global->main->warning, cache->action); + controller_entry_error_print_cache(is_entry, *output, cache->action); - controller_print_unlock_flush(global->main->warning.to.stream, &global->thread->lock.print); + funlockfile(output->to.stream); + + controller_print_unlock_flush(output->to.stream, &global->thread->lock.print); + + if (entry_action->code & controller_entry_rule_code_require) { + return F_status_is_error(F_require); + } } } else { - if (global->main->parameters[controller_parameter_simulate].result == f_console_result_found) { - if (global->main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global->thread->lock.print); - - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->output.stream, "The %s item action '", is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.title.before->string, cache->action.name_action.string, global->main->context.set.title.after->string); - - if (entry_action->parameters.used) { - fprintf(global->main->output.stream, "%s", f_string_space_s); - fprintf(global->main->output.stream, "%s", global->main->context.set.notable.before->string); - controller_entry_action_parameters_print(global->main->output.stream, entry_actions->array[cache->ats.array[at_j]]); - fprintf(global->main->output.stream, "%s", global->main->context.set.notable.after->string); - } - - fprintf(global->main->output.stream, "' is in a %sfailed%s state, skipping.%c", global->main->error.context.before->string, global->main->error.context.after->string, f_string_eol_s[0]); + if (global->main->parameters[controller_parameter_simulate].result == f_console_result_found && global->main->error.verbosity != f_console_verbosity_quiet || global->main->warning.verbosity == f_console_verbosity_debug || global->main->error.verbosity == f_console_verbosity_verbose) { + fll_error_print_t *output = 0; - controller_print_unlock_flush(global->main->output.stream, &global->thread->lock.print); + if (global->main->parameters[controller_parameter_simulate].result == f_console_result_found && global->main->error.verbosity != f_console_verbosity_quiet) { + output = &global->main->error; } - } - else if (global->main->warning.verbosity == f_console_verbosity_debug || global->main->error.verbosity == f_console_verbosity_verbose) { + else { + output = &global->main->warning; + } + f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->warning.to.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->warning.to.stream, "%s%sThe %s item action '", global->main->warning.context.before->string, global->main->warning.prefix ? global->main->warning.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->warning.to.stream, "%s%s", global->main->warning.notable.before->string, cache->action.name_action.string); + flockfile(output->to.stream); + + fl_print_string("%c%[%SThe %s item action '%]", output->to.stream, f_string_eol_s[0], output->prefix ? output->prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_string("%[%Q%]", output->to.stream, output->notable, cache->action.name_action, output->notable); if (entry_action->parameters.used) { - fprintf(global->main->warning.to.stream, "%s", f_string_space_s); - controller_entry_action_parameters_print(global->main->warning.to.stream, entry_actions->array[cache->ats.array[at_j]]); + fl_print_string(" %[%S%]", output->to.stream, output->notable, entry_actions->array[cache->ats.array[at_j]], output->notable); } - fprintf(global->main->warning.to.stream, "%s' is in a ", global->main->warning.notable.after->string); - fprintf(global->main->warning.to.stream, "%s%sfailed%s", global->main->warning.context.after->string, global->main->warning.notable.before->string, global->main->warning.notable.after->string); - fprintf(global->main->warning.to.stream, "%s state, skipping.%s%c", global->main->warning.context.before->string, global->main->warning.context.after->string, f_string_eol_s[0]); + fl_print_string(" %[is in a%] %[failed%]", output->to.stream, output->context, output->context, output->notable, output->notable); + fl_print_string(" %[state, skipping.%]%c", output->to.stream, output->context, output->context, f_string_eol_s[0]); - controller_entry_error_print_cache(is_entry, global->main->warning, cache->action); + controller_entry_error_print_cache(is_entry, *output, cache->action); - controller_print_unlock_flush(global->main->warning.to.stream, &global->thread->lock.print); + funlockfile(output->to.stream); + + controller_print_unlock_flush(output->to.stream, &global->thread->lock.print); } } @@ -920,10 +900,13 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->output.stream, "Waiting before processing %s item action '", is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.title.before->string, controller_string_ready_s, global->main->context.set.title.after->string); - fprintf(global->main->output.stream, "'.%c", f_string_eol_s[0]); + flockfile(global->main->output.stream); + + fl_print_string("%cWaiting before processing %s item action '", global->main->output.stream, f_string_eol_s[0], is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_string("%[%s%]", global->main->output.stream, global->main->context.set.title, controller_string_ready_s, global->main->context.set.title); + fl_print_string("'.%c", global->main->output.stream, f_string_eol_s[0]); + + funlockfile(global->main->output.stream); controller_print_unlock_flush(global->main->output.stream, &global->thread->lock.print); } @@ -939,10 +922,13 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->output.stream, "Processing %s item action '", is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.title.before->string, controller_string_ready_s, global->main->context.set.title.after->string); - fprintf(global->main->output.stream, "'.%c", f_string_eol_s[0]); + flockfile(global->main->output.stream); + + fl_print_string("%cWaiting before processing %s item action '", global->main->output.stream, f_string_eol_s[0], is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_string("%[%s%]", global->main->output.stream, global->main->context.set.title, controller_string_ready_s, global->main->context.set.title); + fl_print_string("'.%c", global->main->output.stream, f_string_eol_s[0]); + + funlockfile(global->main->output.stream); controller_print_unlock_flush(global->main->output.stream, &global->thread->lock.print); } @@ -960,10 +946,13 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->output.stream, "Ignoring %s item action '", is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.title.before->string, controller_string_ready_s, global->main->context.set.title.after->string); - fprintf(global->main->output.stream, "', state already is ready.%c", f_string_eol_s[0]); + flockfile(global->main->output.stream); + + fl_print_string("%cIgnoring %s item action '", global->main->output.stream, f_string_eol_s[0], is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_string("%[%s%]", global->main->output.stream, global->main->context.set.title, controller_string_ready_s, global->main->context.set.title); + fl_print_string("', state already is ready.%c", global->main->output.stream, f_string_eol_s[0]); + + funlockfile(global->main->output.stream); controller_print_unlock_flush(global->main->output.stream, &global->thread->lock.print); } @@ -972,17 +961,20 @@ extern "C" { else if (entry_action->type == controller_entry_action_type_item) { if (entry_action->number == 0 || entry_action->number >= entry->items.used || failsafe && entry_action->number == global->setting->failsafe_item_id) { - // This should not happen if the pre-process is working as designed, but in case it doesn't, return a critical error to prevent infinite recursion and similar errors. + // This should not happen if the pre-process is working as intended, but in case it doesn't, return a critical error to prevent infinite recursion and similar errors. if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->error.to.stream, "%s%sInvalid %s item index ", global->main->error.context.before->string, global->main->error.prefix ? global->main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->error.to.stream, "%s%s%llu%s", global->main->error.context.after->string, global->main->error.notable.before->string, entry_action->number, global->main->error.notable.after->string); - fprintf(global->main->error.to.stream, "%s detected.%s%c", global->main->error.context.before->string, global->main->error.context.after->string, f_string_eol_s[0]); + flockfile(global->main->error.to.stream); + + fl_print_string("%c%[Invalid %s item index '%]", global->main->error.to.stream, f_string_eol_s[0], global->main->error.context, is_entry ? controller_string_entry_s : controller_string_exit_s, global->main->error.context); + fl_print_string("%[%ul%]", global->main->error.to.stream, global->main->error.notable, entry_action->number, global->main->error.notable); + fl_print_string("%[' detected.%]%c", global->main->error.to.stream, global->main->error.context, global->main->error.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global->main->error, cache->action); + funlockfile(global->main->error.to.stream); + controller_print_unlock_flush(global->main->error.to.stream, &global->thread->lock.print); } @@ -1024,10 +1016,13 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->output.stream, "Processing %s item '", is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.title.before->string, cache->action.name_item.string, global->main->context.set.title.after->string); - fprintf(global->main->output.stream, "'.%c", f_string_eol_s[0]); + flockfile(global->main->output.stream); + + fl_print_string("%cProcessing %s item '", global->main->output.stream, f_string_eol_s[0], is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_string("%[%Q%]", global->main->output.stream, global->main->context.set.title, cache->action.name_item, global->main->context.set.title); + fl_print_string("'.%c", global->main->output.stream, f_string_eol_s[0]); + + funlockfile(global->main->output.stream); controller_print_unlock_flush(global->main->output.stream, &global->thread->lock.print); } @@ -1081,10 +1076,13 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->output.stream, "%s %s item rule '", entry_action->type == controller_entry_action_type_consider ? "Considering" : "Processing", is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.title.before->string, alias_rule.string, global->main->context.set.title.after->string); - fprintf(global->main->output.stream, "'.%c", f_string_eol_s[0]); + flockfile(global->main->output.stream); + + fl_print_string("%c%s %s item rule '", global->main->output.stream, f_string_eol_s[0], entry_action->type == controller_entry_action_type_consider ? "Considering" : "Processing", is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_string("%[%Q%]", global->main->output.stream, global->main->context.set.title, alias_rule, global->main->context.set.title); + fl_print_string("'.%c", global->main->output.stream, f_string_eol_s[0]); + + funlockfile(global->main->output.stream); controller_print_unlock_flush(global->main->output.stream, &global->thread->lock.print); } @@ -1212,19 +1210,22 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->output.stream, "%s is executing '", is_entry ? controller_string_entry_s : controller_string_exit_s); + flockfile(global->main->output.stream); + + fl_print_string("%c%s is executing '", global->main->output.stream, f_string_eol_s[0], is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->output.stream, "%s", global->main->context.set.title.before->string); for (f_array_length_t k = 0; k < entry_action->parameters.used; ++k) { - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.title.before->string, entry_action->parameters.array[k].string, global->main->context.set.title.after->string); + fl_print_string("%[%Q%]", global->main->output.stream, global->main->context.set.title, entry_action->parameters.array[k], global->main->context.set.title); if (k + 1 < entry_action->parameters.used) { - fprintf(global->main->output.stream, " "); + f_print_character(f_string_space_s[0], global->main->output.stream); } } // for - fprintf(global->main->output.stream, "%s'.%c", global->main->context.set.title.after->string, f_string_eol_s[0]); + + fl_print_string("'.%c", global->main->output.stream, f_string_eol_s[0]); + + funlockfile(global->main->output.stream); controller_print_unlock_flush(global->main->output.stream, &global->thread->lock.print); } @@ -1245,13 +1246,16 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->error.to.stream, "%s%sExecution failed, unable to find program or script ", global->main->error.context.before->string, global->main->error.prefix ? global->main->error.prefix : f_string_empty_s); - fprintf(global->main->error.to.stream, "%s%s%s%s", global->main->error.context.after->string, global->main->error.notable.before->string, entry_action->parameters.array[0].string, global->main->error.notable.after->string); - fprintf(global->main->error.to.stream, "%s.%s%c", global->main->error.context.before->string, global->main->error.context.after->string, f_string_eol_s[0]); + flockfile(global->main->error.to.stream); + + fl_print_string("%c%[%SExecution failed, unable to find program or script '%]", global->main->error.to.stream, f_string_eol_s[0], global->main->error.context, global->main->error.prefix ? global->main->error.prefix : f_string_empty_s, global->main->error.context); + fl_print_string("%[%Q%]", global->main->error.to.stream, global->main->error.notable, entry_action->parameters.array[0], global->main->error.notable); + fl_print_string("$['.%]%c", global->main->error.to.stream, global->main->error.context, global->main->error.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global->main->error, cache->action); + funlockfile(global->main->error.to.stream); + controller_print_unlock_flush(global->main->error.to.stream, &global->thread->lock.print); } } @@ -1265,13 +1269,16 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->error.to.stream, "%s%sExecution failed with return value of ", global->main->error.context.before->string, global->main->error.prefix ? global->main->error.prefix : f_string_empty_s); - fprintf(global->main->error.to.stream, "%s%s%d%s", global->main->error.context.after->string, global->main->error.notable.before->string, result, global->main->error.notable.after->string); - fprintf(global->main->error.to.stream, "%s.%s%c", global->main->error.context.before->string, global->main->error.context.after->string, f_string_eol_s[0]); + flockfile(global->main->error.to.stream); + + fl_print_string("%c%[%SExecution failed with return value of '%]", global->main->error.to.stream, f_string_eol_s[0], global->main->error.context, global->main->error.prefix ? global->main->error.prefix : f_string_empty_s, global->main->error.context); + fl_print_string("%[%i%]", global->main->error.to.stream, global->main->error.notable, result, global->main->error.notable); + fl_print_string("$['.%]%c", global->main->error.to.stream, global->main->error.context, global->main->error.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global->main->error, cache->action); + funlockfile(global->main->error.to.stream); + controller_print_unlock_flush(global->main->error.to.stream, &global->thread->lock.print); } @@ -1298,14 +1305,14 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->output.stream, "Processing %s item action '", is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.title.before->string, controller_string_timeout_s, global->main->context.set.title.after->string); - fprintf(global->main->output.stream, "' setting '"); - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.important.before->string, code, global->main->context.set.important.after->string); - fprintf(global->main->output.stream, "' to '"); - fprintf(global->main->output.stream, "%s%llu%s", global->main->context.set.important.before->string, entry_action->number, global->main->context.set.important.after->string); - fprintf(global->main->output.stream, "' MegaTime (milliseconds).%c", f_string_eol_s[0]); + flockfile(global->main->output.stream); + + fl_print_string("%cProcessing %s item action '", global->main->output.stream, f_string_eol_s[0], is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_string("%[%s%]' setting '", global->main->output.stream, global->main->context.set.title, controller_string_timeout_s, global->main->context.set.title); + fl_print_string("%[%S%]' to '", global->main->output.stream, global->main->context.set.important, code, global->main->context.set.important); + fl_print_string("%[%ul%]' MegaTime (milliseconds).%c", global->main->output.stream, global->main->context.set.important, entry_action->number, global->main->context.set.important, f_string_eol_s[0]); + + funlockfile(global->main->output.stream); controller_print_unlock_flush(global->main->output.stream, &global->thread->lock.print); } @@ -1327,11 +1334,14 @@ extern "C" { if (global->main->warning.verbosity == f_console_verbosity_debug) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->warning.to.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->warning.to.stream, "%s%sFailsafe may not be specified when running in failsafe, ignoring.%s%c", global->main->warning.context.before->string, global->main->warning.prefix ? global->main->warning.prefix : f_string_empty_s, global->main->warning.context.after->string, f_string_eol_s[0]); + flockfile(global->main->error.to.stream); + + fl_print_string("%c%[%SFailsafe may not be specified when running in failsafe, ignoring.%]%c", global->main->warning.to.stream, f_string_eol_s[0], global->main->warning.context, global->main->warning.prefix ? global->main->warning.prefix : f_string_empty_s, global->main->warning.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global->main->warning, cache->action); + funlockfile(global->main->warning.to.stream); + controller_print_unlock_flush(global->main->warning.to.stream, &global->thread->lock.print); } } @@ -1342,13 +1352,16 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->error.to.stream, "%s%sInvalid %s item index ", global->main->error.context.before->string, global->main->error.prefix ? global->main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->error.to.stream, "%s%s%llu%s", global->main->error.context.after->string, global->main->error.notable.before->string, entry_action->number, global->main->error.notable.after->string); - fprintf(global->main->error.to.stream, "%s detected.%s%c", global->main->error.context.before->string, global->main->error.context.after->string, f_string_eol_s[0]); + flockfile(global->main->error.to.stream); + + fl_print_string("%c%[%SInvalid %s item index '%]", global->main->error.to.stream, f_string_eol_s[0], global->main->error.context, global->main->error.prefix ? global->main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s, global->main->error.context); + fl_print_string("%[%ul%]", global->main->error.to.stream, global->main->error.notable, entry_action->number, global->main->error.notable); + fl_print_string("%[' detected.%]%c", global->main->error.to.stream, global->main->error.context, global->main->error.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global->main->error, cache->action); + funlockfile(global->main->error.to.stream); + controller_print_unlock_flush(global->main->error.to.stream, &global->thread->lock.print); } @@ -1362,12 +1375,14 @@ extern "C" { if (global->main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->output.stream, "Processing %s item action '", is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.title.before->string, controller_string_failsafe_s, global->main->context.set.title.after->string); - fprintf(global->main->output.stream, "' setting value to '"); - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.important.before->string, entry->items.array[global->setting->failsafe_item_id].name.string, global->main->context.set.important.after->string); - fprintf(global->main->output.stream, "'.%c", f_string_eol_s[0]); + flockfile(global->main->output.stream); + + fl_print_string("%cProcessing %s item action '", global->main->output.stream, f_string_eol_s[0], is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_string("%[%s%]' setting value to '", global->main->output.stream, global->main->context.set.title, controller_string_failsafe_s, global->main->context.set.title); + fl_print_string("%[%Q%]", global->main->output.stream, global->main->context.set.important, entry->items.array[global->setting->failsafe_item_id].name, global->main->context.set.important); + fl_print_string("'.%c", global->main->output.stream, f_string_eol_s[0]); + + funlockfile(global->main->output.stream); controller_print_unlock_flush(global->main->output.stream, &global->thread->lock.print); } @@ -1441,16 +1456,19 @@ extern "C" { if ((global->main->parameters[controller_parameter_simulate].result == f_console_result_found && global->main->error.verbosity != f_console_verbosity_quiet) || global->main->error.verbosity == f_console_verbosity_verbose) { f_thread_mutex_lock(&global->thread->lock.print); - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global->main->output.stream, "Done processing %s item '", is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global->main->output.stream, "%s%s%s", global->main->context.set.title.before->string, controller_string_main_s, global->main->context.set.title.after->string); - fprintf(global->main->output.stream, "'.%c", f_string_eol_s[0]); + flockfile(global->main->output.stream); + + fl_print_string("%cDone processing %s item '", global->main->output.stream, f_string_eol_s[0], is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_string("%[%s%]", global->main->output.stream, global->main->context.set.title, controller_string_main_s, global->main->context.set.title); + fl_print_string("'.%c", global->main->output.stream, f_string_eol_s[0]); // failsafe should not print the extra newline because the failure exit from controller_main should handle this. if (!failsafe) { - fprintf(global->main->output.stream, "%c", f_string_eol_s[0]); + f_print_terminated(f_string_eol_s, global->main->output.stream); } + funlockfile(global->main->output.stream); + controller_print_unlock_flush(global->main->output.stream, &global->thread->lock.print); } diff --git a/level_3/controller/c/private-entry.c b/level_3/controller/c/private-entry.c index e565d00..66c2f54 100644 --- a/level_3/controller/c/private-entry.c +++ b/level_3/controller/c/private-entry.c @@ -15,14 +15,13 @@ extern "C" { for (;;) { - // @fixme there needs to be a dynamic string equivalent of: f_print_safely_terminated(). - fll_print_dynamic(stream, action.parameters.array[index]); + f_print_dynamic_safely(action.parameters.array[index], stream); ++index; if (index == action.parameters.used) break; - fprintf(stream, "%s", f_string_space_s); + f_print_terminated(f_string_space_s, stream); } // for } #endif // _di_controller_entry_action_parameters_print_ @@ -330,13 +329,15 @@ extern "C" { } else { if (global.main->warning.verbosity == f_console_verbosity_debug) { - fprintf(global.main->warning.to.stream, "%s%sUnknown %s item action '", global.main->warning.context.before->string, global.main->warning.prefix ? global.main->warning.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global.main->warning.to.stream, "%s%s", global.main->warning.context.after->string, global.main->warning.notable.before->string); - fll_print_dynamic(global.main->warning.to.stream, cache->action.name_action); // @todo needs a f_print_safely_terminated(). - fprintf(global.main->warning.to.stream, "%s", global.main->warning.notable.after->string); - fprintf(global.main->warning.to.stream, "%s'.%s%c", global.main->warning.context.before->string, global.main->warning.context.after->string, f_string_eol_s[0]); + flockfile(global.main->warning.to.stream); + + fl_print_string("%c%[%SUnknown %s item action '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->warning.context); + fl_print_string("%[%S%]'", global.main->warning.to.stream, global.main->warning.notable, cache->action.name_action, global.main->warning.notable); + fl_print_string("%['.%]%c", global.main->warning.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global.main->warning, cache->action); + + funlockfile(global.main->warning.to.stream); } continue; @@ -372,34 +373,33 @@ extern "C" { action->status = F_status_set_error(F_parameter); if (global.main->error.verbosity != f_console_verbosity_quiet) { - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s item action '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - f_print_safely_terminated(global.main->error.to.stream, cache->action.name_action.string); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); + flockfile(global.main->error.to.stream); - fprintf(global.main->error.to.stream, "%s' requires ", global.main->error.context.before->string); + fl_print_string("%c%[%SThe %s item action '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.context, cache->action.name_action, global.main->error.context); + fl_print_string("%[' requires ", global.main->error.to.stream, global.main->error.context); if (at_least == at_most) { - fprintf(global.main->error.to.stream, "exactly "); + f_print_terminated("exactly ", global.main->error.to.stream); } - fprintf(global.main->error.to.stream, "%s%s%llu%s", global.main->error.context.after->string, global.main->error.notable.before->string, at_least, global.main->error.notable.after->string); + fl_print_string("%]%[%ul%]", global.main->error.to.stream, global.main->error.context, global.main->error.notable, at_least, global.main->error.notable); if (action->type == controller_entry_action_type_consider || controller_entry_action_type_is_rule(action->type)) { - fprintf(global.main->error.to.stream, "%s or more parameters.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + fl_print_string("%[' or more parameters.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); } else { if (at_least == at_most) { - fprintf(global.main->error.to.stream, "%s parameters.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + fl_print_string("%[' parameters.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); } else { - fprintf(global.main->error.to.stream, "%s to ", global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s%llu%s", global.main->error.context.after->string, global.main->error.notable.before->string, at_most, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s parameters.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + fl_print_string("%[ to %]", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[%ul%]", global.main->error.to.stream, global.main->error.notable, at_most, global.main->error.notable); + fl_print_string("%[' parameters.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); } } + + funlockfile(global.main->error.to.stream); } } else { @@ -480,8 +480,7 @@ extern "C" { } if (global.main->error.verbosity != f_console_verbosity_quiet) { - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s item action must not have an empty string for a path (the first parameter).%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context.after->string, f_string_eol_s[0]); + fll_print_string("%c%[%SThe %s item action must not have an empty string for a path (the first parameter).%]%c", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context, f_string_eol_s[0]); } } @@ -522,16 +521,15 @@ extern "C" { break; } - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s item action second parameter '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); + flockfile(global.main->error.to.stream); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - f_print_safely_terminated(global.main->error.to.stream, action->parameters.array[1].string); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); + fl_print_string("%c%[%SThe %s item action second parameter '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, action->parameters.array[1], global.main->error.notable); + fl_print_string("%[' must be a base path name, such as '%]", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_path, global.main->error.notable); + fl_print_string("%['.%]", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s' must be a base path name, such as '", global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, cache->buffer_path.string, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s'.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + funlockfile(global.main->error.to.stream); } action->status = F_status_set_error(F_parameter); @@ -550,8 +548,7 @@ extern "C" { } if (global.main->error.verbosity != f_console_verbosity_quiet) { - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s item action must not have an empty string for a rule name (the second parameter).%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context.after->string, f_string_eol_s[0]); + fll_print_string("%c%[%SThe %s item action must not have an empty string for a rule name (the second parameter).%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context, f_string_eol_s[0]); } } @@ -576,20 +573,19 @@ extern "C" { } if (global.main->error.verbosity != f_console_verbosity_quiet) { - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s item action third parameter (and beyond) must be one of '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, controller_string_asynchronous_s, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s', '", global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, controller_string_require_s, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s', or '", global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, controller_string_wait_s, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' but instead has '", global.main->error.context.before->string); - - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - f_print_safely_terminated(global.main->error.to.stream, action->parameters.array[j].string); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - - fprintf(global.main->error.to.stream, "%s'.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SThe %s item action third parameter (and beyond) must be one of '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context); + fl_print_string("%[%s%]", global.main->error.to.stream, global.main->error.notable, controller_string_asynchronous_s, global.main->error.notable); + fl_print_string("%[', '%]", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[%s%]", global.main->error.to.stream, global.main->error.notable, controller_string_require_s, global.main->error.notable); + fl_print_string("%[', or '%]", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[%s%]", global.main->error.to.stream, global.main->error.notable, controller_string_wait_s, global.main->error.notable); + fl_print_string("%[' but instead has '%]", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, action->parameters.array[j], global.main->error.notable); + fl_print_string("%['.%]", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + + funlockfile(global.main->error.to.stream); } } } // for @@ -603,10 +599,13 @@ extern "C" { } if (global.main->error.verbosity != f_console_verbosity_quiet) { - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s item action may not specify the reserved item '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, controller_string_main_s, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s'.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SThe %s item action may not specify the reserved item '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context); + fl_print_string("%[%s%]", global.main->error.to.stream, global.main->error.notable, controller_string_main_s, global.main->error.notable); + fl_print_string("%['.%]", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + + funlockfile(global.main->error.to.stream); } } } @@ -629,20 +628,19 @@ extern "C" { } if (global.main->error.verbosity != f_console_verbosity_quiet) { - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s item action must have one of '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, controller_string_kill_s, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s', '", global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, controller_string_start_s, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s', or '", global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, controller_string_stop_s, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' but instead has '", global.main->error.context.before->string); - - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - f_print_safely_terminated(global.main->error.to.stream, action->parameters.array[0].string); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - - fprintf(global.main->error.to.stream, "%s'.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SThe %s item action must have one of '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context); + fl_print_string("%[%s%]", global.main->error.to.stream, global.main->error.notable, controller_string_kill_s, global.main->error.notable); + fl_print_string("%[', '%]", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[%s%]", global.main->error.to.stream, global.main->error.notable, controller_string_start_s, global.main->error.notable); + fl_print_string("%[', or '%]", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[%s%]", global.main->error.to.stream, global.main->error.notable, controller_string_stop_s, global.main->error.notable); + fl_print_string("%[' but instead has '%]", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, action->parameters.array[0], global.main->error.notable); + fl_print_string("%['.%]", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + + funlockfile(global.main->error.to.stream); } } @@ -669,14 +667,13 @@ extern "C" { } if (global.main->error.verbosity != f_console_verbosity_quiet) { - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s item action parameter '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); + flockfile(global.main->error.to.stream); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - f_print_safely_terminated(global.main->error.to.stream, action->parameters.array[1].string); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); + fl_print_string("%c%[%SThe %s item action parameter '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, action->parameters.array[1], global.main->error.notable); + fl_print_string("%[' is not a valid supported number.%]", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s' is not a valid supported number.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + funlockfile(global.main->error.to.stream); } } } @@ -690,16 +687,15 @@ extern "C" { action->status = F_status_set_error(F_supported_not); if (global.main->error.verbosity != f_console_verbosity_quiet) { - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s item action may only have '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, controller_string_wait_s, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' but instead has '", global.main->error.context.before->string); + flockfile(global.main->error.to.stream); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - f_print_safely_terminated(global.main->error.to.stream, action->parameters.array[0].string); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); + fl_print_string("%c%[%SThe %s item action may only have '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context); + fl_print_string("%[%s%]", global.main->error.to.stream, global.main->error.notable, controller_string_wait_s, global.main->error.notable); + fl_print_string("%[' but instead has '%]", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, action->parameters.array[0], global.main->error.notable); + fl_print_string("%['.%]", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s'.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + funlockfile(global.main->error.to.stream); } } } @@ -733,44 +729,32 @@ extern "C" { #endif // _di_controller_entry_error_print_ #ifndef _di_controller_entry_error_print_cache_ - void controller_entry_error_print_cache(const bool is_entry, const fll_error_print_t print, const controller_cache_action_t cache) { + void controller_entry_error_print_cache(const bool is_entry, const fll_error_print_t output, const controller_cache_action_t cache) { - fprintf(print.to.stream, "%c", f_string_eol_s[0]); - fprintf(print.to.stream, "%s%sWhile processing ", print.context.before->string, print.prefix ? print.prefix : f_string_empty_s); + fl_print_string("%c%[%SWhile processing ", output.to.stream, f_string_eol_s[0], output.context, output.prefix); if (cache.name_action.used) { - fprintf(print.to.stream, "action '"); - - fprintf(print.to.stream, "%s%s", print.context.after->string, print.notable.before->string); - f_print_safely_terminated(print.to.stream, cache.name_action.string); - fprintf(print.to.stream, "%s", print.notable.after->string); - - fprintf(print.to.stream, "%s' on line ", print.context.before->string); - fprintf(print.to.stream, "%s%s%llu%s", print.context.after->string, print.notable.before->string, cache.line_action, print.notable.after->string); - fprintf(print.to.stream, "%s for ", print.context.before->string); + fl_print_string("action '%]", output.to.stream, output.context); + fl_print_string("%[%Q%]", output.to.stream, output.context, cache.name_action, output.context); + fl_print_string("%[' on line%] ", output.to.stream, output.context, output.context); + fl_print_string("%[%ul%]", output.to.stream, output.notable, cache.line_action, output.notable); + fl_print_string("%[ for ", output.to.stream, output.context); } if (cache.name_item.used) { - fprintf(print.to.stream, "%s item '", is_entry ? controller_string_entry_s : controller_string_exit_s); - - fprintf(print.to.stream, "%s%s", print.context.after->string, print.notable.before->string); - f_print_safely_terminated(print.to.stream, cache.name_item.string); - fprintf(print.to.stream, "%s", print.notable.after->string); - - fprintf(print.to.stream, "%s' on line ", print.context.before->string); - fprintf(print.to.stream, "%s%s%llu%s", print.context.after->string, print.notable.before->string, cache.line_item, print.notable.after->string); - fprintf(print.to.stream, "%s for ", print.context.before->string); + fl_print_string("%s item '%]", output.to.stream, is_entry ? controller_string_entry_s : controller_string_exit_s, output.context); + fl_print_string("%[%Q%]", output.to.stream, output.notable, cache.name_item, output.notable); + fl_print_string("%[' on line%] ", output.to.stream, output.context, output.context); + fl_print_string("%[%ul%]", output.to.stream, output.notable, cache.line_item, output.notable); + fl_print_string("%[ for ", output.to.stream, output.context); } if (cache.name_file.used) { - fprintf(print.to.stream, "%s file '", is_entry ? controller_string_entry_s : controller_string_exit_s); - - fprintf(print.to.stream, "%s%s", print.context.after->string, print.notable.before->string); - f_print_safely_terminated(print.to.stream, cache.name_file.string); - fprintf(print.to.stream, "%s", print.notable.after->string); - - fprintf(print.to.stream, "%s'.%s%c", print.context.before->string, print.context.after->string, f_string_eol_s[0]); + fl_print_string("%s file '%]", output.to.stream, is_entry ? controller_string_entry_s : controller_string_exit_s, output.context); + fl_print_string("%[%Q%]%['", output.to.stream, output.notable, cache.name_file, output.notable, output.context); } + + fl_print_string(".%]%c", output.to.stream, output.context, f_string_eol_s[0]); } #endif // _di_controller_entry_error_print_cache_ @@ -874,8 +858,7 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s file is empty.%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context.after->string, f_string_eol_s[0]); + fll_print_string("%c%[%SThe %s file is empty.%]%c", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context, f_string_eol_s[0]); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -955,17 +938,16 @@ extern "C" { if (global.main->warning.verbosity == f_console_verbosity_debug) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->warning.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->warning.to.stream, "%s%sIgnoring duplicate %s item '", global.main->warning.context.before->string, global.main->warning.prefix ? global.main->warning.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - - fprintf(global.main->warning.to.stream, "%s%s", global.main->warning.context.after->string, global.main->warning.notable.before->string); - f_print_safely_terminated(global.main->error.to.stream, cache->action.name_file.string); - fprintf(global.main->warning.to.stream, "%s", global.main->warning.notable.after->string); + flockfile(global.main->warning.to.stream); - fprintf(global.main->warning.to.stream, "%s'.%s%c", global.main->warning.context.before->string, global.main->warning.context.after->string, f_string_eol_s[0]); + fl_print_string("%c%[%SIgnoring duplicate %s item '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->warning.context); + fl_print_string("%[%Q%]", global.main->warning.to.stream, global.main->warning.notable, cache->action.name_file, global.main->warning.notable); + fl_print_string("%['.%]%c", global.main->warning.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global.main->warning, cache->action); + funlockfile(global.main->warning.to.stream); + controller_print_unlock_flush(global.main->warning.to.stream, &global.thread->lock.print); } @@ -1041,10 +1023,13 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe required %s item '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, controller_string_main_s, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' was not found.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SThe required %s item '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context); + fl_print_string("%[%s%]", global.main->error.to.stream, global.main->error.notable, controller_string_main_s, global.main->error.notable); + fl_print_string("%[' was not found.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + + funlockfile(global.main->error.to.stream); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -1103,17 +1088,16 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe required %s item '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - f_print_safely_terminated(global.main->error.to.stream, action->parameters.array[0].string); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); + flockfile(global.main->error.to.stream); - fprintf(global.main->error.to.stream, "%s' does not exist.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + fl_print_string("%c%[%SThe required %s item '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, action->parameters.array[0], global.main->error.notable); + fl_print_string("%[' does not exist.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global.main->error, cache->action); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -1200,16 +1184,15 @@ extern "C" { if (is_entry && fl_string_dynamic_compare_string(controller_string_mode_s, cache->action.name_action, controller_string_mode_length) == F_equal_to) { if (cache->content_actions.array[i].used < 0 || cache->content_actions.array[i].used > 1) { if (global.main->error.verbosity != f_console_verbosity_quiet) { - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe %s item setting '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); + flockfile(global.main->error.to.stream); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - f_print_safely_terminated(global.main->error.to.stream, cache->action.name_action.string); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); + fl_print_string("%c%[%SThe %s item setting '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, cache->action.name_action, global.main->error.notable); + fl_print_string("%[' requires exactly %]", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[1%]", global.main->error.to.stream, global.main->error.notable, global.main->error.notable); + fl_print_string("%[' parameter.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s' requires exactly ", global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s%d%s", global.main->error.context.after->string, global.main->error.notable.before->string, 1, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s parameter.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + funlockfile(global.main->error.to.stream); } continue; @@ -1223,14 +1206,13 @@ extern "C" { } else { if (global.main->warning.verbosity == f_console_verbosity_debug) { - fprintf(global.main->warning.to.stream, "%s%sUnknown %s item setting value '", global.main->warning.context.before->string, global.main->warning.prefix ? global.main->warning.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global.main->warning.to.stream, "%s%s", global.main->warning.context.after->string, global.main->warning.notable.before->string); - fll_print_dynamic_partial(global.main->warning.to.stream, cache->buffer_file, cache->content_actions.array[i].array[0]); - fprintf(global.main->warning.to.stream, "%s%s for %s item setting '", global.main->warning.notable.after->string, global.main->warning.context.before->string, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global.main->warning.to.stream, "%s%s", global.main->warning.context.after->string, global.main->warning.notable.before->string); - fll_print_dynamic(global.main->warning.to.stream, cache->action.name_action); // @todo needs safe print dynamic - fprintf(global.main->warning.to.stream, "%s", global.main->warning.notable.after->string); - fprintf(global.main->warning.to.stream, "%s'.%s%c", global.main->warning.context.before->string, global.main->warning.context.after->string, f_string_eol_s[0]); + flockfile(global.main->warning.to.stream); + + fl_print_string("%c%[%Sfor %s item setting '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->warning.context); + fl_print_string("%[%Q%]", global.main->warning.to.stream, global.main->warning.notable, cache->action.name_action, global.main->warning.notable); + fl_print_string("%['.%]%c", global.main->warning.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]); + + funlockfile(global.main->warning.to.stream); controller_entry_error_print_cache(is_entry, global.main->warning, cache->action); } @@ -1240,11 +1222,13 @@ extern "C" { } else { if (global.main->warning.verbosity == f_console_verbosity_debug) { - fprintf(global.main->warning.to.stream, "%s%sUnknown %s item setting '", global.main->warning.context.before->string, global.main->warning.prefix ? global.main->warning.prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); - fprintf(global.main->warning.to.stream, "%s%s", global.main->warning.context.after->string, global.main->warning.notable.before->string); - fll_print_dynamic(global.main->warning.to.stream, cache->action.name_action); // @todo needs safe print dynamic - fprintf(global.main->warning.to.stream, "%s", global.main->warning.notable.after->string); - fprintf(global.main->warning.to.stream, "%s'.%s%c", global.main->warning.context.before->string, global.main->warning.context.after->string, f_string_eol_s[0]); + flockfile(global.main->warning.to.stream); + + fl_print_string("%c%[%SUnknown %s item setting '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->warning.context); + fl_print_string("%[%Q%]", global.main->warning.to.stream, global.main->warning.notable, cache->action.name_action, global.main->warning.notable); + fl_print_string("%['.%]%c", global.main->warning.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]); + + funlockfile(global.main->warning.to.stream); controller_entry_error_print_cache(is_entry, global.main->warning, cache->action); } diff --git a/level_3/controller/c/private-entry.h b/level_3/controller/c/private-entry.h index 0b73982..20e8b76 100644 --- a/level_3/controller/c/private-entry.h +++ b/level_3/controller/c/private-entry.h @@ -166,7 +166,7 @@ extern "C" { * @param is_entry * If TRUE, then this loads as an entry. * If FALSE, then this loads as an exit. - * @param print + * @param output * Designates how printing is to be performed. * @param cache * The action cache. @@ -175,7 +175,7 @@ extern "C" { * @see controller_entry_read() */ #ifndef _di_controller_entry_error_print_cache_ - extern void controller_entry_error_print_cache(const bool is_entry, const fll_error_print_t print, const controller_cache_action_t cache) f_attribute_visibility_internal; + extern void controller_entry_error_print_cache(const bool is_entry, const fll_error_print_t output, const controller_cache_action_t cache) f_attribute_visibility_internal; #endif // _di_controller_entry_error_print_cache_ /** diff --git a/level_3/controller/c/private-rule.c b/level_3/controller/c/private-rule.c index 977d784..5bb9a11 100644 --- a/level_3/controller/c/private-rule.c +++ b/level_3/controller/c/private-rule.c @@ -455,11 +455,14 @@ extern "C" { if (global.main->warning.verbosity == f_console_verbosity_debug) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->warning.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->warning.to.stream, "%s%sAction is empty, nothing to do.%s%c", global.main->warning.context.before->string, global.main->warning.prefix ? global.main->warning.prefix : f_string_empty_s, global.main->warning.context.after->string, f_string_eol_s[0]); + flockfile(global.main->warning.to.stream); + + fl_print_string("%c%[%SAction is empty, nothing to do.%]%c", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context, f_string_eol_s[0]); controller_rule_error_print_cache(global.main->warning, cache->action, F_true); + funlockfile(global.main->warning.to.stream); + controller_print_unlock_flush(global.main->warning.to.stream, &global.thread->lock.print); } } @@ -672,8 +675,13 @@ extern "C" { f_thread_mutex_lock(&thread->lock.print); fll_error_print(print, status, function, fallback); + + flockfile(print.to.stream); + controller_rule_error_print_cache(print, cache, item); + funlockfile(print.to.stream); + controller_print_unlock_flush(print.to.stream, &thread->lock.print); } } @@ -683,33 +691,29 @@ extern "C" { void controller_rule_error_print_cache(const fll_error_print_t output, const controller_cache_action_t cache, const bool item) { if (output.verbosity != f_console_verbosity_quiet) { - fprintf(output.to.stream, "%c", f_string_eol_s[0]); - fprintf(output.to.stream, "%s%sWhile processing ", output.context.before->string, output.prefix ? output.prefix : f_string_empty_s); + fl_print_string("%c%[%SWhile processing ", output.to.stream, f_string_eol_s[0], output.context, output.prefix); if (cache.name_action.used) { - fprintf(output.to.stream, "%s '", item ? "action" : "value"); - fprintf(output.to.stream, "%s%s", output.context.after->string, output.notable.before->string); - fll_print_dynamic(output.to.stream, cache.name_action); // @todo safe dynamic print - fprintf(output.to.stream, "%s%s' on line ", output.notable.after->string, output.context.before->string); - fprintf(output.to.stream, "%s%s%llu%s", output.context.after->string, output.notable.before->string, cache.line_action, output.notable.after->string); - fprintf(output.to.stream, "%s for ", output.context.before->string); + fl_print_string("%s '%]", output.to.stream, output.context, item ? controller_string_action_s : controller_string_value_s, output.context); + fl_print_string("%[%Q%]", output.to.stream, output.notable, cache.name_action, output.notable); + fl_print_string("%[ on line %]", output.to.stream, output.context, output.context); + fl_print_string("%[%ul%]", output.to.stream, output.notable, cache.line_action, output.notable); + fl_print_string("%[ for ", output.to.stream, output.context); } if (cache.name_item.used) { - fprintf(output.to.stream, "rule %s '", item ? "item" : "setting"); - fprintf(output.to.stream, "%s%s", output.context.after->string, output.notable.before->string); - fll_print_dynamic(output.to.stream, cache.name_item); // @todo safe dynamic print - fprintf(output.to.stream, "%s%s' on line ", output.notable.after->string, output.context.before->string); - fprintf(output.to.stream, "%s%s%llu%s", output.context.after->string, output.notable.before->string, cache.line_item, output.notable.after->string); - fprintf(output.to.stream, "%s for ", output.context.before->string); + fl_print_string("rule %s '%]", output.to.stream, output.context, item ? controller_string_item_s : controller_string_setting_s, output.context); + fl_print_string("%[%Q%]", output.to.stream, output.notable, cache.name_item, output.notable); + fl_print_string("%[ on line %]", output.to.stream, output.context, output.context); + fl_print_string("%[%ul%]", output.to.stream, output.notable, cache.line_item, output.notable); + fl_print_string("%[ for ", output.to.stream, output.context); } if (cache.name_file.used) { - fprintf(output.to.stream, "rule file '"); - fprintf(output.to.stream, "%s%s", output.context.after->string, output.notable.before->string); - fll_print_dynamic(output.to.stream, cache.name_file); // @todo safe dynamic print - fprintf(output.to.stream, "%s'.%s%c", output.context.before->string, output.context.after->string, f_string_eol_s[0]); + fl_print_string("rule file '%]%[%Q%]%['", output.to.stream, output.context, output.notable, cache.name_file, output.notable, output.context); } + + fl_print_string(".%]%c", output.to.stream, output.context, f_string_eol_s[0]); } } #endif // _di_controller_rule_error_print_cache_ @@ -728,108 +732,104 @@ extern "C" { #endif // _di_controller_rule_item_error_print_ #ifndef _di_controller_rule_item_error_print_execute_ - void controller_rule_item_error_print_execute(const fll_error_print_t print, const bool script_is, const f_string_t name, const int code, const f_status_t status) { + void controller_rule_item_error_print_execute(const fll_error_print_t output, const bool script_is, const f_string_t name, const int code, const f_status_t status) { - if (print.verbosity != f_console_verbosity_quiet) { - fprintf(print.to.stream, "%c", f_string_eol_s[0]); - fprintf(print.to.stream, "%s%sThe %s '", print.context.before->string, print.prefix ? print.prefix : f_string_empty_s, script_is ? controller_string_script_s : controller_string_program_s); + if (output.verbosity != f_console_verbosity_quiet) { + flockfile(output.to.stream); - fprintf(print.to.stream, "%s%s", print.context.after->string, print.notable.before->string); - f_print_safely_terminated(print.to.stream, name); - fprintf(print.to.stream, "%s", print.notable.after->string); + fl_print_string("%c%[%SThe %s '%]", output.to.stream, f_string_eol_s[0], output.context, output.prefix, script_is ? controller_string_script_s : controller_string_program_s, output.context); + fl_print_string("%[%S%]", output.to.stream, output.notable, name, output.notable); if (status == F_control_group || status == F_limit || status == F_processor || status == F_schedule) { - fprintf(print.to.stream, "%s' failed due to a failure to setup the '", print.context.before->string); - fprintf(print.to.stream, "%s%s", print.context.after->string, print.notable.before->string); + fl_print_string("%[' failed due to a failure to setup the '%]", output.to.stream, output.context, output.context); + fl_print_color_before(output.notable, output.to.stream); if (status == F_control_group) { - fprintf(print.to.stream, "%s", controller_string_control_group_s); + f_print_terminated(controller_string_control_group_s, output.to.stream); } else if (status == F_limit) { - fprintf(print.to.stream, "%s", controller_string_limit_s); + f_print_terminated(controller_string_limit_s, output.to.stream); } else if (status == F_processor) { - fprintf(print.to.stream, "%s", controller_string_processor_s); + f_print_terminated(controller_string_processor_s, output.to.stream); } else if (status == F_schedule) { - fprintf(print.to.stream, "%s", controller_string_scheduler_s); + f_print_terminated(controller_string_scheduler_s, output.to.stream); } - fprintf(print.to.stream, "%s", print.notable.after->string); - fprintf(print.to.stream, "%s'.%s%c", print.context.before->string, print.context.after->string, f_string_eol_s[0]); + fl_print_color_after(output.notable, output.to.stream); + fl_print_string("%['.%]%c", output.to.stream, output.context, output.context, f_string_eol_s[0]); } else if (code) { - fprintf(print.to.stream, "%s' failed with the exit code '", print.context.before->string); - fprintf(print.to.stream, "%s%s%i%s", print.context.after->string, print.notable.before->string, code, print.notable.after->string); - fprintf(print.to.stream, "%s'.%s%c", print.context.before->string, print.context.after->string, f_string_eol_s[0]); + fl_print_string("%[' failed with the exit code '%]", output.to.stream, output.context, output.context); + fl_print_string("%[%i%]", output.to.stream, output.notable, code, output.notable); + fl_print_string("%['.%]%c", output.to.stream, output.context, output.context, f_string_eol_s[0]); } else { - fprintf(print.to.stream, "%s' failed.%s%c", print.context.before->string, print.context.after->string, f_string_eol_s[0]); + fl_print_string("%[' failed.%]%c", output.to.stream, output.context, output.context, f_string_eol_s[0]); } + + funlockfile(output.to.stream); } } #endif // _di_controller_rule_item_error_print_execute_ #ifndef _di_controller_rule_item_error_print_execute_not_found_ - void controller_rule_item_error_print_execute_not_found(const fll_error_print_t print, const bool script_is, const f_string_t name) { + void controller_rule_item_error_print_execute_not_found(const fll_error_print_t output, const bool script_is, const f_string_t name) { - if (print.verbosity != f_console_verbosity_quiet) { - fprintf(print.to.stream, "%c", f_string_eol_s[0]); - fprintf(print.to.stream, "%s%sThe %s '", print.context.before->string, print.prefix ? print.prefix : f_string_empty_s, script_is ? controller_string_script_s : controller_string_program_s); + if (output.verbosity != f_console_verbosity_quiet) { + flockfile(output.to.stream); - fprintf(print.to.stream, "%s%s", print.context.after->string, print.notable.before->string); - f_print_safely_terminated(print.to.stream, name); - fprintf(print.to.stream, "%s", print.notable.after->string); + fl_print_string("%c%[%SThe %s '%]", output.to.stream, f_string_eol_s[0], output.context, output.prefix, script_is ? controller_string_script_s : controller_string_program_s, output.context); + fl_print_string("%[%S%]", output.to.stream, output.notable, name, output.notable); + fl_print_string("%[' could not be executed because it was not found.%]%c", output.to.stream, output.context, output.context, f_string_eol_s[0]); - fprintf(print.to.stream, "%s' could not be executed because it was not found.%s%c", print.context.before->string, print.context.after->string, f_string_eol_s[0]); + funlockfile(output.to.stream); } } #endif // _di_controller_rule_item_error_print_execute_not_found_ #ifndef _di_controller_rule_item_error_print_need_want_wish_ - void controller_rule_item_error_print_need_want_wish(const fll_error_print_t print, const f_string_t need_want_wish, const f_string_t value, const f_string_t why) { + void controller_rule_item_error_print_need_want_wish(const fll_error_print_t output, const f_string_t need_want_wish, const f_string_t value, const f_string_t why) { - if (print.verbosity != f_console_verbosity_quiet) { - fprintf(print.to.stream, "%c", f_string_eol_s[0]); - fprintf(print.to.stream, "%s%sThe %s rule '", print.context.before->string, print.prefix ? print.prefix : f_string_empty_s, need_want_wish); + if (output.verbosity != f_console_verbosity_quiet) { + flockfile(output.to.stream); - fprintf(print.to.stream, "%s%s", print.context.after->string, print.notable.before->string); - f_print_safely_terminated(print.to.stream, value); - fprintf(print.to.stream, "%s", print.notable.after->string); + fl_print_string("%c%[%SThe %s rule '%]", output.to.stream, f_string_eol_s[0], output.context, output.prefix, need_want_wish, output.context); + fl_print_string("%[%S%]", output.to.stream, output.notable, value, output.notable); + fl_print_string("%[' %S.%]%c", output.to.stream, output.context, why, output.context, f_string_eol_s[0]); - fprintf(print.to.stream, "%s' %s.%s%c", print.context.before->string, why, print.context.after->string, f_string_eol_s[0]); + funlockfile(output.to.stream); } } #endif // _di_controller_rule_item_error_print_need_want_wish_ #ifndef _di_controller_rule_item_error_print_rule_not_loaded_ - void controller_rule_item_error_print_rule_not_loaded(const fll_error_print_t print, const f_string_t alias) { + void controller_rule_item_error_print_rule_not_loaded(const fll_error_print_t output, const f_string_t alias) { - if (print.verbosity != f_console_verbosity_quiet) { - fprintf(print.to.stream, "%c", f_string_eol_s[0]); - fprintf(print.to.stream, "%s%sThe rule '", print.context.before->string, print.prefix ? print.prefix : f_string_empty_s); + if (output.verbosity != f_console_verbosity_quiet) { + flockfile(output.to.stream); - fprintf(print.to.stream, "%s%s", print.context.after->string, print.notable.before->string); - f_print_safely_terminated(print.to.stream, alias); - fprintf(print.to.stream, "%s", print.notable.after->string); + fl_print_string("%c%[%SThe rule '%]", output.to.stream, f_string_eol_s[0], output.context, output.prefix, output.context); + fl_print_string("%[%S%]", output.to.stream, output.notable, alias, output.notable); + fl_print_string("%[' is no longer loaded.%]%c", output.to.stream, output.context, output.context, f_string_eol_s[0]); - fprintf(print.to.stream, "%s' is no longer loaded.%s%c", print.context.before->string, print.context.after->string, f_string_eol_s[0]); + funlockfile(output.to.stream); } } #endif // _di_controller_rule_item_error_print_rule_not_loaded_ #ifndef _di_controller_rule_action_error_missing_pid_ - void controller_rule_action_error_missing_pid(const fll_error_print_t print, const f_string_t alias) { + void controller_rule_action_error_missing_pid(const fll_error_print_t output, const f_string_t alias) { - if (print.verbosity != f_console_verbosity_quiet) { - fprintf(print.to.stream, "%c", f_string_eol_s[0]); - fprintf(print.to.stream, "%s%sThe rule '", print.context.before->string, print.prefix ? print.prefix : f_string_empty_s); + if (output.verbosity != f_console_verbosity_quiet) { + flockfile(output.to.stream); - fprintf(print.to.stream, "%s%s", print.context.after->string, print.notable.before->string); - f_print_safely_terminated(print.to.stream, alias); - fprintf(print.to.stream, "%s", print.notable.after->string); + fl_print_string("%c%[%SThe rule '%]", output.to.stream, f_string_eol_s[0], output.context, output.prefix, output.context); + fl_print_string("%[%S%]", output.to.stream, output.notable, alias, output.notable); + fl_print_string("%[' is not designating a pid file.%]%c", output.to.stream, output.context, output.context, f_string_eol_s[0]); - fprintf(print.to.stream, "%s' is not designating a pid file.%s%c", print.context.before->string, print.context.after->string, f_string_eol_s[0]); + funlockfile(output.to.stream); } } #endif // _di_controller_rule_action_error_missing_pid_ @@ -1067,11 +1067,14 @@ extern "C" { if (global.main->warning.verbosity == f_console_verbosity_debug) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->warning.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->warning.to.stream, "%s%sAction type is unknown, ignoring.%s%c", global.main->warning.context.before->string, global.main->warning.prefix ? global.main->warning.prefix : f_string_empty_s, global.main->warning.context.after->string, f_string_eol_s[0]); + flockfile(global.main->warning.to.stream); + + fl_print_string("%c%[%SAction type is unknown, ignoring.%]%c", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context, f_string_eol_s[0]); controller_rule_error_print_cache(global.main->warning, process->cache.action, F_true); + funlockfile(global.main->warning.to.stream); + controller_print_unlock_flush(global.main->warning.to.stream, &global.thread->lock.print); } @@ -1159,27 +1162,32 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->output.stream, "Simulating execution of '"); + flockfile(global.main->output.stream); + + fl_print_string("%cSimulating execution of '%[", global.main->output.stream, f_string_eol_s[0], global.main->context.set.title); - fprintf(global.main->output.stream, "%s", global.main->context.title.string); - f_print_safely_terminated(global.main->output.stream, program ? program : arguments.used && arguments.array[0].used ? arguments.array[0].string : f_string_empty_s); - fprintf(global.main->output.stream, "%s' with the arguments: '%s", global.main->context.reset.string, global.main->context.important.string); + if (program) { + f_print_safely_terminated(program, global.main->output.stream); + } + else { + f_print_dynamic_safely(arguments.array[0], global.main->output.stream); + } + + fl_print_string("%]' with the arguments: '%[", global.main->output.stream, global.main->context.set.title, global.main->context.set.important); for (f_array_length_t i = program ? 0 : 1; i < arguments.used; ++i) { if (program && i || !program && i > 1) { - fprintf(global.main->output.stream, "%c", f_string_space_s[0]); + f_print_terminated(f_string_space_s, global.main->output.stream); } - f_print_safely_terminated(global.main->output.stream, arguments.array[i].string); + f_print_dynamic_safely(arguments.array[i], global.main->output.stream); } // for - fprintf(global.main->output.stream, "%s' from '", global.main->context.reset.string); + fl_print_string("%]' from '", global.main->output.stream, global.main->context.set.important); + fl_print_string("%[%Q%]'.%c", global.main->output.stream, global.main->context.set.notable, process->rule.name, global.main->context.set.notable, f_string_eol_s[0]); - fprintf(global.main->output.stream, "%s", global.main->context.notable.string); - f_print_safely_terminated(global.main->output.stream, process->rule.name.used ? process->rule.name.string : f_string_empty_s); - fprintf(global.main->output.stream, "%s'.%c", global.main->context.reset.string, f_string_eol_s[0]); + funlockfile(global.main->output.stream); controller_print_unlock_flush(global.main->output.stream, &global.thread->lock.print); } @@ -1411,29 +1419,34 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->output.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->output.stream, "Simulating execution of '"); + flockfile(global.main->error.to.stream); + + fl_print_string("%cSimulating execution of '%[", global.main->error.to.stream, f_string_eol_s[0], global.main->context.set.title); - fprintf(global.main->output.stream, "%s", global.main->context.title.string); - f_print_safely_terminated(global.main->output.stream, program ? program : arguments.used && arguments.array[0].used ? arguments.array[0].string : f_string_empty_s); - fprintf(global.main->output.stream, "%s' with the arguments: '%s", global.main->context.reset.string, global.main->context.important.string); + if (program) { + f_print_safely_terminated(program, global.main->error.to.stream); + } + else { + f_print_dynamic_safely(arguments.array[0], global.main->error.to.stream); + } + + fl_print_string("%]' with the arguments: '%[", global.main->error.to.stream, global.main->context.set.title, global.main->context.set.important); for (f_array_length_t i = program ? 0 : 1; i < arguments.used; ++i) { if (program && i || !program && i > 1) { - fprintf(global.main->output.stream, "%c", f_string_space_s[0]); + f_print_terminated(f_string_space_s, global.main->error.to.stream); } - f_print_safely_terminated(global.main->output.stream, arguments.array[i].string); + f_print_dynamic_safely(arguments.array[i], global.main->error.to.stream); } // for - fprintf(global.main->output.stream, "%s' from '", global.main->context.reset.string); + fl_print_string("%]' from '", global.main->error.to.stream, global.main->context.set.important); + fl_print_string("%[%Q%]'.%c", global.main->error.to.stream, global.main->context.set.notable, process->rule.name, global.main->context.set.notable, f_string_eol_s[0]); - fprintf(global.main->output.stream, "%s", global.main->context.notable.string); - f_print_safely_terminated(global.main->output.stream, process->rule.name.used ? process->rule.name.string : f_string_empty_s); - fprintf(global.main->output.stream, "%s'.%c", global.main->context.reset.string, f_string_eol_s[0]); + funlockfile(global.main->error.to.stream); - controller_print_unlock_flush(global.main->output.stream, &global.thread->lock.print); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } // sleep for less than a second to better show simulation of synchronous vs asynchronous. @@ -1747,15 +1760,16 @@ extern "C" { if (global.main->warning.verbosity == f_console_verbosity_debug) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->warning.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->warning.to.stream, "%s%sUnknown rule item action '", global.main->warning.context.before->string, global.main->warning.prefix ? global.main->warning.prefix : f_string_empty_s); - fprintf(global.main->warning.to.stream, "%s%s", global.main->warning.context.after->string, global.main->warning.notable.before->string); - fll_print_dynamic(global.main->warning.to.stream, cache->action.name_action); - fprintf(global.main->warning.to.stream, "%s", global.main->warning.notable.after->string); - fprintf(global.main->warning.to.stream, "%s'.%s%c", global.main->warning.context.before->string, global.main->warning.context.after->string, f_string_eol_s[0]); + flockfile(global.main->warning.to.stream); + + fl_print_string("%c%[%SUnknown rule item action '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context); + fl_print_string("%[%Q%]", global.main->warning.to.stream, global.main->warning.notable, cache->action.name_action, global.main->warning.notable); + fl_print_string("%['.%]%c", global.main->warning.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]); controller_rule_error_print_cache(global.main->warning, cache->action, F_true); + funlockfile(global.main->warning.to.stream); + controller_print_unlock_flush(global.main->warning.to.stream, &global.thread->lock.print); } @@ -1768,12 +1782,13 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sFSS Extended List is not allowed for the rule item action '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic(global.main->error.to.stream, cache->action.name_action); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s'.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SFSS Extended List is not allowed for the rule item action '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, cache->action.name_action, global.main->error.notable); + fl_print_string("%['.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + + funlockfile(global.main->error.to.stream); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -1974,13 +1989,16 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sUnsupported action type '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, controller_rule_action_type_name(process->action), global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' while attempting to execute rule.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SUnsupported action type '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%q%]", global.main->error.to.stream, global.main->error.notable, controller_rule_action_type_name(process->action), global.main->error.notable); + fl_print_string("%[' while attempting to execute rule.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); controller_rule_error_print_cache(global.main->error, process->cache.action, F_true); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -2401,15 +2419,18 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe rule '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, process->rule.name.used ? process->rule.name.string : f_string_empty_s, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' has no '", global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, controller_rule_action_type_name(process->action).string, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' action to execute.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SThe rule '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, process->rule.name, global.main->error.notable); + fl_print_string("%[' has no '%]", global.main->error.to.stream, global.main->error.context, process->rule.name, global.main->error.context); + fl_print_string("%[%q%]", global.main->error.to.stream, global.main->error.notable, controller_rule_action_type_name(process->action), global.main->error.notable); + fl_print_string("%[' action to execute.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); controller_rule_error_print_cache(global.main->error, process->cache.action, F_true); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -2845,13 +2866,16 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe rule '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, process->rule.alias.string, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' is already on the execution dependency stack, this recursion is prohibited.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SThe rule '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, process->rule.alias, global.main->error.notable); + fl_print_string("%[' is already on the execution dependency stack, this recursion is prohibited.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); controller_rule_error_print_cache(global.main->error, process->cache.action, F_true); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -3220,15 +3244,16 @@ extern "C" { if (global.main->warning.verbosity == f_console_verbosity_debug) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->warning.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->warning.to.stream, "%s%sUnknown rule item '", global.main->warning.context.before->string, global.main->warning.prefix ? global.main->warning.prefix : f_string_empty_s); - fprintf(global.main->warning.to.stream, "%s%s", global.main->warning.context.after->string, global.main->warning.notable.before->string); - fll_print_dynamic(global.main->warning.to.stream, cache->action.name_item); - fprintf(global.main->warning.to.stream, "%s", global.main->warning.notable.after->string); - fprintf(global.main->warning.to.stream, "%s'.%s%c", global.main->warning.context.before->string, global.main->warning.context.after->string, f_string_eol_s[0]); + flockfile(global.main->warning.to.stream); + + fl_print_string("%c%[%SUnknown rule item '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context); + fl_print_string("%[%Q%]", global.main->warning.to.stream, global.main->warning.notable, cache->action.name_item, global.main->warning.notable); + fl_print_string("%['.%]%c", global.main->warning.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]); controller_rule_error_print_cache(global.main->warning, cache->action, F_true); + funlockfile(global.main->warning.to.stream); + f_thread_mutex_lock(&global.thread->lock.print); } @@ -3412,14 +3437,6 @@ extern "C" { } else { if (global.main->warning.verbosity == f_console_verbosity_debug) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->warning.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->warning.to.stream, "%s%sUnknown rule setting '", global.main->warning.context.before->string, global.main->warning.prefix ? global.main->warning.prefix : f_string_empty_s); - fprintf(global.main->warning.to.stream, "%s%s", global.main->warning.context.after->string, global.main->warning.notable.before->string); - fll_print_dynamic(global.main->warning.to.stream, cache->action.name_item); - fprintf(global.main->warning.to.stream, "%s", global.main->warning.notable.after->string); - fprintf(global.main->warning.to.stream, "%s'.%s%c", global.main->warning.context.before->string, global.main->warning.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -3427,8 +3444,18 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->warning.to.stream); + + fl_print_string("%c%[%SUnknown rule setting '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context); + fl_print_string("%[%Q%]", global.main->warning.to.stream, global.main->warning.notable, cache->action.name_item, global.main->warning.notable); + fl_print_string("%['.%]%c", global.main->warning.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->warning, cache->action, F_false); + funlockfile(global.main->warning.to.stream); + controller_print_unlock_flush(global.main->warning.to.stream, &global.thread->lock.print); } @@ -3437,10 +3464,6 @@ extern "C" { if (!cache->content_actions.array[i].used) { if (global.main->warning.verbosity == f_console_verbosity_debug) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->warning.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->warning.to.stream, "%s%sEmpty rule setting.%s%c", global.main->warning.context.before->string, global.main->warning.prefix ? global.main->warning.prefix : f_string_empty_s, global.main->warning.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -3448,8 +3471,16 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->warning.to.stream); + + fl_print_string("%c%[%SEmpty rule setting.%]%c", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix, global.main->warning.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->warning, cache->action, F_false); + funlockfile(global.main->warning.to.stream); + controller_print_unlock_flush(global.main->warning.to.stream, &global.thread->lock.print); } @@ -3508,11 +3539,14 @@ extern "C" { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting requires one or more Content.%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting requires one or more Content.%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context, f_string_eol_s[0]); controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -3560,36 +3594,32 @@ extern "C" { if (status == F_data_not || status == F_number || status == F_number_overflow || status == F_number_underflow) { if (global.main->error.verbosity != f_console_verbosity_quiet) { - if (status == F_number_overflow || status == F_number_underflow) { - f_thread_mutex_lock(&global.thread->lock.print); + // get the current line number within the settings item. + cache->action.line_item = line_item; + f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an unsupported number '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[j]); - fprintf(global.main->error.to.stream, "%s%s', the number is too large for this system.%s%c", global.main->error.notable.after->string, global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + cache->action.line_action = ++cache->action.line_item; - controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); - } - else { - f_thread_mutex_lock(&global.thread->lock.print); + f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an invalid number '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[j]); - fprintf(global.main->error.to.stream, "%s%s', only whole numbers are allowed for an affinity value.%s%c", global.main->error.notable.after->string, global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); - controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); + if (status == F_number_overflow || status == F_number_underflow) { + fl_print_string("%c%[%SRule setting has an unsupported number '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[j], global.main->error.notable); + fl_print_string("%[', the number is too large for this system.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + } + else { + fl_print_string("%c%[%SRule setting has an invalid number '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[j], global.main->error.notable); + fl_print_string("%[' only whole numbers are allowed for an affinity value.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); } - // get the current line number within the settings item. - cache->action.line_item = line_item; - f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); - cache->action.line_action = ++cache->action.line_item; + funlockfile(global.main->error.to.stream); - controller_rule_item_error_print(global.main->error, cache->action, F_false, global.thread); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } status = F_status_set_error(F_valid_not); @@ -3630,11 +3660,14 @@ extern "C" { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting requires exactly two Content.%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting requires exactly two Content.%]%c", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context, f_string_eol_s[0]); controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -3740,6 +3773,7 @@ extern "C" { } ++setting_maps->used; + continue; } @@ -3749,8 +3783,9 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting requires two or more Content.%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting requires two or more Content.%]%c", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -3760,6 +3795,8 @@ extern "C" { controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -3778,13 +3815,6 @@ extern "C" { } else { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an unknown option '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[0]); - fprintf(global.main->error.to.stream, "%s%s'.%s%c", global.main->error.notable.after->string, global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -3792,8 +3822,18 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting has an unknown option '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[0], global.main->error.notable); + fl_print_string("%['.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -3868,10 +3908,6 @@ extern "C" { if (cache->content_actions.array[i].used != 3) { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting requires three Content.%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -3879,8 +3915,16 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting requires three Content.%]%c", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -3941,14 +3985,6 @@ extern "C" { } else { if (global.main->error.verbosity == f_console_verbosity_debug) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sUnknown resource limit type '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic(global.main->error.to.stream, cache->action.name_action); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s'.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -3956,8 +3992,18 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SUnknown resource limit type '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, cache->action.name_action, global.main->error.notable); + fl_print_string("%['.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_true); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -3972,11 +4018,6 @@ extern "C" { if (type == rule->limits.array[j].type) { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe resource limit type is already specified.%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context.after->string, f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -3984,8 +4025,16 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SThe resource limit type is already specified%]%c", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4036,22 +4085,6 @@ extern "C" { if (status == F_data_not || status == F_number || status == F_number_overflow || status == F_number_underflow) { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - if (status == F_number_overflow || status == F_number_underflow) { - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an unsupported number '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[j]); - fprintf(global.main->error.to.stream, "%s%s', the number is too large for this system.%s%c", global.main->error.notable.after->string, global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); - } - else { - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an invalid number '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[j]); - fprintf(global.main->error.to.stream, "%s%s', only whole numbers are allowed for a resource limit value.%s%c", global.main->error.notable.after->string, global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); - } // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4059,8 +4092,25 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + if (status == F_number_overflow || status == F_number_underflow) { + fl_print_string("%c%[%SRule setting has an unsupported number'%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%S%]", global.main->error.to.stream, global.main->error.notable, cache->content_actions.array[i].array[j], global.main->error.notable); + fl_print_string("%[' the number is too large for this system.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + } + else { + fl_print_string("%c%[%SRule setting has an invalid number'%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%S%]", global.main->error.to.stream, global.main->error.notable, cache->content_actions.array[i].array[j], global.main->error.notable); + fl_print_string("%[' only whole numbers are allowed for a resource limit value.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + } + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4112,10 +4162,6 @@ extern "C" { if (setting_value->used || cache->content_actions.array[i].used != 1) { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting requires exactly one Content.%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4123,8 +4169,16 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting requires exactly one Content.%]%c", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4165,26 +4219,29 @@ extern "C" { status = controller_validate_has_graph(*setting_value); if (status == F_false || F_status_set_fine(status) == F_complete_not_utf) { + if (global.main->error.verbosity != f_console_verbosity_quiet) { + + // get the current line number within the settings item. + cache->action.line_item = line_item; + f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item); + + cache->action.line_action = ++cache->action.line_item; + } if (status == F_false) { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an invalid name '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic(global.main->error.to.stream, *setting_value); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s', there must be at least 1 graph character.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); - - // get the current line number within the settings item. - cache->action.line_item = line_item; - f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item); + flockfile(global.main->error.to.stream); - cache->action.line_action = ++cache->action.line_item; + fl_print_string("%c%[%SRule setting has an invalid name '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, *setting_value, global.main->error.notable); + fl_print_string("%[', there must be at least 1 graph character.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4193,28 +4250,19 @@ extern "C" { } } else { - f_thread_mutex_lock(&global.thread->lock.print); // this function should only return F_complete_not_utf on error. controller_rule_error_print(global.main->error, cache->action, F_complete_not_utf, "controller_validate_has_graph", F_true, F_false, global.thread); - controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); - if (F_status_is_error_not(status_return)) { status_return = status; } + + controller_rule_item_error_print(global.main->error, cache->action, F_false, global.thread); } setting_value->used = 0; - // get the current line number within the settings item. - cache->action.line_item = line_item; - f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item); - - cache->action.line_action = ++cache->action.line_item; - - controller_rule_item_error_print(global.main->error, cache->action, F_false, global.thread); - continue; } } @@ -4264,10 +4312,6 @@ extern "C" { if (cache->content_actions.array[i].used < 1 || cache->content_actions.array[i].used > 2 || rule->has & controller_rule_has_scheduler) { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting requires either one or two Content.%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4275,8 +4319,16 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting requires either one or two Content.'%]%c", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4313,13 +4365,6 @@ extern "C" { } else { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an unknown scheduler '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[0]); - fprintf(global.main->error.to.stream, "%s%s'.%s%c", global.main->error.notable.after->string, global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4327,8 +4372,18 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting has an unknown scheduler '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[0], global.main->error.notable); + fl_print_string("%['.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4352,36 +4407,36 @@ extern "C" { if ((zero_only && number) || (!zero_only && (number < 1 || number > 99)) || status == F_data_not || status == F_number || status == F_number_overflow) { if (global.main->error.verbosity != f_console_verbosity_quiet) { + + // get the current line number within the settings item. + cache->action.line_item = line_item; + f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item); + + cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an invalid number '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[1]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting has an invalid number '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[1], global.main->error.notable); if (zero_only) { - fprintf(global.main->error.to.stream, "%s%s', only ", global.main->error.notable.after->string, global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s0%s", global.main->error.context.after->string, global.main->error.notable.before->string, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s is", global.main->error.context.before->string); + fl_print_string("%[', only%] ", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[0%]%[ is", global.main->error.to.stream, global.main->error.notable, global.main->error.notable, global.main->error.context); } else { - fprintf(global.main->error.to.stream, "%s%s', only the whole numbers inclusively between ", global.main->error.notable.after->string, global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s1%s", global.main->error.context.after->string, global.main->error.notable.before->string, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s and ", global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s99%s", global.main->error.context.after->string, global.main->error.notable.before->string, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s are", global.main->error.context.before->string); + fl_print_string("%[', only the whole numbers inclusively between%] ", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[1%] %[and%] ", global.main->error.to.stream, global.main->error.notable, global.main->error.notable, global.main->error.context, global.main->error.context); + fl_print_string("%[99%] %[are", global.main->error.to.stream, global.main->error.notable, global.main->error.notable, global.main->error.context); } - fprintf(global.main->error.to.stream, " allowed for the designated scheduler.%s%c", global.main->error.context.after->string, f_string_eol_s[0]); - - // get the current line number within the settings item. - cache->action.line_item = line_item; - f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item); - - cache->action.line_action = ++cache->action.line_item; + fl_print_string(" allowed for the designated scheduler.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4414,10 +4469,6 @@ extern "C" { if (cache->content_actions.array[i].used != 1 || type == controller_rule_setting_type_capability && rule->capability || type == controller_rule_setting_type_group && (rule->has & controller_rule_has_group) || type == controller_rule_setting_type_nice && (rule->has & controller_rule_has_nice) || type == controller_rule_setting_type_user && (rule->has & controller_rule_has_user)) { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting requires exactly one Content.%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4425,8 +4476,16 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting requires exactly one Content.%]%c", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4443,9 +4502,6 @@ extern "C" { status = f_string_dynamic_partial_append_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], &cache->action.generic); if (F_status_is_error(status)) { - f_thread_mutex_lock(&global.thread->lock.print); - - controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false, global.thread); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4453,6 +4509,10 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true, F_false, global.thread); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); @@ -4470,9 +4530,6 @@ extern "C" { status = f_string_dynamic_terminate_after(&cache->action.generic); if (F_status_is_error(status)) { - f_thread_mutex_lock(&global.thread->lock.print); - - controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false, global.thread); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4480,6 +4537,10 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true, F_false, global.thread); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); @@ -4498,9 +4559,6 @@ extern "C" { if (F_status_is_error(status) && F_status_set_fine(status) != F_supported_not) { if (F_status_set_fine(status) == F_memory_not) { - f_thread_mutex_lock(&global.thread->lock.print); - - controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "f_capability_from_text", F_true, F_false, global.thread); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4508,6 +4566,10 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "f_capability_from_text", F_true, F_false, global.thread); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); @@ -4517,10 +4579,6 @@ extern "C" { } if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting failed to process the capabilities.%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4528,8 +4586,16 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting failed to process the capabilities.%]%c", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4551,17 +4617,6 @@ extern "C" { if (number < -20 || number > 19 || status == F_data_not || status == F_number || status == F_number_overflow || status == F_number_underflow) { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an invalid number '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[0]); - fprintf(global.main->error.to.stream, "%s%s', only the whole numbers inclusively between ", global.main->error.notable.after->string, global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s-20%s", global.main->error.context.after->string, global.main->error.notable.before->string, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s and ", global.main->error.context.before->string); - fprintf(global.main->error.to.stream, "%s%s19%s", global.main->error.context.after->string, global.main->error.notable.before->string, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s are allowed.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4569,8 +4624,22 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting has an invalid number '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[0], global.main->error.notable); + fl_print_string("%[', only the whole numbers inclusively between%] ", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[-20%]", global.main->error.to.stream, global.main->error.notable, global.main->error.notable); + fl_print_string(" %[and%] ", global.main->error.to.stream, global.main->error.context, global.main->error.context); + fl_print_string("%[19%]", global.main->error.to.stream, global.main->error.notable, global.main->error.notable); + fl_print_string(" %[are allowed.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4600,16 +4669,23 @@ extern "C" { if (F_status_is_error(status)) { status = F_status_set_fine(status); + // get the current line number within the settings item. + cache->action.line_item = line_item; + f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item); + + cache->action.line_action = ++cache->action.line_item; + if (status == F_exist_not) { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an invalid user '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[0]); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' because no user was found by that name.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting has an invalid user '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[0], global.main->error.notable); + fl_print_string("%[' because no user was found by that name.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + + funlockfile(global.main->error.to.stream); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4618,12 +4694,13 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an invalid user '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[0]); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' because the given ID is too large.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting has an invalid user '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[0], global.main->error.notable); + fl_print_string("%[' because the given ID is too large.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + + funlockfile(global.main->error.to.stream); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4632,12 +4709,13 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an invalid user '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[0]); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' because the given ID is not a valid supported number.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting has an invalid user '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[0], global.main->error.notable); + fl_print_string("%[' because the given ID is not a valid supported number.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + + funlockfile(global.main->error.to.stream); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4646,12 +4724,6 @@ extern "C" { controller_rule_error_print(global.main->error, cache->action, status, "f_account_id_user_by_name", F_true, F_false, global.thread); } - // get the current line number within the settings item. - cache->action.line_item = line_item; - f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item); - - cache->action.line_action = ++cache->action.line_item; - controller_rule_item_error_print(global.main->error, cache->action, F_false, global.thread); if (F_status_is_error_not(status_return)) { @@ -4670,10 +4742,6 @@ extern "C" { if (type == controller_rule_setting_type_group) { if (!cache->content_actions.array[i].used) { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting requires one or more Content.%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4681,8 +4749,16 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting requires one or more Content.%]%c", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4733,12 +4809,13 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an invalid group '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[j]); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' because no group was found by that name.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting has an invalid group '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[j], global.main->error.notable); + fl_print_string("%[' because no group was found by that name.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + + funlockfile(global.main->error.to.stream); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4747,12 +4824,13 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an invalid group '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[j]); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' because the given ID is too large.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting has an invalid group '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[j], global.main->error.notable); + fl_print_string("%[' because the given ID is too large.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + + funlockfile(global.main->error.to.stream); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4761,12 +4839,13 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an invalid group '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[j]); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' because the given ID is not a valid supported number.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting has an invalid group '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[j], global.main->error.notable); + fl_print_string("%[' because the given ID is not a valid supported number.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + + funlockfile(global.main->error.to.stream); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4872,24 +4951,28 @@ extern "C" { status = controller_validate_environment_name(setting_values->array[setting_values->used]); if (status == F_false || F_status_set_fine(status) == F_complete_not_utf) { + + // get the current line number within the settings item. + cache->action.line_item = line_item; + f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item); + + cache->action.line_action = ++cache->action.line_item; + if (status == F_false) { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting has an invalid environment variable name '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s%s%s", global.main->error.context.after->string, global.main->error.notable.before->string, setting_values->array[setting_values->used].string, global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s'.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); - // get the current line number within the settings item. - cache->action.line_item = line_item; - f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item); - - cache->action.line_action = ++cache->action.line_item; + fl_print_string("%c%[%SRule setting has an invalid environment variable name '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, global.main->error.notable, setting_values->array[setting_values->used], global.main->error.notable); + fl_print_string("%['.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4909,12 +4992,6 @@ extern "C" { setting_values->array[setting_values->used].used = 0; - // get the current line number within the settings item. - cache->action.line_item = line_item; - f_fss_count_lines(cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item); - - cache->action.line_action = ++cache->action.line_item; - controller_rule_item_error_print(global.main->error, cache->action, F_false, global.thread); continue; @@ -4930,10 +5007,6 @@ extern "C" { if (cache->content_actions.array[i].used != 4) { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting requires exactly four Content.%s%c", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4941,8 +5014,16 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting requires exactly four Content.%]%c", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -4983,15 +5064,6 @@ extern "C" { } else { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting's first value has '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[1]); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' but only supports %s, %s, %s, %s, %s", global.main->error.context.before->string, controller_string_freeze_s, controller_string_kill_s, controller_string_pause_s, controller_string_reload_s, controller_string_restart_s); - fprintf(global.main->error.to.stream, "%s, %s, %s, and %s.%s%c", controller_string_resume_s, controller_string_start_s, controller_string_stop_s, controller_string_thaw_s, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -4999,8 +5071,19 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting's first value has '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[1], global.main->error.notable); + fl_print_string("%[' but only supports %s, %s, %s, %s, %s", global.main->error.to.stream, global.main->error.context, controller_string_freeze_s, controller_string_kill_s, controller_string_pause_s, controller_string_reload_s, controller_string_restart_s); + fl_print_string("%s, %s, %s, and %s.%]%c", global.main->error.to.stream, controller_string_resume_s, controller_string_start_s, controller_string_stop_s, controller_string_thaw_s, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -5034,14 +5117,6 @@ extern "C" { } else { if (global.main->error.verbosity != f_console_verbosity_quiet) { - f_thread_mutex_lock(&global.thread->lock.print); - - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sRule setting's second value has '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[1]); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' but only supports %s, %s, and %s.%s%c", global.main->error.context.before->string, controller_string_need_s, controller_string_want_s, controller_string_wish_s, global.main->error.context.after->string, f_string_eol_s[0]); // get the current line number within the settings item. cache->action.line_item = line_item; @@ -5049,8 +5124,18 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; + f_thread_mutex_lock(&global.thread->lock.print); + + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SRule setting's second value has '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[1], global.main->error.notable); + fl_print_string("%[' but only supports %s, %s, and %s.%s.%]%c", global.main->error.to.stream, global.main->error.context, controller_string_need_s, controller_string_want_s, controller_string_wish_s, global.main->error.context, f_string_eol_s[0]); + controller_rule_error_print_cache(global.main->error, cache->action, F_false); + funlockfile(global.main->error.to.stream); + controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -5140,16 +5225,15 @@ extern "C" { if (global.main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&global.thread->lock.print); - fprintf(global.main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(global.main->error.to.stream, "%s%sThe rule item action third parameter '", global.main->error.context.before->string, global.main->error.prefix ? global.main->error.prefix : f_string_empty_s); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic_partial(global.main->error.to.stream, cache->buffer_item, cache->content_actions.array[i].array[2]); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s' must be a base path name, such as %llu '", global.main->error.context.before->string, cache->buffer_path.used); - fprintf(global.main->error.to.stream, "%s%s", global.main->error.context.after->string, global.main->error.notable.before->string); - fll_print_dynamic(global.main->error.to.stream, cache->buffer_path); - fprintf(global.main->error.to.stream, "%s", global.main->error.notable.after->string); - fprintf(global.main->error.to.stream, "%s'.%s%c", global.main->error.context.before->string, global.main->error.context.after->string, f_string_eol_s[0]); + flockfile(global.main->error.to.stream); + + fl_print_string("%c%[%SThe rule item action third parameter '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, global.main->error.prefix, global.main->error.context); + fl_print_string("%[%/Q%]", global.main->error.to.stream, global.main->error.notable, cache->buffer_item, cache->content_actions.array[i].array[2], global.main->error.notable); + fl_print_string("%[' must be a base path name, such as %ul '.%]", global.main->error.to.stream, global.main->error.context, cache->buffer_path.used, global.main->error.context); + fl_print_string("%[%Q%]", global.main->error.to.stream, cache->buffer_path, global.main->error.notable); + fl_print_string("%['.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); + + funlockfile(global.main->error.to.stream); controller_print_unlock_flush(global.main->error.to.stream, &global.thread->lock.print); } @@ -5202,12 +5286,15 @@ extern "C" { default: if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(main->error.to.stream, "%s%sUnsupported action type '", main->error.context.before->string, main->error.prefix ? main->error.prefix : f_string_empty_s); - fprintf(main->error.to.stream, "%s%s%s%s", main->error.context.after->string, main->error.notable.before->string, controller_rule_action_type_name(action).string, main->error.notable.after->string); - fprintf(main->error.to.stream, "%s' while attempting to validate rule execution.%s%c", main->error.context.before->string, main->error.context.after->string, f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_string("%c%[%SUnsupported action type '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context); + fl_print_string("%[%q%]", main->error.to.stream, main->error.notable, controller_rule_action_type_name(action), main->error.notable); + fl_print_string("%[' while attempting to validate rule execution.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); controller_rule_error_print_cache(main->error, cache->action, F_true); + + funlockfile(main->error.to.stream); } controller_print_unlock_flush(main->error.to.stream, &global.thread->lock.print); @@ -5234,66 +5321,61 @@ extern "C" { } // for if (missing) { - fprintf(main->output.stream, "%c", f_string_eol_s[0]); - fprintf(main->output.stream, "Rule '"); - fprintf(main->output.stream, "%s%s%s", main->context.set.title.before->string, rule.name.used ? rule.name.string : f_string_empty_s, main->context.set.title.after->string); - fprintf(main->output.stream, "' has no '"); - fprintf(main->output.stream, "%s%s%s", main->context.set.important.before->string, controller_rule_action_type_name(action).string, main->context.set.important.after->string); - fprintf(main->output.stream, "' action to execute and would '"); - fprintf(main->output.stream, "%s%s%s", main->context.set.important.before->string, options & controller_process_option_require ? controller_string_fail_s : controller_string_succeed_s, main->context.set.important.after->string); - fprintf(main->output.stream, "' because it is '"); - fprintf(main->output.stream, "%s%s%s", main->context.set.important.before->string, options & controller_process_option_require ? controller_string_required_s : controller_string_optional_s, main->context.set.important.after->string); - fprintf(main->output.stream, "'.%c", f_string_eol_s[0]); + flockfile(main->output.stream); + + fl_print_string("%cRule '", main->output.stream, f_string_eol_s[0]); + fl_print_string("%[%Q%]' has no '", main->output.stream, main->context.set.title, rule.name, main->context.set.title); + fl_print_string("%[%q%]' action to execute and would '", main->output.stream, main->context.set.title, controller_rule_action_type_name(action), main->context.set.title); + fl_print_string("%[%s%]' because it is '", main->output.stream, main->context.set.important, options & controller_process_option_require ? controller_string_fail_s : controller_string_succeed_s, main->context.set.important); + fl_print_string("%[%s%]'.%c", main->output.stream, main->context.set.important, options & controller_process_option_require ? controller_string_required_s : controller_string_optional_s, main->context.set.important, f_string_eol_s[0]); + + funlockfile(main->output.stream); } } - fprintf(main->output.stream, "%c", f_string_eol_s[0]); - fprintf(main->output.stream, "Rule %s%s%s {%c", main->context.set.title.before->string, rule.alias.used ? rule.alias.string : f_string_empty_s, main->context.set.title.after->string, f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s %s%c", main->context.set.important.before->string, controller_string_name_s, main->context.set.important.after->string, rule.name.used ? rule.name.string : f_string_empty_s, f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s %s%c", main->context.set.important.before->string, controller_string_how_s, main->context.set.important.after->string, options & controller_process_option_asynchronous ? controller_string_asynchronous_s : controller_string_synchronous_s, f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s %s%c", main->context.set.important.before->string, controller_string_wait_s, main->context.set.important.after->string, options & controller_process_option_wait ? controller_string_yes : controller_string_no_s, f_string_eol_s[0]); + flockfile(main->output.stream); - if (f_capability_supported()) { - fprintf(main->output.stream, " %s%s%s ", main->context.set.important.before->string, controller_string_capability_s, main->context.set.important.after->string); + fl_print_string("%cRule %[%Q%] {%c", main->output.stream, f_string_eol_s[0], main->context.set.title, rule.alias, main->context.set.title, f_string_eol_s[0]); + fl_print_string(" %[%s%] %Q%c", main->output.stream, main->context.set.important, controller_string_name_s, main->context.set.important, rule.name, f_string_eol_s[0]); + fl_print_string(" %[%s%] %s%c", main->output.stream, main->context.set.important, controller_string_how_s, main->context.set.important, options & controller_process_option_asynchronous ? controller_string_asynchronous_s : controller_string_synchronous_s, f_string_eol_s[0]); + fl_print_string(" %[%s%] %s%c", main->output.stream, main->context.set.important, controller_string_wait_s, main->context.set.important, options & controller_process_option_wait ? controller_string_yes : controller_string_no_s, f_string_eol_s[0]); + fl_print_string(" %[%s%] ", main->output.stream, main->context.set.important, controller_string_capability_s, main->context.set.important); + if (f_capability_supported()) { if (rule.capability) { cache->action.generic.used = 0; if (F_status_is_error_not(f_capability_to_text(rule.capability, &cache->action.generic))) { - fprintf(main->output.stream, "%s", cache->action.generic.string); + f_print_dynamic_safely(cache->action.generic, main->output.stream); } } - fprintf(main->output.stream, "%c", f_string_eol_s[0]); + f_print_terminated(f_string_eol_s, main->output.stream); } else { - fprintf(main->output.stream, " %s%s%s ", main->context.set.important.before->string, controller_string_capability_s, main->context.set.important.after->string); - fprintf(main->output.stream, "%s(unsupported)%s%c", main->context.set.warning.before->string, main->context.set.warning.after->string, f_string_eol_s[0]); + fl_print_string("%[(unsupported)%]%c", main->output.stream, main->context.set.warning, controller_string_capability_s, main->context.set.warning, f_string_eol_s[0]); } - fprintf(main->output.stream, " %s%s%s", main->context.set.important.before->string, controller_string_control_group_s, main->context.set.important.after->string); + fl_print_string(" %[%s%]", main->output.stream, main->context.set.important, controller_string_control_group_s, main->context.set.important); if (rule.has & controller_rule_has_control_group) { - fprintf(main->output.stream, " %s", rule.control_group.as_new ? controller_string_new_s : controller_string_existing_s); + fl_print_string(" %s", main->output.stream, rule.control_group.as_new ? controller_string_new_s : controller_string_existing_s); for (i = 0; i < rule.control_group.groups.used; ++i) { if (rule.control_group.groups.array[i].used) { - fprintf(main->output.stream, "%s", f_string_space_s); - fll_print_dynamic(main->output.stream, rule.control_group.groups.array[i]); + fl_print_string(" %Q", main->output.stream, rule.control_group.groups.array[i]); } } // for } - fprintf(main->output.stream, "%c", f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s", main->context.set.important.before->string, controller_string_nice_s, main->context.set.important.after->string); + fl_print_string("%c %[%s%]", main->output.stream, f_string_eol_s[0], main->context.set.important, controller_string_nice_s, main->context.set.important); if (rule.has & controller_rule_has_nice) { - fprintf(main->output.stream, " %i", rule.nice); + fl_print_string(" %i", main->output.stream, rule.nice); } - fprintf(main->output.stream, "%c", f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s", main->context.set.important.before->string, controller_string_scheduler_s, main->context.set.important.after->string); + fl_print_string("%c %[%s%]", main->output.stream, f_string_eol_s[0], main->context.set.important, controller_string_scheduler_s, main->context.set.important); if (rule.has & controller_rule_has_scheduler) { f_string_t policy = ""; @@ -5317,78 +5399,70 @@ extern "C" { policy = controller_string_round_robin_s; } - fprintf(main->output.stream, " %s %i", policy, rule.scheduler.priority); + fl_print_string(" %s %i", main->output.stream, policy, rule.scheduler.priority); } - fprintf(main->output.stream, "%c", f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s %s%c", main->context.set.important.before->string, controller_string_script_s, main->context.set.important.after->string, rule.script.used ? rule.script.string : f_string_empty_s, f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s", main->context.set.important.before->string, controller_string_user_s, main->context.set.important.after->string); + fl_print_string("%c %[%s%] %Q%c", main->output.stream, f_string_eol_s[0], main->context.set.important, controller_string_script_s, main->context.set.important, rule.script, f_string_eol_s[0]); + fl_print_string(" %[%s%]", main->output.stream, main->context.set.important, controller_string_user_s, main->context.set.important); if (rule.has & controller_rule_has_user) { - fprintf(main->output.stream, " %i", rule.user); + fl_print_string(" %i", main->output.stream, rule.user); } - fprintf(main->output.stream, "%c", f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_affinity_s, main->context.set.important.after->string, f_string_eol_s[0]); + fl_print_string("%c %[%s%] {%c", main->output.stream, f_string_eol_s[0], main->context.set.important, controller_string_affinity_s, main->context.set.important, f_string_eol_s[0]); for (i = 0; i < rule.affinity.used; ++i) { - fprintf(main->output.stream, " %i%c", rule.affinity.array[i], f_string_eol_s[0]); + fl_print_string(" %i%c", main->output.stream, rule.affinity.array[i], f_string_eol_s[0]); } // for - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_define_s, main->context.set.important.after->string, f_string_eol_s[0]); + fl_print_string(" }%c %[%s%] {%c", main->output.stream, f_string_eol_s[0], main->context.set.important, controller_string_define_s, main->context.set.important, f_string_eol_s[0]); for (i = 0; i < rule.define.used; ++i) { if (rule.define.array[i].name.used && rule.define.array[i].value.used) { - fprintf(main->output.stream, " %s %s=%s %s%c", rule.define.array[i].name.string, main->context.set.important.before->string, main->context.set.important.after->string, rule.define.array[i].value.string, f_string_eol_s[0]); + fl_print_string(" %Q %[=%] %Q%c", main->output.stream, rule.define.array[i].name, main->context.set.important, main->context.set.important, rule.define.array[i].value, f_string_eol_s[0]); } } // for - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_environment_s, main->context.set.important.after->string, f_string_eol_s[0]); + fl_print_string(" }%c %[%s%] {%c", main->output.stream, f_string_eol_s[0], main->context.set.important, controller_string_environment_s, main->context.set.important, f_string_eol_s[0]); for (i = 0; i < rule.environment.used; ++i) { if (rule.environment.array[i].used) { - fprintf(main->output.stream, " %s%c", rule.environment.array[i].string, f_string_eol_s[0]); + fl_print_string(" %Q%c", main->output.stream, rule.environment.array[i], f_string_eol_s[0]); } } // for - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_parameter_s, main->context.set.important.after->string, f_string_eol_s[0]); + fl_print_string(" }%c %[%s%] {%c", main->output.stream, f_string_eol_s[0], main->context.set.important, controller_string_parameter_s, main->context.set.important, f_string_eol_s[0]); for (i = 0; i < rule.parameter.used; ++i) { if (rule.parameter.array[i].name.used && rule.parameter.array[i].value.used) { - fprintf(main->output.stream, " %s %s=%s %s%c", rule.parameter.array[i].name.string, main->context.set.important.before->string, main->context.set.important.after->string, rule.parameter.array[i].value.string, f_string_eol_s[0]); + fl_print_string(" %Q %[=%] %Q%c", main->output.stream, rule.parameter.array[i].name, main->context.set.important, main->context.set.important, rule.parameter.array[i].value, f_string_eol_s[0]); } } // for - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_group_s, main->context.set.important.after->string, f_string_eol_s[0]); + fl_print_string(" }%c %[%s%] {%c", main->output.stream, f_string_eol_s[0], main->context.set.important, controller_string_group_s, main->context.set.important, f_string_eol_s[0]); if (rule.has & controller_rule_has_group) { - fprintf(main->output.stream, " %i%c", rule.group, f_string_eol_s[0]); + fl_print_string(" %i%c", main->output.stream, rule.group, f_string_eol_s[0]); for (i = 0; i < rule.groups.used; ++i) { - fprintf(main->output.stream, " %i%c", rule.groups.array[i], f_string_eol_s[0]); + fl_print_string(" %i%c", main->output.stream, rule.groups.array[i], f_string_eol_s[0]); } // for } - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_limit_s, main->context.set.important.after->string, f_string_eol_s[0]); + fl_print_string(" }%c %[%s%] {%c", main->output.stream, f_string_eol_s[0], main->context.set.important, controller_string_limit_s, main->context.set.important, f_string_eol_s[0]); for (i = 0; i < rule.limits.used; ++i) { - fprintf(main->output.stream, " %s %s=%s %llu %llu%c", controller_rule_setting_limit_type_name(rule.limits.array[i].type).string, main->context.set.important.before->string, main->context.set.important.after->string, rule.limits.array[i].value.rlim_cur, rule.limits.array[i].value.rlim_max, f_string_eol_s[0]); + fl_print_string(" %Q %[=%] %ul %ul%c", main->output.stream, controller_rule_setting_limit_type_name(rule.limits.array[i].type), main->context.set.important, main->context.set.important, rule.limits.array[i].value.rlim_cur, rule.limits.array[i].value.rlim_max, f_string_eol_s[0]); } // for - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_on_s, main->context.set.important.after->string, f_string_eol_s[0]); + fl_print_string(" }%c %[%s%] {%c", main->output.stream, f_string_eol_s[0], main->context.set.important, controller_string_on_s, main->context.set.important, f_string_eol_s[0]); for (i = 0; i < rule.ons.used; ++i) { - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_action_s, main->context.set.important.after->string, f_string_eol_s[0]); + fl_print_string(" %[%s%] {%c", main->output.stream, main->context.set.important, controller_string_action_s, main->context.set.important, f_string_eol_s[0]); { f_string_t action = ""; @@ -5421,43 +5495,40 @@ extern "C" { action = controller_string_thaw_s; } - fprintf(main->output.stream, " %s%s%s %s%c", main->context.set.important.before->string, controller_string_type_s, main->context.set.important.after->string, action, f_string_eol_s[0]); + fl_print_string(" %[%s%] %s%c", main->output.stream, main->context.set.important, controller_string_type_s, main->context.set.important, action, f_string_eol_s[0]); } - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_need_s, main->context.set.important.after->string, f_string_eol_s[0]); + fl_print_string(" %[%s%] {%c", main->output.stream, main->context.set.important, controller_string_need_s, main->context.set.important, f_string_eol_s[0]); for (j = 0; j < rule.ons.array[i].need.used; ++j) { if (rule.ons.array[i].need.array[j].used) { - fprintf(main->output.stream, " %s%c", rule.ons.array[i].need.array[j].string, f_string_eol_s[0]); + fl_print_string(" %Q%c", main->output.stream, rule.ons.array[i].need.array[j], f_string_eol_s[0]); } } // for - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_want_s, main->context.set.important.after->string, f_string_eol_s[0]); + fl_print_string(" }%c %[%s%] {%c", main->output.stream, f_string_eol_s[0], main->context.set.important, controller_string_want_s, main->context.set.important, f_string_eol_s[0]); for (j = 0; j < rule.ons.array[i].want.used; ++j) { if (rule.ons.array[i].want.array[j].used) { - fprintf(main->output.stream, " %s%c", rule.ons.array[i].want.array[j].string, f_string_eol_s[0]); + fl_print_string(" %Q%c", main->output.stream, rule.ons.array[i].want.array[j], f_string_eol_s[0]); } } // for - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_wish_s, main->context.set.important.after->string, f_string_eol_s[0]); + fl_print_string(" }%c %[%s%] {%c", main->output.stream, f_string_eol_s[0], main->context.set.important, controller_string_wish_s, main->context.set.important, f_string_eol_s[0]); for (j = 0; j < rule.ons.array[i].wish.used; ++j) { if (rule.ons.array[i].wish.array[j].used) { - fprintf(main->output.stream, " %s%c", rule.ons.array[i].wish.array[j].string, f_string_eol_s[0]); + fl_print_string(" %Q%c", main->output.stream, rule.ons.array[i].wish.array[j], f_string_eol_s[0]); } } // for - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); + fl_print_string(" }%c }%c", main->output.stream, f_string_eol_s[0], f_string_eol_s[0]); } // for - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); + fl_print_string(" }%c", main->output.stream, f_string_eol_s[0]); if (rule.items.used) { controller_rule_action_t *action = 0; @@ -5471,52 +5542,58 @@ extern "C" { item = &rule.items.array[i]; - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_item_s, main->context.set.important.after->string, f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s %s%c", main->context.set.important.before->string, controller_string_type_s, main->context.set.important.after->string, controller_rule_item_type_name(item->type).string, f_string_eol_s[0]); + fl_print_string(" %[%s%] {%c", main->output.stream, main->context.set.important, controller_string_item_s, main->context.set.important, f_string_eol_s[0]); + fl_print_string(" %[%s%] %Q%c", main->output.stream, main->context.set.important, controller_string_type_s, main->context.set.important, controller_rule_item_type_name(item->type), f_string_eol_s[0]); for (j = 0; j < item->actions.used; ++j) { action = &item->actions.array[j]; - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_action_s, main->context.set.important.after->string, f_string_eol_s[0]); - fprintf(main->output.stream, " %s%s%s %s%c", main->context.set.important.before->string, controller_string_type_s, main->context.set.important.after->string, controller_rule_action_type_name(action->type).string, f_string_eol_s[0]); + fl_print_string(" %[%s%] {%c", main->output.stream, main->context.set.important, controller_string_action_s, main->context.set.important, f_string_eol_s[0]); + fl_print_string(" %[%s%] %q%c", main->output.stream, main->context.set.important, controller_string_type_s, main->context.set.important, controller_rule_action_type_name(action->type), f_string_eol_s[0]); if (item->type == controller_rule_item_type_script || item->type == controller_rule_item_type_utility) { - fprintf(main->output.stream, " %s%s%s {%c", main->context.set.important.before->string, controller_string_parameter_s, main->context.set.important.after->string, f_string_eol_s[0]); + fl_print_string(" %[%s%] {%c", main->output.stream, main->context.set.important, controller_string_parameter_s, main->context.set.important, f_string_eol_s[0]); parameter = &action->parameters.array[0]; if (parameter->used) { - fprintf(main->output.stream, " "); + f_print_terminated(" ", main->output.stream); for (k = 0; k < parameter->used; ++k) { - fprintf(main->output.stream, "%c", parameter->string[k]); - - if (parameter->string[k] == f_fss_eol && k + 1 < parameter->used) { - fprintf(main->output.stream, " "); + if (parameter->string[k] == f_fss_eol) { + if (k + 1 < parameter->used) { + f_print_terminated(f_string_eol_s, main->output.stream); + f_print_terminated(" ", main->output.stream); + } + } + else { + f_print_character_safely(parameter->string[k], main->output.stream); } } // for - fprintf(main->output.stream, "%c", f_string_eol_s[0]); + f_print_terminated(f_string_eol_s, main->output.stream); } - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); + fl_print_string(" }%c", main->output.stream, f_string_eol_s[0]); } else { for (k = 0; k < action->parameters.used; ++k) { - fprintf(main->output.stream, " %s%s%s %s%c", main->context.set.important.before->string, controller_string_parameter_s, main->context.set.important.after->string, action->parameters.array[k].string, f_string_eol_s[0]); + fl_print_string(" %s%s%s %Q%c", main->output.stream, main->context.set.important, controller_string_parameter_s, main->context.set.important, action->parameters.array[k], f_string_eol_s[0]); } // for } - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); + fl_print_string(" }%c", main->output.stream, f_string_eol_s[0]); } // for - fprintf(main->output.stream, " }%c", f_string_eol_s[0]); + fl_print_string(" }%c", main->output.stream, f_string_eol_s[0]); } // for } - fprintf(main->output.stream, "}%c", f_string_eol_s[0]); + fl_print_string("}%c", main->output.stream, f_string_eol_s[0]); + + funlockfile(main->output.stream); controller_print_unlock_flush(main->output.stream, &global.thread->lock.print); } diff --git a/level_3/controller/c/private-rule.h b/level_3/controller/c/private-rule.h index 268a4b8..bf3971d 100644 --- a/level_3/controller/c/private-rule.h +++ b/level_3/controller/c/private-rule.h @@ -264,7 +264,7 @@ extern "C" { /** * Print an error or warning message related to the failed execution of some program or script. * - * @param print + * @param output * The error or warning output structure. * @param script_is * If TRUE, then this represents a script. @@ -277,13 +277,13 @@ extern "C" { * The status code representing the failure (without the error bit set). */ #ifndef _di_controller_rule_item_error_print_execute_ - extern void controller_rule_item_error_print_execute(const fll_error_print_t print, const bool script_is, const f_string_t name, const int code, const f_status_t status) f_attribute_visibility_internal; + extern void controller_rule_item_error_print_execute(const fll_error_print_t output, const bool script_is, const f_string_t name, const int code, const f_status_t status) f_attribute_visibility_internal; #endif // _di_controller_rule_item_error_print_execute_ /** * Print an error or warning message related to the failed execution of some program or script for when the program or script is not found. * - * @param print + * @param output * The error or warning output structure. * @param script_is * If TRUE, then this represents a script. @@ -292,47 +292,48 @@ extern "C" { * The code returned by the executed program or script. */ #ifndef _di_controller_rule_item_error_print_execute_not_found_ - extern void controller_rule_item_error_print_execute_not_found(const fll_error_print_t print, const bool script_is, const f_string_t name) f_attribute_visibility_internal; + extern void controller_rule_item_error_print_execute_not_found(const fll_error_print_t output, const bool script_is, const f_string_t name) f_attribute_visibility_internal; #endif // _di_controller_rule_item_error_print_execute_not_found_ /** * Print an error or warning message related to need/want/wish settings of some rule. * - * @param print + * @param output * The error or warning output structure. * @param need_want_wish - * The appropriate string, such as "needs", "wants", or "wishes for" to print when describing this error/warning. + * The appropriate string, such as "needs", "wants", or "wishes for" to output when describing this error/warning. + * This string is expected to already be "safe" (no control characters, etc..). * @param value * The value that is the error or warning. * @param why * A short explanation on why this is an error or warning. */ #ifndef _di_controller_rule_item_error_print_need_want_wish_ - extern void controller_rule_item_error_print_need_want_wish(const fll_error_print_t print, const f_string_t need_want_wish, const f_string_t value, const f_string_t why) f_attribute_visibility_internal; + extern void controller_rule_item_error_print_need_want_wish(const fll_error_print_t output, const f_string_t need_want_wish, const f_string_t value, const f_string_t why) f_attribute_visibility_internal; #endif // _di_controller_rule_item_error_print_need_want_wish_ /** * Print an error or warning message about some rule not being loaded. * - * @param print + * @param output * The error or warning output structure. * @param alias * The rule alias of the rule that is not loaded. */ #ifndef _di_controller_rule_item_error_print_rule_not_loaded_ - extern void controller_rule_item_error_print_rule_not_loaded(const fll_error_print_t print, const f_string_t alias) f_attribute_visibility_internal; + extern void controller_rule_item_error_print_rule_not_loaded(const fll_error_print_t output, const f_string_t alias) f_attribute_visibility_internal; #endif // _di_controller_rule_item_error_print_rule_not_loaded_ /** * Print an error or warning message about some rule not having the pid file information. * - * @param print + * @param output * The error or warning output structure. * @param alias * The rule alias of the rule that is missing the pid file designation. */ #ifndef _di_controller_rule_action_error_missing_pid_ - extern void controller_rule_action_error_missing_pid(const fll_error_print_t print, const f_string_t alias) f_attribute_visibility_internal; + extern void controller_rule_action_error_missing_pid(const fll_error_print_t output, const f_string_t alias) f_attribute_visibility_internal; #endif // _di_controller_rule_action_error_missing_pid_ /** diff --git a/level_3/controller/c/private-thread.c b/level_3/controller/c/private-thread.c index 143db65..cedb48c 100644 --- a/level_3/controller/c/private-thread.c +++ b/level_3/controller/c/private-thread.c @@ -229,10 +229,13 @@ extern "C" { if (main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&thread.lock.print); - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(main->error.to.stream, "%s%sThe pid file '", main->error.context.before->string, main->error.prefix ? main->error.prefix : f_string_empty_s); - fprintf(main->error.to.stream, "%s%s%s%s", main->error.context.after->string, main->error.notable.before->string, setting->path_pid.string, main->error.notable.after->string); - fprintf(main->error.to.stream, "%s' must not already exist.%s%c", main->error.context.before->string, main->error.context.after->string, f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_string("%c%[%SThe pid file '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context); + fl_print_string("%[%S%]", main->error.to.stream, main->error.notable, setting->path_pid.string, main->error.notable); + fl_print_string("%[' must not already exist.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); controller_print_unlock_flush(main->error.to.stream, &thread.lock.print); } @@ -722,10 +725,13 @@ extern "C" { if (main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&entry->global->thread->lock.print); - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(main->error.to.stream, "%s%sThe pid file '", main->error.context.before->string, main->error.prefix ? main->error.prefix : f_string_empty_s); - fprintf(main->error.to.stream, "%s%s%s%s", main->error.context.after->string, main->error.notable.before->string, entry->setting->path_pid.string, main->error.notable.after->string); - fprintf(main->error.to.stream, "%s' must not already exist.%s%c", main->error.context.before->string, main->error.context.after->string, f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_string("%c%[%SThe pid file '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context); + fl_print_string("%[%Q%]", main->error.to.stream, main->error.notable, entry->setting->path_pid, main->error.notable); + fl_print_string("%[' must not already exist.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); controller_print_unlock_flush(main->error.to.stream, &entry->global->thread->lock.print); } @@ -763,10 +769,13 @@ extern "C" { if (main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&entry->global->thread->lock.print); - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(main->error.to.stream, "%s%sFailed while processing requested failsafe item '", main->error.context.before->string, main->error.prefix ? main->error.prefix : f_string_empty_s); - fprintf(main->error.to.stream, "%s%s%s%s", main->error.context.after->string, main->error.notable.before->string, entry->global->setting->entry.items.array[entry->global->setting->failsafe_enabled].name.string, main->error.notable.after->string); - fprintf(main->error.to.stream, "%s'.%s%c", main->error.context.before->string, main->error.context.after->string, f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_string("%c%[%SFailed while processing requested failsafe item '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context); + fl_print_string("%[%Q%]", main->error.to.stream, main->error.notable, entry->global->setting->entry.items.array[entry->global->setting->failsafe_enabled].name, main->error.notable); + fl_print_string("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); controller_print_unlock_flush(main->error.to.stream, &entry->global->thread->lock.print); } @@ -873,10 +882,13 @@ extern "C" { if (main->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&entry->global->thread->lock.print); - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - fprintf(main->error.to.stream, "%s%sFailed while processing requested failsafe item '", main->error.context.before->string, main->error.prefix ? main->error.prefix : f_string_empty_s); - fprintf(main->error.to.stream, "%s%s%s%s", main->error.context.after->string, main->error.notable.before->string, entry->global->setting->entry.items.array[entry->global->setting->failsafe_enabled].name.string, main->error.notable.after->string); - fprintf(main->error.to.stream, "%s'.%s%c", main->error.context.before->string, main->error.context.after->string, f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_string("%c%[%SFailed while processing requested failsafe item '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context); + fl_print_string("%[%Q%]", main->error.to.stream, main->error.notable, entry->global->setting->entry.items.array[entry->global->setting->failsafe_enabled].name, main->error.notable); + fl_print_string("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); controller_print_unlock_flush(main->error.to.stream, &entry->global->thread->lock.print); } -- 1.8.3.1