From: Kevin Day Date: Thu, 1 Sep 2022 02:19:05 +0000 (-0500) Subject: Progress: Continue program related work. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=7583821e1ab441eed6192c5b5eb1b74695ffa8c6;p=fll Progress: Continue program related work. Slight restructuring of memory allocation: - Add or move double free and and unnecessary free checks. - If amount 0 for increase functions, then do nothing. - When resizing, perform a stale check in case strings point to a static string. - The private_f_memory_structure_resize() should properly return the error response. Remove fll_program_parameter_long_print_cannot_use_with(). The fll_program_standard_set_down() needs to check both the stream and the descriptors when closing rather than one or the other. Explicitly set signal_received to uint32_t rather than int. - The signal needs to also be uint32_t rather than f_status_t. Add several new print functions for common print messages used by the programs. Switch from flockfile() to f_file_stream_lock() and from funlockfile() to f_file_stream_unlock(). - There are still a lot more cases where these changes need to be made. Add more function documentation. Use "greater than" rather than "not equal to" for console verbosity checks. More changes to these programs: - fss_status_code - iki_write - status_code - utf8 --- diff --git a/level_0/f_console/c/console/common.h b/level_0/f_console/c/console/common.h index c459873..011f993 100644 --- a/level_0/f_console/c/console/common.h +++ b/level_0/f_console/c/console/common.h @@ -247,6 +247,8 @@ extern "C" { * * Intended to be used for the basic/standard verbosity modes for all programs following this practice. * + * These are expected to be in numeric order such that the smallest number is the least verbose and the highest number is the most verbose. + * * f_console_verbosity_*: * - quiet: Verbosity is set to quiet. * - error: Verbosity is set to error. diff --git a/level_0/f_memory/c/memory/structure.c b/level_0/f_memory/c/memory/structure.c index 22dc263..2a73b44 100644 --- a/level_0/f_memory/c/memory/structure.c +++ b/level_0/f_memory/c/memory/structure.c @@ -14,6 +14,9 @@ extern "C" { if (!size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + // Prevent double-frees and unnecessary frees. + if (!*structure && !length_new || *size == length_new) return F_data_not; + return private_f_memory_structure_adjust(length_new, type_size, structure, used, size); } #endif // _di_f_memory_structure_adjust_ @@ -89,7 +92,7 @@ extern "C" { if (!size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (*used + amount > *size) { + if (amount && *used + amount > *size) { if (*used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); } @@ -110,6 +113,9 @@ extern "C" { if (!size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + // Prevent double-frees and unnecessary frees. + if (!*structure && !length_new || *size == length_new) return F_data_not; + return private_f_memory_structure_resize(length_new, type_size, structure, used, size); } #endif // _di_f_memory_structure_resize_ diff --git a/level_0/f_memory/c/private-memory.c b/level_0/f_memory/c/private-memory.c index 8838c77..11c1d48 100644 --- a/level_0/f_memory/c/private-memory.c +++ b/level_0/f_memory/c/private-memory.c @@ -8,7 +8,10 @@ extern "C" { #if !defined(_di_f_memory_adjust_) || !defined(_di_f_memory_structure_adjust_) || !defined(_di_f_memory_structure_decimate_by_) f_status_t private_f_memory_adjust(const size_t length_old, const size_t length_new, const size_t type_size, void ** const pointer) { - if (length_old == length_new) return F_data_not; + // When old length is 0 and the pointer is not NULL, then consider this pointer stale and reset it to NULL. + if (!length_old && *pointer) { + *pointer = 0; + } if (*pointer) { if (length_old) { @@ -60,6 +63,11 @@ extern "C" { #if !defined(_di_f_memory_resize_) || !defined(_di_memory_structure_decrease_by_) || !defined(_di_memory_structure_increase_) || !defined(_di_memory_structure_increase_by_) || !defined(_di_f_memory_structure_resize_) f_status_t private_f_memory_resize(const size_t length_old, const size_t length_new, const size_t type_size, void ** const pointer) { + // When old length is 0 and the pointer is not NULL, then consider this pointer stale and reset it to NULL. + if (!length_old && *pointer) { + *pointer = 0; + } + if (*pointer) { if (length_new) { void * const new_pointer = realloc(*pointer, type_size * length_new); @@ -119,15 +127,16 @@ extern "C" { f_status_t private_f_memory_structure_resize(const size_t length_new, const size_t type_size, void ** const structure, f_array_length_t * const used, f_array_length_t * const size) { const f_status_t status = private_f_memory_resize(*size, length_new, type_size, structure); - if (F_status_is_error(status)) return status; - *size = length_new; + if (F_status_is_error_not(status)) { + *size = length_new; - if (*used > *size) { - *used = *size; + if (*used > *size) { + *used = *size; + } } - return F_none; + return status; } #endif // !defined(_di_memory_structure_decrease_by_) || !defined(_di_memory_structure_increase_) || !defined(_di_memory_structure_increase_by_) || !defined(_di_f_memory_structure_resize_) diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index d3afb00..dc55a0b 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -243,23 +243,6 @@ extern "C" { } #endif // _di_fll_program_parameter_additional_rip_mash_ -#ifndef _di_fll_program_parameter_long_print_cannot_use_with_ - f_status_t fll_program_parameter_long_print_cannot_use_with(const fl_print_t print, const f_string_static_t first, const f_string_static_t second) { - - f_file_stream_lock(print.to); - - fl_print_format("%[%QCannot specify the '%]", print.to.stream, print.context, print.prefix, print.context); - fl_print_format("%[%r%r%]", print.to.stream, print.notable, f_console_symbol_long_enable_s, first, print.notable); - fl_print_format("%[' parameter with the '%]", print.to.stream, print.context, print.context); - fl_print_format("%[%r%r%]", print.to.stream, print.notable, f_console_symbol_long_enable_s, second, print.notable); - fl_print_format("%[' parameter.%]%r", print.to.stream, print.context, print.context, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fll_program_parameter_long_print_cannot_use_with_ - #ifndef _di_fll_program_standard_set_down_ f_status_t fll_program_standard_set_down(fll_program_data_t * const main) { #ifndef _di_level_2_parameter_checking_ @@ -267,19 +250,20 @@ extern "C" { #endif // _di_level_2_parameter_checking_ // The fclose() calls have undefined behavior when closing an already closed file. - // Avoid this by explicitly checking every permutation to make sure each descriptor is not a duplicat descriptor. + // Avoid this by explicitly checking every permutation to make sure each descriptor is not a duplicate descriptor. // 0x1 = message stream, 0x2 = output stream, 0x4 = error stream, 0x8 = warning stream, 0x10 = debug stream. // 0x20 = message descriptor, 0x40 = output descriptor, 0x80 = error descriptor, 0x100 = warning descriptor, 0x200 = debug descriptor. uint16_t flag = 0; - if (main->message.to.id == -1) { - if (main->message.to.stream != 0 && main->message.to.stream != F_type_error_d && main->message.to.stream != F_type_input_d && main->message.to.stream != F_type_output_d) { + if (main->message.to.stream) { + if (main->message.to.stream != F_type_error_d && main->message.to.stream != F_type_input_d && main->message.to.stream != F_type_output_d) { f_file_stream_flush(main->message.to); flag |= 0x1; } } - else { + + if (main->message.to.id == -1) { if (main->message.to.id != F_type_descriptor_error_d && main->message.to.id != F_type_descriptor_input_d && main->message.to.id != F_type_descriptor_output_d) { f_file_flush(main->message.to); @@ -287,8 +271,8 @@ extern "C" { } } - if (main->output.to.id == -1) { - if (main->output.to.stream && main->output.to.stream != main->message.to.stream) { + if (main->output.to.stream) { + if (main->output.to.stream != main->message.to.stream) { if (main->output.to.stream != F_type_error_d && main->output.to.stream != F_type_input_d && main->output.to.stream != F_type_output_d) { f_file_stream_flush(main->output.to); @@ -296,16 +280,19 @@ extern "C" { } } } - else if (main->output.to.id != main->message.to.id) { - if (main->output.to.id != F_type_descriptor_error_d && main->output.to.id != F_type_descriptor_input_d && main->output.to.id != F_type_descriptor_output_d) { - f_file_flush(main->output.to); - flag |= 0x40; + if (main->error.to.id != -1) { + if (main->output.to.id != main->message.to.id) { + if (main->output.to.id != F_type_descriptor_error_d && main->output.to.id != F_type_descriptor_input_d && main->output.to.id != F_type_descriptor_output_d) { + f_file_flush(main->output.to); + + flag |= 0x40; + } } } - if (main->error.to.id == -1) { - if (main->error.to.stream && main->error.to.stream != main->message.to.stream && main->error.to.stream != main->output.to.stream) { + if (main->error.to.stream) { + if (main->error.to.stream != main->message.to.stream && main->error.to.stream != main->output.to.stream) { if (main->error.to.stream != F_type_error_d && main->error.to.stream != F_type_input_d && main->error.to.stream != F_type_output_d) { f_file_stream_flush(main->error.to); @@ -313,16 +300,19 @@ extern "C" { } } } - else if (main->error.to.id != main->message.to.id && main->error.to.id != main->output.to.id) { - if (main->error.to.id != F_type_descriptor_error_d && main->error.to.id != F_type_descriptor_input_d && main->error.to.id != F_type_descriptor_output_d) { - f_file_flush(main->error.to); - flag |= 0x80; + if (main->error.to.id != -1) { + if (main->error.to.id != main->message.to.id && main->error.to.id != main->output.to.id) { + if (main->error.to.id != F_type_descriptor_error_d && main->error.to.id != F_type_descriptor_input_d && main->error.to.id != F_type_descriptor_output_d) { + f_file_flush(main->error.to); + + flag |= 0x80; + } } } - if (main->warning.to.id == -1) { - if (main->warning.to.stream && main->warning.to.stream != main->message.to.stream && main->warning.to.stream != main->output.to.stream && main->warning.to.stream != main->error.to.stream) { + if (main->warning.to.stream) { + if (main->warning.to.stream != main->message.to.stream && main->warning.to.stream != main->output.to.stream && main->warning.to.stream != main->error.to.stream) { if (main->warning.to.stream != F_type_error_d && main->warning.to.stream != F_type_input_d && main->warning.to.stream != F_type_output_d) { f_file_stream_flush(main->warning.to); @@ -330,17 +320,20 @@ extern "C" { } } } - else if (main->warning.to.id != main->message.to.id && main->warning.to.id != main->output.to.id && main->warning.to.id != main->error.to.id) { - if (main->warning.to.id != F_type_descriptor_error_d && main->warning.to.id != F_type_descriptor_input_d && main->warning.to.id != F_type_descriptor_output_d) { - f_file_flush(main->warning.to); - flag |= 0x100; + if (main->warning.to.id != -1) { + if (main->warning.to.id != main->message.to.id && main->warning.to.id != main->output.to.id && main->warning.to.id != main->error.to.id) { + if (main->warning.to.id != F_type_descriptor_error_d && main->warning.to.id != F_type_descriptor_input_d && main->warning.to.id != F_type_descriptor_output_d) { + f_file_flush(main->warning.to); + + flag |= 0x100; + } } } - if (main->debug.to.id == -1) { - if (main->debug.to.stream && main->debug.to.stream != main->message.to.stream && main->debug.to.stream != main->output.to.stream && main->debug.to.stream != main->error.to.stream && main->debug.to.stream != main->warning.to.stream) { + if (main->debug.to.stream) { + if (main->debug.to.stream != main->message.to.stream && main->debug.to.stream != main->output.to.stream && main->debug.to.stream != main->error.to.stream && main->debug.to.stream != main->warning.to.stream) { if (main->debug.to.stream != F_type_error_d && main->debug.to.stream != F_type_input_d && main->debug.to.stream != F_type_output_d) { f_file_stream_flush(main->debug.to); @@ -348,11 +341,14 @@ extern "C" { } } } - else if (main->debug.to.id != main->message.to.id && main->debug.to.id != main->output.to.id && main->debug.to.id != main->error.to.id && main->debug.to.id != main->warning.to.id) { - if (main->debug.to.id != F_type_descriptor_error_d && main->debug.to.id != F_type_descriptor_input_d && main->debug.to.id != F_type_descriptor_output_d) { - f_file_flush(main->debug.to); - flag |= 0x200; + if (main->debug.to.id != -1) { + if (main->debug.to.id != main->message.to.id && main->debug.to.id != main->output.to.id && main->debug.to.id != main->error.to.id && main->debug.to.id != main->warning.to.id) { + if (main->debug.to.id != F_type_descriptor_error_d && main->debug.to.id != F_type_descriptor_input_d && main->debug.to.id != F_type_descriptor_output_d) { + f_file_flush(main->debug.to); + + flag |= 0x200; + } } } diff --git a/level_2/fll_program/c/program.h b/level_2/fll_program/c/program.h index ccda4f8..c53f57a 100644 --- a/level_2/fll_program/c/program.h +++ b/level_2/fll_program/c/program.h @@ -248,25 +248,6 @@ extern "C" { #endif // _di_fll_program_parameter_additional_rip_mash_ /** - * Print message about two long parameters not being allowed to be used together. - * - * This assumes both of the long parameters use f_console_symbol_long_enable_s. - * - * @param print - * The output structure. - * @param first - * The first string. - * @param second - * The second string. - * - * @return - * F_none on success. - */ -#ifndef _di_fll_program_parameter_long_print_cannot_use_with_ - extern f_status_t fll_program_parameter_long_print_cannot_use_with(const fl_print_t print, const f_string_static_t first, const f_string_static_t second); -#endif // _di_fll_program_parameter_long_print_cannot_use_with_ - -/** * This provides a standard program set down operations used by FLL programs. * * This does the following: diff --git a/level_2/fll_program/c/program/common.h b/level_2/fll_program/c/program/common.h index 283a669..a0a6a8a 100644 --- a/level_2/fll_program/c/program/common.h +++ b/level_2/fll_program/c/program/common.h @@ -84,7 +84,7 @@ extern "C" { int child; uint8_t pipe; - int signal_received; + uint32_t signal_received; uint16_t signal_check; f_signal_t signal; diff --git a/level_2/fll_program/c/program/print.c b/level_2/fll_program/c/program/print.c index 285cebb..5dfee1a 100644 --- a/level_2/fll_program/c/program/print.c +++ b/level_2/fll_program/c/program/print.c @@ -5,6 +5,157 @@ extern "C" { #endif +#ifndef _di_fll_program_print_error_missing_variable_not_zero_ + f_status_t fll_program_print_error_missing_variable_not_zero(const fl_print_t print, const f_string_static_t variable) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QThe %]", print.to.stream, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%Q%]", print.to.stream, print.set->notable, variable, print.set->notable); + fl_print_format("%[ is missing or has a length of %]", print.to.stream, print.set->error, print.set->error); + fl_print_format("%[0%]", print.to.stream, print.set->notable, print.set->notable); + fl_print_format("%[.%]%r", print.to.stream, print.set->error, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fll_program_print_error_missing_variable_not_zero_ + +#ifndef _di_fll_program_print_error_parameter_both_specified_same_amount_ + f_status_t fll_program_print_error_parameter_both_specified_same_amount(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t first, const f_string_static_t second) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QThe '%]", print.to.stream, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%Q%Q%]", print.to.stream, print.set->notable, symbol, first, print.set->notable); + fl_print_format("%[' parameter and the '%]", print.to.stream, print.set->error, print.set->error); + fl_print_format("%[%Q%Q%]", print.to.stream, print.set->notable, symbol, second, print.set->notable); + fl_print_format("%[' parameter must be specified the same number of times.%]%r", print.to.stream, print.set->error, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fll_program_print_error_parameter_both_specified_same_amount_ + +#ifndef _di_fll_program_print_error_parameter_cannot_use_with_ + f_status_t fll_program_print_error_parameter_cannot_use_with(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t first, const f_string_static_t second) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QCannot specify the '%]", print.to.stream, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%Q%Q%]", print.to.stream, print.set->notable, symbol, first, print.set->notable); + fl_print_format("%[' parameter with the '%]", print.to.stream, print.set->error, print.set->error); + fl_print_format("%[%Q%Q%]", print.to.stream, print.set->notable, symbol, second, print.set->notable); + fl_print_format("%[' parameter.%]%r", print.to.stream, print.set->error, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fll_program_print_error_parameter_cannot_use_with_ + +#ifndef _di_fll_program_print_error_parameter_missing_value_ + f_status_t fll_program_print_error_parameter_missing_value(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fll_program_print_error_parameter_missing_value_ + +#ifndef _di_fll_program_print_error_parameter_must_specify_once_ + f_status_t fll_program_print_error_parameter_must_specify_once(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QThe parameter '%]", print.to.stream, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%Q%Q%]", print.to.stream, print.set->notable, symbol, parameter, print.set->notable); + fl_print_format("%[' may only be specified once.%]%r", print.to.stream, print.set->error, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fll_program_print_error_parameter_must_specify_once_ + +#ifndef _di_fll_program_print_error_parameter_must_specify_once_value_ + f_status_t fll_program_print_error_parameter_must_specify_once_value(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter, const f_string_static_t value) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QThe value '%]", print.to.stream, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%Q%Q%]", print.to.stream, print.set->notable, symbol, value, print.set->notable); + fl_print_format("%[' may only be specified once for the parameter '%]", print.to.stream, print.set->error, print.set->error); + fl_print_format("%[%Q%Q%]", print.to.stream, print.set->notable, symbol, parameter, print.set->notable); + fl_print_format("%['.%]%r", print.to.stream, print.set->error, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fll_program_print_error_parameter_must_specify_once_value_ + +#ifndef _di_fll_program_print_error_pipe_invalid_form_feed_ + f_status_t fll_program_print_error_pipe_invalid_form_feed(const fl_print_t print) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QThe pipe has incorrectly placed form-feed characters (\\f).%]%r", print.to.stream, print.set->error, print.prefix, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fll_program_print_error_pipe_invalid_form_feed_ + +#ifndef _di_fll_program_print_error_pipe_missing_content_ + f_status_t fll_program_print_error_pipe_missing_content(const fl_print_t print) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QThe pipe has no content.%]%r", print.to.stream, print.set->error, print.prefix, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fll_program_print_error_pipe_missing_content_ + +#ifndef _di_fll_program_print_error_pipe_object_without_content_ + f_status_t fll_program_print_error_pipe_object_without_content(const fl_print_t print) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QThe pipe has an Object without Content.%]%r", print.to.stream, print.set->error, print.prefix, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fll_program_print_error_pipe_object_without_content_ + #ifndef _di_fll_program_print_help_header_ f_status_t fll_program_print_help_header(const fl_print_t print, const f_string_static_t name, const f_string_static_t version) { @@ -65,7 +216,7 @@ extern "C" { #ifndef _di_fll_program_print_help_usage_ f_status_t fll_program_print_help_usage(const fl_print_t print, const f_string_static_t name, const f_string_static_t parameters) { - fl_print_format("%r%r %[Usage:%]%r", print.to.stream, f_string_eol_s, f_string_eol_s, print.set->important, print.set->important, f_string_eol_s); + fl_print_format(" %[Usage:%]%r", print.to.stream, print.set->important, print.set->important, f_string_eol_s); fl_print_format(" %[%Q%]", print.to.stream, print.set->standout, name, print.set->standout); fl_print_format(" %[[%] options %[]%]", print.to.stream, print.set->notable, print.set->notable, print.set->notable, print.set->notable); @@ -81,22 +232,22 @@ extern "C" { #endif // _di_fll_program_print_help_usage_ #ifndef _di_fll_program_print_signal_received_ - f_status_t fll_program_print_signal_received(const fl_print_t print, const f_string_static_t line_first, const f_status_t signal) { + f_status_t fll_program_print_signal_received(const fl_print_t print, const f_string_static_t line_first, const uint32_t signal) { if (print.verbosity != f_console_verbosity_verbose_e && print.verbosity != f_console_verbosity_debug_e) { return F_output_not; } - flockfile(print.to.stream); + f_file_stream_lock(print.to); // Must flush and reset color because the interrupt may have interrupted the middle of a print function. f_file_stream_flush(print.to); fl_print_format("%]%r%[Received signal code %]", print.to.stream, print.set->reset, line_first, print.set->warning, print.set->warning); - fl_print_format("%[%i%]", print.to.stream, print.set->notable, signal, print.set->notable); + fl_print_format("%[%u%]", print.to.stream, print.set->notable, signal, print.set->notable); fl_print_format("%[.%]%r", print.to.stream, print.set->warning, print.set->warning, f_string_eol_s); - funlockfile(print.to.stream); + f_file_stream_unlock(print.to); return F_none; } diff --git a/level_2/fll_program/c/program/print.h b/level_2/fll_program/c/program/print.h index 7568fb9..4030de7 100644 --- a/level_2/fll_program/c/program/print.h +++ b/level_2/fll_program/c/program/print.h @@ -17,12 +17,249 @@ extern "C" { #endif /** + * Print an error message a variable not being defined or the variable has a length is 0. + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * @param variable + * The name of the variable that is not defined or has a length of 0. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fll_program_print_error_missing_variable_not_zero_ + extern f_status_t fll_program_print_error_missing_variable_not_zero(const fl_print_t print, const f_string_static_t variable); +#endif // _di_fll_program_print_error_missing_variable_not_zero_ + +/** + * Print an error message about two parameters being required to be specified the same number of times. + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * @param symbol + * The symbol string prepended to both parameters. + * This is usually f_console_symbol_long_enable_s. + * @param first + * The first parameter name. + * @param second + * The second parameter name. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fll_program_print_error_parameter_both_specified_same_amount_ + extern f_status_t fll_program_print_error_parameter_both_specified_same_amount(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t first, const f_string_static_t second); +#endif // _di_fll_program_print_error_parameter_both_specified_same_amount_ + +/** + * Print message about two parameters not being allowed to be used together. + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * @param symbol + * The symbol string prepended to both parameters. + * This is usually f_console_symbol_long_enable_s. + * @param first + * The first parameter name. + * @param second + * The second parameter name. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fll_program_print_error_parameter_cannot_use_with_ + extern f_status_t fll_program_print_error_parameter_cannot_use_with(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t first, const f_string_static_t second); +#endif // _di_fll_program_print_error_parameter_cannot_use_with_ + +/** + * Print message about parameter not have the required value associated with this. + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * @param symbol + * The symbol string prepended to both parameters. + * This locks, uses, and unlocks the file stream. + * This is usually f_console_symbol_long_enable_s. + * @param parameter + * The parameter name. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fll_program_print_error_parameter_missing_value_ + f_status_t fll_program_print_error_parameter_missing_value(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter); +#endif // _di_fll_program_print_error_parameter_missing_value_ + +/** + * Print message about parameter only being allowed to be used once. + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * @param symbol + * The symbol string prepended to both parameters. + * This locks, uses, and unlocks the file stream. + * This is usually f_console_symbol_long_enable_s. + * @param parameter + * The parameter name. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fll_program_print_error_parameter_must_specify_once_ + extern f_status_t fll_program_print_error_parameter_must_specify_once(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter); +#endif // _di_fll_program_print_error_parameter_must_specify_once_ + +/** + * Print message about a specific value only being allowed to be used once for the parameter. + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * @param symbol + * The symbol string prepended to both parameters. + * This locks, uses, and unlocks the file stream. + * This is usually f_console_symbol_long_enable_s. + * @param parameter + * The parameter name. + * @param value + * The value. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fll_program_print_error_parameter_must_specify_once_value_ + extern f_status_t fll_program_print_error_parameter_must_specify_once_value(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter, const f_string_static_t value); +#endif // _di_fll_program_print_error_parameter_must_specify_once_value_ + +/** + * Print a message about the pipe having an invalid form-feed character '\f' (U+000C). + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fll_program_print_error_pipe_invalid_form_feed_ + extern f_status_t fll_program_print_error_pipe_invalid_form_feed(const fl_print_t print); +#endif // _di_fll_program_print_error_pipe_invalid_form_feed_ + +/** + * Print a message about the pipe not having any content. + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fll_program_print_error_pipe_missing_content_ + extern f_status_t fll_program_print_error_pipe_missing_content(const fl_print_t print); +#endif // _di_fll_program_print_error_pipe_missing_content_ + +/** + * Print a message about the pipe having an Object without Content. + * + * This generally refers to an FSS Object and an FSS Content. + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fll_program_print_error_pipe_object_without_content_ + extern f_status_t fll_program_print_error_pipe_object_without_content(const fl_print_t print); +#endif // _di_fll_program_print_error_pipe_object_without_content_ + +/** * Print standard help header. * * This print function does not use locking, be sure something like flockfile() and funlockfile() are appropriately called. * * @param print * The output structure to print to. + * This uses but does not lock or unlock file stream. * This requires print.set to be non-NULL. * @param name * The name of the program. @@ -31,6 +268,7 @@ extern "C" { * * @return * F_none on success. + * F_output_not on success, but no printing is performed. * * @see f_print_terminated() * @see fl_print_format() @@ -46,6 +284,7 @@ extern "C" { * * @param print * The output structure to print to. + * This uses but does not lock or unlock file stream. * This requires print.set to be non-NULL. * @param option_short * The short name of the option. @@ -60,6 +299,7 @@ extern "C" { * * @return * F_none on success. + * F_output_not on success, but no printing is performed. * * @see f_print_terminated() * @see fl_print_format() @@ -75,6 +315,7 @@ extern "C" { * * @param print * The output structure to print to. + * This uses but does not lock or unlock file stream. * This requires print.set to be non-NULL. * @param option_long * The long name of the option. @@ -85,6 +326,7 @@ extern "C" { * * @return * F_none on success. + * F_output_not on success, but no printing is performed. * * @see f_print_terminated() * @see fl_print_format() @@ -100,6 +342,7 @@ extern "C" { * * @param print * The output structure to print to. + * This uses but does not lock or unlock file stream. * This requires print.set to be non-NULL. * @param option_other * The other name of the option. @@ -108,6 +351,7 @@ extern "C" { * * @return * F_none on success. + * F_output_not on success, but no printing is performed. * * @see f_print_terminated() * @see fl_print_format() @@ -122,13 +366,15 @@ extern "C" { * This print function does not use locking, be sure something like flockfile() and funlockfile() are appropriately called. * * @param print - * The output structure to print to. + * The output structure to print to + * This uses but does not lock or unlock file stream. * This requires print.set to be non-NULL. * @param context * The color context. * * @return * F_none on success. + * F_output_not on success, but no printing is performed. * * @see f_print_terminated() * @see fl_print_format() @@ -144,6 +390,7 @@ extern "C" { * * @param print * The output structure to print to. + * This uses but does not lock or unlock file stream. * This requires print.set to be non-NULL. * @param name * The name of the program. @@ -154,6 +401,7 @@ extern "C" { * * @return * F_none on success. + * F_output_not on success, but no printing is performed. * * @see f_print_terminated() * @see fl_print_format() @@ -169,6 +417,7 @@ extern "C" { * * @param print * The output structure to print to. + * This locks, uses, and unlocks the file stream. * This requires print.set to be non-NULL. * @param line_first * The first line character, which is expected to be set to either f_string_eol_s or f_string_empty_s. @@ -180,22 +429,22 @@ extern "C" { * F_output_not on success, but no printing is performed. */ #ifndef _di_fll_program_print_signal_received_ - extern f_status_t fll_program_print_signal_received(const fl_print_t print, const f_string_static_t line_first, const f_status_t signal); + extern f_status_t fll_program_print_signal_received(const fl_print_t print, const f_string_static_t line_first, const uint32_t signal); #endif // _di_fll_program_print_signal_received_ /** * Print the program version. * - * This print function does not use locking, be sure something like flockfile() and funlockfile() are appropriately called. - * * @param print * The output structure to print to. + * This uses but does not lock or unlock file stream. * This requires print.set to be non-NULL. * @param version * The version number of the program. * * @return * F_none on success. + * F_output_not on success, but no printing is performed. * * @see fl_print_format() */ diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index f23e811..76ed280 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -154,13 +154,13 @@ extern "C" { if (main->parameters.remaining.used || (main->pipe & fll_program_data_pipe_input_e)) { if (main->parameters.array[byte_dump_parameter_width_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%[%QThe parameter '%]", main->error.to.stream, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%r%r%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, byte_dump_long_width_s, main->context.set.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); return F_status_set_error(F_parameter); } @@ -172,7 +172,7 @@ extern "C" { status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], &number); if (F_status_is_error(status) || number < 1 || number >= 0xfb) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%[%QThe parameter '%]", main->error.to.stream, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%r%r%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, byte_dump_long_width_s, main->context.set.notable); @@ -182,7 +182,7 @@ extern "C" { fl_print_format("%[250%]", main->error.to.stream, main->context.set.notable, main->context.set.notable); fl_print_format("%[.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); if (F_status_is_error(status)) return status; @@ -193,13 +193,13 @@ extern "C" { } if (main->parameters.array[byte_dump_parameter_first_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%[%QThe parameter '%]", main->error.to.stream, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%r%r%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, byte_dump_long_first_s, main->context.set.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); return F_status_set_error(F_parameter); } @@ -211,7 +211,7 @@ extern "C" { status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], &number); if (F_status_is_error(status) || number > F_number_t_size_unsigned_d) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%[%QThe parameter '%]", main->error.to.stream, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%r%r%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, byte_dump_long_first_s, main->context.set.notable); @@ -221,7 +221,7 @@ extern "C" { fl_print_format("%[%un%]", main->error.to.stream, main->context.set.notable, F_number_t_size_unsigned_d, main->context.set.notable); fl_print_format("%[.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); if (F_status_is_error(status)) return status; @@ -232,13 +232,13 @@ extern "C" { } if (main->parameters.array[byte_dump_parameter_last_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%[%QThe parameter '%]", main->error.to.stream, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%r%r%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, byte_dump_long_last_s, main->context.set.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); return F_status_set_error(F_parameter); } @@ -250,7 +250,7 @@ extern "C" { status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], &number); if (F_status_is_error(status) || number < 0 || number > F_number_t_size_unsigned_d) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%[%QThe parameter '%]", main->error.to.stream, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%r%r%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, byte_dump_long_last_s, main->context.set.notable); @@ -260,7 +260,7 @@ extern "C" { fl_print_format("%[%un%]", main->error.to.stream, main->context.set.notable, F_number_t_size_unsigned_d, main->context.set.notable); fl_print_format("%[.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); if (F_status_is_error(status)) return status; @@ -272,7 +272,7 @@ extern "C" { if (main->parameters.array[byte_dump_parameter_first_e].result == f_console_result_additional_e && main->parameters.array[byte_dump_parameter_last_e].result == f_console_result_additional_e) { if (data.first > data.last) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%[%QThe parameter '%]", main->error.to.stream, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%r%r%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, byte_dump_long_first_s, main->context.set.notable); @@ -280,7 +280,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, byte_dump_long_last_s, main->context.set.notable); fl_print_format("%[' value.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); return F_status_set_error(F_parameter); } @@ -406,13 +406,13 @@ extern "C" { // Ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->output.verbosity != f_console_verbosity_quiet_e) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } } else { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_error_file_print(main->error, F_status_set_fine(status), "byte_dump_file", F_true, data.argv[main->parameters.remaining.array[counter]], f_file_operation_process_s, fll_error_file_type_file_e); } } diff --git a/level_3/byte_dump/c/common.c b/level_3/byte_dump/c/common.c index 53e56aa..34dc117 100644 --- a/level_3/byte_dump/c/common.c +++ b/level_3/byte_dump/c/common.c @@ -150,261 +150,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { byte_dump_parameter_from_bytesequence_e, byte_dump_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - byte_dump_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == byte_dump_parameter_from_bytesequence_e) { - if (setting->mode & byte_dump_mode_from_codepoint_e) { - setting->mode -= byte_dump_mode_from_codepoint_e; - } - - setting->mode |= byte_dump_mode_from_bytesequence_e; - } - else if (choices.array[choice] == byte_dump_parameter_from_codepoint_e) { - if (setting->mode & byte_dump_mode_from_bytesequence_e) { - setting->mode -= byte_dump_mode_from_bytesequence_e; - } - - setting->mode |= byte_dump_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { byte_dump_parameter_to_bytesequence_e, byte_dump_parameter_to_codepoint_e, byte_dump_parameter_to_combining_e, byte_dump_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - byte_dump_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == byte_dump_parameter_to_bytesequence_e) { - if (setting->mode & byte_dump_mode_to_codepoint_e) { - setting->mode -= byte_dump_mode_to_codepoint_e; - } - - if (setting->mode & byte_dump_mode_to_combining_e) { - setting->mode -= byte_dump_mode_to_combining_e; - } - - if (setting->mode & byte_dump_mode_to_width_e) { - setting->mode -= byte_dump_mode_to_width_e; - } - - setting->mode |= byte_dump_mode_to_bytesequence_e; - } - else if (choices.array[choice] == byte_dump_parameter_to_codepoint_e) { - if (setting->mode & byte_dump_mode_to_bytesequence_e) { - setting->mode -= byte_dump_mode_to_bytesequence_e; - } - - if (setting->mode & byte_dump_mode_to_combining_e) { - setting->mode -= byte_dump_mode_to_combining_e; - } - - if (setting->mode & byte_dump_mode_to_width_e) { - setting->mode -= byte_dump_mode_to_width_e; - } - - setting->mode |= byte_dump_mode_to_codepoint_e; - } - else if (choices.array[choice] == byte_dump_parameter_to_combining_e) { - if (setting->mode & byte_dump_mode_to_bytesequence_e) { - setting->mode -= byte_dump_mode_to_bytesequence_e; - } - - if (setting->mode & byte_dump_mode_to_codepoint_e) { - setting->mode -= byte_dump_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[byte_dump_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= byte_dump_mode_to_width_e; - } - - setting->mode |= byte_dump_mode_to_combining_e; - } - else if (choices.array[choice] == byte_dump_parameter_to_width_e) { - if (setting->mode & byte_dump_mode_to_bytesequence_e) { - setting->mode -= byte_dump_mode_to_bytesequence_e; - } - - if (setting->mode & byte_dump_mode_to_codepoint_e) { - setting->mode -= byte_dump_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[byte_dump_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= byte_dump_mode_to_combining_e; - } - - setting->mode |= byte_dump_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[byte_dump_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[byte_dump_parameter_to_file_e].values.used > 1) { - byte_dump_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[byte_dump_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[byte_dump_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[byte_dump_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[byte_dump_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= byte_dump_main_flag_file_to_e; - } - else { - byte_dump_print_error_parameter_file_name_empty(main, setting, main->parameters.array[byte_dump_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[byte_dump_parameter_to_file_e].result == f_console_result_found_e) { - byte_dump_print_error_no_value(main, setting, byte_dump_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & byte_dump_main_flag_file_to_e) { - setting->flag -= byte_dump_main_flag_file_to_e; - } - } - - if (main->parameters.array[byte_dump_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[byte_dump_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[byte_dump_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[byte_dump_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - byte_dump_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - byte_dump_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= byte_dump_main_flag_file_from_e; - } - else if (main->parameters.array[byte_dump_parameter_from_file_e].result == f_console_result_found_e) { - byte_dump_print_error_no_value(main, setting, byte_dump_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & byte_dump_main_flag_file_from_e) { - setting->flag -= byte_dump_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[byte_dump_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - byte_dump_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & byte_dump_mode_to_bytesequence_e)) { - if (main->parameters.array[byte_dump_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[byte_dump_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = byte_dump_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[byte_dump_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= byte_dump_main_flag_header_e; - } - - if (main->parameters.array[byte_dump_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= byte_dump_main_flag_separate_e; - } - if (main->parameters.array[byte_dump_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= byte_dump_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_byte_dump_setting_load_ diff --git a/level_3/byte_dump/c/private-byte_dump.c b/level_3/byte_dump/c/private-byte_dump.c index d72dac8..d41f09d 100644 --- a/level_3/byte_dump/c/private-byte_dump.c +++ b/level_3/byte_dump/c/private-byte_dump.c @@ -314,7 +314,7 @@ extern "C" { fflush(data->main->output.to.stream); if (found_invalid_utf) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%[Invalid UTF-8 codes were detected for file '%]", data->main->error.to.stream, data->main->context.set.error, data->main->context.set.error); @@ -326,7 +326,7 @@ extern "C" { } if (ferror(file.stream)) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%[%Qread() failed for '%]", data->main->error.to.stream, data->main->context.set.error, data->main->error.prefix, data->main->context.set.error); diff --git a/level_3/control/c/common.c b/level_3/control/c/common.c index 550fde8..6a57dda 100644 --- a/level_3/control/c/common.c +++ b/level_3/control/c/common.c @@ -253,261 +253,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { control_parameter_from_bytesequence_e, control_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - control_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == control_parameter_from_bytesequence_e) { - if (setting->mode & control_mode_from_codepoint_e) { - setting->mode -= control_mode_from_codepoint_e; - } - - setting->mode |= control_mode_from_bytesequence_e; - } - else if (choices.array[choice] == control_parameter_from_codepoint_e) { - if (setting->mode & control_mode_from_bytesequence_e) { - setting->mode -= control_mode_from_bytesequence_e; - } - - setting->mode |= control_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { control_parameter_to_bytesequence_e, control_parameter_to_codepoint_e, control_parameter_to_combining_e, control_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - control_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == control_parameter_to_bytesequence_e) { - if (setting->mode & control_mode_to_codepoint_e) { - setting->mode -= control_mode_to_codepoint_e; - } - - if (setting->mode & control_mode_to_combining_e) { - setting->mode -= control_mode_to_combining_e; - } - - if (setting->mode & control_mode_to_width_e) { - setting->mode -= control_mode_to_width_e; - } - - setting->mode |= control_mode_to_bytesequence_e; - } - else if (choices.array[choice] == control_parameter_to_codepoint_e) { - if (setting->mode & control_mode_to_bytesequence_e) { - setting->mode -= control_mode_to_bytesequence_e; - } - - if (setting->mode & control_mode_to_combining_e) { - setting->mode -= control_mode_to_combining_e; - } - - if (setting->mode & control_mode_to_width_e) { - setting->mode -= control_mode_to_width_e; - } - - setting->mode |= control_mode_to_codepoint_e; - } - else if (choices.array[choice] == control_parameter_to_combining_e) { - if (setting->mode & control_mode_to_bytesequence_e) { - setting->mode -= control_mode_to_bytesequence_e; - } - - if (setting->mode & control_mode_to_codepoint_e) { - setting->mode -= control_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[control_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= control_mode_to_width_e; - } - - setting->mode |= control_mode_to_combining_e; - } - else if (choices.array[choice] == control_parameter_to_width_e) { - if (setting->mode & control_mode_to_bytesequence_e) { - setting->mode -= control_mode_to_bytesequence_e; - } - - if (setting->mode & control_mode_to_codepoint_e) { - setting->mode -= control_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[control_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= control_mode_to_combining_e; - } - - setting->mode |= control_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[control_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[control_parameter_to_file_e].values.used > 1) { - control_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[control_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[control_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[control_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[control_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= control_main_flag_file_to_e; - } - else { - control_print_error_parameter_file_name_empty(main, setting, main->parameters.array[control_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[control_parameter_to_file_e].result == f_console_result_found_e) { - control_print_error_no_value(main, setting, control_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & control_main_flag_file_to_e) { - setting->flag -= control_main_flag_file_to_e; - } - } - - if (main->parameters.array[control_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[control_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[control_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[control_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - control_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - control_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= control_main_flag_file_from_e; - } - else if (main->parameters.array[control_parameter_from_file_e].result == f_console_result_found_e) { - control_print_error_no_value(main, setting, control_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & control_main_flag_file_from_e) { - setting->flag -= control_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[control_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - control_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & control_mode_to_bytesequence_e)) { - if (main->parameters.array[control_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[control_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = control_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[control_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= control_main_flag_header_e; - } - - if (main->parameters.array[control_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= control_main_flag_separate_e; - } - if (main->parameters.array[control_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= control_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_control_setting_load_ diff --git a/level_3/control/c/control.c b/level_3/control/c/control.c index 4c2864b..c14e04a 100644 --- a/level_3/control/c/control.c +++ b/level_3/control/c/control.c @@ -199,7 +199,7 @@ extern "C" { // Ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->output.verbosity != f_console_verbosity_quiet_e) { if (F_status_is_error(status)) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); fflush(main->error.to.stream); fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); diff --git a/level_3/control/c/private-control.c b/level_3/control/c/private-control.c index 3b6d494..0385004 100644 --- a/level_3/control/c/private-control.c +++ b/level_3/control/c/private-control.c @@ -733,7 +733,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_file_print(main->error, F_status_set_fine(status), "f_file_exists", F_true, data->cache.small, f_file_operation_find_s, fll_error_file_type_directory_e); - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); } } @@ -802,7 +802,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_file_print(main->error, F_status_set_fine(status), "f_file_exists", F_true, data->cache.small, f_file_operation_find_s, fll_error_file_type_directory_e); - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); } } diff --git a/level_3/control/c/private-print.c b/level_3/control/c/private-print.c index 8fdfaef..5ec604f 100644 --- a/level_3/control/c/private-print.c +++ b/level_3/control/c/private-print.c @@ -13,7 +13,7 @@ extern "C" { if (header.status == F_failure) { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe action '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, control_action_type_name(header.action), main->context.set.notable); @@ -29,7 +29,7 @@ extern "C" { fl_print_format("%[).%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); } - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); return; } @@ -120,7 +120,7 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QReceived error response for " CONTROL_action_s " '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%q%]", main->error.to.stream, main->context.set.notable, control_action_type_name(header.action), main->context.set.notable); @@ -136,7 +136,7 @@ extern "C" { fl_print_format("%[).%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); } - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_packet_response_ @@ -154,13 +154,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, action, main->context.set.notable); fl_print_format("%[' is not a known controller action.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_parameter_action_not_ @@ -169,13 +169,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe action parameter '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, action, main->context.set.notable); fl_print_format("%[' a rule base name cannot be an empty string.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_parameter_action_rule_basename_empty_ @@ -184,13 +184,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe action parameter '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, action, main->context.set.notable); fl_print_format("%[' a rule directory path cannot be an empty string.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_parameter_action_rule_directory_empty_ @@ -199,13 +199,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe action parameter '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, action, main->context.set.notable); fl_print_format("%[' a rule name cannot be an empty string.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_parameter_action_rule_empty_ @@ -214,13 +214,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe action parameter '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, action, main->context.set.notable); fl_print_format("%[' requires either a full rule name or a rule directory path along with the rule base name.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_parameter_action_rule_not_ @@ -229,13 +229,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe action parameter '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, action, main->context.set.notable); fl_print_format("%[' has too few arguments.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_parameter_action_rule_too_few_ @@ -244,7 +244,7 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe action parameter '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, action, main->context.set.notable); @@ -252,7 +252,7 @@ extern "C" { fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, with, main->context.set.notable); fl_print_format("%[' has too few arguments.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_parameter_action_rule_too_few_with_ @@ -261,13 +261,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe action parameter '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, action, main->context.set.notable); fl_print_format("%[' has too many arguments.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_parameter_action_rule_too_many_ @@ -276,7 +276,7 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe action parameter '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, action, main->context.set.notable); @@ -284,7 +284,7 @@ extern "C" { fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, with, main->context.set.notable); fl_print_format("%[' has too many arguments.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_parameter_action_rule_too_many_with_ @@ -293,7 +293,7 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe action parameter '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, action, main->context.set.notable); @@ -301,7 +301,7 @@ extern "C" { fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, with, main->context.set.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_parameter_action_rule_with_unknown_ @@ -310,13 +310,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%r%r%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, parameter, main->context.set.notable); fl_print_format("%[' must not be an empty string.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_parameter_value_empty_ @@ -325,13 +325,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%r%r%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, parameter, main->context.set.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_parameter_value_not_ @@ -367,13 +367,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QFailed to connect to the socket file '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, path_socket, main->context.set.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_socket_file_failed_ @@ -382,13 +382,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe controller socket file '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, path_socket, main->context.set.notable); fl_print_format("%[' could not be found and is required.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_socket_file_missing_ @@ -397,13 +397,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe controller socket file '%]", main->error.to.stream, f_string_eol_s, main->context.set.error, main->error.prefix, main->context.set.error); fl_print_format("%[%Q%]", main->error.to.stream, main->context.set.notable, path_socket, main->context.set.notable); fl_print_format("%[' is not a socket file.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_control_print_error_socket_file_not_ diff --git a/level_3/controller/c/common.c b/level_3/controller/c/common.c index c73b693..07b5523 100644 --- a/level_3/controller/c/common.c +++ b/level_3/controller/c/common.c @@ -685,261 +685,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { controller_parameter_from_bytesequence_e, controller_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - controller_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == controller_parameter_from_bytesequence_e) { - if (setting->mode & controller_mode_from_codepoint_e) { - setting->mode -= controller_mode_from_codepoint_e; - } - - setting->mode |= controller_mode_from_bytesequence_e; - } - else if (choices.array[choice] == controller_parameter_from_codepoint_e) { - if (setting->mode & controller_mode_from_bytesequence_e) { - setting->mode -= controller_mode_from_bytesequence_e; - } - - setting->mode |= controller_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { controller_parameter_to_bytesequence_e, controller_parameter_to_codepoint_e, controller_parameter_to_combining_e, controller_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - controller_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == controller_parameter_to_bytesequence_e) { - if (setting->mode & controller_mode_to_codepoint_e) { - setting->mode -= controller_mode_to_codepoint_e; - } - - if (setting->mode & controller_mode_to_combining_e) { - setting->mode -= controller_mode_to_combining_e; - } - - if (setting->mode & controller_mode_to_width_e) { - setting->mode -= controller_mode_to_width_e; - } - - setting->mode |= controller_mode_to_bytesequence_e; - } - else if (choices.array[choice] == controller_parameter_to_codepoint_e) { - if (setting->mode & controller_mode_to_bytesequence_e) { - setting->mode -= controller_mode_to_bytesequence_e; - } - - if (setting->mode & controller_mode_to_combining_e) { - setting->mode -= controller_mode_to_combining_e; - } - - if (setting->mode & controller_mode_to_width_e) { - setting->mode -= controller_mode_to_width_e; - } - - setting->mode |= controller_mode_to_codepoint_e; - } - else if (choices.array[choice] == controller_parameter_to_combining_e) { - if (setting->mode & controller_mode_to_bytesequence_e) { - setting->mode -= controller_mode_to_bytesequence_e; - } - - if (setting->mode & controller_mode_to_codepoint_e) { - setting->mode -= controller_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[controller_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= controller_mode_to_width_e; - } - - setting->mode |= controller_mode_to_combining_e; - } - else if (choices.array[choice] == controller_parameter_to_width_e) { - if (setting->mode & controller_mode_to_bytesequence_e) { - setting->mode -= controller_mode_to_bytesequence_e; - } - - if (setting->mode & controller_mode_to_codepoint_e) { - setting->mode -= controller_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[controller_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= controller_mode_to_combining_e; - } - - setting->mode |= controller_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[controller_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[controller_parameter_to_file_e].values.used > 1) { - controller_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[controller_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[controller_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[controller_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[controller_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= controller_main_flag_file_to_e; - } - else { - controller_print_error_parameter_file_name_empty(main, setting, main->parameters.array[controller_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[controller_parameter_to_file_e].result == f_console_result_found_e) { - controller_print_error_no_value(main, setting, controller_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & controller_main_flag_file_to_e) { - setting->flag -= controller_main_flag_file_to_e; - } - } - - if (main->parameters.array[controller_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[controller_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[controller_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[controller_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - controller_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - controller_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= controller_main_flag_file_from_e; - } - else if (main->parameters.array[controller_parameter_from_file_e].result == f_console_result_found_e) { - controller_print_error_no_value(main, setting, controller_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & controller_main_flag_file_from_e) { - setting->flag -= controller_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[controller_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - controller_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & controller_mode_to_bytesequence_e)) { - if (main->parameters.array[controller_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[controller_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = controller_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[controller_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= controller_main_flag_header_e; - } - - if (main->parameters.array[controller_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= controller_main_flag_separate_e; - } - if (main->parameters.array[controller_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= controller_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_controller_setting_load_ diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index 595d63f..5342cbd 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -117,7 +117,7 @@ extern "C" { } else { if (main->parameters.array[controller_parameter_settings_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(main->error.to, 0); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); @@ -156,7 +156,7 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[controller_parameter_pid_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(main->error.to, 0); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); @@ -214,7 +214,7 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[controller_parameter_cgroup_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(main->error.to, 0); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); @@ -259,7 +259,7 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.array[controller_parameter_daemon_e].result == f_console_result_found_e) { if (main->parameters.array[controller_parameter_validate_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(main->error.to, 0); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); @@ -340,7 +340,7 @@ extern "C" { // Ensure a newline is always put at the end of the program execution, unless in quiet mode. if (F_status_is_error(status) && main->output.verbosity != f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); } fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); diff --git a/level_3/controller/c/controller/private-controller.c b/level_3/controller/c/controller/private-controller.c index 1570655..ac4568d 100644 --- a/level_3/controller/c/controller/private-controller.c +++ b/level_3/controller/c/controller/private-controller.c @@ -100,7 +100,7 @@ extern "C" { return F_file_found_not; } - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_print_error_file(global.thread, global.main->error, F_status_set_fine(status), "f_file_stream_open", F_true, path, f_file_operation_open_s, fll_error_file_type_file_e); } } @@ -108,7 +108,7 @@ extern "C" { status = f_file_stream_read(file, &cache->buffer_file); if (F_status_is_error(status)) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_print_error_file(global.thread, global.main->error, F_status_set_fine(status), "f_file_stream_read", F_true, path, f_file_operation_read_s, fll_error_file_type_file_e); } } @@ -123,7 +123,7 @@ extern "C" { status = f_file_stat(path, F_true, &stat_file); if (F_status_is_error(status)) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_print_error_file(global.thread, global.main->error, F_status_set_fine(status), "f_file_stat", F_true, path, f_file_operation_stat_s, fll_error_file_type_file_e); } } @@ -434,7 +434,7 @@ extern "C" { // Always return immediately on memory errors. if (F_status_set_fine(status) == F_memory_not) { - if (global->main->error.verbosity != f_console_verbosity_quiet_e) { + if (global->main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global->main->error.to, global->thread); controller_print_error_file(0, global->main->error, F_status_set_fine(status), "controller_file_pid_create", F_true, global->setting->path_pid, f_file_operation_create_s, fll_error_file_type_file_e); @@ -667,7 +667,7 @@ extern "C" { global->thread->id_control = 0; } - if (global->main->error.verbosity != f_console_verbosity_quiet_e) { + if (global->main->error.verbosity > f_console_verbosity_quiet_e) { controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_thread_create", F_true); } } diff --git a/level_3/controller/c/entry/private-entry.c b/level_3/controller/c/entry/private-entry.c index 36a9435..5de673e 100644 --- a/level_3/controller/c/entry/private-entry.c +++ b/level_3/controller/c/entry/private-entry.c @@ -257,7 +257,7 @@ extern "C" { if (cache->content_actions.array[i].used < at_least || cache->content_actions.array[i].used > at_most) { action->status = F_status_set_error(F_parameter); - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { f_thread_mutex_lock(&global.thread->lock.print); flockfile(global.main->error.to.stream); @@ -373,7 +373,7 @@ extern "C" { status_action = action->status; } - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QThe %r item action must not have an empty string for a path (the first parameter).%]%r", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context, f_string_eol_s); } } @@ -400,7 +400,7 @@ extern "C" { } else { if (fl_string_dynamic_compare(action->parameters.array[1], cache->buffer_path) == F_equal_to_not) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(global.main->error.to.stream); fl_print_format("%r%[%QThe %r item action second parameter '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context); @@ -427,7 +427,7 @@ extern "C" { status_action = action->status; } - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QThe %r item action must not have an empty string for a rule name (the second parameter).%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context, f_string_eol_s); } } @@ -452,7 +452,7 @@ extern "C" { } } - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(global.main->error.to.stream); fl_print_format("%r%[%QThe %r item action third parameter (and beyond) must be one of '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context); @@ -478,7 +478,7 @@ extern "C" { status_action = action->status; } - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(global.main->error.to.stream); fl_print_format("%r%[%QThe %r item action may not specify the reserved item '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context); @@ -507,7 +507,7 @@ extern "C" { status_action = action->status; } - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(global.main->error.to.stream); fl_print_format("%r%[%QThe %r item action must have one of '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context); @@ -550,7 +550,7 @@ extern "C" { break; } - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(global.main->error.to.stream); fl_print_format("%r%[%QThe %r item action parameter '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context); @@ -574,7 +574,7 @@ extern "C" { else { action->status = F_status_set_error(F_supported_not); - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(global.main->error.to.stream); fl_print_format("%r%[%QThe %r item action may only have '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context); @@ -709,7 +709,7 @@ extern "C" { for (j = 2; j < cache->ats.used; j += 2) { if (cache->ats.array[j] == i) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QThe %r item named '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, is_entry ? controller_entry_s : controller_exit_s, global.main->error.prefix, global.main->error.context); @@ -771,7 +771,7 @@ extern "C" { if (error_has || i >= entry->items.used) { if (i >= entry->items.used) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QThe %r item named '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, is_entry ? controller_entry_s : controller_exit_s, global.main->error.prefix, global.main->error.context); @@ -888,7 +888,7 @@ extern "C" { } if (global->main->parameters.array[controller_parameter_simulate_e].result == f_console_result_found_e || global->main->error.verbosity == f_console_verbosity_verbose_e || global->main->error.verbosity == f_console_verbosity_debug_e) { - if (global->main->error.verbosity != f_console_verbosity_quiet_e && global->main->error.verbosity != f_console_verbosity_error_e) { + if ((global->main->error.verbosity > f_console_verbosity_error_e)) { controller_lock_print(global->main->output.to, global->thread); fl_print_format("%rProcessing %r%r item '", global->main->output.to.stream, f_string_eol_s, failsafe ? controller_entry_print_failsafe_s : f_string_empty_s, is_entry ? controller_entry_s : controller_exit_s); @@ -925,7 +925,7 @@ extern "C" { if (F_status_is_error(entry_action->status)) { if (global->main->parameters.array[controller_parameter_simulate_e].result == f_console_result_found_e) { - if (global->main->error.verbosity != f_console_verbosity_quiet_e) { + if (global->main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global->main->output.to, global->thread); fl_print_format("%rThe %r item action '", global->main->output.to.stream, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); @@ -947,7 +947,7 @@ extern "C" { } } else { - if ((entry_action->code & controller_entry_rule_code_require_d) && global->main->error.verbosity != f_console_verbosity_quiet_e || !(entry_action->code & controller_entry_rule_code_require_d) && (global->main->warning.verbosity == f_console_verbosity_verbose_e || global->main->warning.verbosity == f_console_verbosity_debug_e)) { + if ((entry_action->code & controller_entry_rule_code_require_d) && global->main->error.verbosity > f_console_verbosity_quiet_e || !(entry_action->code & controller_entry_rule_code_require_d) && (global->main->warning.verbosity == f_console_verbosity_verbose_e || global->main->warning.verbosity == f_console_verbosity_debug_e)) { fl_print_t *output = 0; if (entry_action->code & controller_entry_rule_code_require_d) { @@ -1037,7 +1037,7 @@ extern "C" { } else { if (!failsafe && (global->main->error.verbosity == f_console_verbosity_verbose_e || entry->show == controller_entry_show_init_e) && global->main->parameters.array[controller_parameter_simulate_e].result == f_console_result_none_e) { - if (global->main->error.verbosity != f_console_verbosity_quiet_e && global->main->error.verbosity != f_console_verbosity_error_e) { + if ((global->main->error.verbosity > f_console_verbosity_error_e)) { fl_print_format("%rState is now '%[%r%]'.%r", global->main->output.to.stream, f_string_eol_s, global->main->context.set.notable, controller_ready_s, global->main->context.set.notable, f_string_eol_s); } } @@ -1050,7 +1050,7 @@ extern "C" { if (entry_action->number == 0 || entry_action->number >= entry->items.used || failsafe && entry_action->number == global->setting->failsafe_item_id) { // This should not happen if the pre-process is working as intended, but in case it doesn't, return a critical error to prevent infinite recursion and similar errors. - if (global->main->error.verbosity != f_console_verbosity_quiet_e) { + if (global->main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global->main->error.to, global->thread); fl_print_format("%r%[Invalid %r item index '%]", global->main->error.to.stream, f_string_eol_s, global->main->error.context, is_entry ? controller_entry_s : controller_exit_s, global->main->error.context); @@ -1233,7 +1233,7 @@ extern "C" { } if (F_status_is_error(status)) { - if (global->main->error.verbosity != f_console_verbosity_quiet_e) { + if (global->main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global->main->error.to, global->thread); controller_entry_print_error_cache(is_entry, global->main->error, cache->action); @@ -1340,7 +1340,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_file_found_not) { - if (global->main->error.verbosity != f_console_verbosity_quiet_e) { + if (global->main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global->main->error.to, global->thread); fl_print_format("%r%[%QExecution failed, unable to find program or script '%]", global->main->error.to.stream, f_string_eol_s, global->main->error.context, global->main->error.prefix, global->main->error.context); @@ -1359,7 +1359,7 @@ extern "C" { return F_status_set_error(F_execute); } else if (result != 0) { - if (global->main->error.verbosity != f_console_verbosity_quiet_e) { + if (global->main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global->main->error.to, global->thread); fl_print_format("%r%[%QExecution failed with return value of '%]", global->main->error.to.stream, f_string_eol_s, global->main->error.context, global->main->error.prefix, global->main->error.context); @@ -1415,7 +1415,7 @@ extern "C" { if (entry_action->number == 0 || entry_action->number >= entry->items.used) { // This should not happen if the pre-process is working as designed, but in case it doesn't, return a critical error to prevent infinite recursion and similar errors. - if (global->main->error.verbosity != f_console_verbosity_quiet_e) { + if (global->main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global->main->error.to, global->thread); fl_print_format("%r%[%QInvalid %r item index '%]", global->main->error.to.stream, f_string_eol_s, global->main->error.context, global->main->error.prefix, is_entry ? controller_entry_s : controller_exit_s, global->main->error.context); @@ -1500,7 +1500,7 @@ extern "C" { } } - if ((global->main->parameters.array[controller_parameter_simulate_e].result == f_console_result_found_e && global->main->error.verbosity != f_console_verbosity_quiet_e) && global->main->error.verbosity != f_console_verbosity_error_e || global->main->error.verbosity == f_console_verbosity_verbose_e) { + if ((global->main->parameters.array[controller_parameter_simulate_e].result == f_console_result_found_e && global->main->error.verbosity > f_console_verbosity_quiet_e) && global->main->error.verbosity != f_console_verbosity_error_e || global->main->error.verbosity == f_console_verbosity_verbose_e) { controller_lock_print(global->main->output.to, global->thread); fl_print_format("%rDone processing %r item '", global->main->output.to.stream, f_string_eol_s, is_entry ? controller_entry_s : controller_exit_s); @@ -1602,7 +1602,7 @@ extern "C" { } } else { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fll_print_format("%r%[%QThe %r file is empty.%]%r", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, is_entry ? controller_entry_s : is_entry ? controller_entry_s : controller_exit_s, global.main->error.context, f_string_eol_s); @@ -1771,7 +1771,7 @@ extern "C" { cache->action.name_item.used = 0; if (!(code & 0x1)) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QThe required %r item '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context); @@ -1833,7 +1833,7 @@ extern "C" { break; } - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QThe required %r item '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context); @@ -2275,7 +2275,7 @@ extern "C" { continue; } - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(global.main->error.to.stream); fl_print_format("%r%[%QThe %r setting '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, is_entry ? controller_entry_s : controller_exit_s, global.main->error.context); diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index ce0ee4c..fa71074 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -439,7 +439,7 @@ extern "C" { } if (!type_rerun) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QRule item action '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, global.main->error.context); @@ -479,7 +479,7 @@ extern "C" { } } else { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QRule item action '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, global.main->error.context); @@ -511,7 +511,7 @@ extern "C" { item->reruns[type_rerun].is |= rerun_item == &item->reruns[type_rerun].failure ? controller_rule_rerun_is_failure_reset_d : controller_rule_rerun_is_success_reset_d; } else { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QRule item action '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, global.main->error.context); @@ -552,7 +552,7 @@ extern "C" { } } else { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QUnknown value '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, global.main->error.context); @@ -695,7 +695,7 @@ extern "C" { } if (F_status_is_error(status)) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { status = F_status_set_fine(status); if (status != F_valid_not && status != F_number && status != F_number_decimal && status != F_number_overflow && status != F_number_underflow && status != F_number_negative) { @@ -1693,7 +1693,7 @@ extern "C" { } if (options & controller_process_option_simulate_d) { - if (main->error.verbosity != f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e) { + if (main->error.verbosity > f_console_verbosity_error_e) { controller_lock_print(main->error.to, thread); fl_print_format("%rSimulating execution of '%[", main->error.to.stream, f_string_eol_s, main->context.set.title); @@ -2496,7 +2496,7 @@ extern "C" { if (multiple) { if (type == controller_rule_action_type_group_e || type == controller_rule_action_type_pid_file_e || type == controller_rule_action_type_user_e) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QFSS Extended List is not allowed for the rule item action '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, global.main->error.context); @@ -2569,7 +2569,7 @@ extern "C" { break; default: - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QUnsupported action type '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, global.main->error.context); @@ -2688,7 +2688,7 @@ extern "C" { } } - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); controller_rule_item_print_error_rule_not_loaded(global.main->error, dynamics[i]->array[j]); @@ -2989,7 +2989,7 @@ extern "C" { } // for if (missing) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); if (process->rule.items.used) { @@ -3138,7 +3138,7 @@ extern "C" { if (F_status_is_error(status)) { f_thread_unlock(&global.thread->lock.process); - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); controller_rule_item_print_error_rule_not_loaded(global.main->error, alias_rule); @@ -3445,7 +3445,7 @@ extern "C" { for (f_array_length_t i = 0; i < process->stack.used && controller_thread_is_enabled_process(process, global.thread); ++i) { if (process->stack.array[i] == id_rule) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QThe rule '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, global.main->error.context); @@ -3523,7 +3523,7 @@ extern "C" { status = F_status_set_error(F_found_not); - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); controller_rule_item_print_error_rule_not_loaded(global.main->error, process->rule.alias); @@ -4447,7 +4447,7 @@ extern "C" { for (j = 0; j < rule->limits.used; ++j) { if (type == rule->limits.array[j].type) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { // Get the current line number within the settings item. cache->action.line_item = line_item; @@ -4636,7 +4636,7 @@ extern "C" { status = controller_validate_has_graph(*setting_value); if (status == F_false || F_status_set_fine(status) == F_complete_not_utf) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { // Get the current line number within the settings item. cache->action.line_item = line_item; @@ -4646,7 +4646,7 @@ extern "C" { } if (status == F_false) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QRule setting has an invalid name '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, global.main->error.context); @@ -4781,7 +4781,7 @@ extern "C" { status = F_status_set_fine(status); if ((zero_only && number) || (!zero_only && (number < 1 || number > 99)) || status == F_data_not || status == F_number || status == F_number_overflow || status == F_number_negative || status == F_number_positive) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { // Get the current line number within the settings item. cache->action.line_item = line_item; @@ -4860,7 +4860,7 @@ extern "C" { timeout_code = controller_rule_timeout_code_stop_d; } else { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { // Get the current line number within the settings item. cache->action.line_item = line_item; @@ -5057,7 +5057,7 @@ extern "C" { status = F_status_set_fine(status); if (number < -20 || number > 19 || status == F_data_not || status == F_number || status == F_number_overflow || status == F_number_underflow || status == F_number_decimal) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { // Get the current line number within the settings item. cache->action.line_item = line_item; @@ -5348,7 +5348,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; if (status == F_false) { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(global.main->error.to, global.thread); fl_print_format("%r%[%QRule setting has an invalid environment variable name '%]", global.main->error.to.stream, f_string_eol_s, global.main->error.context, global.main->error.prefix, global.main->error.context); @@ -5441,7 +5441,7 @@ extern "C" { action = controller_rule_action_type_thaw_e; } else { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { // Get the current line number within the settings item. cache->action.line_item = line_item; @@ -5492,7 +5492,7 @@ extern "C" { setting_values = &rule->ons.array[j].wish; } else { - if (global.main->error.verbosity != f_console_verbosity_quiet_e) { + if (global.main->error.verbosity > f_console_verbosity_quiet_e) { // Get the current line number within the settings item. cache->action.line_item = line_item; @@ -5644,7 +5644,7 @@ extern "C" { break; default: - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(main->error.to, global.thread); fl_print_format("%r%[%QUnsupported action type '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); diff --git a/level_3/controller/c/thread/private-thread.c b/level_3/controller/c/thread/private-thread.c index b448988..b7582b4 100644 --- a/level_3/controller/c/thread/private-thread.c +++ b/level_3/controller/c/thread/private-thread.c @@ -191,7 +191,7 @@ extern "C" { status = controller_lock_create(&thread.lock); if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_error_print(main->error, status, "controller_lock_create", F_true); } } @@ -210,7 +210,7 @@ extern "C" { if (F_status_is_error(status)) { thread.id_signal = 0; - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { controller_print_error(&thread, main->error, F_status_set_fine(status), "f_thread_create", F_true); } } @@ -219,7 +219,7 @@ extern "C" { setting->ready = controller_setting_ready_done_e; if (f_file_exists(setting->path_pid, F_true) == F_true) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(main->error.to, &thread); fl_print_format("%r%[%QThe pid file '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); @@ -239,7 +239,7 @@ extern "C" { status = f_thread_create(0, &thread.id_entry, &controller_thread_entry, (void *) &entry); if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { controller_print_error(&thread, main->error, F_status_set_fine(status), "f_thread_create", F_true); } } @@ -272,7 +272,7 @@ extern "C" { if (F_status_is_error(status)) { thread.id_cleanup = 0; - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { controller_print_error(&thread, main->error, F_status_set_fine(status), "f_thread_create", F_true); } } diff --git a/level_3/controller/c/thread/private-thread_entry.c b/level_3/controller/c/thread/private-thread_entry.c index ba707b6..1331d4a 100644 --- a/level_3/controller/c/thread/private-thread_entry.c +++ b/level_3/controller/c/thread/private-thread_entry.c @@ -39,7 +39,7 @@ extern "C" { if (main->parameters.array[controller_parameter_validate_e].result == f_console_result_none_e || main->parameters.array[controller_parameter_simulate_e].result == f_console_result_found_e) { if (entry->setting->entry.pid == controller_entry_pid_require_e && f_file_exists(entry->setting->path_pid, F_true) == F_true) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(main->error.to, entry->global->thread); fl_print_format("%r%[%QThe pid file '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); @@ -78,7 +78,7 @@ extern "C" { const f_status_t status_failsafe = controller_entry_process(entry->global, cache, F_true, F_true); if (F_status_is_error(status_failsafe)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(main->error.to, entry->global->thread); fl_print_format("%r%[%QFailed while processing requested failsafe item '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); @@ -193,7 +193,7 @@ extern "C" { const f_status_t status_failsafe = controller_entry_process(entry->global, cache, F_true, F_false); if (F_status_is_error(status_failsafe)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { controller_lock_print(main->error.to, entry->global->thread); fl_print_format("%r%[%QFailed while processing requested failsafe item '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); diff --git a/level_3/controller/c/thread/private-thread_process.c b/level_3/controller/c/thread/private-thread_process.c index 29f5444..ceb0193 100644 --- a/level_3/controller/c/thread/private-thread_process.c +++ b/level_3/controller/c/thread/private-thread_process.c @@ -330,7 +330,7 @@ extern "C" { f_status_t status = f_thread_create(0, &global->thread->id_entry, &controller_thread_exit, (void *) &entry); if (F_status_is_error(status)) { - if (global->main->error.verbosity != f_console_verbosity_quiet_e) { + if (global->main->error.verbosity > f_console_verbosity_quiet_e) { controller_print_error(global->thread, global->main->error, F_status_set_fine(status), "f_thread_create", F_true); } diff --git a/level_3/fake/c/common.c b/level_3/fake/c/common.c index 9f06812..ecbf20d 100644 --- a/level_3/fake/c/common.c +++ b/level_3/fake/c/common.c @@ -198,261 +198,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fake_parameter_from_bytesequence_e, fake_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fake_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fake_parameter_from_bytesequence_e) { - if (setting->mode & fake_mode_from_codepoint_e) { - setting->mode -= fake_mode_from_codepoint_e; - } - - setting->mode |= fake_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fake_parameter_from_codepoint_e) { - if (setting->mode & fake_mode_from_bytesequence_e) { - setting->mode -= fake_mode_from_bytesequence_e; - } - - setting->mode |= fake_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fake_parameter_to_bytesequence_e, fake_parameter_to_codepoint_e, fake_parameter_to_combining_e, fake_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fake_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fake_parameter_to_bytesequence_e) { - if (setting->mode & fake_mode_to_codepoint_e) { - setting->mode -= fake_mode_to_codepoint_e; - } - - if (setting->mode & fake_mode_to_combining_e) { - setting->mode -= fake_mode_to_combining_e; - } - - if (setting->mode & fake_mode_to_width_e) { - setting->mode -= fake_mode_to_width_e; - } - - setting->mode |= fake_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fake_parameter_to_codepoint_e) { - if (setting->mode & fake_mode_to_bytesequence_e) { - setting->mode -= fake_mode_to_bytesequence_e; - } - - if (setting->mode & fake_mode_to_combining_e) { - setting->mode -= fake_mode_to_combining_e; - } - - if (setting->mode & fake_mode_to_width_e) { - setting->mode -= fake_mode_to_width_e; - } - - setting->mode |= fake_mode_to_codepoint_e; - } - else if (choices.array[choice] == fake_parameter_to_combining_e) { - if (setting->mode & fake_mode_to_bytesequence_e) { - setting->mode -= fake_mode_to_bytesequence_e; - } - - if (setting->mode & fake_mode_to_codepoint_e) { - setting->mode -= fake_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fake_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fake_mode_to_width_e; - } - - setting->mode |= fake_mode_to_combining_e; - } - else if (choices.array[choice] == fake_parameter_to_width_e) { - if (setting->mode & fake_mode_to_bytesequence_e) { - setting->mode -= fake_mode_to_bytesequence_e; - } - - if (setting->mode & fake_mode_to_codepoint_e) { - setting->mode -= fake_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fake_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fake_mode_to_combining_e; - } - - setting->mode |= fake_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fake_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fake_parameter_to_file_e].values.used > 1) { - fake_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fake_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fake_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fake_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fake_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fake_main_flag_file_to_e; - } - else { - fake_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fake_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fake_parameter_to_file_e].result == f_console_result_found_e) { - fake_print_error_no_value(main, setting, fake_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fake_main_flag_file_to_e) { - setting->flag -= fake_main_flag_file_to_e; - } - } - - if (main->parameters.array[fake_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fake_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fake_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fake_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fake_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fake_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fake_main_flag_file_from_e; - } - else if (main->parameters.array[fake_parameter_from_file_e].result == f_console_result_found_e) { - fake_print_error_no_value(main, setting, fake_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fake_main_flag_file_from_e) { - setting->flag -= fake_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fake_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fake_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fake_mode_to_bytesequence_e)) { - if (main->parameters.array[fake_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fake_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fake_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fake_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fake_main_flag_header_e; - } - - if (main->parameters.array[fake_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fake_main_flag_separate_e; - } - if (main->parameters.array[fake_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fake_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fake_setting_load_ diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index 002dcf6..658d754 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -173,7 +173,7 @@ extern "C" { if (!(main->pipe & fll_program_data_pipe_input_e) && main->parameters.remaining.used) { status = F_status_set_error(F_parameter); - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QYou failed to specify a valid operation.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); } } @@ -183,8 +183,8 @@ extern "C" { if (main->parameters.array[fake_parameter_operation_build_e].locations.used && main->parameters.array[fake_parameter_operation_make_e].locations.used) { status = F_status_set_error(F_parameter); - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe operation '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%]", main->error.to.stream, main->error.notable, fake_other_operation_build_s, main->error.notable); @@ -192,7 +192,7 @@ extern "C" { fl_print_format("%[%r%]", main->error.to.stream, main->error.notable, fake_other_operation_make_s, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } } @@ -345,28 +345,28 @@ extern "C" { } if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe operation '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%]", main->error.to.stream, main->error.notable, operations_name, main->error.notable); fl_print_format("%[' failed.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } } - if (main->error.verbosity != f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e) { + if (main->error.verbosity > f_console_verbosity_error_e) { if (F_status_is_error_not(status) && status != F_child) { fll_print_format("%rAll operations complete.%r%r", main->output.to.stream, f_string_eol_s, f_string_eol_s, f_string_eol_s); } } } - if (F_status_is_error(status) && main->error.verbosity != f_console_verbosity_quiet_e) { + if (F_status_is_error(status) && main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); } fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); diff --git a/level_3/fake/c/private-build-load.c b/level_3/fake/c/private-build-load.c index 3faf748..7157859 100644 --- a/level_3/fake/c/private-build-load.c +++ b/level_3/fake/c/private-build-load.c @@ -43,7 +43,7 @@ extern "C" { if (environment->used + data_build->setting.environment.used > environment->size) { if (environment->used + data_build->setting.environment.used > f_environment_max_length) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe values for the setting '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -579,7 +579,7 @@ extern "C" { } // for if (found == F_false) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe specified mode '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -673,7 +673,7 @@ extern "C" { if (F_status_is_error(*status)) { if (*status == F_status_set_error(F_string_too_large)) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { funlockfile(data->main->error.to.stream); fl_print_format("%r%[%QA setting in the file '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -1376,7 +1376,7 @@ extern "C" { setting->search_shared = F_false; } - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe parameters '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -1437,7 +1437,7 @@ extern "C" { if (setting->build_language == fake_build_language_type_c_e || setting->build_language == fake_build_language_type_cpp_e) { if (setting->build_shared == F_false && setting->build_static == F_false) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe build settings '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); diff --git a/level_3/fake/c/private-build-objects.c b/level_3/fake/c/private-build-objects.c index 29e50c1..2498bcd 100644 --- a/level_3/fake/c/private-build-objects.c +++ b/level_3/fake/c/private-build-objects.c @@ -101,7 +101,7 @@ extern "C" { *status = f_directory_exists(destination_path); if (*status == F_false) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe path '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 99f1d16..4a3a3a0 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -451,7 +451,7 @@ extern "C" { break; } - else if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + else if (data->main->error.verbosity > f_console_verbosity_quiet_e) { fake_print_error_build_operation_file(data, F_status_set_fine(*status), "fl_directory_copy", fake_common_file_directory_copy_s, f_file_operation_to_s, path_source, destination_directory, F_true); } @@ -721,7 +721,7 @@ extern "C" { else if (*status != F_child) { if (F_status_is_error(*status)) { if (F_status_set_fine(*status) == F_failure) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QFailed to execute script: '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index fd5bd8f..81f8d0d 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -66,7 +66,7 @@ extern "C" { return_code = 1; if (F_status_set_fine(*status) == F_file_found_not) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QFailed to find program '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -255,7 +255,7 @@ extern "C" { status = f_utf_is_word_dash_plus(data->main->parameters.arguments.array[index].string + j, width_max, F_false); if (F_status_is_error(status)) { - if (fll_error_print(data->main->error, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_known_not && data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (fll_error_print(data->main->error, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_known_not && data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QFailed to process the parameter '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -269,7 +269,7 @@ extern "C" { } if (status == F_false) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -298,7 +298,7 @@ extern "C" { if (F_status_is_error(status)) { if (status == F_status_set_error(F_string_too_large)) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe parameter '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -319,7 +319,7 @@ extern "C" { } if (!data->main->parameters.arguments.array[index].used || status == F_data_not) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe parameter '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -413,7 +413,7 @@ extern "C" { status = f_path_directory_cleanup(data->main->parameters.arguments.array[index], parameters_value[i]); if (F_status_is_error(status)) { - if (fll_error_print(data->main->error, F_status_set_fine(status), "f_path_directory_cleanup", F_false) == F_known_not && data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (fll_error_print(data->main->error, F_status_set_fine(status), "f_path_directory_cleanup", F_false) == F_known_not && data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QFailed to process parameter '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -440,7 +440,7 @@ extern "C" { status = f_string_dynamic_append(parameter_defaults[i], parameters_value[i]); if (F_status_is_error(status)) { - if (fll_error_print(data->main->error, F_status_set_fine(status), " f_string_dynamic_append", F_false) == F_known_not && data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (fll_error_print(data->main->error, F_status_set_fine(status), " f_string_dynamic_append", F_false) == F_known_not && data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QFailed to load default for the parameter '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -460,7 +460,7 @@ extern "C" { status = fll_program_parameter_additional_rip(data->main->parameters.arguments.array, data->main->parameters.array[fake_parameter_define_e].values, &data->define); if (F_status_is_error(status)) { - if (fll_error_print(data->main->error, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_known_not && data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (fll_error_print(data->main->error, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_known_not && data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QFailed to process the parameter '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -484,7 +484,7 @@ extern "C" { status = fll_program_parameter_additional_rip(data->main->parameters.arguments.array, data->main->parameters.array[fake_parameter_mode_e].values, &data->mode); if (F_status_is_error(status)) { - if (fll_error_print(data->main->error, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_known_not && data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (fll_error_print(data->main->error, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_known_not && data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QFailed to process the parameter '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -510,7 +510,7 @@ extern "C" { status = f_utf_is_word_dash_plus(data->mode.array[i].string + j, width_max, F_false); if (F_status_is_error(status)) { - if (fll_error_print(data->main->error, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_known_not && data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (fll_error_print(data->main->error, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_known_not && data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QFailed to process the parameter '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -524,7 +524,7 @@ extern "C" { } if (status == F_false) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); diff --git a/level_3/fake/c/private-make-load_fakefile.c b/level_3/fake/c/private-make-load_fakefile.c index d63b29c..9d7aef3 100644 --- a/level_3/fake/c/private-make-load_fakefile.c +++ b/level_3/fake/c/private-make-load_fakefile.c @@ -213,7 +213,7 @@ extern "C" { } if (missing_main) { - if (data_make->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data_make->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data_make->main->error.to.stream); fl_print_format("%r%[%QThe fakefile '%]", data_make->main->error.to.stream, f_string_eol_s, data_make->main->error.context, data_make->main->error.prefix, data_make->main->error.context); @@ -449,7 +449,7 @@ extern "C" { } } else { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QInvalid characters in the define setting name '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); diff --git a/level_3/fake/c/private-make-operate.c b/level_3/fake/c/private-make-operate.c index 501f3da..9278829 100644 --- a/level_3/fake/c/private-make-operate.c +++ b/level_3/fake/c/private-make-operate.c @@ -1389,7 +1389,7 @@ extern "C" { if (F_status_set_error(*status) == F_interrupt) return 0; if (i == section->objects.used && F_status_is_error_not(*status) && (state_process.operation == fake_make_operation_type_and_e || state_process.operation == fake_make_operation_type_else_e || state_process.operation == fake_make_operation_type_if_e || state_process.operation == fake_make_operation_type_or_e)) { - if (data_make->data->main->error.verbosity != f_console_verbosity_quiet_e && data_make->error.to.stream) { + if (data_make->data->main->error.verbosity > f_console_verbosity_quiet_e && data_make->error.to.stream) { flockfile(data_make->error.to.stream); fl_print_format("%r%[%QIncomplete '%]", data_make->error.to.stream, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); diff --git a/level_3/fake/c/private-make-operate_process_type.c b/level_3/fake/c/private-make-operate_process_type.c index 530ac34..6e90900 100644 --- a/level_3/fake/c/private-make-operate_process_type.c +++ b/level_3/fake/c/private-make-operate_process_type.c @@ -930,7 +930,7 @@ extern "C" { if (F_status_is_error(status)) { state_process->condition_result = fake_condition_result_error_e; - if (data_make->main->error.verbosity != f_console_verbosity_quiet_e && data_make->error.to.stream) { + if (data_make->main->error.verbosity > f_console_verbosity_quiet_e && data_make->error.to.stream) { flockfile(data_make->error.to.stream); if ((i == 1 && number_left > F_number_t_size_unsigned_d) || (i > 1 && number_right > F_number_t_size_unsigned_d)) { diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index 081d209..6ba0249 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -59,7 +59,7 @@ extern "C" { } if (status == F_exist_not) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe group name '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -81,7 +81,7 @@ extern "C" { } if (number > F_type_size_32_unsigned_d) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe number '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -110,7 +110,7 @@ extern "C" { const f_status_t status = f_file_mode_from_string(buffer, data->main->umask, mode, replace); if (F_status_is_error(status)) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_syntax) { flockfile(data->main->error.to.stream); @@ -152,7 +152,7 @@ extern "C" { } if (status == F_exist_not) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe user '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -174,7 +174,7 @@ extern "C" { } if (number > F_type_size_32_unsigned_d) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe number '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); diff --git a/level_3/fake/c/private-print.c b/level_3/fake/c/private-print.c index 6213226..a5c9db8 100644 --- a/level_3/fake/c/private-print.c +++ b/level_3/fake/c/private-print.c @@ -10,7 +10,7 @@ extern "C" { bool fake_print_error_build_operation_file(fake_data_t * const data, const f_status_t status, const char *function, const f_string_static_t operation, const f_string_static_t source, const f_string_static_t destination, const f_string_static_t how, const bool fallback) { if (status == F_file_found_not) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QFailed to find '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -26,7 +26,7 @@ extern "C" { } if (status == F_parameter) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QInvalid parameter when calling '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -44,7 +44,7 @@ extern "C" { } if (status == F_name) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QInvalid name for '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -67,7 +67,7 @@ extern "C" { } if (status == F_memory_not) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QUnable to allocate memory, while trying to %Q '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, operation, data->main->error.context); @@ -83,7 +83,7 @@ extern "C" { } if (status == F_number_overflow) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QOverflow while trying to %Q '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, operation, data->main->error.context); @@ -99,7 +99,7 @@ extern "C" { } if (status == F_directory) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QInvalid directory while trying to %Q '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, operation, data->main->error.context); @@ -115,7 +115,7 @@ extern "C" { } if (status == F_access_denied) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QAccess denied while trying to %Q '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, operation, data->main->error.context); @@ -131,7 +131,7 @@ extern "C" { } if (status == F_loop) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QLoop while trying to %Q '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, operation, data->main->error.context); @@ -147,7 +147,7 @@ extern "C" { } if (status == F_prohibited) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QProhibited by system while trying to %Q '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, operation, data->main->error.context); @@ -163,7 +163,7 @@ extern "C" { } if (status == F_directory_found_not) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QFailed to %Q '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, operation, data->main->error.context); @@ -179,7 +179,7 @@ extern "C" { } if (status == F_failure) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QFailed to %Q '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, operation, data->main->error.context); @@ -194,7 +194,7 @@ extern "C" { return F_false; } - if (fll_error_print(data->main->error, status, function, F_false) == F_known_not && fallback && data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (fll_error_print(data->main->error, status, function, F_false) == F_known_not && fallback && data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[UNKNOWN %Q(%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -235,7 +235,7 @@ extern "C" { bool fake_print_error_fss(fake_data_t * const data, const f_status_t status, const char *function, const f_string_static_t path_file, const f_string_range_t range, const bool fallback) { if (status == F_file_found_not) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QOccurred on invalid UTF-8 character at stop position (at '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -251,7 +251,7 @@ extern "C" { } if (status == F_complete_not_utf || status == F_complete_not_utf_eos || status == F_complete_not_utf_stop) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QOccurred on invalid UTF-8 character at %s (at '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, status == F_complete_not_utf_eos ? "end of string" : "stop point of string", data->main->error.context); @@ -267,7 +267,7 @@ extern "C" { } if (status == F_complete_not_utf_stop) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QOccurred on invalid UTF-8 character at stop point of string (at '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); @@ -282,7 +282,7 @@ extern "C" { return F_false; } - if (fll_error_print(data->main->error, status, function, F_false) == F_known_not && fallback && data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (fll_error_print(data->main->error, status, function, F_false) == F_known_not && fallback && data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[UNKNOWN %Q(%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); diff --git a/level_3/fake/c/private-skeleton.c b/level_3/fake/c/private-skeleton.c index 28d68d2..8ab4e16 100644 --- a/level_3/fake/c/private-skeleton.c +++ b/level_3/fake/c/private-skeleton.c @@ -142,7 +142,7 @@ extern "C" { } if (status == F_false) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { flockfile(data->main->error.to.stream); fl_print_format("%r%[%QThe path '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); diff --git a/level_3/firewall/c/common.c b/level_3/firewall/c/common.c index e921ce9..759827b 100644 --- a/level_3/firewall/c/common.c +++ b/level_3/firewall/c/common.c @@ -186,261 +186,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { firewall_parameter_from_bytesequence_e, firewall_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - firewall_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == firewall_parameter_from_bytesequence_e) { - if (setting->mode & firewall_mode_from_codepoint_e) { - setting->mode -= firewall_mode_from_codepoint_e; - } - - setting->mode |= firewall_mode_from_bytesequence_e; - } - else if (choices.array[choice] == firewall_parameter_from_codepoint_e) { - if (setting->mode & firewall_mode_from_bytesequence_e) { - setting->mode -= firewall_mode_from_bytesequence_e; - } - - setting->mode |= firewall_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { firewall_parameter_to_bytesequence_e, firewall_parameter_to_codepoint_e, firewall_parameter_to_combining_e, firewall_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - firewall_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == firewall_parameter_to_bytesequence_e) { - if (setting->mode & firewall_mode_to_codepoint_e) { - setting->mode -= firewall_mode_to_codepoint_e; - } - - if (setting->mode & firewall_mode_to_combining_e) { - setting->mode -= firewall_mode_to_combining_e; - } - - if (setting->mode & firewall_mode_to_width_e) { - setting->mode -= firewall_mode_to_width_e; - } - - setting->mode |= firewall_mode_to_bytesequence_e; - } - else if (choices.array[choice] == firewall_parameter_to_codepoint_e) { - if (setting->mode & firewall_mode_to_bytesequence_e) { - setting->mode -= firewall_mode_to_bytesequence_e; - } - - if (setting->mode & firewall_mode_to_combining_e) { - setting->mode -= firewall_mode_to_combining_e; - } - - if (setting->mode & firewall_mode_to_width_e) { - setting->mode -= firewall_mode_to_width_e; - } - - setting->mode |= firewall_mode_to_codepoint_e; - } - else if (choices.array[choice] == firewall_parameter_to_combining_e) { - if (setting->mode & firewall_mode_to_bytesequence_e) { - setting->mode -= firewall_mode_to_bytesequence_e; - } - - if (setting->mode & firewall_mode_to_codepoint_e) { - setting->mode -= firewall_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[firewall_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= firewall_mode_to_width_e; - } - - setting->mode |= firewall_mode_to_combining_e; - } - else if (choices.array[choice] == firewall_parameter_to_width_e) { - if (setting->mode & firewall_mode_to_bytesequence_e) { - setting->mode -= firewall_mode_to_bytesequence_e; - } - - if (setting->mode & firewall_mode_to_codepoint_e) { - setting->mode -= firewall_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[firewall_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= firewall_mode_to_combining_e; - } - - setting->mode |= firewall_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[firewall_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[firewall_parameter_to_file_e].values.used > 1) { - firewall_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[firewall_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[firewall_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[firewall_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[firewall_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= firewall_main_flag_file_to_e; - } - else { - firewall_print_error_parameter_file_name_empty(main, setting, main->parameters.array[firewall_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[firewall_parameter_to_file_e].result == f_console_result_found_e) { - firewall_print_error_no_value(main, setting, firewall_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & firewall_main_flag_file_to_e) { - setting->flag -= firewall_main_flag_file_to_e; - } - } - - if (main->parameters.array[firewall_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[firewall_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[firewall_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[firewall_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - firewall_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - firewall_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= firewall_main_flag_file_from_e; - } - else if (main->parameters.array[firewall_parameter_from_file_e].result == f_console_result_found_e) { - firewall_print_error_no_value(main, setting, firewall_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & firewall_main_flag_file_from_e) { - setting->flag -= firewall_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[firewall_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - firewall_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & firewall_mode_to_bytesequence_e)) { - if (main->parameters.array[firewall_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[firewall_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = firewall_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[firewall_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= firewall_main_flag_header_e; - } - - if (main->parameters.array[firewall_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= firewall_main_flag_separate_e; - } - if (main->parameters.array[firewall_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= firewall_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_firewall_setting_load_ diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index ca0f630..63bdd9b 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -203,7 +203,7 @@ extern "C" { if (show_nat) { fll_print_format("%[===========================%] %[NAT%] %[============================%]%r", main->output.to.stream, main->context.set.standout, main->context.set.standout, main->context.set.title, main->context.set.title, main->context.set.standout, main->context.set.standout, f_string_eol_s); - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); status = fll_execute_program(firewall_tool_iptables_s, parameters, 0, 0, (void *) &return_code); @@ -217,12 +217,12 @@ extern "C" { } fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); } if (F_status_is_error_not(status) && show_mangle) { fll_print_format("%[==========================%] %[MANGLE%] %[==========================%]%r", main->output.to.stream, main->context.set.standout, main->context.set.standout, main->context.set.title, main->context.set.title, main->context.set.standout, main->context.set.standout, f_string_eol_s); - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); parameters_array[3] = firewall_show_mangle_s; @@ -238,12 +238,12 @@ extern "C" { } fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); } if (F_status_is_error_not(status) && show_ports) { fll_print_format("%[==========================%] %[FILTER%] %[==========================%]%r", main->output.to.stream, main->context.set.standout, main->context.set.standout, main->context.set.title, main->context.set.title, main->context.set.standout, main->context.set.standout, f_string_eol_s); - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); parameters_array[0] = firewall_show_parameter_exact_s; parameters_array[1] = firewall_show_parameter_verbose_s; @@ -263,7 +263,7 @@ extern "C" { } fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); } if (F_status_is_error(status)) { @@ -291,7 +291,7 @@ extern "C" { if (F_status_is_error(status)) { status = F_status_set_fine(status); - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (status == F_memory_not) { firewall_print_error_on_allocation_failure(main->error); } @@ -392,7 +392,7 @@ extern "C" { return status; } - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QFailed to perform lock request because the lock instructions are missing from: %r.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, path_file_other, main->error.context, f_string_eol_s); } @@ -434,7 +434,7 @@ extern "C" { } } else { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QFailed to perform stop request because the lock instructions are missing from: %r.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, path_file_other, main->error.context, f_string_eol_s); } @@ -683,16 +683,16 @@ extern "C" { firewall_delete_local_data(&local); } else { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QNo command given.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); } status = F_status_set_error(F_parameter); } - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index 0a63bd5..834136d 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -548,7 +548,7 @@ f_status_t firewall_perform_commands(firewall_data_t * const data, firewall_loca if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_parameter) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { firewall_print_error_on_invalid_parameter(data->main->error, "f_file_open"); } } @@ -562,12 +562,12 @@ f_status_t firewall_perform_commands(firewall_data_t * const data, firewall_loca status = F_none; } else if (F_status_set_fine(status) == F_file_open) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QUnable to open the file '%Q'.%]%r", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, path_file, data->main->error.context, f_string_eol_s); } } else if (F_status_set_fine(status) == F_file_descriptor) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QFile descriptor error while trying to open the file '%Q'.%]%r", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, path_file, data->main->error.context, f_string_eol_s); } } @@ -588,7 +588,7 @@ f_status_t firewall_perform_commands(firewall_data_t * const data, firewall_loca f_file_stream_close(&file); if (F_status_is_error(status)) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_parameter) { firewall_print_error_on_invalid_parameter(data->main->error, "f_file_read"); } @@ -1128,7 +1128,7 @@ f_status_t firewall_buffer_rules(firewall_data_t * const data, const f_string_st f_status_t status = f_file_open(filename, 0, &file); if (F_status_is_error(status)) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { if (optional) { if (F_status_set_fine(status) == F_parameter) { firewall_print_error_on_invalid_parameter(data->main->error, "f_file_open"); @@ -1164,7 +1164,7 @@ f_status_t firewall_buffer_rules(firewall_data_t * const data, const f_string_st f_file_stream_close(&file); if (F_status_is_error(status)) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_parameter) { firewall_print_error_on_invalid_parameter(data->main->error, "f_file_read"); } @@ -1204,7 +1204,7 @@ f_status_t firewall_buffer_rules(firewall_data_t * const data, const f_string_st if (F_status_is_error(status)) { status = F_status_set_fine(status); - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + if (data->main->error.verbosity > f_console_verbosity_quiet_e) { if (status == F_parameter) { firewall_print_error_on_invalid_parameter_for_file(data->main->error, "fll_fss_basic_list_read", filename); } diff --git a/level_3/fss_basic_list_read/c/common.c b/level_3/fss_basic_list_read/c/common.c index 63fb628..2afe8bf 100644 --- a/level_3/fss_basic_list_read/c/common.c +++ b/level_3/fss_basic_list_read/c/common.c @@ -144,261 +144,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_basic_list_read_parameter_from_bytesequence_e, fss_basic_list_read_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_basic_list_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_basic_list_read_parameter_from_bytesequence_e) { - if (setting->mode & fss_basic_list_read_mode_from_codepoint_e) { - setting->mode -= fss_basic_list_read_mode_from_codepoint_e; - } - - setting->mode |= fss_basic_list_read_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_basic_list_read_parameter_from_codepoint_e) { - if (setting->mode & fss_basic_list_read_mode_from_bytesequence_e) { - setting->mode -= fss_basic_list_read_mode_from_bytesequence_e; - } - - setting->mode |= fss_basic_list_read_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_basic_list_read_parameter_to_bytesequence_e, fss_basic_list_read_parameter_to_codepoint_e, fss_basic_list_read_parameter_to_combining_e, fss_basic_list_read_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_basic_list_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_basic_list_read_parameter_to_bytesequence_e) { - if (setting->mode & fss_basic_list_read_mode_to_codepoint_e) { - setting->mode -= fss_basic_list_read_mode_to_codepoint_e; - } - - if (setting->mode & fss_basic_list_read_mode_to_combining_e) { - setting->mode -= fss_basic_list_read_mode_to_combining_e; - } - - if (setting->mode & fss_basic_list_read_mode_to_width_e) { - setting->mode -= fss_basic_list_read_mode_to_width_e; - } - - setting->mode |= fss_basic_list_read_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_basic_list_read_parameter_to_codepoint_e) { - if (setting->mode & fss_basic_list_read_mode_to_bytesequence_e) { - setting->mode -= fss_basic_list_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_basic_list_read_mode_to_combining_e) { - setting->mode -= fss_basic_list_read_mode_to_combining_e; - } - - if (setting->mode & fss_basic_list_read_mode_to_width_e) { - setting->mode -= fss_basic_list_read_mode_to_width_e; - } - - setting->mode |= fss_basic_list_read_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_basic_list_read_parameter_to_combining_e) { - if (setting->mode & fss_basic_list_read_mode_to_bytesequence_e) { - setting->mode -= fss_basic_list_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_basic_list_read_mode_to_codepoint_e) { - setting->mode -= fss_basic_list_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_basic_list_read_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_basic_list_read_mode_to_width_e; - } - - setting->mode |= fss_basic_list_read_mode_to_combining_e; - } - else if (choices.array[choice] == fss_basic_list_read_parameter_to_width_e) { - if (setting->mode & fss_basic_list_read_mode_to_bytesequence_e) { - setting->mode -= fss_basic_list_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_basic_list_read_mode_to_codepoint_e) { - setting->mode -= fss_basic_list_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_basic_list_read_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_basic_list_read_mode_to_combining_e; - } - - setting->mode |= fss_basic_list_read_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_basic_list_read_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_basic_list_read_parameter_to_file_e].values.used > 1) { - fss_basic_list_read_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_basic_list_read_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_basic_list_read_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_basic_list_read_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_basic_list_read_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_basic_list_read_main_flag_file_to_e; - } - else { - fss_basic_list_read_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_basic_list_read_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_basic_list_read_parameter_to_file_e].result == f_console_result_found_e) { - fss_basic_list_read_print_error_no_value(main, setting, fss_basic_list_read_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_basic_list_read_main_flag_file_to_e) { - setting->flag -= fss_basic_list_read_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_basic_list_read_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_basic_list_read_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_basic_list_read_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_basic_list_read_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_basic_list_read_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_basic_list_read_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_basic_list_read_main_flag_file_from_e; - } - else if (main->parameters.array[fss_basic_list_read_parameter_from_file_e].result == f_console_result_found_e) { - fss_basic_list_read_print_error_no_value(main, setting, fss_basic_list_read_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_basic_list_read_main_flag_file_from_e) { - setting->flag -= fss_basic_list_read_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_basic_list_read_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_basic_list_read_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_basic_list_read_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_basic_list_read_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_basic_list_read_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_basic_list_read_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_basic_list_read_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_basic_list_read_main_flag_header_e; - } - - if (main->parameters.array[fss_basic_list_read_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_basic_list_read_main_flag_separate_e; - } - if (main->parameters.array[fss_basic_list_read_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_basic_list_read_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_basic_list_read_setting_load_ diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index 1abbed3..dccb6ef 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -117,13 +117,13 @@ extern "C" { for (f_array_length_t i = 0; i < 6; ++i) { if (main->parameters.array[parameter_code[i]].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, parameter_name[i], main->error.notable); fl_print_format("%[' requires a %s.%]%r", main->error.to.stream, main->error.context, parameter_message[i], main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); @@ -160,8 +160,8 @@ extern "C" { for (f_array_length_t i = 0; i < 5; ++i) { if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_basic_list_read_long_columns_s, parameter_name[i]); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_basic_list_read_long_columns_s, parameter_name[i]); } status = F_status_set_error(F_parameter); @@ -173,15 +173,15 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.array[fss_basic_list_read_parameter_pipe_e].result == f_console_result_found_e) { if (main->parameters.array[fss_basic_list_read_parameter_total_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_basic_list_read_long_pipe_s, fss_basic_list_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_basic_list_read_long_pipe_s, fss_basic_list_read_long_total_s); } status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_basic_list_read_parameter_line_e].result == f_console_result_additional_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_basic_list_read_long_pipe_s, fss_basic_list_read_long_line_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_basic_list_read_long_pipe_s, fss_basic_list_read_long_line_s); } status = F_status_set_error(F_parameter); @@ -213,13 +213,13 @@ extern "C" { length = data.argv[index].used; if (!length) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_delimit_s, main->error.notable); fl_print_format("%[' must not be empty.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); @@ -346,13 +346,13 @@ extern "C" { } if (F_status_is_error_not(status) && main->parameters.array[fss_basic_list_read_parameter_select_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_select_s, main->error.notable); fl_print_format("%[' parameter requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -518,9 +518,9 @@ extern "C" { status = F_status_set_error(F_parameter); } - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } diff --git a/level_3/fss_basic_list_read/c/private-read.c b/level_3/fss_basic_list_read/c/private-read.c index 74c0333..a97e18f 100644 --- a/level_3/fss_basic_list_read/c/private-read.c +++ b/level_3/fss_basic_list_read/c/private-read.c @@ -185,8 +185,8 @@ extern "C" { } if (data->depths.array[i].depth == data->depths.array[j].depth) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, data->depths.array[i].depth, main->error.notable); @@ -194,15 +194,15 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_depth_s, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } return F_status_set_error(F_parameter); } if (data->depths.array[i].depth > data->depths.array[j].depth) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_read_long_depth_s, main->error.notable); @@ -212,7 +212,7 @@ extern "C" { fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, data->depths.array[j].depth, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } return F_status_set_error(F_parameter); diff --git a/level_3/fss_basic_list_write/c/common.c b/level_3/fss_basic_list_write/c/common.c index b3b1329..beb3a6f 100644 --- a/level_3/fss_basic_list_write/c/common.c +++ b/level_3/fss_basic_list_write/c/common.c @@ -125,261 +125,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_basic_list_write_parameter_from_bytesequence_e, fss_basic_list_write_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_basic_list_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_basic_list_write_parameter_from_bytesequence_e) { - if (setting->mode & fss_basic_list_write_mode_from_codepoint_e) { - setting->mode -= fss_basic_list_write_mode_from_codepoint_e; - } - - setting->mode |= fss_basic_list_write_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_basic_list_write_parameter_from_codepoint_e) { - if (setting->mode & fss_basic_list_write_mode_from_bytesequence_e) { - setting->mode -= fss_basic_list_write_mode_from_bytesequence_e; - } - - setting->mode |= fss_basic_list_write_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_basic_list_write_parameter_to_bytesequence_e, fss_basic_list_write_parameter_to_codepoint_e, fss_basic_list_write_parameter_to_combining_e, fss_basic_list_write_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_basic_list_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_basic_list_write_parameter_to_bytesequence_e) { - if (setting->mode & fss_basic_list_write_mode_to_codepoint_e) { - setting->mode -= fss_basic_list_write_mode_to_codepoint_e; - } - - if (setting->mode & fss_basic_list_write_mode_to_combining_e) { - setting->mode -= fss_basic_list_write_mode_to_combining_e; - } - - if (setting->mode & fss_basic_list_write_mode_to_width_e) { - setting->mode -= fss_basic_list_write_mode_to_width_e; - } - - setting->mode |= fss_basic_list_write_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_basic_list_write_parameter_to_codepoint_e) { - if (setting->mode & fss_basic_list_write_mode_to_bytesequence_e) { - setting->mode -= fss_basic_list_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_basic_list_write_mode_to_combining_e) { - setting->mode -= fss_basic_list_write_mode_to_combining_e; - } - - if (setting->mode & fss_basic_list_write_mode_to_width_e) { - setting->mode -= fss_basic_list_write_mode_to_width_e; - } - - setting->mode |= fss_basic_list_write_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_basic_list_write_parameter_to_combining_e) { - if (setting->mode & fss_basic_list_write_mode_to_bytesequence_e) { - setting->mode -= fss_basic_list_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_basic_list_write_mode_to_codepoint_e) { - setting->mode -= fss_basic_list_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_basic_list_write_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_basic_list_write_mode_to_width_e; - } - - setting->mode |= fss_basic_list_write_mode_to_combining_e; - } - else if (choices.array[choice] == fss_basic_list_write_parameter_to_width_e) { - if (setting->mode & fss_basic_list_write_mode_to_bytesequence_e) { - setting->mode -= fss_basic_list_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_basic_list_write_mode_to_codepoint_e) { - setting->mode -= fss_basic_list_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_basic_list_write_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_basic_list_write_mode_to_combining_e; - } - - setting->mode |= fss_basic_list_write_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_basic_list_write_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_basic_list_write_parameter_to_file_e].values.used > 1) { - fss_basic_list_write_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_basic_list_write_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_basic_list_write_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_basic_list_write_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_basic_list_write_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_basic_list_write_main_flag_file_to_e; - } - else { - fss_basic_list_write_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_basic_list_write_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_basic_list_write_parameter_to_file_e].result == f_console_result_found_e) { - fss_basic_list_write_print_error_no_value(main, setting, fss_basic_list_write_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_basic_list_write_main_flag_file_to_e) { - setting->flag -= fss_basic_list_write_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_basic_list_write_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_basic_list_write_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_basic_list_write_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_basic_list_write_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_basic_list_write_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_basic_list_write_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_basic_list_write_main_flag_file_from_e; - } - else if (main->parameters.array[fss_basic_list_write_parameter_from_file_e].result == f_console_result_found_e) { - fss_basic_list_write_print_error_no_value(main, setting, fss_basic_list_write_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_basic_list_write_main_flag_file_from_e) { - setting->flag -= fss_basic_list_write_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_basic_list_write_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_basic_list_write_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_basic_list_write_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_basic_list_write_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_basic_list_write_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_basic_list_write_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_basic_list_write_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_basic_list_write_main_flag_header_e; - } - - if (main->parameters.array[fss_basic_list_write_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_basic_list_write_main_flag_separate_e; - } - if (main->parameters.array[fss_basic_list_write_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_basic_list_write_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_basic_list_write_setting_load_ diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.c b/level_3/fss_basic_list_write/c/fss_basic_list_write.c index 311fb52..eeb3b87 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.c @@ -81,14 +81,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_basic_list_write_parameter_file_e].result == f_console_result_additional_e) { if (main->parameters.array[fss_basic_list_write_parameter_file_e].values.used > 1) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_file_s, main->error.notable); fl_print_format("%[' may only be specified once.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -128,8 +128,8 @@ extern "C" { } else if (main->parameters.array[fss_basic_list_write_parameter_content_e].locations.used && main->parameters.array[fss_basic_list_write_parameter_partial_e].locations.used) { if (main->parameters.array[fss_basic_list_write_parameter_content_e].result == f_console_result_additional_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_partial_s, main->error.notable); @@ -139,7 +139,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_content_s, main->error.notable); fl_print_format("%[' parameter, but not both.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -160,8 +160,8 @@ extern "C" { location_sub_content = main->parameters.array[fss_basic_list_write_parameter_content_e].locations_sub.array[i]; if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QEach '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_object_s, main->error.notable); @@ -169,7 +169,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -192,8 +192,8 @@ extern "C" { } } else if (!(main->pipe & fll_program_data_pipe_input_e)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThis requires either piped data or the use of the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_object_s, main->error.notable); @@ -201,7 +201,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -209,14 +209,14 @@ extern "C" { if (F_status_is_error_not(status) && (main->pipe & fll_program_data_pipe_input_e)) { if (main->parameters.array[fss_basic_list_write_parameter_partial_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThis '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_partial_s, main->error.notable); fl_print_format("%[' parameter cannot be used when processing a pipe.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -226,14 +226,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_basic_list_write_parameter_prepend_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_prepend_s, main->error.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -251,14 +251,14 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_false) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_prepend_s, main->error.notable); fl_print_format("%[' must only contain white space.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -268,14 +268,14 @@ extern "C" { } // for } else { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_prepend_s, main->error.notable); fl_print_format("%[' must not be an empty string.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -285,14 +285,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_basic_list_write_parameter_ignore_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_ignore_s, main->error.notable); fl_print_format("%[' was specified, but no values were given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -302,13 +302,13 @@ extern "C" { const f_array_length_t total_arguments = main->parameters.array[fss_basic_list_write_parameter_ignore_e].values.used; if (total_locations * 2 > total_arguments) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_ignore_s, main->error.notable); fl_print_format("%[' requires two values.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -337,13 +337,13 @@ extern "C" { status = fss_basic_list_write_process_pipe(main, output, quoted, &buffer); if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QWhile processing the '%]%[input pipe%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } } @@ -418,16 +418,16 @@ extern "C" { } if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QWhile processing the '%]%[input arguments%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } - else if (main->error.verbosity != f_console_verbosity_quiet_e && main->parameters.array[fss_basic_list_write_parameter_file_e].result == f_console_result_none_e) { + else if (main->error.verbosity > f_console_verbosity_quiet_e && main->parameters.array[fss_basic_list_write_parameter_file_e].result == f_console_result_none_e) { // Ensure there is always a newline at the end, unless in quiet mode. fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); @@ -441,7 +441,7 @@ extern "C" { } // Ensure a newline is always put at the end of the program execution, unless in quiet mode. - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_is_error(status)) { fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); } diff --git a/level_3/fss_basic_list_write/c/private-write.c b/level_3/fss_basic_list_write/c/private-write.c index 4d3d125..bbf3d7b 100644 --- a/level_3/fss_basic_list_write/c/private-write.c +++ b/level_3/fss_basic_list_write/c/private-write.c @@ -11,7 +11,7 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QMust specify the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_object_s, main->error.notable); @@ -21,7 +21,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_list_write_long_partial_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_basic_list_write_error_parameter_same_times_print_ @@ -30,7 +30,7 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe FSS-0002 (Basic List) standard does not support end of line character '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[\\n%]", main->error.to.stream, main->error.notable, main->error.notable); @@ -38,7 +38,7 @@ extern "C" { fl_print_format("%[U+000A%]", main->error.to.stream, main->error.notable, main->error.notable); fl_print_format("%[) in objects.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_basic_list_write_error_parameter_unsupported_eol_print_ @@ -47,13 +47,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, symbol, parameter, main->error.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_basic_list_write_error_parameter_value_missing_print_ @@ -267,7 +267,7 @@ extern "C" { for (; range.start <= range.stop; ++range.start) { if (block.string[range.start] == fss_basic_list_write_pipe_content_start_s.string[0]) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QThe FSS-0002 (Basic List) standard only supports one content per object.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); } diff --git a/level_3/fss_basic_read/c/common.c b/level_3/fss_basic_read/c/common.c index 923d37c..c275f86 100644 --- a/level_3/fss_basic_read/c/common.c +++ b/level_3/fss_basic_read/c/common.c @@ -143,261 +143,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_basic_read_parameter_from_bytesequence_e, fss_basic_read_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_basic_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_basic_read_parameter_from_bytesequence_e) { - if (setting->mode & fss_basic_read_mode_from_codepoint_e) { - setting->mode -= fss_basic_read_mode_from_codepoint_e; - } - - setting->mode |= fss_basic_read_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_basic_read_parameter_from_codepoint_e) { - if (setting->mode & fss_basic_read_mode_from_bytesequence_e) { - setting->mode -= fss_basic_read_mode_from_bytesequence_e; - } - - setting->mode |= fss_basic_read_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_basic_read_parameter_to_bytesequence_e, fss_basic_read_parameter_to_codepoint_e, fss_basic_read_parameter_to_combining_e, fss_basic_read_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_basic_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_basic_read_parameter_to_bytesequence_e) { - if (setting->mode & fss_basic_read_mode_to_codepoint_e) { - setting->mode -= fss_basic_read_mode_to_codepoint_e; - } - - if (setting->mode & fss_basic_read_mode_to_combining_e) { - setting->mode -= fss_basic_read_mode_to_combining_e; - } - - if (setting->mode & fss_basic_read_mode_to_width_e) { - setting->mode -= fss_basic_read_mode_to_width_e; - } - - setting->mode |= fss_basic_read_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_basic_read_parameter_to_codepoint_e) { - if (setting->mode & fss_basic_read_mode_to_bytesequence_e) { - setting->mode -= fss_basic_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_basic_read_mode_to_combining_e) { - setting->mode -= fss_basic_read_mode_to_combining_e; - } - - if (setting->mode & fss_basic_read_mode_to_width_e) { - setting->mode -= fss_basic_read_mode_to_width_e; - } - - setting->mode |= fss_basic_read_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_basic_read_parameter_to_combining_e) { - if (setting->mode & fss_basic_read_mode_to_bytesequence_e) { - setting->mode -= fss_basic_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_basic_read_mode_to_codepoint_e) { - setting->mode -= fss_basic_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_basic_read_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_basic_read_mode_to_width_e; - } - - setting->mode |= fss_basic_read_mode_to_combining_e; - } - else if (choices.array[choice] == fss_basic_read_parameter_to_width_e) { - if (setting->mode & fss_basic_read_mode_to_bytesequence_e) { - setting->mode -= fss_basic_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_basic_read_mode_to_codepoint_e) { - setting->mode -= fss_basic_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_basic_read_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_basic_read_mode_to_combining_e; - } - - setting->mode |= fss_basic_read_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_basic_read_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_basic_read_parameter_to_file_e].values.used > 1) { - fss_basic_read_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_basic_read_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_basic_read_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_basic_read_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_basic_read_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_basic_read_main_flag_file_to_e; - } - else { - fss_basic_read_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_basic_read_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_basic_read_parameter_to_file_e].result == f_console_result_found_e) { - fss_basic_read_print_error_no_value(main, setting, fss_basic_read_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_basic_read_main_flag_file_to_e) { - setting->flag -= fss_basic_read_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_basic_read_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_basic_read_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_basic_read_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_basic_read_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_basic_read_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_basic_read_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_basic_read_main_flag_file_from_e; - } - else if (main->parameters.array[fss_basic_read_parameter_from_file_e].result == f_console_result_found_e) { - fss_basic_read_print_error_no_value(main, setting, fss_basic_read_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_basic_read_main_flag_file_from_e) { - setting->flag -= fss_basic_read_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_basic_read_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_basic_read_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_basic_read_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_basic_read_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_basic_read_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_basic_read_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_basic_read_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_basic_read_main_flag_header_e; - } - - if (main->parameters.array[fss_basic_read_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_basic_read_main_flag_separate_e; - } - if (main->parameters.array[fss_basic_read_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_basic_read_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_basic_read_setting_load_ diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 5aee79c..6726b1b 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -117,13 +117,13 @@ extern "C" { for (f_array_length_t i = 0; i < 6; ++i) { if (main->parameters.array[parameter_code[i]].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, parameter_name[i], main->error.notable); fl_print_format("%[' requires a %s.%]%r", main->error.to.stream, main->error.context, parameter_message[i], main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); @@ -160,8 +160,8 @@ extern "C" { for (f_array_length_t i = 0; i < 5; ++i) { if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_basic_read_long_columns_s, parameter_name[i]); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_basic_read_long_columns_s, parameter_name[i]); } status = F_status_set_error(F_parameter); @@ -173,15 +173,15 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.array[fss_basic_read_parameter_pipe_e].result == f_console_result_found_e) { if (main->parameters.array[fss_basic_read_parameter_total_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_basic_read_long_pipe_s, fss_basic_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_basic_read_long_pipe_s, fss_basic_read_long_total_s); } status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_basic_read_parameter_line_e].result == f_console_result_additional_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_basic_read_long_pipe_s, fss_basic_read_long_line_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_basic_read_long_pipe_s, fss_basic_read_long_line_s); } status = F_status_set_error(F_parameter); @@ -213,13 +213,13 @@ extern "C" { length = data.argv[index].used; if (!length) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_read_long_delimit_s, main->error.notable); fl_print_format("%[' must not be empty.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); @@ -346,13 +346,13 @@ extern "C" { } if (F_status_is_error_not(status) && main->parameters.array[fss_basic_read_parameter_select_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_read_long_select_s, main->error.notable); fl_print_format("%[' parameter requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); fss_basic_read_depths_resize(0, &data.depths); @@ -523,9 +523,9 @@ extern "C" { status = F_status_set_error(F_parameter); } - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } diff --git a/level_3/fss_basic_read/c/private-read.c b/level_3/fss_basic_read/c/private-read.c index 657a5d4..f3fd7fe 100644 --- a/level_3/fss_basic_read/c/private-read.c +++ b/level_3/fss_basic_read/c/private-read.c @@ -162,8 +162,8 @@ extern "C" { } if (data->depths.array[i].depth == data->depths.array[j].depth) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, data->depths.array[i].depth, main->error.notable); @@ -171,15 +171,15 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_read_long_depth_s, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } return F_status_set_error(F_parameter); } if (data->depths.array[i].depth > data->depths.array[j].depth) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_read_long_depth_s, main->error.notable); @@ -189,7 +189,7 @@ extern "C" { fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, data->depths.array[j].depth, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } return F_status_set_error(F_parameter); diff --git a/level_3/fss_basic_write/c/common.c b/level_3/fss_basic_write/c/common.c index 4e4edf1..2a5fef9 100644 --- a/level_3/fss_basic_write/c/common.c +++ b/level_3/fss_basic_write/c/common.c @@ -125,261 +125,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_basic_write_parameter_from_bytesequence_e, fss_basic_write_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_basic_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_basic_write_parameter_from_bytesequence_e) { - if (setting->mode & fss_basic_write_mode_from_codepoint_e) { - setting->mode -= fss_basic_write_mode_from_codepoint_e; - } - - setting->mode |= fss_basic_write_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_basic_write_parameter_from_codepoint_e) { - if (setting->mode & fss_basic_write_mode_from_bytesequence_e) { - setting->mode -= fss_basic_write_mode_from_bytesequence_e; - } - - setting->mode |= fss_basic_write_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_basic_write_parameter_to_bytesequence_e, fss_basic_write_parameter_to_codepoint_e, fss_basic_write_parameter_to_combining_e, fss_basic_write_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_basic_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_basic_write_parameter_to_bytesequence_e) { - if (setting->mode & fss_basic_write_mode_to_codepoint_e) { - setting->mode -= fss_basic_write_mode_to_codepoint_e; - } - - if (setting->mode & fss_basic_write_mode_to_combining_e) { - setting->mode -= fss_basic_write_mode_to_combining_e; - } - - if (setting->mode & fss_basic_write_mode_to_width_e) { - setting->mode -= fss_basic_write_mode_to_width_e; - } - - setting->mode |= fss_basic_write_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_basic_write_parameter_to_codepoint_e) { - if (setting->mode & fss_basic_write_mode_to_bytesequence_e) { - setting->mode -= fss_basic_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_basic_write_mode_to_combining_e) { - setting->mode -= fss_basic_write_mode_to_combining_e; - } - - if (setting->mode & fss_basic_write_mode_to_width_e) { - setting->mode -= fss_basic_write_mode_to_width_e; - } - - setting->mode |= fss_basic_write_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_basic_write_parameter_to_combining_e) { - if (setting->mode & fss_basic_write_mode_to_bytesequence_e) { - setting->mode -= fss_basic_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_basic_write_mode_to_codepoint_e) { - setting->mode -= fss_basic_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_basic_write_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_basic_write_mode_to_width_e; - } - - setting->mode |= fss_basic_write_mode_to_combining_e; - } - else if (choices.array[choice] == fss_basic_write_parameter_to_width_e) { - if (setting->mode & fss_basic_write_mode_to_bytesequence_e) { - setting->mode -= fss_basic_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_basic_write_mode_to_codepoint_e) { - setting->mode -= fss_basic_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_basic_write_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_basic_write_mode_to_combining_e; - } - - setting->mode |= fss_basic_write_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_basic_write_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_basic_write_parameter_to_file_e].values.used > 1) { - fss_basic_write_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_basic_write_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_basic_write_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_basic_write_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_basic_write_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_basic_write_main_flag_file_to_e; - } - else { - fss_basic_write_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_basic_write_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_basic_write_parameter_to_file_e].result == f_console_result_found_e) { - fss_basic_write_print_error_no_value(main, setting, fss_basic_write_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_basic_write_main_flag_file_to_e) { - setting->flag -= fss_basic_write_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_basic_write_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_basic_write_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_basic_write_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_basic_write_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_basic_write_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_basic_write_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_basic_write_main_flag_file_from_e; - } - else if (main->parameters.array[fss_basic_write_parameter_from_file_e].result == f_console_result_found_e) { - fss_basic_write_print_error_no_value(main, setting, fss_basic_write_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_basic_write_main_flag_file_from_e) { - setting->flag -= fss_basic_write_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_basic_write_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_basic_write_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_basic_write_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_basic_write_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_basic_write_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_basic_write_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_basic_write_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_basic_write_main_flag_header_e; - } - - if (main->parameters.array[fss_basic_write_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_basic_write_main_flag_separate_e; - } - if (main->parameters.array[fss_basic_write_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_basic_write_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_basic_write_setting_load_ diff --git a/level_3/fss_basic_write/c/fss_basic_write.c b/level_3/fss_basic_write/c/fss_basic_write.c index b375bb6..e3cfc5b 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -79,14 +79,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_basic_write_parameter_file_e].result == f_console_result_additional_e) { if (main->parameters.array[fss_basic_write_parameter_file_e].values.used > 1) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_file_s, main->error.notable); fl_print_format("%[' may only be specified once.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -126,8 +126,8 @@ extern "C" { } else if (main->parameters.array[fss_basic_write_parameter_content_e].locations.used && main->parameters.array[fss_basic_write_parameter_partial_e].locations.used) { if (main->parameters.array[fss_basic_write_parameter_content_e].result == f_console_result_additional_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_partial_s, main->error.notable); @@ -137,7 +137,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_content_s, main->error.notable); fl_print_format("%[' parameter, but not both.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -158,8 +158,8 @@ extern "C" { location_sub_content = main->parameters.array[fss_basic_write_parameter_content_e].locations_sub.array[i]; if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QEach '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_object_s, main->error.notable); @@ -167,7 +167,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -190,8 +190,8 @@ extern "C" { } } else if (!(main->pipe & fll_program_data_pipe_input_e)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThis requires either piped data or the use of the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_object_s, main->error.notable); @@ -199,7 +199,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -207,14 +207,14 @@ extern "C" { if (F_status_is_error_not(status) && (main->pipe & fll_program_data_pipe_input_e)) { if (main->parameters.array[fss_basic_write_parameter_partial_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThis '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_partial_s, main->error.notable); fl_print_format("%[' parameter cannot be used when processing a pipe.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -224,14 +224,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_basic_write_parameter_prepend_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_prepend_s, main->error.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -250,14 +250,14 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_false) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_prepend_s, main->error.notable); fl_print_format("%[' must only contain white space.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -267,14 +267,14 @@ extern "C" { } // for } else { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_prepend_s, main->error.notable); fl_print_format("%[' must not be an empty string.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -284,14 +284,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_basic_write_parameter_ignore_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_ignore_s, main->error.notable); fl_print_format("%[' was specified, but no values were given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -301,13 +301,13 @@ extern "C" { const f_array_length_t total_arguments = main->parameters.array[fss_basic_write_parameter_ignore_e].values.used; if (total_locations * 2 > total_arguments) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_ignore_s, main->error.notable); fl_print_format("%[' requires two values.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -336,13 +336,13 @@ extern "C" { status = fss_basic_write_process_pipe(main, output, quote, &buffer); if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QWhile processing the '%]%[input pipe%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } } @@ -409,16 +409,16 @@ extern "C" { } if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QWhile processing the '%]%[input arguments%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } - else if (main->error.verbosity != f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e && main->parameters.array[fss_basic_write_parameter_file_e].result == f_console_result_none_e) { + else if (main->error.verbosity > f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e && main->parameters.array[fss_basic_write_parameter_file_e].result == f_console_result_none_e) { // Ensure there is always a newline at the end, unless in quiet mode. fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); @@ -432,7 +432,7 @@ extern "C" { } // Ensure a newline is always put at the end of the program execution, unless in quiet mode. - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_is_error(status)) { fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); } diff --git a/level_3/fss_basic_write/c/private-write.c b/level_3/fss_basic_write/c/private-write.c index d86cd5f..2356ce3 100644 --- a/level_3/fss_basic_write/c/private-write.c +++ b/level_3/fss_basic_write/c/private-write.c @@ -11,7 +11,7 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QMust specify the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_object_s, main->error.notable); @@ -21,7 +21,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_basic_write_long_partial_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_basic_write_error_parameter_same_times_print_ @@ -30,13 +30,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, symbol, parameter, main->error.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_basic_write_error_parameter_value_missing_print_ @@ -45,7 +45,7 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe FSS-0000 (Basic) standard does not support end of line character '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[\\n%]", main->error.to.stream, main->error.notable, main->error.notable); @@ -53,7 +53,7 @@ extern "C" { fl_print_format("%[U+000A%]", main->error.to.stream, main->error.notable, main->error.notable); fl_print_format("%[) in objects.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_basic_write_error_parameter_unsupported_eol_print_ @@ -269,7 +269,7 @@ extern "C" { for (; range.start <= range.stop; ++range.start) { if (block.string[range.start] == fss_basic_write_pipe_content_start_s.string[0]) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QThe FSS-0000 (Basic) standard only supports one content per object.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); } diff --git a/level_3/fss_embedded_list_read/c/common.c b/level_3/fss_embedded_list_read/c/common.c index 98a5025..f7353da 100644 --- a/level_3/fss_embedded_list_read/c/common.c +++ b/level_3/fss_embedded_list_read/c/common.c @@ -142,261 +142,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_embedded_list_read_parameter_from_bytesequence_e, fss_embedded_list_read_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_embedded_list_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_embedded_list_read_parameter_from_bytesequence_e) { - if (setting->mode & fss_embedded_list_read_mode_from_codepoint_e) { - setting->mode -= fss_embedded_list_read_mode_from_codepoint_e; - } - - setting->mode |= fss_embedded_list_read_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_embedded_list_read_parameter_from_codepoint_e) { - if (setting->mode & fss_embedded_list_read_mode_from_bytesequence_e) { - setting->mode -= fss_embedded_list_read_mode_from_bytesequence_e; - } - - setting->mode |= fss_embedded_list_read_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_embedded_list_read_parameter_to_bytesequence_e, fss_embedded_list_read_parameter_to_codepoint_e, fss_embedded_list_read_parameter_to_combining_e, fss_embedded_list_read_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_embedded_list_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_embedded_list_read_parameter_to_bytesequence_e) { - if (setting->mode & fss_embedded_list_read_mode_to_codepoint_e) { - setting->mode -= fss_embedded_list_read_mode_to_codepoint_e; - } - - if (setting->mode & fss_embedded_list_read_mode_to_combining_e) { - setting->mode -= fss_embedded_list_read_mode_to_combining_e; - } - - if (setting->mode & fss_embedded_list_read_mode_to_width_e) { - setting->mode -= fss_embedded_list_read_mode_to_width_e; - } - - setting->mode |= fss_embedded_list_read_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_embedded_list_read_parameter_to_codepoint_e) { - if (setting->mode & fss_embedded_list_read_mode_to_bytesequence_e) { - setting->mode -= fss_embedded_list_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_embedded_list_read_mode_to_combining_e) { - setting->mode -= fss_embedded_list_read_mode_to_combining_e; - } - - if (setting->mode & fss_embedded_list_read_mode_to_width_e) { - setting->mode -= fss_embedded_list_read_mode_to_width_e; - } - - setting->mode |= fss_embedded_list_read_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_embedded_list_read_parameter_to_combining_e) { - if (setting->mode & fss_embedded_list_read_mode_to_bytesequence_e) { - setting->mode -= fss_embedded_list_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_embedded_list_read_mode_to_codepoint_e) { - setting->mode -= fss_embedded_list_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_embedded_list_read_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_embedded_list_read_mode_to_width_e; - } - - setting->mode |= fss_embedded_list_read_mode_to_combining_e; - } - else if (choices.array[choice] == fss_embedded_list_read_parameter_to_width_e) { - if (setting->mode & fss_embedded_list_read_mode_to_bytesequence_e) { - setting->mode -= fss_embedded_list_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_embedded_list_read_mode_to_codepoint_e) { - setting->mode -= fss_embedded_list_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_embedded_list_read_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_embedded_list_read_mode_to_combining_e; - } - - setting->mode |= fss_embedded_list_read_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_embedded_list_read_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_embedded_list_read_parameter_to_file_e].values.used > 1) { - fss_embedded_list_read_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_embedded_list_read_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_embedded_list_read_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_embedded_list_read_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_embedded_list_read_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_embedded_list_read_main_flag_file_to_e; - } - else { - fss_embedded_list_read_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_embedded_list_read_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_embedded_list_read_parameter_to_file_e].result == f_console_result_found_e) { - fss_embedded_list_read_print_error_no_value(main, setting, fss_embedded_list_read_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_embedded_list_read_main_flag_file_to_e) { - setting->flag -= fss_embedded_list_read_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_embedded_list_read_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_embedded_list_read_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_embedded_list_read_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_embedded_list_read_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_embedded_list_read_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_embedded_list_read_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_embedded_list_read_main_flag_file_from_e; - } - else if (main->parameters.array[fss_embedded_list_read_parameter_from_file_e].result == f_console_result_found_e) { - fss_embedded_list_read_print_error_no_value(main, setting, fss_embedded_list_read_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_embedded_list_read_main_flag_file_from_e) { - setting->flag -= fss_embedded_list_read_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_embedded_list_read_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_embedded_list_read_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_embedded_list_read_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_embedded_list_read_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_embedded_list_read_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_embedded_list_read_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_embedded_list_read_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_embedded_list_read_main_flag_header_e; - } - - if (main->parameters.array[fss_embedded_list_read_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_embedded_list_read_main_flag_separate_e; - } - if (main->parameters.array[fss_embedded_list_read_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_embedded_list_read_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_embedded_list_read_setting_load_ diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c index e8d4762..c5e8211 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c @@ -79,8 +79,8 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { if (main->parameters.array[fss_embedded_list_read_parameter_columns_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_embedded_list_read_long_columns_s, fss_embedded_list_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_embedded_list_read_long_columns_s, fss_embedded_list_read_long_total_s); } status = F_status_set_error(F_parameter); @@ -89,69 +89,69 @@ extern "C" { if (main->parameters.remaining.used > 0 || (main->pipe & fll_program_data_pipe_input_e)) { if (main->parameters.array[fss_embedded_list_read_parameter_at_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_read_long_at_s, main->error.notable); fl_print_format("%[' requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } if (F_status_is_error_not(status) && main->parameters.array[fss_embedded_list_read_parameter_depth_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_read_long_depth_s, main->error.notable); fl_print_format("%[' requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } if (F_status_is_error_not(status) && main->parameters.array[fss_embedded_list_read_parameter_line_e].result == f_console_result_additional_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_read_long_line_s, main->error.notable); fl_print_format("%[' requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } if (F_status_is_error_not(status) && main->parameters.array[fss_embedded_list_read_parameter_name_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_read_long_name_s, main->error.notable); fl_print_format("%[' requires a string.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } if (F_status_is_error_not(status) && main->parameters.array[fss_embedded_list_read_parameter_select_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_read_long_select_s, main->error.notable); fl_print_format("%[' requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } if (main->parameters.array[fss_embedded_list_read_parameter_line_e].result == f_console_result_additional_e) { if (F_status_is_error_not(status) && main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_embedded_list_read_long_line_s, fss_embedded_list_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_embedded_list_read_long_line_s, fss_embedded_list_read_long_total_s); } status = F_status_set_error(F_parameter); @@ -160,8 +160,8 @@ extern "C" { if (main->parameters.array[fss_embedded_list_read_parameter_pipe_e].result == f_console_result_found_e) { if (F_status_is_error_not(status) && main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_embedded_list_read_long_pipe_s, fss_embedded_list_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_embedded_list_read_long_pipe_s, fss_embedded_list_read_long_total_s); } status = F_status_set_error(F_parameter); @@ -170,13 +170,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_embedded_list_read_parameter_delimit_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_read_long_delimit_s, main->error.notable); fl_print_format("%[' requires a value.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -185,13 +185,13 @@ extern "C" { f_array_length_t length = data.argv[index].used; if (!length) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_read_long_delimit_s, main->error.notable); fl_print_format("%[' must not be empty.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -248,13 +248,13 @@ extern "C" { } if (F_status_is_error_not(status) && main->parameters.array[fss_embedded_list_read_parameter_select_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_read_long_select_s, main->error.notable); fl_print_format("%[' parameter requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -415,9 +415,9 @@ extern "C" { status = F_status_set_error(F_parameter); } - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } diff --git a/level_3/fss_embedded_list_write/c/common.c b/level_3/fss_embedded_list_write/c/common.c index a31b4b7..11bfc9e 100644 --- a/level_3/fss_embedded_list_write/c/common.c +++ b/level_3/fss_embedded_list_write/c/common.c @@ -125,261 +125,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_embedded_list_write_parameter_from_bytesequence_e, fss_embedded_list_write_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_embedded_list_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_embedded_list_write_parameter_from_bytesequence_e) { - if (setting->mode & fss_embedded_list_write_mode_from_codepoint_e) { - setting->mode -= fss_embedded_list_write_mode_from_codepoint_e; - } - - setting->mode |= fss_embedded_list_write_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_embedded_list_write_parameter_from_codepoint_e) { - if (setting->mode & fss_embedded_list_write_mode_from_bytesequence_e) { - setting->mode -= fss_embedded_list_write_mode_from_bytesequence_e; - } - - setting->mode |= fss_embedded_list_write_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_embedded_list_write_parameter_to_bytesequence_e, fss_embedded_list_write_parameter_to_codepoint_e, fss_embedded_list_write_parameter_to_combining_e, fss_embedded_list_write_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_embedded_list_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_embedded_list_write_parameter_to_bytesequence_e) { - if (setting->mode & fss_embedded_list_write_mode_to_codepoint_e) { - setting->mode -= fss_embedded_list_write_mode_to_codepoint_e; - } - - if (setting->mode & fss_embedded_list_write_mode_to_combining_e) { - setting->mode -= fss_embedded_list_write_mode_to_combining_e; - } - - if (setting->mode & fss_embedded_list_write_mode_to_width_e) { - setting->mode -= fss_embedded_list_write_mode_to_width_e; - } - - setting->mode |= fss_embedded_list_write_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_embedded_list_write_parameter_to_codepoint_e) { - if (setting->mode & fss_embedded_list_write_mode_to_bytesequence_e) { - setting->mode -= fss_embedded_list_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_embedded_list_write_mode_to_combining_e) { - setting->mode -= fss_embedded_list_write_mode_to_combining_e; - } - - if (setting->mode & fss_embedded_list_write_mode_to_width_e) { - setting->mode -= fss_embedded_list_write_mode_to_width_e; - } - - setting->mode |= fss_embedded_list_write_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_embedded_list_write_parameter_to_combining_e) { - if (setting->mode & fss_embedded_list_write_mode_to_bytesequence_e) { - setting->mode -= fss_embedded_list_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_embedded_list_write_mode_to_codepoint_e) { - setting->mode -= fss_embedded_list_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_embedded_list_write_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_embedded_list_write_mode_to_width_e; - } - - setting->mode |= fss_embedded_list_write_mode_to_combining_e; - } - else if (choices.array[choice] == fss_embedded_list_write_parameter_to_width_e) { - if (setting->mode & fss_embedded_list_write_mode_to_bytesequence_e) { - setting->mode -= fss_embedded_list_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_embedded_list_write_mode_to_codepoint_e) { - setting->mode -= fss_embedded_list_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_embedded_list_write_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_embedded_list_write_mode_to_combining_e; - } - - setting->mode |= fss_embedded_list_write_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_embedded_list_write_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_embedded_list_write_parameter_to_file_e].values.used > 1) { - fss_embedded_list_write_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_embedded_list_write_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_embedded_list_write_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_embedded_list_write_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_embedded_list_write_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_embedded_list_write_main_flag_file_to_e; - } - else { - fss_embedded_list_write_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_embedded_list_write_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_embedded_list_write_parameter_to_file_e].result == f_console_result_found_e) { - fss_embedded_list_write_print_error_no_value(main, setting, fss_embedded_list_write_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_embedded_list_write_main_flag_file_to_e) { - setting->flag -= fss_embedded_list_write_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_embedded_list_write_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_embedded_list_write_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_embedded_list_write_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_embedded_list_write_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_embedded_list_write_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_embedded_list_write_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_embedded_list_write_main_flag_file_from_e; - } - else if (main->parameters.array[fss_embedded_list_write_parameter_from_file_e].result == f_console_result_found_e) { - fss_embedded_list_write_print_error_no_value(main, setting, fss_embedded_list_write_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_embedded_list_write_main_flag_file_from_e) { - setting->flag -= fss_embedded_list_write_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_embedded_list_write_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_embedded_list_write_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_embedded_list_write_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_embedded_list_write_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_embedded_list_write_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_embedded_list_write_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_embedded_list_write_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_embedded_list_write_main_flag_header_e; - } - - if (main->parameters.array[fss_embedded_list_write_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_embedded_list_write_main_flag_separate_e; - } - if (main->parameters.array[fss_embedded_list_write_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_embedded_list_write_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_embedded_list_write_setting_load_ diff --git a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c index a5bd532..5424528 100644 --- a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c +++ b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c @@ -79,14 +79,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_embedded_list_write_parameter_file_e].result == f_console_result_additional_e) { if (main->parameters.array[fss_embedded_list_write_parameter_file_e].values.used > 1) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_file_s, main->error.notable); fl_print_format("%[' may only be specified once.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -126,8 +126,8 @@ extern "C" { } else if (main->parameters.array[fss_embedded_list_write_parameter_content_e].locations.used && main->parameters.array[fss_embedded_list_write_parameter_partial_e].locations.used) { if (main->parameters.array[fss_embedded_list_write_parameter_content_e].result == f_console_result_additional_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_partial_s, main->error.notable); @@ -137,7 +137,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_content_s, main->error.notable); fl_print_format("%[' parameter, but not both.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -158,8 +158,8 @@ extern "C" { location_sub_content = main->parameters.array[fss_embedded_list_write_parameter_content_e].locations_sub.array[i]; if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QEach '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_object_s, main->error.notable); @@ -167,7 +167,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -190,8 +190,8 @@ extern "C" { } } else if (!(main->pipe & fll_program_data_pipe_input_e)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThis requires either piped data or the use of the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_object_s, main->error.notable); @@ -199,7 +199,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -207,14 +207,14 @@ extern "C" { if (F_status_is_error_not(status) && (main->pipe & fll_program_data_pipe_input_e)) { if (main->parameters.array[fss_embedded_list_write_parameter_partial_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThis '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_partial_s, main->error.notable); fl_print_format("%[' parameter cannot be used when processing a pipe.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -224,14 +224,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_embedded_list_write_parameter_prepend_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_prepend_s, main->error.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -249,14 +249,14 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_false) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_prepend_s, main->error.notable); fl_print_format("%[' must only contain white space.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -266,14 +266,14 @@ extern "C" { } // for } else { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_prepend_s, main->error.notable); fl_print_format("%[' must not be an empty string.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -283,14 +283,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_embedded_list_write_parameter_ignore_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_ignore_s, main->error.notable); fl_print_format("%[' was specified, but no values were given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -300,13 +300,13 @@ extern "C" { const f_array_length_t total_arguments = main->parameters.array[fss_embedded_list_write_parameter_ignore_e].values.used; if (total_locations * 2 > total_arguments) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_ignore_s, main->error.notable); fl_print_format("%[' requires two values.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -337,13 +337,13 @@ extern "C" { status = fss_embedded_list_write_process_pipe(main, output, quote, &buffer, &ignore); if (F_status_is_error(status) && F_status_set_fine(status) != F_interrupt) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QWhile processing the '%]%[input pipe%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } @@ -419,16 +419,16 @@ extern "C" { } if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QWhile processing the '%]%[input arguments%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } - else if (main->error.verbosity != f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e && main->parameters.array[fss_embedded_list_write_parameter_file_e].result == f_console_result_none_e) { + else if (main->error.verbosity > f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e && main->parameters.array[fss_embedded_list_write_parameter_file_e].result == f_console_result_none_e) { // Ensure there is always a newline at the end, unless in quiet mode. fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); @@ -444,7 +444,7 @@ extern "C" { } // Ensure a newline is always put at the end of the program execution, unless in quiet mode. - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_is_error(status)) { fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); } diff --git a/level_3/fss_embedded_list_write/c/private-write.c b/level_3/fss_embedded_list_write/c/private-write.c index 3654add..33bb70a 100644 --- a/level_3/fss_embedded_list_write/c/private-write.c +++ b/level_3/fss_embedded_list_write/c/private-write.c @@ -13,7 +13,7 @@ extern "C" { return; } - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QMust specify the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_object_s, main->error.notable); @@ -23,7 +23,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_embedded_list_write_long_partial_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_embedded_list_write_error_parameter_same_times_print_ @@ -34,7 +34,7 @@ extern "C" { return; } - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe FSS-0008 (Embedded List) standard does not support end of line character '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[\\n%]", main->error.to.stream, main->error.notable, main->error.notable); @@ -42,7 +42,7 @@ extern "C" { fl_print_format("%[U+000A%]", main->error.to.stream, main->error.notable, main->error.notable); fl_print_format("%[) in objects.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_embedded_list_write_error_parameter_unsupported_eol_print_ @@ -53,13 +53,13 @@ extern "C" { return; } - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, symbol, parameter, main->error.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_embedded_list_write_error_parameter_value_missing_print_ @@ -279,7 +279,7 @@ extern "C" { for (; range.start <= range.stop; ++range.start) { if (block.string[range.start] == fss_embedded_list_write_pipe_content_start_s.string[0]) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QThe FSS-0008 (Embedded List) standard only supports one content per object.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); } diff --git a/level_3/fss_extended_list_read/c/common.c b/level_3/fss_extended_list_read/c/common.c index 1726e8f..727047c 100644 --- a/level_3/fss_extended_list_read/c/common.c +++ b/level_3/fss_extended_list_read/c/common.c @@ -150,261 +150,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_extended_list_read_parameter_from_bytesequence_e, fss_extended_list_read_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_extended_list_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_extended_list_read_parameter_from_bytesequence_e) { - if (setting->mode & fss_extended_list_read_mode_from_codepoint_e) { - setting->mode -= fss_extended_list_read_mode_from_codepoint_e; - } - - setting->mode |= fss_extended_list_read_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_extended_list_read_parameter_from_codepoint_e) { - if (setting->mode & fss_extended_list_read_mode_from_bytesequence_e) { - setting->mode -= fss_extended_list_read_mode_from_bytesequence_e; - } - - setting->mode |= fss_extended_list_read_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_extended_list_read_parameter_to_bytesequence_e, fss_extended_list_read_parameter_to_codepoint_e, fss_extended_list_read_parameter_to_combining_e, fss_extended_list_read_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_extended_list_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_extended_list_read_parameter_to_bytesequence_e) { - if (setting->mode & fss_extended_list_read_mode_to_codepoint_e) { - setting->mode -= fss_extended_list_read_mode_to_codepoint_e; - } - - if (setting->mode & fss_extended_list_read_mode_to_combining_e) { - setting->mode -= fss_extended_list_read_mode_to_combining_e; - } - - if (setting->mode & fss_extended_list_read_mode_to_width_e) { - setting->mode -= fss_extended_list_read_mode_to_width_e; - } - - setting->mode |= fss_extended_list_read_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_extended_list_read_parameter_to_codepoint_e) { - if (setting->mode & fss_extended_list_read_mode_to_bytesequence_e) { - setting->mode -= fss_extended_list_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_extended_list_read_mode_to_combining_e) { - setting->mode -= fss_extended_list_read_mode_to_combining_e; - } - - if (setting->mode & fss_extended_list_read_mode_to_width_e) { - setting->mode -= fss_extended_list_read_mode_to_width_e; - } - - setting->mode |= fss_extended_list_read_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_extended_list_read_parameter_to_combining_e) { - if (setting->mode & fss_extended_list_read_mode_to_bytesequence_e) { - setting->mode -= fss_extended_list_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_extended_list_read_mode_to_codepoint_e) { - setting->mode -= fss_extended_list_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_extended_list_read_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_extended_list_read_mode_to_width_e; - } - - setting->mode |= fss_extended_list_read_mode_to_combining_e; - } - else if (choices.array[choice] == fss_extended_list_read_parameter_to_width_e) { - if (setting->mode & fss_extended_list_read_mode_to_bytesequence_e) { - setting->mode -= fss_extended_list_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_extended_list_read_mode_to_codepoint_e) { - setting->mode -= fss_extended_list_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_extended_list_read_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_extended_list_read_mode_to_combining_e; - } - - setting->mode |= fss_extended_list_read_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_extended_list_read_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_extended_list_read_parameter_to_file_e].values.used > 1) { - fss_extended_list_read_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_extended_list_read_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_extended_list_read_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_extended_list_read_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_extended_list_read_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_extended_list_read_main_flag_file_to_e; - } - else { - fss_extended_list_read_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_extended_list_read_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_extended_list_read_parameter_to_file_e].result == f_console_result_found_e) { - fss_extended_list_read_print_error_no_value(main, setting, fss_extended_list_read_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_extended_list_read_main_flag_file_to_e) { - setting->flag -= fss_extended_list_read_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_extended_list_read_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_extended_list_read_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_extended_list_read_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_extended_list_read_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_extended_list_read_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_extended_list_read_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_extended_list_read_main_flag_file_from_e; - } - else if (main->parameters.array[fss_extended_list_read_parameter_from_file_e].result == f_console_result_found_e) { - fss_extended_list_read_print_error_no_value(main, setting, fss_extended_list_read_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_extended_list_read_main_flag_file_from_e) { - setting->flag -= fss_extended_list_read_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_extended_list_read_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_extended_list_read_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_extended_list_read_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_extended_list_read_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_extended_list_read_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_extended_list_read_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_extended_list_read_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_extended_list_read_main_flag_header_e; - } - - if (main->parameters.array[fss_extended_list_read_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_extended_list_read_main_flag_separate_e; - } - if (main->parameters.array[fss_extended_list_read_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_extended_list_read_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_extended_list_read_setting_load_ diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index 218d78c..df2e21e 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -117,13 +117,13 @@ extern "C" { for (f_array_length_t i = 0; i < 6; ++i) { if (main->parameters.array[parameter_code[i]].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, parameter_name[i], main->error.notable); fl_print_format("%[' requires a %s.%]%r", main->error.to.stream, main->error.context, parameter_message[i], main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); @@ -160,8 +160,8 @@ extern "C" { for (f_array_length_t i = 0; i < 5; ++i) { if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_extended_list_read_long_columns_s, parameter_name[i]); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_extended_list_read_long_columns_s, parameter_name[i]); } status = F_status_set_error(F_parameter); @@ -173,15 +173,15 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.array[fss_extended_list_read_parameter_pipe_e].result == f_console_result_found_e) { if (main->parameters.array[fss_extended_list_read_parameter_total_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_extended_list_read_long_pipe_s, fss_extended_list_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_extended_list_read_long_pipe_s, fss_extended_list_read_long_total_s); } status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_extended_list_read_parameter_line_e].result == f_console_result_additional_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_extended_list_read_long_pipe_s, fss_extended_list_read_long_line_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_extended_list_read_long_pipe_s, fss_extended_list_read_long_line_s); } status = F_status_set_error(F_parameter); @@ -213,13 +213,13 @@ extern "C" { length = data.argv[index].used; if (!length) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_read_long_delimit_s, main->error.notable); fl_print_format("%[' must not be empty.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); @@ -346,13 +346,13 @@ extern "C" { } if (F_status_is_error_not(status) && main->parameters.array[fss_extended_list_read_parameter_select_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_read_long_select_s, main->error.notable); fl_print_format("%[' parameter requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); fss_extended_list_read_depths_resize(0, &data.depths); @@ -523,9 +523,9 @@ extern "C" { status = F_status_set_error(F_parameter); } - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } diff --git a/level_3/fss_extended_list_read/c/private-read.c b/level_3/fss_extended_list_read/c/private-read.c index 3494f4b..fc32736 100644 --- a/level_3/fss_extended_list_read/c/private-read.c +++ b/level_3/fss_extended_list_read/c/private-read.c @@ -185,8 +185,8 @@ extern "C" { } if (data->depths.array[i].depth == data->depths.array[j].depth) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, data->depths.array[i].depth, main->error.notable); @@ -194,14 +194,14 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_read_long_depth_s, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } return F_status_set_error(F_parameter); } else if (data->depths.array[i].depth > data->depths.array[j].depth) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_read_long_depth_s, main->error.notable); @@ -211,7 +211,7 @@ extern "C" { fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, data->depths.array[j].depth, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } return F_status_set_error(F_parameter); diff --git a/level_3/fss_extended_list_write/c/common.c b/level_3/fss_extended_list_write/c/common.c index ec3991a..6043faf 100644 --- a/level_3/fss_extended_list_write/c/common.c +++ b/level_3/fss_extended_list_write/c/common.c @@ -132,261 +132,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_extended_list_write_parameter_from_bytesequence_e, fss_extended_list_write_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_extended_list_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_extended_list_write_parameter_from_bytesequence_e) { - if (setting->mode & fss_extended_list_write_mode_from_codepoint_e) { - setting->mode -= fss_extended_list_write_mode_from_codepoint_e; - } - - setting->mode |= fss_extended_list_write_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_extended_list_write_parameter_from_codepoint_e) { - if (setting->mode & fss_extended_list_write_mode_from_bytesequence_e) { - setting->mode -= fss_extended_list_write_mode_from_bytesequence_e; - } - - setting->mode |= fss_extended_list_write_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_extended_list_write_parameter_to_bytesequence_e, fss_extended_list_write_parameter_to_codepoint_e, fss_extended_list_write_parameter_to_combining_e, fss_extended_list_write_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_extended_list_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_extended_list_write_parameter_to_bytesequence_e) { - if (setting->mode & fss_extended_list_write_mode_to_codepoint_e) { - setting->mode -= fss_extended_list_write_mode_to_codepoint_e; - } - - if (setting->mode & fss_extended_list_write_mode_to_combining_e) { - setting->mode -= fss_extended_list_write_mode_to_combining_e; - } - - if (setting->mode & fss_extended_list_write_mode_to_width_e) { - setting->mode -= fss_extended_list_write_mode_to_width_e; - } - - setting->mode |= fss_extended_list_write_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_extended_list_write_parameter_to_codepoint_e) { - if (setting->mode & fss_extended_list_write_mode_to_bytesequence_e) { - setting->mode -= fss_extended_list_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_extended_list_write_mode_to_combining_e) { - setting->mode -= fss_extended_list_write_mode_to_combining_e; - } - - if (setting->mode & fss_extended_list_write_mode_to_width_e) { - setting->mode -= fss_extended_list_write_mode_to_width_e; - } - - setting->mode |= fss_extended_list_write_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_extended_list_write_parameter_to_combining_e) { - if (setting->mode & fss_extended_list_write_mode_to_bytesequence_e) { - setting->mode -= fss_extended_list_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_extended_list_write_mode_to_codepoint_e) { - setting->mode -= fss_extended_list_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_extended_list_write_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_extended_list_write_mode_to_width_e; - } - - setting->mode |= fss_extended_list_write_mode_to_combining_e; - } - else if (choices.array[choice] == fss_extended_list_write_parameter_to_width_e) { - if (setting->mode & fss_extended_list_write_mode_to_bytesequence_e) { - setting->mode -= fss_extended_list_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_extended_list_write_mode_to_codepoint_e) { - setting->mode -= fss_extended_list_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_extended_list_write_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_extended_list_write_mode_to_combining_e; - } - - setting->mode |= fss_extended_list_write_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_extended_list_write_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_extended_list_write_parameter_to_file_e].values.used > 1) { - fss_extended_list_write_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_extended_list_write_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_extended_list_write_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_extended_list_write_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_extended_list_write_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_extended_list_write_main_flag_file_to_e; - } - else { - fss_extended_list_write_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_extended_list_write_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_extended_list_write_parameter_to_file_e].result == f_console_result_found_e) { - fss_extended_list_write_print_error_no_value(main, setting, fss_extended_list_write_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_extended_list_write_main_flag_file_to_e) { - setting->flag -= fss_extended_list_write_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_extended_list_write_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_extended_list_write_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_extended_list_write_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_extended_list_write_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_extended_list_write_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_extended_list_write_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_extended_list_write_main_flag_file_from_e; - } - else if (main->parameters.array[fss_extended_list_write_parameter_from_file_e].result == f_console_result_found_e) { - fss_extended_list_write_print_error_no_value(main, setting, fss_extended_list_write_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_extended_list_write_main_flag_file_from_e) { - setting->flag -= fss_extended_list_write_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_extended_list_write_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_extended_list_write_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_extended_list_write_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_extended_list_write_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_extended_list_write_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_extended_list_write_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_extended_list_write_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_extended_list_write_main_flag_header_e; - } - - if (main->parameters.array[fss_extended_list_write_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_extended_list_write_main_flag_separate_e; - } - if (main->parameters.array[fss_extended_list_write_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_extended_list_write_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_extended_list_write_setting_load_ diff --git a/level_3/fss_extended_list_write/c/fss_extended_list_write.c b/level_3/fss_extended_list_write/c/fss_extended_list_write.c index 4b3c9a6..33eb064 100644 --- a/level_3/fss_extended_list_write/c/fss_extended_list_write.c +++ b/level_3/fss_extended_list_write/c/fss_extended_list_write.c @@ -79,14 +79,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_extended_list_write_parameter_file_e].result == f_console_result_additional_e) { if (main->parameters.array[fss_extended_list_write_parameter_file_e].values.used > 1) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_file_s, main->error.notable); fl_print_format("%[' may only be specified once.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -126,8 +126,8 @@ extern "C" { } else if (main->parameters.array[fss_extended_list_write_parameter_content_e].locations.used && main->parameters.array[fss_extended_list_write_parameter_partial_e].locations.used) { if (main->parameters.array[fss_extended_list_write_parameter_content_e].result == f_console_result_additional_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_partial_s, main->error.notable); @@ -137,7 +137,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_content_s, main->error.notable); fl_print_format("%[' parameter, but not both.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -158,8 +158,8 @@ extern "C" { location_sub_content = main->parameters.array[fss_extended_list_write_parameter_content_e].locations_sub.array[i]; if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QEach '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_object_s, main->error.notable); @@ -167,7 +167,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -189,8 +189,8 @@ extern "C" { } } else if (!(main->pipe & fll_program_data_pipe_input_e)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThis requires either piped data or the use of the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_object_s, main->error.notable); @@ -198,7 +198,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -206,14 +206,14 @@ extern "C" { if (F_status_is_error_not(status) && (main->pipe & fll_program_data_pipe_input_e)) { if (main->parameters.array[fss_extended_list_write_parameter_partial_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThis '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_partial_s, main->error.notable); fl_print_format("%[' parameter cannot be used when processing a pipe.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -223,14 +223,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_extended_list_write_parameter_prepend_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_prepend_s, main->error.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -248,14 +248,14 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_false) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_prepend_s, main->error.notable); fl_print_format("%[' must only contain white space.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -265,14 +265,14 @@ extern "C" { } // for } else { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_prepend_s, main->error.notable); fl_print_format("%[' must not be an empty string.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -282,14 +282,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_extended_list_write_parameter_ignore_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_ignore_s, main->error.notable); fl_print_format("%[' was specified, but no values were given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -299,13 +299,13 @@ extern "C" { const f_array_length_t total_arguments = main->parameters.array[fss_extended_list_write_parameter_ignore_e].values.used; if (total_locations * 2 > total_arguments) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_ignore_s, main->error.notable); fl_print_format("%[' requires two values.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -336,13 +336,13 @@ extern "C" { status = fss_extended_list_write_process_pipe(main, output, quote, &buffer, &ignore); if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QWhile processing the '%]%[input pipe%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } @@ -418,16 +418,16 @@ extern "C" { } if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QWhile processing the '%]%[input arguments%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } - else if (main->error.verbosity != f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e && main->parameters.array[fss_extended_list_write_parameter_file_e].result == f_console_result_none_e) { + else if (main->error.verbosity > f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e && main->parameters.array[fss_extended_list_write_parameter_file_e].result == f_console_result_none_e) { // Ensure there is always a newline at the end, unless in quiet mode. fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); @@ -443,7 +443,7 @@ extern "C" { } // Ensure a newline is always put at the end of the program execution, unless in quiet mode. - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_is_error(status)) { fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); } diff --git a/level_3/fss_extended_list_write/c/private-write.c b/level_3/fss_extended_list_write/c/private-write.c index 1a44c8d..e2b8748 100644 --- a/level_3/fss_extended_list_write/c/private-write.c +++ b/level_3/fss_extended_list_write/c/private-write.c @@ -11,7 +11,7 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QMust specify the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_object_s, main->error.notable); @@ -21,7 +21,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_list_write_long_partial_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_extended_list_write_error_parameter_same_times_print_ @@ -30,7 +30,7 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe FSS-0003 (Extended List) standard does not support end of line character '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[\\n%]", main->error.to.stream, main->error.notable, main->error.notable); @@ -38,7 +38,7 @@ extern "C" { fl_print_format("%[U+000A%]", main->error.to.stream, main->error.notable, main->error.notable); fl_print_format("%[) in objects.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_extended_list_write_error_parameter_unsupported_eol_print_ @@ -47,13 +47,13 @@ extern "C" { if (main->error.verbosity == f_console_verbosity_quiet_e) return; - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, symbol, parameter, main->error.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_extended_list_write_error_parameter_value_missing_print_ @@ -270,7 +270,7 @@ extern "C" { for (; range.start <= range.stop; ++range.start) { if (block.string[range.start] == fss_extended_list_write_pipe_content_start_s.string[0]) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QThe FSS-0003 (Extended List) standard only supports one content per object.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); } diff --git a/level_3/fss_extended_read/c/common.c b/level_3/fss_extended_read/c/common.c index cb20d43..518f301 100644 --- a/level_3/fss_extended_read/c/common.c +++ b/level_3/fss_extended_read/c/common.c @@ -143,261 +143,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_extended_read_parameter_from_bytesequence_e, fss_extended_read_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_extended_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_extended_read_parameter_from_bytesequence_e) { - if (setting->mode & fss_extended_read_mode_from_codepoint_e) { - setting->mode -= fss_extended_read_mode_from_codepoint_e; - } - - setting->mode |= fss_extended_read_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_extended_read_parameter_from_codepoint_e) { - if (setting->mode & fss_extended_read_mode_from_bytesequence_e) { - setting->mode -= fss_extended_read_mode_from_bytesequence_e; - } - - setting->mode |= fss_extended_read_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_extended_read_parameter_to_bytesequence_e, fss_extended_read_parameter_to_codepoint_e, fss_extended_read_parameter_to_combining_e, fss_extended_read_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_extended_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_extended_read_parameter_to_bytesequence_e) { - if (setting->mode & fss_extended_read_mode_to_codepoint_e) { - setting->mode -= fss_extended_read_mode_to_codepoint_e; - } - - if (setting->mode & fss_extended_read_mode_to_combining_e) { - setting->mode -= fss_extended_read_mode_to_combining_e; - } - - if (setting->mode & fss_extended_read_mode_to_width_e) { - setting->mode -= fss_extended_read_mode_to_width_e; - } - - setting->mode |= fss_extended_read_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_extended_read_parameter_to_codepoint_e) { - if (setting->mode & fss_extended_read_mode_to_bytesequence_e) { - setting->mode -= fss_extended_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_extended_read_mode_to_combining_e) { - setting->mode -= fss_extended_read_mode_to_combining_e; - } - - if (setting->mode & fss_extended_read_mode_to_width_e) { - setting->mode -= fss_extended_read_mode_to_width_e; - } - - setting->mode |= fss_extended_read_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_extended_read_parameter_to_combining_e) { - if (setting->mode & fss_extended_read_mode_to_bytesequence_e) { - setting->mode -= fss_extended_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_extended_read_mode_to_codepoint_e) { - setting->mode -= fss_extended_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_extended_read_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_extended_read_mode_to_width_e; - } - - setting->mode |= fss_extended_read_mode_to_combining_e; - } - else if (choices.array[choice] == fss_extended_read_parameter_to_width_e) { - if (setting->mode & fss_extended_read_mode_to_bytesequence_e) { - setting->mode -= fss_extended_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_extended_read_mode_to_codepoint_e) { - setting->mode -= fss_extended_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_extended_read_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_extended_read_mode_to_combining_e; - } - - setting->mode |= fss_extended_read_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_extended_read_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_extended_read_parameter_to_file_e].values.used > 1) { - fss_extended_read_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_extended_read_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_extended_read_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_extended_read_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_extended_read_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_extended_read_main_flag_file_to_e; - } - else { - fss_extended_read_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_extended_read_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_extended_read_parameter_to_file_e].result == f_console_result_found_e) { - fss_extended_read_print_error_no_value(main, setting, fss_extended_read_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_extended_read_main_flag_file_to_e) { - setting->flag -= fss_extended_read_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_extended_read_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_extended_read_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_extended_read_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_extended_read_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_extended_read_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_extended_read_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_extended_read_main_flag_file_from_e; - } - else if (main->parameters.array[fss_extended_read_parameter_from_file_e].result == f_console_result_found_e) { - fss_extended_read_print_error_no_value(main, setting, fss_extended_read_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_extended_read_main_flag_file_from_e) { - setting->flag -= fss_extended_read_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_extended_read_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_extended_read_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_extended_read_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_extended_read_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_extended_read_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_extended_read_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_extended_read_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_extended_read_main_flag_header_e; - } - - if (main->parameters.array[fss_extended_read_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_extended_read_main_flag_separate_e; - } - if (main->parameters.array[fss_extended_read_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_extended_read_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_extended_read_setting_load_ diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index b64bbfa..77ec860 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -117,13 +117,13 @@ extern "C" { for (f_array_length_t i = 0; i < 6; ++i) { if (main->parameters.array[parameter_code[i]].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, parameter_name[i], main->error.notable); fl_print_format("%[' requires a %s.%]%r", main->error.to.stream, main->error.context, parameter_message[i], main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); break; @@ -159,8 +159,8 @@ extern "C" { for (f_array_length_t i = 0; i < 5; ++i) { if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_extended_read_long_columns_s, parameter_name[i]); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_extended_read_long_columns_s, parameter_name[i]); } status = F_status_set_error(F_parameter); @@ -172,15 +172,15 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.array[fss_extended_read_parameter_pipe_e].result == f_console_result_found_e) { if (main->parameters.array[fss_extended_read_parameter_total_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_extended_read_long_pipe_s, fss_extended_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_extended_read_long_pipe_s, fss_extended_read_long_total_s); } status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_extended_read_parameter_line_e].result == f_console_result_additional_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_extended_read_long_pipe_s, fss_extended_read_long_line_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_extended_read_long_pipe_s, fss_extended_read_long_line_s); } status = F_status_set_error(F_parameter); @@ -212,13 +212,13 @@ extern "C" { length = data.argv[index].used; if (!length) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_read_long_delimit_s, main->error.notable); fl_print_format("%[' must not be empty.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); @@ -345,13 +345,13 @@ extern "C" { } if (F_status_is_error_not(status) && main->parameters.array[fss_extended_read_parameter_select_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_read_long_select_s, main->error.notable); fl_print_format("%[' parameter requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); fss_extended_read_depths_resize(0, &data.depths); @@ -522,9 +522,9 @@ extern "C" { status = F_status_set_error(F_parameter); } - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } diff --git a/level_3/fss_extended_read/c/private-read.c b/level_3/fss_extended_read/c/private-read.c index fedaa0e..6a8356e 100644 --- a/level_3/fss_extended_read/c/private-read.c +++ b/level_3/fss_extended_read/c/private-read.c @@ -189,8 +189,8 @@ extern "C" { } if (data->depths.array[i].depth == data->depths.array[j].depth) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, data->depths.array[i].depth, main->error.notable); @@ -198,14 +198,14 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_read_long_depth_s, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } return F_status_set_error(F_parameter); } else if (data->depths.array[i].depth > data->depths.array[j].depth) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_read_long_depth_s, main->error.notable); @@ -215,7 +215,7 @@ extern "C" { fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, data->depths.array[j].depth, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } return F_status_set_error(F_parameter); diff --git a/level_3/fss_extended_write/c/common.c b/level_3/fss_extended_write/c/common.c index f432360..c8dbc47 100644 --- a/level_3/fss_extended_write/c/common.c +++ b/level_3/fss_extended_write/c/common.c @@ -125,261 +125,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_extended_write_parameter_from_bytesequence_e, fss_extended_write_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_extended_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_extended_write_parameter_from_bytesequence_e) { - if (setting->mode & fss_extended_write_mode_from_codepoint_e) { - setting->mode -= fss_extended_write_mode_from_codepoint_e; - } - - setting->mode |= fss_extended_write_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_extended_write_parameter_from_codepoint_e) { - if (setting->mode & fss_extended_write_mode_from_bytesequence_e) { - setting->mode -= fss_extended_write_mode_from_bytesequence_e; - } - - setting->mode |= fss_extended_write_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_extended_write_parameter_to_bytesequence_e, fss_extended_write_parameter_to_codepoint_e, fss_extended_write_parameter_to_combining_e, fss_extended_write_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_extended_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_extended_write_parameter_to_bytesequence_e) { - if (setting->mode & fss_extended_write_mode_to_codepoint_e) { - setting->mode -= fss_extended_write_mode_to_codepoint_e; - } - - if (setting->mode & fss_extended_write_mode_to_combining_e) { - setting->mode -= fss_extended_write_mode_to_combining_e; - } - - if (setting->mode & fss_extended_write_mode_to_width_e) { - setting->mode -= fss_extended_write_mode_to_width_e; - } - - setting->mode |= fss_extended_write_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_extended_write_parameter_to_codepoint_e) { - if (setting->mode & fss_extended_write_mode_to_bytesequence_e) { - setting->mode -= fss_extended_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_extended_write_mode_to_combining_e) { - setting->mode -= fss_extended_write_mode_to_combining_e; - } - - if (setting->mode & fss_extended_write_mode_to_width_e) { - setting->mode -= fss_extended_write_mode_to_width_e; - } - - setting->mode |= fss_extended_write_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_extended_write_parameter_to_combining_e) { - if (setting->mode & fss_extended_write_mode_to_bytesequence_e) { - setting->mode -= fss_extended_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_extended_write_mode_to_codepoint_e) { - setting->mode -= fss_extended_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_extended_write_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_extended_write_mode_to_width_e; - } - - setting->mode |= fss_extended_write_mode_to_combining_e; - } - else if (choices.array[choice] == fss_extended_write_parameter_to_width_e) { - if (setting->mode & fss_extended_write_mode_to_bytesequence_e) { - setting->mode -= fss_extended_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_extended_write_mode_to_codepoint_e) { - setting->mode -= fss_extended_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_extended_write_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_extended_write_mode_to_combining_e; - } - - setting->mode |= fss_extended_write_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_extended_write_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_extended_write_parameter_to_file_e].values.used > 1) { - fss_extended_write_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_extended_write_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_extended_write_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_extended_write_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_extended_write_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_extended_write_main_flag_file_to_e; - } - else { - fss_extended_write_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_extended_write_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_extended_write_parameter_to_file_e].result == f_console_result_found_e) { - fss_extended_write_print_error_no_value(main, setting, fss_extended_write_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_extended_write_main_flag_file_to_e) { - setting->flag -= fss_extended_write_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_extended_write_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_extended_write_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_extended_write_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_extended_write_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_extended_write_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_extended_write_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_extended_write_main_flag_file_from_e; - } - else if (main->parameters.array[fss_extended_write_parameter_from_file_e].result == f_console_result_found_e) { - fss_extended_write_print_error_no_value(main, setting, fss_extended_write_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_extended_write_main_flag_file_from_e) { - setting->flag -= fss_extended_write_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_extended_write_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_extended_write_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_extended_write_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_extended_write_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_extended_write_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_extended_write_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_extended_write_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_extended_write_main_flag_header_e; - } - - if (main->parameters.array[fss_extended_write_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_extended_write_main_flag_separate_e; - } - if (main->parameters.array[fss_extended_write_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_extended_write_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_extended_write_setting_load_ diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index de6d4b9..8dd62a9 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -79,14 +79,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_extended_write_parameter_file_e].result == f_console_result_additional_e) { if (main->parameters.array[fss_extended_write_parameter_file_e].values.used > 1) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_file_s, main->error.notable); fl_print_format("%[' may only be specified once.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -126,8 +126,8 @@ extern "C" { } else if (main->parameters.array[fss_extended_write_parameter_content_e].locations.used && main->parameters.array[fss_extended_write_parameter_partial_e].locations.used) { if (main->parameters.array[fss_extended_write_parameter_content_e].result == f_console_result_additional_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_partial_s, main->error.notable); @@ -137,7 +137,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_content_s, main->error.notable); fl_print_format("%[' parameter, but not both.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -152,8 +152,8 @@ extern "C" { f_array_length_t location_sub_content = main->parameters.array[fss_extended_write_parameter_content_e].locations_sub.array[0]; if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QEach '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_object_s, main->error.notable); @@ -161,7 +161,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -173,8 +173,8 @@ extern "C" { location_sub_content = main->parameters.array[fss_extended_write_parameter_content_e].locations_sub.array[main->parameters.array[fss_extended_write_parameter_content_e].locations_sub.used - 1]; if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QEach '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_object_s, main->error.notable); @@ -182,7 +182,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -203,8 +203,8 @@ extern "C" { } } else if (!(main->pipe & fll_program_data_pipe_input_e)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThis requires either piped data or the use of the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_object_s, main->error.notable); @@ -212,7 +212,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -220,14 +220,14 @@ extern "C" { if (F_status_is_error_not(status) && (main->pipe & fll_program_data_pipe_input_e)) { if (main->parameters.array[fss_extended_write_parameter_partial_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThis '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_partial_s, main->error.notable); fl_print_format("%[' parameter cannot be used when processing a pipe.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -237,14 +237,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_extended_write_parameter_prepend_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_prepend_s, main->error.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -263,14 +263,14 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_false) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_prepend_s, main->error.notable); fl_print_format("%[' must only contain white space.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -280,14 +280,14 @@ extern "C" { } // for } else { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_prepend_s, main->error.notable); fl_print_format("%[' must not be an empty string.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -297,14 +297,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_extended_write_parameter_ignore_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_ignore_s, main->error.notable); fl_print_format("%[' was specified, but no values were given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -314,13 +314,13 @@ extern "C" { const f_array_length_t total_arguments = main->parameters.array[fss_extended_write_parameter_ignore_e].values.used; if (total_locations * 2 > total_arguments) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_ignore_s, main->error.notable); fl_print_format("%[' requires two values.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -352,13 +352,13 @@ extern "C" { status = fss_extended_write_process_pipe(main, output, quote, &buffer); if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QWhile processing the '%]%[input pipe%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } } @@ -476,16 +476,16 @@ extern "C" { } if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QWhile processing the '%]%[input arguments%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } - else if (main->error.verbosity != f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e && main->parameters.array[fss_extended_write_parameter_file_e].result == f_console_result_none_e) { + else if (main->error.verbosity > f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e && main->parameters.array[fss_extended_write_parameter_file_e].result == f_console_result_none_e) { // Ensure there is always a newline at the end, unless in quiet mode. fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); @@ -501,10 +501,10 @@ extern "C" { } // Ensure a newline is always put at the end of the program execution, unless in quiet mode. - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); } fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); diff --git a/level_3/fss_extended_write/c/private-write.c b/level_3/fss_extended_write/c/private-write.c index c1cdbe4..64b7ae2 100644 --- a/level_3/fss_extended_write/c/private-write.c +++ b/level_3/fss_extended_write/c/private-write.c @@ -13,7 +13,7 @@ extern "C" { return; } - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QMust specify the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_object_s, main->error.notable); @@ -23,7 +23,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_extended_write_long_partial_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_extended_write_error_parameter_at_least_once_print_ @@ -34,13 +34,13 @@ extern "C" { return; } - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, symbol, parameter, main->error.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_extended_write_error_parameter_value_missing_print_ @@ -51,7 +51,7 @@ extern "C" { return; } - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe FSS-0001 (Extended) standard does not support end of line character '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[\\n%]", main->error.to.stream, main->error.notable, main->error.notable); @@ -59,7 +59,7 @@ extern "C" { fl_print_format("%[U+000A%]", main->error.to.stream, main->error.notable, main->error.notable); fl_print_format("%[) in objects.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_extended_write_error_parameter_unsupported_eol_print_ diff --git a/level_3/fss_identify/c/common.c b/level_3/fss_identify/c/common.c index 2e87b18..06971ea 100644 --- a/level_3/fss_identify/c/common.c +++ b/level_3/fss_identify/c/common.c @@ -110,261 +110,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_identify_parameter_from_bytesequence_e, fss_identify_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_identify_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_identify_parameter_from_bytesequence_e) { - if (setting->mode & fss_identify_mode_from_codepoint_e) { - setting->mode -= fss_identify_mode_from_codepoint_e; - } - - setting->mode |= fss_identify_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_identify_parameter_from_codepoint_e) { - if (setting->mode & fss_identify_mode_from_bytesequence_e) { - setting->mode -= fss_identify_mode_from_bytesequence_e; - } - - setting->mode |= fss_identify_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_identify_parameter_to_bytesequence_e, fss_identify_parameter_to_codepoint_e, fss_identify_parameter_to_combining_e, fss_identify_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_identify_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_identify_parameter_to_bytesequence_e) { - if (setting->mode & fss_identify_mode_to_codepoint_e) { - setting->mode -= fss_identify_mode_to_codepoint_e; - } - - if (setting->mode & fss_identify_mode_to_combining_e) { - setting->mode -= fss_identify_mode_to_combining_e; - } - - if (setting->mode & fss_identify_mode_to_width_e) { - setting->mode -= fss_identify_mode_to_width_e; - } - - setting->mode |= fss_identify_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_identify_parameter_to_codepoint_e) { - if (setting->mode & fss_identify_mode_to_bytesequence_e) { - setting->mode -= fss_identify_mode_to_bytesequence_e; - } - - if (setting->mode & fss_identify_mode_to_combining_e) { - setting->mode -= fss_identify_mode_to_combining_e; - } - - if (setting->mode & fss_identify_mode_to_width_e) { - setting->mode -= fss_identify_mode_to_width_e; - } - - setting->mode |= fss_identify_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_identify_parameter_to_combining_e) { - if (setting->mode & fss_identify_mode_to_bytesequence_e) { - setting->mode -= fss_identify_mode_to_bytesequence_e; - } - - if (setting->mode & fss_identify_mode_to_codepoint_e) { - setting->mode -= fss_identify_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_identify_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_identify_mode_to_width_e; - } - - setting->mode |= fss_identify_mode_to_combining_e; - } - else if (choices.array[choice] == fss_identify_parameter_to_width_e) { - if (setting->mode & fss_identify_mode_to_bytesequence_e) { - setting->mode -= fss_identify_mode_to_bytesequence_e; - } - - if (setting->mode & fss_identify_mode_to_codepoint_e) { - setting->mode -= fss_identify_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_identify_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_identify_mode_to_combining_e; - } - - setting->mode |= fss_identify_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_identify_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_identify_parameter_to_file_e].values.used > 1) { - fss_identify_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_identify_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_identify_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_identify_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_identify_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_identify_main_flag_file_to_e; - } - else { - fss_identify_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_identify_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_identify_parameter_to_file_e].result == f_console_result_found_e) { - fss_identify_print_error_no_value(main, setting, fss_identify_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_identify_main_flag_file_to_e) { - setting->flag -= fss_identify_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_identify_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_identify_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_identify_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_identify_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_identify_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_identify_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_identify_main_flag_file_from_e; - } - else if (main->parameters.array[fss_identify_parameter_from_file_e].result == f_console_result_found_e) { - fss_identify_print_error_no_value(main, setting, fss_identify_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_identify_main_flag_file_from_e) { - setting->flag -= fss_identify_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_identify_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_identify_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_identify_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_identify_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_identify_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_identify_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_identify_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_identify_main_flag_header_e; - } - - if (main->parameters.array[fss_identify_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_identify_main_flag_separate_e; - } - if (main->parameters.array[fss_identify_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_identify_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_identify_setting_load_ diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index f5a0711..671b0a8 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -74,13 +74,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_identify_parameter_line_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_identify_long_line_s, main->error.notable); fl_print_format("%[' requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -97,15 +97,15 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.array[fss_identify_parameter_total_e].result == f_console_result_found_e) { if (main->parameters.array[fss_identify_parameter_object_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_identify_long_object_s, fss_identify_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_identify_long_object_s, fss_identify_long_total_s); } status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_identify_parameter_content_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_identify_long_content_s, fss_identify_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_identify_long_content_s, fss_identify_long_total_s); } status = F_status_set_error(F_parameter); @@ -114,13 +114,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_identify_parameter_name_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_identify_long_name_s, main->error.notable); fl_print_format("%[' requires a string.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -130,13 +130,13 @@ extern "C" { const f_string_range_t range = macro_f_string_range_t_initialize2(length); if (length == 0) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_identify_long_name_s, main->error.notable); fl_print_format("%[' does not allow zero length strings.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -160,7 +160,7 @@ extern "C" { break; } else if (status == F_false) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%Q%]", main->error.to.stream, main->error.notable, data.argv[index], main->error.notable); @@ -168,7 +168,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_identify_long_name_s, main->error.notable); fl_print_format("%[' may only contain word characters or the dash (minus)y character.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); @@ -249,10 +249,10 @@ extern "C" { } // Ensure a newline is always put at the end of the program execution, unless in quiet mode. - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); } fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); diff --git a/level_3/fss_payload_read/c/common.c b/level_3/fss_payload_read/c/common.c index 49fdb5d..2b51e5c 100644 --- a/level_3/fss_payload_read/c/common.c +++ b/level_3/fss_payload_read/c/common.c @@ -135,261 +135,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_payload_read_parameter_from_bytesequence_e, fss_payload_read_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_payload_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_payload_read_parameter_from_bytesequence_e) { - if (setting->mode & fss_payload_read_mode_from_codepoint_e) { - setting->mode -= fss_payload_read_mode_from_codepoint_e; - } - - setting->mode |= fss_payload_read_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_payload_read_parameter_from_codepoint_e) { - if (setting->mode & fss_payload_read_mode_from_bytesequence_e) { - setting->mode -= fss_payload_read_mode_from_bytesequence_e; - } - - setting->mode |= fss_payload_read_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_payload_read_parameter_to_bytesequence_e, fss_payload_read_parameter_to_codepoint_e, fss_payload_read_parameter_to_combining_e, fss_payload_read_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_payload_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_payload_read_parameter_to_bytesequence_e) { - if (setting->mode & fss_payload_read_mode_to_codepoint_e) { - setting->mode -= fss_payload_read_mode_to_codepoint_e; - } - - if (setting->mode & fss_payload_read_mode_to_combining_e) { - setting->mode -= fss_payload_read_mode_to_combining_e; - } - - if (setting->mode & fss_payload_read_mode_to_width_e) { - setting->mode -= fss_payload_read_mode_to_width_e; - } - - setting->mode |= fss_payload_read_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_payload_read_parameter_to_codepoint_e) { - if (setting->mode & fss_payload_read_mode_to_bytesequence_e) { - setting->mode -= fss_payload_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_payload_read_mode_to_combining_e) { - setting->mode -= fss_payload_read_mode_to_combining_e; - } - - if (setting->mode & fss_payload_read_mode_to_width_e) { - setting->mode -= fss_payload_read_mode_to_width_e; - } - - setting->mode |= fss_payload_read_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_payload_read_parameter_to_combining_e) { - if (setting->mode & fss_payload_read_mode_to_bytesequence_e) { - setting->mode -= fss_payload_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_payload_read_mode_to_codepoint_e) { - setting->mode -= fss_payload_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_payload_read_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_payload_read_mode_to_width_e; - } - - setting->mode |= fss_payload_read_mode_to_combining_e; - } - else if (choices.array[choice] == fss_payload_read_parameter_to_width_e) { - if (setting->mode & fss_payload_read_mode_to_bytesequence_e) { - setting->mode -= fss_payload_read_mode_to_bytesequence_e; - } - - if (setting->mode & fss_payload_read_mode_to_codepoint_e) { - setting->mode -= fss_payload_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_payload_read_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_payload_read_mode_to_combining_e; - } - - setting->mode |= fss_payload_read_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_payload_read_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_payload_read_parameter_to_file_e].values.used > 1) { - fss_payload_read_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_payload_read_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_payload_read_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_payload_read_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_payload_read_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_payload_read_main_flag_file_to_e; - } - else { - fss_payload_read_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_payload_read_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_payload_read_parameter_to_file_e].result == f_console_result_found_e) { - fss_payload_read_print_error_no_value(main, setting, fss_payload_read_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_payload_read_main_flag_file_to_e) { - setting->flag -= fss_payload_read_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_payload_read_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_payload_read_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_payload_read_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_payload_read_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_payload_read_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_payload_read_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_payload_read_main_flag_file_from_e; - } - else if (main->parameters.array[fss_payload_read_parameter_from_file_e].result == f_console_result_found_e) { - fss_payload_read_print_error_no_value(main, setting, fss_payload_read_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_payload_read_main_flag_file_from_e) { - setting->flag -= fss_payload_read_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_payload_read_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_payload_read_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_payload_read_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_payload_read_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_payload_read_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_payload_read_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_payload_read_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_payload_read_main_flag_header_e; - } - - if (main->parameters.array[fss_payload_read_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_payload_read_main_flag_separate_e; - } - if (main->parameters.array[fss_payload_read_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_payload_read_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_payload_read_setting_load_ diff --git a/level_3/fss_payload_read/c/fss_payload_read.c b/level_3/fss_payload_read/c/fss_payload_read.c index 4b536ae..40cb7c3 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.c +++ b/level_3/fss_payload_read/c/fss_payload_read.c @@ -126,13 +126,13 @@ extern "C" { for (f_array_length_t i = 0; i < 6; ++i) { if (main->parameters.array[parameter_code[i]].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, parameter_name[i], main->error.notable); fl_print_format("%[' requires a %s.%]%r", main->error.to.stream, main->error.context, parameter_message[i], main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); break; @@ -168,8 +168,8 @@ extern "C" { for (f_array_length_t i = 0; i < 5; ++i) { if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_payload_read_long_columns_s, parameter_name[i]); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_payload_read_long_columns_s, parameter_name[i]); } status = F_status_set_error(F_parameter); @@ -181,15 +181,15 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.array[fss_payload_read_parameter_pipe_e].result == f_console_result_found_e) { if (main->parameters.array[fss_payload_read_parameter_total_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_payload_read_long_pipe_s, fss_payload_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_payload_read_long_pipe_s, fss_payload_read_long_total_s); } status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_payload_read_parameter_line_e].result == f_console_result_additional_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, fss_payload_read_long_pipe_s, fss_payload_read_long_line_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_payload_read_long_pipe_s, fss_payload_read_long_line_s); } status = F_status_set_error(F_parameter); @@ -221,13 +221,13 @@ extern "C" { length = data.argv[index].used; if (!length) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_read_long_delimit_s, main->error.notable); fl_print_format("%[' must not be empty.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); @@ -367,13 +367,13 @@ extern "C" { } if (F_status_is_error_not(status) && main->parameters.array[fss_payload_read_parameter_select_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_read_long_select_s, main->error.notable); fl_print_format("%[' parameter requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); fss_payload_read_depths_resize(0, &data.depths); @@ -536,9 +536,9 @@ extern "C" { status = F_status_set_error(F_parameter); } - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } diff --git a/level_3/fss_payload_read/c/private-read.c b/level_3/fss_payload_read/c/private-read.c index d99d35d..b43252f 100644 --- a/level_3/fss_payload_read/c/private-read.c +++ b/level_3/fss_payload_read/c/private-read.c @@ -185,23 +185,17 @@ extern "C" { } if (data->depths.array[i].depth == data->depths.array[j].depth) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity < f_console_verbosity_normal_e) { + fss_payload_read_print_line_first(setting, main->error, F_true); - fl_print_format("%r%[%QThe value '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, data->depths.array[i].depth, main->error.notable); - fl_print_format("%[' may only be specified once for the parameter '%]", main->error.to.stream, main->error.context, main->error.context); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_read_long_depth_s, main->error.notable); - fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - - funlockfile(main->error.to.stream); + fll_program_print_error_parameter_must_specify_once_value(main->error, f_console_symbol_long_enable_s, fss_payload_read_long_depth_s, data->depths.array[i].depth); } return F_status_set_error(F_parameter); } else if (data->depths.array[i].depth > data->depths.array[j].depth) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_read_long_depth_s, main->error.notable); @@ -211,7 +205,7 @@ extern "C" { fl_print_format("%[%ul%]", main->error.to.stream, main->error.notable, data->depths.array[j].depth, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } return F_status_set_error(F_parameter); @@ -257,8 +251,8 @@ extern "C" { const f_string_static_t file_name = fss_payload_read_file_identify(input.start, data->files); if (F_status_set_fine(status) == F_none || F_status_set_fine(status) == F_none_eos || F_status_set_fine(status) == F_none_stop || F_status_set_fine(status) == F_data_not_eos || F_status_set_fine(status) == F_data_not_stop) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe file '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%]", main->error.to.stream, main->error.notable, file_name, main->error.notable); @@ -266,7 +260,7 @@ extern "C" { fl_print_format("%[%r%]", main->error.to.stream, main->error.notable, f_fss_string_payload_s, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } else { diff --git a/level_3/fss_payload_write/c/common.c b/level_3/fss_payload_write/c/common.c index 84a5dcf..6af79f4 100644 --- a/level_3/fss_payload_write/c/common.c +++ b/level_3/fss_payload_write/c/common.c @@ -115,261 +115,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { fss_payload_write_parameter_from_bytesequence_e, fss_payload_write_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_payload_write_parameter_from_bytesequence_e) { - if (setting->mode & fss_payload_write_mode_from_codepoint_e) { - setting->mode -= fss_payload_write_mode_from_codepoint_e; - } - - setting->mode |= fss_payload_write_mode_from_bytesequence_e; - } - else if (choices.array[choice] == fss_payload_write_parameter_from_codepoint_e) { - if (setting->mode & fss_payload_write_mode_from_bytesequence_e) { - setting->mode -= fss_payload_write_mode_from_bytesequence_e; - } - - setting->mode |= fss_payload_write_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { fss_payload_write_parameter_to_bytesequence_e, fss_payload_write_parameter_to_codepoint_e, fss_payload_write_parameter_to_combining_e, fss_payload_write_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == fss_payload_write_parameter_to_bytesequence_e) { - if (setting->mode & fss_payload_write_mode_to_codepoint_e) { - setting->mode -= fss_payload_write_mode_to_codepoint_e; - } - - if (setting->mode & fss_payload_write_mode_to_combining_e) { - setting->mode -= fss_payload_write_mode_to_combining_e; - } - - if (setting->mode & fss_payload_write_mode_to_width_e) { - setting->mode -= fss_payload_write_mode_to_width_e; - } - - setting->mode |= fss_payload_write_mode_to_bytesequence_e; - } - else if (choices.array[choice] == fss_payload_write_parameter_to_codepoint_e) { - if (setting->mode & fss_payload_write_mode_to_bytesequence_e) { - setting->mode -= fss_payload_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_payload_write_mode_to_combining_e) { - setting->mode -= fss_payload_write_mode_to_combining_e; - } - - if (setting->mode & fss_payload_write_mode_to_width_e) { - setting->mode -= fss_payload_write_mode_to_width_e; - } - - setting->mode |= fss_payload_write_mode_to_codepoint_e; - } - else if (choices.array[choice] == fss_payload_write_parameter_to_combining_e) { - if (setting->mode & fss_payload_write_mode_to_bytesequence_e) { - setting->mode -= fss_payload_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_payload_write_mode_to_codepoint_e) { - setting->mode -= fss_payload_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_payload_write_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= fss_payload_write_mode_to_width_e; - } - - setting->mode |= fss_payload_write_mode_to_combining_e; - } - else if (choices.array[choice] == fss_payload_write_parameter_to_width_e) { - if (setting->mode & fss_payload_write_mode_to_bytesequence_e) { - setting->mode -= fss_payload_write_mode_to_bytesequence_e; - } - - if (setting->mode & fss_payload_write_mode_to_codepoint_e) { - setting->mode -= fss_payload_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[fss_payload_write_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= fss_payload_write_mode_to_combining_e; - } - - setting->mode |= fss_payload_write_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[fss_payload_write_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[fss_payload_write_parameter_to_file_e].values.used > 1) { - fss_payload_write_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[fss_payload_write_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[fss_payload_write_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[fss_payload_write_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[fss_payload_write_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_payload_write_main_flag_file_to_e; - } - else { - fss_payload_write_print_error_parameter_file_name_empty(main, setting, main->parameters.array[fss_payload_write_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[fss_payload_write_parameter_to_file_e].result == f_console_result_found_e) { - fss_payload_write_print_error_no_value(main, setting, fss_payload_write_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & fss_payload_write_main_flag_file_to_e) { - setting->flag -= fss_payload_write_main_flag_file_to_e; - } - } - - if (main->parameters.array[fss_payload_write_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[fss_payload_write_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[fss_payload_write_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[fss_payload_write_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - fss_payload_write_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - fss_payload_write_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= fss_payload_write_main_flag_file_from_e; - } - else if (main->parameters.array[fss_payload_write_parameter_from_file_e].result == f_console_result_found_e) { - fss_payload_write_print_error_no_value(main, setting, fss_payload_write_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & fss_payload_write_main_flag_file_from_e) { - setting->flag -= fss_payload_write_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[fss_payload_write_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - fss_payload_write_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & fss_payload_write_mode_to_bytesequence_e)) { - if (main->parameters.array[fss_payload_write_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[fss_payload_write_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = fss_payload_write_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[fss_payload_write_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= fss_payload_write_main_flag_header_e; - } - - if (main->parameters.array[fss_payload_write_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= fss_payload_write_main_flag_separate_e; - } - if (main->parameters.array[fss_payload_write_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= fss_payload_write_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_fss_payload_write_setting_load_ diff --git a/level_3/fss_payload_write/c/fss_payload_write.c b/level_3/fss_payload_write/c/fss_payload_write.c index 0669bb8..5a8222f 100644 --- a/level_3/fss_payload_write/c/fss_payload_write.c +++ b/level_3/fss_payload_write/c/fss_payload_write.c @@ -90,14 +90,8 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_payload_write_parameter_file_e].result == f_console_result_additional_e) { if (main->parameters.array[fss_payload_write_parameter_file_e].values.used > 1) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_file_s, main->error.notable); - fl_print_format("%[' may only be specified once.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - - funlockfile(main->error.to.stream); + if (main->error.verbosity < f_console_verbosity_normal_e) { + fll_program_print_error_parameter_must_specify_once(main->error, f_console_symbol_long_enable_s, fss_payload_write_long_file_s); } status = F_status_set_error(F_parameter); @@ -137,8 +131,8 @@ extern "C" { } else if (main->parameters.array[fss_payload_write_parameter_content_e].locations.used && main->parameters.array[fss_payload_write_parameter_partial_e].locations.used) { if (main->parameters.array[fss_payload_write_parameter_content_e].result == f_console_result_additional_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_partial_s, main->error.notable); @@ -148,7 +142,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_content_s, main->error.notable); fl_print_format("%[' parameter, but not both.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -169,8 +163,8 @@ extern "C" { location_sub_content = main->parameters.array[fss_payload_write_parameter_content_e].locations_sub.array[i]; if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QEach '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_object_s, main->error.notable); @@ -178,7 +172,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -200,8 +194,8 @@ extern "C" { } } else if (!(main->pipe & fll_program_data_pipe_input_e)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThis requires either piped data or the use of the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_object_s, main->error.notable); @@ -209,7 +203,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_content_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -217,14 +211,14 @@ extern "C" { if (F_status_is_error_not(status) && (main->pipe & fll_program_data_pipe_input_e)) { if (main->parameters.array[fss_payload_write_parameter_partial_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThis '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_partial_s, main->error.notable); fl_print_format("%[' parameter cannot be used when processing a pipe.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -234,14 +228,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_payload_write_parameter_prepend_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_prepend_s, main->error.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -259,14 +253,14 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_false) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_prepend_s, main->error.notable); fl_print_format("%[' must only contain white space.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -275,14 +269,14 @@ extern "C" { } // for } else { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_prepend_s, main->error.notable); fl_print_format("%[' must not be an empty string.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -292,14 +286,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters.array[fss_payload_write_parameter_ignore_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_ignore_s, main->error.notable); fl_print_format("%[' was specified, but no values were given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -309,13 +303,13 @@ extern "C" { const f_array_length_t total_arguments = main->parameters.array[fss_payload_write_parameter_ignore_e].values.used; if (total_locations * 2 > total_arguments) { - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_ignore_s, main->error.notable); fl_print_format("%[' requires two values.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); status = F_status_set_error(F_parameter); } @@ -346,13 +340,13 @@ extern "C" { status = fss_payload_write_process_pipe(main, output, quote, &buffer); if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QWhile processing the '%]%[input pipe%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } } @@ -420,16 +414,16 @@ extern "C" { } if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QWhile processing the '%]%[input arguments%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, main->error.notable, main->error.notable); fl_print_format("%['.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } } - else if (main->error.verbosity != f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e && main->parameters.array[fss_payload_write_parameter_file_e].result == f_console_result_none_e) { + else if (main->error.verbosity > f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e && main->parameters.array[fss_payload_write_parameter_file_e].result == f_console_result_none_e) { // Ensure there is always a newline at the end, unless in quiet mode. fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); @@ -445,7 +439,7 @@ extern "C" { } // Ensure a newline is always put at the end of the program execution, unless in quiet mode. - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { if (F_status_is_error(status)) { fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); } diff --git a/level_3/fss_payload_write/c/private-write.c b/level_3/fss_payload_write/c/private-write.c index 3b93b2a..6c574d0 100644 --- a/level_3/fss_payload_write/c/private-write.c +++ b/level_3/fss_payload_write/c/private-write.c @@ -13,7 +13,7 @@ extern "C" { return; } - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QMust specify the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_object_s, main->error.notable); @@ -23,7 +23,7 @@ extern "C" { fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_partial_s, main->error.notable); fl_print_format("%[' parameter.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_payload_write_error_parameter_same_times_print_ @@ -34,7 +34,7 @@ extern "C" { return; } - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe FSS-000E (Payload) standard does not support end of line character '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[\\n%]", main->error.to.stream, main->error.notable, main->error.notable); @@ -42,7 +42,7 @@ extern "C" { fl_print_format("%[U+000A%]", main->error.to.stream, main->error.notable, main->error.notable); fl_print_format("%[) in objects.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_payload_write_error_parameter_unsupported_eol_print_ @@ -53,13 +53,13 @@ extern "C" { return; } - flockfile(main->error.to.stream); + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, symbol, parameter, main->error.notable); fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } #endif // _di_fss_payload_write_error_parameter_value_missing_print_ @@ -344,7 +344,7 @@ extern "C" { for (; range.start <= range.stop; ++range.start) { if (block.string[range.start] == fss_payload_write_pipe_content_start_s.string[0]) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QThe FSS-000E (Payload) standard only supports one content per object.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); } diff --git a/level_3/fss_status_code/c/common.c b/level_3/fss_status_code/c/common.c index 0d5f548..4bd0140 100644 --- a/level_3/fss_status_code/c/common.c +++ b/level_3/fss_status_code/c/common.c @@ -55,7 +55,14 @@ extern "C" { // Load parameters. setting->status = f_console_parameter_process(arguments, &main->parameters); - if (F_status_is_error(setting->status)) return; + + if (F_status_is_error(setting->status)) { + fss_status_code_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_status_code_print_line_last(setting, main->error, F_true); + + return; + } { f_array_length_t choice = 0; @@ -145,43 +152,43 @@ extern "C" { if (setting->flag & fss_status_code_main_flag_error_e) { if (setting->flag & fss_status_code_main_flag_warning_e) { if (!(setting->flag & fss_status_code_main_flag_number_e)) { + setting->status = F_status_set_error(F_parameter); + fss_status_code_print_line_first(setting, main->error, F_true); fss_status_code_print_error_cannot_error_warning_number(setting, main->error); fss_status_code_print_line_last(setting, main->error, F_true); - setting->status = F_status_set_error(F_parameter); - return; } } if (setting->flag & fss_status_code_main_flag_fine_e) { + setting->status = F_status_set_error(F_parameter); + fss_status_code_print_line_first(setting, main->error, F_true); - fll_program_parameter_long_print_cannot_use_with(main->error, fss_status_code_long_error_s, fss_status_code_long_fine_s); + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_status_code_long_error_s, fss_status_code_long_fine_s); fss_status_code_print_line_last(setting, main->error, F_true); - setting->status = F_status_set_error(F_parameter); - return; } } else if (setting->flag & fss_status_code_main_flag_warning_e && setting->flag & fss_status_code_main_flag_fine_e) { + setting->status = F_status_set_error(F_parameter); + fss_status_code_print_line_first(setting, main->error, F_true); - fll_program_parameter_long_print_cannot_use_with(main->error, fss_status_code_long_warning_s, fss_status_code_long_fine_s); + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, fss_status_code_long_warning_s, fss_status_code_long_fine_s); fss_status_code_print_line_last(setting, main->error, F_true); - setting->status = F_status_set_error(F_parameter); - return; } if (main->parameters.remaining.used == 0 && !(main->pipe & fll_program_data_pipe_input_e)) { + setting->status = F_status_set_error(F_parameter); + fss_status_code_print_line_first(setting, main->error, F_true); fss_status_code_print_error_no_fss_status_codes(setting, main->error); fss_status_code_print_line_last(setting, main->error, F_true); - setting->status = F_status_set_error(F_parameter); - return; } } diff --git a/level_3/fss_status_code/c/fss_status_code.c b/level_3/fss_status_code/c/fss_status_code.c index 3b580e4..8e48fb0 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -9,17 +9,7 @@ extern "C" { #ifndef _di_fss_status_code_main_ void fss_status_code_main(fll_program_data_t * const main, fss_status_code_setting_t * const setting) { - if (!main || !setting) { - fss_status_code_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_parameter, "fss_status_code_main", F_true); - fss_status_code_print_line_last(setting, main->error, F_true); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (F_status_is_error(setting->status)) return; + if (!main || !setting || F_status_is_error(setting->status)) return; setting->status = F_none; diff --git a/level_3/fss_status_code/c/print.c b/level_3/fss_status_code/c/print.c index f0d58a2..377018b 100644 --- a/level_3/fss_status_code/c/print.c +++ b/level_3/fss_status_code/c/print.c @@ -7,9 +7,9 @@ extern "C" { #endif #ifndef _di_fss_status_code_print_error_cannot_error_warning_number_ - void fss_status_code_print_error_cannot_error_warning_number(fss_status_code_setting_t * const setting, const fl_print_t print) { + f_status_t fss_status_code_print_error_cannot_error_warning_number(fss_status_code_setting_t * const setting, const fl_print_t print) { - if (print.verbosity == f_console_verbosity_quiet_e) return; + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; f_file_stream_lock(print.to); @@ -22,15 +22,19 @@ extern "C" { fl_print_format("%[' parameter.%]%r", print.to.stream, print.context, print.context, f_string_eol_s); f_file_stream_unlock(print.to); + + return F_none; } #endif // _di_fss_status_code_print_error_cannot_error_warning_number_ #ifndef _di_fss_status_code_print_error_no_fss_status_codes_ - void fss_status_code_print_error_no_fss_status_codes(fss_status_code_setting_t * const setting, const fl_print_t print) { + f_status_t fss_status_code_print_error_no_fss_status_codes(fss_status_code_setting_t * const setting, const fl_print_t print) { - if (print.verbosity == f_console_verbosity_quiet_e) return; + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; fll_print_format("%[No status code is specified.%]%r", print.to.stream, print.context, print.context, f_string_eol_s); + + return F_none; } #endif // _di_fss_status_code_print_error_no_fss_status_codes_ @@ -64,9 +68,9 @@ extern "C" { #endif // _di_fss_status_code_print_help_ #ifndef _di_fss_status_code_print_line_first_ - void fss_status_code_print_line_first(fss_status_code_setting_t * const setting, const fl_print_t print, const bool lock) { + f_status_t fss_status_code_print_line_first(fss_status_code_setting_t * const setting, const fl_print_t print, const bool lock) { - if (print.verbosity == f_console_verbosity_quiet_e) return; + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; if (lock) { fll_print_dynamic_raw(setting->line_first, print.to.stream); @@ -74,14 +78,16 @@ extern "C" { else { f_print_dynamic_raw(setting->line_first, print.to.stream); } + + return F_none; } #endif // _di_fss_status_code_print_line_first_ #ifndef _di_fss_status_code_print_line_last_ - void fss_status_code_print_line_last(fss_status_code_setting_t * const setting, const fl_print_t print, const bool lock) { + f_status_t fss_status_code_print_line_last(fss_status_code_setting_t * const setting, const fl_print_t print, const bool lock) { - if (print.verbosity == f_console_verbosity_quiet_e) return; - if (print.verbosity == f_console_verbosity_error_e && !F_status_is_error(setting->status)) return; + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + if (print.verbosity == f_console_verbosity_error_e && !F_status_is_error(setting->status)) return F_output_not; if (lock) { fll_print_dynamic_raw(setting->line_last, print.to.stream); @@ -89,6 +95,8 @@ extern "C" { else { f_print_dynamic_raw(setting->line_last, print.to.stream); } + + return F_none; } #endif // _di_fss_status_code_print_line_last_ diff --git a/level_3/fss_status_code/c/print.h b/level_3/fss_status_code/c/print.h index cca7957..aa00721 100644 --- a/level_3/fss_status_code/c/print.h +++ b/level_3/fss_status_code/c/print.h @@ -20,9 +20,13 @@ extern "C" { * This does not alter setting.status. * @param print * Designates the how and where to print. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_fss_status_code_print_error_cannot_error_warning_number_ - extern void fss_status_code_print_error_cannot_error_warning_number(fss_status_code_setting_t * const setting, const fl_print_t print); + extern f_status_t fss_status_code_print_error_cannot_error_warning_number(fss_status_code_setting_t * const setting, const fl_print_t print); #endif // _di_fss_status_code_print_error_cannot_error_warning_number_ /** @@ -33,9 +37,13 @@ extern "C" { * This does not alter setting.status. * @param print * Designates the how and where to print. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_fss_status_code_print_error_no_fss_status_codes_ - extern void fss_status_code_print_error_no_fss_status_codes(fss_status_code_setting_t * const setting, const fl_print_t print); + extern f_status_t fss_status_code_print_error_no_fss_status_codes(fss_status_code_setting_t * const setting, const fl_print_t print); #endif // _di_fss_status_code_print_error_no_fss_status_codes_ /** @@ -49,6 +57,7 @@ extern "C" { * * @return * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_fss_status_code_print_help_ extern f_status_t fss_status_code_print_help(fss_status_code_setting_t * const setting, const fl_print_t print); @@ -67,9 +76,13 @@ extern "C" { * @param lock * If TRUE, then lock the stream. * If FALSE, then do not lock or unlock the stream. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_fss_status_code_print_line_first_ - extern void fss_status_code_print_line_first(fss_status_code_setting_t * const setting, const fl_print_t print, const bool lock); + extern f_status_t fss_status_code_print_line_first(fss_status_code_setting_t * const setting, const fl_print_t print, const bool lock); #endif // _di_fss_status_code_print_line_first_ /** @@ -85,9 +98,13 @@ extern "C" { * @param lock * If TRUE, then lock the stream. * If FALSE, then do not lock or unlock the stream. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_fss_status_code_print_line_last_ - extern void fss_status_code_print_line_last(fss_status_code_setting_t * const setting, const fl_print_t print, const bool lock); + extern f_status_t fss_status_code_print_line_last(fss_status_code_setting_t * const setting, const fl_print_t print, const bool lock); #endif // _di_fss_status_code_print_line_last_ #ifdef __cplusplus diff --git a/level_3/iki_read/c/common.c b/level_3/iki_read/c/common.c index a0ccf60..932b8db 100644 --- a/level_3/iki_read/c/common.c +++ b/level_3/iki_read/c/common.c @@ -130,261 +130,13 @@ extern "C" { return; } - - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { iki_read_parameter_from_bytesequence_e, iki_read_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - iki_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == iki_read_parameter_from_bytesequence_e) { - if (setting->mode & iki_read_mode_from_codepoint_e) { - setting->mode -= iki_read_mode_from_codepoint_e; - } - - setting->mode |= iki_read_mode_from_bytesequence_e; - } - else if (choices.array[choice] == iki_read_parameter_from_codepoint_e) { - if (setting->mode & iki_read_mode_from_bytesequence_e) { - setting->mode -= iki_read_mode_from_bytesequence_e; - } - - setting->mode |= iki_read_mode_from_codepoint_e; - } - } - - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { iki_read_parameter_to_bytesequence_e, iki_read_parameter_to_codepoint_e, iki_read_parameter_to_combining_e, iki_read_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - iki_read_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == iki_read_parameter_to_bytesequence_e) { - if (setting->mode & iki_read_mode_to_codepoint_e) { - setting->mode -= iki_read_mode_to_codepoint_e; - } - - if (setting->mode & iki_read_mode_to_combining_e) { - setting->mode -= iki_read_mode_to_combining_e; - } - - if (setting->mode & iki_read_mode_to_width_e) { - setting->mode -= iki_read_mode_to_width_e; - } - - setting->mode |= iki_read_mode_to_bytesequence_e; - } - else if (choices.array[choice] == iki_read_parameter_to_codepoint_e) { - if (setting->mode & iki_read_mode_to_bytesequence_e) { - setting->mode -= iki_read_mode_to_bytesequence_e; - } - - if (setting->mode & iki_read_mode_to_combining_e) { - setting->mode -= iki_read_mode_to_combining_e; - } - - if (setting->mode & iki_read_mode_to_width_e) { - setting->mode -= iki_read_mode_to_width_e; - } - - setting->mode |= iki_read_mode_to_codepoint_e; - } - else if (choices.array[choice] == iki_read_parameter_to_combining_e) { - if (setting->mode & iki_read_mode_to_bytesequence_e) { - setting->mode -= iki_read_mode_to_bytesequence_e; - } - - if (setting->mode & iki_read_mode_to_codepoint_e) { - setting->mode -= iki_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[iki_read_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= iki_read_mode_to_width_e; - } - - setting->mode |= iki_read_mode_to_combining_e; - } - else if (choices.array[choice] == iki_read_parameter_to_width_e) { - if (setting->mode & iki_read_mode_to_bytesequence_e) { - setting->mode -= iki_read_mode_to_bytesequence_e; - } - - if (setting->mode & iki_read_mode_to_codepoint_e) { - setting->mode -= iki_read_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[iki_read_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= iki_read_mode_to_combining_e; - } - - setting->mode |= iki_read_mode_to_width_e; - } - } } f_string_static_t * const args = main->parameters.arguments.array; - if (main->parameters.array[iki_read_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[iki_read_parameter_to_file_e].values.used > 1) { - iki_read_print_error_parameter_file_to_too_many(main, setting); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (args[main->parameters.array[iki_read_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[iki_read_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[iki_read_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[iki_read_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= iki_read_main_flag_file_to_e; - } - else { - iki_read_print_error_parameter_file_name_empty(main, setting, main->parameters.array[iki_read_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); - - return; - } - } - else if (main->parameters.array[iki_read_parameter_to_file_e].result == f_console_result_found_e) { - iki_read_print_error_no_value(main, setting, iki_read_long_to_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - main->output.to = main->message.to; - - if (setting->flag & iki_read_main_flag_file_to_e) { - setting->flag -= iki_read_main_flag_file_to_e; - } - } - - if (main->parameters.array[iki_read_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[iki_read_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; - - setting->path_files_from.used = main->parameters.array[iki_read_parameter_from_file_e].values.used; - - f_array_length_t i = 0; - f_array_length_t index = 0; - - for (; i < setting->path_files_from.used; ++i) { - - index = main->parameters.array[iki_read_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; - - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - iki_read_print_error_parameter_file_not_found(main, setting, F_true, args[index]); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - iki_read_print_error_parameter_file_name_empty(main, setting, index); - - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } - } // for - - if (F_status_is_error(setting->status)) return; - - setting->flag |= iki_read_main_flag_file_from_e; - } - else if (main->parameters.array[iki_read_parameter_from_file_e].result == f_console_result_found_e) { - iki_read_print_error_no_value(main, setting, iki_read_long_from_file_s); - - setting->status = F_status_set_error(F_parameter); - - return; - } - else { - if (setting->flag & iki_read_main_flag_file_from_e) { - setting->flag -= iki_read_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[iki_read_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - iki_read_print_error_no_from(main, setting); - - setting->status = F_status_set_error(F_parameter); - } - - if (!(setting->mode & iki_read_mode_to_bytesequence_e)) { - if (main->parameters.array[iki_read_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[iki_read_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = iki_read_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } - - if (main->parameters.array[iki_read_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= iki_read_main_flag_header_e; - } - - if (main->parameters.array[iki_read_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= iki_read_main_flag_separate_e; - } - if (main->parameters.array[iki_read_parameter_strip_invalid_e].result == f_console_result_found_e) { setting->flag |= iki_read_main_flag_strip_invalid_e; } - - setting->valid_not = main->message.set->error; } #endif // _di_iki_read_setting_load_ diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index 3b03fb6..4628854 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -78,14 +78,14 @@ extern "C" { if (main->parameters.remaining.used > 0 || (main->pipe & fll_program_data_pipe_input_e)) { if (main->parameters.array[iki_read_parameter_at_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_read_long_at_s, main->error.notable); fl_print_format("%[' requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -106,8 +106,8 @@ extern "C" { data.at = number; if (main->parameters.array[iki_read_parameter_whole_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_at_s, iki_read_long_whole_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, iki_read_long_at_s, iki_read_long_whole_s); } status = F_status_set_error(F_parameter); @@ -115,14 +115,14 @@ extern "C" { } if (main->parameters.array[iki_read_parameter_line_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_read_long_line_s, main->error.notable); fl_print_format("%[' requires a positive number.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -144,14 +144,14 @@ extern "C" { } if (main->parameters.array[iki_read_parameter_name_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_read_long_name_s, main->error.notable); fl_print_format("%[' requires a string.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); @@ -159,22 +159,22 @@ extern "C" { if (main->parameters.array[iki_read_parameter_replace_e].result != f_console_result_none_e) { if (main->parameters.array[iki_read_parameter_replace_e].result == f_console_result_found_e || main->parameters.array[iki_read_parameter_replace_e].values.used % 2 != 0) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_read_long_replace_s, main->error.notable); fl_print_format("%[' requires 2 strings.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); } if (main->parameters.array[iki_read_parameter_total_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_replace_s, iki_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, iki_read_long_replace_s, iki_read_long_total_s); } status = F_status_set_error(F_parameter); @@ -183,22 +183,22 @@ extern "C" { if (main->parameters.array[iki_read_parameter_substitute_e].result != f_console_result_none_e) { if (main->parameters.array[iki_read_parameter_substitute_e].result == f_console_result_found_e || main->parameters.array[iki_read_parameter_substitute_e].values.used % 3 != 0) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + f_file_stream_lock(main->error.to); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_read_long_substitute_s, main->error.notable); fl_print_format("%[' requires 3 strings.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + f_file_stream_unlock(main->error.to); } status = F_status_set_error(F_parameter); } if (main->parameters.array[iki_read_parameter_total_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_substitute_s, iki_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, iki_read_long_substitute_s, iki_read_long_total_s); } status = F_status_set_error(F_parameter); @@ -207,24 +207,24 @@ extern "C" { if (main->parameters.array[iki_read_parameter_literal_e].result == f_console_result_found_e) { if (main->parameters.array[iki_read_parameter_object_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_literal_s, iki_read_long_object_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, iki_read_long_literal_s, iki_read_long_object_s); } status = F_status_set_error(F_parameter); } if (main->parameters.array[iki_read_parameter_content_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_literal_s, iki_read_long_content_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, iki_read_long_literal_s, iki_read_long_content_s); } status = F_status_set_error(F_parameter); } if (main->parameters.array[iki_read_parameter_total_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_literal_s, iki_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, iki_read_long_literal_s, iki_read_long_total_s); } status = F_status_set_error(F_parameter); @@ -234,16 +234,16 @@ extern "C" { } else if (main->parameters.array[iki_read_parameter_object_e].result == f_console_result_found_e) { if (main->parameters.array[iki_read_parameter_content_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_object_s, iki_read_long_content_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, iki_read_long_object_s, iki_read_long_content_s); } status = F_status_set_error(F_parameter); } if (main->parameters.array[iki_read_parameter_total_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_object_s, iki_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, iki_read_long_object_s, iki_read_long_total_s); } status = F_status_set_error(F_parameter); @@ -262,8 +262,8 @@ extern "C" { if (main->parameters.array[iki_read_parameter_whole_e].result == f_console_result_found_e) { if (main->parameters.array[iki_read_parameter_total_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_whole_s, iki_read_long_total_s); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, iki_read_long_whole_s, iki_read_long_total_s); } status = F_status_set_error(F_parameter); @@ -271,7 +271,7 @@ extern "C" { } if (F_status_is_error(status)) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); } @@ -407,7 +407,7 @@ extern "C" { } } else { - if (main->error.verbosity != f_console_verbosity_quiet_e) { + if (main->error.verbosity > f_console_verbosity_quiet_e) { fll_print_format("%r%[%QYou failed to specify one or more files.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); } @@ -417,10 +417,10 @@ extern "C" { // Ensure a new line is always put at the end of the program execution, unless in quiet mode. if (main->output.verbosity != f_console_verbosity_quiet_e) { if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + f_file_stream_flush(main->output.to); } - fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); + fll_print_dynamic_raw(f_string_eol_s, main->message.to.stream); } iki_read_data_delete(&data); diff --git a/level_3/iki_write/c/common.c b/level_3/iki_write/c/common.c index 993dc44..6164233 100644 --- a/level_3/iki_write/c/common.c +++ b/level_3/iki_write/c/common.c @@ -13,6 +13,10 @@ extern "C" { const f_string_static_t iki_write_program_name_long_s = macro_f_string_static_t_initialize(IKI_WRITE_program_name_long_s, 0, IKI_WRITE_program_name_long_s_length); #endif // _di_iki_write_program_name_ +#ifndef _di_iki_write_strings_ + const f_string_static_t iki_write_object_s = macro_f_string_static_t_initialize(IKI_WRITE_object_s, 0, IKI_WRITE_object_s_length); +#endif // _di_iki_write_strings_ + #ifndef _di_iki_write_parameters_ const f_string_static_t iki_write_short_file_s = macro_f_string_static_t_initialize(IKI_WRITE_short_file_s, 0, IKI_WRITE_short_file_s_length); const f_string_static_t iki_write_short_content_s = macro_f_string_static_t_initialize(IKI_WRITE_short_content_s, 0, IKI_WRITE_short_content_s_length); @@ -32,6 +36,14 @@ extern "C" { if (!setting) return F_status_set_error(F_parameter); + f_string_dynamic_resize(0, &setting->escaped); + f_string_dynamic_resize(0, &setting->buffer); + f_string_dynamic_resize(0, &setting->object); + f_string_dynamic_resize(0, &setting->content); + + f_string_dynamics_resize(0, &setting->objects); + f_string_dynamics_resize(0, &setting->contents); + return F_none; } #endif // _di_iki_write_setting_delete_ @@ -43,7 +55,14 @@ extern "C" { // Load parameters. setting->status = f_console_parameter_process(arguments, &main->parameters); - if (F_status_is_error(setting->status)) return; + + if (F_status_is_error(setting->status)) { + iki_write_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + iki_write_print_line_last(setting, main->error, F_true); + + return; + } { f_array_length_t choice = 0; @@ -62,6 +81,7 @@ extern "C" { if (F_status_is_error(setting->status)) { iki_write_print_line_first(setting, main->error, F_true); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + iki_write_print_line_last(setting, main->error, F_true); return; } @@ -94,6 +114,7 @@ extern "C" { if (F_status_is_error(setting->status)) { iki_write_print_line_first(setting, main->error, F_true); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + iki_write_print_line_last(setting, main->error, F_true); return; } @@ -110,261 +131,148 @@ extern "C" { return; } + } - // Identify and prioritize "from" mode parameters. - { - uint16_t choices_array[2] = { iki_write_parameter_from_bytesequence_e, iki_write_parameter_from_codepoint_e }; - choices.array = choices_array; - choices.used = 2; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - iki_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } + main->output.to.id = F_type_descriptor_output_d; + main->output.to.stream = F_type_output_d; + main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - if (choices.array[choice] == iki_write_parameter_from_bytesequence_e) { - if (setting->mode & iki_write_mode_from_codepoint_e) { - setting->mode -= iki_write_mode_from_codepoint_e; - } + if (main->parameters.array[iki_write_parameter_file_e].result == f_console_result_additional_e) { + if (main->parameters.array[iki_write_parameter_file_e].values.used > 1) { + setting->status = F_status_set_error(F_parameter); - setting->mode |= iki_write_mode_from_bytesequence_e; - } - else if (choices.array[choice] == iki_write_parameter_from_codepoint_e) { - if (setting->mode & iki_write_mode_from_bytesequence_e) { - setting->mode -= iki_write_mode_from_bytesequence_e; - } + iki_write_print_line_first(setting, main->error, F_true); + fll_program_print_error_parameter_must_specify_once(main->error, f_console_symbol_long_enable_s, iki_write_long_file_s); + iki_write_print_line_last(setting, main->error, F_true); - setting->mode |= iki_write_mode_from_codepoint_e; - } + return; } - // Identify and prioritize "to" mode parameters. - { - uint16_t choices_array[4] = { iki_write_parameter_to_bytesequence_e, iki_write_parameter_to_codepoint_e, iki_write_parameter_to_combining_e, iki_write_parameter_to_width_e }; - choices.array = choices_array; - choices.used = 4; - choice = 1; - - setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); - - if (F_status_is_error(setting->status)) { - iki_write_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - - return; - } - - if (choices.array[choice] == iki_write_parameter_to_bytesequence_e) { - if (setting->mode & iki_write_mode_to_codepoint_e) { - setting->mode -= iki_write_mode_to_codepoint_e; - } - - if (setting->mode & iki_write_mode_to_combining_e) { - setting->mode -= iki_write_mode_to_combining_e; - } + f_string_static_t * const args = main->parameters.arguments.array; - if (setting->mode & iki_write_mode_to_width_e) { - setting->mode -= iki_write_mode_to_width_e; - } + const f_array_length_t index = main->parameters.array[iki_write_parameter_file_e].values.array[0]; - setting->mode |= iki_write_mode_to_bytesequence_e; - } - else if (choices.array[choice] == iki_write_parameter_to_codepoint_e) { - if (setting->mode & iki_write_mode_to_bytesequence_e) { - setting->mode -= iki_write_mode_to_bytesequence_e; - } - - if (setting->mode & iki_write_mode_to_combining_e) { - setting->mode -= iki_write_mode_to_combining_e; - } + main->output.to.id = -1; + main->output.to.stream = 0; - if (setting->mode & iki_write_mode_to_width_e) { - setting->mode -= iki_write_mode_to_width_e; - } + setting->status = f_file_stream_open(args[index], f_string_empty_s, &main->output.to); - setting->mode |= iki_write_mode_to_codepoint_e; - } - else if (choices.array[choice] == iki_write_parameter_to_combining_e) { - if (setting->mode & iki_write_mode_to_bytesequence_e) { - setting->mode -= iki_write_mode_to_bytesequence_e; - } + if (F_status_is_error(setting->status)) { + iki_write_print_line_first(setting, main->error, F_true); + fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[index], f_file_operation_open_s, fll_error_file_type_file_e); + iki_write_print_line_last(setting, main->error, F_true); - if (setting->mode & iki_write_mode_to_codepoint_e) { - setting->mode -= iki_write_mode_to_codepoint_e; - } - - // --to_width may be specified with --to_combining. - if (main->parameters.array[iki_write_parameter_to_width_e].result == f_console_result_found_e) { - setting->mode |= iki_write_mode_to_width_e; - } - - setting->mode |= iki_write_mode_to_combining_e; - } - else if (choices.array[choice] == iki_write_parameter_to_width_e) { - if (setting->mode & iki_write_mode_to_bytesequence_e) { - setting->mode -= iki_write_mode_to_bytesequence_e; - } + return; + } - if (setting->mode & iki_write_mode_to_codepoint_e) { - setting->mode -= iki_write_mode_to_codepoint_e; - } + setting->flag |= iki_write_main_flag_file_to_e; + } + else if (main->parameters.array[iki_write_parameter_file_e].result == f_console_result_found_e) { + setting->status = F_status_set_error(F_parameter); - // --to_width may be specified with --to_combining. - if (main->parameters.array[iki_write_parameter_to_combining_e].result == f_console_result_found_e) { - setting->mode |= iki_write_mode_to_combining_e; - } + iki_write_print_line_first(setting, main->error, F_true); + fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_enable_s, iki_write_long_file_s); + iki_write_print_line_last(setting, main->error, F_true); - setting->mode |= iki_write_mode_to_width_e; - } - } + return; } - f_string_static_t * const args = main->parameters.arguments.array; + if (main->parameters.array[iki_write_parameter_object_e].result == f_console_result_additional_e) { + f_array_lengths_t * const values = &main->parameters.array[iki_write_parameter_object_e].values; - if (main->parameters.array[iki_write_parameter_to_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[iki_write_parameter_to_file_e].values.used > 1) { - iki_write_print_error_parameter_file_to_too_many(main, setting); + setting->objects.used = 0; - setting->status = F_status_set_error(F_parameter); + setting->status = f_string_dynamics_resize(values->used, &setting->objects); + + if (F_status_is_error(setting->status)) { + iki_write_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamics_resize", F_true); + iki_write_print_line_last(setting, main->error, F_true); return; } - if (args[main->parameters.array[iki_write_parameter_to_file_e].values.array[0]].used) { - setting->path_files_to.used = 0; - - setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; - - setting->path_files_to.array[setting->path_files_to.used].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[iki_write_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; - - ++setting->path_files_to.used; - - setting->status = f_file_stream_open(args[main->parameters.array[iki_write_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); + // Construct the array without allocating any more memory by setting this as a static string (used > 0, size = 0). + for (f_array_length_t index = 0; setting->objects.used < values->used; ) { - if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[iki_write_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } + index = values->array[setting->objects.used]; - setting->flag |= iki_write_main_flag_file_to_e; - } - else { - iki_write_print_error_parameter_file_name_empty(main, setting, main->parameters.array[iki_write_parameter_to_file_e].values.array[0]); - - setting->status = F_status_set_error(F_parameter); + setting->objects.array[setting->objects.used].string = main->parameters.arguments.array[index].string; + setting->objects.array[setting->objects.used].used = main->parameters.arguments.array[index].used; + setting->objects.array[setting->objects.used++].size = 0; + } // for - return; - } + setting->flag |= iki_write_main_flag_object_e; } - else if (main->parameters.array[iki_write_parameter_to_file_e].result == f_console_result_found_e) { - iki_write_print_error_no_value(main, setting, iki_write_long_to_file_s); - + else if (main->parameters.array[iki_write_parameter_object_e].result == f_console_result_found_e) { setting->status = F_status_set_error(F_parameter); - return; - } - else { - main->output.to = main->message.to; + iki_write_print_line_first(setting, main->error, F_true); + fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_enable_s, iki_write_long_object_s); + iki_write_print_line_last(setting, main->error, F_true); - if (setting->flag & iki_write_main_flag_file_to_e) { - setting->flag -= iki_write_main_flag_file_to_e; - } + return; } - if (main->parameters.array[iki_write_parameter_from_file_e].result == f_console_result_additional_e) { - setting->path_files_from.used = 0; - - setting->status = f_string_dynamics_increase_by(main->parameters.array[iki_write_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; + if (main->parameters.array[iki_write_parameter_content_e].result == f_console_result_additional_e) { + f_array_lengths_t * const values = &main->parameters.array[iki_write_parameter_content_e].values; - setting->path_files_from.used = main->parameters.array[iki_write_parameter_from_file_e].values.used; + setting->contents.used = 0; - f_array_length_t i = 0; - f_array_length_t index = 0; + setting->status = f_string_dynamics_resize(values->used, &setting->contents); - for (; i < setting->path_files_from.used; ++i) { + if (F_status_is_error(setting->status)) { + iki_write_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamics_resize", F_true); + iki_write_print_line_last(setting, main->error, F_true); - index = main->parameters.array[iki_write_parameter_from_file_e].values.array[i]; - setting->path_files_from.array[i].used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; + return; + } - if (args[index].used) { - if (f_file_exists(args[index], F_true) != F_true) { - iki_write_print_error_parameter_file_not_found(main, setting, F_true, args[index]); + // Construct the array without allocating any more memory by setting this as a static string (used > 0, size = 0). + for (f_array_length_t index = 0; setting->contents.used < values->used; ) { - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_file_found_not); - } - } - } - else { - iki_write_print_error_parameter_file_name_empty(main, setting, index); + index = values->array[setting->contents.used]; - if (F_status_is_error_not(setting->status)) { - setting->status = F_status_set_error(F_parameter); - } - } + setting->contents.array[setting->contents.used].string = main->parameters.arguments.array[index].string; + setting->contents.array[setting->contents.used].used = main->parameters.arguments.array[index].used; + setting->contents.array[setting->contents.used++].size = 0; } // for - if (F_status_is_error(setting->status)) return; - - setting->flag |= iki_write_main_flag_file_from_e; + setting->flag |= iki_write_main_flag_content_e; } - else if (main->parameters.array[iki_write_parameter_from_file_e].result == f_console_result_found_e) { - iki_write_print_error_no_value(main, setting, iki_write_long_from_file_s); - + else if (main->parameters.array[iki_write_parameter_content_e].result == f_console_result_found_e) { setting->status = F_status_set_error(F_parameter); + iki_write_print_line_first(setting, main->error, F_true); + fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_enable_s, iki_write_long_content_s); + iki_write_print_line_last(setting, main->error, F_true); + return; } - else { - if (setting->flag & iki_write_main_flag_file_from_e) { - setting->flag -= iki_write_main_flag_file_from_e; - } - } - - if (F_status_is_error(setting->status)) return; - - if (main->parameters.array[iki_write_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { - iki_write_print_error_no_from(main, setting); + if (!(main->pipe & fll_program_data_pipe_input_e) && !(setting->flag & (iki_write_main_flag_content_e | iki_write_parameter_object_e))) { setting->status = F_status_set_error(F_parameter); - } - if (!(setting->mode & iki_write_mode_to_bytesequence_e)) { - if (main->parameters.array[iki_write_parameter_separate_e].result == f_console_result_found_e || main->parameters.array[iki_write_parameter_headers_e].result == f_console_result_found_e) { - setting->prepend = iki_write_string_prepend_padding_s; - setting->append = f_string_eol_s; - } - else { - setting->prepend = f_string_space_s; - } - } + iki_write_print_line_first(setting, main->error, F_true); + iki_write_print_error_main_missing(setting, main->error); + iki_write_print_line_last(setting, main->error, F_true); - if (main->parameters.array[iki_write_parameter_headers_e].result == f_console_result_found_e) { - setting->flag |= iki_write_main_flag_header_e; + return; } - if (main->parameters.array[iki_write_parameter_separate_e].result == f_console_result_found_e) { - setting->flag |= iki_write_main_flag_separate_e; - } + setting->quote = f_iki_syntax_quote_double_s; - if (main->parameters.array[iki_write_parameter_strip_invalid_e].result == f_console_result_found_e) { - setting->flag |= iki_write_main_flag_strip_invalid_e; + if (main->parameters.array[iki_write_parameter_double_e].result == f_console_result_found_e) { + if (main->parameters.array[iki_write_parameter_single_e].result == f_console_result_found_e) { + if (main->parameters.array[iki_write_parameter_double_e].location < main->parameters.array[iki_write_parameter_single_e].location) { + setting->quote = f_iki_syntax_quote_single_s; + } + } + } + else if (main->parameters.array[iki_write_parameter_single_e].result == f_console_result_found_e) { + setting->quote = f_iki_syntax_quote_single_s; } - - setting->valid_not = main->message.set->error; } #endif // _di_iki_write_setting_load_ diff --git a/level_3/iki_write/c/common.h b/level_3/iki_write/c/common.h index 0da4da3..6d2e6be 100644 --- a/level_3/iki_write/c/common.h +++ b/level_3/iki_write/c/common.h @@ -60,6 +60,17 @@ extern "C" { #endif // _di_iki_write_program_name_ /** + * Special strings used by this program. + */ +#ifndef _di_iki_write_strings_ + #define IKI_WRITE_object_s "object" + + #define IKI_WRITE_object_s_length 6 + + extern const f_string_static_t iki_write_object_s; +#endif // _di_iki_write_strings_ + +/** * The program defines. */ #ifndef _di_iki_write_defines_ @@ -157,26 +168,24 @@ extern "C" { * * iki_write_main_flag_*_e: * - none: No modes in use. - * - file_from: Using a specified source file. + * - content: The Content being written is specified. + * - double: Operate using double quotes. * - file_to: Using a specified destination file. * - help: Print help. - * - header: Enable printing of headers. - * - separate: Enable printing of separators. - * - strip_invalid: Using strip invalid character mode. - * - verify: Using verify mode. + * - object: The Object being written is specified. + * - single: Operate using single quotes. * - version: Print version. */ #ifndef _di_iki_write_main_flag_e_ enum { - iki_write_main_flag_none_e = 0x0, - iki_write_main_flag_file_from_e = 0x1, - iki_write_main_flag_file_to_e = 0x2, - iki_write_main_flag_header_e = 0x4, - iki_write_main_flag_help_e = 0x8, - iki_write_main_flag_separate_e = 0x10, - iki_write_main_flag_strip_invalid_e = 0x20, - iki_write_main_flag_verify_e = 0x40, - iki_write_main_flag_version_e = 0x80, + iki_write_main_flag_none_e = 0x0, + iki_write_main_flag_content_e = 0x1, + iki_write_main_flag_double_e = 0x2, + iki_write_main_flag_file_to_e = 0x4, + iki_write_main_flag_help_e = 0x8, + iki_write_main_flag_object_e = 0x10, + iki_write_main_flag_single_e = 0x20, + iki_write_main_flag_version_e = 0x40, }; #endif // _di_iki_write_main_flag_e_ @@ -192,6 +201,16 @@ extern "C" { * * line_first: A string expected to represent either "\n" or NULL to allow for easy handling of when to print first new line or not. * line_last: A string expected to represent either "\n" or NULL to allow for easy handling of when to print last new line or not. + * + * quote: This holds the quote used during processing. + * + * escaped: A buffer used for escaping strings during processing. + * buffer: A buffer used during processing the file. + * object: A buffer used to hold an Object during processing. + * content: A buffer used to hold a Content during processing. + * + * objects: An array of objects passed as values to the "--object" parameter. + * contents: An array of objects passed as values to the "--content" parameter and must match the length of objects. */ #ifndef _di_iki_write_setting_t_ typedef struct { @@ -201,6 +220,16 @@ extern "C" { f_string_static_t line_first; f_string_static_t line_last; + + f_string_static_t quote; + + f_string_dynamic_t escaped; + f_string_dynamic_t buffer; + f_string_dynamic_t object; + f_string_dynamic_t content; + + f_string_dynamics_t objects; + f_string_dynamics_t contents; } iki_write_setting_t; #define iki_write_setting_t_initialize \ @@ -209,6 +238,12 @@ extern "C" { F_none, \ f_string_static_t_initialize, \ f_string_static_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_string_dynamics_t_initialize, \ + f_string_dynamics_t_initialize, \ } #endif // _di_iki_write_setting_t_ diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index c265da3..0c77860 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -7,396 +7,189 @@ extern "C" { #endif #ifndef _di_iki_write_main_ - f_status_t iki_write_main(fll_program_data_t * const main, iki_write_setting_t * const setting) { + void iki_write_main(fll_program_data_t * const main, iki_write_setting_t * const setting) { - f_status_t status = F_none; + if (!main || !setting || F_status_is_error(setting->status)) return; - // Load parameters. - status = f_console_parameter_process(arguments, &main->parameters); - if (F_status_is_error(status)) return; + setting->status = F_none; - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; - - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { iki_write_parameter_no_color_e, iki_write_parameter_light_e, iki_write_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; - - const uint8_t modes[3] = { f_color_mode_color_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - - status = fll_program_parameter_process_context(choices, modes, F_true, main); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); - - return; - } - } - - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { iki_write_parameter_verbosity_quiet_e, iki_write_parameter_verbosity_error_e, iki_write_parameter_verbosity_verbose_e, iki_write_parameter_verbosity_debug_e, iki_write_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; - - const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - - status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); - - return; - } - } - } - - iki_write_data_t data = iki_write_data_t_initialize; - data.main = main; - data.argv = main->parameters.arguments.array; - - status = F_none; - - if (main->parameters.array[iki_write_parameter_help_e].result == f_console_result_found_e) { + if (setting->flag & iki_write_main_flag_help_e) { iki_write_print_help(setting, main->message); - iki_write_data_delete(&data); - - return F_none; + return; } - if (main->parameters.array[iki_write_parameter_version_e].result == f_console_result_found_e) { + if (setting->flag & iki_write_main_flag_version_e) { fll_program_print_version(main->message, iki_write_program_version_s); - iki_write_data_delete(&data); - - return F_none; + return; } - f_file_t file = f_file_t_initialize; + setting->escaped.used = 0; - file.id = F_type_descriptor_output_d; - file.stream = F_type_output_d; - file.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->pipe & fll_program_data_pipe_input_e) { + bool object_ended = F_false; - if (F_status_is_error_not(status)) { - if (main->parameters.array[iki_write_parameter_file_e].result == f_console_result_additional_e) { - if (main->parameters.array[iki_write_parameter_file_e].values.used > 1) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + f_array_length_t previous = 0; + f_string_range_t range = f_string_range_t_initialize; + f_status_t status = F_none; + f_file_t pipe = f_file_t_initialize; - fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_write_long_file_s, main->error.notable); - fl_print_format("%[' may only be specified once.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); + pipe.id = F_type_descriptor_input_d; + pipe.size_read = 1; - funlockfile(main->error.to.stream); - } + setting->buffer.used = 0; + setting->object.used = 0; + setting->content.used = 0; - status = F_status_set_error(F_parameter); - } - else { - const f_array_length_t index = main->parameters.array[iki_write_parameter_file_e].values.array[0]; + range.start = 0; - file.id = -1; - file.stream = 0; + do { + if (!((++main->signal_check) % iki_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + setting->status = F_status_set_error(F_interrupt); - status = f_file_stream_open(data.argv[index], f_string_empty_s, &file); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, data.argv[index], f_file_operation_open_s, fll_error_file_type_file_e); + return; } - } - } - else if (main->parameters.array[iki_write_parameter_file_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_write_long_file_s, main->error.notable); - fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - funlockfile(main->error.to.stream); + main->signal_check = 0; } - status = F_status_set_error(F_parameter); - } - } - - if (F_status_is_error_not(status) && main->parameters.array[iki_write_parameter_object_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_write_long_object_s, main->error.notable); - fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - - funlockfile(main->error.to.stream); - } - - status = F_status_set_error(F_parameter); - } + if (status != F_none_eof) { + status = f_file_read(pipe, &setting->buffer); - if (F_status_is_error_not(status) && main->parameters.array[iki_write_parameter_content_e].result == f_console_result_found_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + if (F_status_is_error(status)) { + setting->status = F_status_set_error(F_pipe); - fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_write_long_content_s, main->error.notable); - fl_print_format("%[' is specified, but no value is given.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); + iki_write_print_line_first(setting, main->error, F_true); + fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_read", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); + iki_write_print_line_last(setting, main->error, F_true); - funlockfile(main->error.to.stream); - } + return; + } - status = F_status_set_error(F_parameter); - } + if (!setting->buffer.used) { + setting->status = F_status_set_error(F_parameter); - if (F_status_is_error_not(status) && !(main->pipe & fll_program_data_pipe_input_e)) { - if (main->parameters.array[iki_write_parameter_object_e].result != f_console_result_additional_e && main->parameters.array[iki_write_parameter_content_e].result != f_console_result_additional_e) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); + iki_write_print_line_first(setting, main->error, F_true); + fll_program_print_error_pipe_missing_content(main->error); + iki_write_print_line_last(setting, main->error, F_true); - fl_print_format("%r%[%QNo main provided, either pipe the main or use the '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_write_long_object_s, main->error.notable); - fl_print_format("%[' and the '%]", main->error.to.stream, main->error.context, main->error.context); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_write_long_content_s, main->error.notable); - fl_print_format("%[' parameters.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); + return; + } - funlockfile(main->error.to.stream); + range.stop = setting->buffer.used - 1; } - status = F_status_set_error(F_parameter); - } - } + previous = range.start; + setting->status = f_string_dynamic_seek_to(setting->buffer, f_string_ascii_feed_form_s.string[0], &range); - if (F_status_is_error_not(status)) { - if (main->parameters.array[iki_write_parameter_object_e].values.used != main->parameters.array[iki_write_parameter_content_e].values.used) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QThe parameters '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_write_long_content_s, main->error.notable); - fl_print_format("%[' and '%]", main->error.to.stream, main->error.context, main->error.context); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_write_long_object_s, main->error.notable); - fl_print_format("%[' must be specified the same number of times.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - - funlockfile(main->error.to.stream); + if (setting->status == F_data_not_stop) { + setting->status = F_status_set_error(F_parameter); } - status = F_status_set_error(F_parameter); - } - } + if (F_status_is_error(setting->status)) { + iki_write_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_seek_to", F_true); + iki_write_print_line_last(setting, main->error, F_true); - data.quote = f_iki_syntax_quote_double_s; - - if (F_status_is_error_not(status)) { - if (main->parameters.array[iki_write_parameter_double_e].result == f_console_result_found_e) { - if (main->parameters.array[iki_write_parameter_single_e].result == f_console_result_found_e) { - if (main->parameters.array[iki_write_parameter_double_e].location < main->parameters.array[iki_write_parameter_single_e].location) { - data.quote = f_iki_syntax_quote_single_s; - } + return; } - } - else if (main->parameters.array[iki_write_parameter_single_e].result == f_console_result_found_e) { - data.quote = f_iki_syntax_quote_single_s; - } - } - - if (F_status_is_error_not(status)) { - f_string_dynamic_t escaped = f_string_dynamic_t_initialize; - - if (main->pipe & fll_program_data_pipe_input_e) { - f_file_t pipe = f_file_t_initialize; - - pipe.id = F_type_descriptor_input_d; - pipe.size_read = 1; - - f_string_dynamic_t buffer = f_string_dynamic_t_initialize; - f_string_dynamic_t object = f_string_dynamic_t_initialize; - f_string_dynamic_t content = f_string_dynamic_t_initialize; - bool object_ended = F_false; + if (object_ended && previous == range.start) { + setting->status = F_status_set_error(F_parameter); - f_array_length_t previous = 0; - f_string_range_t range = f_string_range_t_initialize; + iki_write_print_line_first(setting, main->error, F_true); + fll_program_print_error_pipe_invalid_form_feed(main->error); + iki_write_print_line_last(setting, main->error, F_true); - range.start = 0; - - for (f_status_t status_pipe = F_none; ; ) { - - if (!((++main->signal_check) % iki_write_signal_check_d)) { - if (fll_program_standard_signal_received(main)) { - status = F_status_set_error(F_interrupt); - - break; - } - - main->signal_check = 0; - } - - if (status_pipe != F_none_eof) { - status_pipe = f_file_read(pipe, &buffer); - - if (F_status_is_error(status_pipe)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read_to", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); - - status = F_status_set_error(F_pipe); - - break; - } - - if (!buffer.used) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_print_format("%r%[%QThe pipe has no content.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); - } - - status = F_status_set_error(F_parameter); - - break; - } - - range.stop = buffer.used - 1; - } - - previous = range.start; - status = f_string_dynamic_seek_to(buffer, f_string_ascii_feed_form_s.string[0], &range); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_seek_to", F_true); - - break; - } - - if (status == F_data_not_stop) { - status = F_status_set_error(F_parameter); - - fll_error_print(main->error, F_parameter, "f_string_dynamic_seek_line", F_true); - - break; - } - - if (object_ended && previous == range.start) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_print_format("%r%[%QThe pipe has incorrectly placed form-feed characters (\\f).%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); - } - - status = F_status_set_error(F_parameter); - - break; - } + return; + } - range.stop = range.start - 1; - range.start = previous; + range.stop = range.start - 1; + range.start = previous; - if (object_ended) { - content.used = 0; + if (object_ended) { + setting->content.used = 0; - if (buffer.used) { - status = f_string_dynamic_partial_append_nulless(buffer, range, &content); + if (setting->buffer.used) { + setting->status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->content); - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true); + if (F_status_is_error(setting->status)) { + iki_write_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_partial_append_nulless", F_true); + iki_write_print_line_last(setting, main->error, F_true); - break; - } + return; } - - status = iki_write_process(&data, file, object, content, &escaped); - if (F_status_is_error(status)) break; - - fll_print_dynamic_raw(f_string_eol_s, file.stream); - - object_ended = F_false; } - else { - object.used = 0; - status = f_string_dynamic_partial_append_nulless(buffer, range, &object); + setting->status = iki_write_process(main, setting, setting->object, setting->content); + if (F_status_is_error(setting->status)) return; - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true); + fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); - break; - } - - object_ended = F_true; - } - - // Restore the range, positioned after the new line. - range.start = range.stop + 2; - range.stop = buffer.used - 1; + object_ended = F_false; + } + else { + setting->object.used = 0; - // only clear the buffer and reset the start when the entire buffer has been processed. - if (range.start > range.stop) { - range.start = 0; - buffer.used = 0; - } + setting->status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->object); - if (status_pipe == F_none_eof && !buffer.used && !object_ended) break; - } // for + if (F_status_is_error(setting->status)) { + iki_write_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_partial_append_nulless", F_true); + iki_write_print_line_last(setting, main->error, F_true); - if (F_status_is_error_not(status) && object_ended) { - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_print_format("%r%[%QThe pipe has an object without content.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); + return; } - status = F_status_set_error(F_parameter); + object_ended = F_true; } - f_string_dynamic_resize(0, &buffer); - f_string_dynamic_resize(0, &object); - f_string_dynamic_resize(0, &content); - } + // Restore the range, positioned after the new line. + range.start = range.stop + 2; + range.stop = setting->buffer.used - 1; - if (F_status_is_error_not(status)) { - for (f_array_length_t i = 0; i < main->parameters.array[iki_write_parameter_object_e].values.used; ++i) { - - if (!((++main->signal_check) % iki_write_signal_check_d)) { - if (fll_program_standard_signal_received(main)) { - status = F_status_set_error(F_interrupt); + // Only clear the buffer and reset the start when the entire buffer has been processed. + if (range.start > range.stop) { + range.start = 0; + setting->buffer.used = 0; + } - break; - } + } while (status != F_none_eof || setting->buffer.used || object_ended); - main->signal_check = 0; - } + if (object_ended) { + setting->status = F_status_set_error(F_parameter); - status = iki_write_process(&data, file, data.argv[main->parameters.array[iki_write_parameter_object_e].values.array[i]], data.argv[main->parameters.array[iki_write_parameter_content_e].values.array[i]], &escaped); - if (F_status_is_error(status)) break; + iki_write_print_line_first(setting, main->error, F_true); + fll_program_print_error_pipe_object_without_content(main->error); + iki_write_print_line_last(setting, main->error, F_true); - fll_print_dynamic_raw(f_string_eol_s, file.stream); - } // for - - // Ensure there is always a new line at the end, unless in quiet mode. - if (F_status_is_error_not(status) && main->error.verbosity != f_console_verbosity_quiet_e && main->error.verbosity != f_console_verbosity_error_e && main->parameters.array[iki_write_parameter_file_e].result == f_console_result_none_e) { - fll_print_dynamic_raw(f_string_eol_s, file.stream); - } + return; } - - f_string_dynamic_resize(0, &escaped); } - if (main->parameters.array[iki_write_parameter_file_e].result == f_console_result_additional_e) { - f_file_stream_flush(output); - f_file_stream_close(&file); - } + for (f_array_length_t i = 0; i < setting->objects.used; ++i) { - // Ensure a new line is always put at the end of the program execution, unless in quiet mode. - if (main->error.verbosity != f_console_verbosity_quiet_e) { - if (F_status_is_error(status)) { - if (F_status_set_fine(status) == F_interrupt) { - fflush(main->output.to.stream); + if (!((++main->signal_check) % iki_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + setting->status = F_status_set_error(F_interrupt); + + return; } - fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); + main->signal_check = 0; } - } - iki_write_data_delete(&data); + setting->status = iki_write_process(main, setting, setting->objects.array[i], setting->contents.array[i]); + if (F_status_is_error(setting->status)) return; + + fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); + } // for - return status; + // Ensure a new line is always put at the end of the program execution, unless in quiet mode. + iki_write_print_line_last(setting, main->message, F_true); } #endif // _di_iki_write_main_ diff --git a/level_3/iki_write/c/iki_write.h b/level_3/iki_write/c/iki_write.h index 3251550..6857588 100644 --- a/level_3/iki_write/c/iki_write.h +++ b/level_3/iki_write/c/iki_write.h @@ -52,6 +52,7 @@ // IKI Write includes. #include +#include #ifdef __cplusplus extern "C" { @@ -82,7 +83,7 @@ extern "C" { * F_parameter (with error bit) if main is NULL or setting is NULL. */ #ifndef _di_iki_write_main_ - extern f_status_t iki_write_main(fll_program_data_t * const main, iki_write_setting_t * const setting); + extern void iki_write_main(fll_program_data_t * const main, iki_write_setting_t * const setting); #endif // _di_iki_write_main_ #ifdef __cplusplus diff --git a/level_3/iki_write/c/main.c b/level_3/iki_write/c/main.c index fa672df..b4dfcf8 100644 --- a/level_3/iki_write/c/main.c +++ b/level_3/iki_write/c/main.c @@ -30,5 +30,5 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { fll_program_standard_set_down(&data); - return F_status_is_error(status) ? 1 : 0; + return F_status_is_error(setting.status) ? 1 : 0; } diff --git a/level_3/iki_write/c/print.c b/level_3/iki_write/c/print.c index 0249187..9c0ac56 100644 --- a/level_3/iki_write/c/print.c +++ b/level_3/iki_write/c/print.c @@ -33,6 +33,9 @@ extern "C" { fll_program_print_help_option(print, iki_write_short_object_s, iki_write_long_object_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " The Object to write."); fll_program_print_help_option(print, iki_write_short_single_s, iki_write_long_single_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Use single quotes."); + f_print_dynamic_raw(f_string_eol_s, print.to.stream); + f_print_dynamic_raw(f_string_eol_s, print.to.stream); + fll_program_print_help_usage(print, iki_write_program_name_s, f_string_empty_s); fl_print_format("%r %[Notes:%]%r", print.to.stream, f_string_eol_s, print.set->important, print.set->important, f_string_eol_s); @@ -53,9 +56,9 @@ extern "C" { #endif // _di_iki_write_print_help_ #ifndef _di_iki_write_print_line_first_ - void iki_write_print_line_first(iki_write_setting_t * const setting, const fl_print_t print, const bool lock) { + f_status_t iki_write_print_line_first(iki_write_setting_t * const setting, const fl_print_t print, const bool lock) { - if (print.verbosity == f_console_verbosity_quiet_e) return; + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; if (lock) { fll_print_dynamic_raw(setting->line_first, print.to.stream); @@ -63,16 +66,16 @@ extern "C" { else { f_print_dynamic_raw(setting->line_first, print.to.stream); } + + return F_none; } #endif // _di_iki_write_print_line_first_ #ifndef _di_iki_write_print_line_last_ - void iki_write_print_line_last(iki_write_setting_t * const setting, const fl_print_t print, const bool lock) { + f_status_t iki_write_print_line_last(iki_write_setting_t * const setting, const fl_print_t print, const bool lock) { - if (print.verbosity == f_console_verbosity_quiet_e) return; - if (print.verbosity == f_console_verbosity_error_e && !F_status_is_error(setting->status)) return; - if (setting->flag & iki_write_main_flag_verify_e) return; - if ((setting->flag & iki_write_main_flag_file_to_e) && !F_status_is_error(setting->status)) return; + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + if (print.verbosity == f_console_verbosity_error_e && !F_status_is_error(setting->status)) return F_output_not; if (lock) { fll_print_dynamic_raw(setting->line_last, print.to.stream); @@ -80,9 +83,47 @@ extern "C" { else { f_print_dynamic_raw(setting->line_last, print.to.stream); } + + return F_none; } #endif // _di_iki_write_print_line_last_ +#ifndef _di_iki_write_print_error_main_missing_ + f_status_t iki_write_print_error_main_missing(iki_write_setting_t * const setting, const fl_print_t print) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QNo main provided, either pipe the main data or use the '%]", print.to.stream, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%r%r%]", print.to.stream, print.set->notable, f_console_symbol_long_enable_s, iki_write_long_object_s, print.set->notable); + fl_print_format("%[' and the '%]", print.to.stream, print.set->error, print.set->error); + fl_print_format("%[%r%r%]", print.to.stream, print.set->notable, f_console_symbol_long_enable_s, iki_write_long_content_s, print.set->notable); + fl_print_format("%[' parameters.%]%r", print.to.stream, print.set->error, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_iki_write_print_error_main_missing_ + +#ifndef _di_iki_write_print_error_object_not_valid_ + f_status_t iki_write_print_error_object_not_valid(iki_write_setting_t * const setting, const fl_print_t print, const f_string_static_t object) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QThe object '%]", print.to.stream, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%Q%]", print.to.stream, print.set->notable, object, print.set->notable); + fl_print_format("%[' is not a valid IKI Object.%]%r", print.to.stream, print.set->error, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_iki_write_print_error_object_not_valid_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_write/c/print.h b/level_3/iki_write/c/print.h index 7d27db1..fd08013 100644 --- a/level_3/iki_write/c/print.h +++ b/level_3/iki_write/c/print.h @@ -23,6 +23,7 @@ extern "C" { * * @return * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_iki_write_print_help_ extern f_status_t iki_write_print_help(iki_write_setting_t * const setting, const fl_print_t print); @@ -41,9 +42,13 @@ extern "C" { * @param lock * If TRUE, then lock the stream. * If FALSE, then do not lock or unlock the stream. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_iki_write_print_line_first_ - extern void iki_write_print_line_first(iki_write_setting_t * const setting, const fl_print_t print, const bool lock); + extern f_status_t iki_write_print_line_first(iki_write_setting_t * const setting, const fl_print_t print, const bool lock); #endif // _di_iki_write_print_line_first_ /** @@ -59,11 +64,51 @@ extern "C" { * @param lock * If TRUE, then lock the stream. * If FALSE, then do not lock or unlock the stream. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_iki_write_print_line_last_ - extern void iki_write_print_line_last(iki_write_setting_t * const setting, const fl_print_t print, const bool lock); + extern f_status_t iki_write_print_line_last(iki_write_setting_t * const setting, const fl_print_t print, const bool lock); #endif // _di_iki_write_print_line_last_ +/** + * Print error message about "main" Object being missing. + * + * @param setting + * The main program settings. + * This does not alter setting.status. + * @param print + * Designates the how and where to print. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_iki_write_print_error_main_missing_ + extern f_status_t iki_write_print_error_main_missing(iki_write_setting_t * const setting, const fl_print_t print); +#endif // _di_iki_write_print_error_main_missing_ + +/** + * Print error message about an Object not being valid. + * + * @param setting + * The main program settings. + * This does not alter setting.status. + * @param print + * Designates the how and where to print. + * @param object + * The a string representing the object that is missing. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_iki_write_print_error_object_not_valid_ + extern f_status_t iki_write_print_error_object_not_valid(iki_write_setting_t * const setting, const fl_print_t print, const f_string_static_t object); +#endif // _di_iki_write_print_error_object_not_valid_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_write/c/private-common.c b/level_3/iki_write/c/private-common.c index a14b2d9..f860d81 100644 --- a/level_3/iki_write/c/private-common.c +++ b/level_3/iki_write/c/private-common.c @@ -5,13 +5,6 @@ extern "C" { #endif -#ifndef _di_iki_write_data_delete_ - void iki_write_data_delete(iki_write_data_t *data) { - - // Nothing to deallocate. - } -#endif // _di_iki_write_data_delete_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_write/c/private-common.h b/level_3/iki_write/c/private-common.h index 54c0945..b84006a 100644 --- a/level_3/iki_write/c/private-common.h +++ b/level_3/iki_write/c/private-common.h @@ -13,29 +13,6 @@ extern "C" { #endif /** - * The program data. - * - * argv: The argument structure in the progam data parameters for simplifying syntax. - * main: The main program data. - * quote: The quote to use when writing. - */ -#ifndef _di_iki_write_data_t_ - typedef struct { - fll_program_data_t *main; - f_string_static_t *argv; - - f_string_static_t quote; - } iki_write_data_t; - - #define iki_write_data_t_initialize \ - { \ - 0, \ - 0, \ - f_string_static_t_initialize, \ - } -#endif // _di_iki_write_data_t_ - -/** * Provide common/generic definitions. * * iki_write_common_allocation_*: @@ -47,19 +24,6 @@ extern "C" { #define iki_write_common_allocation_small_d 16 #endif // _di_iki_write_common_ -/** - * Deallocate program data. - * - * @param data - * The program data. - * - * @return - * F_none on success. - */ -#ifndef _di_iki_write_data_delete_ - extern void iki_write_data_delete(iki_write_data_t *data) F_attribute_visibility_internal_d; -#endif // _di_iki_write_data_delete_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_write/c/private-write.c b/level_3/iki_write/c/private-write.c index 8e5db8f..8036182 100644 --- a/level_3/iki_write/c/private-write.c +++ b/level_3/iki_write/c/private-write.c @@ -7,18 +7,10 @@ extern "C" { #endif #ifndef _di_iki_write_process_ - f_status_t iki_write_process(fll_program_data_t * const main, status_code_setting_t * const setting, iki_write_data_t * const data, const f_file_t output, const f_string_static_t object, const f_string_static_t content, f_string_dynamic_t *escaped) { + f_status_t iki_write_process(fll_program_data_t * const main, iki_write_setting_t * const setting, const f_string_static_t object, const f_string_static_t content) { if (!object.used) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(data->main->error.to.stream); - - fl_print_format("%r%[%QThe object is missing, it must not have a length of %]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); - fl_print_format("%[0%]", data->main->error.to.stream, data->main->error.notable, data->main->error.notable); - fl_print_format("%[.%]%r", data->main->error.to.stream, data->main->error.context, data->main->error.context, f_string_eol_s); - - funlockfile(data->main->error.to.stream); - } + fll_program_print_error_missing_variable_not_zero(main->error, iki_write_object_s); return F_status_set_error(F_failure); } @@ -26,35 +18,28 @@ extern "C" { f_status_t status = f_iki_object_is(object); if (status == F_false) { - if (data->main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(data->main->error.to.stream); - - fl_print_format("%r%[%QThe object '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); - fl_print_format("%[%Q%]", data->main->error.to.stream, data->main->error.notable, object, data->main->error.notable); - fl_print_format("%[' is not a valid IKI object.%]%r", data->main->error.to.stream, data->main->error.context, data->main->error.context, f_string_eol_s); - - funlockfile(data->main->error.to.stream); - } + iki_write_print_error_object_not_valid(setting, main->error, object); return F_status_set_error(F_failure); } - else if (F_status_is_error(status)) { - fll_error_print(data->main->error, F_status_set_fine(status), "f_iki_object_is", F_true); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_iki_object_is", F_true); return F_status_set_error(F_failure); } - escaped->used = 0; + setting->escaped.used = 0; - status = fll_iki_content_escape(content, data->quote, escaped); + status = fll_iki_content_escape(content, setting->quote, &setting->escaped); if (F_status_is_error(status)) { - fll_error_print(data->main->error, F_status_set_fine(status), "fll_iki_content_escape", F_true); + fll_error_print(main->error, F_status_set_fine(status), "fll_iki_content_escape", F_true); return F_status_set_error(F_failure); } - fl_print_format("%Q%r%r%Q%r", output, object, f_iki_syntax_separator_s, data->quote, *escaped, data->quote); + fl_print_format("%Q%r%r%Q%r", main->output.to.stream, object, f_iki_syntax_separator_s, setting->quote, setting->escaped, setting->quote); return F_none; } diff --git a/level_3/iki_write/c/private-write.h b/level_3/iki_write/c/private-write.h index 1743b9b..266882a 100644 --- a/level_3/iki_write/c/private-write.h +++ b/level_3/iki_write/c/private-write.h @@ -15,23 +15,22 @@ extern "C" { /** * Process a given object and content, printing the IKI if valid or an error if invalid. * - * @param data - * The program data. - * @param output - * The file to output to. + * @param main + * The main program data. + * @param setting + * The main program settings. * @param object * The object to validate and print. * @param content * The content to escape and print. - * @param escaped - * A string buffer used as a string cache to save the string into while escaping. * * @return * F_none on success. + * * F_failure (with error bit) for any othe failure. */ #ifndef _di_iki_write_process_ - extern f_status_t iki_write_process(fll_program_data_t * const main, status_code_setting_t * const setting, iki_write_data_t * const data, const f_file_t output, const f_string_static_t object, const f_string_static_t content, f_string_dynamic_t *escaped) F_attribute_visibility_internal_d; + extern f_status_t iki_write_process(fll_program_data_t * const main, iki_write_setting_t * const setting, const f_string_static_t object, const f_string_static_t content) F_attribute_visibility_internal_d; #endif // _di_iki_write_process_ #ifdef __cplusplus diff --git a/level_3/status_code/c/common.c b/level_3/status_code/c/common.c index f646606..d450687 100644 --- a/level_3/status_code/c/common.c +++ b/level_3/status_code/c/common.c @@ -55,7 +55,14 @@ extern "C" { // Load parameters. setting->status = f_console_parameter_process(arguments, &main->parameters); - if (F_status_is_error(setting->status)) return; + + if (F_status_is_error(setting->status)) { + status_code_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + status_code_print_line_last(setting, main->error, F_true); + + return; + } { f_array_length_t choice = 0; @@ -145,43 +152,43 @@ extern "C" { if (setting->flag & status_code_main_flag_error_e) { if (setting->flag & status_code_main_flag_warning_e) { if (!(setting->flag & status_code_main_flag_number_e)) { + setting->status = F_status_set_error(F_parameter); + status_code_print_line_first(setting, main->error, F_true); status_code_print_error_cannot_error_warning_number(setting, main->error); status_code_print_line_last(setting, main->error, F_true); - setting->status = F_status_set_error(F_parameter); - return; } } if (setting->flag & status_code_main_flag_fine_e) { + setting->status = F_status_set_error(F_parameter); + status_code_print_line_first(setting, main->error, F_true); - fll_program_parameter_long_print_cannot_use_with(main->error, status_code_long_error_s, status_code_long_fine_s); + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, status_code_long_error_s, status_code_long_fine_s); status_code_print_line_last(setting, main->error, F_true); - setting->status = F_status_set_error(F_parameter); - return; } } else if (setting->flag & status_code_main_flag_warning_e && setting->flag & status_code_main_flag_fine_e) { + setting->status = F_status_set_error(F_parameter); + status_code_print_line_first(setting, main->error, F_true); - fll_program_parameter_long_print_cannot_use_with(main->error, status_code_long_warning_s, status_code_long_fine_s); + fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_enable_s, status_code_long_warning_s, status_code_long_fine_s); status_code_print_line_last(setting, main->error, F_true); - setting->status = F_status_set_error(F_parameter); - return; } if (main->parameters.remaining.used == 0 && !(main->pipe & fll_program_data_pipe_input_e)) { + setting->status = F_status_set_error(F_parameter); + status_code_print_line_first(setting, main->error, F_true); status_code_print_error_no_status_codes(setting, main->error); status_code_print_line_last(setting, main->error, F_true); - setting->status = F_status_set_error(F_parameter); - return; } } diff --git a/level_3/status_code/c/print.c b/level_3/status_code/c/print.c index d28b8b1..29c5537 100644 --- a/level_3/status_code/c/print.c +++ b/level_3/status_code/c/print.c @@ -7,9 +7,9 @@ extern "C" { #endif #ifndef _di_status_code_print_error_cannot_error_warning_number_ - void status_code_print_error_cannot_error_warning_number(status_code_setting_t * const setting, const fl_print_t print) { + f_status_t status_code_print_error_cannot_error_warning_number(status_code_setting_t * const setting, const fl_print_t print) { - if (print.verbosity == f_console_verbosity_quiet_e) return; + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; f_file_stream_lock(print.to); @@ -22,15 +22,19 @@ extern "C" { fl_print_format("%[' parameter.%]%r", print.to.stream, print.context, print.context, f_string_eol_s); f_file_stream_unlock(print.to); + + return F_none; } #endif // _di_status_code_print_error_cannot_error_warning_number_ #ifndef _di_status_code_print_error_no_status_codes_ - void status_code_print_error_no_status_codes(status_code_setting_t * const setting, const fl_print_t print) { + f_status_t status_code_print_error_no_status_codes(status_code_setting_t * const setting, const fl_print_t print) { - if (print.verbosity == f_console_verbosity_quiet_e) return; + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; fll_print_format("%[No status code is specified.%]%r", print.to.stream, print.context, print.context, f_string_eol_s); + + return F_none; } #endif // _di_status_code_print_error_no_status_codes_ @@ -52,6 +56,9 @@ extern "C" { fll_program_print_help_option(print, status_code_short_error_s, status_code_long_error_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print F_true or F_false if status code is an error or print number with error code bit set."); fll_program_print_help_option(print, status_code_short_number_s, status_code_long_number_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Convert status code name to number."); + f_print_dynamic_raw(f_string_eol_s, print.to.stream); + f_print_dynamic_raw(f_string_eol_s, print.to.stream); + fll_program_print_help_usage(print, status_code_program_name_s, status_code_program_help_parameters_s); f_print_dynamic_raw(setting->line_last, print.to.stream); @@ -64,9 +71,9 @@ extern "C" { #endif // _di_status_code_print_help_ #ifndef _di_status_code_print_line_first_ - void status_code_print_line_first(status_code_setting_t * const setting, const fl_print_t print, const bool lock) { + f_status_t status_code_print_line_first(status_code_setting_t * const setting, const fl_print_t print, const bool lock) { - if (print.verbosity == f_console_verbosity_quiet_e) return; + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; if (lock) { fll_print_dynamic_raw(setting->line_first, print.to.stream); @@ -74,14 +81,16 @@ extern "C" { else { f_print_dynamic_raw(setting->line_first, print.to.stream); } + + return F_none; } #endif // _di_status_code_print_line_first_ #ifndef _di_status_code_print_line_last_ - void status_code_print_line_last(status_code_setting_t * const setting, const fl_print_t print, const bool lock) { + f_status_t status_code_print_line_last(status_code_setting_t * const setting, const fl_print_t print, const bool lock) { - if (print.verbosity == f_console_verbosity_quiet_e) return; - if (print.verbosity == f_console_verbosity_error_e && !F_status_is_error(setting->status)) return; + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + if (print.verbosity == f_console_verbosity_error_e && !F_status_is_error(setting->status)) return F_output_not; if (lock) { fll_print_dynamic_raw(setting->line_last, print.to.stream); @@ -89,6 +98,8 @@ extern "C" { else { f_print_dynamic_raw(setting->line_last, print.to.stream); } + + return F_none; } #endif // _di_status_code_print_line_last_ diff --git a/level_3/status_code/c/print.h b/level_3/status_code/c/print.h index e541062..99513e9 100644 --- a/level_3/status_code/c/print.h +++ b/level_3/status_code/c/print.h @@ -20,9 +20,13 @@ extern "C" { * This does not alter setting.status. * @param print * Designates the how and where to print. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_status_code_print_error_cannot_error_warning_number_ - extern void status_code_print_error_cannot_error_warning_number(status_code_setting_t * const setting, const fl_print_t print); + extern f_status_t status_code_print_error_cannot_error_warning_number(status_code_setting_t * const setting, const fl_print_t print); #endif // _di_status_code_print_error_cannot_error_warning_number_ /** @@ -33,9 +37,13 @@ extern "C" { * This does not alter setting.status. * @param print * Designates the how and where to print. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_status_code_print_error_no_status_codes_ - extern void status_code_print_error_no_status_codes(status_code_setting_t * const setting, const fl_print_t print); + extern f_status_t status_code_print_error_no_status_codes(status_code_setting_t * const setting, const fl_print_t print); #endif // _di_status_code_print_error_no_status_codes_ /** @@ -49,6 +57,7 @@ extern "C" { * * @return * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_status_code_print_help_ extern f_status_t status_code_print_help(status_code_setting_t * const setting, const fl_print_t print); @@ -67,9 +76,13 @@ extern "C" { * @param lock * If TRUE, then lock the stream. * If FALSE, then do not lock or unlock the stream. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_status_code_print_line_first_ - extern void status_code_print_line_first(status_code_setting_t * const setting, const fl_print_t print, const bool lock); + extern f_status_t status_code_print_line_first(status_code_setting_t * const setting, const fl_print_t print, const bool lock); #endif // _di_status_code_print_line_first_ /** @@ -85,9 +98,13 @@ extern "C" { * @param lock * If TRUE, then lock the stream. * If FALSE, then do not lock or unlock the stream. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_status_code_print_line_last_ - extern void status_code_print_line_last(status_code_setting_t * const setting, const fl_print_t print, const bool lock); + extern f_status_t status_code_print_line_last(status_code_setting_t * const setting, const fl_print_t print, const bool lock); #endif // _di_status_code_print_line_last_ #ifdef __cplusplus diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index 94fe552..8e3a00d 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -9,17 +9,7 @@ extern "C" { #ifndef _di_status_code_main_ void status_code_main(fll_program_data_t * const main, status_code_setting_t * const setting) { - if (!main || !setting) { - status_code_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_parameter, "status_code_main", F_true); - status_code_print_line_last(setting, main->error, F_true); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (F_status_is_error(setting->status)) return; + if (!main || !setting || F_status_is_error(setting->status)) return; setting->status = F_none; @@ -39,7 +29,7 @@ extern "C" { if (setting->flag & status_code_main_flag_number_e) { if (main->pipe & fll_program_data_pipe_input_e) { - // @todo call status_code_process_number() here for all main from pipe that is space separated. + // @todo call status_code_process_number() here for all main from pipe that are space separated. } if (main->parameters.remaining.used) { @@ -51,9 +41,9 @@ extern "C" { if (fll_program_standard_signal_received(main)) { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - setting->status = F_status_set_error(F_signal); + setting->status = F_status_set_error(F_interrupt); - break; + return; } main->signal_check = 0; @@ -83,9 +73,9 @@ extern "C" { if (fll_program_standard_signal_received(main)) { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - setting->status = F_status_set_error(F_signal); + setting->status = F_status_set_error(F_interrupt); - break; + return; } main->signal_check = 0; @@ -115,9 +105,9 @@ extern "C" { if (fll_program_standard_signal_received(main)) { fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - setting->status = F_status_set_error(F_signal); + setting->status = F_status_set_error(F_interrupt); - break; + return; } main->signal_check = 0; diff --git a/level_3/utf8/c/common.c b/level_3/utf8/c/common.c index 1555f6b..0ae9def 100644 --- a/level_3/utf8/c/common.c +++ b/level_3/utf8/c/common.c @@ -81,6 +81,7 @@ extern "C" { f_string_dynamics_resize(0, &setting->path_files_from); f_string_dynamics_resize(0, &setting->path_files_to); + f_string_dynamics_resize(0, &setting->remaining); return F_none; } @@ -93,7 +94,14 @@ extern "C" { // Load parameters. setting->status = f_console_parameter_process(arguments, &main->parameters); - if (F_status_is_error(setting->status)) return; + + if (F_status_is_error(setting->status)) { + utf8_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + utf8_print_line_last(setting, main->error, F_true); + + return; + } { f_array_length_t choice = 0; @@ -281,10 +289,11 @@ extern "C" { if (main->parameters.array[utf8_parameter_to_file_e].result == f_console_result_additional_e) { if (main->parameters.array[utf8_parameter_to_file_e].values.used > 1) { - utf8_print_error_parameter_file_to_too_many(main, setting); - setting->status = F_status_set_error(F_parameter); + utf8_print_error_parameter_file_to_too_many(main, setting); + utf8_print_line_last(setting, main->error, F_true); + return; } @@ -292,19 +301,35 @@ extern "C" { setting->path_files_to.used = 0; setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); - if (F_status_is_error(setting->status)) return; + + if (F_status_is_error(setting->status)) { + utf8_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamics_increase_by", F_true); + utf8_print_line_last(setting, main->error, F_true); + + return; + } setting->path_files_to.array[setting->path_files_to.used].used = 0; setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); - if (F_status_is_error(setting->status)) return; + + if (F_status_is_error(setting->status)) { + utf8_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_append_nulless", F_true); + utf8_print_line_last(setting, main->error, F_true); + + return; + } ++setting->path_files_to.used; setting->status = f_file_stream_open(args[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); if (F_status_is_error(setting->status)) { + utf8_print_line_first(setting, main->error, F_true); fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); + utf8_print_line_last(setting, main->error, F_true); return; } @@ -312,7 +337,9 @@ extern "C" { setting->flag |= utf8_main_flag_file_to_e; } else { + utf8_print_line_first(setting, main->error, F_true); utf8_print_error_parameter_file_name_empty(main, setting, main->parameters.array[utf8_parameter_to_file_e].values.array[0]); + utf8_print_line_last(setting, main->error, F_true); setting->status = F_status_set_error(F_parameter); @@ -320,10 +347,12 @@ extern "C" { } } else if (main->parameters.array[utf8_parameter_to_file_e].result == f_console_result_found_e) { - utf8_print_error_no_value(main, setting, utf8_long_to_file_s); - setting->status = F_status_set_error(F_parameter); + utf8_print_line_first(setting, main->error, F_true); + fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_enable_s, utf8_long_to_file_s); + utf8_print_line_last(setting, main->error, F_true); + return; } else { @@ -338,7 +367,14 @@ extern "C" { setting->path_files_from.used = 0; setting->status = f_string_dynamics_increase_by(main->parameters.array[utf8_parameter_from_file_e].values.used, &setting->path_files_from); - if (F_status_is_error(setting->status)) return; + + if (F_status_is_error(setting->status)) { + utf8_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamics_increase_by", F_true); + utf8_print_line_last(setting, main->error, F_true); + + return; + } setting->path_files_from.used = main->parameters.array[utf8_parameter_from_file_e].values.used; @@ -351,7 +387,13 @@ extern "C" { setting->path_files_from.array[i].used = 0; setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]); - if (F_status_is_error(setting->status)) return; + + if (F_status_is_error(setting->status)) { + utf8_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_append_nulless", F_true); + + break; + } if (args[index].used) { if (f_file_exists(args[index], F_true) != F_true) { @@ -371,15 +413,21 @@ extern "C" { } } // for - if (F_status_is_error(setting->status)) return; + if (F_status_is_error(setting->status)) { + utf8_print_line_last(setting, main->error, F_true); + + return; + } setting->flag |= utf8_main_flag_file_from_e; } else if (main->parameters.array[utf8_parameter_from_file_e].result == f_console_result_found_e) { - utf8_print_error_no_value(main, setting, utf8_long_from_file_s); - setting->status = F_status_set_error(F_parameter); + utf8_print_line_first(setting, main->error, F_true); + fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_enable_s, utf8_long_from_file_s); + utf8_print_line_last(setting, main->error, F_true); + return; } else { @@ -388,12 +436,37 @@ extern "C" { } } - if (F_status_is_error(setting->status)) return; + if (main->parameters.remaining.used) { + setting->remaining.used = 0; + + setting->status = f_string_dynamics_resize(main->parameters.remaining.used, &setting->remaining); + + if (F_status_is_error(setting->status)) { + utf8_print_line_first(setting, main->error, F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_append_nulless", F_true); + utf8_print_line_last(setting, main->error, F_true); + + return; + } + + // Construct the array without allocating any more memory by setting this as a static string (used > 0, size = 0). + for (f_array_length_t index = 0; setting->remaining.used < main->parameters.remaining.used; ) { + + index = main->parameters.remaining.array[setting->remaining.used]; + + setting->remaining.array[setting->remaining.used].string = main->parameters.arguments.array[index].string; + setting->remaining.array[setting->remaining.used].used = main->parameters.arguments.array[index].used; + setting->remaining.array[setting->remaining.used++].size = 0; + } // for + } if (main->parameters.array[utf8_parameter_from_file_e].result == f_console_result_none_e && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) { + setting->status = F_status_set_error(F_parameter); + utf8_print_error_no_from(main, setting); + utf8_print_line_last(setting, main->error, F_true); - setting->status = F_status_set_error(F_parameter); + return; } if (!(setting->mode & utf8_mode_to_bytesequence_e)) { diff --git a/level_3/utf8/c/common.h b/level_3/utf8/c/common.h index 8fe8008..22b8881 100644 --- a/level_3/utf8/c/common.h +++ b/level_3/utf8/c/common.h @@ -311,10 +311,10 @@ extern "C" { * - codepoint: The input format is codepoint (U+XXXX or U+XXXXXX). * * utf8_mode_to_*_e: - * - bytesequence: The outout format is bytesequence. - * - codepoint: The outout format is codepoint (U+XXXX or U+XXXXXX). - * - combining: The outout format is whether or not character is combining (may be used with "width"). - * - width: The outout format is how wide the character is (may be used with "combining"). + * - bytesequence: The output format is bytesequence. + * - codepoint: The output format is codepoint (U+XXXX or U+XXXXXX). + * - combining: The output format is whether or not character is combining (may be used with "width"). + * - width: The output format is how wide the character is (may be used with "combining"). */ #ifndef _di_utf8_modes_e_ enum { @@ -332,15 +332,15 @@ extern "C" { * Flags used to represent flags passed to the main function. * * utf8_main_flag_*_e: - * - none: No modes in use. - * - file_from: Using a specified source file. - * - file_to: Using a specified destination file. - * - help: Print help. - * - header: Enable printing of headers. - * - separate: Enable printing of separators. - * - strip_invalid: Using strip invalid character mode. - * - verify: Using verify mode. - * - version: Print version. + * - none: No modes in use. + * - file_from: Using a specified source file. + * - file_to: Using a specified destination file. + * - header: Enable printing of headers. + * - help: Print help. + * - separate: Enable printing of separators. + * - strip_invalid: Using strip invalid character mode. + * - verify: Using verify mode. + * - version: Print version. */ #ifndef _di_utf8_main_flag_e_ enum { @@ -381,6 +381,7 @@ extern "C" { * * path_files_from: An array of all "from" file paths for when the flag utf8_main_flag_file_from_e is set. * path_files_to: An array of all "to" file paths for when the flag utf8_main_flag_file_to_e is set. + * remaining: An array containing all remaining arguments passed to the program. */ #ifndef _di_utf8_setting_t_ typedef struct { @@ -403,6 +404,7 @@ extern "C" { f_string_dynamics_t path_files_from; f_string_dynamics_t path_files_to; + f_string_dynamics_t remaining; } utf8_setting_t; #define utf8_setting_t_initialize \ @@ -420,6 +422,7 @@ extern "C" { f_string_dynamic_t_initialize, \ f_string_dynamics_t_initialize, \ f_string_dynamics_t_initialize, \ + f_string_dynamics_t_initialize, \ } #endif // _di_utf8_setting_t_ diff --git a/level_3/utf8/c/print.c b/level_3/utf8/c/print.c index 5e87a36..b1f85fa 100644 --- a/level_3/utf8/c/print.c +++ b/level_3/utf8/c/print.c @@ -6,17 +6,19 @@ extern "C" { #endif #ifndef _di_utf8_print_bytesequence_ - void utf8_print_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence) { + f_status_t utf8_print_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence) { fl_print_format("%r%r%r", main->output.to.stream, setting->prepend, sequence, setting->append); + + return F_none; } #endif // _di_utf8_print_bytesequence_ #ifndef _di_utf8_print_character_invalid_ - void utf8_print_character_invalid(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t invalid) { + f_status_t utf8_print_character_invalid(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t invalid) { - if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return; - if (!invalid.used) return; + if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not; + if (!invalid.used) return F_output_not; if ((setting->mode & utf8_mode_to_combining_e) || (setting->mode & utf8_mode_to_width_e)) { utf8_print_combining_or_width(main, setting, invalid); @@ -36,11 +38,13 @@ extern "C" { fl_print_format("%]%r", main->output.to.stream, setting->valid_not, setting->append); } + + return F_none; } #endif // _di_utf8_print_character_invalid_ #ifndef _di_utf8_print_codepoint_ - void utf8_print_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const uint32_t codepoint) { + f_status_t utf8_print_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const uint32_t codepoint) { if (codepoint < 0x10000) { fl_print_format("%rU+%04_U%r", main->output.to.stream, setting->prepend, codepoint, setting->append); @@ -51,11 +55,13 @@ extern "C" { else { fl_print_format("%rU+%06_U%r", main->output.to.stream, setting->prepend, codepoint, setting->append); } + + return F_none; } #endif // _di_utf8_print_codepoint_ #ifndef _di_utf8_print_combining_or_width_ - void utf8_print_combining_or_width(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence) { + f_status_t utf8_print_combining_or_width(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence) { if (setting->mode & utf8_mode_to_combining_e) { f_status_t status = f_utf_is_combining(sequence.string, sequence.used); @@ -83,23 +89,27 @@ extern "C" { else if (setting->mode & utf8_mode_to_width_e) { utf8_print_width(main, setting, sequence); } + + return F_none; } #endif // _di_utf8_print_combining_or_width_ #ifndef _di_utf8_print_error_combining_or_width_ - void utf8_print_error_combining_or_width(fll_program_data_t * const main, utf8_setting_t * const setting) { + f_status_t utf8_print_error_combining_or_width(fll_program_data_t * const main, utf8_setting_t * const setting) { - if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return; + if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not; fl_print_format("%r%[%r%]%r", main->output.to.stream, setting->prepend, setting->valid_not, utf8_string_unknown_s, setting->valid_not, setting->append); + + return F_none; } #endif // _di_utf8_print_error_combining_or_width_ #ifndef _di_utf8_print_error_decode_ - void utf8_print_error_decode(fll_program_data_t * const main, utf8_setting_t * const setting, const f_status_t status, const f_string_static_t invalid) { + f_status_t utf8_print_error_decode(fll_program_data_t * const main, utf8_setting_t * const setting, const f_status_t status, const f_string_static_t invalid) { - if (main->error.verbosity == f_console_verbosity_quiet_e) return; - if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return; + if (main->error.verbosity == f_console_verbosity_quiet_e) return F_output_not; + if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not; utf8_print_line_first(setting, main->error, F_false); @@ -129,13 +139,15 @@ extern "C" { fl_print_format("%[%ui%]", main->error.to.stream, main->context.set.notable, F_status_set_fine(status), main->context.set.notable); fl_print_format("%[.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); } + + return F_none; } #endif // _di_utf8_print_error_decode_ #ifndef _di_utf8_print_error_encode_ - void utf8_print_error_encode(fll_program_data_t * const main, utf8_setting_t * const setting, const f_status_t status, const uint32_t codepoint) { + f_status_t utf8_print_error_encode(fll_program_data_t * const main, utf8_setting_t * const setting, const f_status_t status, const uint32_t codepoint) { - if (main->error.verbosity == f_console_verbosity_quiet_e) return; + if (main->error.verbosity == f_console_verbosity_quiet_e) return F_output_not; utf8_print_line_first(setting, main->error, F_false); @@ -150,41 +162,28 @@ extern "C" { fl_print_format("%[%ui%]", main->error.to.stream, main->context.set.notable, F_status_set_fine(status), main->context.set.notable); fl_print_format("%[.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); } + + return F_none; } #endif // _di_utf8_print_error_encode_ #ifndef _di_utf8_print_error_no_from_ - void utf8_print_error_no_from(fll_program_data_t * const main, utf8_setting_t * const setting) { + f_status_t utf8_print_error_no_from(fll_program_data_t * const main, utf8_setting_t * const setting) { - if (main->error.verbosity == f_console_verbosity_quiet_e) return; + if (main->error.verbosity == f_console_verbosity_quiet_e) return F_output_not; utf8_print_line_first(setting, main->error, F_true); fll_print_format("%[%QNo from sources are specified, please pipe data, designate a file, or add parameters.%]%r", main->error.to.stream, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); - } -#endif // _di_utf8_print_error_no_from_ - -#ifndef _di_utf8_print_error_no_value_ - void utf8_print_error_no_value(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t parameter) { - - if (main->error.verbosity == f_console_verbosity_quiet_e) return; - - f_file_stream_lock(main->error.to); - - utf8_print_line_first(setting, main->error, F_false); - fl_print_format("%[%QThe parameter '%]", main->error.to.stream, main->context.set.error, main->error.prefix, main->context.set.error); - fl_print_format("%[%r%r%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, parameter, main->context.set.notable); - fl_print_format("%[' is specified, but no value was given.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); - - f_file_stream_unlock(main->error.to); + return F_none; } -#endif // _di_utf8_print_error_no_value_ +#endif // _di_utf8_print_error_no_from_ #ifndef _di_utf8_print_error_parameter_file_name_empty_ - void utf8_print_error_parameter_file_name_empty(fll_program_data_t * const main, utf8_setting_t * const setting, const f_array_length_t index) { + f_status_t utf8_print_error_parameter_file_name_empty(fll_program_data_t * const main, utf8_setting_t * const setting, const f_array_length_t index) { - if (main->error.verbosity == f_console_verbosity_quiet_e) return; + if (main->error.verbosity == f_console_verbosity_quiet_e) return F_output_not; f_file_stream_lock(main->error.to); @@ -195,13 +194,15 @@ extern "C" { fl_print_format("%[.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); f_file_stream_unlock(main->error.to); + + return F_none; } #endif // _di_utf8_print_error_parameter_file_name_empty_ #ifndef _di_utf8_print_error_parameter_file_not_found_ - void utf8_print_error_parameter_file_not_found(fll_program_data_t * const main, utf8_setting_t * const setting, const bool from, const f_string_static_t name) { + f_status_t utf8_print_error_parameter_file_not_found(fll_program_data_t * const main, utf8_setting_t * const setting, const bool from, const f_string_static_t name) { - if (main->error.verbosity == f_console_verbosity_quiet_e) return; + if (main->error.verbosity == f_console_verbosity_quiet_e) return F_output_not; f_file_stream_lock(main->error.to); @@ -212,24 +213,28 @@ extern "C" { fl_print_format("%['.%]%r", main->error.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); f_file_stream_unlock(main->error.to); + + return F_none; } #endif // _di_utf8_print_error_parameter_file_not_found_ #ifndef _di_utf8_print_error_parameter_file_to_too_many_ - void utf8_print_error_parameter_file_to_too_many(fll_program_data_t * const main, utf8_setting_t * const setting) { + f_status_t utf8_print_error_parameter_file_to_too_many(fll_program_data_t * const main, utf8_setting_t * const setting) { - if (main->error.verbosity == f_console_verbosity_quiet_e) return; + if (main->error.verbosity == f_console_verbosity_quiet_e) return F_output_not; utf8_print_line_first(setting, main->error, F_true); - fll_print_format("%[%QToo many %r files specified, there may only be one to file.%]%r", main->error.to.stream, main->context.set.error, main->error.prefix, utf8_string_to_s, main->context.set.error, f_string_eol_s); + fll_print_format("%[%QToo many '%r' files specified, there may only be one '%r' file.%]%r", main->error.to.stream, main->context.set.error, main->error.prefix, utf8_string_to_s, utf8_string_to_s, main->context.set.error, f_string_eol_s); + + return F_none; } #endif // _di_utf8_print_error_parameter_file_to_too_many_ #ifndef _di_utf8_print_flush_ - void utf8_print_flush(fll_program_data_t * const main, utf8_setting_t * const setting) { + f_status_t utf8_print_flush(fll_program_data_t * const main, utf8_setting_t * const setting) { - if (setting->flag & utf8_main_flag_verify_e) return; + if (setting->flag & utf8_main_flag_verify_e) return F_output_not; if (setting->status == F_interrupt) { if (main->output.verbosity != f_console_verbosity_quiet_e) { @@ -242,6 +247,8 @@ extern "C" { } } } + + return F_none; } #endif // _di_utf8_print_flush_ @@ -277,6 +284,9 @@ extern "C" { fll_program_print_help_option(print, utf8_short_strip_invalid_s, utf8_long_strip_invalid_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Strip invalid Unicode characters (do not print invalid sequences)."); fll_program_print_help_option(print, utf8_short_verify_s, utf8_long_verify_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Only perform verification of valid sequences."); + f_print_dynamic_raw(f_string_eol_s, print.to.stream); + f_print_dynamic_raw(f_string_eol_s, print.to.stream); + fll_program_print_help_usage(print, utf8_program_name_s, utf8_program_help_parameters_s); fl_print_format("%r The default behavior is to assume the expected input is byte sequence from the command line to be print.to to the screen as codepoints.%r%r", print.to.stream, f_string_eol_s, f_string_eol_s, f_string_eol_s); @@ -300,9 +310,9 @@ extern "C" { #endif // _di_utf8_print_help_ #ifndef _di_utf8_print_line_first_ - void utf8_print_line_first(utf8_setting_t * const setting, const fl_print_t print, const bool lock) { + f_status_t utf8_print_line_first(utf8_setting_t * const setting, const fl_print_t print, const bool lock) { - if (print.verbosity == f_console_verbosity_quiet_e) return; + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; if (lock) { fll_print_dynamic_raw(setting->line_first, print.to.stream); @@ -310,16 +320,20 @@ extern "C" { else { f_print_dynamic_raw(setting->line_first, print.to.stream); } + + return F_none; } #endif // _di_utf8_print_line_first_ #ifndef _di_utf8_print_line_last_ - void utf8_print_line_last(utf8_setting_t * const setting, const fl_print_t print, const bool lock) { + f_status_t utf8_print_line_last(utf8_setting_t * const setting, const fl_print_t print, const bool lock) { - if (print.verbosity == f_console_verbosity_quiet_e) return; - if (print.verbosity == f_console_verbosity_error_e && !F_status_is_error(setting->status)) return; - if (setting->flag & utf8_main_flag_verify_e) return; - if ((setting->flag & utf8_main_flag_file_to_e) && !F_status_is_error(setting->status)) return; + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + if (!F_status_is_error(setting->status)) { + if (print.verbosity == f_console_verbosity_error_e) return F_output_not; + if (setting->flag & (utf8_main_flag_verify_e | utf8_main_flag_file_to_e)) return F_output_not; + } if (lock) { fll_print_dynamic_raw(setting->line_last, print.to.stream); @@ -327,13 +341,15 @@ extern "C" { else { f_print_dynamic_raw(setting->line_last, print.to.stream); } + + return F_none; } #endif // _di_utf8_print_line_last_ #ifndef _di_utf8_print_raw_bytesequence_ - void utf8_print_raw_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_utf_char_t raw, const uint8_t width) { + f_status_t utf8_print_raw_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_utf_char_t raw, const uint8_t width) { - if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return; + if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not; f_string_static_t character = macro_f_string_static_t_initialize(0, 0, width); @@ -366,22 +382,26 @@ extern "C" { } fl_print_format("%r%[%r%]%r", main->output.to.stream, setting->prepend, setting->valid_not, character, setting->valid_not, setting->append); + + return F_none; } #endif // _di_utf8_print_raw_bytesequence_ #ifndef _di_utf8_print_raw_codepoint_ - void utf8_print_raw_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t raw) { + f_status_t utf8_print_raw_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t raw) { - if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return; + if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not; fl_print_format("%r%[%r%]%r", main->output.to.stream, setting->prepend, setting->valid_not, raw, setting->valid_not, setting->append); + + return F_none; } #endif // _di_utf8_print_raw_codepoint_ #ifndef _di_utf8_print_raw_combining_or_width_ - void utf8_print_raw_combining_or_width(fll_program_data_t * const main, utf8_setting_t * const setting, const uint8_t width) { + f_status_t utf8_print_raw_combining_or_width(fll_program_data_t * const main, utf8_setting_t * const setting, const uint8_t width) { - if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return; + if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not; if (setting->mode & utf8_mode_to_combining_e) { utf8_print_error_combining_or_width(main, setting); @@ -412,16 +432,18 @@ extern "C" { fl_print_format("%r%[%r%]%r", main->output.to.stream, setting->prepend, setting->valid_not, *character, setting->valid_not, setting->append); } + + return F_none; } #endif // _di_utf8_print_raw_combining_or_width_ #ifndef _di_utf8_print_section_header_file_ - void utf8_print_section_header_file(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t name, const f_array_length_t index) { + f_status_t utf8_print_section_header_file(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t name, const f_array_length_t index) { - if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return; - if (setting->flag & utf8_main_flag_verify_e) return; + if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return F_output_not; + if (setting->flag & utf8_main_flag_verify_e) return F_output_not; - flockfile(main->output.to.stream); + f_file_stream_lock(main->output.to); if ((main->pipe & fll_program_data_pipe_input_e) || index) { f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); @@ -441,17 +463,19 @@ extern "C" { } } - funlockfile(main->output.to.stream); + f_file_stream_unlock(main->output.to); + + return F_none; } #endif // _di_utf8_print_section_header_file_ #ifndef _di_utf8_print_section_header_parameter_ - void utf8_print_section_header_parameter(fll_program_data_t * const main, utf8_setting_t * const setting, const f_array_length_t index) { + f_status_t utf8_print_section_header_parameter(fll_program_data_t * const main, utf8_setting_t * const setting, const f_array_length_t index) { - if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return; - if (setting->flag & utf8_main_flag_verify_e) return; + if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return F_output_not; + if (setting->flag & utf8_main_flag_verify_e) return F_output_not; - flockfile(main->output.to.stream); + f_file_stream_lock(main->output.to); if ((main->pipe & fll_program_data_pipe_input_e) || (setting->flag & utf8_main_flag_file_from_e) || index) { f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); @@ -465,17 +489,19 @@ extern "C" { fl_print_format("%[%ul%]:%r", main->output.to.stream, main->output.set->notable, index, main->output.set->notable, f_string_eol_s); } - funlockfile(main->output.to.stream); + f_file_stream_unlock(main->output.to); + + return F_none; } #endif // _di_utf8_print_section_header_parameter_ #ifndef _di_utf8_print_section_header_pipe_ - void utf8_print_section_header_pipe(fll_program_data_t * const main, utf8_setting_t * const setting) { + f_status_t utf8_print_section_header_pipe(fll_program_data_t * const main, utf8_setting_t * const setting) { - if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return; - if (setting->flag & utf8_main_flag_verify_e) return; + if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return F_output_not; + if (setting->flag & utf8_main_flag_verify_e) return F_output_not; - flockfile(main->output.to.stream); + f_file_stream_lock(main->output.to); f_print_dynamic_raw(setting->line_first, main->output.to.stream); @@ -483,19 +509,21 @@ extern "C" { fl_print_format("%[Pipe%]:%r", main->output.to.stream, main->output.set->title, main->output.set->title, f_string_eol_s); } - funlockfile(main->output.to.stream); + f_file_stream_unlock(main->output.to); + + return F_none; } #endif // _di_utf8_print_section_header_pipe_ #ifndef _di_utf8_print_width_ - void utf8_print_width(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence) { + f_status_t utf8_print_width(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence) { f_status_t status = f_utf_is_wide(sequence.string, sequence.used); if (status == F_true) { fl_print_format("%r%r%r", main->output.to.stream, setting->prepend, utf8_string_width_2_s, setting->append); - return; + return F_output_not; } if (status == F_false) { @@ -504,17 +532,19 @@ extern "C" { if (status == F_true) { fl_print_format("%r%r%r", main->output.to.stream, setting->prepend, utf8_string_width_1_s, setting->append); - return; + return F_output_not; } if (status == F_false) { fl_print_format("%r%r%r", main->output.to.stream, setting->prepend, utf8_string_width_0_s, setting->append); - return; + return F_output_not; } } utf8_print_error_combining_or_width(main, setting); + + return F_none; } #endif // _di_utf8_print_width_ diff --git a/level_3/utf8/c/print.h b/level_3/utf8/c/print.h index c02b5e3..785e0a3 100644 --- a/level_3/utf8/c/print.h +++ b/level_3/utf8/c/print.h @@ -23,9 +23,13 @@ extern "C" { * Assumed to always be non-NULL. * @param sequence * A byte sequences representing a single character to print. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_bytesequence_ - extern void utf8_print_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence); + extern f_status_t utf8_print_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence); #endif // _di_utf8_print_bytesequence_ /** @@ -42,10 +46,14 @@ extern "C" { * @param invalid * The byte sequence string or unicode codepoint string representing a single character to print. * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * * @see utf8_print_combining_or_width() */ #ifndef _di_utf8_print_character_invalid_ - extern void utf8_print_character_invalid(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t invalid); + extern f_status_t utf8_print_character_invalid(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t invalid); #endif // _di_utf8_print_character_invalid_ /** @@ -60,9 +68,13 @@ extern "C" { * @param codepoint * The codepoint to print. * This is the code that represents a single character. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_codepoint_ - extern void utf8_print_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const uint32_t codepoint); + extern f_status_t utf8_print_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const uint32_t codepoint); #endif // _di_utf8_print_codepoint_ /** @@ -78,9 +90,13 @@ extern "C" { * A byte sequences representing a single character to print. * * @see utf8_print_width() + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_combining_or_width_ - extern void utf8_print_combining_or_width(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence); + extern f_status_t utf8_print_combining_or_width(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence); #endif // _di_utf8_print_combining_or_width_ /** @@ -92,9 +108,13 @@ extern "C" { * The main program settings. * * Assumed to always be non-NULL. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_error_combining_or_width_ - extern void utf8_print_error_combining_or_width(fll_program_data_t * const main, utf8_setting_t * const setting); + extern f_status_t utf8_print_error_combining_or_width(fll_program_data_t * const main, utf8_setting_t * const setting); #endif // _di_utf8_print_error_combining_or_width_ /** @@ -108,9 +128,13 @@ extern "C" { * Assumed to always be non-NULL. * @param invalid * The byte sequence string or unicode codepoint string representing a single character to print. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_error_decode_ - extern void utf8_print_error_decode(fll_program_data_t * const main, utf8_setting_t * const setting, const f_status_t status, const f_string_static_t invalid); + extern f_status_t utf8_print_error_decode(fll_program_data_t * const main, utf8_setting_t * const setting, const f_status_t status, const f_string_static_t invalid); #endif // _di_utf8_print_error_decode_ /** @@ -124,9 +148,13 @@ extern "C" { * Assumed to always be non-NULL. * @param codepoint * The codepoint that is invalid. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_error_encode_ - extern void utf8_print_error_encode(fll_program_data_t * const main, utf8_setting_t * const setting, const f_status_t status, const uint32_t codepoint); + extern f_status_t utf8_print_error_encode(fll_program_data_t * const main, utf8_setting_t * const setting, const f_status_t status, const uint32_t codepoint); #endif // _di_utf8_print_error_encode_ /** @@ -138,28 +166,16 @@ extern "C" { * The main program settings. * * Assumed to always be non-NULL. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_error_no_from_ - extern void utf8_print_error_no_from(fll_program_data_t * const main, utf8_setting_t * const setting); + extern f_status_t utf8_print_error_no_from(fll_program_data_t * const main, utf8_setting_t * const setting); #endif // _di_utf8_print_error_no_from_ /** - * Print error message for when no sources are provided. - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * Assumed to always be non-NULL. - * @param parameter - * The long parameter name. - */ -#ifndef _di_utf8_print_error_no_value_ - extern void utf8_print_error_no_value(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t parameter); -#endif // _di_utf8_print_error_no_value_ - -/** * Print error message for when the file parameter is an empty string. * * @param main @@ -170,9 +186,13 @@ extern "C" { * Assumed to always be non-NULL. * @param index * The index within the argv[] array where the empty string is found. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_error_parameter_file_name_empty_ - extern void utf8_print_error_parameter_file_name_empty(fll_program_data_t * const main, utf8_setting_t * const setting, const f_array_length_t index); + extern f_status_t utf8_print_error_parameter_file_name_empty(fll_program_data_t * const main, utf8_setting_t * const setting, const f_array_length_t index); #endif // _di_utf8_print_error_parameter_file_name_empty_ /** @@ -189,9 +209,13 @@ extern "C" { * If FALSE, then this is a to file (destination file). * @param name * The file path name. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_error_parameter_file_not_found_ - extern void utf8_print_error_parameter_file_not_found(fll_program_data_t * const main, utf8_setting_t * const setting, const bool from, const f_string_static_t name); + extern f_status_t utf8_print_error_parameter_file_not_found(fll_program_data_t * const main, utf8_setting_t * const setting, const bool from, const f_string_static_t name); #endif // _di_utf8_print_error_parameter_file_not_found_ /** @@ -203,9 +227,13 @@ extern "C" { * The main program settings. * * Assumed to always be non-NULL. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_error_parameter_file_to_too_many_ - extern void utf8_print_error_parameter_file_to_too_many(fll_program_data_t * const main, utf8_setting_t * const setting); + extern f_status_t utf8_print_error_parameter_file_to_too_many(fll_program_data_t * const main, utf8_setting_t * const setting); #endif // _di_utf8_print_error_parameter_file_to_too_many_ /** @@ -218,9 +246,13 @@ extern "C" { * @param setting * The main program settings. * This does not alter setting.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_flush_ - extern void utf8_print_flush(fll_program_data_t * const main, utf8_setting_t * const setting); + extern f_status_t utf8_print_flush(fll_program_data_t * const main, utf8_setting_t * const setting); #endif // _di_utf8_print_flush_ /** @@ -234,6 +266,7 @@ extern "C" { * * @return * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_help_ extern f_status_t utf8_print_help(utf8_setting_t * const setting, const fl_print_t print); @@ -252,9 +285,13 @@ extern "C" { * @param lock * If TRUE, then lock the stream. * If FALSE, then do not lock or unlock the stream. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_line_first_ - extern void utf8_print_line_first(utf8_setting_t * const setting, const fl_print_t print, const bool lock); + extern f_status_t utf8_print_line_first(utf8_setting_t * const setting, const fl_print_t print, const bool lock); #endif // _di_utf8_print_line_first_ /** @@ -270,9 +307,13 @@ extern "C" { * @param lock * If TRUE, then lock the stream. * If FALSE, then do not lock or unlock the stream. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_line_last_ - extern void utf8_print_line_last(utf8_setting_t * const setting, const fl_print_t print, const bool lock); + extern f_status_t utf8_print_line_last(utf8_setting_t * const setting, const fl_print_t print, const bool lock); #endif // _di_utf8_print_line_last_ /** @@ -288,9 +329,13 @@ extern "C" { * The raw string in integer format. * @param width * The width the raw character represents (a value inclusively from 1 to 4). + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_raw_bytesequence_ - extern void utf8_print_raw_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_utf_char_t raw, const uint8_t width); + extern f_status_t utf8_print_raw_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_utf_char_t raw, const uint8_t width); #endif // _di_utf8_print_raw_bytesequence_ /** @@ -304,9 +349,13 @@ extern "C" { * Assumed to always be non-NULL. * @param raw * The raw string already in codepoint format. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_raw_codepoint_ - extern void utf8_print_raw_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t raw); + extern f_status_t utf8_print_raw_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t raw); #endif // _di_utf8_print_raw_codepoint_ /** @@ -321,10 +370,14 @@ extern "C" { * @param width * The pre-calculated width. * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * * @see utf8_print_width() */ #ifndef _di_utf8_print_raw_combining_or_width_ - extern void utf8_print_raw_combining_or_width(fll_program_data_t * const main, utf8_setting_t * const setting, const uint8_t width); + extern f_status_t utf8_print_raw_combining_or_width(fll_program_data_t * const main, utf8_setting_t * const setting, const uint8_t width); #endif // _di_utf8_print_raw_combining_or_width_ /** @@ -340,9 +393,13 @@ extern "C" { * The name of the file. * @param index * The index position of the file. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_section_header_file_ - extern void utf8_print_section_header_file(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t name, const f_array_length_t index); + extern f_status_t utf8_print_section_header_file(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t name, const f_array_length_t index); #endif // _di_utf8_print_section_header_file_ /** @@ -356,9 +413,13 @@ extern "C" { * Assumed to always be non-NULL. * @param index * The index position of the parameter. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_section_header_parameter_ - extern void utf8_print_section_header_parameter(fll_program_data_t * const main, utf8_setting_t * const setting, const f_array_length_t index); + extern f_status_t utf8_print_section_header_parameter(fll_program_data_t * const main, utf8_setting_t * const setting, const f_array_length_t index); #endif // _di_utf8_print_section_header_parameter_ /** @@ -370,9 +431,13 @@ extern "C" { * The main program settings. * * Assumed to always be non-NULL. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_section_header_pipe_ - extern void utf8_print_section_header_pipe(fll_program_data_t * const main, utf8_setting_t * const setting); + extern f_status_t utf8_print_section_header_pipe(fll_program_data_t * const main, utf8_setting_t * const setting); #endif // _di_utf8_print_section_header_pipe_ /** @@ -386,9 +451,13 @@ extern "C" { * Assumed to always be non-NULL. * @param sequence * A byte sequences representing a single character whose width is to be printed. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. */ #ifndef _di_utf8_print_width_ - extern void utf8_print_width(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence); + extern f_status_t utf8_print_width(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence); #endif // _di_utf8_print_width_ #ifdef __cplusplus diff --git a/level_3/utf8/c/utf8.c b/level_3/utf8/c/utf8.c index 9dfc146..2d278a5 100644 --- a/level_3/utf8/c/utf8.c +++ b/level_3/utf8/c/utf8.c @@ -11,17 +11,7 @@ extern "C" { #ifndef _di_utf8_main_ void utf8_main(fll_program_data_t * const main, utf8_setting_t * const setting) { - if (!main || !setting) { - utf8_print_line_first(setting, main->error, F_true); - fll_error_print(main->error, F_parameter, "utf8_main", F_true); - utf8_print_line_last(setting, main->error, F_true); - - setting->status = F_status_set_error(F_parameter); - - return; - } - - if (F_status_is_error(setting->status)) return; + if (!main || !setting || F_status_is_error(setting->status)) return; setting->status = F_none; @@ -56,7 +46,7 @@ extern "C" { if (setting->flag & utf8_main_flag_header_e) { fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } - else if ((setting->flag & utf8_main_flag_separate_e) && ((setting->flag & utf8_main_flag_file_from_e) || main->parameters.remaining.used)) { + else if ((setting->flag & (utf8_main_flag_separate_e | utf8_main_flag_file_from_e)) || setting->remaining.used) { fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } } @@ -67,15 +57,11 @@ extern "C" { } } + // Process "from" files. if (F_status_is_error_not(setting->status) && setting->status != F_interrupt && (setting->flag & utf8_main_flag_file_from_e)) { - f_array_length_t i = 0; - f_array_length_t index = 0; - f_file_t file = macro_f_file_t_initialize(0, -1, F_file_flag_read_only_d, 32768, F_file_default_write_size_d); - f_string_static_t * const args = main->parameters.arguments.array; - - for (; i < main->parameters.array[utf8_parameter_from_file_e].values.used && setting->status != F_interrupt; ++i) { + for (f_array_length_t i = 0; i < setting->path_files_from.used && setting->status != F_interrupt; ++i) { if (!((++main->signal_check) % utf8_signal_check_d)) { if (fll_program_standard_signal_received(main)) { @@ -87,14 +73,12 @@ extern "C" { main->signal_check = 0; } - index = main->parameters.array[utf8_parameter_from_file_e].values.array[i]; - - utf8_print_section_header_file(main, setting, args[index], i); + utf8_print_section_header_file(main, setting, setting->path_files_from.array[i], i); - setting->status = f_file_stream_open(args[index], f_string_empty_s, &file); + setting->status = f_file_stream_open(setting->path_files_from.array[i], f_string_empty_s, &file); if (F_status_is_error(setting->status)) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, args[index], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, setting->path_files_from.array[i], f_file_operation_open_s, fll_error_file_type_file_e); break; } @@ -120,7 +104,7 @@ extern "C" { if (setting->flag & utf8_main_flag_header_e) { fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } - else if ((setting->flag & utf8_main_flag_separate_e) && (main->parameters.remaining.used || i + 1 < main->parameters.array[utf8_parameter_from_file_e].values.used)) { + else if ((setting->flag & utf8_main_flag_separate_e) && (setting->remaining.used || setting->path_files_from.used)) { fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } } @@ -134,15 +118,16 @@ extern "C" { } if (F_status_is_error(setting->status) && F_status_set_fine(setting->status) != F_utf_fragment && F_status_set_fine(setting->status) != F_complete_not_utf) { - fll_error_file_print(main->error, F_status_set_fine(setting->status), setting->mode & utf8_mode_from_bytesequence_e ? "utf8_process_file_bytesequence" : "utf8_process_file_codepoint", F_true, args[index], f_file_operation_process_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(setting->status), setting->mode & utf8_mode_from_bytesequence_e ? "utf8_process_file_bytesequence" : "utf8_process_file_codepoint", F_true, setting->path_files_from.array[i], f_file_operation_process_s, fll_error_file_type_file_e); break; } } // for } - if (F_status_is_error_not(setting->status) && setting->status != F_interrupt && main->parameters.remaining.used) { - for (f_array_length_t i = 0; F_status_is_error_not(setting->status) && i < main->parameters.remaining.used; ++i) { + // Process remaining parameters. + if (F_status_is_error_not(setting->status) && setting->status != F_interrupt && setting->remaining.used) { + for (f_array_length_t i = 0; F_status_is_error_not(setting->status) && i < setting->remaining.used; ++i) { if (!((++main->signal_check) % utf8_signal_check_d)) { if (fll_program_standard_signal_received(main)) {