From bd69fbb0779198dca8c3ab004f14393f070c3f20 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 14 Nov 2022 21:10:10 -0600 Subject: [PATCH] Progress: Continue program related work. Lots of print related changes and improvements. Primarily working on fss_payload_write changes. --- level_2/fll_program/c/program/print.c | 38 +++ level_2/fll_program/c/program/print.h | 70 +++++ level_3/byte_dump/c/byte_dump.c | 4 + level_3/byte_dump/c/byte_dump.h | 1 + level_3/byte_dump/c/common.c | 19 +- level_3/control/c/common.c | 19 +- level_3/control/c/control.c | 4 + level_3/control/c/control.h | 1 + level_3/controller/c/common.c | 19 +- level_3/controller/c/controller.c | 4 + level_3/controller/c/controller.h | 1 + level_3/fake/c/common.c | 19 +- level_3/fake/c/fake.c | 4 + level_3/fake/c/fake.h | 1 + level_3/firewall/c/common.c | 19 +- level_3/firewall/c/firewall.c | 4 + level_3/firewall/c/firewall.h | 1 + level_3/fss_basic_list_read/c/common.c | 19 +- .../fss_basic_list_read/c/fss_basic_list_read.c | 4 + .../fss_basic_list_read/c/fss_basic_list_read.h | 1 + level_3/fss_basic_list_write/c/common.c | 19 +- .../fss_basic_list_write/c/fss_basic_list_write.c | 4 + .../fss_basic_list_write/c/fss_basic_list_write.h | 1 + level_3/fss_basic_read/c/common.c | 19 +- level_3/fss_basic_read/c/fss_basic_read.c | 4 + level_3/fss_basic_read/c/fss_basic_read.h | 1 + level_3/fss_basic_write/c/common.c | 19 +- level_3/fss_basic_write/c/fss_basic_write.c | 4 + level_3/fss_basic_write/c/fss_basic_write.h | 1 + level_3/fss_embedded_list_read/c/common.c | 19 +- .../c/fss_embedded_list_read.c | 4 + .../c/fss_embedded_list_read.h | 1 + level_3/fss_embedded_list_write/c/common.c | 19 +- .../c/fss_embedded_list_write.c | 4 + .../c/fss_embedded_list_write.h | 1 + level_3/fss_extended_list_read/c/common.c | 19 +- .../c/fss_extended_list_read.c | 4 + .../c/fss_extended_list_read.h | 1 + level_3/fss_extended_list_write/c/common.c | 19 +- .../c/fss_extended_list_write.c | 4 + .../c/fss_extended_list_write.h | 1 + level_3/fss_extended_read/c/common.c | 19 +- level_3/fss_extended_read/c/fss_extended_read.c | 4 + level_3/fss_extended_read/c/fss_extended_read.h | 1 + level_3/fss_extended_write/c/common.c | 19 +- level_3/fss_extended_write/c/fss_extended_write.c | 2 + level_3/fss_extended_write/c/fss_extended_write.h | 1 + level_3/fss_identify/c/common.c | 19 +- level_3/fss_identify/c/fss_identify.c | 4 + level_3/fss_identify/c/fss_identify.h | 1 + level_3/fss_payload_read/c/common.c | 28 +- level_3/fss_payload_read/c/common.h | 48 ++-- level_3/fss_payload_read/c/fss_payload_read.c | 13 +- level_3/fss_payload_read/c/fss_payload_read.h | 1 + level_3/fss_payload_write/c/common.c | 298 +++++++++++++++++++- level_3/fss_payload_write/c/common.h | 78 ++++-- level_3/fss_payload_write/c/fss_payload_write.c | 308 +++++++++------------ level_3/fss_payload_write/c/fss_payload_write.h | 3 +- level_3/fss_payload_write/c/print.c | 62 +++++ level_3/fss_payload_write/c/print.h | 85 ++++++ level_3/fss_payload_write/c/private-write.c | 30 +- level_3/iki_read/c/common.c | 55 ++-- level_3/iki_read/c/iki_read.c | 24 +- level_3/iki_read/c/print.c | 26 ++ level_3/iki_read/c/print.h | 49 ++++ level_3/iki_read/c/private-read.c | 12 +- level_3/iki_write/c/common.c | 22 +- level_3/iki_write/c/iki_write.c | 20 +- level_3/iki_write/c/iki_write.h | 7 + level_3/iki_write/c/print.c | 102 ++++--- level_3/iki_write/c/print.h | 125 ++++++--- level_3/iki_write/c/private-write.c | 36 ++- level_3/iki_write/c/private-write.h | 16 +- level_3/status_code/c/common.c | 12 +- level_3/status_code/c/print.c | 13 + level_3/status_code/c/print.h | 20 ++ level_3/utf8/c/common.c | 40 +-- level_3/utf8/c/print.c | 26 ++ level_3/utf8/c/print.h | 49 ++++ level_3/utf8/c/utf8.c | 6 +- 80 files changed, 1572 insertions(+), 532 deletions(-) diff --git a/level_2/fll_program/c/program/print.c b/level_2/fll_program/c/program/print.c index e429df0..c7e6075 100644 --- a/level_2/fll_program/c/program/print.c +++ b/level_2/fll_program/c/program/print.c @@ -77,6 +77,44 @@ extern "C" { } #endif // _di_fll_program_print_error_parameter_cannot_use_with_ +#ifndef _di_fll_program_print_error_parameter_cannot_use_with_pipe_ + f_status_t fll_program_print_error_parameter_cannot_use_with_pipe(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("%[%QCannot specify the '%]", print.to, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%Q%Q%]", print.to, print.set->notable, symbol, parameter, print.set->notable); + fl_print_format("%[' when processing a pipe.%]%r", print.to, 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_pipe_ + +#ifndef _di_fll_program_print_error_parameter_cannot_use_with_xor_ + f_status_t fll_program_print_error_parameter_cannot_use_with_xor(const fl_print_t print, const f_string_static_t symbol_first, const f_string_static_t symbol_second, const f_string_static_t symbol_third, const f_string_static_t first, const f_string_static_t second, const f_string_static_t third) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%r%[%QThe '%]", print.to, f_string_eol_s, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%Q%Q%]", print.to, print.set->notable, symbol_first, first, print.set->notable); + fl_print_format("%[' parameter only allows either the '%]", print.to, print.set->error, print.set->error); + fl_print_format("%[%Q%Q%]", print.to, print.set->notable, symbol_second, second, print.set->notable); + fl_print_format("%[' parameter or the '%]", print.to, print.set->error, print.set->error); + fl_print_format("%[%Q%Q%]", print.to, print.set->notable, symbol_third, third, print.set->notable); + fl_print_format("%[' parameter, but not both.%]%r", print.to, 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_xor_ + #ifndef _di_fll_program_print_error_parameter_integer_not_ f_status_t fll_program_print_error_parameter_integer_not(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter, const f_string_static_t value) { diff --git a/level_2/fll_program/c/program/print.h b/level_2/fll_program/c/program/print.h index 95d8478..7734235 100644 --- a/level_2/fll_program/c/program/print.h +++ b/level_2/fll_program/c/program/print.h @@ -124,6 +124,76 @@ extern "C" { #endif // _di_fll_program_print_error_parameter_cannot_use_with_ /** + * Print message about one parameter not being allowed to be used when processing a pipe. + * + * 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 the first parameter. + * 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_cannot_use_with_pipe_ + extern f_status_t fll_program_print_error_parameter_cannot_use_with_pipe(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter); +#endif // _di_fll_program_print_error_parameter_cannot_use_with_pipe_ + +/** + * Print message about two parameters not being allowed to be used together with another specified 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_first + * The symbol string prepended to the first parameter. + * This is usually f_console_symbol_long_enable_s. + * @param symbol_second + * The symbol string prepended to the second parameter. + * This is usually f_console_symbol_long_enable_s. + * @param symbol_third + * The symbol string prepended to the third parameter. + * This is usually f_console_symbol_long_enable_s. + * @param first + * The first parameter name. + * + * This represents the parameter that imposes the exclusive or relation on the second and third parameters. + * @param second + * The second parameter name. + * + * This represents the parameter that is an exclusive or with the third parameter. + * @param third + * The second parameter name. + * + * This represents the parameter that is an exclusive or with the second parameter. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fll_program_print_error_parameter_allows_either_xor_ + extern f_status_t fll_program_print_error_parameter_cannot_use_with_xor(const fl_print_t print, const f_string_static_t symbol_first, const f_string_static_t symbol_second, const f_string_static_t symbol_third, const f_string_static_t first, const f_string_static_t second, const f_string_static_t third); +#endif // _di_fll_program_print_error_parameter_allows_either_xor_ + +/** * Print message about parameter not being a valid integer. * * This is only printed when verbosity is not set to quiet. diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index 855b679..70f7be3 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -30,7 +30,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + byte_dump_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + byte_dump_print_line_last_locked(setting, main->error); return; } @@ -47,7 +49,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + byte_dump_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + byte_dump_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/byte_dump/c/byte_dump.h b/level_3/byte_dump/c/byte_dump.h index cd798c7..b117547 100644 --- a/level_3/byte_dump/c/byte_dump.h +++ b/level_3/byte_dump/c/byte_dump.h @@ -48,6 +48,7 @@ // Byte Dump includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/byte_dump/c/common.c b/level_3/byte_dump/c/common.c index 34dc117..9b991e2 100644 --- a/level_3/byte_dump/c/common.c +++ b/level_3/byte_dump/c/common.c @@ -83,7 +83,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)) { + byte_dump_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + byte_dump_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -100,8 +107,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - byte_dump_print_line_first(setting, main->error, F_true); + byte_dump_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + byte_dump_print_line_last_locked(setting, main->error); return; } @@ -132,8 +140,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - byte_dump_print_line_first(setting, main->error, F_true); + byte_dump_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + byte_dump_print_line_last_locked(setting, main->error); return; } @@ -152,6 +161,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[byte_dump_parameter_strip_invalid_e].result == f_console_result_found_e) { diff --git a/level_3/control/c/common.c b/level_3/control/c/common.c index 6a57dda..8e2ad1e 100644 --- a/level_3/control/c/common.c +++ b/level_3/control/c/common.c @@ -186,7 +186,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)) { + control_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + control_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -203,8 +210,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - control_print_line_first(setting, main->error, F_true); + control_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + control_print_line_last_locked(setting, main->error); return; } @@ -235,8 +243,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - control_print_line_first(setting, main->error, F_true); + control_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + control_print_line_last_locked(setting, main->error); return; } @@ -255,6 +264,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[control_parameter_strip_invalid_e].result == f_console_result_found_e) { diff --git a/level_3/control/c/control.c b/level_3/control/c/control.c index a1dec4f..f4ddb02 100644 --- a/level_3/control/c/control.c +++ b/level_3/control/c/control.c @@ -31,7 +31,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + control_print_line_first_locked(setting, main->error) fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + control_print_line_last_locked(setting, main->error); return; } @@ -48,7 +50,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + control_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + control_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/control/c/control.h b/level_3/control/c/control.h index 980be6c..0c6407b 100644 --- a/level_3/control/c/control.h +++ b/level_3/control/c/control.h @@ -52,6 +52,7 @@ // Control includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/controller/c/common.c b/level_3/controller/c/common.c index 07b5523..4d5fbdf 100644 --- a/level_3/controller/c/common.c +++ b/level_3/controller/c/common.c @@ -618,7 +618,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)) { + controller_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + controller_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -635,8 +642,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - controller_print_line_first(setting, main->error, F_true); + controller_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + controller_print_line_last_locked(setting, main->error); return; } @@ -667,8 +675,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - controller_print_line_first(setting, main->error, F_true); + controller_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + controller_print_line_last_locked(setting, main->error); return; } @@ -687,6 +696,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[controller_parameter_strip_invalid_e].result == f_console_result_found_e) { diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index 5f6f70f..2e598b1 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -36,7 +36,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + controller_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + controller_print_line_last_locked(setting, main->error); return; } @@ -53,7 +55,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + controller_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + controller_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/controller/c/controller.h b/level_3/controller/c/controller.h index d3ae9b5..25a6c4e 100644 --- a/level_3/controller/c/controller.h +++ b/level_3/controller/c/controller.h @@ -76,6 +76,7 @@ // Controller includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fake/c/common.c b/level_3/fake/c/common.c index ecbf20d..28de632 100644 --- a/level_3/fake/c/common.c +++ b/level_3/fake/c/common.c @@ -131,7 +131,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)) { + fake_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fake_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -148,8 +155,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fake_print_line_first(setting, main->error, F_true); + fake_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fake_print_line_last_locked(setting, main->error); return; } @@ -180,8 +188,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fake_print_line_first(setting, main->error, F_true); + fake_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fake_print_line_last_locked(setting, main->error); return; } @@ -200,6 +209,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fake_parameter_strip_invalid_e].result == f_console_result_found_e) { diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index 7e48ba1..ddefbbd 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -37,7 +37,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + fake_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + fake_print_line_last_locked(setting, main->error); return; } @@ -54,7 +56,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fake_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fake_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fake/c/fake.h b/level_3/fake/c/fake.h index 972d326..254ce0a 100644 --- a/level_3/fake/c/fake.h +++ b/level_3/fake/c/fake.h @@ -91,6 +91,7 @@ // Featureless Make includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/firewall/c/common.c b/level_3/firewall/c/common.c index 759827b..5e6058d 100644 --- a/level_3/firewall/c/common.c +++ b/level_3/firewall/c/common.c @@ -119,7 +119,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)) { + firewall_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + firewall_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -136,8 +143,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - firewall_print_line_first(setting, main->error, F_true); + firewall_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + firewall_print_line_last_locked(setting, main->error); return; } @@ -168,8 +176,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - firewall_print_line_first(setting, main->error, F_true); + firewall_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + firewall_print_line_last_locked(setting, main->error); return; } @@ -188,6 +197,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[firewall_parameter_strip_invalid_e].result == f_console_result_found_e) { diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index d89c92e..0e8489b 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -38,7 +38,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + firewall_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + firewall_print_line_last_locked(setting, main->error); return; } @@ -55,7 +57,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + firewall_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + firewall_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/firewall/c/firewall.h b/level_3/firewall/c/firewall.h index b05ec3c..3fc3b5f 100644 --- a/level_3/firewall/c/firewall.h +++ b/level_3/firewall/c/firewall.h @@ -49,6 +49,7 @@ // Firewall includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_basic_list_read/c/common.c b/level_3/fss_basic_list_read/c/common.c index 2afe8bf..8486314 100644 --- a/level_3/fss_basic_list_read/c/common.c +++ b/level_3/fss_basic_list_read/c/common.c @@ -77,7 +77,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_basic_list_read_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_basic_list_read_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -94,8 +101,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_basic_list_read_print_line_first(setting, main->error, F_true); + fss_basic_list_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fss_basic_list_read_print_line_last_locked(setting, main->error); return; } @@ -126,8 +134,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_basic_list_read_print_line_first(setting, main->error, F_true); + fss_basic_list_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fss_basic_list_read_print_line_last_locked(setting, main->error); return; } @@ -146,6 +155,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_basic_list_read_parameter_strip_invalid_e].result == f_console_result_found_e) { 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 e06f495..a73a06f 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 @@ -31,7 +31,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + fss_basic_list_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + fss_basic_list_read_print_line_last_locked(setting, main->error); return; } @@ -48,7 +50,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fss_basic_list_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fss_basic_list_read_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.h b/level_3/fss_basic_list_read/c/fss_basic_list_read.h index d6bc982..2433f82 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.h +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.h @@ -49,6 +49,7 @@ // FSS Basic List Read includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_basic_list_write/c/common.c b/level_3/fss_basic_list_write/c/common.c index beb3a6f..e96ab73 100644 --- a/level_3/fss_basic_list_write/c/common.c +++ b/level_3/fss_basic_list_write/c/common.c @@ -58,7 +58,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_basic_list_write_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_basic_list_write_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -75,8 +82,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_basic_list_write_print_line_first(setting, main->error, F_true); + fss_basic_list_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fss_basic_list_write_print_line_last_locked(setting, main->error); return; } @@ -107,8 +115,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_basic_list_write_print_line_first(setting, main->error, F_true); + fss_basic_list_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fss_basic_list_write_print_line_last_locked(setting, main->error); return; } @@ -127,6 +136,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_basic_list_write_parameter_strip_invalid_e].result == f_console_result_found_e) { 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 cb43de2..ef8e535 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 @@ -30,7 +30,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + fss_basic_list_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + fss_basic_list_write_print_line_last_locked(setting, main->error); return; } @@ -47,7 +49,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fss_basic_list_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fss_basic_list_write_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.h b/level_3/fss_basic_list_write/c/fss_basic_list_write.h index 251c719..1c6a804 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.h +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.h @@ -41,6 +41,7 @@ // FSS Basic List Write includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_basic_read/c/common.c b/level_3/fss_basic_read/c/common.c index c275f86..ba9d8e4 100644 --- a/level_3/fss_basic_read/c/common.c +++ b/level_3/fss_basic_read/c/common.c @@ -76,7 +76,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_basic_read_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_basic_read_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -93,8 +100,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_basic_read_print_line_first(setting, main->error, F_true); + fss_basic_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fss_basic_read_print_line_last_locked(setting, main->error); return; } @@ -125,8 +133,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_basic_read_print_line_first(setting, main->error, F_true); + fss_basic_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fss_basic_read_print_line_last_locked(setting, main->error); return; } @@ -145,6 +154,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_basic_read_parameter_strip_invalid_e].result == f_console_result_found_e) { 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 3978cda..b114faa 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -31,7 +31,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + fss_basic_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + fss_basic_read_print_line_last_locked(setting, main->error); return; } @@ -48,7 +50,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fss_basic_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fss_basic_read_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fss_basic_read/c/fss_basic_read.h b/level_3/fss_basic_read/c/fss_basic_read.h index acc481f..eb30e3e 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.h +++ b/level_3/fss_basic_read/c/fss_basic_read.h @@ -49,6 +49,7 @@ // FSS Basic Read includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_basic_write/c/common.c b/level_3/fss_basic_write/c/common.c index 2a5fef9..5a0d36b 100644 --- a/level_3/fss_basic_write/c/common.c +++ b/level_3/fss_basic_write/c/common.c @@ -58,7 +58,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_basic_write_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_basic_write_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -75,8 +82,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_basic_write_print_line_first(setting, main->error, F_true); + fss_basic_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fss_basic_write_print_line_last_locked(setting, main->error); return; } @@ -107,8 +115,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_basic_write_print_line_first(setting, main->error, F_true); + fss_basic_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fss_basic_write_print_line_last_locked(setting, main->error); return; } @@ -127,6 +136,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_basic_write_parameter_strip_invalid_e].result == f_console_result_found_e) { 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 44397a1..8ba09d5 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -30,7 +30,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + fss_basic_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + fss_basic_write_print_line_last_locked(setting, main->error); return; } @@ -47,7 +49,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fss_basic_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fss_basic_write_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fss_basic_write/c/fss_basic_write.h b/level_3/fss_basic_write/c/fss_basic_write.h index f9b3294..c39d88a 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.h +++ b/level_3/fss_basic_write/c/fss_basic_write.h @@ -42,6 +42,7 @@ // FSS Basic Write includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_embedded_list_read/c/common.c b/level_3/fss_embedded_list_read/c/common.c index f7353da..9f07442 100644 --- a/level_3/fss_embedded_list_read/c/common.c +++ b/level_3/fss_embedded_list_read/c/common.c @@ -75,7 +75,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_embedded_list_read_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_embedded_list_read_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -92,8 +99,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_embedded_list_read_print_line_first(setting, main->error, F_true); + fss_embedded_list_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fss_embedded_list_read_print_line_last_locked(setting, main->error); return; } @@ -124,8 +132,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_embedded_list_read_print_line_first(setting, main->error, F_true); + fss_embedded_list_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fss_embedded_list_read_print_line_last_locked(setting, main->error); return; } @@ -144,6 +153,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_embedded_list_read_parameter_strip_invalid_e].result == f_console_result_found_e) { 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 b170ba0..4eb69bc 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 @@ -31,7 +31,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + fss_embedded_list_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + fss_embedded_list_read_print_line_last_locked(setting, main->error); return; } @@ -48,7 +50,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fss_embedded_list_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fss_embedded_list_read_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h index 0145067..d203715 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h @@ -49,6 +49,7 @@ // FSS Embedded List Read includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_embedded_list_write/c/common.c b/level_3/fss_embedded_list_write/c/common.c index 11bfc9e..d79cb19 100644 --- a/level_3/fss_embedded_list_write/c/common.c +++ b/level_3/fss_embedded_list_write/c/common.c @@ -58,7 +58,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_embedded_list_write_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_embedded_list_write_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -75,8 +82,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_embedded_list_write_print_line_first(setting, main->error, F_true); + fss_embedded_list_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fss_embedded_list_write_print_line_last_locked(setting, main->error); return; } @@ -107,8 +115,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_embedded_list_write_print_line_first(setting, main->error, F_true); + fss_embedded_list_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fss_embedded_list_write_print_line_last_locked(setting, main->error); return; } @@ -127,6 +136,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_embedded_list_write_parameter_strip_invalid_e].result == f_console_result_found_e) { 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 83a188b..e33b6be 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 @@ -30,7 +30,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + fss_embedded_list_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + fss_embedded_list_write_print_line_last_locked(setting, main->error); return; } @@ -47,7 +49,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fss_embedded_list_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fss_embedded_list_write_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.h b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.h index 4347d39..8f10b92 100644 --- a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.h +++ b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.h @@ -42,6 +42,7 @@ // FSS Embedded List Write includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_extended_list_read/c/common.c b/level_3/fss_extended_list_read/c/common.c index 727047c..bfd366f 100644 --- a/level_3/fss_extended_list_read/c/common.c +++ b/level_3/fss_extended_list_read/c/common.c @@ -83,7 +83,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_extended_list_read_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_extended_list_read_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -100,8 +107,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_extended_list_read_print_line_first(setting, main->error, F_true); + fss_extended_list_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fss_extended_list_read_print_line_last_locked(setting, main->error); return; } @@ -132,8 +140,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_extended_list_read_print_line_first(setting, main->error, F_true); + fss_extended_list_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fss_extended_list_read_print_line_last_locked(setting, main->error); return; } @@ -152,6 +161,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_extended_list_read_parameter_strip_invalid_e].result == f_console_result_found_e) { 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 5d4dddc..0798799 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 @@ -31,7 +31,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + fss_extended_list_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + fss_extended_list_read_print_line_last_locked(setting, main->error); return; } @@ -48,7 +50,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fss_extended_list_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fss_extended_list_read_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.h b/level_3/fss_extended_list_read/c/fss_extended_list_read.h index b2b6cc5..e77afb9 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.h +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.h @@ -49,6 +49,7 @@ // FSS Extended List Read includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_extended_list_write/c/common.c b/level_3/fss_extended_list_write/c/common.c index 6043faf..74f14e5 100644 --- a/level_3/fss_extended_list_write/c/common.c +++ b/level_3/fss_extended_list_write/c/common.c @@ -65,7 +65,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_extended_list_write_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_extended_list_write_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -82,8 +89,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_extended_list_write_print_line_first(setting, main->error, F_true); + fss_extended_list_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fss_extended_list_write_print_line_last_locked(setting, main->error); return; } @@ -114,8 +122,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_extended_list_write_print_line_first(setting, main->error, F_true); + fss_extended_list_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fss_extended_list_write_print_line_last_locked(setting, main->error); return; } @@ -134,6 +143,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_extended_list_write_parameter_strip_invalid_e].result == f_console_result_found_e) { 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 2024196..1705cc2 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 @@ -30,7 +30,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + fss_extended_list_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + fss_extended_list_write_print_line_last_locked(setting, main->error); return; } @@ -47,7 +49,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fss_extended_list_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fss_extended_list_write_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fss_extended_list_write/c/fss_extended_list_write.h b/level_3/fss_extended_list_write/c/fss_extended_list_write.h index 64f3df7..6dea20d 100644 --- a/level_3/fss_extended_list_write/c/fss_extended_list_write.h +++ b/level_3/fss_extended_list_write/c/fss_extended_list_write.h @@ -42,6 +42,7 @@ // FSS Extended List Write includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_extended_read/c/common.c b/level_3/fss_extended_read/c/common.c index 518f301..e272744 100644 --- a/level_3/fss_extended_read/c/common.c +++ b/level_3/fss_extended_read/c/common.c @@ -76,7 +76,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_extended_read_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_extended_read_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -93,8 +100,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_extended_read_print_line_first(setting, main->error, F_true); + fss_extended_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fss_extended_read_print_line_last_locked(setting, main->error); return; } @@ -125,8 +133,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_extended_read_print_line_first(setting, main->error, F_true); + fss_extended_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fss_extended_read_print_line_last_locked(setting, main->error); return; } @@ -145,6 +154,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_extended_read_parameter_strip_invalid_e].result == f_console_result_found_e) { 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 24d76c0..ee11649 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -31,7 +31,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + fss_extended_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + fss_extended_read_print_line_last_locked(setting, main->error); return; } @@ -48,7 +50,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fss_extended_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fss_extended_read_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fss_extended_read/c/fss_extended_read.h b/level_3/fss_extended_read/c/fss_extended_read.h index 9d28801..be4fe40 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.h +++ b/level_3/fss_extended_read/c/fss_extended_read.h @@ -49,6 +49,7 @@ // FSS Extended Read includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_extended_write/c/common.c b/level_3/fss_extended_write/c/common.c index c8dbc47..0d1084c 100644 --- a/level_3/fss_extended_write/c/common.c +++ b/level_3/fss_extended_write/c/common.c @@ -58,7 +58,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_extended_write_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_extended_write_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -75,8 +82,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_extended_write_print_line_first(setting, main->error, F_true); + fss_extended_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fss_extended_write_print_line_last_locked(setting, main->error); return; } @@ -107,8 +115,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_extended_write_print_line_first(setting, main->error, F_true); + fss_extended_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fss_extended_write_print_line_last_locked(setting, main->error); return; } @@ -127,6 +136,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_extended_write_parameter_strip_invalid_e].result == f_console_result_found_e) { 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 23c3e27..fa47b62 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -47,7 +47,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fss_extended_write_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fss_extended_write_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fss_extended_write/c/fss_extended_write.h b/level_3/fss_extended_write/c/fss_extended_write.h index e1da061..8f1ea51 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.h +++ b/level_3/fss_extended_write/c/fss_extended_write.h @@ -42,6 +42,7 @@ // FSS Extended Write includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_identify/c/common.c b/level_3/fss_identify/c/common.c index 06971ea..91485b9 100644 --- a/level_3/fss_identify/c/common.c +++ b/level_3/fss_identify/c/common.c @@ -43,7 +43,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_identify_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_identify_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -60,8 +67,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_identify_print_line_first(setting, main->error, F_true); + fss_identify_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fss_identify_print_line_last_locked(setting, main->error); return; } @@ -92,8 +100,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_identify_print_line_first(setting, main->error, F_true); + fss_identify_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fss_identify_print_line_last_locked(setting, main->error); return; } @@ -112,6 +121,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_identify_parameter_strip_invalid_e].result == f_console_result_found_e) { diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index faa490c..fe85174 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -30,7 +30,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + fss_identify_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + fss_identify_print_line_last_locked(setting, main->error); return; } @@ -47,7 +49,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fss_identify_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fss_identify_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fss_identify/c/fss_identify.h b/level_3/fss_identify/c/fss_identify.h index a7750e6..a30d43c 100644 --- a/level_3/fss_identify/c/fss_identify.h +++ b/level_3/fss_identify/c/fss_identify.h @@ -47,6 +47,7 @@ // FSS Identify includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_payload_read/c/common.c b/level_3/fss_payload_read/c/common.c index 2b51e5c..9657bd1 100644 --- a/level_3/fss_payload_read/c/common.c +++ b/level_3/fss_payload_read/c/common.c @@ -4,6 +4,15 @@ extern "C" { #endif +#ifndef _di_fss_payload_read_program_version_ + const f_string_static_t fss_payload_read_program_version_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_program_version_s, 0, FSS_PAYLOAD_READ_program_version_s_length); +#endif // _di_fss_payload_read_program_version_ + +#ifndef _di_fss_payload_read_program_name_ + const f_string_static_t fss_payload_read_program_name_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_program_name_s, 0, FSS_PAYLOAD_READ_program_name_s_length); + const f_string_static_t fss_payload_read_program_name_long_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_program_name_long_s, 0, FSS_PAYLOAD_READ_program_name_long_s_length); +#endif // _di_fss_payload_read_program_name_ + #ifndef _di_fss_payload_read_defines_ const f_string_static_t fss_payload_read_pipe_name_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_pipe_name_s, 0, FSS_PAYLOAD_READ_pipe_name_s_length); @@ -68,7 +77,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_payload_read_print_line_first_locked(setting, main->error); + fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); + fss_payload_read_print_line_last_locked(setting, main->error); + + return; + } { f_array_length_t choice = 0; @@ -85,8 +101,9 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_payload_read_print_line_first(setting, main->error, F_true); + fss_payload_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); + fss_payload_read_print_line_last_locked(setting, main->error); return; } @@ -117,8 +134,9 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_payload_read_print_line_first(setting, main->error, F_true); + fss_payload_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); + fss_payload_read_print_line_last_locked(setting, main->error); return; } @@ -137,6 +155,10 @@ extern "C" { } } + 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; + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_payload_read_parameter_strip_invalid_e].result == f_console_result_found_e) { diff --git a/level_3/fss_payload_read/c/common.h b/level_3/fss_payload_read/c/common.h index 9076ed6..d5465e0 100644 --- a/level_3/fss_payload_read/c/common.h +++ b/level_3/fss_payload_read/c/common.h @@ -291,27 +291,39 @@ extern "C" { * Flags used to represent flags passed to the main function. * * fss_payload_read_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. + * - at: Selecting at a specific index. + * - content: Print Contents. + * - help: Print help. + * - literal: Print as literal data (printing entire variable). + * - line: Selecting at a specific line. + * - name: Selecting using a specific Vocabulary name. + * - object: Print Objects. + * - replace: Using re-assignments. + * - replace: Using replacements. + * - substitute: Using substitutions. + * - total: Enable printing of "total" count. + * - version: Print version. + * - whole: Print all data. + * - wrap: Using wrapping. */ #ifndef _di_fss_payload_read_main_flag_e_ enum { - fss_payload_read_main_flag_none_e = 0x0, - fss_payload_read_main_flag_file_from_e = 0x1, - fss_payload_read_main_flag_file_to_e = 0x2, - fss_payload_read_main_flag_header_e = 0x4, - fss_payload_read_main_flag_help_e = 0x8, - fss_payload_read_main_flag_separate_e = 0x10, - fss_payload_read_main_flag_strip_invalid_e = 0x20, - fss_payload_read_main_flag_verify_e = 0x40, - fss_payload_read_main_flag_version_e = 0x80, + fss_payload_read_main_flag_none_e = 0x0, + fss_payload_read_main_flag_at_e = 0x1, + fss_payload_read_main_flag_content_e = 0x2, + fss_payload_read_main_flag_help_e = 0x4, + fss_payload_read_main_flag_literal_e = 0x8, + fss_payload_read_main_flag_line_e = 0x10, + fss_payload_read_main_flag_name_e = 0x20, + fss_payload_read_main_flag_object_e = 0x40, + fss_payload_read_main_flag_reassign_e = 0x80, + fss_payload_read_main_flag_replace_e = 0x100, + fss_payload_read_main_flag_substitute_e = 0x200, + fss_payload_read_main_flag_total_e = 0x400, + fss_payload_read_main_flag_version_e = 0x800, + fss_payload_read_main_flag_whole_e = 0x1000, + fss_payload_read_main_flag_wrap_e = 0x2000, }; #endif // _di_fss_payload_read_main_flag_e_ 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 ff74d55..40523ef 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.c +++ b/level_3/fss_payload_read/c/fss_payload_read.c @@ -7,15 +7,6 @@ extern "C" { #endif -#ifndef _di_fss_payload_read_program_version_ - const f_string_static_t fss_payload_read_program_version_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_program_version_s, 0, FSS_PAYLOAD_READ_program_version_s_length); -#endif // _di_fss_payload_read_program_version_ - -#ifndef _di_fss_payload_read_program_name_ - const f_string_static_t fss_payload_read_program_name_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_program_name_s, 0, FSS_PAYLOAD_READ_program_name_s_length); - const f_string_static_t fss_payload_read_program_name_long_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_program_name_long_s, 0, FSS_PAYLOAD_READ_program_name_long_s_length); -#endif // _di_fss_payload_read_program_name_ - #ifndef _di_fss_payload_read_main_ f_status_t fss_payload_read_main(fll_program_data_t * const main, fss_payload_read_setting_t * const setting) { @@ -40,7 +31,9 @@ extern "C" { status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(status)) { + fss_payload_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + fss_payload_read_print_line_last_locked(setting, main->error); return; } @@ -57,7 +50,9 @@ extern "C" { status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(status)) { + fss_payload_read_print_line_first_locked(setting, main->error); fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + fss_payload_read_print_line_last_locked(setting, main->error); return; } diff --git a/level_3/fss_payload_read/c/fss_payload_read.h b/level_3/fss_payload_read/c/fss_payload_read.h index 237c49c..914df74 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.h +++ b/level_3/fss_payload_read/c/fss_payload_read.h @@ -50,6 +50,7 @@ // FSS Payload Read includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_payload_write/c/common.c b/level_3/fss_payload_write/c/common.c index 6af79f4..5c53e90 100644 --- a/level_3/fss_payload_write/c/common.c +++ b/level_3/fss_payload_write/c/common.c @@ -4,6 +4,15 @@ extern "C" { #endif +#ifndef _di_fss_payload_write_program_version_ + const f_string_static_t fss_payload_write_program_version_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_program_version_s, 0, FSS_PAYLOAD_WRITE_program_version_s_length); +#endif // _di_fss_payload_write_program_version_ + +#ifndef _di_fss_payload_write_program_name_ + const f_string_static_t fss_payload_write_program_name_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_program_name_s, 0, FSS_PAYLOAD_WRITE_program_name_s_length); + const f_string_static_t fss_payload_write_program_name_long_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_program_name_long_s, 0, FSS_PAYLOAD_WRITE_program_name_long_s_length); +#endif // _di_fss_payload_write_program_name_ + #ifndef _di_fss_payload_write_defines_ const f_string_static_t fss_payload_write_pipe_content_end_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_pipe_content_end_s, 0, FSS_PAYLOAD_WRITE_pipe_content_end_s_length); const f_string_static_t fss_payload_write_pipe_content_ignore_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_pipe_content_ignore_s, 0, FSS_PAYLOAD_WRITE_pipe_content_ignore_s_length); @@ -37,6 +46,15 @@ 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_dynamic_resize(0, &setting->prepend); + + f_string_dynamics_resize(0, &setting->objects); + f_string_dynamics_resize(0, &setting->contents); + return F_none; } #endif // _di_fss_payload_write_setting_delete_ @@ -48,7 +66,12 @@ 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_payload_write_print_error(setting, main->error, "f_console_parameter_process"); + + return; + } { f_array_length_t choice = 0; @@ -65,8 +88,7 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); 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), "fll_program_parameter_process_context", F_true); + fss_payload_write_print_error(setting, main->error, "fll_program_parameter_process_context"); return; } @@ -97,8 +119,7 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); 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), "fll_program_parameter_process_verbosity", F_true); + fss_payload_write_print_error(setting, main->error, "fll_program_parameter_process_verbosity"); return; } @@ -117,10 +138,271 @@ extern "C" { } } - f_string_static_t * const args = main->parameters.arguments.array; + 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 (main->parameters.array[fss_payload_write_parameter_file_e].result == f_console_result_additional_e && main->parameters.array[fss_payload_write_parameter_file_e].values.used) { + if (main->parameters.array[fss_payload_write_parameter_file_e].values.used > 1) { + setting->status = F_status_set_error(F_parameter); + + fss_payload_write_print_line_first_locked(setting, main->error); + fll_program_print_error_parameter_must_specify_once(main->error, f_console_symbol_long_enable_s, fss_payload_write_long_file_s); + fss_payload_write_print_line_last_locked(setting, main->error); + + return; + } + + const f_array_length_t index = main->parameters.array[fss_payload_write_parameter_file_e].values.array[0]; + + main->output.to.id = -1; + main->output.to.stream = 0; + + setting->status = f_file_stream_open(main->parameters.arguments.array[index], f_string_empty_s, &main->output.to); + + if (F_status_is_error(setting->status)) { + fss_payload_write_print_error_file(setting, main->error, "f_file_stream_open", main->parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); + + return; + } + + setting->flag |= fss_payload_write_main_flag_file_to_e; + } + else if (main->parameters.array[fss_payload_write_parameter_file_e].result == f_console_result_found_e) { + setting->status = F_status_set_error(F_parameter); + + fss_payload_write_print_line_first_locked(setting, main->error); + fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_enable_s, fss_payload_write_long_file_s); + fss_payload_write_print_line_last_locked(setting, main->error); + + return; + } + + if (main->parameters.array[fss_payload_write_parameter_object_e].result == f_console_result_additional_e && main->parameters.array[fss_payload_write_parameter_object_e].values.used) { + f_array_lengths_t * const values = &main->parameters.array[fss_payload_write_parameter_object_e].values; + + setting->objects.used = 0; + + setting->status = f_string_dynamics_resize(values->used, &setting->objects); + + if (F_status_is_error(setting->status)) { + fss_payload_write_print_error(setting, main->error, "f_string_dynamics_resize"); + + 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->objects.used < values->used; ) { + + index = values->array[setting->objects.used]; + + 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 + + setting->flag |= fss_payload_write_main_flag_object_e; + } + else if (main->parameters.array[fss_payload_write_parameter_object_e].result == f_console_result_found_e) { + setting->status = F_status_set_error(F_parameter); + + fss_payload_write_print_line_first_locked(setting, main->error); + fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_enable_s, fss_payload_write_long_object_s); + fss_payload_write_print_line_last_locked(setting, main->error); + + return; + } + + if (main->parameters.array[fss_payload_write_parameter_content_e].result == f_console_result_additional_e && main->parameters.array[fss_payload_write_parameter_content_e].values.used) { + f_array_lengths_t * const values = &main->parameters.array[fss_payload_write_parameter_content_e].values; + + setting->contents.used = 0; + + setting->status = f_string_dynamics_resize(values->used, &setting->contents); + + if (F_status_is_error(setting->status)) { + fss_payload_write_print_error(setting, main->error, "f_string_dynamics_resize"); + + 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->contents.used < values->used; ) { + + index = values->array[setting->contents.used]; + + 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 + + setting->flag |= fss_payload_write_main_flag_content_e; + } + else if (main->parameters.array[fss_payload_write_parameter_content_e].result == f_console_result_found_e) { + setting->status = F_status_set_error(F_parameter); + + fss_payload_write_print_line_first_locked(setting, main->error); + fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_enable_s, fss_payload_write_long_content_s); + fss_payload_write_print_line_last_locked(setting, main->error); + + return; + } + + if (main->parameters.array[fss_payload_write_parameter_prepend_e].result == f_console_result_additional_e && main->parameters.array[fss_payload_write_parameter_prepend_e].values.used) { + const f_array_length_t index = main->parameters.array[fss_payload_write_parameter_prepend_e].values.array[main->parameters.array[fss_payload_write_parameter_prepend_e].values.used - 1]; + + setting->prepend.used = 0; + + setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->prepend); + + if (F_status_is_error(setting->status)) { + fss_payload_write_print_error(setting, main->error, "f_string_dynamic_append_nulless"); + + return; + } + + if (main->parameters.arguments.array[index].used) { + f_string_range_t range = macro_f_string_range_t_initialize2(main->parameters.arguments.array[index].used); + f_state_t state = f_state_t_initialize; + + for (; range.start < main->parameters.arguments.array[index].used; range.start++) { + + setting->status = f_fss_is_space(state, main->parameters.arguments.array[index], range); + + if (F_status_is_error(setting->status)) { + fss_payload_write_print_error(setting, main->error, "f_fss_is_space"); + + return; + } + + if (status == F_false) { + setting->status = F_status_set_error(F_parameter); + + fss_payload_write_print_error_prepend_only_whitespace(setting, main->error); + + return; + } + } // for + } + + setting->flag |= fss_payload_write_main_flag_prepend_e; + } + else if (main->parameters.array[fss_payload_write_parameter_prepend_e].result == f_console_result_found_e) { + setting->status = F_status_set_error(F_parameter); + + fss_payload_write_print_line_first_locked(setting, main->error); + fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_enable_s, fss_payload_write_long_prepend_s); + fss_payload_write_print_line_last_locked(setting, main->error); + + return; + } + + if (main->parameters.array[fss_payload_write_parameter_partial_e].result == f_console_result_found_e) { + setting->flag |= fss_payload_write_main_flag_partial_e; + } + + if (setting->flag & (fss_payload_write_main_flag_object_e | fss_payload_write_main_flag_content_e)) { + if (setting->flag & fss_payload_write_main_flag_object_e) { + if (main->parameters.array[fss_payload_write_parameter_object_e].locations.used != main->parameters.array[fss_payload_write_parameter_object_e].values.used) { + setting->status = F_status_set_error(F_parameter); + + fss_payload_write_print_line_first_locked(setting, main->error); + fss_payload_write_error_parameter_value_missing_print(main, f_console_symbol_long_enable_s, fss_payload_write_long_object_s); + fss_payload_write_print_line_last_locked(setting, main->error); + + return; + } + + if (main->parameters.array[fss_payload_write_parameter_content_e].locations.used != main->parameters.array[fss_payload_write_parameter_content_e].values.used) { + setting->status = F_status_set_error(F_parameter); + + fss_payload_write_print_line_first_locked(setting, main->error); + fss_payload_write_error_parameter_value_missing_print(main, f_console_symbol_long_enable_s, fss_payload_write_long_content_s); + fss_payload_write_print_line_last_locked(setting, main->error); + + return; + } + + if (main->parameters.array[fss_payload_write_parameter_object_e].locations.used != main->parameters.array[fss_payload_write_parameter_content_e].locations.used && !(setting->flag & fss_payload_write_main_flag_partial_e)) { + setting->status = F_status_set_error(F_parameter); + + fss_payload_write_print_line_first_locked(setting, main->error); + fss_payload_write_error_parameter_same_times_print(main); + fss_payload_write_print_line_last_locked(setting, main->error); - 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; + return; + } + + if ((setting->flag & fss_payload_write_main_flag_content_e) && (setting->flag & fss_payload_write_main_flag_partial_e)) { + if (main->parameters.array[fss_payload_write_parameter_content_e].result == f_console_result_additional_e) { + setting->status = F_status_set_error(F_parameter); + + fss_payload_write_print_line_first_locked(setting, main->error); + fll_program_print_error_parameter_cannot_use_with_xor(main->error, f_console_symbol_long_enable_s, f_console_symbol_long_enable_s, f_console_symbol_long_enable_s, fss_payload_write_long_partial_s, fss_payload_write_long_object_s, fss_payload_write_long_content_s); + fss_payload_write_print_line_last_locked(setting, main->error); + + return; + } + } + + if (setting->flag & fss_payload_write_main_flag_content_e) { + f_array_length_t location_object = 0; + f_array_length_t location_content = 0; + f_array_length_t location_sub_object = 0; + f_array_length_t location_sub_content = 0; + + for (f_array_length_t i = 0; i < main->parameters.array[fss_payload_write_parameter_object_e].locations.used; ++i) { + + location_object = main->parameters.array[fss_payload_write_parameter_object_e].locations.array[i]; + location_content = main->parameters.array[fss_payload_write_parameter_content_e].locations.array[i]; + location_sub_object = main->parameters.array[fss_payload_write_parameter_object_e].locations_sub.array[i]; + 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) { + setting->status = F_status_set_error(F_parameter); + + fss_payload_write_print_line_first_locked(setting, main->error); + fss_payload_write_print_error_object_not_before_content(setting, main->error); + fss_payload_write_print_line_last_locked(setting, main->error); + + break; + } + } // for + } + } + } + + setting->quote = f_iki_syntax_quote_double_s; + + if (main->parameters.array[fss_payload_write_parameter_double_e].result == f_console_result_found_e) { + if (main->parameters.array[fss_payload_write_parameter_single_e].result == f_console_result_found_e) { + if (main->parameters.array[fss_payload_write_parameter_double_e].location < main->parameters.array[fss_payload_write_parameter_single_e].location) { + setting->quote = f_iki_syntax_quote_single_s; + } + } + } + else if (main->parameters.array[fss_payload_write_parameter_single_e].result == f_console_result_found_e) { + setting->quote = f_iki_syntax_quote_single_s; + } + + if (main->parameters.array[fss_payload_write_parameter_trim_e].result == f_console_result_found_e) { + setting->flag |= fss_payload_write_main_flag_trim_e; + } + + if (main->pipe & fll_program_data_pipe_input_e) { + // @fixme why is this not allowed? + if (setting->flag & fss_payload_write_main_flag_partial_e) { + setting->status = F_status_set_error(F_parameter); + + fss_payload_write_print_line_first_locked(setting, main->error); + fll_program_print_error_parameter_cannot_use_with_pipe(setting, main->error); + fss_payload_write_print_line_last_locked(setting, main->error); + + return; + } + } + else if (!(setting->flag & (fss_payload_write_main_flag_content_e | fss_payload_write_parameter_object_e))) { + setting->status = F_data_not; } } #endif // _di_fss_payload_write_setting_load_ diff --git a/level_3/fss_payload_write/c/common.h b/level_3/fss_payload_write/c/common.h index 0377ec9..a22a4a0 100644 --- a/level_3/fss_payload_write/c/common.h +++ b/level_3/fss_payload_write/c/common.h @@ -200,27 +200,33 @@ extern "C" { * Flags used to represent flags passed to the main function. * * fss_payload_write_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. + * - content: The Content being written is specified. + * - double: Operate using double quotes. + * - file_to: Using a specified destination file. + * - help: Print help. + * - ignore: Ignore a given range within a Content. + * - object: The Object being written is specified. + * - partial: Do not write end of Object/Content character. + * - prepend: Prepend the given white space characters to the start of each multi-line Content. + * - single: Operate using single quotes. + * - trim: Trim Object names. + * - version: Print version. */ #ifndef _di_fss_payload_write_main_flag_e_ enum { - fss_payload_write_main_flag_none_e = 0x0, - fss_payload_write_main_flag_file_from_e = 0x1, - fss_payload_write_main_flag_file_to_e = 0x2, - fss_payload_write_main_flag_header_e = 0x4, - fss_payload_write_main_flag_help_e = 0x8, - fss_payload_write_main_flag_separate_e = 0x10, - fss_payload_write_main_flag_strip_invalid_e = 0x20, - fss_payload_write_main_flag_verify_e = 0x40, - fss_payload_write_main_flag_version_e = 0x80, + fss_payload_write_main_flag_none_e = 0x0, + fss_payload_write_main_flag_content_e = 0x1, + fss_payload_write_main_flag_double_e = 0x2, + fss_payload_write_main_flag_file_to_e = 0x4, + fss_payload_write_main_flag_help_e = 0x8, + fss_payload_write_main_flag_ignore_e = 0x10, + fss_payload_write_main_flag_object_e = 0x20, + fss_payload_write_main_flag_partial_e = 0x40, + fss_payload_write_main_flag_prepend_e = 0x80, + fss_payload_write_main_flag_single_e = 0x100, + fss_payload_write_main_flag_trim_e = 0x200, + fss_payload_write_main_flag_version_e = 0x400, }; #endif // _di_fss_payload_write_main_flag_e_ @@ -236,6 +242,17 @@ 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. + * prepend: A string to prepend to each multi-line Content. + * + * 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_fss_payload_write_setting_t_ typedef struct { @@ -245,6 +262,17 @@ 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_dynamic_t prepend; + + f_string_dynamics_t objects; + f_string_dynamics_t contents; } fss_payload_write_setting_t; #define fss_payload_write_setting_t_initialize \ @@ -253,6 +281,13 @@ 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_dynamic_t_initialize, \ + f_string_dynamics_t_initialize, \ + f_string_dynamics_t_initialize, \ } #endif // _di_fss_payload_write_setting_t_ @@ -289,12 +324,19 @@ extern "C" { * * This alters setting.status: * F_none on success. + * F_data_not on success but nothing was provided to operate with. * * Errors (with error bit) from: f_console_parameter_process(). + * Errors (with error bit) from: f_file_stream_open(). + * Errors (with error bit) from: f_string_dynamics_resize(). * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_verbosity(). * * @see f_console_parameter_process() + * @see f_file_stream_open() + * @see f_string_dynamics_resize() * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_verbosity() */ #ifndef _di_fss_payload_write_setting_load_ extern void fss_payload_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_payload_write_setting_t * const setting); 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 caf37b9..0e5c0f7 100644 --- a/level_3/fss_payload_write/c/fss_payload_write.c +++ b/level_3/fss_payload_write/c/fss_payload_write.c @@ -6,241 +6,188 @@ extern "C" { #endif -#ifndef _di_fss_payload_write_program_version_ - const f_string_static_t fss_payload_write_program_version_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_program_version_s, 0, FSS_PAYLOAD_WRITE_program_version_s_length); -#endif // _di_fss_payload_write_program_version_ +#ifndef _di_fss_payload_write_main_ + void fss_payload_write_main(fll_program_data_t * const main, fss_payload_write_setting_t * const setting) { -#ifndef _di_fss_payload_write_program_name_ - const f_string_static_t fss_payload_write_program_name_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_program_name_s, 0, FSS_PAYLOAD_WRITE_program_name_s_length); - const f_string_static_t fss_payload_write_program_name_long_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_program_name_long_s, 0, FSS_PAYLOAD_WRITE_program_name_long_s_length); -#endif // _di_fss_payload_write_program_name_ + if (!main || !setting || F_status_is_error(setting->status)) return; -#ifndef _di_fss_payload_write_main_ - f_status_t fss_payload_write_main(fll_program_data_t * const main, fss_payload_write_setting_t * const setting) { + setting->status = F_none; - f_status_t status = F_none; + if (setting->flag & fss_payload_write_main_flag_help_e) { + fss_payload_write_print_help(setting, main->message); - // Load parameters. - setting->status = f_console_parameter_process(arguments, &main->parameters); - if (F_status_is_error(setting->status)) return; + return; + } - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; + if (setting->flag & fss_payload_write_main_flag_version_e) { + fll_program_print_version(main->message, fss_payload_write_program_version_s); - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { fss_payload_write_parameter_no_color_e, fss_payload_write_parameter_light_e, fss_payload_write_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; + return; + } - const uint8_t modes[3] = { f_color_mode_color_not_e, f_color_mode_light_e, f_color_mode_dark_e }; + setting->escaped.used = 0; - status = fll_program_parameter_process_context(choices, modes, F_true, main); + if (main->pipe & fll_program_data_pipe_input_e) { + bool object_ended = F_false; - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", F_true); + 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; - return; - } - } + pipe.id = F_type_descriptor_input_d; + pipe.size_read = 1; - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { fss_payload_write_parameter_verbosity_quiet_e, fss_payload_write_parameter_verbosity_error_e, fss_payload_write_parameter_verbosity_verbose_e, fss_payload_write_parameter_verbosity_debug_e, fss_payload_write_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; + setting->buffer.used = 0; + setting->object.used = 0; + setting->content.used = 0; - 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 }; + range.start = 0; - status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); + do { + if (!((++main->signal_check) % fss_payload_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + setting->status = F_status_set_error(F_interrupt); - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", F_true); + return; + } - return; + main->signal_check = 0; } - } - } - f_string_static_t * const argv = main->parameters.arguments.array; + if (status != F_none_eof) { + status = f_file_read(pipe, &setting->buffer); - status = F_none; + if (F_status_is_error(status)) { + setting->status = F_status_set_error(F_pipe); - if (main->parameters.array[fss_payload_write_parameter_help_e].result == f_console_result_found_e) { - fss_payload_write_print_help(setting, main->message); + fss_payload_write_print_error_file(setting, main->error, "f_file_read", f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); - return status; - } + return; + } - if (main->parameters.array[fss_payload_write_parameter_version_e].result == f_console_result_found_e) { - fll_program_print_version(main->message, fss_payload_write_program_version_s); + if (!setting->buffer.used) { + setting->status = F_status_set_error(F_parameter); - return status; - } + fss_payload_write_print_line_first_locked(setting, main->error); + fll_program_print_error_pipe_missing_content(main->error); + fss_payload_write_print_line_last_locked(setting, main->error); - f_file_t output = f_file_t_initialize; + return; + } - output.id = F_type_descriptor_output_d; - output.stream = main->output.to; - output.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - output.size_read = main->output.to.size_read; - output.size_write = main->output.to.size_write; + range.stop = setting->buffer.used - 1; + } - 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_normal_e) { - fll_program_print_error_parameter_must_specify_once(main->error, f_console_symbol_long_enable_s, fss_payload_write_long_file_s); - } + previous = range.start; + setting->status = f_string_dynamic_seek_to(setting->buffer, f_string_ascii_feed_form_s.string[0], &range); - status = F_status_set_error(F_parameter); + if (setting->status == F_data_not_stop) { + setting->status = F_status_set_error(F_parameter); } - else { - const f_array_length_t location = main->parameters.array[fss_payload_write_parameter_file_e].values.array[0]; - output.id = -1; - output.stream = 0; - status = f_file_stream_open(argv[location], f_string_empty_s, &output); + if (F_status_is_error(setting->status)) { + fss_payload_write_print_error(setting, main->error, "f_string_dynamic_seek_to"); - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[location], f_file_operation_open_s, fll_error_file_type_file_e); - } + return; } - } - else if (main->parameters.array[fss_payload_write_parameter_file_e].result == f_console_result_found_e) { - fss_payload_write_error_parameter_value_missing_print(main, f_console_symbol_long_enable_s, fss_payload_write_long_file_s); - status = F_status_set_error(F_parameter); - } - } - if (F_status_is_error_not(status)) { - if (main->parameters.array[fss_payload_write_parameter_object_e].locations.used || main->parameters.array[fss_payload_write_parameter_content_e].locations.used) { - if (main->parameters.array[fss_payload_write_parameter_object_e].locations.used) { - if (main->parameters.array[fss_payload_write_parameter_object_e].locations.used != main->parameters.array[fss_payload_write_parameter_object_e].values.used) { - fss_payload_write_error_parameter_value_missing_print(main, f_console_symbol_long_enable_s, fss_payload_write_long_object_s); - status = F_status_set_error(F_parameter); - } - else if (main->parameters.array[fss_payload_write_parameter_content_e].locations.used != main->parameters.array[fss_payload_write_parameter_content_e].values.used) { - fss_payload_write_error_parameter_value_missing_print(main, f_console_symbol_long_enable_s, fss_payload_write_long_content_s); - status = F_status_set_error(F_parameter); - } - else if (main->parameters.array[fss_payload_write_parameter_object_e].locations.used != main->parameters.array[fss_payload_write_parameter_content_e].locations.used && main->parameters.array[fss_payload_write_parameter_partial_e].result == f_console_result_none_e) { - fss_payload_write_error_parameter_same_times_print(main); - status = F_status_set_error(F_parameter); - } - 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) { - f_file_stream_lock(main->error.to); + if (object_ended && previous == range.start) { + setting->status = F_status_set_error(F_parameter); - fl_print_format("%r%[%QThe '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_partial_s, main->error.notable); - fl_print_format("%[' parameter only allows either the '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_object_s, main->error.notable); - fl_print_format("%[' parameter or the '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, 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, main->error.context, main->error.context, f_string_eol_s); + fss_payload_write_print_line_first_locked(setting, main->error); + fll_program_print_error_pipe_invalid_form_feed(main->error); + fss_payload_write_print_line_last_locked(setting, main->error); - f_file_stream_unlock(main->error.to); - } + return; + } - status = F_status_set_error(F_parameter); - } - } + range.stop = range.start - 1; + range.start = previous; - if (F_status_is_error_not(status)) { - if (main->parameters.array[fss_payload_write_parameter_content_e].result == f_console_result_additional_e) { - f_array_length_t location_object = 0; - f_array_length_t location_content = 0; - f_array_length_t location_sub_object = 0; - f_array_length_t location_sub_content = 0; - - for (f_array_length_t i = 0; i < main->parameters.array[fss_payload_write_parameter_object_e].locations.used; ++i) { - location_object = main->parameters.array[fss_payload_write_parameter_object_e].locations.array[i]; - location_content = main->parameters.array[fss_payload_write_parameter_content_e].locations.array[i]; - location_sub_object = main->parameters.array[fss_payload_write_parameter_object_e].locations_sub.array[i]; - 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) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QEach '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_object_s, main->error.notable); - fl_print_format("%[' parameter must be specified before a '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, 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, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - } - - status = F_status_set_error(F_parameter); - break; - } - } // for + if (object_ended) { + setting->content.used = 0; + + if (setting->buffer.used) { + setting->status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->content); + + if (F_status_is_error(setting->status)) { + fss_payload_write_print_error(setting, main->error, "f_string_dynamic_partial_append_nulless"); + + return; } } + + setting->status = fss_payload_write_process(main, setting, setting->object, setting->content); + if (F_status_is_error(setting->status)) return; + + fll_print_dynamic_raw(f_string_eol_s, main->output.to); + + object_ended = F_false; } - else if (main->parameters.array[fss_payload_write_parameter_content_e].locations.used) { - if (main->parameters.array[fss_payload_write_parameter_content_e].locations.used != main->parameters.array[fss_payload_write_parameter_content_e].values.used) { - fss_payload_write_error_parameter_value_missing_print(main, f_console_symbol_long_enable_s, fss_payload_write_long_content_s); - status = F_status_set_error(F_parameter); - } - else if (!main->parameters.array[fss_payload_write_parameter_partial_e].locations.used) { - fss_payload_write_error_parameter_same_times_print(main); - status = F_status_set_error(F_parameter); + else { + setting->object.used = 0; + + setting->status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->object); + + if (F_status_is_error(setting->status)) { + fss_payload_write_print_error(setting, main->error, "f_string_dynamic_partial_append_nulless"); + + return; } + + object_ended = F_true; } - } - else if (!(main->pipe & fll_program_data_pipe_input_e)) { - 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, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_enable_s, fss_payload_write_long_object_s, main->error.notable); - fl_print_format("%[' parameter with the '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, 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, main->error.context, main->error.context, f_string_eol_s); + // Restore the range, positioned after the new line. + range.start = range.stop + 2; + range.stop = setting->buffer.used - 1; - f_file_stream_unlock(main->error.to); + // 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; } - status = F_status_set_error(F_parameter); - } + } while (status != F_none_eof || setting->buffer.used || object_ended); - 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) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThis '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, 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, main->error.context, main->error.context, f_string_eol_s); + if (object_ended) { + setting->status = F_status_set_error(F_parameter); - f_file_stream_unlock(main->error.to); - } + fss_payload_write_print_line_first_locked(setting, main->error); + fll_program_print_error_pipe_object_without_content(main->error); + fss_payload_write_print_line_last_locked(setting, main->error); - status = F_status_set_error(F_parameter); - } + return; } } - 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) { - f_file_stream_lock(main->error.to); + for (f_array_length_t i = 0; i < setting->objects.used; ++i) { - fl_print_format("%r%[%QThe parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, 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, main->error.context, main->error.context, f_string_eol_s); + if (!((++main->signal_check) % fss_payload_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + setting->status = F_status_set_error(F_interrupt); - f_file_stream_unlock(main->error.to); + return; } - status = F_status_set_error(F_parameter); + main->signal_check = 0; } - else if (main->parameters.array[fss_payload_write_parameter_prepend_e].result == f_console_result_additional_e) { + + setting->status = fss_payload_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); + } // for + + // Ensure a new line is always put at the end of the program execution, unless in quiet mode. + fss_payload_write_print_line_last_locked(setting, main->message); + + + // xxxxxxxxxxx + + if (F_status_is_error_not(status)) { + if (main->parameters.array[fss_payload_write_parameter_prepend_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_payload_write_parameter_prepend_e].values.array[main->parameters.array[fss_payload_write_parameter_prepend_e].values.used - 1]; if (argv[index].used) { @@ -264,6 +211,7 @@ extern "C" { } status = F_status_set_error(F_parameter); + break; } } // for diff --git a/level_3/fss_payload_write/c/fss_payload_write.h b/level_3/fss_payload_write/c/fss_payload_write.h index 1f64019..3ddecee 100644 --- a/level_3/fss_payload_write/c/fss_payload_write.h +++ b/level_3/fss_payload_write/c/fss_payload_write.h @@ -42,6 +42,7 @@ // FSS Payload Write includes. #include +#include #ifdef __cplusplus extern "C" { @@ -72,7 +73,7 @@ extern "C" { * F_parameter (with error bit) if main is NULL or setting is NULL. */ #ifndef _di_fss_payload_write_main_ - extern f_status_t fss_payload_write_main(fll_program_data_t * const main, fss_payload_write_setting_t * const setting); + extern void fss_payload_write_main(fll_program_data_t * const main, fss_payload_write_setting_t * const setting); #endif // _di_fss_payload_write_main_ #ifdef __cplusplus diff --git a/level_3/fss_payload_write/c/print.c b/level_3/fss_payload_write/c/print.c index 00eba02..bf6343c 100644 --- a/level_3/fss_payload_write/c/print.c +++ b/level_3/fss_payload_write/c/print.c @@ -5,6 +5,68 @@ extern "C" { #endif +#ifndef _di_fss_payload_write_print_error_ + f_status_t fss_payload_write_print_error(fss_payload_write_setting_t * const setting, const fl_print_t print, const f_string_t function) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + fss_payload_write_print_line_first_locked(setting, print); + fll_error_print(print, F_status_set_fine(setting->status), function, F_true); + fss_payload_write_print_line_last_locked(setting, print); + + return F_none; + } +#endif // _di_fss_payload_write_print_error_ + +#ifndef _di_fss_payload_write_print_error_file_ + f_status_t fss_payload_write_print_error_file(fss_payload_write_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + fss_payload_write_print_line_first_locked(setting, print); + fll_error_file_print(print, F_status_set_fine(setting->status), function, F_true, name, operation, type); + fss_payload_write_print_line_last_locked(setting, print); + + return F_none; + } +#endif // _di_fss_payload_write_print_error_file_ + +#ifndef _di_fss_payload_write_print_error_object_not_before_content_ + f_status_t fss_payload_write_print_error_object_not_before_content(fss_payload_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("%r%[%QEach '%]", print.to, f_string_eol_s, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%r%r%]", print.to, print.set->notable, f_console_symbol_long_enable_s, fss_payload_write_long_object_s, print.set->notable); + fl_print_format("%[' parameter must be specified before a '%]", print.to, print.set->error, print.set->error); + fl_print_format("%[%r%r%]", print.to, print.set->notable, f_console_symbol_long_enable_s, fss_payload_write_long_content_s, print.set->notable); + fl_print_format("%[' parameter.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fss_payload_write_print_error_object_not_before_content_ + +#ifndef _fss_payload_write_print_error_prepend_only_whitespace_ + f_status_t fss_payload_write_print_error_prepend_only_whitespace(fss_payload_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("%r%[%QThe value for the parameter '%]", print.to, f_string_eol_s, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%r%r%]", print.to, print.set->notable, f_console_symbol_long_enable_s, fss_payload_write_long_prepend_s, print.set->notable); + fl_print_format("%[' must only contain white space.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _fss_payload_write_print_error_prepend_only_whitespace_ + #ifndef _di_fss_payload_write_print_help_ f_status_t fss_payload_write_print_help(fss_payload_write_setting_t * const setting, const fl_print_t print) { diff --git a/level_3/fss_payload_write/c/print.h b/level_3/fss_payload_write/c/print.h index 854a25f..7f42181 100644 --- a/level_3/fss_payload_write/c/print.h +++ b/level_3/fss_payload_write/c/print.h @@ -13,6 +13,91 @@ extern "C" { #endif /** + * Print generic error message regarding a function failing in some way. + * + * @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. + * + * @see fll_error_print() + */ +#ifndef _di_fss_payload_write_print_error_ + extern f_status_t fss_payload_write_print_error(fss_payload_write_setting_t * const setting, const fl_print_t print, const f_string_t function); +#endif // _di_fss_payload_write_print_error_ + +/** + * Print file related error or warning messages. + * + * @param setting + * The main program settings. + * + * This does not alter setting.status. + * @param print + * Designates how printing is to be performed. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * @param name + * The name of the file or directory. + * @param operation + * The operation that fails, such as 'create' or 'access'. + * @param type + * A valid file type code from the fll_error_file_type enum. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * @see fll_error_file_print() + */ +#ifndef _di_fss_payload_write_print_error_file_ + extern f_status_t fss_payload_write_print_error_file(fss_payload_write_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type); +#endif // _di_fss_payload_write_print_error_file_ + +/** + * Print error message about each Object parameter not being specified before a Content parameter. + * + * @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_fss_payload_write_print_error_object_not_before_content_ + extern f_status_t fss_payload_write_print_error_object_not_before_content(fss_payload_write_setting_t * const setting, const fl_print_t print); +#endif // _di_fss_payload_write_print_error_object_not_before_content_ + +/** + * Print error when prepend parameter has something other than white space. + * + * @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 _fss_payload_write_print_error_prepend_only_whitespace_ + extern f_status_t fss_payload_write_print_error_prepend_only_whitespace(fss_payload_write_setting_t * const setting, const fl_print_t print); +#endif // _fss_payload_write_print_error_prepend_only_whitespace_ + +/** * Print help. * * @param setting diff --git a/level_3/fss_payload_write/c/private-write.c b/level_3/fss_payload_write/c/private-write.c index b91cf3d..e847547 100644 --- a/level_3/fss_payload_write/c/private-write.c +++ b/level_3/fss_payload_write/c/private-write.c @@ -9,9 +9,7 @@ extern "C" { #ifndef _di_fss_payload_write_error_parameter_same_times_print_ void fss_payload_write_error_parameter_same_times_print(fll_program_data_t * const main) { - if (main->error.verbosity == f_console_verbosity_quiet_e) { - return; - } + if (main->error.verbosity == f_console_verbosity_quiet_e) return; f_file_stream_lock(main->error.to); @@ -30,9 +28,7 @@ extern "C" { #ifndef _di_fss_payload_write_error_parameter_unsupported_eol_print_ void fss_payload_write_error_parameter_unsupported_eol_print(fll_program_data_t * const main) { - if (main->error.verbosity == f_console_verbosity_quiet_e) { - return; - } + if (main->error.verbosity == f_console_verbosity_quiet_e) return; f_file_stream_lock(main->error.to); @@ -49,9 +45,7 @@ extern "C" { #ifndef _di_fss_payload_write_error_parameter_value_missing_print_ void fss_payload_write_error_parameter_value_missing_print(fll_program_data_t * const main, const f_string_static_t symbol, const f_string_static_t parameter) { - if (main->error.verbosity == f_console_verbosity_quiet_e) { - return; - } + if (main->error.verbosity == f_console_verbosity_quiet_e) return; f_file_stream_lock(main->error.to); @@ -104,7 +98,7 @@ extern "C" { } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_fss_payload_write", F_true); + fss_payload_write_print_error(setting, main->error, "fll_fss_payload_write"); return status; } @@ -139,7 +133,7 @@ extern "C" { } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fl_fss_basic_list_object_write", F_true); + fss_payload_write_print_error(setting, main->error, "fl_fss_basic_list_object_write"); return status; } @@ -161,7 +155,7 @@ extern "C" { status = fl_fss_basic_list_content_write(*content, object ? f_fss_complete_full_e : f_fss_complete_none_e, prepend, state, &range, buffer); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fl_fss_payload_content_write", F_true); + fss_payload_write_print_error(setting, main->error, "fl_fss_payload_content_write"); return status; } @@ -172,7 +166,7 @@ extern "C" { status = f_string_dynamic_append(f_string_eol_s, buffer); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); + fss_payload_write_print_error(setting, main->error, "f_string_dynamic_append"); return status; } @@ -229,7 +223,7 @@ extern "C" { status_pipe = f_file_read_block(input, &block); if (F_status_is_error(status_pipe)) { - fll_error_print(main->error, F_status_set_fine(status_pipe), "f_file_read_block", F_true); + fss_payload_write_print_error(setting, main->error, "f_file_read_block"); status_pipe = F_status_set_error(F_pipe); @@ -254,7 +248,7 @@ extern "C" { status = f_string_dynamic_increase_by(block.used, &object); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + fss_payload_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); break; } @@ -313,7 +307,7 @@ extern "C" { status = f_string_dynamic_increase_by(total, &content); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + fss_payload_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); break; } @@ -336,7 +330,7 @@ extern "C" { status = f_string_dynamic_increase_by(total, &content); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + fss_payload_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); break; } @@ -388,7 +382,7 @@ extern "C" { status = f_string_dynamic_increase_by(block.used, &content); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true); + fss_payload_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); break; } diff --git a/level_3/iki_read/c/common.c b/level_3/iki_read/c/common.c index a9dd4d7..50716c9 100644 --- a/level_3/iki_read/c/common.c +++ b/level_3/iki_read/c/common.c @@ -81,7 +81,12 @@ 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_read_print_error(setting, main->error, "f_console_parameter_process"); + + return; + } { f_array_length_t choice = 0; @@ -98,9 +103,7 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "fll_program_parameter_process_context"); return; } @@ -131,9 +134,7 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "fll_program_parameter_process_verbosity"); return; } @@ -236,9 +237,7 @@ extern "C" { setting->status = f_string_dynamics_increase_by(main->parameters.array[iki_read_parameter_name_e].values.used, &setting->names); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamics_increase_by", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "f_string_dynamics_increase_by"); return; } @@ -269,9 +268,7 @@ extern "C" { } // for if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamics_append", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "f_string_dynamics_append"); return; } @@ -304,9 +301,7 @@ extern "C" { setting->status = f_string_maps_increase_by(main->parameters.array[iki_read_parameter_replace_e].values.used / 2, &setting->replace); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_maps_increase_by", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "f_string_maps_increase_by"); return; } @@ -340,9 +335,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_resize", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "f_string_dynamic_resize"); return; } @@ -393,9 +386,7 @@ extern "C" { setting->status = f_string_triples_increase_by(main->parameters.array[iki_read_parameter_wrap_e].values.used / 3, &setting->wrap); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_triples_increase_by", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "f_string_triples_increase_by"); return; } @@ -433,9 +424,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_resize", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "f_string_dynamic_resize"); return; } @@ -560,9 +549,7 @@ extern "C" { setting->status = f_string_dynamics_resize(main->parameters.remaining.used, &setting->files); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamics_resize", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "f_string_dynamics_resize"); return; } @@ -576,9 +563,7 @@ extern "C" { setting->status = f_string_dynamic_resize(0, &setting->files.array[setting->files.used]); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_resize", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "f_string_dynamic_resize"); return; } @@ -624,9 +609,7 @@ extern "C" { setting->status = f_string_triples_increase_by(parameter.values.used / 3, triple); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_triples_increase_by", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "f_string_triples_increase_by"); return F_false; } @@ -666,9 +649,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_resize", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "f_string_dynamic_resize"); return F_false; } diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index 2277dd5..842b0c1 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -35,9 +35,7 @@ extern "C" { setting->status = f_file_read(file, &setting->buffer); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - 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_process_s, fll_error_file_type_file_e); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error_file(setting, main->error, "f_file_read", f_string_ascii_minus_s, f_file_operation_process_s, fll_error_file_type_file_e); } else { iki_read_process_buffer(main, setting); @@ -71,9 +69,7 @@ extern "C" { setting->status = f_file_stream_open(setting->files.array[i], f_string_empty_s, &file); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error_file(setting, main->error, "f_file_stream_open", setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); return; } @@ -81,9 +77,7 @@ extern "C" { setting->status = f_file_descriptor(&file); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_descriptor", F_true, setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error_file(setting, main->error, "f_file_descriptor", setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); return; } @@ -93,9 +87,7 @@ extern "C" { setting->status = f_file_size_by_id(file, &size_file); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_size_by_id", F_true, setting->files.array[i], f_file_operation_analyze_s, fll_error_file_type_file_e); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error_file(setting, main->error, "f_file_size_by_id", setting->files.array[i], f_file_operation_analyze_s, fll_error_file_type_file_e); break; } @@ -122,9 +114,7 @@ extern "C" { setting->status = f_string_dynamic_increase_by(size_file + 1, &setting->buffer); if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_increase_by", F_true, setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error_file(setting, main->error, "f_string_dynamic_increase_by", setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); break; } @@ -146,9 +136,7 @@ extern "C" { if (F_status_is_error(setting->status)) { if (F_status_set_fine(setting->status) != F_interrupt) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_read_until", F_true, setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error_file(setting, main->error, "f_file_stream_read_until", setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); } break; diff --git a/level_3/iki_read/c/print.c b/level_3/iki_read/c/print.c index c18c8d7..f951f2f 100644 --- a/level_3/iki_read/c/print.c +++ b/level_3/iki_read/c/print.c @@ -5,6 +5,32 @@ extern "C" { #endif +#ifndef _di_iki_read_print_error_ + f_status_t iki_read_print_error(iki_read_setting_t * const setting, const fl_print_t print, const f_string_t function) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + iki_read_print_line_first_locked(setting, print); + fll_error_print(print, F_status_set_fine(setting->status), function, F_true); + iki_read_print_line_last_locked(setting, print); + + return F_none; + } +#endif // _di_iki_read_print_error_ + +#ifndef _di_iki_read_print_error_file_ + f_status_t iki_read_print_error_file(iki_read_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + iki_read_print_line_first_locked(setting, print); + fll_error_file_print(print, F_status_set_fine(setting->status), function, F_true, name, operation, type); + iki_read_print_line_last_locked(setting, print); + + return F_none; + } +#endif // _di_iki_read_print_error_file_ + #ifndef _di_iki_read_print_help_ f_status_t iki_read_print_help(iki_read_setting_t * const setting, const fl_print_t print) { diff --git a/level_3/iki_read/c/print.h b/level_3/iki_read/c/print.h index 55dea8a..7d1dc4c 100644 --- a/level_3/iki_read/c/print.h +++ b/level_3/iki_read/c/print.h @@ -13,6 +13,55 @@ extern "C" { #endif /** + * Print generic error message regarding a function failing in some way. + * + * @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. + * + * @see fll_error_print() + */ +#ifndef _di_iki_read_print_error_ + extern f_status_t iki_read_print_error(iki_read_setting_t * const setting, const fl_print_t print, const f_string_t function); +#endif // _di_iki_read_print_error_ + +/** + * Print file related error or warning messages. + * + * @param setting + * The main program settings. + * + * This does not alter setting.status. + * @param print + * Designates how printing is to be performed. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * @param name + * The name of the file or directory. + * @param operation + * The operation that fails, such as 'create' or 'access'. + * @param type + * A valid file type code from the fll_error_file_type enum. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * @see fll_error_file_print() + */ +#ifndef _di_iki_read_print_error_file_ + extern f_status_t iki_read_print_error_file(iki_read_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type); +#endif // _di_iki_read_print_error_file_ + +/** * Print help. * * @param setting diff --git a/level_3/iki_read/c/private-read.c b/level_3/iki_read/c/private-read.c index 22354e4..b25f2c6 100644 --- a/level_3/iki_read/c/private-read.c +++ b/level_3/iki_read/c/private-read.c @@ -169,9 +169,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fl_iki_read", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "fl_iki_read"); return; } @@ -284,9 +282,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_read_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fl_iki_read", F_true); - iki_read_print_line_last_locked(setting, main->error); + iki_read_print_error(setting, main->error, "fl_iki_read"); return; } @@ -400,7 +396,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fll_error_print(main->error, F_status_set_fine(setting->status), "fl_iki_read", F_true); + iki_read_print_error(setting, main->error, "fl_iki_read"); return; } @@ -442,7 +438,7 @@ extern "C" { setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &name); if (F_status_is_error(setting->status)) { - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_append_nulless", F_true); + iki_read_print_error(setting, main->error, "f_string_dynamic_append_nulless"); f_string_dynamic_resize(0, &name); diff --git a/level_3/iki_write/c/common.c b/level_3/iki_write/c/common.c index 04285e3..5303521 100644 --- a/level_3/iki_write/c/common.c +++ b/level_3/iki_write/c/common.c @@ -57,9 +57,7 @@ extern "C" { setting->status = f_console_parameter_process(arguments, &main->parameters); if (F_status_is_error(setting->status)) { - iki_write_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); - iki_write_print_line_last_locked(setting, main->error); + iki_write_print_error(setting, main->error, "f_console_parameter_process"); return; } @@ -79,9 +77,7 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - iki_write_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); - iki_write_print_line_last_locked(setting, main->error); + iki_write_print_error(setting, main->error, "fll_program_parameter_process_context"); return; } @@ -112,9 +108,7 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - iki_write_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); - iki_write_print_line_last_locked(setting, main->error); + iki_write_print_error(setting, main->error, "fll_program_parameter_process_verbosity"); return; } @@ -137,7 +131,7 @@ extern "C" { 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 (main->parameters.array[iki_write_parameter_file_e].result == f_console_result_additional_e) { + if (main->parameters.array[iki_write_parameter_file_e].result == f_console_result_additional_e && main->parameters.array[iki_write_parameter_file_e].values.used) { if (main->parameters.array[iki_write_parameter_file_e].values.used > 1) { setting->status = F_status_set_error(F_parameter); @@ -183,9 +177,7 @@ extern "C" { setting->status = f_string_dynamics_resize(values->used, &setting->objects); if (F_status_is_error(setting->status)) { - iki_write_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamics_resize", F_true); - iki_write_print_line_last_locked(setting, main->error); + iki_write_print_error(setting, main->error, "f_string_dynamics_resize"); return; } @@ -220,9 +212,7 @@ extern "C" { setting->status = f_string_dynamics_resize(values->used, &setting->contents); if (F_status_is_error(setting->status)) { - iki_write_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamics_resize", F_true); - iki_write_print_line_last_locked(setting, main->error); + iki_write_print_error(setting, main->error, "f_string_dynamics_resize"); return; } diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index bcdc4a1..136f7ef 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -61,9 +61,7 @@ extern "C" { if (F_status_is_error(status)) { setting->status = F_status_set_error(F_pipe); - iki_write_print_line_first_locked(setting, main->error); - 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_locked(setting, main->error); + iki_write_print_error_file(setting, main->error, "f_file_read", f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); return; } @@ -89,9 +87,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_write_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_seek_to", F_true); - iki_write_print_line_last_locked(setting, main->error); + iki_write_print_error(setting, main->error, "f_string_dynamic_seek_to"); return; } @@ -116,15 +112,13 @@ extern "C" { setting->status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->content); if (F_status_is_error(setting->status)) { - iki_write_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_partial_append_nulless", F_true); - iki_write_print_line_last_locked(setting, main->error); + iki_write_print_error(setting, main->error, "f_string_dynamic_partial_append_nulless"); return; } } - setting->status = iki_write_process(main, setting, setting->object, setting->content); + iki_write_process(main, setting, setting->object, setting->content); if (F_status_is_error(setting->status)) return; fll_print_dynamic_raw(f_string_eol_s, main->output.to); @@ -137,9 +131,7 @@ extern "C" { setting->status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->object); if (F_status_is_error(setting->status)) { - iki_write_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_partial_append_nulless", F_true); - iki_write_print_line_last_locked(setting, main->error); + iki_write_print_error(setting, main->error, "f_string_dynamic_partial_append_nulless"); return; } @@ -182,7 +174,7 @@ extern "C" { main->signal_check = 0; } - setting->status = iki_write_process(main, setting, setting->objects.array[i], setting->contents.array[i]); + 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); diff --git a/level_3/iki_write/c/iki_write.h b/level_3/iki_write/c/iki_write.h index 6857588..67027cd 100644 --- a/level_3/iki_write/c/iki_write.h +++ b/level_3/iki_write/c/iki_write.h @@ -80,7 +80,14 @@ extern "C" { * F_false on success when performing verification and verify failed. * F_interrupt on (exit) signal received. * + * F_failure (with error bit) on processing failure. * F_parameter (with error bit) if main is NULL or setting is NULL. + * + * Errors (with error bit) from: f_iki_object_is(). + * Errors (with error bit) from: fll_iki_content_escape(). + * + * @see f_iki_object_is() + * @see fll_iki_content_escape() */ #ifndef _di_iki_write_main_ extern void iki_write_main(fll_program_data_t * const main, iki_write_setting_t * const setting); diff --git a/level_3/iki_write/c/print.c b/level_3/iki_write/c/print.c index d411935..ebb169c 100644 --- a/level_3/iki_write/c/print.c +++ b/level_3/iki_write/c/print.c @@ -5,6 +5,72 @@ extern "C" { #endif +#ifndef _di_iki_write_print_error_ + f_status_t iki_write_print_error(iki_write_setting_t * const setting, const fl_print_t print, const f_string_t function) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + iki_write_print_line_first_locked(setting, print); + fll_error_print(print, F_status_set_fine(setting->status), function, F_true); + iki_write_print_line_last_locked(setting, print); + + return F_none; + } +#endif // _di_iki_write_print_error_ + +#ifndef _di_iki_write_print_error_file_ + f_status_t iki_write_print_error_file(iki_write_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + iki_write_print_line_first_locked(setting, print); + fll_error_file_print(print, F_status_set_fine(setting->status), function, F_true, name, operation, type); + iki_write_print_line_last_locked(setting, print); + + return F_none; + } +#endif // _di_iki_write_print_error_file_ + +#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, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%r%r%]", print.to, print.set->notable, f_console_symbol_long_enable_s, iki_write_long_object_s, print.set->notable); + fl_print_format("%[' and the '%]", print.to, print.set->error, print.set->error); + fl_print_format("%[%r%r%]", print.to, print.set->notable, f_console_symbol_long_enable_s, iki_write_long_content_s, print.set->notable); + fl_print_format("%[' parameters.%]%r", print.to, 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); + + iki_write_print_line_first_unlocked(setting, print); + + fl_print_format("%[%QThe object '%]", print.to, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%Q%]", print.to, print.set->notable, object, print.set->notable); + fl_print_format("%[' is not a valid IKI Object.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); + + iki_write_print_line_last_unlocked(setting, print); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_iki_write_print_error_object_not_valid_ + #ifndef _di_iki_write_print_help_ f_status_t iki_write_print_help(iki_write_setting_t * const setting, const fl_print_t print) { @@ -115,42 +181,6 @@ extern "C" { } #endif // _di_iki_write_print_line_last_unlocked_ -#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, print.set->error, print.prefix, print.set->error); - fl_print_format("%[%r%r%]", print.to, print.set->notable, f_console_symbol_long_enable_s, iki_write_long_object_s, print.set->notable); - fl_print_format("%[' and the '%]", print.to, print.set->error, print.set->error); - fl_print_format("%[%r%r%]", print.to, print.set->notable, f_console_symbol_long_enable_s, iki_write_long_content_s, print.set->notable); - fl_print_format("%[' parameters.%]%r", print.to, 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, print.set->error, print.prefix, print.set->error); - fl_print_format("%[%Q%]", print.to, print.set->notable, object, print.set->notable); - fl_print_format("%[' is not a valid IKI Object.%]%r", print.to, 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 99fdf84..6fa4a6d 100644 --- a/level_3/iki_write/c/print.h +++ b/level_3/iki_write/c/print.h @@ -13,29 +13,56 @@ extern "C" { #endif /** - * Print help. + * Print generic error message regarding a function failing in some way. * * @param setting * The main program settings. * * This does not alter setting.status. * @param print - * The output structure to print to. + * Designates the how and where to print. * * @return * F_none on success. * F_output_not on success, but no printing is performed. + * + * @see fll_error_print() */ -#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); -#endif // _di_iki_write_print_help_ +#ifndef _di_iki_write_print_error_ + extern f_status_t iki_write_print_error(iki_write_setting_t * const setting, const fl_print_t print, const f_string_t function); +#endif // _di_iki_write_print_error_ /** - * Print first new line, unless verbosity says otherwise. + * Print file related error or warning messages. * - * This is generally either the first line in the program or the first line printed before an error message. + * @param setting + * The main program settings. * - * This function locks and then unlocks the input stream when printing. + * This does not alter setting.status. + * @param print + * Designates how printing is to be performed. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * @param name + * The name of the file or directory. + * @param operation + * The operation that fails, such as 'create' or 'access'. + * @param type + * A valid file type code from the fll_error_file_type enum. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * @see fll_error_file_print() + */ +#ifndef _di_iki_write_print_error_file_ + extern f_status_t iki_write_print_error_file(iki_write_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type); +#endif // _di_iki_write_print_error_file_ + +/** + * Print error message about "main" Object being missing. * * @param setting * The main program settings. @@ -48,36 +75,52 @@ extern "C" { * F_none on success. * F_output_not on success, but no printing is performed. */ -#ifndef _di_iki_write_print_line_first_locked_ - extern f_status_t iki_write_print_line_first_locked(iki_write_setting_t * const setting, const fl_print_t print); -#endif // _di_iki_write_print_line_first_locked_ +#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 first new line, unless verbosity says otherwise. + * Print error message about an Object not being valid. * - * This is generally either the first line in the program or the first line printed before an error message. + * @param setting + * The main program settings. * - * This function neither locks nor unlocks the input stream. + * 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_ + +/** + * Print help. * * @param setting * The main program settings. * * This does not alter setting.status. * @param print - * Designates the how and where to print. + * The output structure to print to. * * @return * F_none on success. * F_output_not on success, but no printing is performed. */ -#ifndef _di_iki_write_print_line_first_unlocked_ - extern f_status_t iki_write_print_line_first_unlocked(iki_write_setting_t * const setting, const fl_print_t print); -#endif // _di_iki_write_print_line_first_unlocked_ +#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); +#endif // _di_iki_write_print_help_ /** - * Print last new line when the main is complete, unless verbosity says otherwise. + * Print first new line, unless verbosity says otherwise. * - * This is generally the very last line printed in the program. + * This is generally either the first line in the program or the first line printed before an error message. * * This function locks and then unlocks the input stream when printing. * @@ -92,14 +135,14 @@ extern "C" { * F_none on success. * F_output_not on success, but no printing is performed. */ -#ifndef _di_iki_write_print_line_last_locked_ - extern f_status_t iki_write_print_line_last_locked(iki_write_setting_t * const setting, const fl_print_t print); -#endif // _di_iki_write_print_line_last_locked_ +#ifndef _di_iki_write_print_line_first_locked_ + extern f_status_t iki_write_print_line_first_locked(iki_write_setting_t * const setting, const fl_print_t print); +#endif // _di_iki_write_print_line_first_locked_ /** - * Print last new line when the main is complete, unless verbosity says otherwise. + * Print first new line, unless verbosity says otherwise. * - * This is generally the very last line printed in the program. + * This is generally either the first line in the program or the first line printed before an error message. * * This function neither locks nor unlocks the input stream. * @@ -114,12 +157,16 @@ extern "C" { * F_none on success. * F_output_not on success, but no printing is performed. */ -#ifndef _di_iki_write_print_line_last_unlocked_ - extern f_status_t iki_write_print_line_last_unlocked(iki_write_setting_t * const setting, const fl_print_t print); -#endif // _di_iki_write_print_line_last_unlocked_ +#ifndef _di_iki_write_print_line_first_unlocked_ + extern f_status_t iki_write_print_line_first_unlocked(iki_write_setting_t * const setting, const fl_print_t print); +#endif // _di_iki_write_print_line_first_unlocked_ /** - * Print error message about "main" Object being missing. + * Print last new line when the main is complete, unless verbosity says otherwise. + * + * This is generally the very last line printed in the program. + * + * This function locks and then unlocks the input stream when printing. * * @param setting * The main program settings. @@ -132,12 +179,16 @@ extern "C" { * 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_ +#ifndef _di_iki_write_print_line_last_locked_ + extern f_status_t iki_write_print_line_last_locked(iki_write_setting_t * const setting, const fl_print_t print); +#endif // _di_iki_write_print_line_last_locked_ /** - * Print error message about an Object not being valid. + * Print last new line when the main is complete, unless verbosity says otherwise. + * + * This is generally the very last line printed in the program. + * + * This function neither locks nor unlocks the input stream. * * @param setting * The main program settings. @@ -145,16 +196,14 @@ extern "C" { * 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_ +#ifndef _di_iki_write_print_line_last_unlocked_ + extern f_status_t iki_write_print_line_last_unlocked(iki_write_setting_t * const setting, const fl_print_t print); +#endif // _di_iki_write_print_line_last_unlocked_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/iki_write/c/private-write.c b/level_3/iki_write/c/private-write.c index eacb585..7531131 100644 --- a/level_3/iki_write/c/private-write.c +++ b/level_3/iki_write/c/private-write.c @@ -7,41 +7,47 @@ extern "C" { #endif #ifndef _di_iki_write_process_ - 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) { + void 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) { - fll_program_print_error_missing_variable_not_zero(main->error, iki_write_object_s); + setting->status = F_status_set_error(F_failure); - return F_status_set_error(F_failure); + if (main->error.verbosity != f_console_verbosity_quiet_e) { + iki_write_print_line_first_locked(setting, main->error); + fll_program_print_error_missing_variable_not_zero(main->error, iki_write_object_s); + iki_write_print_line_last_locked(setting, main->error); + } + + return; } - f_status_t status = f_iki_object_is(object); + setting->status = f_iki_object_is(object); + + if (setting->status == F_false) { + setting->status = F_status_set_error(F_failure); - if (status == F_false) { iki_write_print_error_object_not_valid(setting, main->error, object); - return F_status_set_error(F_failure); + return; } - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_iki_object_is", F_true); + if (F_status_is_error(setting->status)) { + iki_write_print_error(setting, main->error, "f_iki_object_is"); - return F_status_set_error(F_failure); + return; } setting->escaped.used = 0; - status = fll_iki_content_escape(content, setting->quote, &setting->escaped); + setting->status = fll_iki_content_escape(content, setting->quote, &setting->escaped); - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_iki_content_escape", F_true); + if (F_status_is_error(setting->status)) { + iki_write_print_error(setting, main->error, "fll_iki_content_escape"); - return F_status_set_error(F_failure); + return; } fl_print_format("%Q%r%r%Q%r", main->output.to, object, f_iki_syntax_separator_s, setting->quote, setting->escaped, setting->quote); - - return F_none; } #endif // _di_iki_write_process_ diff --git a/level_3/iki_write/c/private-write.h b/level_3/iki_write/c/private-write.h index 41587cd..55051d4 100644 --- a/level_3/iki_write/c/private-write.h +++ b/level_3/iki_write/c/private-write.h @@ -19,18 +19,24 @@ extern "C" { * The main program data. * @param setting * The main program settings. + * + * This alters setting.status: + * F_none on success. + * + * Errors (with error bit) from: f_iki_object_is(). + * Errors (with error bit) from: fll_iki_content_escape(). + * + * F_failure (with error bit) for any other failure. * @param object * The object to validate and print. * @param content * The content to escape and print. * - * @return - * F_none on success. - * - * F_failure (with error bit) for any other failure. + * @see f_iki_object_is() + * @see fll_iki_content_escape() */ #ifndef _di_iki_write_process_ - 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; + extern void 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 b21cf92..d51637f 100644 --- a/level_3/status_code/c/common.c +++ b/level_3/status_code/c/common.c @@ -57,9 +57,7 @@ extern "C" { setting->status = f_console_parameter_process(arguments, &main->parameters); if (F_status_is_error(setting->status)) { - status_code_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); - status_code_print_line_last_locked(setting, main->error); + status_code_print_error(setting, main->error, "f_console_parameter_process"); return; } @@ -79,9 +77,7 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - status_code_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); - status_code_print_line_last_locked(setting, main->error); + status_code_print_error(setting, main->error, "fll_program_parameter_process_context"); return; } @@ -112,9 +108,7 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - status_code_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); - status_code_print_line_last_locked(setting, main->error); + status_code_print_error(setting, main->error, "fll_program_parameter_process_verbosity"); return; } diff --git a/level_3/status_code/c/print.c b/level_3/status_code/c/print.c index e457d5a..c1c9637 100644 --- a/level_3/status_code/c/print.c +++ b/level_3/status_code/c/print.c @@ -6,6 +6,19 @@ extern "C" { #endif +#ifndef _di_status_code_print_error_ + f_status_t status_code_print_error(status_code_setting_t * const setting, const fl_print_t print, const f_string_t function) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + status_code_print_line_first_locked(setting, print); + fll_error_print(print, F_status_set_fine(setting->status), function, F_true); + status_code_print_line_last_locked(setting, print); + + return F_none; + } +#endif // _di_status_code_print_error_ + #ifndef _di_status_code_print_error_cannot_error_warning_number_ f_status_t status_code_print_error_cannot_error_warning_number(status_code_setting_t * const setting, const fl_print_t print) { diff --git a/level_3/status_code/c/print.h b/level_3/status_code/c/print.h index 97a0a13..3caab26 100644 --- a/level_3/status_code/c/print.h +++ b/level_3/status_code/c/print.h @@ -13,6 +13,26 @@ extern "C" { #endif /** + * Print generic error message regarding a function failing in some way. + * + * @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. + * + * @see fll_error_print() + */ +#ifndef _di_status_code_print_error_ + extern f_status_t status_code_print_error(status_code_setting_t * const setting, const fl_print_t print, const f_string_t function); +#endif // _di_status_code_print_error_ + +/** * Print an error message when error parameter and warning parameter are specified without number parameter. * * @param setting diff --git a/level_3/utf8/c/common.c b/level_3/utf8/c/common.c index 35301bd..9f4b685 100644 --- a/level_3/utf8/c/common.c +++ b/level_3/utf8/c/common.c @@ -96,9 +96,7 @@ extern "C" { setting->status = f_console_parameter_process(arguments, &main->parameters); if (F_status_is_error(setting->status)) { - utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_process", F_true); - utf8_print_line_last_locked(setting, main->error); + utf8_print_error(setting, main->error, "f_console_parameter_process"); return; } @@ -118,9 +116,7 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_context", F_true); - utf8_print_line_last_locked(setting, main->error); + utf8_print_error(setting, main->error, "fll_program_parameter_process_context"); return; } @@ -151,9 +147,7 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "fll_program_parameter_process_verbosity", F_true); - utf8_print_line_last_locked(setting, main->error); + utf8_print_error(setting, main->error, "fll_program_parameter_process_verbosity"); return; } @@ -180,9 +174,7 @@ extern "C" { setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); if (F_status_is_error(setting->status)) { - utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - utf8_print_line_last_locked(setting, main->error); + utf8_print_error(setting, main->error, "f_console_parameter_prioritize_right"); return; } @@ -213,9 +205,7 @@ extern "C" { setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); if (F_status_is_error(setting->status)) { - utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_console_parameter_prioritize_right", F_true); - utf8_print_line_last_locked(setting, main->error); + utf8_print_error(setting, main->error, "f_console_parameter_prioritize_right"); return; } @@ -301,9 +291,7 @@ extern "C" { setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); if (F_status_is_error(setting->status)) { - utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamics_increase_by", F_true); - utf8_print_line_last_locked(setting, main->error); + utf8_print_error(setting, main->error, "f_string_dynamics_increase_by"); return; } @@ -313,9 +301,7 @@ extern "C" { 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)) { - utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_append_nulless", F_true); - utf8_print_line_last_locked(setting, main->error); + utf8_print_error(setting, main->error, "f_string_dynamic_append_nulless"); return; } @@ -325,9 +311,7 @@ extern "C" { setting->status = f_file_stream_open(main->parameters.arguments.array[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_locked(setting, main->error); - fll_error_file_print(main->error, F_status_set_fine(setting->status), "f_file_stream_open", F_true, main->parameters.arguments.array[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_locked(setting, main->error); + utf8_print_error_file(setting, main->error, "f_file_stream_open", main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); return; } @@ -367,9 +351,7 @@ extern "C" { 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)) { - utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamics_increase_by", F_true); - utf8_print_line_last_locked(setting, main->error); + utf8_print_error(setting, main->error, "f_string_dynamics_increase_by"); return; } @@ -440,9 +422,7 @@ extern "C" { setting->status = f_string_dynamics_resize(main->parameters.remaining.used, &setting->remaining); if (F_status_is_error(setting->status)) { - utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_append_nulless", F_true); - utf8_print_line_last_locked(setting, main->error); + utf8_print_error(setting, main->error, "f_string_dynamic_append_nulless"); return; } diff --git a/level_3/utf8/c/print.c b/level_3/utf8/c/print.c index b7f742d..4105f68 100644 --- a/level_3/utf8/c/print.c +++ b/level_3/utf8/c/print.c @@ -5,6 +5,32 @@ extern "C" { #endif +#ifndef _di_utf8_print_error_ + f_status_t utf8_print_error(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + utf8_print_line_first_locked(setting, print); + fll_error_print(print, F_status_set_fine(setting->status), function, F_true); + utf8_print_line_last_locked(setting, print); + + return F_none; + } +#endif // _di_utf8_print_error_ + +#ifndef _di_utf8_print_error_file_ + f_status_t utf8_print_error_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + utf8_print_line_first_locked(setting, print); + fll_error_file_print(print, F_status_set_fine(setting->status), function, F_true, name, operation, type); + utf8_print_line_last_locked(setting, print); + + return F_none; + } +#endif // _di_utf8_print_error_file_ + #ifndef _di_utf8_print_bytesequence_ f_status_t utf8_print_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence) { diff --git a/level_3/utf8/c/print.h b/level_3/utf8/c/print.h index d690ab0..8a656e6 100644 --- a/level_3/utf8/c/print.h +++ b/level_3/utf8/c/print.h @@ -13,6 +13,55 @@ extern "C" { #endif /** + * Print generic error message regarding a function failing in some way. + * + * @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. + * + * @see fll_error_print() + */ +#ifndef _di_utf8_print_error_ + extern f_status_t utf8_print_error(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function); +#endif // _di_utf8_print_error_ + +/** + * Print file related error or warning messages. + * + * @param setting + * The main program settings. + * + * This does not alter setting.status. + * @param print + * Designates how printing is to be performed. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * @param name + * The name of the file or directory. + * @param operation + * The operation that fails, such as 'create' or 'access'. + * @param type + * A valid file type code from the fll_error_file_type enum. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * @see fll_error_file_print() + */ +#ifndef _di_utf8_print_error_file_ + extern f_status_t utf8_print_error_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type); +#endif // _di_utf8_print_error_file_ + +/** * Print the byte sequence character (such as '豸'). * * @param main diff --git a/level_3/utf8/c/utf8.c b/level_3/utf8/c/utf8.c index 84a3712..a26997b 100644 --- a/level_3/utf8/c/utf8.c +++ b/level_3/utf8/c/utf8.c @@ -53,7 +53,7 @@ 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, f_string_empty_s, f_file_operation_process_s, fll_error_file_type_pipe_e); + utf8_print_error_file(setting, main->error, setting->mode & utf8_mode_from_bytesequence_e ? "utf8_process_file_bytesequence" : "utf8_process_file_codepoint", f_string_empty_s, f_file_operation_process_s, fll_error_file_type_pipe_e); } } @@ -78,7 +78,7 @@ extern "C" { 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, setting->path_files_from.array[i], f_file_operation_open_s, fll_error_file_type_file_e); + utf8_print_error_file(setting, main->error, "f_file_stream_open", setting->path_files_from.array[i], f_file_operation_open_s, fll_error_file_type_file_e); break; } @@ -118,7 +118,7 @@ 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, setting->path_files_from.array[i], f_file_operation_process_s, fll_error_file_type_file_e); + utf8_print_error_file(setting, main->error, setting->mode & utf8_mode_from_bytesequence_e ? "utf8_process_file_bytesequence" : "utf8_process_file_codepoint", setting->path_files_from.array[i], f_file_operation_process_s, fll_error_file_type_file_e); break; } -- 1.8.3.1