From 0d0a27fb43f8bce5982479a5ccd69690f97bf95c Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Fri, 1 Apr 2022 23:08:41 -0500 Subject: [PATCH] Update: Centralize common error function, minor cleanups, and improve status code programs. Printing an error for two different long parameters that cannot be used together is very common. Move this into a single function inside of fll_program. Make sure that these calls are wrapped in appropriate verbosity checks. The status code programs is now able to print the number with the error bit and/or warning bit set. The status code programs status codes error and warning can be used together when using the -n/--number. Perform minor cleanup where the "main->parameters.remaining.used > 0" can be simplified. --- level_2/fll_program/c/program.c | 17 ++++ level_2/fll_program/c/program.h | 19 +++++ level_3/byte_dump/c/byte_dump.c | 2 +- level_3/firewall/c/firewall.c | 2 +- .../fss_basic_list_read/c/fss_basic_list_read.c | 36 +++------ level_3/fss_basic_read/c/fss_basic_read.c | 36 +++------ .../c/fss_embedded_list_read.c | 36 +++------ .../c/fss_extended_list_read.c | 36 +++------ level_3/fss_extended_read/c/fss_extended_read.c | 37 +++------ level_3/fss_identify/c/fss_identify.c | 24 ++---- level_3/fss_payload_read/c/fss_payload_read.c | 36 +++------ level_3/fss_status_code/c/common.c | 12 +-- level_3/fss_status_code/c/common.h | 64 +++++++-------- level_3/fss_status_code/c/fss_status_code.c | 90 +++++++++++----------- level_3/fss_status_code/c/private-common.h | 10 +++ .../fss_status_code/c/private-fss_status_code.c | 14 +++- level_3/iki_read/c/iki_read.c | 80 ++----------------- level_3/status_code/c/common.c | 12 +-- level_3/status_code/c/common.h | 64 +++++++-------- level_3/status_code/c/private-status_code.c | 14 +++- level_3/status_code/c/status_code.c | 90 +++++++++++----------- 21 files changed, 301 insertions(+), 430 deletions(-) diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index 0c9fe91..e47bd72 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -271,6 +271,23 @@ 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) { + + flockfile(print.to.stream); + + fl_print_format("%r%[%QCannot specify the '%]", print.to.stream, f_string_eol_s, 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); + + funlockfile(print.to.stream); + + return F_none; + } +#endif // _di_fll_program_parameter_long_print_cannot_use_with_ + #ifndef _di_fll_program_standard_setdown_ f_status_t fll_program_standard_setdown(f_signal_t * const signal) { diff --git a/level_2/fll_program/c/program.h b/level_2/fll_program/c/program.h index f44fdc2..6c30ed5 100644 --- a/level_2/fll_program/c/program.h +++ b/level_2/fll_program/c/program.h @@ -358,6 +358,25 @@ 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 setdown operations used by FLL programs. * * This does the following: diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index 78cc792..8430a23 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -423,7 +423,7 @@ extern "C" { } } - if (main->parameters.remaining.used > 0) { + if (main->parameters.remaining.used) { // Pre-process remaining arguments to ensure that they all files exist before processing. { diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index fdd5424..3f85c97 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -200,7 +200,7 @@ extern "C" { int return_code = 0; - if (main->parameters.remaining.used > 0) { + if (main->parameters.remaining.used) { show_nat = F_false; show_mangle = F_false; show_ports = F_false; 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 b976543..dd929c0 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 @@ -288,15 +288,9 @@ extern "C" { for (f_array_length_t i = 0; i < 5; ++i) { if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_columns_s, main->error.notable); - fl_print_format("%[' parameter with 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, parameter_name[i], 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); + 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]); + } status = F_status_set_error(F_parameter); @@ -307,28 +301,16 @@ 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_pipe_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_basic_list_read_long_total_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); + 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); + } 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_pipe_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_basic_list_read_long_line_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); + 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); + } status = F_status_set_error(F_parameter); } 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 c86fb99..691ad89 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -287,15 +287,9 @@ extern "C" { for (f_array_length_t i = 0; i < 5; ++i) { if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_columns_s, main->error.notable); - fl_print_format("%[' parameter with 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, parameter_name[i], 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); + 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]); + } status = F_status_set_error(F_parameter); @@ -306,28 +300,16 @@ 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_pipe_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_basic_read_long_total_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); + 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); + } status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_basic_read_parameter_line_e].result == f_console_result_additional_e) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_pipe_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_basic_read_long_line_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); + 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); + } status = F_status_set_error(F_parameter); } 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 6b9a3a7..3fed9e0 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 @@ -208,15 +208,9 @@ 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_total_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_embedded_list_read_long_columns_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); + 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); + } status = F_status_set_error(F_parameter); } @@ -285,15 +279,9 @@ extern "C" { 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_line_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_embedded_list_read_long_total_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); + 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); + } status = F_status_set_error(F_parameter); } @@ -301,15 +289,9 @@ 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_pipe_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_embedded_list_read_long_total_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); + 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); + } status = F_status_set_error(F_parameter); } 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 404b298..e3a8416 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 @@ -287,15 +287,9 @@ extern "C" { for (f_array_length_t i = 0; i < 5; ++i) { if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_columns_s, main->error.notable); - fl_print_format("%[' parameter with 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, parameter_name[i], 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); + 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]); + } status = F_status_set_error(F_parameter); @@ -306,28 +300,16 @@ 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_pipe_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_extended_list_read_long_total_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); + 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); + } 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_pipe_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_extended_list_read_long_line_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); + 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); + } status = F_status_set_error(F_parameter); } 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 8a00680..081eb89 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -286,17 +286,12 @@ extern "C" { for (f_array_length_t i = 0; i < 5; ++i) { if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_columns_s, main->error.notable); - fl_print_format("%[' parameter with 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, parameter_name[i], 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); + 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]); + } status = F_status_set_error(F_parameter); + break; } } // for @@ -304,28 +299,16 @@ 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_pipe_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_extended_read_long_total_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); + 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); + } status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_extended_read_parameter_line_e].result == f_console_result_additional_e) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_pipe_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_extended_read_long_line_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); + 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); + } status = F_status_set_error(F_parameter); } diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index bb90dfb..e6746d4 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -172,28 +172,16 @@ 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_identify_long_object_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_identify_long_total_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); + 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); + } status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_identify_parameter_content_e].result == f_console_result_found_e) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_identify_long_content_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_identify_long_total_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); + 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); + } status = F_status_set_error(F_parameter); } 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 826e671..fd68257 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.c +++ b/level_3/fss_payload_read/c/fss_payload_read.c @@ -305,15 +305,9 @@ extern "C" { for (f_array_length_t i = 0; i < 5; ++i) { if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_columns_s, main->error.notable); - fl_print_format("%[' parameter with 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, parameter_name[i], 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); + 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]); + } status = F_status_set_error(F_parameter); @@ -324,28 +318,16 @@ 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_pipe_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_payload_read_long_total_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); + 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); + } status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_payload_read_parameter_line_e].result == f_console_result_additional_e) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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_read_long_pipe_s, main->error.notable); - fl_print_format("%[' parameter with 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, fss_payload_read_long_line_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); + 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); + } status = F_status_set_error(F_parameter); } diff --git a/level_3/fss_status_code/c/common.c b/level_3/fss_status_code/c/common.c index 143dc8f..c6e73aa 100644 --- a/level_3/fss_status_code/c/common.c +++ b/level_3/fss_status_code/c/common.c @@ -18,14 +18,14 @@ extern "C" { #endif // _di_fss_status_code_program_help_parameters_ #ifndef _di_fss_status_code_parameters_ - const f_string_static_t fss_status_code_short_is_fine_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_short_is_fine_s, 0, FSS_STATUS_CODE_short_is_fine_s_length); - const f_string_static_t fss_status_code_short_is_warning_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_short_is_warning_s, 0, FSS_STATUS_CODE_short_is_warning_s_length); - const f_string_static_t fss_status_code_short_is_error_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_short_is_error_s, 0, FSS_STATUS_CODE_short_is_error_s_length); + const f_string_static_t fss_status_code_short_fine_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_short_fine_s, 0, FSS_STATUS_CODE_short_fine_s_length); + const f_string_static_t fss_status_code_short_warning_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_short_warning_s, 0, FSS_STATUS_CODE_short_warning_s_length); + const f_string_static_t fss_status_code_short_error_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_short_error_s, 0, FSS_STATUS_CODE_short_error_s_length); const f_string_static_t fss_status_code_short_number_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_short_number_s, 0, FSS_STATUS_CODE_short_number_s_length); - const f_string_static_t fss_status_code_long_is_fine_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_long_is_fine_s, 0, FSS_STATUS_CODE_long_is_fine_s_length); - const f_string_static_t fss_status_code_long_is_warning_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_long_is_warning_s, 0, FSS_STATUS_CODE_long_is_warning_s_length); - const f_string_static_t fss_status_code_long_is_error_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_long_is_error_s, 0, FSS_STATUS_CODE_long_is_error_s_length); + const f_string_static_t fss_status_code_long_fine_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_long_fine_s, 0, FSS_STATUS_CODE_long_fine_s_length); + const f_string_static_t fss_status_code_long_warning_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_long_warning_s, 0, FSS_STATUS_CODE_long_warning_s_length); + const f_string_static_t fss_status_code_long_error_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_long_error_s, 0, FSS_STATUS_CODE_long_error_s_length); const f_string_static_t fss_status_code_long_number_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_long_number_s, 0, FSS_STATUS_CODE_long_number_s_length); #endif // _di_fss_status_code_parameters_ diff --git a/level_3/fss_status_code/c/common.h b/level_3/fss_status_code/c/common.h index d4745b0..514554b 100644 --- a/level_3/fss_status_code/c/common.h +++ b/level_3/fss_status_code/c/common.h @@ -80,34 +80,34 @@ extern "C" { * The main program parameters. */ #ifndef _di_fss_status_code_parameters_ - #define FSS_STATUS_CODE_short_is_fine_s "f" - #define FSS_STATUS_CODE_short_is_warning_s "w" - #define FSS_STATUS_CODE_short_is_error_s "e" - #define FSS_STATUS_CODE_short_number_s "n" - - #define FSS_STATUS_CODE_long_is_fine_s "is_fine" - #define FSS_STATUS_CODE_long_is_warning_s "is_warning" - #define FSS_STATUS_CODE_long_is_error_s "is_error" - #define FSS_STATUS_CODE_long_number_s "number" - - #define FSS_STATUS_CODE_short_is_fine_s_length 1 - #define FSS_STATUS_CODE_short_is_warning_s_length 1 - #define FSS_STATUS_CODE_short_is_error_s_length 1 - #define FSS_STATUS_CODE_short_number_s_length 1 - - #define FSS_STATUS_CODE_long_is_fine_s_length 7 - #define FSS_STATUS_CODE_long_is_warning_s_length 10 - #define FSS_STATUS_CODE_long_is_error_s_length 8 - #define FSS_STATUS_CODE_long_number_s_length 6 - - extern const f_string_static_t fss_status_code_short_is_fine_s; - extern const f_string_static_t fss_status_code_short_is_warning_s; - extern const f_string_static_t fss_status_code_short_is_error_s; + #define FSS_STATUS_CODE_short_fine_s "f" + #define FSS_STATUS_CODE_short_warning_s "w" + #define FSS_STATUS_CODE_short_error_s "e" + #define FSS_STATUS_CODE_short_number_s "n" + + #define FSS_STATUS_CODE_long_fine_s "fine" + #define FSS_STATUS_CODE_long_warning_s "warning" + #define FSS_STATUS_CODE_long_error_s "error" + #define FSS_STATUS_CODE_long_number_s "number" + + #define FSS_STATUS_CODE_short_fine_s_length 1 + #define FSS_STATUS_CODE_short_warning_s_length 1 + #define FSS_STATUS_CODE_short_error_s_length 1 + #define FSS_STATUS_CODE_short_number_s_length 1 + + #define FSS_STATUS_CODE_long_fine_s_length 4 + #define FSS_STATUS_CODE_long_warning_s_length 7 + #define FSS_STATUS_CODE_long_error_s_length 5 + #define FSS_STATUS_CODE_long_number_s_length 6 + + extern const f_string_static_t fss_status_code_short_fine_s; + extern const f_string_static_t fss_status_code_short_warning_s; + extern const f_string_static_t fss_status_code_short_error_s; extern const f_string_static_t fss_status_code_short_number_s; - extern const f_string_static_t fss_status_code_long_is_fine_s; - extern const f_string_static_t fss_status_code_long_is_warning_s; - extern const f_string_static_t fss_status_code_long_is_error_s; + extern const f_string_static_t fss_status_code_long_fine_s; + extern const f_string_static_t fss_status_code_long_warning_s; + extern const f_string_static_t fss_status_code_long_error_s; extern const f_string_static_t fss_status_code_long_number_s; enum { @@ -121,9 +121,9 @@ extern "C" { fss_status_code_parameter_verbosity_debug_e, fss_status_code_parameter_version_e, - fss_status_code_parameter_is_fine_e, - fss_status_code_parameter_is_warning_e, - fss_status_code_parameter_is_error_e, + fss_status_code_parameter_fine_e, + fss_status_code_parameter_warning_e, + fss_status_code_parameter_error_e, fss_status_code_parameter_number_e, }; @@ -138,9 +138,9 @@ extern "C" { macro_f_console_parameter_t_initialize(f_console_standard_short_verbose_s.string, f_console_standard_long_verbose_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_debug_s.string, f_console_standard_long_debug_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_version_s.string, f_console_standard_long_version_s.string, 0, 0, f_console_type_inverse_e), \ - macro_f_console_parameter_t_initialize(fss_status_code_short_is_fine_s.string, fss_status_code_long_is_fine_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(fss_status_code_short_is_warning_s.string, fss_status_code_long_is_warning_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(fss_status_code_short_is_error_s.string, fss_status_code_long_is_error_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(fss_status_code_short_fine_s.string, fss_status_code_long_fine_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(fss_status_code_short_warning_s.string, fss_status_code_long_warning_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(fss_status_code_short_error_s.string, fss_status_code_long_error_s.string, 0, 0, f_console_type_normal_e), \ macro_f_console_parameter_t_initialize(fss_status_code_short_number_s.string, fss_status_code_long_number_s.string, 0, 0, f_console_type_normal_e), \ } 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 b130b65..2517e62 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -25,10 +25,10 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, file.stream); - fll_program_print_help_option(file, context, fss_status_code_short_is_fine_s, fss_status_code_long_is_fine_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print F_true if the error code is not an error, F_false otherwise."); - fll_program_print_help_option(file, context, fss_status_code_short_is_warning_s, fss_status_code_long_is_warning_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Print F_true if the error code is a warning, F_false otherwise."); - fll_program_print_help_option(file, context, fss_status_code_short_is_error_s, fss_status_code_long_is_error_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print F_true if the error code is an error, F_false otherwise."); - fll_program_print_help_option(file, context, fss_status_code_short_number_s, fss_status_code_long_number_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Convert status code name to number."); + fll_program_print_help_option(file, context, fss_status_code_short_fine_s, fss_status_code_long_fine_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print F_true or F_false if status code is neither an error nor a warning or print number with neither the error code nor the warning code bits set."); + fll_program_print_help_option(file, context, fss_status_code_short_warning_s, fss_status_code_long_warning_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Print F_true or F_false if status code is a warning or print number with warning code bit set."); + fll_program_print_help_option(file, context, fss_status_code_short_error_s, fss_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(file, context, fss_status_code_short_number_s, fss_status_code_long_number_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Convert status code name to number."); fll_program_print_help_usage(file, context, fss_status_code_program_name_s, fss_status_code_program_help_parameters_s); @@ -119,45 +119,41 @@ extern "C" { return F_none; } - if (main->parameters.array[fss_status_code_parameter_is_error_e].result == f_console_result_found_e) { - if (main->parameters.array[fss_status_code_parameter_is_warning_e].result == f_console_result_found_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_status_code_long_is_error_s, main->error.notable); - fl_print_format("%[' cannot be used with 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_status_code_long_is_warning_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); + if (main->parameters.array[fss_status_code_parameter_error_e].result == f_console_result_found_e) { + if (main->parameters.array[fss_status_code_parameter_warning_e].result == f_console_result_found_e) { + if (main->parameters.array[fss_status_code_parameter_number_e].result == f_console_result_none_e) { + if (main->error.verbosity != f_console_verbosity_quiet_e) { + flockfile(main->error.to.stream); + + fl_print_format("%r%[%QCannot 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_status_code_long_error_s, main->error.notable); + fl_print_format("%[' parameter with 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, fss_status_code_long_warning_s, main->error.notable); + fl_print_format("%[' parameter when not also specifying 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, fss_status_code_long_number_s, main->error.notable); + fl_print_format("%[' parameter.%]%r%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s, f_string_eol_s); + + funlockfile(main->error.to.stream); + } - return F_status_set_error(status); + return F_status_set_error(status); + } } - if (main->parameters.array[fss_status_code_parameter_is_fine_e].result == f_console_result_found_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_status_code_long_is_error_s, main->error.notable); - fl_print_format("%[' cannot be used with 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_status_code_long_is_fine_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); + if (main->parameters.array[fss_status_code_parameter_fine_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_status_code_long_error_s, fss_status_code_long_fine_s); + fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); + } return F_status_set_error(status); } } - else if (main->parameters.array[fss_status_code_parameter_is_warning_e].result == f_console_result_found_e && main->parameters.array[fss_status_code_parameter_is_fine_e].result == f_console_result_found_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_status_code_long_is_warning_s, main->error.notable); - fl_print_format("%[' cannot be used with 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_status_code_long_is_fine_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); + else if (main->parameters.array[fss_status_code_parameter_warning_e].result == f_console_result_found_e && main->parameters.array[fss_status_code_parameter_fine_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_status_code_long_warning_s, fss_status_code_long_fine_s); + fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); + } return F_status_set_error(status); } @@ -170,12 +166,12 @@ extern "C" { f_status_t status2 = F_none; - if (main->parameters.array[fss_status_code_parameter_is_error_e].result == f_console_result_found_e || main->parameters.array[fss_status_code_parameter_is_warning_e].result == f_console_result_found_e || main->parameters.array[fss_status_code_parameter_is_fine_e].result == f_console_result_found_e) { + if (main->parameters.array[fss_status_code_parameter_number_e].result == f_console_result_found_e) { if (main->process_pipe) { - // @todo call fss_status_code_process_check() here for all main from pipe that is space separated. + // @todo call fss_status_code_process_number() here for all main from pipe that is space separated. } - if (main->parameters.remaining.used > 0) { + if (main->parameters.remaining.used) { flockfile(main->output.to.stream); for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { @@ -192,7 +188,7 @@ extern "C" { main->signal_check = 0; } - status2 = fss_status_code_process_check(main, argv[main->parameters.remaining.array[i]]); + status2 = fss_status_code_process_number(main, argv[main->parameters.remaining.array[i]]); if (F_status_is_error(status2) && status == F_none) { status = status2; @@ -202,12 +198,12 @@ extern "C" { funlockfile(main->output.to.stream); } } - else if (main->parameters.array[fss_status_code_parameter_number_e].result == f_console_result_found_e) { + else if (main->parameters.array[fss_status_code_parameter_error_e].result == f_console_result_found_e || main->parameters.array[fss_status_code_parameter_warning_e].result == f_console_result_found_e || main->parameters.array[fss_status_code_parameter_fine_e].result == f_console_result_found_e) { if (main->process_pipe) { - // @todo call fss_status_code_process_number() here for all main from pipe that is space separated. + // @todo call fss_status_code_process_check() here for all main from pipe that is space separated. } - if (main->parameters.remaining.used > 0) { + if (main->parameters.remaining.used) { flockfile(main->output.to.stream); for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { @@ -224,7 +220,7 @@ extern "C" { main->signal_check = 0; } - status2 = fss_status_code_process_number(main, argv[main->parameters.remaining.array[i]]); + status2 = fss_status_code_process_check(main, argv[main->parameters.remaining.array[i]]); if (F_status_is_error(status2) && status == F_none) { status = status2; @@ -239,7 +235,7 @@ extern "C" { // @todo call fss_status_code_process_normal() here for all main from pipe that is space separated. } - if (main->parameters.remaining.used > 0) { + if (main->parameters.remaining.used) { flockfile(main->output.to.stream); for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { @@ -267,8 +263,8 @@ extern "C" { } } - if (main->error.verbosity != f_console_verbosity_quiet_e) { - if (F_status_set_fine(status) == F_interrupt) { + if (F_status_set_fine(status) == F_interrupt) { + if (main->output.verbosity != f_console_verbosity_quiet_e) { fflush(main->output.to.stream); fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); diff --git a/level_3/fss_status_code/c/private-common.h b/level_3/fss_status_code/c/private-common.h index 5ba37eb..7f5fec8 100644 --- a/level_3/fss_status_code/c/private-common.h +++ b/level_3/fss_status_code/c/private-common.h @@ -22,6 +22,16 @@ extern "C" { extern void fss_status_code_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_status_code_print_signal_received_ +/** + * Print a message about a one parameter not being allowed to be used with another. + * + * @param main + * The main program data. + */ +#ifndef _di_fss_status_code_print_parameter_cannot_be_used_with_ + extern void fss_status_code_print_parameter_cannot_be_used_with(fll_program_data_t * const main) F_attribute_visibility_internal_d; +#endif // _di_fss_status_code_print_parameter_cannot_be_used_with_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_status_code/c/private-fss_status_code.c b/level_3/fss_status_code/c/private-fss_status_code.c index 729541a..12866ef 100644 --- a/level_3/fss_status_code/c/private-fss_status_code.c +++ b/level_3/fss_status_code/c/private-fss_status_code.c @@ -16,7 +16,7 @@ extern "C" { if (F_status_is_error(status)) return status; } - if (main->parameters.array[fss_status_code_parameter_is_error_e].result == f_console_result_found_e) { + if (main->parameters.array[fss_status_code_parameter_error_e].result == f_console_result_found_e) { if (F_status_is_error(number)) { f_print_dynamic_raw(f_status_true_s, main->output.to.stream); } @@ -26,7 +26,7 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } - else if (main->parameters.array[fss_status_code_parameter_is_warning_e].result == f_console_result_found_e) { + else if (main->parameters.array[fss_status_code_parameter_warning_e].result == f_console_result_found_e) { if (F_status_is_warning(number)) { f_print_dynamic_raw(f_status_true_s, main->output.to.stream); } @@ -36,7 +36,7 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } - else if (main->parameters.array[fss_status_code_parameter_is_fine_e].result == f_console_result_found_e) { + else if (main->parameters.array[fss_status_code_parameter_fine_e].result == f_console_result_found_e) { if (F_status_is_fine(number)) { f_print_dynamic_raw(f_status_true_s, main->output.to.stream); } @@ -101,6 +101,14 @@ extern "C" { return F_none; } + if (main->parameters.array[fss_status_code_parameter_error_e].result == f_console_result_found_e) { + code = F_status_set_error(code); + } + + if (main->parameters.array[fss_status_code_parameter_warning_e].result == f_console_result_found_e) { + code = F_status_set_warning(code); + } + fl_print_format("%ui%r", main->output.to.stream, code, f_string_eol_s); return F_none; diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index 499034b..5241a50 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -196,15 +196,7 @@ extern "C" { if (main->parameters.array[iki_read_parameter_whole_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%[%QCannot 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, iki_read_long_at_s, main->error.notable); - fl_print_format("%[' parameter with 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_read_long_whole_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); + fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_at_s, iki_read_long_whole_s); } status = F_status_set_error(F_parameter); @@ -271,15 +263,7 @@ extern "C" { if (main->parameters.array[iki_read_parameter_total_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%[%QCannot 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, iki_read_long_substitute_s, main->error.notable); - fl_print_format("%[' parameter with 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_read_long_total_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); + fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_substitute_s, iki_read_long_total_s); } status = F_status_set_error(F_parameter); @@ -289,15 +273,7 @@ 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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, iki_read_long_literal_s, main->error.notable); - fl_print_format("%[' parameter with 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_read_long_object_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); + fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_literal_s, iki_read_long_object_s); } status = F_status_set_error(F_parameter); @@ -305,15 +281,7 @@ extern "C" { if (main->parameters.array[iki_read_parameter_content_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%[%QCannot 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, iki_read_long_literal_s, main->error.notable); - fl_print_format("%[' parameter with 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_read_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); + fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_literal_s, iki_read_long_content_s); } status = F_status_set_error(F_parameter); @@ -321,15 +289,7 @@ extern "C" { if (main->parameters.array[iki_read_parameter_total_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%[%QCannot 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, iki_read_long_literal_s, main->error.notable); - fl_print_format("%[' parameter with 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_read_long_total_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); + fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_literal_s, iki_read_long_total_s); } status = F_status_set_error(F_parameter); @@ -340,15 +300,7 @@ 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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, iki_read_long_object_s, main->error.notable); - fl_print_format("%[' parameter with 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_read_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); + fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_object_s, iki_read_long_content_s); } status = F_status_set_error(F_parameter); @@ -356,15 +308,7 @@ extern "C" { if (main->parameters.array[iki_read_parameter_total_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%[%QCannot 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, iki_read_long_object_s, main->error.notable); - fl_print_format("%[' parameter with 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_read_long_total_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); + fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_object_s, iki_read_long_total_s); } status = F_status_set_error(F_parameter); @@ -384,15 +328,7 @@ 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) { - flockfile(main->error.to.stream); - - fl_print_format("%r%[%QCannot 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, iki_read_long_whole_s, main->error.notable); - fl_print_format("%[' parameter with 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_read_long_total_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); + fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_whole_s, iki_read_long_total_s); } status = F_status_set_error(F_parameter); diff --git a/level_3/status_code/c/common.c b/level_3/status_code/c/common.c index e2ef3f3..abccb6d 100644 --- a/level_3/status_code/c/common.c +++ b/level_3/status_code/c/common.c @@ -18,14 +18,14 @@ extern "C" { #endif // _di_status_code_program_help_parameters_ #ifndef _di_status_code_parameters_ - const f_string_static_t status_code_short_is_fine_s = macro_f_string_static_t_initialize(STATUS_CODE_short_is_fine_s, 0, STATUS_CODE_short_is_fine_s_length); - const f_string_static_t status_code_short_is_warning_s = macro_f_string_static_t_initialize(STATUS_CODE_short_is_warning_s, 0, STATUS_CODE_short_is_warning_s_length); - const f_string_static_t status_code_short_is_error_s = macro_f_string_static_t_initialize(STATUS_CODE_short_is_error_s, 0, STATUS_CODE_short_is_error_s_length); + const f_string_static_t status_code_short_fine_s = macro_f_string_static_t_initialize(STATUS_CODE_short_fine_s, 0, STATUS_CODE_short_fine_s_length); + const f_string_static_t status_code_short_warning_s = macro_f_string_static_t_initialize(STATUS_CODE_short_warning_s, 0, STATUS_CODE_short_warning_s_length); + const f_string_static_t status_code_short_error_s = macro_f_string_static_t_initialize(STATUS_CODE_short_error_s, 0, STATUS_CODE_short_error_s_length); const f_string_static_t status_code_short_number_s = macro_f_string_static_t_initialize(STATUS_CODE_short_number_s, 0, STATUS_CODE_short_number_s_length); - const f_string_static_t status_code_long_is_fine_s = macro_f_string_static_t_initialize(STATUS_CODE_long_is_fine_s, 0, STATUS_CODE_long_is_fine_s_length); - const f_string_static_t status_code_long_is_warning_s = macro_f_string_static_t_initialize(STATUS_CODE_long_is_warning_s, 0, STATUS_CODE_long_is_warning_s_length); - const f_string_static_t status_code_long_is_error_s = macro_f_string_static_t_initialize(STATUS_CODE_long_is_error_s, 0, STATUS_CODE_long_is_error_s_length); + const f_string_static_t status_code_long_fine_s = macro_f_string_static_t_initialize(STATUS_CODE_long_fine_s, 0, STATUS_CODE_long_fine_s_length); + const f_string_static_t status_code_long_warning_s = macro_f_string_static_t_initialize(STATUS_CODE_long_warning_s, 0, STATUS_CODE_long_warning_s_length); + const f_string_static_t status_code_long_error_s = macro_f_string_static_t_initialize(STATUS_CODE_long_error_s, 0, STATUS_CODE_long_error_s_length); const f_string_static_t status_code_long_number_s = macro_f_string_static_t_initialize(STATUS_CODE_long_number_s, 0, STATUS_CODE_long_number_s_length); #endif // _di_status_code_parameters_ diff --git a/level_3/status_code/c/common.h b/level_3/status_code/c/common.h index d2fed6e..9babb6b 100644 --- a/level_3/status_code/c/common.h +++ b/level_3/status_code/c/common.h @@ -80,34 +80,34 @@ extern "C" { * The main program parameters. */ #ifndef _di_status_code_parameters_ - #define STATUS_CODE_short_is_fine_s "f" - #define STATUS_CODE_short_is_warning_s "w" - #define STATUS_CODE_short_is_error_s "e" - #define STATUS_CODE_short_number_s "n" - - #define STATUS_CODE_long_is_fine_s "is_fine" - #define STATUS_CODE_long_is_warning_s "is_warning" - #define STATUS_CODE_long_is_error_s "is_error" - #define STATUS_CODE_long_number_s "number" - - #define STATUS_CODE_short_is_fine_s_length 1 - #define STATUS_CODE_short_is_warning_s_length 1 - #define STATUS_CODE_short_is_error_s_length 1 - #define STATUS_CODE_short_number_s_length 1 - - #define STATUS_CODE_long_is_fine_s_length 7 - #define STATUS_CODE_long_is_warning_s_length 10 - #define STATUS_CODE_long_is_error_s_length 8 - #define STATUS_CODE_long_number_s_length 6 - - extern const f_string_static_t status_code_short_is_fine_s; - extern const f_string_static_t status_code_short_is_warning_s; - extern const f_string_static_t status_code_short_is_error_s; + #define STATUS_CODE_short_fine_s "f" + #define STATUS_CODE_short_warning_s "w" + #define STATUS_CODE_short_error_s "e" + #define STATUS_CODE_short_number_s "n" + + #define STATUS_CODE_long_fine_s "fine" + #define STATUS_CODE_long_warning_s "warning" + #define STATUS_CODE_long_error_s "error" + #define STATUS_CODE_long_number_s "number" + + #define STATUS_CODE_short_fine_s_length 1 + #define STATUS_CODE_short_warning_s_length 1 + #define STATUS_CODE_short_error_s_length 1 + #define STATUS_CODE_short_number_s_length 1 + + #define STATUS_CODE_long_fine_s_length 4 + #define STATUS_CODE_long_warning_s_length 7 + #define STATUS_CODE_long_error_s_length 5 + #define STATUS_CODE_long_number_s_length 6 + + extern const f_string_static_t status_code_short_fine_s; + extern const f_string_static_t status_code_short_warning_s; + extern const f_string_static_t status_code_short_error_s; extern const f_string_static_t status_code_short_number_s; - extern const f_string_static_t status_code_long_is_fine_s; - extern const f_string_static_t status_code_long_is_warning_s; - extern const f_string_static_t status_code_long_is_error_s; + extern const f_string_static_t status_code_long_fine_s; + extern const f_string_static_t status_code_long_warning_s; + extern const f_string_static_t status_code_long_error_s; extern const f_string_static_t status_code_long_number_s; enum { @@ -121,9 +121,9 @@ extern "C" { status_code_parameter_verbosity_debug_e, status_code_parameter_version_e, - status_code_parameter_is_fine_e, - status_code_parameter_is_warning_e, - status_code_parameter_is_error_e, + status_code_parameter_fine_e, + status_code_parameter_warning_e, + status_code_parameter_error_e, status_code_parameter_number_e, }; @@ -138,9 +138,9 @@ extern "C" { macro_f_console_parameter_t_initialize(f_console_standard_short_verbose_s.string, f_console_standard_long_verbose_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_debug_s.string, f_console_standard_long_debug_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_version_s.string, f_console_standard_long_version_s.string, 0, 0, f_console_type_inverse_e), \ - macro_f_console_parameter_t_initialize(status_code_short_is_fine_s.string, status_code_long_is_fine_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(status_code_short_is_warning_s.string, status_code_long_is_warning_s.string, 0, 0, f_console_type_normal_e), \ - macro_f_console_parameter_t_initialize(status_code_short_is_error_s.string, status_code_long_is_error_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(status_code_short_fine_s.string, status_code_long_fine_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(status_code_short_warning_s.string, status_code_long_warning_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(status_code_short_error_s.string, status_code_long_error_s.string, 0, 0, f_console_type_normal_e), \ macro_f_console_parameter_t_initialize(status_code_short_number_s.string, status_code_long_number_s.string, 0, 0, f_console_type_normal_e), \ } diff --git a/level_3/status_code/c/private-status_code.c b/level_3/status_code/c/private-status_code.c index 44e09e3..185a041 100644 --- a/level_3/status_code/c/private-status_code.c +++ b/level_3/status_code/c/private-status_code.c @@ -14,7 +14,7 @@ extern "C" { if (F_status_is_error(status)) return status; - if (main->parameters.array[status_code_parameter_is_error_e].result == f_console_result_found_e) { + if (main->parameters.array[status_code_parameter_error_e].result == f_console_result_found_e) { if (F_status_is_error(number)) { f_print_dynamic_raw(f_status_true_s, main->output.to.stream); } @@ -24,7 +24,7 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } - else if (main->parameters.array[status_code_parameter_is_warning_e].result == f_console_result_found_e) { + else if (main->parameters.array[status_code_parameter_warning_e].result == f_console_result_found_e) { if (F_status_is_warning(number)) { f_print_dynamic_raw(f_status_true_s, main->output.to.stream); } @@ -34,7 +34,7 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } - else if (main->parameters.array[status_code_parameter_is_fine_e].result == f_console_result_found_e) { + else if (main->parameters.array[status_code_parameter_fine_e].result == f_console_result_found_e) { if (F_status_is_fine(number)) { f_print_dynamic_raw(f_status_true_s, main->output.to.stream); } @@ -93,6 +93,14 @@ extern "C" { return F_none; } + if (main->parameters.array[status_code_parameter_error_e].result == f_console_result_found_e) { + code = F_status_set_error(code); + } + + if (main->parameters.array[status_code_parameter_warning_e].result == f_console_result_found_e) { + code = F_status_set_warning(code); + } + fl_print_format("%ui%r", main->output.to.stream, code, f_string_eol_s); return F_none; diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index 3c383e8..e53ca4f 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -25,10 +25,10 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, file.stream); - fll_program_print_help_option(file, context, status_code_short_is_fine_s, status_code_long_is_fine_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print F_true if the error code is not an error, F_false otherwise."); - fll_program_print_help_option(file, context, status_code_short_is_warning_s, status_code_long_is_warning_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Print F_true if the error code is a warning, F_false otherwise."); - fll_program_print_help_option(file, context, status_code_short_is_error_s, status_code_long_is_error_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print F_true if the error code is an error, F_false otherwise."); - fll_program_print_help_option(file, context, 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."); + fll_program_print_help_option(file, context, status_code_short_fine_s, status_code_long_fine_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print F_true or F_false if status code is neither an error nor a warning or print number with neither the error code nor the warning code bits set."); + fll_program_print_help_option(file, context, status_code_short_warning_s, status_code_long_warning_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Print F_true or F_false if status code is a warning or print number with warning code bit set."); + fll_program_print_help_option(file, context, 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(file, context, 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."); fll_program_print_help_usage(file, context, status_code_program_name_s, status_code_program_help_parameters_s); @@ -119,45 +119,41 @@ extern "C" { return F_none; } - if (main->parameters.array[status_code_parameter_is_error_e].result == f_console_result_found_e) { - if (main->parameters.array[status_code_parameter_is_warning_e].result == f_console_result_found_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, status_code_long_is_error_s, main->error.notable); - fl_print_format("%[' cannot be used with 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, status_code_long_is_warning_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); + if (main->parameters.array[status_code_parameter_error_e].result == f_console_result_found_e) { + if (main->parameters.array[status_code_parameter_warning_e].result == f_console_result_found_e) { + if (main->parameters.array[status_code_parameter_number_e].result == f_console_result_none_e) { + if (main->error.verbosity != f_console_verbosity_quiet_e) { + flockfile(main->error.to.stream); + + fl_print_format("%r%[%QCannot 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, status_code_long_error_s, main->error.notable); + fl_print_format("%[' parameter with 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, status_code_long_warning_s, main->error.notable); + fl_print_format("%[' parameter when not also specifying 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, status_code_long_number_s, main->error.notable); + fl_print_format("%[' parameter.%]%r%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s, f_string_eol_s); + + funlockfile(main->error.to.stream); + } - return F_status_set_error(status); + return F_status_set_error(status); + } } - if (main->parameters.array[status_code_parameter_is_fine_e].result == f_console_result_found_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, status_code_long_is_error_s, main->error.notable); - fl_print_format("%[' cannot be used with 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, status_code_long_is_fine_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); + if (main->parameters.array[status_code_parameter_fine_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, status_code_long_error_s, status_code_long_fine_s); + fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); + } return F_status_set_error(status); } } - else if (main->parameters.array[status_code_parameter_is_warning_e].result == f_console_result_found_e && main->parameters.array[status_code_parameter_is_fine_e].result == f_console_result_found_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, status_code_long_is_warning_s, main->error.notable); - fl_print_format("%[' cannot be used with 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, status_code_long_is_fine_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); + else if (main->parameters.array[status_code_parameter_warning_e].result == f_console_result_found_e && main->parameters.array[status_code_parameter_fine_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, status_code_long_warning_s, status_code_long_fine_s); + fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); + } return F_status_set_error(status); } @@ -170,12 +166,12 @@ extern "C" { f_status_t status2 = F_none; - if (main->parameters.array[status_code_parameter_is_error_e].result == f_console_result_found_e || main->parameters.array[status_code_parameter_is_warning_e].result == f_console_result_found_e || main->parameters.array[status_code_parameter_is_fine_e].result == f_console_result_found_e) { + if (main->parameters.array[status_code_parameter_number_e].result == f_console_result_found_e) { if (main->process_pipe) { - // @todo call status_code_process_check() here for all main from pipe that is space separated. + // @todo call status_code_process_number() here for all main from pipe that is space separated. } - if (main->parameters.remaining.used > 0) { + if (main->parameters.remaining.used) { flockfile(main->output.to.stream); for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { @@ -192,7 +188,7 @@ extern "C" { main->signal_check = 0; } - status2 = status_code_process_check(main, argv[main->parameters.remaining.array[i]]); + status2 = status_code_process_number(main, argv[main->parameters.remaining.array[i]]); if (F_status_is_error(status2) && status == F_none) { status = status2; @@ -202,12 +198,12 @@ extern "C" { funlockfile(main->output.to.stream); } } - else if (main->parameters.array[status_code_parameter_number_e].result == f_console_result_found_e) { + else if (main->parameters.array[status_code_parameter_error_e].result == f_console_result_found_e || main->parameters.array[status_code_parameter_warning_e].result == f_console_result_found_e || main->parameters.array[status_code_parameter_fine_e].result == f_console_result_found_e) { if (main->process_pipe) { - // @todo call status_code_process_number() here for all main from pipe that is space separated. + // @todo call status_code_process_check() here for all main from pipe that is space separated. } - if (main->parameters.remaining.used > 0) { + if (main->parameters.remaining.used) { flockfile(main->output.to.stream); for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { @@ -224,7 +220,7 @@ extern "C" { main->signal_check = 0; } - status2 = status_code_process_number(main, argv[main->parameters.remaining.array[i]]); + status2 = status_code_process_check(main, argv[main->parameters.remaining.array[i]]); if (F_status_is_error(status2) && status == F_none) { status = status2; @@ -239,7 +235,7 @@ extern "C" { // @todo call status_code_process_normal() here for all main from pipe that is space separated. } - if (main->parameters.remaining.used > 0) { + if (main->parameters.remaining.used) { flockfile(main->output.to.stream); for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { @@ -267,8 +263,8 @@ extern "C" { } } - if (main->error.verbosity != f_console_verbosity_quiet_e) { - if (F_status_set_fine(status) == F_interrupt) { + if (F_status_set_fine(status) == F_interrupt) { + if (main->output.verbosity != f_console_verbosity_quiet_e) { fflush(main->output.to.stream); fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); -- 1.8.3.1