From e89dc4f625404730f8c3713d01261fafcb721717 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 20 Feb 2023 00:13:37 -0600 Subject: [PATCH] Progress: Continue work on Featureless Make, focusing on printing. Relax parameter checks on most of the print functions. Add check to see if file.stream is set and if not return F_stream_not but not an error. Make sue similar string checks are consistently used. This should better allow for more flexible designs around stream and string data. This eliminates a good amount of parameter checking. Further simplify printing that has a common structure into more common print function. This print function may end up being moved to a more common path as I can see printing from other directory trees in Featureless Make utilizing this. --- level_0/f_print/c/print.c | 270 ++++++----------------- level_0/f_print/c/print.h | 41 ++++ level_1/fl_print/c/print.c | 229 ++++++------------- level_1/fl_print/c/print.h | 43 ++++ level_2/fll_print/c/print.c | 162 ++++++++++++++ level_2/fll_print/c/print.h | 170 +++++++++++++- level_3/fake/c/main/make/operate.c | 2 +- level_3/fake/c/main/make/operate_validate_type.c | 102 ++------- level_3/fake/c/main/make/print-error.c | 135 +++++++----- level_3/fake/c/main/make/print-error.h | 161 +++++++++++++- 10 files changed, 801 insertions(+), 514 deletions(-) diff --git a/level_0/f_print/c/print.c b/level_0/f_print/c/print.c index ee56117..a1fac1f 100644 --- a/level_0/f_print/c/print.c +++ b/level_0/f_print/c/print.c @@ -33,10 +33,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_ f_status_t f_print(const f_string_t string, const f_array_length_t length, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!length || !string) return F_data_not; return private_f_print(string, length, file); @@ -45,9 +43,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_character_ f_status_t f_print_character(const f_char_t character, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + + if (!file.stream) return F_stream_not; clearerr_unlocked(file.stream); @@ -57,9 +54,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_character_safely_ f_status_t f_print_character_safely(const f_char_t character, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + + if (!file.stream) return F_stream_not; clearerr_unlocked(file.stream); @@ -95,13 +91,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_dynamic_ f_status_t f_print_dynamic(const f_string_static_t buffer, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || !buffer.string) return F_data_not; return private_f_print(buffer.string, buffer.used, file); } @@ -109,13 +101,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_dynamic_partial_ f_status_t f_print_dynamic_partial(const f_string_static_t buffer, const f_string_range_t range, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -129,13 +117,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_dynamic_partial_raw_ f_status_t f_print_dynamic_partial_raw(const f_string_static_t buffer, const f_string_range_t range, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -149,13 +133,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_dynamic_partial_raw_safely_ f_status_t f_print_dynamic_partial_raw_safely(const f_string_static_t buffer, const f_string_range_t range, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -169,13 +149,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_dynamic_partial_safely_ f_status_t f_print_dynamic_partial_safely(const f_string_static_t buffer, const f_string_range_t range, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -189,10 +165,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_dynamic_raw_ f_status_t f_print_dynamic_raw(const f_string_static_t buffer, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used || !buffer.string) return F_data_not; return private_f_print_raw(buffer.string, buffer.used, file); @@ -201,10 +175,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_dynamic_raw_safely_ f_status_t f_print_dynamic_raw_safely(const f_string_static_t buffer, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used || !buffer.string) return F_data_not; return private_f_print_raw_safely(buffer.string, buffer.used, file); @@ -213,10 +185,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_dynamic_safely_ f_status_t f_print_dynamic_safely(const f_string_static_t buffer, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used || !buffer.string) return F_data_not; return private_f_print_safely(buffer.string, buffer.used, file); @@ -225,10 +195,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_ 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, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!length || !string) return F_data_not; return private_f_print_except(string, offset, length, except, file); @@ -237,10 +205,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_dynamic_ f_status_t f_print_except_dynamic(const f_string_static_t buffer, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used || !buffer.string) return F_data_not; return private_f_print_except(buffer.string, 0, buffer.used, except, file); @@ -249,13 +215,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_dynamic_partial_ f_status_t f_print_except_dynamic_partial(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -269,13 +231,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_dynamic_partial_raw_ f_status_t f_print_except_dynamic_partial_raw(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -289,13 +247,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_dynamic_partial_raw_safely_ f_status_t f_print_except_dynamic_partial_raw_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -309,13 +263,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_dynamic_partial_safely_ f_status_t f_print_except_dynamic_partial_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -329,10 +279,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_dynamic_raw_ f_status_t f_print_except_dynamic_raw(const f_string_static_t buffer, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used || !buffer.string) return F_data_not; return private_f_print_except_raw(buffer.string, 0, buffer.used, except, file); @@ -341,10 +289,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_dynamic_raw_safely_ f_status_t f_print_except_dynamic_raw_safely(const f_string_static_t buffer, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used || !buffer.string) return F_data_not; return private_f_print_except_raw_safely(buffer.string, 0, buffer.used, except, file); @@ -353,10 +299,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_dynamic_safely_ f_status_t f_print_except_dynamic_safely(const f_string_static_t buffer, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used || !buffer.string) return F_data_not; return private_f_print_except_safely(buffer.string, 0, buffer.used, except, file); @@ -365,13 +309,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_in_ 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, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!length || !string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!length || !string) return F_data_not; return private_f_print_except_in(string, offset, length, except_at, except_in, file); } @@ -379,10 +319,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_in_dynamic_ f_status_t f_print_except_in_dynamic(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used || !buffer.string) return F_data_not; return private_f_print_except_in(buffer.string, 0, buffer.used, except_at, except_in, file); @@ -391,13 +329,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_in_dynamic_partial_ f_status_t f_print_except_in_dynamic_partial(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -411,13 +345,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_in_dynamic_partial_raw_ f_status_t f_print_except_in_dynamic_partial_raw(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -431,13 +361,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_in_dynamic_partial_raw_safely_ f_status_t f_print_except_in_dynamic_partial_raw_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -451,13 +377,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_in_dynamic_partial_safely_ f_status_t f_print_except_in_dynamic_partial_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used || !buffer.string) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -471,10 +393,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_in_dynamic_raw_ f_status_t f_print_except_in_dynamic_raw(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used || !buffer.string) return F_data_not; return private_f_print_except_in_raw(buffer.string, 0, buffer.used, except_at, except_in, file); @@ -483,10 +403,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_in_dynamic_raw_safely_ f_status_t f_print_except_in_dynamic_raw_safely(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used || !buffer.string) return F_data_not; return private_f_print_except_in_raw_safely(buffer.string, 0, buffer.used, except_at, except_in, file); @@ -495,10 +413,8 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_in_dynamic_safely_ f_status_t f_print_except_in_dynamic_safely(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used || !buffer.string) return F_data_not; return private_f_print_except_in_safely(buffer.string, 0, buffer.used, except_at, except_in, file); @@ -507,13 +423,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #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 offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!length || !string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!length || !string) return F_data_not; return private_f_print_except_in_raw(string, offset, length, except_at, except_in, file); } @@ -521,13 +433,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_in_raw_safely_ f_status_t f_print_except_in_raw_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, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!length || !string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!length || !string) return F_data_not; return private_f_print_except_in_raw_safely(string, offset, length, except_at, except_in, file); } @@ -535,13 +443,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #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 offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!length || !string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!length || !string) return F_data_not; return private_f_print_except_in_safely(string, offset, length, except_at, except_in, file); } @@ -549,13 +453,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_raw_ 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, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!length || !string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!length || !string) return F_data_not; return private_f_print_except_raw(string, offset, length, except, file); } @@ -563,13 +463,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_raw_safely_ f_status_t f_print_except_raw_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!length || !string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!length || !string) return F_data_not; return private_f_print_except_raw_safely(string, offset, length, except, file); } @@ -577,13 +473,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_except_safely_ 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, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!length || !string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!length || !string) return F_data_not; return private_f_print_except_safely(string, offset, length, except, file); } @@ -591,13 +483,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_raw_ f_status_t f_print_raw(const f_string_t string, const f_array_length_t length, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!length || !string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!length || !string) return F_data_not; return private_f_print_raw(string, length, file); } @@ -605,13 +493,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_raw_safely_ f_status_t f_print_raw_safely(const f_string_t string, const f_array_length_t length, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!length || !string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!length || !string) return F_data_not; return private_f_print_raw_safely(string, length, file); } @@ -619,13 +503,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_raw_terminated_ f_status_t f_print_raw_terminated(const f_string_t string, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!string) return F_data_not; // The f_print_raw_terminated() and f_print_terminated() are functionality identical due to being NULL terminated. return private_f_print_terminated(string, file); @@ -634,13 +514,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_safely_ f_status_t f_print_safely(const f_string_t string, const f_array_length_t length, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!length || !string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!length || !string) return F_data_not; return private_f_print_safely(string, length, file); } @@ -655,13 +531,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_safely_terminated_ f_status_t f_print_safely_terminated(const f_string_t string, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!string) return F_data_not; f_array_length_t start = 0; f_array_length_t total = 0; @@ -765,13 +637,9 @@ static inline f_status_t private_inline_f_print_write_unlocked(const f_string_t #ifndef _di_f_print_terminated_ f_status_t f_print_terminated(const f_string_t string, const f_file_t file) { - #ifndef _di_level_0_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - if (!string) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!string) return F_data_not; return private_f_print_terminated(string, file); } diff --git a/level_0/f_print/c/print.h b/level_0/f_print/c/print.h index 888afa7..d84c285 100644 --- a/level_0/f_print/c/print.h +++ b/level_0/f_print/c/print.h @@ -57,6 +57,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -85,6 +86,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure (fwrite_unlocked() returns 0). * F_parameter (with error bit) if a parameter is invalid. @@ -120,6 +122,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * F_utf on success, but character is a UTF-8 character. * * F_output (with error bit) on failure (fwrite_unlocked() returns 0). @@ -175,6 +178,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -207,6 +211,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -241,6 +246,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -278,6 +284,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -315,6 +322,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -349,6 +357,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -384,6 +393,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -419,6 +429,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -461,6 +472,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -495,6 +507,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -531,6 +544,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -569,6 +583,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -610,6 +625,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -651,6 +667,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -689,6 +706,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -728,6 +746,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -767,6 +786,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -813,6 +833,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -851,6 +872,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -891,6 +913,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -933,6 +956,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -975,6 +999,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1017,6 +1042,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1059,6 +1085,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1102,6 +1129,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1144,6 +1172,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1192,6 +1221,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1241,6 +1271,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1290,6 +1321,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1334,6 +1366,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1377,6 +1410,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1420,6 +1454,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1456,6 +1491,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1493,6 +1529,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1525,6 +1562,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1560,6 +1598,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1623,6 +1662,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. @@ -1655,6 +1695,7 @@ extern "C" { * @return * F_none on success. * F_data_not if there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. diff --git a/level_1/fl_print/c/print.c b/level_1/fl_print/c/print.c index b41b4ae..09f3e94 100644 --- a/level_1/fl_print/c/print.c +++ b/level_1/fl_print/c/print.c @@ -7,10 +7,9 @@ extern "C" { #ifndef _di_fl_print_format_ f_status_t fl_print_format(const f_string_t string, const f_file_t file, ...) { - #ifndef _di_level_1_parameter_checking_ - if (!string) return F_status_set_error(F_parameter); - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + + if (!file.stream) return F_stream_not; + if (!string) return F_data_not; f_status_t status = F_none; @@ -30,20 +29,34 @@ extern "C" { #ifndef _di_fl_print_format_convert_ f_string_t fl_print_format_convert(const f_string_t string, const f_file_t file, va_list ap, f_status_t * const status) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return 0; - #endif // _di_level_1_parameter_checking_ - return private_fl_print_format_convert(string, file, ap, status); + if (!file.stream) { + if (status) *status = F_stream_not; + + return 0; + } + + if (!string) { + if (status) *status = F_data_not; + + return 0; + } + + if (status) { + return private_fl_print_format_convert(string, file, ap, status); + } + + f_status_t status_local = F_none; + + return private_fl_print_format_convert(string, file, ap, &status_local); } #endif // _di_fl_print_format_convert_ #ifndef _di_fl_print_string_va_ f_status_t fl_print_string_va(const f_string_t string, const f_file_t file, va_list ap) { - #ifndef _di_level_1_parameter_checking_ - if (!string) return F_status_set_error(F_parameter); - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + + if (!file.stream) return F_stream_not; + if (!string) return F_data_not; f_status_t status = F_none; @@ -56,10 +69,8 @@ extern "C" { #ifndef _di_fl_print_trim_ f_status_t fl_print_trim(const f_string_t string, const f_array_length_t length, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!string || !length) return F_data_not; return private_fl_print_trim(string, length, file); @@ -68,10 +79,8 @@ extern "C" { #ifndef _di_fl_print_trim_raw_ f_status_t fl_print_trim_raw(const f_string_t string, const f_array_length_t length, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!string || !length) return F_data_not; return private_fl_print_trim_raw(string, length, file); @@ -80,10 +89,8 @@ extern "C" { #ifndef _di_fl_print_trim_raw_safely_ f_status_t fl_print_trim_raw_safely(const f_string_t string, const f_array_length_t length, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!string || !length) return F_data_not; return private_fl_print_trim_raw_safely(string, length, file); @@ -92,10 +99,8 @@ extern "C" { #ifndef _di_fl_print_trim_safely_ f_status_t fl_print_trim_safely(const f_string_t string, const f_array_length_t length, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!string || !length) return F_data_not; return private_fl_print_trim_safely(string, length, file); @@ -104,10 +109,8 @@ extern "C" { #ifndef _di_fl_print_trim_dynamic_ f_status_t fl_print_trim_dynamic(const f_string_static_t buffer, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used) return F_data_not; return private_fl_print_trim(buffer.string, buffer.used, file); @@ -116,10 +119,8 @@ extern "C" { #ifndef _di_fl_print_trim_dynamic_raw_ f_status_t fl_print_trim_dynamic_raw(const f_string_static_t buffer, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used) return F_data_not; return private_fl_print_trim_raw(buffer.string, buffer.used, file); @@ -128,10 +129,8 @@ extern "C" { #ifndef _di_fl_print_trim_dynamic_raw_safely_ f_status_t fl_print_trim_dynamic_raw_safely(const f_string_static_t buffer, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used) return F_data_not; return private_fl_print_trim_raw_safely(buffer.string, buffer.used, file); @@ -140,10 +139,8 @@ extern "C" { #ifndef _di_fl_print_trim_dynamic_safely_ f_status_t fl_print_trim_dynamic_safely(const f_string_static_t buffer, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used) return F_data_not; return private_fl_print_trim_safely(buffer.string, buffer.used, file); @@ -152,13 +149,9 @@ extern "C" { #ifndef _di_fl_print_trim_dynamic_partial_ f_status_t fl_print_trim_dynamic_partial(const f_string_static_t buffer, const f_string_range_t range, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -172,13 +165,9 @@ extern "C" { #ifndef _di_fl_print_trim_dynamic_partial_raw_ f_status_t fl_print_trim_dynamic_partial_raw(const f_string_static_t buffer, const f_string_range_t range, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -192,13 +181,9 @@ extern "C" { #ifndef _di_fl_print_trim_dynamic_partial_raw_safely_ f_status_t fl_print_trim_dynamic_partial_raw_safely(const f_string_static_t buffer, const f_string_range_t range, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -212,13 +197,9 @@ extern "C" { #ifndef _di_fl_print_trim_dynamic_partial_safely_ f_status_t fl_print_trim_dynamic_partial_safely(const f_string_static_t buffer, const f_string_range_t range, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -232,10 +213,8 @@ extern "C" { #ifndef _di_fl_print_trim_except_ 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, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!string || !length) return F_data_not; const f_string_ranges_t except_in = f_string_ranges_t_initialize; @@ -246,10 +225,8 @@ extern "C" { #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 offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!string || !length) return F_data_not; const f_string_ranges_t except_in = f_string_ranges_t_initialize; @@ -260,10 +237,8 @@ extern "C" { #ifndef _di_fl_print_trim_except_raw_safely_ f_status_t fl_print_trim_except_raw_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_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!string || !length) return F_data_not; const f_string_ranges_t except_in = f_string_ranges_t_initialize; @@ -274,10 +249,8 @@ extern "C" { #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 offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!string || !length) return F_data_not; const f_string_ranges_t except_in = f_string_ranges_t_initialize; @@ -288,10 +261,8 @@ extern "C" { #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_at, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used) return F_data_not; const f_string_ranges_t except_in = f_string_ranges_t_initialize; @@ -302,10 +273,8 @@ extern "C" { #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_at, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used) return F_data_not; const f_string_ranges_t except_in = f_string_ranges_t_initialize; @@ -316,10 +285,8 @@ extern "C" { #ifndef _di_fl_print_trim_except_dynamic_raw_safely_ f_status_t fl_print_trim_except_dynamic_raw_safely(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used) return F_data_not; const f_string_ranges_t except_in = f_string_ranges_t_initialize; @@ -330,10 +297,8 @@ extern "C" { #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_at, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used) return F_data_not; const f_string_ranges_t except_in = f_string_ranges_t_initialize; @@ -344,10 +309,8 @@ extern "C" { #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 offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!string || !length) return F_data_not; return private_fl_print_trim_except_in(string, offset, offset + length, except_at, except_in, file); @@ -356,10 +319,8 @@ extern "C" { #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 offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!string || !length) return F_data_not; return private_fl_print_trim_except_in_raw(string, offset, offset + length, except_at, except_in, file); @@ -368,10 +329,8 @@ extern "C" { #ifndef _di_fl_print_trim_except_in_raw_safely_ f_status_t fl_print_trim_except_in_raw_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, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!string || !length) return F_data_not; return private_fl_print_trim_except_in_raw_safely(string, offset, offset + length, except_at, except_in, file); @@ -380,10 +339,8 @@ extern "C" { #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 offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!string || !length) return F_data_not; return private_fl_print_trim_except_in_safely(string, offset, offset + length, except_at, except_in, file); @@ -392,10 +349,8 @@ extern "C" { #ifndef _di_fl_print_trim_except_in_dynamic_ f_status_t fl_print_trim_except_in_dynamic(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used) return F_data_not; return private_fl_print_trim_except_in(buffer.string, 0, buffer.used, except_at, except_in, file); @@ -404,10 +359,8 @@ extern "C" { #ifndef _di_fl_print_trim_except_in_dynamic_raw_ f_status_t fl_print_trim_except_in_dynamic_raw(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used) return F_data_not; return private_fl_print_trim_except_in_raw(buffer.string, 0, buffer.used, except_at, except_in, file); @@ -416,10 +369,8 @@ extern "C" { #ifndef _di_fl_print_trim_except_in_dynamic_raw_safely_ f_status_t fl_print_trim_except_in_dynamic_raw_safely(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used) return F_data_not; return private_fl_print_trim_except_in_raw_safely(buffer.string, 0, buffer.used, except_at, except_in, file); @@ -428,10 +379,8 @@ extern "C" { #ifndef _di_fl_print_trim_except_in_dynamic_safely_ f_status_t fl_print_trim_except_in_dynamic_safely(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + if (!file.stream) return F_stream_not; if (!buffer.used) return F_data_not; return private_fl_print_trim_except_in_safely(buffer.string, 0, buffer.used, except_at, except_in, file); @@ -440,13 +389,9 @@ extern "C" { #ifndef _di_fl_print_trim_except_in_dynamic_partial_ f_status_t fl_print_trim_except_in_dynamic_partial(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -460,13 +405,9 @@ extern "C" { #ifndef _di_fl_print_trim_except_in_dynamic_partial_raw_ f_status_t fl_print_trim_except_in_dynamic_partial_raw(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -480,13 +421,9 @@ extern "C" { #ifndef _di_fl_print_trim_except_in_dynamic_partial_raw_safely_ f_status_t fl_print_trim_except_in_dynamic_partial_raw_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -500,13 +437,9 @@ extern "C" { #ifndef _di_fl_print_trim_except_in_dynamic_partial_safely_ f_status_t fl_print_trim_except_in_dynamic_partial_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -520,13 +453,9 @@ extern "C" { #ifndef _di_fl_print_trim_except_dynamic_partial_ f_status_t fl_print_trim_except_dynamic_partial(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -542,13 +471,9 @@ extern "C" { #ifndef _di_fl_print_trim_except_dynamic_partial_raw_ f_status_t fl_print_trim_except_dynamic_partial_raw(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -564,13 +489,9 @@ extern "C" { #ifndef _di_fl_print_trim_except_dynamic_partial_raw_safely_ f_status_t fl_print_trim_except_dynamic_partial_raw_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; @@ -586,13 +507,9 @@ extern "C" { #ifndef _di_fl_print_trim_except_dynamic_partial_safely_ f_status_t fl_print_trim_except_dynamic_partial_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, const f_file_t file) { - #ifndef _di_level_1_parameter_checking_ - if (!file.stream) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { - return F_data_not; - } + if (!file.stream) return F_stream_not; + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) return F_data_not; f_array_length_t length = (range.stop - range.start) + 1; diff --git a/level_1/fl_print/c/print.h b/level_1/fl_print/c/print.h index ba1a581..4c531fe 100644 --- a/level_1/fl_print/c/print.h +++ b/level_1/fl_print/c/print.h @@ -193,6 +193,8 @@ extern "C" { * * @return * F_none on success. + * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_eos (with error bit) on EOS reached. * F_output (with error bit) on failure to print to the output file. @@ -243,6 +245,7 @@ extern "C" { * The variable arguments list. * @param status * The status is stored here rather then via the return. + * Set to NULL to not use. * * @return * This returns a string at either the start position (if nothing done or an error occurred) or at the character last processed. @@ -251,6 +254,8 @@ extern "C" { * The status parameter will be set as follows: * * F_none on success. + * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on failure to print to the output file. * F_parameter (with error bit) if a parameter is invalid. @@ -302,6 +307,8 @@ extern "C" { * * @return * F_none on success. + * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_eos (with error bit) on EOS reached. * F_output (with error bit) on failure to print to the output file. @@ -354,6 +361,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_complete_not_utf_stop (with error bit) if character is an incomplete UTF-8 fragment at end of the string. * F_output (with error bit) on error when printing to output. @@ -397,6 +405,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -437,6 +446,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -477,6 +487,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -517,6 +528,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_complete_not_utf_stop (with error bit) if character is an incomplete UTF-8 fragment at end of the string. * F_output (with error bit) on error when printing to output. @@ -561,6 +573,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -603,6 +616,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -644,6 +658,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -686,6 +701,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_complete_not_utf_stop (with error bit) if character is an incomplete UTF-8 fragment at end of the string. * F_output (with error bit) on error when printing to output. @@ -732,6 +748,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -776,6 +793,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -819,6 +837,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -866,6 +885,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_complete_not_utf_stop (with error bit) if character is an incomplete UTF-8 fragment at end of the string. * F_output (with error bit) on error when printing to output. @@ -917,6 +937,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -966,6 +987,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1014,6 +1036,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1058,6 +1081,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_complete_not_utf_stop (with error bit) if character is an incomplete UTF-8 fragment at end of the string. * F_output (with error bit) on error when printing to output. @@ -1106,6 +1130,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1152,6 +1177,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1197,6 +1223,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1248,6 +1275,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_complete_not_utf_stop (with error bit) if character is an incomplete UTF-8 fragment at end of the string. * F_output (with error bit) on error when printing to output. @@ -1303,6 +1331,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1356,6 +1385,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1408,6 +1438,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1458,6 +1489,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_complete_not_utf_stop (with error bit) if character is an incomplete UTF-8 fragment at end of the string. * F_output (with error bit) on error when printing to output. @@ -1510,6 +1542,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1560,6 +1593,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1609,6 +1643,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1659,6 +1694,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_complete_not_utf_stop (with error bit) if character is an incomplete UTF-8 fragment at end of the string. * F_output (with error bit) on error when printing to output. @@ -1713,6 +1749,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1764,6 +1801,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1815,6 +1853,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1861,6 +1900,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_complete_not_utf_stop (with error bit) if character is an incomplete UTF-8 fragment at end of the string. * F_output (with error bit) on error when printing to output. @@ -1911,6 +1951,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -1958,6 +1999,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. @@ -2005,6 +2047,7 @@ extern "C" { * @return * F_none on success. * F_data_not on success but there is nothing to print. + * F_stream_not if file.stream is NULL. * * F_output (with error bit) on error when printing to output. * F_parameter (with error bit) if a parameter is invalid. diff --git a/level_2/fll_print/c/print.c b/level_2/fll_print/c/print.c index 196fae6..a7e5b40 100644 --- a/level_2/fll_print/c/print.c +++ b/level_2/fll_print/c/print.c @@ -7,6 +7,8 @@ extern "C" { #ifndef _di_fll_print_ f_status_t fll_print(const f_string_t string, const f_array_length_t length, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print(string, length, file); @@ -20,6 +22,8 @@ extern "C" { #ifndef _di_fll_print_character_ f_status_t fll_print_character(const f_char_t character, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_character(character, file); @@ -33,6 +37,8 @@ extern "C" { #ifndef _di_fll_print_character_safely_ f_status_t fll_print_character_safely(const f_char_t character, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_character_safely(character, file); @@ -46,6 +52,8 @@ extern "C" { #ifndef _di_fll_print_dynamic_ f_status_t fll_print_dynamic(const f_string_static_t buffer, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_dynamic(buffer, file); @@ -59,6 +67,8 @@ extern "C" { #ifndef _di_fll_print_dynamic_partial_ f_status_t fll_print_dynamic_partial(const f_string_static_t buffer, const f_string_range_t range, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_dynamic_partial(buffer, range, file); @@ -72,6 +82,8 @@ extern "C" { #ifndef _di_fll_print_dynamic_partial_raw_ f_status_t fll_print_dynamic_partial_raw(const f_string_static_t buffer, const f_string_range_t range, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_dynamic_partial_raw(buffer, range, file); @@ -85,6 +97,8 @@ extern "C" { #ifndef _di_fll_print_dynamic_partial_raw_safely_ f_status_t fll_print_dynamic_partial_raw_safely(const f_string_static_t buffer, const f_string_range_t range, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_dynamic_partial_raw_safely(buffer, range, file); @@ -98,6 +112,8 @@ extern "C" { #ifndef _di_fll_print_dynamic_partial_safely_ f_status_t fll_print_dynamic_partial_safely(const f_string_static_t buffer, const f_string_range_t range, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_dynamic_partial_safely(buffer, range, file); @@ -111,6 +127,8 @@ extern "C" { #ifndef _di_fll_print_dynamic_raw_ f_status_t fll_print_dynamic_raw(const f_string_static_t buffer, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_dynamic_raw(buffer, file); @@ -124,6 +142,8 @@ extern "C" { #ifndef _di_fll_print_dynamic_raw_safely_ f_status_t fll_print_dynamic_raw_safely(const f_string_static_t buffer, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_dynamic_raw_safely(buffer, file); @@ -137,6 +157,8 @@ extern "C" { #ifndef _di_fll_print_dynamic_safely_ f_status_t fll_print_dynamic_safely(const f_string_static_t buffer, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_dynamic_safely(buffer, file); @@ -150,6 +172,8 @@ extern "C" { #ifndef _di_fll_print_except_ 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, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except(buffer, offset, length, except, file); @@ -163,6 +187,8 @@ extern "C" { #ifndef _di_fll_print_except_dynamic_ f_status_t fll_print_except_dynamic(const f_string_static_t buffer, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_dynamic(buffer, except, file); @@ -176,6 +202,8 @@ extern "C" { #ifndef _di_fll_print_except_dynamic_partial_ f_status_t fll_print_except_dynamic_partial(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_dynamic_partial(buffer, range, except, file); @@ -189,6 +217,8 @@ extern "C" { #ifndef _di_fll_print_except_dynamic_partial_raw_ f_status_t fll_print_except_dynamic_partial_raw(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_dynamic_partial_raw(buffer, range, except, file); @@ -202,6 +232,8 @@ extern "C" { #ifndef _di_fll_print_except_dynamic_partial_raw_safely_ f_status_t fll_print_except_dynamic_partial_raw_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_dynamic_partial_raw_safely(buffer, range, except, file); @@ -215,6 +247,8 @@ extern "C" { #ifndef _di_fll_print_except_dynamic_partial_safely_ f_status_t fll_print_except_dynamic_partial_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_dynamic_partial_safely(buffer, range, except, file); @@ -228,6 +262,8 @@ extern "C" { #ifndef _di_fll_print_except_dynamic_raw_ f_status_t fll_print_except_dynamic_raw(const f_string_static_t buffer, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_dynamic_raw(buffer, except, file); @@ -241,6 +277,8 @@ extern "C" { #ifndef _di_fll_print_except_dynamic_raw_safely_ f_status_t fll_print_except_dynamic_raw_safely(const f_string_static_t buffer, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_dynamic_raw_safely(buffer, except, file); @@ -254,6 +292,8 @@ extern "C" { #ifndef _di_fll_print_except_dynamic_safely_ f_status_t fll_print_except_dynamic_safely(const f_string_static_t buffer, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_dynamic_safely(buffer, except, file); @@ -267,6 +307,8 @@ extern "C" { #ifndef _di_fll_print_except_raw_ 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, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_raw(buffer, offset, length, except, file); @@ -280,6 +322,8 @@ extern "C" { #ifndef _di_fll_print_except_raw_safely_ f_status_t fll_print_except_raw_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_raw_safely(string, offset, length, except, file); @@ -293,6 +337,8 @@ extern "C" { #ifndef _di_fll_print_except_safely_ 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, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_safely(string, offset, length, except, file); @@ -306,6 +352,8 @@ extern "C" { #ifndef _di_fll_print_except_in_ 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, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_in(string, offset, length, except_at, except_in, file); @@ -319,6 +367,8 @@ extern "C" { #ifndef _di_fll_print_except_in_dynamic_ f_status_t fll_print_except_in_dynamic(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_in_dynamic(buffer, except_at, except_in, file); @@ -332,6 +382,8 @@ extern "C" { #ifndef _di_fll_print_except_in_dynamic_partial_ f_status_t fll_print_except_in_dynamic_partial(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_in_dynamic_partial(buffer, range, except_at, except_in, file); @@ -345,6 +397,8 @@ extern "C" { #ifndef _di_fll_print_except_in_dynamic_partial_raw_ f_status_t fll_print_except_in_dynamic_partial_raw(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_in_dynamic_partial_raw(buffer, range, except_at, except_in, file); @@ -358,6 +412,8 @@ extern "C" { #ifndef _di_fll_print_except_in_dynamic_partial_raw_safely_ f_status_t fll_print_except_in_dynamic_partial_raw_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_in_dynamic_partial_raw_safely(buffer, range, except_at, except_in, file); @@ -371,6 +427,8 @@ extern "C" { #ifndef _di_fll_print_except_in_dynamic_partial_safely_ f_status_t fll_print_except_in_dynamic_partial_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_in_dynamic_partial_safely(buffer, range, except_at, except_in, file); @@ -384,6 +442,8 @@ extern "C" { #ifndef _di_fll_print_except_in_dynamic_raw_ f_status_t fll_print_except_in_dynamic_raw(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_in_dynamic_raw(buffer, except_at, except_in, file); @@ -397,6 +457,8 @@ extern "C" { #ifndef _di_fll_print_except_in_dynamic_raw_safely_ f_status_t fll_print_except_in_dynamic_raw_safely(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_in_dynamic_raw_safely(buffer, except_at, except_in, file); @@ -410,6 +472,8 @@ extern "C" { #ifndef _di_fll_print_except_in_dynamic_safely_ f_status_t fll_print_except_in_dynamic_safely(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_in_dynamic_safely(buffer, except_at, except_in, file); @@ -423,6 +487,8 @@ extern "C" { #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 offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_in_raw(string, offset, length, except_at, except_in, file); @@ -436,6 +502,8 @@ extern "C" { #ifndef _di_fll_print_except_in_raw_safely_ f_status_t fll_print_except_in_raw_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, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_in_raw_safely(string, offset, length, except_at, except_in, file); @@ -449,6 +517,8 @@ extern "C" { #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 offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_except_in_safely(string, offset, length, except_at, except_in, file); @@ -462,6 +532,8 @@ extern "C" { #ifndef _di_fll_print_format_ f_status_t fll_print_format(const f_string_t string, f_file_t file, ...) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); va_list ap; @@ -481,6 +553,12 @@ extern "C" { #ifndef _di_fll_print_format_convert_ f_string_t fll_print_format_convert(const f_string_t string, f_file_t file, va_list ap, f_status_t * const status) { + if (!file.stream) { + if (status) *status = F_stream_not; + + return 0; + } + flockfile(file.stream); f_string_t str = fl_print_format_convert(string, file, ap, status); @@ -494,6 +572,8 @@ extern "C" { #ifndef _di_fll_print_raw_ f_status_t fll_print_raw(const f_string_t string, const f_array_length_t length, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_raw(string, length, file); @@ -507,6 +587,8 @@ extern "C" { #ifndef _di_fll_print_raw_safely_ f_status_t fll_print_raw_safely(const f_string_t string, const f_array_length_t length, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_raw_safely(string, length, file); @@ -520,6 +602,8 @@ extern "C" { #ifndef _di_fll_print_raw_terminated_ f_status_t fll_print_raw_terminated(const f_string_t string, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_raw_terminated(string, file); @@ -533,6 +617,8 @@ extern "C" { #ifndef _di_fll_print_safely_ f_status_t fll_print_safely(const f_string_t string, const f_array_length_t length, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_safely(string, length, file); @@ -546,6 +632,8 @@ extern "C" { #ifndef _di_fll_print_safely_terminated_ f_status_t fll_print_safely_terminated(const f_string_t string, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_safely_terminated(string, file); @@ -559,6 +647,8 @@ extern "C" { #ifndef _di_fll_print_string_va_ f_status_t fll_print_string_va(const f_string_t string, f_file_t file, va_list ap) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_string_va(string, file, ap); @@ -572,6 +662,8 @@ extern "C" { #ifndef _di_fll_print_terminated_ f_status_t fll_print_terminated(const f_string_t string, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = f_print_terminated(string, file); @@ -585,6 +677,8 @@ extern "C" { #ifndef _di_fll_print_trim_raw_ f_status_t fll_print_trim_raw(const f_string_t string, const f_array_length_t length, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_raw(string, length, file); @@ -598,6 +692,8 @@ extern "C" { #ifndef _di_fll_print_trim_raw_safely_ f_status_t fll_print_trim_raw_safely(const f_string_t string, const f_array_length_t length, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_raw_safely(string, length, file); @@ -611,6 +707,8 @@ extern "C" { #ifndef _di_fll_print_trim_safely_ f_status_t fll_print_trim_safely(const f_string_t string, const f_array_length_t length, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_safely(string, length, file); @@ -624,6 +722,8 @@ extern "C" { #ifndef _di_fll_print_trim_dynamic_ f_status_t fll_print_trim_dynamic(const f_string_static_t buffer, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_dynamic(buffer, file); @@ -637,6 +737,8 @@ extern "C" { #ifndef _di_fll_print_trim_dynamic_raw_ f_status_t fll_print_trim_dynamic_raw(const f_string_static_t buffer, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_dynamic_raw(buffer, file); @@ -650,6 +752,8 @@ extern "C" { #ifndef _di_fll_print_trim_dynamic_raw_safely_ f_status_t fll_print_trim_dynamic_raw_safely(const f_string_static_t buffer, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_dynamic_raw_safely(buffer, file); @@ -663,6 +767,8 @@ extern "C" { #ifndef _di_fll_print_trim_dynamic_safely_ f_status_t fll_print_trim_dynamic_safely(const f_string_static_t buffer, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_dynamic_safely(buffer, file); @@ -676,6 +782,8 @@ extern "C" { #ifndef _di_fll_print_trim_dynamic_partial_ f_status_t fll_print_trim_dynamic_partial(const f_string_static_t buffer, const f_string_range_t range, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_dynamic_partial(buffer, range, file); @@ -689,6 +797,8 @@ extern "C" { #ifndef _di_fll_print_trim_dynamic_partial_raw_ f_status_t fll_print_trim_dynamic_partial_raw(const f_string_static_t buffer, const f_string_range_t range, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_dynamic_partial_raw(buffer, range, file); @@ -702,6 +812,8 @@ extern "C" { #ifndef _di_fll_print_trim_dynamic_partial_raw_safely_ f_status_t fll_print_trim_dynamic_partial_raw_safely(const f_string_static_t buffer, const f_string_range_t range, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_dynamic_partial_raw_safely(buffer, range, file); @@ -715,6 +827,8 @@ extern "C" { #ifndef _di_fll_print_trim_dynamic_partial_safely_ f_status_t fll_print_trim_dynamic_partial_safely(const f_string_static_t buffer, const f_string_range_t range, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_dynamic_partial_safely(buffer, range, file); @@ -728,6 +842,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_ 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, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except(string, offset, length, except, file); @@ -741,6 +857,8 @@ extern "C" { #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 offset, const f_array_length_t length, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_raw(string, offset, length, except, file); @@ -754,6 +872,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_raw_safely_ f_status_t fll_print_trim_except_raw_safely(const f_string_t string, const f_array_length_t offset, const f_array_length_t length, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_raw_safely(string, offset, length, except, file); @@ -767,6 +887,8 @@ extern "C" { #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 offset, const f_array_length_t length, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_safely(string, offset, length, except, file); @@ -780,6 +902,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_dynamic_ f_status_t fll_print_trim_except_dynamic(const f_string_static_t buffer, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_dynamic(buffer, except, file); @@ -793,6 +917,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_dynamic_raw_ f_status_t fll_print_trim_except_dynamic_raw(const f_string_static_t buffer, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_dynamic_raw(buffer, except, file); @@ -806,6 +932,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_dynamic_raw_safely_ f_status_t fll_print_trim_except_dynamic_raw_safely(const f_string_static_t buffer, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_dynamic_raw_safely(buffer, except, file); @@ -819,6 +947,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_dynamic_safely_ f_status_t fll_print_trim_except_dynamic_safely(const f_string_static_t buffer, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_dynamic_safely(buffer, except, file); @@ -832,6 +962,8 @@ extern "C" { #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 offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_in(string, offset, length, except_at, except_in, file); @@ -845,6 +977,8 @@ extern "C" { #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 offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_in_raw(string, offset, length, except_at, except_in, file); @@ -858,6 +992,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_in_raw_safely_ f_status_t fll_print_trim_except_in_raw_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, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_in_raw_safely(string, offset, length, except_at, except_in, file); @@ -871,6 +1007,8 @@ extern "C" { #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 offset, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_in_safely(string, offset, length, except_at, except_in, file); @@ -884,6 +1022,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_in_dynamic_ f_status_t fll_print_trim_except_in_dynamic(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_in_dynamic(buffer, except_at, except_in, file); @@ -897,6 +1037,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_in_dynamic_raw_ f_status_t fll_print_trim_except_in_dynamic_raw(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_in_dynamic_raw(buffer, except_at, except_in, file); @@ -910,6 +1052,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_in_dynamic_raw_safely_ f_status_t fll_print_trim_except_in_dynamic_raw_safely(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_in_dynamic_raw_safely(buffer, except_at, except_in, file); @@ -923,6 +1067,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_in_dynamic_safely_ f_status_t fll_print_trim_except_in_dynamic_safely(const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_in_dynamic_safely(buffer, except_at, except_in, file); @@ -936,6 +1082,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_in_dynamic_partial_ f_status_t fll_print_trim_except_in_dynamic_partial(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_in_dynamic_partial(buffer, range, except_at, except_in, file); @@ -949,6 +1097,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_in_dynamic_partial_raw_ f_status_t fll_print_trim_except_in_dynamic_partial_raw(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_in_dynamic_partial_raw(buffer, range, except_at, except_in, file); @@ -962,6 +1112,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_in_dynamic_partial_raw_safely_ f_status_t fll_print_trim_except_in_dynamic_partial_raw_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_in_dynamic_partial_raw_safely(buffer, range, except_at, except_in, file); @@ -975,6 +1127,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_in_dynamic_partial_safely_ f_status_t fll_print_trim_except_in_dynamic_partial_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_in_dynamic_partial_safely(buffer, range, except_at, except_in, file); @@ -988,6 +1142,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_dynamic_partial_ f_status_t fll_print_trim_except_dynamic_partial(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_dynamic_partial(buffer, range, except, file); @@ -1001,6 +1157,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_dynamic_partial_raw_ f_status_t fll_print_trim_except_dynamic_partial_raw(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_dynamic_partial_raw(buffer, range, except, file); @@ -1014,6 +1172,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_dynamic_partial_raw_safely_ f_status_t fll_print_trim_except_dynamic_partial_raw_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_dynamic_partial_raw_safely(buffer, range, except, file); @@ -1027,6 +1187,8 @@ extern "C" { #ifndef _di_fll_print_trim_except_dynamic_partial_safely_ f_status_t fll_print_trim_except_dynamic_partial_safely(const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except, f_file_t file) { + if (!file.stream) return F_stream_not; + flockfile(file.stream); const f_status_t status = fl_print_trim_except_dynamic_partial_safely(buffer, range, except, file); diff --git a/level_2/fll_print/c/print.h b/level_2/fll_print/c/print.h index 1007df7..960bf04 100644 --- a/level_2/fll_print/c/print.h +++ b/level_2/fll_print/c/print.h @@ -40,6 +40,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print(). * * Errors (with error bit) from: f_print(). @@ -62,6 +64,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_character(). * * Errors (with error bit) from: f_print_character(). @@ -84,6 +88,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_character_safely(). * * Errors (with error bit) from: f_print_character_safely(). @@ -106,6 +112,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_dynamic(). * * Errors (with error bit) from: f_print_dynamic(). @@ -130,6 +138,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_dynamic_partial(). * * Errors (with error bit) from: f_print_dynamic_partial(). @@ -154,6 +164,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_dynamic_partial_raw(). * * Errors (with error bit) from: f_print_dynamic_partial_raw(). @@ -178,6 +190,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_dynamic_partial_raw_safely(). * * Errors (with error bit) from: f_print_dynamic_partial_raw_safely(). @@ -202,6 +216,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_dynamic_partial_safely(). * * Errors (with error bit) from: f_print_dynamic_partial_safely(). @@ -224,6 +240,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_dynamic_raw(). * * Errors (with error bit) from: f_print_dynamic_raw(). @@ -246,6 +264,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_dynamic_raw_safely(). * * Errors (with error bit) from: f_print_dynamic_raw_safely(). @@ -268,6 +288,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_dynamic_safely(). * * Errors (with error bit) from: f_print_dynamic_safely(). @@ -297,6 +319,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except(). * * Errors (with error bit) from: f_print_except(). @@ -322,6 +346,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_dynamic(). * * Errors (with error bit) from: f_print_except_dynamic(). @@ -349,6 +375,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_dynamic_partial(). * * Errors (with error bit) from: f_print_except_dynamic_partial(). @@ -376,6 +404,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_dynamic_partial_raw(). * * Errors (with error bit) from: f_print_except_dynamic_partial_raw(). @@ -403,6 +433,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_dynamic_partial_raw_safely(). * * Errors (with error bit) from: f_print_except_dynamic_partial_raw_safely(). @@ -430,6 +462,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_dynamic_partial_safely(). * * Errors (with error bit) from: f_print_except_dynamic_partial_safely(). @@ -455,6 +489,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_dynamic_raw(). * * Errors (with error bit) from: f_print_except_dynamic_raw(). @@ -480,6 +516,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_dynamic_raw_safely(). * * Errors (with error bit) from: f_print_except_dynamic_raw_safely(). @@ -505,6 +543,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_dynamic_safely(). * * Errors (with error bit) from: f_print_except_dynamic_safely(). @@ -537,6 +577,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_in(). * * Errors (with error bit) from: f_print_except_in(). @@ -569,6 +611,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_in_raw(). * * Errors (with error bit) from: f_print_except_in_raw(). @@ -601,6 +645,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_in_raw_safely(). * * Errors (with error bit) from: f_print_except_in_raw_safely(). @@ -633,6 +679,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_in_safely(). * * Errors (with error bit) from: f_print_except_in_safely(). @@ -661,6 +709,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_in_dynamic(). * * Errors (with error bit) from: f_print_except_in_dynamic(). @@ -691,6 +741,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_in_dynamic_partial(). * * Errors (with error bit) from: f_print_except_in_dynamic_partial(). @@ -721,6 +773,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_in_dynamic_partial_raw(). * * Errors (with error bit) from: f_print_except_in_dynamic_partial_raw(). @@ -751,6 +805,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_in_dynamic_partial_raw_safely(). * * Errors (with error bit) from: f_print_except_in_dynamic_partial_raw_safely(). @@ -781,6 +837,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_in_dynamic_partial_safely(). * * Errors (with error bit) from: f_print_except_in_dynamic_partial_safely(). @@ -809,6 +867,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_in_dynamic_raw(). * * Errors (with error bit) from: f_print_except_in_dynamic_raw(). @@ -837,6 +897,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_in_dynamic_raw_safely(). * * Errors (with error bit) from: f_print_except_in_dynamic_raw_safely(). @@ -865,6 +927,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_in_dynamic_safely(). * * Errors (with error bit) from: f_print_except_in_dynamic_safely(). @@ -894,6 +958,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_raw(). * * Errors (with error bit) from: f_print_except_raw(). @@ -923,6 +989,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_raw_safely(). * * Errors (with error bit) from: f_print_except_raw_safely(). @@ -952,6 +1020,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_safely(). * * Errors (with error bit) from: f_print_except_safely(). @@ -977,6 +1047,8 @@ extern "C" { * Additional arguments relating to the string. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_format(). * * Errors (with error bit) from: fl_print_format(). @@ -1003,9 +1075,19 @@ extern "C" { * The variable arguments list. * @param status * The status is stored here rather then via the return. + * Set to NULL to not use. * * @return - * Result from: fl_print_format_convert(). + * This returns a string at either the start position (if nothing done or an error occurred) or at the character last processed. + * The caller is expected to increment past this if they wish to continue processing the string. + * + * The status parameter will be set as follows: + * + * F_stream_not if file.stream is NULL. + * + * Success from: fl_print_format_convert(). + * + * Errors (with error bit) from: fl_print_format_convert(). * * @see flockfile() * @see funlockfile() @@ -1027,6 +1109,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_raw(). * * Errors (with error bit) from: f_print_raw(). @@ -1051,6 +1135,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_raw_safely(). * * Errors (with error bit) from: f_print_raw_safely(). @@ -1073,6 +1159,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_raw_terminated(). * * Errors (with error bit) from: f_print_raw_terminated(). @@ -1097,6 +1185,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_safely(). * * Errors (with error bit) from: f_print_safely(). @@ -1121,6 +1211,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_safely_terminated(). * * Errors (with error bit) from: f_print_safely_terminated(). @@ -1146,6 +1238,8 @@ extern "C" { * The va_start(ap, string) and va_end(ap) is required to be called outside this function. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_string_va(). * * Errors (with error bit) from: fl_print_string_va(). @@ -1168,6 +1262,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_terminated(). * * Errors (with error bit) from: f_print_terminated(). @@ -1192,6 +1288,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim(). * * Errors (with error bit) from: fl_print_trim(). @@ -1216,6 +1314,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_raw(). * * Errors (with error bit) from: fl_print_trim_raw(). @@ -1240,6 +1340,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_raw_safely(). * * Errors (with error bit) from: fl_print_trim_raw_safely(). @@ -1264,6 +1366,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_safely(). * * Errors (with error bit) from: fl_print_trim_safely(). @@ -1286,6 +1390,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_dynamic(). * * Errors (with error bit) from: fl_print_trim_dynamic(). @@ -1308,6 +1414,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_dynamic_raw(). * * Errors (with error bit) from: fl_print_trim_dynamic_raw(). @@ -1330,6 +1438,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_dynamic_raw_safely(). * * Errors (with error bit) from: fl_print_trim_dynamic_raw_safely(). @@ -1352,6 +1462,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_dynamic_safely(). * * Errors (with error bit) from: fl_print_trim_dynamic_safely(). @@ -1376,6 +1488,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_dynamic_partial(). * * Errors (with error bit) from: fl_print_trim_dynamic_partial(). @@ -1400,6 +1514,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_dynamic_partial_raw(). * * Errors (with error bit) from: fl_print_trim_dynamic_partial_raw(). @@ -1424,6 +1540,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_dynamic_partial(). * * Errors (with error bit) from: f_print_except_dynamic_partial(). @@ -1448,6 +1566,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: f_print_except_dynamic_partial(). * * Errors (with error bit) from: f_print_except_dynamic_partial(). @@ -1477,6 +1597,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except(). * * Errors (with error bit) from: fl_print_trim_except(). @@ -1506,6 +1628,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_raw(). * * Errors (with error bit) from: fl_print_trim_except_raw(). @@ -1535,6 +1659,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_raw_safely(). * * Errors (with error bit) from: fl_print_trim_except_raw_safely(). @@ -1564,6 +1690,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_safely(). * * Errors (with error bit) from: fl_print_trim_except_safely(). @@ -1589,6 +1717,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_dynamic(). * * Errors (with error bit) from: fl_print_trim_except_dynamic(). @@ -1614,6 +1744,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_dynamic_raw(). * * Errors (with error bit) from: fl_print_trim_except_dynamic_raw(). @@ -1639,6 +1771,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_dynamic_raw_safely(). * * Errors (with error bit) from: fl_print_trim_except_dynamic_raw_safely(). @@ -1664,6 +1798,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_dynamic_safely(). * * Errors (with error bit) from: fl_print_trim_except_dynamic_safely(). @@ -1696,6 +1832,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_in(). * * Errors (with error bit) from: fl_print_trim_except_in(). @@ -1728,6 +1866,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_in_raw(). * * Errors (with error bit) from: fl_print_trim_except_in_raw(). @@ -1760,6 +1900,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_in_raw_safely(). * * Errors (with error bit) from: fl_print_trim_except_in_raw_safely(). @@ -1792,6 +1934,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_in_safely(). * * Errors (with error bit) from: fl_print_trim_except_in_safely(). @@ -1820,6 +1964,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_in_dynamic(). * * Errors (with error bit) from: fl_print_trim_except_in_dynamic(). @@ -1848,6 +1994,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_in_dynamic_raw(). * * Errors (with error bit) from: fl_print_trim_except_in_dynamic_raw(). @@ -1876,6 +2024,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_in_dynamic_raw_safely(). * * Errors (with error bit) from: fl_print_trim_except_in_dynamic_raw_safely(). @@ -1904,6 +2054,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_in_dynamic_safely(). * * Errors (with error bit) from: fl_print_trim_except_in_dynamic_safely(). @@ -1934,6 +2086,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_in_dynamic_partial(). * * Errors (with error bit) from: fl_print_trim_except_in_dynamic_partial(). @@ -1964,6 +2118,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_in_dynamic_partial_raw(). * * Errors (with error bit) from: fl_print_trim_except_in_dynamic_partial_raw(). @@ -1994,6 +2150,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_in_dynamic_partial_raw_safely(). * * Errors (with error bit) from: fl_print_trim_except_in_dynamic_partial_raw_safely(). @@ -2024,6 +2182,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_in_dynamic_partial_safely(). * * Errors (with error bit) from: fl_print_trim_except_in_dynamic_partial_safely(). @@ -2051,6 +2211,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_dynamic_partial(). * * Errors (with error bit) from: fl_print_trim_except_dynamic_partial(). @@ -2078,6 +2240,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_dynamic_partial_raw(). * * Errors (with error bit) from: fl_print_trim_except_dynamic_partial_raw(). @@ -2105,6 +2269,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_dynamic_partial_raw_safely(). * * Errors (with error bit) from: fl_print_trim_except_dynamic_partial_raw_safely(). @@ -2132,6 +2298,8 @@ extern "C" { * The file structure containing a valid stream to output to, including standard streams such as stdout and stderr. * * @return + * F_stream_not if file.stream is NULL. + * * Success from: fl_print_trim_except_dynamic_partial_safely(). * * Errors (with error bit) from: fl_print_trim_except_dynamic_partial_safely(). diff --git a/level_3/fake/c/main/make/operate.c b/level_3/fake/c/main/make/operate.c index 6235191..fc3aa80 100644 --- a/level_3/fake/c/main/make/operate.c +++ b/level_3/fake/c/main/make/operate.c @@ -142,7 +142,7 @@ extern "C" { } // for if (F_status_is_error(status)) { - fake_make_print_error_argument_invalid_section(data->setting, data->main->error, data->main->parameters, data->main->parameters.remaining.array[i]); + fake_make_print_error_argument_invalid_section(data->setting, data->main->error, data->main->parameters.arguments.array[data->main->parameters.remaining.array[i]]); } else { int result = 0; diff --git a/level_3/fake/c/main/make/operate_validate_type.c b/level_3/fake/c/main/make/operate_validate_type.c index 39802cd..65dc896 100644 --- a/level_3/fake/c/main/make/operate_validate_type.c +++ b/level_3/fake/c/main/make/operate_validate_type.c @@ -625,17 +625,7 @@ extern "C" { status_file = f_directory_is(data_make->cache_arguments.array[data_make->cache_arguments.used - 1]); if (status_file == F_false || status_file == F_file_found_not) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - f_file_stream_lock(data_make->main->error.to); - - fl_print_format("%r%[%QThe last file '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%Q%]", data_make->main->error.to, data_make->error.notable, data_make->cache_arguments.array[data_make->cache_arguments.used - 1], data_make->error.notable); - fl_print_format("%[' must be a valid directory.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - - f_file_stream_unlock(data_make->main->error.to); - } + fake_make_print_error_content_not_directory(data_make->setting, data_make->main->error, "last", data_make->cache_arguments.array[data_make->cache_arguments.used - 1]); status = F_status_set_error(F_failure); } @@ -655,17 +645,7 @@ extern "C" { status_file = f_directory_is(data_make->cache_arguments.array[1]); if (status_file == F_false) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - f_file_stream_lock(data_make->main->error.to); - - fl_print_format("%r%[%QThe second file '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%Q%]", data_make->main->error.to, data_make->error.notable, data_make->cache_arguments.array[1], data_make->error.notable); - fl_print_format("%[' must be a valid directory.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - - f_file_stream_unlock(data_make->main->error.to); - } + fake_make_print_error_content_not_directory(data_make->setting, data_make->main->error, "second", data_make->cache_arguments.array[1]); status = F_status_set_error(F_failure); } @@ -686,34 +666,16 @@ extern "C" { if (data_make->cache_arguments.used) { const f_status_t status = fake_make_operate_validate_define_name(data_make->cache_arguments.array[0]); + if (status == F_true) return F_none; if (status == F_none) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - fll_print_format("%r%[%QDefine name must not be an empty string.%]%r", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context, f_string_eol_s); - } - - return F_status_set_error(F_failure); + fake_make_print_error_define_name_empty(data_make->setting, data_make->main->error); } - - if (status == F_false) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - f_file_stream_lock(data_make->main->error.to); - - fl_print_format("%r%[%QInvalid characters in the define setting name '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%Q%]", data_make->main->error.to, data_make->error.notable, data_make->cache_arguments.array[0], data_make->error.notable); - fl_print_format("%[', only alpha-numeric ASCII characters and underscore (without a leading digit) is allowed.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - - f_file_stream_unlock(data_make->main->error.to); - } - - return F_status_set_error(F_failure); + else { + fake_make_print_error_define_invalid_character(data_make->setting, data_make->main->error, data_make->cache_arguments.array[0]); } - return F_none; + return F_status_set_error(F_failure); } fake_print_error_requires_more_arguments(data_make->setting, data_make->main->error); @@ -1146,15 +1108,7 @@ extern "C" { } // for if (id_section == data_make->fakefile.used) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - f_file_stream_lock(data_make->main->error.to); - - fl_print_format("%r%[%QNo operation section named '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%Q%]", data_make->main->error.to, data_make->error.notable, data_make->cache_arguments.array[0], data_make->error.notable); - fl_print_format("%[' is found.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - - f_file_stream_unlock(data_make->main->error.to); + fake_make_print_error_operation_section_not_found(data_make->setting, data_make->main->error, data_make->cache_arguments.array[0]); return F_status_set_error(F_failure); } @@ -1162,17 +1116,7 @@ extern "C" { for (f_array_length_t i = 0; i < section_stack->used; ++i) { if (section_stack->array[i] == id_section) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - f_file_stream_lock(data_make->main->error.to); - - fl_print_format("%r%[%QThe section operation '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%Q%]", data_make->main->error.to, data_make->error.notable, data_make->fakefile.array[id_section].name, data_make->error.notable); - fl_print_format("%[' is already in the operation stack, recursion is not allowed.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - - f_file_stream_unlock(data_make->main->error.to); - } + fake_make_print_error_operation_recursion(data_make->setting, data_make->main->error, data_make->buffer, data_make->fakefile.array[id_section].name); return F_status_set_error(F_failure); } @@ -1232,9 +1176,7 @@ extern "C" { for (f_array_length_t i = 0; i < 33; ++i) { if (fl_string_dynamic_compare(reserved_name[i], data_make->cache_arguments.array[0]) == F_equal_to) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - fll_print_format("%r%[%QCannot assign a value to the parameter name '%r' because it is a reserved parameter name.%]%r", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, reserved_name[i], data_make->error.context, f_string_eol_s); + fake_make_print_error_reserved_parameter_name(data_make->setting, data_make->main->error, reserved_name[i]); status = F_status_set_error(F_failure); } @@ -1304,11 +1246,7 @@ extern "C" { } if (data_make->path.stack.used == 1) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - fll_print_format("%r%[%QMust not attempt to pop project root off of path stack.%]%r", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context, f_string_eol_s); - } + fake_make_print_error_pop_last_path(data_make->setting, data_make->main->error); return F_status_set_error(F_failure); } @@ -1358,17 +1296,7 @@ extern "C" { } if (!status) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - f_file_stream_lock(data_make->main->error.to); - - fl_print_format("%r%[%QThe file '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%Q%]", data_make->main->error.to, data_make->error.notable, data_make->cache_arguments.array[0], data_make->error.notable); - fl_print_format("%[' must be a directory file.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - - f_file_stream_unlock(data_make->main->error.to); - } + fake_make_print_error_content_not_directory(data_make->setting, data_make->main->error, 0, data_make->cache_arguments.array[0]); return F_status_set_error(F_failure); } @@ -1376,11 +1304,7 @@ extern "C" { return F_none; } - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - fll_print_format("%r%[%QFilename argument must not be an empty string.%]%r", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context, f_string_eol_s); - } + fake_make_print_error_file_name_empty(data_make->setting, data_make->main->error); return F_status_set_error(F_failure); } diff --git a/level_3/fake/c/main/make/print-error.c b/level_3/fake/c/main/make/print-error.c index a0380ab..e422c83 100644 --- a/level_3/fake/c/main/make/print-error.c +++ b/level_3/fake/c/main/make/print-error.c @@ -6,40 +6,16 @@ extern "C" { #endif #ifndef _di_fake_make_print_error_argument_invalid_section_ - f_status_t fake_make_print_error_argument_invalid_section(fake_setting_t * const setting, const fl_print_t print, const f_console_parameters_t parameters, const f_array_length_t index) { + f_status_t fake_make_print_error_argument_invalid_section(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t name) { - if (print.verbosity < f_console_verbosity_error_e) return F_output_not; - - f_file_stream_lock(print.to); - - fake_print_line_first_unlocked(setting, print); - - fl_print_format("%[%QThe argument '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%Q%]", print.to, print.notable, parameters.arguments.array[index], print.notable); - fl_print_format("%[' is not a valid section name.%]%r", print.to, print.context, print.context, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; + return fake_make_print_error_simple_variable(setting, print, "The argument", name, " is not a valid section name"); } #endif // _di_fake_make_print_error_argument_invalid_section_ #ifndef _di_fake_make_print_error_compiler_not_specified_ f_status_t fake_make_print_error_compiler_not_specified(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t action) { - if (print.verbosity < f_console_verbosity_error_e) return F_output_not; - - f_file_stream_lock(print.to); - - fake_print_line_first_unlocked(setting, print); - - fl_print_format("%[%QNo compiler has been specified, cannot perform '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%Q%]", print.to, print.notable, action, print.notable); - fl_print_format("%[' section operation.%]%r", print.to, print.context, print.context, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; + return fake_make_print_error_simple_variable(setting, print, "No compiler has been specified, cannot perform", action, " section operation"); } #endif // _di_fake_make_print_error_compiler_not_specified_ @@ -52,7 +28,7 @@ extern "C" { fake_print_line_first_unlocked(setting, print); - fl_print_format("%[%QThe %S content '%]", print.to, print.context, print.prefix, content, print.context); + fl_print_format("%[%QThe %S%rcontent '%]", print.to, print.context, print.prefix, content, content ? f_string_space_s : f_string_empty_s, print.context); fl_print_format("%[%Q%]", print.to, print.notable, file, print.notable); fl_print_format("%[' must be a valid directory.%]%r", print.to, print.context, print.context, f_string_eol_s); @@ -62,22 +38,17 @@ extern "C" { } #endif // _di_fake_make_print_error_content_not_directory_ -#ifndef _di_fake_make_print_error_define_invalid_character_ - f_status_t fake_make_print_error_define_invalid_character(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t name) { - - if (print.verbosity < f_console_verbosity_error_e) return F_output_not; - - f_file_stream_lock(print.to); +#ifndef _di_fake_make_print_error_define_name_empty_ + f_status_t fake_make_print_error_define_name_empty(fake_setting_t * const setting, const fl_print_t print) { - fake_print_line_first_unlocked(setting, print); - - fl_print_format("%[%QInvalid characters in the define setting name '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%Q%]", print.to, print.notable, name, print.notable); - fl_print_format("%[', only alpha-numeric ASCII characters and underscore (without a leading digit) are allowed.%]%r", print.to, print.context, print.context, f_string_eol_s); + return fake_make_print_error_simple(setting, print, "Define name must not be an empty string"); + } +#endif // _di_fake_make_print_error_define_name_empty_ - f_file_stream_unlock(print.to); +#ifndef _di_fake_make_print_error_define_invalid_character_ + f_status_t fake_make_print_error_define_invalid_character(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t name) { - return F_none; + return fake_make_print_error_simple_variable(setting, print, "Invalid characters in the define name", name, ", only alpha-numeric ASCII characters and underscore (without a leading digit) are allowed"); } #endif // _di_fake_make_print_error_define_invalid_character_ @@ -105,17 +76,7 @@ extern "C" { #ifndef _di_fake_make_print_error_file_name_empty_ f_status_t fake_make_print_error_file_name_empty(fake_setting_t * const setting, const fl_print_t print) { - if (print.verbosity < f_console_verbosity_error_e) return F_output_not; - - f_file_stream_lock(print.to); - - fake_print_line_first_unlocked(setting, print); - - fll_print_format("%[%QFilename argument must not be an empty string.%]%r", print.to, print.context, print.prefix, print.context, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; + return fake_make_print_error_simple(setting, print, "File name argument must not be an empty string"); } #endif // _di_fake_make_print_error_file_name_empty_ @@ -193,6 +154,32 @@ extern "C" { } #endif // _di_fake_make_print_error_operation_incomplete_ +#ifndef _di_fake_make_print_error_operation_recursion_ + f_status_t fake_make_print_error_operation_recursion(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t buffer, const f_string_range_t range) { + + if (print.verbosity < f_console_verbosity_error_e) return F_output_not; + + f_file_stream_lock(print.to); + + fake_print_line_first_unlocked(setting, print); + + fl_print_format("%[%QThe section operation '%]", print.to, print.context, print.prefix, print.context); + fl_print_format("%[%/Q%]", print.to, print.notable, buffer, range, print.notable); + fl_print_format("%[' is already in the operation stack, recursion is not allowed.%]%r", print.to, print.context, print.context, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fake_make_print_error_operation_recursion_ + +#ifndef _di_fake_make_print_error_operation_section_not_found_ + f_status_t fake_make_print_error_operation_section_not_found(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t name) { + + return fake_make_print_error_simple_variable(setting, print, "No operation section named", name, " is found"); + } +#endif // _di_fake_make_print_error_operation_section_not_found_ + #ifndef _di_fake_make_print_error_out_of_range_number_ f_status_t fake_make_print_error_out_of_range_number(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t number, const f_number_unsigned_t minimum, const f_number_unsigned_t maximum) { @@ -212,6 +199,13 @@ extern "C" { } #endif // _di_fake_make_print_error_out_of_range_number_ +#ifndef _di_fake_make_print_error_pop_last_path_ + f_status_t fake_make_print_error_pop_last_path(fake_setting_t * const setting, const fl_print_t print) { + + return fake_make_print_error_simple(setting, print, "Must not attempt to pop project root off of path stack"); + } +#endif // _di_fake_make_print_error_pop_last_path_ + #ifndef _di_fake_make_print_error_program_failed_ f_status_t fake_make_print_error_program_failed(fake_setting_t * const setting, const fl_print_t print, const int return_code) { @@ -234,24 +228,36 @@ extern "C" { #ifndef _di_fake_make_print_error_program_not_found_ f_status_t fake_make_print_error_program_not_found(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t program) { + return fake_make_print_error_simple_variable(setting, print, "Failed to find program", program, " for executing"); + } +#endif // _di_fake_make_print_error_program_not_found_ + +#ifndef _di_fake_make_print_error_reserved_parameter_name_ + f_status_t fake_make_print_error_reserved_parameter_name(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t name) { + + return fake_make_print_error_simple_variable(setting, print, "Cannot assign a value to the parameter name", name, " because it is a reserved parameter name"); + } +#endif // _di_fake_make_print_error_reserved_parameter_name_ + +#ifndef _di_fake_make_print_error_simple_ + f_status_t fake_make_print_error_simple(fake_setting_t * const setting, const fl_print_t print, const f_string_t message) { + if (print.verbosity < f_console_verbosity_error_e) return F_output_not; f_file_stream_lock(print.to); fake_print_line_first_unlocked(setting, print); - fl_print_format("%[%QFailed to find program '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%Q%]", print.to, print.notable, program, print.notable); - fl_print_format("%[' for executing.%]%r", print.to, print.context, print.context, f_string_eol_s); + fl_print_format("%[%Q%S.%]%r", print.to, print.context, print.prefix, message, print.context, f_string_eol_s); f_file_stream_unlock(print.to); return F_none; } -#endif // _di_fake_make_print_error_program_not_found_ +#endif // _di_fake_make_print_error_simple_ -#ifndef _di_fake_make_print_error_unsupported_number_ - f_status_t fake_make_print_error_unsupported_number(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t number) { +#ifndef _di_fake_make_print_error_simple_variable_ + f_status_t fake_make_print_error_simple_variable(fake_setting_t * const setting, const fl_print_t print, const f_string_t before, const f_string_static_t variable, const f_string_t after) { if (print.verbosity < f_console_verbosity_error_e) return F_output_not; @@ -259,14 +265,21 @@ extern "C" { fake_print_line_first_unlocked(setting, print); - fl_print_format("%[%QInvalid or unsupported number provided '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%Q%]", print.to, print.notable, number, print.notable); - fl_print_format("%['.%]%r", print.to, print.context, print.context, f_string_eol_s); + fl_print_format("%[%Q%S '%]", print.to, print.context, print.prefix, before, print.context); + fl_print_format("%[%Q%]", print.to, print.notable, variable, print.notable); + fl_print_format("%['%S.%]%r", print.to, print.context, after, print.context, f_string_eol_s); f_file_stream_unlock(print.to); return F_none; } +#endif // _di_fake_make_print_error_simple_variable_ + +#ifndef _di_fake_make_print_error_unsupported_number_ + f_status_t fake_make_print_error_unsupported_number(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t number) { + + return fake_make_print_error_simple_variable(setting, print, "setting, print, Invalid or unsupported number provided", number, 0); + } #endif // _di_fake_make_print_error_unsupported_number_ #ifndef _di_fake_make_print_error_unsupported_type_ diff --git a/level_3/fake/c/main/make/print-error.h b/level_3/fake/c/main/make/print-error.h index cfd386c..a6dfa97 100644 --- a/level_3/fake/c/main/make/print-error.h +++ b/level_3/fake/c/main/make/print-error.h @@ -24,17 +24,15 @@ extern "C" { * This does not alter setting.status. * @param print * The output structure to print to. - * @param parameters - * The console parameters. - * @param index - * An index within the console parameters arguments that represents the invalid argument. + * @param name + * The invalid section name. * * @return * F_none on success. * F_output_not on success, but no printing is performed. */ #ifndef _di_fake_make_print_error_argument_invalid_section_ - extern f_status_t fake_make_print_error_argument_invalid_section(fake_setting_t * const setting, const fl_print_t print, const f_console_parameters_t parameters, const f_array_length_t index); + extern f_status_t fake_make_print_error_argument_invalid_section(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t name); #endif // _di_fake_make_print_error_argument_invalid_section_ /** @@ -151,6 +149,25 @@ extern "C" { #endif // _di_fake_make_print_error_content_not_directory_ /** + * Print error about a define name being an empty string. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_define_name_empty_ + extern f_status_t fake_make_print_error_define_name_empty(fake_setting_t * const setting, const fl_print_t print); +#endif // _di_fake_make_print_error_define_name_empty_ + +/** * Print error about a file not being of a specific type. * * @param setting @@ -216,6 +233,48 @@ extern "C" { #endif // _di_fake_make_print_error_operation_incomplete_ /** + * Print error about an operation recursion not being allowed. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param buffer + * The buffer containing the range to use. + * @param range + * The range within the buffer representing the operation name. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_operation_recursion_ + extern f_status_t fake_make_print_error_operation_recursion(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t buffer, const f_string_range_t range); +#endif // _di_fake_make_print_error_operation_recursion_ + +/** + * Print error about an operation section not being found. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param name + * The name of the operation. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_operation_section_not_found_ + extern f_status_t fake_make_print_error_operation_section_not_found(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t name); +#endif // _di_fake_make_print_error_operation_section_not_found_ + +/** * Print error about number being out of range. * * @param setting @@ -241,6 +300,25 @@ extern "C" { #endif // _di_fake_make_print_error_out_of_range_number_ /** + * Print error about attempting to pop last path off the project path stack. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_pop_last_path_ + extern f_status_t fake_make_print_error_pop_last_path(fake_setting_t * const setting, const fl_print_t print); +#endif // _di_fake_make_print_error_pop_last_path_ + +/** * Print error about program failed. * * @param setting @@ -283,6 +361,79 @@ extern "C" { #endif // _di_fake_make_print_error_program_not_found_ /** + * Print error about attempting to assign to a reserved parameter name. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param name + * The reserved parameter name. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_reserved_parameter_name_ + extern f_status_t fake_make_print_error_reserved_parameter_name(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t name); +#endif // _di_fake_make_print_error_reserved_parameter_name_ + +/** + * Print a simple error message with a single string message. + * + * This is primarily used by numerous error print functions to reduce code. + * This is not used for any error print functions that has more complex format structures. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param message + * The string to print. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_simple_ + extern f_status_t fake_make_print_error_simple(fake_setting_t * const setting, const fl_print_t print, const f_string_t message); +#endif // _di_fake_make_print_error_simple_ + +/** + * Print a simple error message with a before string, an after string, and a string variable. + * + * This is primarily used by numerous error print functions to reduce code. + * This is not used for any error print functions that has more complex format structures. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param before + * The string being printed before the variable. + * @param variable + * The string representing the variable. + * @param before + * The string being printed after the variable. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_simple_variable_ + extern f_status_t fake_make_print_error_simple_variable(fake_setting_t * const setting, const fl_print_t print, const f_string_t before, const f_string_static_t variable, const f_string_t after); +#endif // _di_fake_make_print_error_simple_variable_ + +/** * Print error about number not being supported. * * @param setting -- 1.8.3.1