From: Kevin Day Date: Thu, 7 Apr 2022 06:11:20 +0000 (-0500) Subject: Update: Add new return status codes: F_debug, F_error, F_fine, and F_warning. X-Git-Tag: 0.5.10~229 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=5d88ef546f9dac20e8f5ad4bd7c3b5de7e01333b;p=fll Update: Add new return status codes: F_debug, F_error, F_fine, and F_warning. Also add handling of F_error to the standard error handler. --- diff --git a/level_0/f_file/c/file.c b/level_0/f_file/c/file.c index 718a4fa..c0915d5 100644 --- a/level_0/f_file/c/file.c +++ b/level_0/f_file/c/file.c @@ -2075,7 +2075,7 @@ extern "C" { if (ferror(file.stream)) { funlockfile(file.stream); - return F_status_set_error(F_failure); // @todo create F_error and return F_error. + return F_status_set_error(F_error); } f_status_t status = F_none; @@ -2129,7 +2129,7 @@ extern "C" { } if (ferror(file.stream)) { - return F_status_set_error(F_failure); // @todo create F_error and return F_error. + return F_status_set_error(F_error); } { @@ -2182,7 +2182,7 @@ extern "C" { if (ferror(file.stream)) { funlockfile(file.stream); - return F_status_set_error(F_failure); // @todo create F_error and return F_error. + return F_status_set_error(F_error); } { diff --git a/level_0/f_file/c/file.h b/level_0/f_file/c/file.h index 88147a0..98a9c05 100644 --- a/level_0/f_file/c/file.h +++ b/level_0/f_file/c/file.h @@ -2069,6 +2069,7 @@ extern "C" { * * F_block (with error bit) if file descriptor is set to non-block and the read would result in a blocking operation. * F_buffer (with error bit) if the buffer is invalid. + * F_error (with error bit) if the file is already in the error state at the start of this function. * F_file_closed (with error bit) if file is not open. * F_file_descriptor (with error bit) if the file descriptor is invalid. * F_file_type_directory (with error bit) if file descriptor represents a directory. @@ -2103,6 +2104,7 @@ extern "C" { * * F_block (with error bit) if file descriptor is set to non-block and the read would result in a blocking operation. * F_buffer (with error bit) if the buffer is invalid. + * F_error (with error bit) if the file is already in the error state at the start of this function. * F_file_closed (with error bit) if file is not open. * F_file_descriptor (with error bit) if the file descriptor is invalid. * F_file_type_directory (with error bit) if file descriptor represents a directory. @@ -2141,6 +2143,7 @@ extern "C" { * * F_block (with error bit) if file descriptor is set to non-block and the read would result in a blocking operation. * F_buffer (with error bit) if the buffer is invalid. + * F_error (with error bit) if the file is already in the error state at the start of this function. * F_file_closed (with error bit) if file is not open. * F_file_descriptor (with error bit) if the file descriptor is invalid. * F_file_type_directory (with error bit) if file descriptor represents a directory. diff --git a/level_0/f_status/c/status.h b/level_0/f_status/c/status.h index 4b6a938..b1d1d75 100644 --- a/level_0/f_status/c/status.h +++ b/level_0/f_status/c/status.h @@ -430,6 +430,17 @@ extern "C" { F_write_only, #endif // _di_f_status_basic_ + #ifndef _di_f_status_return_ + F_debug, + F_debug_not, + F_error, + F_error_not, + F_fine, + F_fine_not, + F_warning, + F_warning_not, + #endif // _di_f_status_return_ + #ifndef _di_f_status_array_ F_array, F_array_not, diff --git a/level_2/fll_error/c/error.c b/level_2/fll_error/c/error.c index 92b7ea4..00b69f8 100644 --- a/level_2/fll_error/c/error.c +++ b/level_2/fll_error/c/error.c @@ -100,6 +100,20 @@ extern "C" { return F_false; } + if (status == F_error) { + if (print.verbosity != f_console_verbosity_quiet_e) { + flockfile(print.to.stream); + + fl_print_format("%r%[%QFailed to %Q %Q '%]", print.to.stream, f_string_eol_s, print.context, print.prefix, operation, type_name, print.context); + fl_print_format("%[%Q%]", print.to.stream, print.notable, name, print.notable); + fl_print_format("%[', already in an error state.%]%r", print.to.stream, print.context, print.context, f_string_eol_s); + + funlockfile(print.to.stream); + } + + return F_false; + } + if (status == F_failure) { if (print.verbosity != f_console_verbosity_quiet_e) { flockfile(print.to.stream); diff --git a/level_2/fll_error/c/private-error.c b/level_2/fll_error/c/private-error.c index 01563f0..cbbde44 100644 --- a/level_2/fll_error/c/private-error.c +++ b/level_2/fll_error/c/private-error.c @@ -56,6 +56,22 @@ extern "C" { return F_false; } + if (status == F_error) { + if (print.verbosity != f_console_verbosity_quiet_e) { + flockfile(print.to.stream); + + fl_print_format("%r%[%QAn error has occurred", print.to.stream, f_string_eol_s, print.context, print.prefix); + + private_fll_error_print_function(print, function); + + fl_print_format(".%]%r", print.to.stream, print.context, f_string_eol_s); + + funlockfile(print.to.stream); + } + + return F_false; + } + if (status == F_file_found_not) { if (print.verbosity != f_console_verbosity_quiet_e) { flockfile(print.to.stream); diff --git a/level_2/fll_status_string/c/status_string.c b/level_2/fll_status_string/c/status_string.c index 749c23c..0d7fdc2 100644 --- a/level_2/fll_status_string/c/status_string.c +++ b/level_2/fll_status_string/c/status_string.c @@ -1969,6 +1969,56 @@ extern "C" { } #endif // _di_f_status_basic_ + #ifndef _di_f_status_return_ + if (fl_string_dynamic_compare(name, f_status_debug_s) == F_equal_to) { + *code = F_debug; + + return F_none; + } + + if (fl_string_dynamic_compare(name, f_status_debug_not_s) == F_equal_to) { + *code = F_debug_not; + + return F_none; + } + + if (fl_string_dynamic_compare(name, f_status_error_s) == F_equal_to) { + *code = F_error; + + return F_none; + } + + if (fl_string_dynamic_compare(name, f_status_error_not_s) == F_equal_to) { + *code = F_error_not; + + return F_none; + } + + if (fl_string_dynamic_compare(name, f_status_fine_s) == F_equal_to) { + *code = F_fine; + + return F_none; + } + + if (fl_string_dynamic_compare(name, f_status_fine_not_s) == F_equal_to) { + *code = F_fine_not; + + return F_none; + } + + if (fl_string_dynamic_compare(name, f_status_warning_s) == F_equal_to) { + *code = F_warning; + + return F_none; + } + + if (fl_string_dynamic_compare(name, f_status_warning_not_s) == F_equal_to) { + *code = F_warning_not; + + return F_none; + } + #endif // _di_f_status_return_ + #ifndef _di_f_status_array_ if (fl_string_dynamic_compare(name, f_status_array_s) == F_equal_to) { *code = F_array;