From: Kevin Day Date: Fri, 3 Sep 2021 03:07:00 +0000 (-0500) Subject: Progress: Continue string and convert changes. X-Git-Tag: 0.5.5~9 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=0445b5ae13ba9cfd3ff692aeb425c20048333058;p=fll Progress: Continue string and convert changes. Finish changing the fss_status_code and status_code, fixing mistakes identified. Change fss_identify. Change iki_write. --- diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index 8605792..07182b6 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -9,6 +9,8 @@ extern "C" { #ifndef _di_fss_identify_print_help_ f_status_t fss_identify_print_help(const f_file_t output, const f_color_context_t context) { + flockfile(output.stream); + fll_program_print_help_header(output, context, fss_identify_name_long, fss_identify_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,12 +23,12 @@ 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_identify_short_content, fss_identify_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Print the Identifier content (the 4-digit hexidecimal type code)."); fll_program_print_help_option(output, context, fss_identify_short_object, fss_identify_long_object, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Identifier object (the name)."); - 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_identify_short_line, fss_identify_long_line, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print only the Identifier at the given line."); fll_program_print_help_option(output, context, fss_identify_short_name, fss_identify_long_name, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object with this name."); @@ -34,38 +36,22 @@ extern "C" { fll_program_print_help_usage(output, context, fss_identify_name, "filename(s)"); - fprintf(output.stream, " The "); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_identify_long_line); - fprintf(output.stream, " parameter refers to the output lines and not the lines in a given file.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); - - fprintf(output.stream, " If neither the "); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_identify_long_object); - fprintf(output.stream, " nor ", f_string_eol_s[0]); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_identify_long_content); - fprintf(output.stream, " are specified, then the default behavior is to print both.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); + fl_print_format(" The %[%s%s%] parameter refers to the output lines and not the lines in a given file.%c%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_identify_long_line, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); - fprintf(output.stream, " When specifying the "); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_identify_long_total); - fprintf(output.stream, " parameter, neither the "); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_identify_long_object); - fprintf(output.stream, " nor the "); - f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_identify_long_content); - fprintf(output.stream, " parameter may be specified.%c", f_string_eol_s[0]); + fl_print_format(" If neither the %[%s%s%] nor", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_identify_long_object, context.set.notable); + fl_print_format(" %[%s%s%] are specified, then the default behavior is to print both.%c%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_identify_long_content, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); - fprintf(output.stream, "%c", f_string_eol_s[0]); + fl_print_format(" When specifying the %[%s%s%] parameter, neither the", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_identify_long_total, context.set.notable); + fl_print_format(" %[%s%s%] nor the", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_identify_long_object, context.set.notable); + fl_print_format(" %[%s%s%] parameter may be specified.%c%c", output.stream, context.set.notable, f_console_symbol_long_enable_s, fss_identify_long_content, context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); - fprintf(output.stream, " An FSS file is identified by the following format: '"); - f_color_print(output.stream, context.set.notable, "# Object-Content"); - fprintf(output.stream, "' where the Object, is a machine-name representing the name and may only consist of \"word\" characters and the Content is a 4-digit hexidecimal number representing a particular variant of the Object.%c", f_string_eol_s[0]); - fprintf(output.stream, " This identifier, if provided, must exist on the first line in a file and must begin with the pound character: '#'.%c", f_string_eol_s[0]); - fprintf(output.stream, " Whitespace must follow this pound character.%c", f_string_eol_s[0]); - fprintf(output.stream, " There may be multiple Object and Content pairs, separated by whitspace, such as: \"# fss-0002 fss-0000 iki-0002\".%c", f_string_eol_s[0]); + fl_print_format(" An FSS file is identified by the following format: '%[# Object-Content%]'", output.stream, context.set.notable, context.set.notable); + fl_print_format(" where the Object, is a machine-name representing the name and may only consist of \"word\" characters and the Content is a 4-digit hexidecimal number representing a particular variant of the Object.%c", output.stream, f_string_eol_s[0]); + fl_print_format(" This identifier, if provided, must exist on the first line in a file and must begin with the pound character: '#'.%c", output.stream, f_string_eol_s[0]); + fl_print_format(" Whitespace must follow this pound character.%c", output.stream, f_string_eol_s[0]); + fl_print_format(" There may be multiple Object and Content pairs, separated by whitspace, such as: \"# fss-0002 fss-0000 iki-0002\".%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); - fprintf(output.stream, "%c", f_string_eol_s[0]); + funlockfile(output.stream); return F_none; } @@ -100,7 +86,7 @@ extern "C" { if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet) { fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process", F_true); - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } fss_identify_main_delete(main); @@ -125,15 +111,19 @@ extern "C" { if (choice == fss_identify_parameter_verbosity_quiet) { main->error.verbosity = f_console_verbosity_quiet; + main->warning.verbosity = f_console_verbosity_quiet; } else if (choice == fss_identify_parameter_verbosity_normal) { main->error.verbosity = f_console_verbosity_normal; + main->warning.verbosity = f_console_verbosity_normal; } else if (choice == fss_identify_parameter_verbosity_verbose) { main->error.verbosity = f_console_verbosity_verbose; + main->warning.verbosity = f_console_verbosity_verbose; } else if (choice == fss_identify_parameter_verbosity_debug) { main->error.verbosity = f_console_verbosity_debug; + main->warning.verbosity = f_console_verbosity_debug; } } @@ -160,9 +150,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_identify_parameter_line].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_identify_long_line); - f_color_print(main->error.to.stream, main->context.set.error, " requires a positive number.%c", f_string_eol_s[0]); + flockfile(main->error.to.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_identify_long_line, main->error.notable); + fl_print_format("%[' requires a positive number.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); } @@ -180,20 +174,28 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters[fss_identify_parameter_total].result == f_console_result_found) { if (main->parameters[fss_identify_parameter_object].result == f_console_result_found) { - f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_identify_long_object); - f_color_print(main->error.to.stream, main->context.set.error, " parameter with the "); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_identify_long_total); - f_color_print(main->error.to.stream, main->context.set.error, " parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sCannot specify the '%]", 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_identify_long_object, main->error.notable); + fl_print_format("%[' parameter with the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_identify_long_total, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); } else if (main->parameters[fss_identify_parameter_content].result == f_console_result_found) { - f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the ", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_identify_long_content); - f_color_print(main->error.to.stream, main->context.set.error, " parameter with the "); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_identify_long_total); - f_color_print(main->error.to.stream, main->context.set.error, " parameter.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sCannot specify the '%]", 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_identify_long_content, main->error.notable); + fl_print_format("%[' parameter with the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_identify_long_total, main->error.notable); + fl_print_format("%[' parameter.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); } @@ -201,9 +203,13 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_identify_parameter_name].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_identify_long_name); - f_color_print(main->error.to.stream, main->context.set.error, " requires a string.%c", f_string_eol_s[0]); + flockfile(main->error.to.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_identify_long_name, main->error.notable); + fl_print_format("%[' requires a string.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); } @@ -213,9 +219,13 @@ extern "C" { const f_string_range_t range = macro_f_string_range_t_initialize(length); if (length == 0) { - 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_identify_long_name); - f_color_print(main->error.to.stream, main->context.set.error, " does not allow zero length strings.%c", f_string_eol_s[0]); + flockfile(main->error.to.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_identify_long_name, main->error.notable); + fl_print_format("%[' does not allow zero length strings.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); } @@ -239,11 +249,15 @@ extern "C" { break; } else if (status == F_false) { - f_color_print(main->error.to.stream, main->context.set.error, "%sThe value '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s", arguments.argv[index]); - f_color_print(main->error.to.stream, main->context.set.error, "' for the 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_identify_long_name); - f_color_print(main->error.to.stream, main->context.set.error, " may only contain word characters.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe value '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%S%]", main->error.to.stream, main->error.notable, arguments.argv[index], main->error.notable); + fl_print_format("%[' for the parameter '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_identify_long_name, main->error.notable); + fl_print_format("%[' may only contain word characters.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); @@ -307,14 +321,14 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[fss_identify_parameter_total].result == f_console_result_found) { - fprintf(main->output.stream, "%llu%c", data.total, f_string_eol_s[0]); + fll_print_format("%ul%c", main->output.stream, data.total, f_string_eol_s[0]); } } // ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->error.verbosity != f_console_verbosity_quiet) { if (F_status_is_error(status)) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } } diff --git a/level_3/fss_identify/c/fss_identify.h b/level_3/fss_identify/c/fss_identify.h index 7621200..633b1b6 100644 --- a/level_3/fss_identify/c/fss_identify.h +++ b/level_3/fss_identify/c/fss_identify.h @@ -35,11 +35,13 @@ #include #include #include +#include #include // fll-2 includes #include #include +#include #include #ifdef __cplusplus diff --git a/level_3/fss_identify/c/private-fss_identify.c b/level_3/fss_identify/c/private-fss_identify.c index 40bea8d..cc6e19f 100644 --- a/level_3/fss_identify/c/private-fss_identify.c +++ b/level_3/fss_identify/c/private-fss_identify.c @@ -55,25 +55,23 @@ extern "C" { #ifndef _di_fss_identify_print_ void fss_identify_print(const fss_identify_main_t main, f_fll_id_t id) { - if (main.parameters[fss_identify_parameter_object].result == f_console_result_found || main.parameters[fss_identify_parameter_content].result != f_console_result_found) { - f_string_static_t part = f_string_static_t_initialize; - - part.string = id.name; - part.used = id.used; - part.size = part.used; + flockfile(main.output.stream); - f_print_dynamic(main.output.stream, part); + if (main.parameters[fss_identify_parameter_object].result == f_console_result_found || main.parameters[fss_identify_parameter_content].result != f_console_result_found) { + f_print(id.name, id.used, main.output.stream); if (main.parameters[fss_identify_parameter_object].result != f_console_result_found || main.parameters[fss_identify_parameter_content].result == f_console_result_found) { - fprintf(main.output.stream, "%c", f_fss_type_header_part5); + f_print_character(f_fss_type_header_part5, main.output.stream); } } if (main.parameters[fss_identify_parameter_object].result != f_console_result_found || main.parameters[fss_identify_parameter_content].result == f_console_result_found) { - fprintf(main.output.stream, "%04x", id.type); + fl_print_format("%04_ui", main.output.stream, id.type); } - 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); } #endif // _di_fss_identify_print_ diff --git a/level_3/fss_identify/data/build/dependencies b/level_3/fss_identify/data/build/dependencies index 1d1f796..84d8784 100644 --- a/level_3/fss_identify/data/build/dependencies +++ b/level_3/fss_identify/data/build/dependencies @@ -15,6 +15,9 @@ f_print fl_console fl_conversion fl_fss +fl_print +fl_string fll_error fll_fss +fll_print fll_program diff --git a/level_3/fss_identify/data/build/settings b/level_3/fss_identify/data/build/settings index 384fe74..6c5ef33 100644 --- a/level_3/fss_identify/data/build/settings +++ b/level_3/fss_identify/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_fss -lfll_program -lfl_console -lfl_conversion -lfl_fss -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -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_fss -lfll_print -lfll_program -lfl_console -lfl_conversion -lfl_fss -lfl_print -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -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_identify.c private-common.c private-fss_identify.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/fss_status_code/c/fss_status_code.c b/level_3/fss_status_code/c/fss_status_code.c index 91cd9dd..e76bd63 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -120,44 +120,44 @@ 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) { - flockfile(main->output.stream); + flockfile(main->error.to.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("%[' cannot be used with the parameter '%]", main->error.to.stream, main->error.context, 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); + funlockfile(main->error.to.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) { - flockfile(main->output.stream); + flockfile(main->error.to.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("%[' cannot be used with the parameter '%]", main->error.to.stream, main->error.context, 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); + funlockfile(main->error.to.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) { - flockfile(main->output.stream); + flockfile(main->error.to.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("%[' cannot be used with the parameter '%]", main->error.to.stream, main->error.context, 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); + funlockfile(main->error.to.stream); fss_status_code_main_delete(main); return F_status_set_error(status); @@ -178,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 = fss_status_code_process_check(*main, arguments.argv[main->remaining.array[i]]); @@ -186,6 +188,8 @@ extern "C" { status = status2; } } // for + + funlockfile(main->output.stream); } } else if (main->parameters[fss_status_code_parameter_number].result == f_console_result_found) { @@ -194,6 +198,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 = fss_status_code_process_number(*main, arguments.argv[main->remaining.array[i]]); @@ -202,6 +208,8 @@ extern "C" { status = status2; } } // for + + funlockfile(main->output.stream); } } else { @@ -210,6 +218,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 = fss_status_code_process_normal(*main, arguments.argv[main->remaining.array[i]]); @@ -217,6 +227,8 @@ extern "C" { status = status2; } } // for + + funlockfile(main->output.stream); } } 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 803f746..4f94074 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 @@ -62,13 +62,13 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(value, range, &number); if (status == F_none) { - fll_print_format("%[invalid name%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_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) { - fll_print_format("%[invalid main%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[invalid main%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); return status; } @@ -85,10 +85,10 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { - fll_print_format("%[unknown name%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[unknown name%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } else { - fll_print_format("%[failed to convert%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[failed to convert%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } return status; @@ -96,12 +96,12 @@ extern "C" { } if (status == F_data) { - fll_print_format("%[unknown code%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[unknown code%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); return F_none; } - fll_print_format("%ui%c", main.output.stream, code, f_string_eol_s[0]); + fl_print_format("%ui%c", main.output.stream, code, f_string_eol_s[0]); return F_none; } @@ -122,16 +122,16 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { - fll_print_format("%[unknown code%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[unknown code%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } else { - fll_print_format("%[failed to convert%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[failed to convert%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } return status; } - fll_print_format("%S%c", main.output.stream, string, f_string_eol_s[0]); + fl_print_format("%S%c", main.output.stream, string, f_string_eol_s[0]); return F_none; } @@ -145,17 +145,17 @@ extern "C" { f_status_t status = fl_conversion_string_to_number_unsigned(value, range, number); if (*number > F_status_size_max_with_signal) { - fll_print_format("%[out of range%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_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) { - fll_print_format("%[out of range%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[out of range%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } else { - fll_print_format("%[invalid number%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_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/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index 79db81f..9145961 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -9,6 +9,8 @@ extern "C" { #ifndef _di_iki_write_print_help_ f_status_t iki_write_print_help(const f_file_t output, const f_color_context_t context) { + flockfile(output.stream); + fll_program_print_help_header(output, context, iki_write_name_long, iki_write_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, iki_write_short_file, iki_write_long_file, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a file to send output to."); fll_program_print_help_option(output, context, iki_write_short_content, iki_write_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "The content to output."); @@ -31,22 +33,15 @@ extern "C" { fll_program_print_help_usage(output, context, iki_write_name, f_string_empty_s); - f_color_print(output.stream, context.set.important, " Notes:"); - - fprintf(output.stream, "%c", f_string_eol_s[0]); - - fprintf(output.stream, " This program will accept object and content strings to generate an IKI string, such as: "); - f_color_print(output.stream, context.set.notable, "object:\"content\""); - fprintf(output.stream, ".%c", f_string_eol_s[0]); + fl_print_format(" %[Notes:%]%c", output.stream, context.set.important, context.set.important, f_string_eol_s[0]); + fl_print_format(" This program will accept object and content strings to generate an IKI string, such as %[object:\"content\"%].%c", output.stream, context.set.notable, context.set.notable, f_string_eol_s[0]); - fprintf(output.stream, " Each object must have a content (and each content must have an object).%c", f_string_eol_s[0]); + fl_print_format(" Each object must have a content (and each content must have an object).%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); - fprintf(output.stream, "%c", f_string_eol_s[0]); + fl_print_format(" When piping main to this program, a single end of line (\\n) must be used to separate each object from each content.%c", output.stream, f_string_eol_s[0]); + fl_print_format(" Furthermore, each object must be followed by a content.%c%c", output.stream, f_string_eol_s[0], f_string_eol_s[0]); - fprintf(output.stream, " When piping main to this program, a single end of line (\\n) must be used to separate each object from each content.%c", f_string_eol_s[0]); - fprintf(output.stream, " Furthermore, each object must be followed by a content.%c", f_string_eol_s[0]); - - fprintf(output.stream, "%c", f_string_eol_s[0]); + funlockfile(output.stream); return F_none; } @@ -69,9 +64,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); } @@ -79,7 +77,7 @@ extern "C" { if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet) { fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process", F_true); - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); + f_print_character(f_string_eol_s[0], main->error.to.stream); } iki_write_main_delete(main); @@ -103,15 +101,19 @@ extern "C" { if (choice == iki_write_parameter_verbosity_quiet) { main->error.verbosity = f_console_verbosity_quiet; + main->warning.verbosity = f_console_verbosity_quiet; } else if (choice == iki_write_parameter_verbosity_normal) { main->error.verbosity = f_console_verbosity_normal; + main->warning.verbosity = f_console_verbosity_normal; } else if (choice == iki_write_parameter_verbosity_verbose) { main->error.verbosity = f_console_verbosity_verbose; + main->warning.verbosity = f_console_verbosity_verbose; } else if (choice == iki_write_parameter_verbosity_debug) { main->error.verbosity = f_console_verbosity_debug; + main->warning.verbosity = f_console_verbosity_debug; } } @@ -142,9 +144,13 @@ extern "C" { if (main->parameters[iki_write_parameter_file].result == f_console_result_additional) { if (main->parameters[iki_write_parameter_file].values.used > 1) { if (main->error.verbosity != f_console_verbosity_quiet) { - 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, iki_write_long_file); - f_color_print(main->error.to.stream, main->context.set.error, "' may only be specified once.%c", f_string_eol_s[0]); + flockfile(main->error.to.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, iki_write_long_file, main->error.notable); + fl_print_format("%[' may only be specified once.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -164,9 +170,13 @@ extern "C" { } else if (main->parameters[iki_write_parameter_file].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - 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, iki_write_long_file); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main->error.to.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, iki_write_long_file, main->error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -175,9 +185,13 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters[iki_write_parameter_object].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - 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, iki_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main->error.to.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, iki_write_long_object, main->error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -185,9 +199,13 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters[iki_write_parameter_content].result == f_console_result_found) { if (main->error.verbosity != f_console_verbosity_quiet) { - 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, iki_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' was specified, but no value was given.%c", f_string_eol_s[0]); + flockfile(main->error.to.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, iki_write_long_content, main->error.notable); + fl_print_format("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -196,12 +214,15 @@ extern "C" { if (F_status_is_error_not(status) && !main->process_pipe) { if (main->parameters[iki_write_parameter_object].result != f_console_result_additional && main->parameters[iki_write_parameter_content].result != f_console_result_additional) { if (main->error.verbosity != f_console_verbosity_quiet) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main->error.to.stream, main->context.set.error, "%sNo main provided, either pipe the main or use the '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, iki_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' and the '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, iki_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' parameters.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sNo main provided, either pipe the main or use the '%]", 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, iki_write_long_object, main->error.notable); + fl_print_format("%[' and the '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_write_long_content, main->error.notable); + fl_print_format("%[' parameters.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -211,11 +232,15 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->parameters[iki_write_parameter_object].values.used != main->parameters[iki_write_parameter_content].values.used) { if (main->error.verbosity != f_console_verbosity_quiet) { - f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameters '", fll_error_print_error); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, iki_write_long_content); - f_color_print(main->error.to.stream, main->context.set.error, "' and '"); - f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, iki_write_long_object); - f_color_print(main->error.to.stream, main->context.set.error, "' must be specified the same number of times.%c", f_string_eol_s[0]); + flockfile(main->error.to.stream); + + fl_print_format("%c%[%sThe parameters '%]", 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, iki_write_long_content, main->error.notable); + fl_print_format("%[' and '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%s%s%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_write_long_object, main->error.notable); + fl_print_format("%[' must be specified the same number of times.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); } status = F_status_set_error(F_parameter); @@ -271,7 +296,7 @@ extern "C" { if (!buffer.used) { if (main->error.verbosity != f_console_verbosity_quiet) { - f_color_print(main->error.to.stream, main->context.set.error, "%sThe pipe has no main.%c", fll_error_print_error, f_string_eol_s[0]); + fll_print_format("%c%[%sThe pipe has no main.%]%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); @@ -298,7 +323,7 @@ extern "C" { if (object_ended && previous == range.start) { if (main->error.verbosity != f_console_verbosity_quiet) { - f_color_print(main->error.to.stream, main->context.set.error, "%sThe pipe has incorrectly placed newlines.%c", fll_error_print_error, f_string_eol_s[0]); + fll_print_format("%c%[%sThe pipe has incorrectly placed newlines.%]%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); @@ -323,7 +348,7 @@ extern "C" { status = iki_write_process(*main, output, object, content, quote, &escaped); if (F_status_is_error(status)) break; - fprintf(output.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], output.stream); object_ended = F_false; } @@ -355,7 +380,7 @@ extern "C" { if (F_status_is_error_not(status) && object_ended) { if (main->error.verbosity != f_console_verbosity_quiet) { - f_color_print(main->error.to.stream, main->context.set.error, "%sThe pipe has an object without content.%c", fll_error_print_error, f_string_eol_s[0]); + fll_print_format("%c%[%sThe pipe has an object without content.%]%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); @@ -383,12 +408,12 @@ extern "C" { status = iki_write_process(*main, output, object, content, quote, &escaped); if (F_status_is_error(status)) break; - fprintf(output.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], output.stream); } // for // ensure there is always a newline at the end, unless in quiet mode. if (F_status_is_error_not(status) && main->error.verbosity != f_console_verbosity_quiet && main->parameters[iki_write_parameter_file].result == f_console_result_none) { - fprintf(main->output.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], output.stream); } } @@ -404,7 +429,7 @@ extern "C" { // ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->error.verbosity != f_console_verbosity_quiet) { if (F_status_is_error(status)) { - fprintf(main->error.to.stream, "%c", f_string_eol_s[0]); + fll_print_character(f_string_eol_s[0], main->error.to.stream); } } diff --git a/level_3/iki_write/c/iki_write.h b/level_3/iki_write/c/iki_write.h index 86d6aba..cbfd0f3 100644 --- a/level_3/iki_write/c/iki_write.h +++ b/level_3/iki_write/c/iki_write.h @@ -46,6 +46,7 @@ #include #include #include +#include #include #ifdef __cplusplus @@ -134,6 +135,7 @@ extern "C" { f_file_t output; fll_error_print_t error; + fll_error_print_t warning; f_string_dynamic_t buffer; @@ -147,6 +149,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_string_dynamic_t_initialize, \ f_color_context_t_initialize, \ } diff --git a/level_3/iki_write/c/private-iki_write.c b/level_3/iki_write/c/private-iki_write.c index a0142c6..65f6137 100644 --- a/level_3/iki_write/c/private-iki_write.c +++ b/level_3/iki_write/c/private-iki_write.c @@ -11,10 +11,13 @@ extern "C" { if (!object.used) { if (main.error.verbosity != f_console_verbosity_quiet) { - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThe object is missing, it must not have a length of ", fll_error_print_error); - f_color_print(main.error.to.stream, main.context.set.notable, "0"); - f_color_print(main.error.to.stream, main.context.set.error, ".%c", f_string_eol_s[0]); + flockfile(main.error.to.stream); + + fl_print_format("%c%[%sThe object is missing, it must not have a length of %]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[0%]", main.error.to.stream, main.error.notable, main.error.notable); + fl_print_format("%[.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); + + funlockfile(main.error.to.stream); } return F_status_set_error(F_failure); @@ -24,14 +27,13 @@ extern "C" { if (status == F_false) { if (main.error.verbosity != f_console_verbosity_quiet) { - fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "%sThe object '", fll_error_print_error); + flockfile(main.error.to.stream); - f_color_print_code(main.error.to.stream, main.context.notable); - f_print_dynamic(main.error.to.stream, object); - f_color_print_code(main.error.to.stream, main.context.reset); + fl_print_format("%c%[%sThe object '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); + fl_print_format("%[%Q%]", main.error.to.stream, main.error.notable, object, main.error.notable); + fl_print_format("%[' is not a valid IKI object.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]); - f_color_print(main.error.to.stream, main.context.set.error, "' is not a valid IKI object.%c", f_string_eol_s[0]); + funlockfile(main.error.to.stream); } return F_status_set_error(F_failure); @@ -52,7 +54,7 @@ extern "C" { return F_status_set_error(F_failure); } - fprintf(output.stream, "%s%c%c%s%c", object.string, f_iki_syntax_separator, quote, escaped->string, quote); + fl_print_format("%Q%c%c%Q%c", output.stream, object, f_iki_syntax_separator, quote, *escaped, quote); return F_none; } diff --git a/level_3/iki_write/data/build/dependencies b/level_3/iki_write/data/build/dependencies index 30e8b86..472223c 100644 --- a/level_3/iki_write/data/build/dependencies +++ b/level_3/iki_write/data/build/dependencies @@ -13,6 +13,9 @@ f_pipe f_print fl_console fl_iki +fl_print +fl_string fll_iki fll_error +fll_print fll_program diff --git a/level_3/iki_write/data/build/settings b/level_3/iki_write/data/build/settings index 87bb911..23ca09d 100644 --- a/level_3/iki_write/data/build/settings +++ b/level_3/iki_write/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_iki -lfll_program -lfl_console -lfl_iki -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_iki -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_iki -lfll_print -lfll_program -lfl_console -lfl_iki -lfl_print -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_iki -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 iki_write.c private-common.c private-iki_write.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 49eb2d2..3bf8850 100644 --- a/level_3/status_code/c/private-status_code.c +++ b/level_3/status_code/c/private-status_code.c @@ -64,13 +64,13 @@ extern "C" { status = fl_conversion_string_to_number_unsigned(value, range, &number); if (status == F_none) { - fll_print_format("%[invalid name%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_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) { - fll_print_format("%[invalid main%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[invalid main%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); return status; } @@ -82,22 +82,22 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { - fll_print_format("%[unknown name%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[unknown name%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } else { - fll_print_format("%[failed to convert%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_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) { - fll_print_format("%[unknown code%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[unknown code%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); return F_none; } - fll_print_format("%ui%c", main.output.stream, code, f_string_eol_s[0]); + fl_print_format("%ui%c", main.output.stream, code, f_string_eol_s[0]); return F_none; } @@ -120,16 +120,16 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { - fll_print_format("%[unknown code%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[unknown code%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } else { - fll_print_format("%[failed to convert%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[failed to convert%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } return status; } - fll_print_format("%S%c", main.output.stream, string, f_string_eol_s[0]); + fl_print_format("%S%c", main.output.stream, string, f_string_eol_s[0]); return F_none; } @@ -143,17 +143,17 @@ extern "C" { f_status_t status = fl_conversion_string_to_number_unsigned(value, range, number); if (*number > F_status_size_max_with_signal) { - fll_print_format("%[out of range%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_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) { - fll_print_format("%[out of range%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_print_format("%[out of range%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); } else { - fll_print_format("%[invalid number%]%c", main.output.stream, main.context.set.error, main.context.set.error, f_string_eol_s[0]); + fl_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 4275031..97652ae 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -120,44 +120,44 @@ 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) { - flockfile(main->output.stream); + flockfile(main->error.to.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("%[' cannot be used with the parameter '%]", main->error.to.stream, main->error.context, 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); + funlockfile(main->error.to.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) { - flockfile(main->output.stream); + flockfile(main->error.to.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("%[' cannot be used with the parameter '%]", main->error.to.stream, main->error.context, 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); + funlockfile(main->error.to.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) { - flockfile(main->output.stream); + flockfile(main->error.to.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("%[' cannot be used with the parameter '%]", main->error.to.stream, main->error.context, 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); + funlockfile(main->error.to.stream); status_code_main_delete(main); return F_status_set_error(status); @@ -198,6 +198,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_number(*main, arguments.argv[main->remaining.array[i]]); @@ -206,6 +208,8 @@ extern "C" { status = status2; } } // for + + funlockfile(main->output.stream); } } else { @@ -214,6 +218,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_normal(*main, arguments.argv[main->remaining.array[i]]); @@ -222,6 +228,8 @@ extern "C" { status = status2; } } // for + + funlockfile(main->output.stream); } }