From c35da1e46c9f907805ef34934b8d7a56d3c6ea97 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 1 Sep 2021 20:22:40 -0500 Subject: [PATCH] Progress: Continue string and convert changes. Handle some loose ends in the FSS read programs. Update fss_status_code and status_code. --- .../fss_basic_list_read/c/fss_basic_list_read.c | 2 +- level_3/fss_basic_read/c/fss_basic_read.c | 2 +- level_3/fss_basic_read/c/private-fss_basic_read.c | 42 ++++++++++- .../c/fss_embedded_list_read.c | 4 +- .../c/private-fss_embedded_list_read.c | 2 +- .../c/fss_extended_list_read.c | 2 +- .../c/private-fss_extended_list_read.c | 43 +++++++++-- level_3/fss_extended_read/c/fss_extended_read.c | 2 +- .../c/private-fss_extended_read.c | 87 +++++++++++----------- level_3/fss_status_code/c/fss_status_code.c | 59 ++++++++++----- level_3/fss_status_code/c/fss_status_code.h | 4 + .../fss_status_code/c/private-fss_status_code.c | 46 +++++++----- level_3/fss_status_code/data/build/dependencies | 3 + level_3/fss_status_code/data/build/settings | 4 +- level_3/status_code/c/private-status_code.c | 46 +++++++----- level_3/status_code/c/status_code.c | 63 +++++++++++----- level_3/status_code/c/status_code.h | 4 + level_3/status_code/data/build/dependencies | 3 + level_3/status_code/data/build/settings | 4 +- 19 files changed, 287 insertions(+), 135 deletions(-) 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 99c6ff4..4500997 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 @@ -597,7 +597,7 @@ extern "C" { fss_basic_list_read_data_delete_simple(&data); } else { - fll_print_format("%c%[%sYou failed to specify one or more files.%]%c", main->error.to.stream, main->error.context, main->error.prefix, main->error.context, f_string_eol_s[0]); + fll_print_format("%c%[%sYou failed to specify one or more files.%]%c", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, f_string_eol_s[0]); status = F_status_set_error(F_parameter); } diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 7ae6323..579a687 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -597,7 +597,7 @@ extern "C" { fss_basic_read_data_delete_simple(&data); } else { - fll_print_format("%c%[%sYou failed to specify one or more files.%]%c", main->error.to.stream, main->error.context, main->error.prefix, main->error.context, f_string_eol_s[0]); + fll_print_format("%c%[%sYou failed to specify one or more files.%]%c", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, f_string_eol_s[0]); status = F_status_set_error(F_parameter); } diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.c b/level_3/fss_basic_read/c/private-fss_basic_read.c index 0b3542f..605bce0 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.c +++ b/level_3/fss_basic_read/c/private-fss_basic_read.c @@ -345,7 +345,11 @@ extern "C" { // This standard does not support multiple content groups. if ((data->option & fss_basic_read_data_option_select) && data->select) { if (main->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { + flockfile(main->output.stream); + fss_basic_read_print_zero(main); + + funlockfile(main->output.stream); } return F_none; @@ -394,7 +398,11 @@ extern "C" { if (data->depths.array[0].value_at >= data->objects.used) { if (data->option & (fss_basic_read_data_option_columns | fss_basic_read_data_option_total)) { + flockfile(main->output.stream); + fss_basic_read_print_zero(main); + + funlockfile(main->output.stream); } return F_none; @@ -404,7 +412,11 @@ extern "C" { if (data->option & fss_basic_read_data_option_line) { if (data->line) { if (data->option & fss_basic_read_data_option_total) { + flockfile(main->output.stream); + fss_basic_read_print_zero(main); + + funlockfile(main->output.stream); } return F_none; @@ -427,22 +439,30 @@ extern "C" { if (data->line) break; if (data->option & fss_basic_read_data_option_total) { + flockfile(main->output.stream); + fss_basic_read_print_one(main); + + funlockfile(main->output.stream); } else { fss_basic_read_print_at(i, *delimits, except_none, main, data); } } else if (data->option & fss_basic_read_data_option_columns) { - fprintf(main->output.stream, "%llu%c", data->contents.array[i].used, f_string_eol_s[0]); + fll_print_format("%ul%c", main->output.stream, data->contents.array[i].used, f_string_eol_s[0]); } else if (data->option & fss_basic_read_data_option_total) { + flockfile(main->output.stream); + if (data->contents.array[i].used) { fss_basic_read_print_one(main); } else { fss_basic_read_print_zero(main); } + + funlockfile(main->output.stream); } else { fss_basic_read_print_at(i, *delimits, except_none, main, data); @@ -455,7 +475,11 @@ extern "C" { } // for if (data->option & fss_basic_read_data_option_total) { + flockfile(main->output.stream); + fss_basic_read_print_zero(main); + + funlockfile(main->output.stream); } return F_none; @@ -466,8 +490,12 @@ extern "C" { f_status_t fss_basic_read_process_columns(fss_basic_read_main_t * const main, fss_basic_read_data_t *data, bool names[]) { if (!(data->option & fss_basic_read_data_option_content)) { + flockfile(main->output.stream); + fss_basic_read_print_zero(main); + funlockfile(main->output.stream); + return F_none; } @@ -482,7 +510,7 @@ extern "C" { } } // for - fprintf(main->output.stream, "%llu%c", max, f_string_eol_s[0]); + fll_print_format("%ul%c", main->output.stream, max, f_string_eol_s[0]); return F_none; } @@ -504,8 +532,12 @@ extern "C" { if (!data->contents.array[i].used) { if (data->option & fss_basic_read_data_option_empty) { if (line == data->line) { + flockfile(main->output.stream); + fss_basic_read_print_set_end(main); + funlockfile(main->output.stream); + break; } @@ -642,6 +674,8 @@ extern "C" { ++total; } // for + flockfile(main->output.stream); + if (data->option & fss_basic_read_data_option_line) { if (data->line < total) { fss_basic_read_print_one(main); @@ -651,9 +685,11 @@ extern "C" { } } else { - fprintf(main->output.stream, "%llu%c", total, f_string_eol_s[0]); + fl_print_format("%ul%c", main->output.stream, total, f_string_eol_s[0]); } + funlockfile(main->output.stream); + return F_none; } #endif // _di_fss_basic_read_process_total_ 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 7e601f6..9e4c924 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 @@ -446,7 +446,7 @@ extern "C" { // Skip past empty files. if (!main->quantity.total) { if (main->parameters[fss_embedded_list_read_parameter_total].result == f_console_result_found) { - fprintf(main->output.stream, "0%c", f_string_eol_s[0]); + fll_print_format("0%c", main->output.stream, f_string_eol_s[0]); } f_file_stream_close(F_true, &file); @@ -487,7 +487,7 @@ extern "C" { macro_f_fss_comments_t_delete_simple(comments); } else { - fll_print_format("%c%[%sYou failed to specify one or more files.%]%c", main->error.to.stream, main->error.context, main->error.prefix, main->error.context, f_string_eol_s[0]); + fll_print_format("%c%[%sYou failed to specify one or more files.%]%c", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, f_string_eol_s[0]); status = F_status_set_error(F_parameter); } diff --git a/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c index 92412d4..0aa8e05 100644 --- a/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c @@ -495,7 +495,7 @@ extern "C" { ++total; } // for - fl_print_format("%lu%c", main->output.stream, total, f_string_eol_s[0]); + fll_print_format("%lu%c", main->output.stream, total, f_string_eol_s[0]); return F_none; } 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 a4c8b18..08a67b6 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 @@ -595,7 +595,7 @@ extern "C" { fss_extended_list_read_data_delete_simple(&data); } else { - fll_print_format("%c%[%sYou failed to specify one or more files.%]%c", main->error.to.stream, main->error.context, main->error.prefix, main->error.context, f_string_eol_s[0]); + fll_print_format("%c%[%sYou failed to specify one or more files.%]%c", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, f_string_eol_s[0]); status = F_status_set_error(F_parameter); } diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c index 34fbde0..2ed16c0 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c @@ -463,7 +463,11 @@ extern "C" { if (data->depths.array[0].value_at >= data->objects.used) { if (data->option & (fss_extended_list_read_data_option_columns | fss_extended_list_read_data_option_total)) { + flockfile(main->output.stream); + fss_extended_list_read_print_zero(main); + + funlockfile(main->output.stream); } return F_none; @@ -488,16 +492,20 @@ extern "C" { if (status == F_success) return F_none; } else if (data->option & fss_extended_list_read_data_option_columns) { - fprintf(main->output.stream, "%llu%c", data->contents.array[i].used, f_string_eol_s[0]); + fll_print_format("%ul%c", main->output.stream, data->contents.array[i].used, f_string_eol_s[0]); } else if (data->option & fss_extended_list_read_data_option_total) { if ((data->option & fss_extended_list_read_data_option_object) && !(data->option & fss_extended_list_read_data_option_content)) { + flockfile(main->output.stream); + if (data->contents.array[i].used) { fss_extended_list_read_print_one(main); } else { fss_extended_list_read_print_zero(main); } + + funlockfile(main->output.stream); } else { f_array_length_t total = 0; @@ -539,7 +547,7 @@ extern "C" { } } // for - fprintf(main->output.stream, "%llu%c", total, f_string_eol_s[0]); + fll_print_format("%ul%c", main->output.stream, total, f_string_eol_s[0]); } } else { @@ -553,7 +561,11 @@ extern "C" { } // for if (data->option & fss_extended_list_read_data_option_total) { + flockfile(main->output.stream); + fss_extended_list_read_print_zero(main); + + funlockfile(main->output.stream); } return F_none; @@ -564,8 +576,12 @@ extern "C" { f_status_t fss_extended_list_read_process_columns(fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data, bool names[]) { if (!(data->option & fss_extended_list_read_data_option_content)) { + flockfile(main->output.stream); + fss_extended_list_read_print_zero(main); + funlockfile(main->output.stream); + return F_none; } @@ -580,7 +596,7 @@ extern "C" { } } // for - fprintf(main->output.stream, "%llu%c", max, f_string_eol_s[0]); + fll_print_format("%ul%c", main->output.stream, max, f_string_eol_s[0]); return F_none; } @@ -590,7 +606,10 @@ extern "C" { f_status_t fss_extended_list_read_process_at_line(const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data, f_array_length_t *line) { if (data->option & fss_extended_list_read_data_option_object) { + if (*line == data->line) { + flockfile(main->output.stream); + if (data->option & fss_extended_list_read_data_option_total) { fss_extended_list_read_print_one(main); } @@ -598,6 +617,8 @@ extern "C" { fss_extended_list_read_print_at_object(main, data, at, delimits_object); } + funlockfile(main->output.stream); + return F_success; } @@ -627,6 +648,8 @@ extern "C" { if (*line == data->line) { range.stop = i; + flockfile(main->output.stream); + if (data->option & fss_extended_list_read_data_option_total) { fss_extended_list_read_print_one(main); } @@ -634,6 +657,8 @@ extern "C" { f_print_except_in_dynamic_partial(data->buffer, range, delimits_content, data->comments, main->output.stream); } + funlockfile(main->output.stream); + return F_success; } @@ -650,6 +675,8 @@ extern "C" { ++(*line); if (*line == data->line) { + flockfile(main->output.stream); + if (data->option & fss_extended_list_read_data_option_total) { fss_extended_list_read_print_one(main); } @@ -657,9 +684,11 @@ extern "C" { range.stop = data->contents.array[at].array[0].stop; f_print_except_in_dynamic_partial(data->buffer, range, delimits_content, data->comments, main->output.stream); - fprintf(main->output.stream, "%c", f_string_eol_s[0]); + f_print_character(f_string_eol_s[0], main->output.stream); } + funlockfile(main->output.stream); + return F_success; } } @@ -828,6 +857,8 @@ extern "C" { } } // for + flockfile(main->output.stream); + if (data->option & fss_extended_list_read_data_option_line) { if (data->line < total) { fss_extended_list_read_print_one(main); @@ -837,9 +868,11 @@ extern "C" { } } else { - fprintf(main->output.stream, "%llu%c", total, f_string_eol_s[0]); + fl_print_format("%ul%c", main->output.stream, total, f_string_eol_s[0]); } + funlockfile(main->output.stream); + return F_none; } #endif // _di_fss_extended_list_read_process_total_ 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 b66588f..f5058c4 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -595,7 +595,7 @@ extern "C" { fss_extended_read_data_delete_simple(&data); } else { - fll_print_format("%c%[%sYou failed to specify one or more files.%]%c", main->error.to.stream, main->error.context, main->error.prefix, main->error.context, f_string_eol_s[0]); + fll_print_format("%c%[%sYou failed to specify one or more files.%]%c", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context, f_string_eol_s[0]); status = F_status_set_error(F_parameter); } diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.c b/level_3/fss_extended_read/c/private-fss_extended_read.c index a0db80c..cd9c248 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.c +++ b/level_3/fss_extended_read/c/private-fss_extended_read.c @@ -357,30 +357,46 @@ extern "C" { if (data->option & fss_extended_read_data_option_select) { if (data->option & fss_extended_read_data_option_object) { + flockfile(main->output.stream); + fss_extended_read_print_one(main); + funlockfile(main->output.stream); + return F_success; } if (data->select < data->contents.array[at].used) { if (data->contents.array[at].array[data->select].start <= data->contents.array[at].array[data->select].stop || (data->option & fss_extended_read_data_option_empty)) { + flockfile(main->output.stream); + fss_extended_read_print_one(main); + funlockfile(main->output.stream); + return F_success; } } } else if ((data->option & fss_extended_read_data_option_object) || (data->option & fss_extended_read_data_option_empty)) { + flockfile(main->output.stream); + fss_extended_read_print_one(main); + funlockfile(main->output.stream); + return F_success; } else if (data->contents.array[at].used) { for (f_array_length_t j = 0; j < data->contents.array[at].used; ++j) { if (data->contents.array[at].array[j].start <= data->contents.array[at].array[j].stop) { + flockfile(main->output.stream); + fss_extended_read_print_one(main); + funlockfile(main->output.stream); + return F_success; } } // for @@ -428,7 +444,6 @@ extern "C" { f_print_character(fss_extended_read_pipe_content_end, main->output.stream); } else { - fprintf(main->output.stream, "%c", f_fss_eol); f_print_character(f_fss_eol, main->output.stream); } } @@ -491,7 +506,11 @@ extern "C" { if (data->depths.array[0].value_at >= data->objects.used) { if (data->option & (fss_extended_read_data_option_columns | fss_extended_read_data_option_total)) { + flockfile(main->output.stream); + fss_extended_read_print_zero(main); + + funlockfile(main->output.stream); } return F_none; @@ -501,7 +520,11 @@ extern "C" { if (data->option & fss_extended_read_data_option_line) { if (data->line) { if (data->option & fss_extended_read_data_option_total) { + flockfile(main->output.stream); + fss_extended_read_print_zero(main); + + funlockfile(main->output.stream); } return F_none; @@ -534,7 +557,7 @@ extern "C" { } } else if (data->option & fss_extended_read_data_option_columns) { - fprintf(main->output.stream, "%llu%c", data->contents.array[i].used, f_string_eol_s[0]); + fll_print_format("%ul%c", main->output.stream, data->contents.array[i].used, f_string_eol_s[0]); } else if (data->option & fss_extended_read_data_option_total) { if (fss_extended_read_print_at_total(i, main, data) == F_none) { @@ -552,7 +575,11 @@ extern "C" { } // for if (data->option & fss_extended_read_data_option_total) { + flockfile(main->output.stream); + fss_extended_read_print_zero(main); + + funlockfile(main->output.stream); } return F_none; @@ -563,8 +590,12 @@ extern "C" { f_status_t fss_extended_read_process_columns(fss_extended_read_main_t * const main, fss_extended_read_data_t *data, bool names[]) { if (!(data->option & fss_extended_read_data_option_content)) { + flockfile(main->output.stream); + fss_extended_read_print_zero(main); + funlockfile(main->output.stream); + return F_none; } @@ -579,7 +610,7 @@ extern "C" { } } // for - fprintf(main->output.stream, "%llu%c", max, f_string_eol_s[0]); + fll_print_format("%ul%c", main->output.stream, max, f_string_eol_s[0]); return F_none; } @@ -602,8 +633,12 @@ extern "C" { if (!data->contents.array[i].used) { if (data->option & fss_extended_read_data_option_empty) { if (line == data->line) { + flockfile(main->output.stream); + fss_extended_read_print_set_end(main); + funlockfile(main->output.stream); + break; } @@ -769,6 +804,8 @@ extern "C" { } // for } + flockfile(main->output.stream); + if (data->option & fss_extended_read_data_option_line) { if (data->line < total) { fss_extended_read_print_one(main); @@ -778,52 +815,14 @@ extern "C" { } } else { - fprintf(main->output.stream, "%llu%c", total, f_string_eol_s[0]); + fl_print_format("%ul%c", main->output.stream, total, f_string_eol_s[0]); } - return F_none; - } -#endif // _di_fss_extended_read_process_total_ - - - -#ifndef _di_fss_extended_read_process_total_content_ - f_status_t fss_extended_read_process_total_content(const f_array_length_t at, fss_extended_read_main_t * const main, fss_extended_read_data_t *data, f_array_length_t *total) { - - if (data->option & fss_extended_read_data_option_select) { - if (data->option & fss_extended_read_data_option_object) { - fss_extended_read_print_one(main); - - return F_success; - } - - if (data->select < data->contents.array[at].used) { - if (data->contents.array[at].array[data->select].start <= data->contents.array[at].array[data->select].stop || (data->option & fss_extended_read_data_option_empty)) { - fss_extended_read_print_one(main); - - return F_success; - } - } - } - else if ((data->option & fss_extended_read_data_option_object) || (data->option & fss_extended_read_data_option_empty)) { - fss_extended_read_print_one(main); - - return F_success; - } - else if (data->contents.array[at].used) { - for (f_array_length_t j = 0; j < data->contents.array[at].used; ++j) { - - if (data->contents.array[at].array[j].start <= data->contents.array[at].array[j].stop) { - fss_extended_read_print_one(main); - - return F_success; - } - } // for - } + funlockfile(main->output.stream); return F_none; } -#endif // _di_fss_extended_read_process_total_content_ +#endif // _di_fss_extended_read_process_total_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_status_code/c/fss_status_code.c b/level_3/fss_status_code/c/fss_status_code.c index 1839088..91cd9dd 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -9,6 +9,8 @@ extern "C" { #ifndef _di_fss_status_code_print_help_ f_status_t fss_status_code_print_help(const f_file_t output, const f_color_context_t context) { + flockfile(output.stream); + fll_program_print_help_header(output, context, fss_status_code_name_long, fss_status_code_version); fll_program_print_help_option(output, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); @@ -21,7 +23,7 @@ extern "C" { fll_program_print_help_option(output, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, inceasing verbosity beyond normal output."); fll_program_print_help_option(output, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); - fprintf(output.stream, "%c", f_string_eol_s[0]); + f_print_character(f_string_eol_s[0], output.stream); fll_program_print_help_option(output, context, fss_status_code_short_is_fine, fss_status_code_long_is_fine, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print F_true if the error code is not an error, F_false otherwise."); fll_program_print_help_option(output, context, fss_status_code_short_is_warning, fss_status_code_long_is_warning, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Print F_true if the error code is a warning, F_false otherwise."); @@ -30,6 +32,8 @@ extern "C" { fll_program_print_help_usage(output, context, fss_status_code_name, "status code(s)"); + funlockfile(output.stream); + return F_none; } #endif // _di_fss_status_code_print_help_ @@ -50,9 +54,12 @@ extern "C" { if (main->context.set.error.before) { main->error.context = main->context.set.error; main->error.notable = main->context.set.notable; + + main->warning.context = main->context.set.warning; + main->warning.notable = main->context.set.notable; } else { - f_color_set_t *sets[] = { &main->error.context, &main->error.notable, 0 }; + f_color_set_t *sets[] = { &main->error.context, &main->error.notable, &main->warning.context, &main->warning.notable, 0 }; fll_program_parameter_process_empty(&main->context, sets); } @@ -78,15 +85,19 @@ extern "C" { if (choice == fss_status_code_parameter_verbosity_quiet) { main->error.verbosity = f_console_verbosity_quiet; + main->warning.verbosity = f_console_verbosity_quiet; } else if (choice == fss_status_code_parameter_verbosity_normal) { main->error.verbosity = f_console_verbosity_normal; + main->warning.verbosity = f_console_verbosity_normal; } else if (choice == fss_status_code_parameter_verbosity_verbose) { main->error.verbosity = f_console_verbosity_verbose; + main->warning.verbosity = f_console_verbosity_verbose; } else if (choice == fss_status_code_parameter_verbosity_debug) { main->error.verbosity = f_console_verbosity_debug; + main->warning.verbosity = f_console_verbosity_debug; } } @@ -109,39 +120,51 @@ extern "C" { if (main->parameters[fss_status_code_parameter_is_error].result == f_console_result_found) { if (main->parameters[fss_status_code_parameter_is_warning].result == f_console_result_found) { - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_status_code_long_is_error); - f_color_print(main->error.to.stream, main->context.set.error, "' cannot be used with the parameter "); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_status_code_long_is_warning); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->output.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_status_code_long_is_error, main->error.notable); + fl_print_format("%[' cannot be used with the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_status_code_long_is_warning, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->output.stream); fss_status_code_main_delete(main); return F_status_set_error(status); } else if (main->parameters[fss_status_code_parameter_is_fine].result == f_console_result_found) { - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_status_code_long_is_error); - f_color_print(main->error.to.stream, main->context.set.error, "' cannot be used with the parameter "); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_status_code_long_is_fine); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->output.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_status_code_long_is_error, main->error.notable); + fl_print_format("%[' cannot be used with the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_status_code_long_is_fine, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->output.stream); fss_status_code_main_delete(main); return F_status_set_error(status); } } else if (main->parameters[fss_status_code_parameter_is_warning].result == f_console_result_found && main->parameters[fss_status_code_parameter_is_fine].result == f_console_result_found) { - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_status_code_long_is_warning); - f_color_print(main->error.to.stream, main->context.set.error, "' cannot be used with the parameter "); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_status_code_long_is_fine); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->output.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_status_code_long_is_warning, main->error.notable); + fl_print_format("%[' cannot be used with the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_status_code_long_is_fine, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->output.stream); fss_status_code_main_delete(main); return F_status_set_error(status); } if (main->remaining.used == 0 && !main->process_pipe) { - f_color_print(main->error.to.stream, main->context.set.error, "%sYou failed to specify an error code.%c", fll_error_print_error, f_string_eol_s[0]); + fll_print_format("%[You failed to specify an error code.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); fss_status_code_main_delete(main); return F_status_set_error(F_parameter); diff --git a/level_3/fss_status_code/c/fss_status_code.h b/level_3/fss_status_code/c/fss_status_code.h index 34a8220..dfc4892 100644 --- a/level_3/fss_status_code/c/fss_status_code.h +++ b/level_3/fss_status_code/c/fss_status_code.h @@ -30,12 +30,14 @@ // fll-1 includes #include #include +#include #include #include // fll-2 includes #include #include +#include #include #include @@ -121,6 +123,7 @@ extern "C" { f_file_t output; fll_error_print_t error; + fll_error_print_t warning; f_color_context_t context; } fss_status_code_main_t; @@ -132,6 +135,7 @@ extern "C" { F_false, \ macro_f_file_t_initialize2(f_type_output, f_type_descriptor_output, f_file_flag_write_only), \ fll_error_print_t_initialize, \ + macro_fll_error_print_t_initialize_warning(), \ f_color_context_t_initialize, \ } #endif // _di_fss_status_code_main_t_ diff --git a/level_3/fss_status_code/c/private-fss_status_code.c b/level_3/fss_status_code/c/private-fss_status_code.c index 4b1f433..803f746 100644 --- a/level_3/fss_status_code/c/private-fss_status_code.c +++ b/level_3/fss_status_code/c/private-fss_status_code.c @@ -8,6 +8,7 @@ extern "C" { #ifndef _di_fss_status_code_process_check_ f_status_t fss_status_code_process_check(const fss_status_code_main_t main, const f_string_t value) { + f_number_unsigned_t number = 0; f_status_t status = fss_status_code_convert_number(main, value, &number); @@ -15,27 +16,33 @@ extern "C" { if (main.parameters[fss_status_code_parameter_is_error].result == f_console_result_found) { if (F_status_is_error(number)) { - printf("%s\n", FL_status_string_true); + f_print_terminated(FL_status_string_true, main.output.stream); } else { - printf("%s\n", FL_status_string_false); + f_print_terminated(FL_status_string_false, main.output.stream); } + + f_print_character(f_string_eol_s[0], main.output.stream); } else if (main.parameters[fss_status_code_parameter_is_warning].result == f_console_result_found) { if (F_status_is_warning(number)) { - printf("%s\n", FL_status_string_true); + f_print_terminated(FL_status_string_true, main.output.stream); } else { - printf("%s\n", FL_status_string_false); + f_print_terminated(FL_status_string_false, main.output.stream); } + + f_print_character(f_string_eol_s[0], main.output.stream); } else if (main.parameters[fss_status_code_parameter_is_fine].result == f_console_result_found) { if (F_status_is_fine(number)) { - printf("%s\n", FL_status_string_true); + f_print_terminated(FL_status_string_true, main.output.stream); } else { - printf("%s\n", FL_status_string_false); + f_print_terminated(FL_status_string_false, main.output.stream); } + + f_print_character(f_string_eol_s[0], main.output.stream); } return F_none; @@ -44,6 +51,7 @@ extern "C" { #ifndef _di_fss_status_code_process_number_ f_status_t fss_status_code_process_number(const fss_status_code_main_t main, const f_string_t value) { + f_status_t status = F_none; { @@ -54,13 +62,13 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(value, range, &number); if (status == F_none) { - f_color_print(main.output.stream, main.context.set.error, "invalid name%c", f_string_eol_s[0]); + fll_print_format("%[invalid name%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); return F_status_set_error(F_parameter); } if (status == F_data_not || F_status_set_fine(status) == F_parameter) { - f_color_print(main.output.stream, main.context.set.error, "invalid main%c", f_string_eol_s[0]); + fll_print_format("%[invalid main%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); return status; } @@ -77,10 +85,10 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { - f_color_print(main.output.stream, main.context.set.error, "unknown name%c", f_string_eol_s[0]); + fll_print_format("%[unknown name%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } else { - f_color_print(main.output.stream, main.context.set.error, "failed to convert%c", f_string_eol_s[0]); + fll_print_format("%[failed to convert%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } return status; @@ -88,12 +96,12 @@ extern "C" { } if (status == F_data) { - f_color_print(main.output.stream, main.context.set.warning, "unknown code%c", f_string_eol_s[0]); + fll_print_format("%[unknown code%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); return F_none; } - printf("%u\n", code); + fll_print_format("%ui%c", main.output.stream, code, f_string_eol_s[0]); return F_none; } @@ -101,6 +109,7 @@ extern "C" { #ifndef _di_fss_status_code_process_normal_ f_status_t fss_status_code_process_normal(const fss_status_code_main_t main, const f_string_t value) { + f_number_unsigned_t number = 0; f_status_t status = fss_status_code_convert_number(main, value, &number); @@ -113,16 +122,16 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { - f_color_print(main.output.stream, main.context.set.error, "unknown code%c", f_string_eol_s[0]); + fll_print_format("%[unknown code%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } else { - f_color_print(main.output.stream, main.context.set.error, "failed to convert%c", f_string_eol_s[0]); + fll_print_format("%[failed to convert%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } return status; } - printf("%s\n", string); + fll_print_format("%S%c", main.output.stream, string, f_string_eol_s[0]); return F_none; } @@ -130,22 +139,23 @@ extern "C" { #ifndef _di_fss_status_code_convert_number_ f_status_t fss_status_code_convert_number(const fss_status_code_main_t main, const f_string_t value, f_number_unsigned_t *number) { + const f_string_range_t range = macro_f_string_range_t_initialize(strlen(value)); f_status_t status = fl_conversion_string_to_number_unsigned(value, range, number); if (*number > F_status_size_max_with_signal) { - f_color_print(main.output.stream, main.context.set.error, "out of range%c", f_string_eol_s[0]); + fll_print_format("%[out of range%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); return status; } if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_number_negative) { - f_color_print(main.output.stream, main.context.set.error, "out of range%c", f_string_eol_s[0]); + fll_print_format("%[out of range%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } else { - f_color_print(main.output.stream, main.context.set.error, "invalid number%c", f_string_eol_s[0]); + fll_print_format("%[invalid number%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } return status; diff --git a/level_3/fss_status_code/data/build/dependencies b/level_3/fss_status_code/data/build/dependencies index a8d9226..808aad1 100644 --- a/level_3/fss_status_code/data/build/dependencies +++ b/level_3/fss_status_code/data/build/dependencies @@ -17,9 +17,12 @@ f_print fl_console fl_conversion fl_fss +fl_print fl_status +fl_string fll_error fll_file fll_fss +fll_print fll_program fll_status diff --git a/level_3/fss_status_code/data/build/settings b/level_3/fss_status_code/data/build/settings index b131479..4ac98f2 100644 --- a/level_3/fss_status_code/data/build/settings +++ b/level_3/fss_status_code/data/build/settings @@ -20,7 +20,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_program -lfll_status -lfl_console -lfl_conversion -lfl_directory -lfl_fss -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfll_status -lfl_console -lfl_conversion -lfl_directory -lfl_fss -lfl_print -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_status_code.c private-common.c private-fss_status_code.c @@ -51,7 +51,7 @@ defines_all defines_static defines_shared -flags_all -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses +flags_all -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses flags_shared flags_static flags_library -fPIC diff --git a/level_3/status_code/c/private-status_code.c b/level_3/status_code/c/private-status_code.c index 5ebe036..49eb2d2 100644 --- a/level_3/status_code/c/private-status_code.c +++ b/level_3/status_code/c/private-status_code.c @@ -8,6 +8,7 @@ extern "C" { #ifndef _di_status_code_process_check_ f_status_t status_code_process_check(const status_code_main_t main, const f_string_t value) { + f_number_unsigned_t number = 0; f_status_t status = status_code_convert_number(main, value, &number); @@ -17,27 +18,33 @@ extern "C" { if (main.parameters[status_code_parameter_is_error].result == f_console_result_found) { if (F_status_is_error(number)) { - printf("%s\n", FL_status_string_true); + f_print_terminated(FL_status_string_true, main.output.stream); } else { - printf("%s\n", FL_status_string_false); + f_print_terminated(FL_status_string_false, main.output.stream); } + + f_print_character(f_string_eol_s[0], main.output.stream); } else if (main.parameters[status_code_parameter_is_warning].result == f_console_result_found) { if (F_status_is_warning(number)) { - printf("%s\n", FL_status_string_true); + f_print_terminated(FL_status_string_true, main.output.stream); } else { - printf("%s\n", FL_status_string_false); + f_print_terminated(FL_status_string_false, main.output.stream); } + + f_print_character(f_string_eol_s[0], main.output.stream); } else if (main.parameters[status_code_parameter_is_fine].result == f_console_result_found) { if (F_status_is_fine(number)) { - printf("%s\n", FL_status_string_true); + f_print_terminated(FL_status_string_true, main.output.stream); } else { - printf("%s\n", FL_status_string_false); + f_print_terminated(FL_status_string_false, main.output.stream); } + + f_print_character(f_string_eol_s[0], main.output.stream); } return F_none; @@ -46,6 +53,7 @@ extern "C" { #ifndef _di_status_code_process_number_ f_status_t status_code_process_number(const status_code_main_t main, const f_string_t value) { + f_status_t status = F_none; { @@ -56,13 +64,13 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(value, range, &number); if (status == F_none) { - f_color_print(main.output.stream, main.context.set.error, "invalid name%c", f_string_eol_s[0]); + fll_print_format("%[invalid name%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); return F_status_set_error(F_parameter); } if (status == F_data_not || F_status_set_fine(status) == F_parameter) { - f_color_print(main.output.stream, main.context.set.error, "invalid main%c", f_string_eol_s[0]); + fll_print_format("%[invalid main%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); return status; } @@ -74,22 +82,22 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { - f_color_print(main.output.stream, main.context.set.error, "unknown name%c", f_string_eol_s[0]); + fll_print_format("%[unknown name%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } else { - f_color_print(main.output.stream, main.context.set.error, "failed to convert%c", f_string_eol_s[0]); + fll_print_format("%[failed to convert%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } return status; } if (status == F_data) { - f_color_print(main.output.stream, main.context.set.warning, "unknown code%c", f_string_eol_s[0]); + fll_print_format("%[unknown code%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); return F_none; } - printf("%u\n", code); + fll_print_format("%ui%c", main.output.stream, code, f_string_eol_s[0]); return F_none; } @@ -97,6 +105,7 @@ extern "C" { #ifndef _di_status_code_process_normal_ f_status_t status_code_process_normal(const status_code_main_t main, const f_string_t value) { + f_number_unsigned_t number = 0; f_status_t status = status_code_convert_number(main, value, &number); @@ -111,16 +120,16 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { - f_color_print(main.output.stream, main.context.set.error, "unknown code%c", f_string_eol_s[0]); + fll_print_format("%[unknown code%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } else { - f_color_print(main.output.stream, main.context.set.error, "failed to convert%c", f_string_eol_s[0]); + fll_print_format("%[failed to convert%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } return status; } - printf("%s\n", string); + fll_print_format("%S%c", main.output.stream, string, f_string_eol_s[0]); return F_none; } @@ -128,22 +137,23 @@ extern "C" { #ifndef _di_status_code_convert_number_ f_status_t status_code_convert_number(const status_code_main_t main, const f_string_t value, f_number_unsigned_t *number) { + const f_string_range_t range = macro_f_string_range_t_initialize(strlen(value)); f_status_t status = fl_conversion_string_to_number_unsigned(value, range, number); if (*number > F_status_size_max_with_signal) { - f_color_print(main.output.stream, main.context.set.error, "out of range%c", f_string_eol_s[0]); + fll_print_format("%[out of range%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); return status; } if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_number_negative) { - f_color_print(main.output.stream, main.context.set.error, "out of range%c", f_string_eol_s[0]); + fll_print_format("%[out of range%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } else { - f_color_print(main.output.stream, main.context.set.error, "invalid number%c", f_string_eol_s[0]); + fll_print_format("%[invalid number%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } return status; diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index fdf2d05..4275031 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -9,6 +9,8 @@ extern "C" { #ifndef _di_status_code_print_help_ f_status_t status_code_print_help(const f_file_t output, const f_color_context_t context) { + flockfile(output.stream); + fll_program_print_help_header(output, context, status_code_name_long, status_code_version); fll_program_print_help_option(output, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); @@ -21,7 +23,7 @@ extern "C" { fll_program_print_help_option(output, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, inceasing verbosity beyond normal output."); fll_program_print_help_option(output, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); - fprintf(output.stream, "%c", f_string_eol_s[0]); + f_print_character(f_string_eol_s[0], output.stream); fll_program_print_help_option(output, context, status_code_short_is_fine, status_code_long_is_fine, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print F_true if the error code is not an error, F_false otherwise."); fll_program_print_help_option(output, context, status_code_short_is_warning, status_code_long_is_warning, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Print F_true if the error code is a warning, F_false otherwise."); @@ -30,6 +32,8 @@ extern "C" { fll_program_print_help_usage(output, context, status_code_name, "status code(s)"); + funlockfile(output.stream); + return F_none; } #endif // _di_status_code_print_help_ @@ -50,9 +54,12 @@ extern "C" { if (main->context.set.error.before) { main->error.context = main->context.set.error; main->error.notable = main->context.set.notable; + + main->warning.context = main->context.set.warning; + main->warning.notable = main->context.set.notable; } else { - f_color_set_t *sets[] = { &main->error.context, &main->error.notable, 0 }; + f_color_set_t *sets[] = { &main->error.context, &main->error.notable, &main->warning.context, &main->warning.notable, 0 }; fll_program_parameter_process_empty(&main->context, sets); } @@ -78,15 +85,19 @@ extern "C" { if (choice == status_code_parameter_verbosity_quiet) { main->error.verbosity = f_console_verbosity_quiet; + main->warning.verbosity = f_console_verbosity_quiet; } else if (choice == status_code_parameter_verbosity_normal) { main->error.verbosity = f_console_verbosity_normal; + main->warning.verbosity = f_console_verbosity_normal; } else if (choice == status_code_parameter_verbosity_verbose) { main->error.verbosity = f_console_verbosity_verbose; + main->warning.verbosity = f_console_verbosity_verbose; } else if (choice == status_code_parameter_verbosity_debug) { main->error.verbosity = f_console_verbosity_debug; + main->warning.verbosity = f_console_verbosity_debug; } } @@ -109,39 +120,51 @@ extern "C" { if (main->parameters[status_code_parameter_is_error].result == f_console_result_found) { if (main->parameters[status_code_parameter_is_warning].result == f_console_result_found) { - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, status_code_long_is_error); - f_color_print(main->error.to.stream, main->context.set.error, "' cannot be used with the parameter "); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, status_code_long_is_warning); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->output.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, status_code_long_is_error, main->error.notable); + fl_print_format("%[' cannot be used with the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, status_code_long_is_warning, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->output.stream); status_code_main_delete(main); return F_status_set_error(status); } else if (main->parameters[status_code_parameter_is_fine].result == f_console_result_found) { - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, status_code_long_is_error); - f_color_print(main->error.to.stream, main->context.set.error, "' cannot be used with the parameter "); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, status_code_long_is_fine); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->output.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, status_code_long_is_error, main->error.notable); + fl_print_format("%[' cannot be used with the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, status_code_long_is_fine, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->output.stream); status_code_main_delete(main); return F_status_set_error(status); } } else if (main->parameters[status_code_parameter_is_warning].result == f_console_result_found && main->parameters[status_code_parameter_is_fine].result == f_console_result_found) { - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, status_code_long_is_warning); - f_color_print(main->error.to.stream, main->context.set.error, "' cannot be used with the parameter "); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, status_code_long_is_fine); - f_color_print(main->error.to.stream, main->context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main->output.stream); + + fl_print_format("%c%[%sThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, status_code_long_is_warning, main->error.notable); + fl_print_format("%[' cannot be used with the parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, status_code_long_is_fine, main->error.notable); + fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->output.stream); status_code_main_delete(main); return F_status_set_error(status); } if (main->remaining.used == 0 && !main->process_pipe) { - f_color_print(main->error.to.stream, main->context.set.error, "%sYou failed to specify a status code.%c", fll_error_print_error, f_string_eol_s[0]); + fll_print_format("%[You failed to specify a status code.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); status_code_main_delete(main); return F_status_set_error(F_parameter); @@ -155,6 +178,8 @@ extern "C" { } if (main->remaining.used > 0) { + flockfile(main->output.stream); + for (f_array_length_t i = 0; i < main->remaining.used; ++i) { status2 = status_code_process_check(*main, arguments.argv[main->remaining.array[i]]); @@ -163,6 +188,8 @@ extern "C" { status = status2; } } // for + + funlockfile(main->output.stream); } } else if (main->parameters[status_code_parameter_number].result == f_console_result_found) { diff --git a/level_3/status_code/c/status_code.h b/level_3/status_code/c/status_code.h index b8b0d69..6bc93ef 100644 --- a/level_3/status_code/c/status_code.h +++ b/level_3/status_code/c/status_code.h @@ -30,11 +30,13 @@ // fll-1 includes #include #include +#include #include #include // fll-2 includes #include +#include #include #include @@ -120,6 +122,7 @@ extern "C" { f_file_t output; fll_error_print_t error; + fll_error_print_t warning; f_color_context_t context; } status_code_main_t; @@ -131,6 +134,7 @@ extern "C" { F_false, \ macro_f_file_t_initialize2(f_type_output, f_type_descriptor_output, f_file_flag_write_only), \ fll_error_print_t_initialize, \ + macro_fll_error_print_t_initialize_warning(), \ f_color_context_t_initialize, \ } #endif // _di_status_code_main_t_ diff --git a/level_3/status_code/data/build/dependencies b/level_3/status_code/data/build/dependencies index 0f7a8c5..4ad511e 100644 --- a/level_3/status_code/data/build/dependencies +++ b/level_3/status_code/data/build/dependencies @@ -13,7 +13,10 @@ f_pipe f_print fl_console fl_conversion +fl_print fl_status +fl_string fll_error +fll_print fll_program fll_status diff --git a/level_3/status_code/data/build/settings b/level_3/status_code/data/build/settings index f41a59c..b5d63a5 100644 --- a/level_3/status_code/data/build/settings +++ b/level_3/status_code/data/build/settings @@ -20,7 +20,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_program -lfll_status -lfl_console -lfl_conversion -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_print -lfll_program -lfll_status -lfl_console -lfl_conversion -lfl_print -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library status_code.c private-common.c private-status_code.c @@ -51,7 +51,7 @@ defines_all defines_static defines_shared -flags_all -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses +flags_all -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses flags_shared flags_static flags_library -fPIC -- 1.8.3.1