From: Kevin Day Date: Fri, 2 Dec 2022 04:29:36 +0000 (-0600) Subject: Progress: Continue program related work, updating fss_write. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=50eeb19219f09f3ff53a99f196b8183b4d0a50cb;p=fll Progress: Continue program related work, updating fss_write. Fix minor spacing problem where the color context should be closed near non-whitespace whenever possible. Add missing word "error" in some comments. Continue working in fss_write. This gets the fss_payload_write program compiling. The installer by default doesn't handle all of the programs. Where before './install.sh -w /tmp/fll/' used to work now the following are all needed: - ./install.sh -w /tmp/fll/ - ./install.sh -w /tmp/fll/ -s data/build/settings.main - ./install.sh -w /tmp/fll/ -s data/build/settings.payload --- diff --git a/level_2/fll_program/c/program/print.c b/level_2/fll_program/c/program/print.c index c93bd69..e0d74a2 100644 --- a/level_2/fll_program/c/program/print.c +++ b/level_2/fll_program/c/program/print.c @@ -27,9 +27,9 @@ extern "C" { f_file_stream_lock(print.to); - fl_print_format("%[%QThe %]", print.to, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%QThe%] ", print.to, print.set->error, print.prefix, print.set->error); fl_print_format("%[%Q%]", print.to, print.set->notable, variable, print.set->notable); - fl_print_format("%[ is missing or has a length of %]", print.to, print.set->error, print.set->error); + fl_print_format("%[ is missing or has a length of%] ", print.to, print.set->error, print.set->error); fl_print_format("%[0%]", print.to, print.set->notable, print.set->notable); fl_print_format("%[.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); @@ -200,7 +200,7 @@ extern "C" { f_file_stream_lock(print.to); - fl_print_format("%[%QThe parameter %]", print.to, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%QThe parameter%] ", print.to, print.set->error, print.prefix, print.set->error); fl_print_format("%[%Q%Q%]", print.to, print.set->notable, symbol, parameter, print.set->notable); fl_print_format(" %[is specified, but no value is given.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); @@ -217,9 +217,9 @@ extern "C" { f_file_stream_lock(print.to); - fl_print_format("%[%QThe parameter %]", print.to, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%QThe parameter%] ", print.to, print.set->error, print.prefix, print.set->error); fl_print_format("%[%Q%Q%]", print.to, print.set->notable, symbol, parameter, print.set->notable); - fl_print_format("%[ is specified, but %]", print.to, print.set->error, print.set->error); + fl_print_format("%[ is specified, but%] ", print.to, print.set->error, print.set->error); fl_print_format("%[%Q%]", print.to, print.set->notable, amount, print.set->notable); fl_print_format(" %[values are not given.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); diff --git a/level_3/fss_basic_list_write/c/private-write.h b/level_3/fss_basic_list_write/c/private-write.h index 7080fc3..16ba393 100644 --- a/level_3/fss_basic_list_write/c/private-write.h +++ b/level_3/fss_basic_list_write/c/private-write.h @@ -23,7 +23,7 @@ extern "C" { #endif // _di_fss_basic_list_write_error_parameter_same_times_print_ /** - * Print an message about a parameter a New Line character '\n' (U+000A) being unsupported. + * Print an error message about a parameter a New Line character '\n' (U+000A) being unsupported. * * @param main * The main program data. @@ -33,7 +33,7 @@ extern "C" { #endif // _di_fss_basic_list_write_error_parameter_unsupported_eol_print_ /** - * Print an message about a parameter missing a value. + * Print an error message about a parameter missing a value. * * @param main * The main program data. diff --git a/level_3/fss_basic_write/c/private-write.h b/level_3/fss_basic_write/c/private-write.h index 5997cea..e596537 100644 --- a/level_3/fss_basic_write/c/private-write.h +++ b/level_3/fss_basic_write/c/private-write.h @@ -23,7 +23,7 @@ extern "C" { #endif // _di_fss_basic_write_error_parameter_same_times_print_ /** - * Print an message about a parameter missing a value. + * Print an error message about a parameter missing a value. * * @param main * The main program data. @@ -37,7 +37,7 @@ extern "C" { #endif // _di_fss_basic_write_error_parameter_value_missing_print_ /** - * Print an message about a parameter a New Line character '\n' (U+000A) being unsupported. + * Print an error message about a parameter a New Line character '\n' (U+000A) being unsupported. * * @param main * The main program data. diff --git a/level_3/fss_embedded_list_write/c/private-write.h b/level_3/fss_embedded_list_write/c/private-write.h index 4900687..a54549b 100644 --- a/level_3/fss_embedded_list_write/c/private-write.h +++ b/level_3/fss_embedded_list_write/c/private-write.h @@ -23,7 +23,7 @@ extern "C" { #endif // _di_fss_embedded_list_write_error_parameter_same_times_print_ /** - * Print an message about a parameter a New Line character '\n' (U+000A) being unsupported. + * Print an error message about a parameter a New Line character '\n' (U+000A) being unsupported. * * @param main * The main program data. @@ -33,7 +33,7 @@ extern "C" { #endif // _di_fss_embedded_list_write_error_parameter_unsupported_eol_print_ /** - * Print an message about a parameter missing a value. + * Print an error message about a parameter missing a value. * * @param main * The main program data. diff --git a/level_3/fss_extended_list_write/c/private-write.h b/level_3/fss_extended_list_write/c/private-write.h index 6d345ba..39cdf64 100644 --- a/level_3/fss_extended_list_write/c/private-write.h +++ b/level_3/fss_extended_list_write/c/private-write.h @@ -23,7 +23,7 @@ extern "C" { #endif // _di_fss_extended_list_write_error_parameter_same_times_print_ /** - * Print an message about a parameter New Line character '\n' (U+000A) being unsupported. + * Print an error message about a parameter New Line character '\n' (U+000A) being unsupported. * * @param main * The main program data. @@ -33,7 +33,7 @@ extern "C" { #endif // _di_fss_extended_list_write_error_parameter_unsupported_eol_print_ /** - * Print an message about a parameter missing a value. + * Print an error message about a parameter missing a value. * * @param main * The main program data. diff --git a/level_3/fss_extended_write/c/private-write.h b/level_3/fss_extended_write/c/private-write.h index 85dc1fb..883328e 100644 --- a/level_3/fss_extended_write/c/private-write.h +++ b/level_3/fss_extended_write/c/private-write.h @@ -27,7 +27,7 @@ extern "C" { #endif // _di_fss_extended_write_error_parameter_at_least_once_print_ /** - * Print an message about a parameter missing a value. + * Print an error message about a parameter missing a value. * * @param main * The main program data. @@ -45,7 +45,7 @@ extern "C" { #endif // _di_fss_extended_write_error_parameter_value_missing_print_ /** - * Print an message about a parameter a New Line character '\n' (U+000A) being unsupported. + * Print an error message about a parameter a New Line character '\n' (U+000A) being unsupported. * * @param main * The main program data. diff --git a/level_3/fss_payload_write/c/print.h b/level_3/fss_payload_write/c/print.h index 3cc0ccf..50fc3fa 100644 --- a/level_3/fss_payload_write/c/print.h +++ b/level_3/fss_payload_write/c/print.h @@ -116,7 +116,7 @@ extern "C" { #endif // _fss_payload_write_print_error_prepend_only_whitespace_ /** - * Print an message about a parameter New Line character '\n' (U+000A) being unsupported. + * Print an error message about a parameter New Line character '\n' (U+000A) being unsupported. * * @param setting * The main program settings. diff --git a/level_3/fss_write/c/basic/fss_write.h b/level_3/fss_write/c/basic/fss_write.h index b5a7bba..701999f 100644 --- a/level_3/fss_write/c/basic/fss_write.h +++ b/level_3/fss_write/c/basic/fss_write.h @@ -44,10 +44,10 @@ #include // FSS Write includes. -#include #include -#include +#include #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_write/c/basic_list/fss_write.h b/level_3/fss_write/c/basic_list/fss_write.h index a40a7e4..d7391c3 100644 --- a/level_3/fss_write/c/basic_list/fss_write.h +++ b/level_3/fss_write/c/basic_list/fss_write.h @@ -44,10 +44,10 @@ #include // FSS Write includes. -#include #include -#include +#include #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_write/c/embedded_list/fss_write.h b/level_3/fss_write/c/embedded_list/fss_write.h index 60e2342..9483c6e 100644 --- a/level_3/fss_write/c/embedded_list/fss_write.h +++ b/level_3/fss_write/c/embedded_list/fss_write.h @@ -43,10 +43,10 @@ #include // FSS Write includes. -#include #include -#include +#include #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_write/c/extended/fss_write.h b/level_3/fss_write/c/extended/fss_write.h index 608a8ac..0b7e9f4 100644 --- a/level_3/fss_write/c/extended/fss_write.h +++ b/level_3/fss_write/c/extended/fss_write.h @@ -44,10 +44,10 @@ #include // FSS Write includes. -#include #include -#include +#include #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_write/c/extended_list/fss_write.h b/level_3/fss_write/c/extended_list/fss_write.h index f047b5f..5f9d094 100644 --- a/level_3/fss_write/c/extended_list/fss_write.h +++ b/level_3/fss_write/c/extended_list/fss_write.h @@ -44,10 +44,10 @@ #include // FSS Write includes. -#include #include -#include +#include #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_write/c/main/common.c b/level_3/fss_write/c/main/common.c index 69d7ccd..db0515f 100644 --- a/level_3/fss_write/c/main/common.c +++ b/level_3/fss_write/c/main/common.c @@ -198,7 +198,7 @@ extern "C" { return; } - if (main->parameters.array[fss_write_parameter_object_e].result & f_console_result_value_e && main->parameters.array[fss_write_parameter_object_e].values.used) { + if ((main->parameters.array[fss_write_parameter_object_e].result & f_console_result_value_e) && main->parameters.array[fss_write_parameter_object_e].values.used) { f_array_lengths_t * const values = &main->parameters.array[fss_write_parameter_object_e].values; setting->objects.used = 0; diff --git a/level_3/fss_write/c/main/common.h b/level_3/fss_write/c/main/common.h index fc3f3ee..a65ea8e 100644 --- a/level_3/fss_write/c/main/common.h +++ b/level_3/fss_write/c/main/common.h @@ -382,6 +382,8 @@ extern "C" { * F_none on success. * F_data_not on success but nothing was provided to operate with. * + * F_parameter (with error bit) on parameter error. + * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: f_file_stream_open(). * Errors (with error bit) from: f_string_dynamics_resize(). diff --git a/level_3/fss_write/c/main/cp b/level_3/fss_write/c/main/cp new file mode 100644 index 0000000..e69de29 diff --git a/level_3/fss_write/c/main/main-print.c b/level_3/fss_write/c/main/main-print.c new file mode 100644 index 0000000..5150f8d --- /dev/null +++ b/level_3/fss_write/c/main/main-print.c @@ -0,0 +1,109 @@ +#include "fss_write.h" +#include "main-print.h" +#include "../basic/fss_write.h" +#include "../basic_list/fss_write.h" +#include "../extended/fss_write.h" +#include "../extended_list/fss_write.h" +#include "../embedded_list/fss_write.h" +#include "../payload/fss_write.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_write_main_print_error_format_unknown_ + f_status_t fss_write_main_print_error_format_unknown(const fl_print_t print, const f_string_static_t value) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QThe format '%]", print.to, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%Q%]", print.to, print.set->notable, value, print.set->notable); + fl_print_format("%[' is not known for the parameter%] ", print.to, print.set->error, print.set->error); + fl_print_format("%[%Q%Q%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_as_s, print.set->notable); + fl_print_format("%[.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fss_write_main_print_error_format_unknown_ + +#ifndef _di_fss_write_main_print_help_ + f_status_t fss_write_main_print_help(fss_write_setting_t * const setting, const fl_print_t print) { + + f_file_stream_lock(print.to); + + f_print_dynamic_raw(setting->line_first, print.to); + + fll_program_print_help_header(print, fss_write_program_name_long_s, fss_write_program_version_s); + + fss_write_print_help(setting, print); + + fll_program_print_help_option(print, fss_write_short_as_s, fss_write_long_as_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Designate the supported format to write as."); + + f_print_dynamic_raw(f_string_eol_s, print.to); + f_print_dynamic_raw(f_string_eol_s, print.to); + + fll_program_print_help_usage(print, fss_write_program_name_s, f_string_empty_s); + + fss_write_print_help_pipe(setting, print); + + f_print_dynamic_raw(f_string_eol_s, print.to); + + fl_print_format(" The '%[%r%r%]' parameter supports the following standards with the specified possible case-sensitive values:%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_as_s, print.set->notable, f_string_eol_s); + + // FSS-0000 (Basic) + fl_print_format(" - As %[%r%] format: ", print.to, print.set->notable, fss_write_basic_standard_s, print.set->notable); + fl_print_format("'%[%r%]', ", print.to, print.set->notable, fss_write_format_code_short_0000_s, print.set->notable); + fl_print_format("'%[%r%]', or ", print.to, print.set->notable, fss_write_format_code_long_0000_s, print.set->notable); + fl_print_format("'%[%r%]'.%r", print.to, print.set->notable, fss_write_format_code_human_0000_s, print.set->notable, f_string_eol_s); + + // FSS-0001 (Extended) + fl_print_format(" - As %[%r%] format: ", print.to, print.set->notable, fss_write_extended_standard_s, print.set->notable); + fl_print_format("'%[%r%]', ", print.to, print.set->notable, fss_write_format_code_short_0001_s, print.set->notable); + fl_print_format("'%[%r%]', or ", print.to, print.set->notable, fss_write_format_code_long_0001_s, print.set->notable); + fl_print_format("'%[%r%]'.%r", print.to, print.set->notable, fss_write_format_code_human_0001_s, print.set->notable, f_string_eol_s); + + // FSS-0002 (Basic List) + fl_print_format(" - As %[%r%] format: ", print.to, print.set->notable, fss_write_basic_list_standard_s, print.set->notable); + fl_print_format("'%[%r%]', ", print.to, print.set->notable, fss_write_format_code_short_0002_s, print.set->notable); + fl_print_format("'%[%r%]', or ", print.to, print.set->notable, fss_write_format_code_long_0002_s, print.set->notable); + fl_print_format("'%[%r%]'.%r", print.to, print.set->notable, fss_write_format_code_human_0002_s, print.set->notable, f_string_eol_s); + + // FSS-0003 (Extended List) + fl_print_format(" - As %[%r%] format: ", print.to, print.set->notable, fss_write_extended_list_standard_s, print.set->notable); + fl_print_format("'%[%r%]', ", print.to, print.set->notable, fss_write_format_code_short_0003_s, print.set->notable); + fl_print_format("'%[%r%]', or ", print.to, print.set->notable, fss_write_format_code_long_0003_s, print.set->notable); + fl_print_format("'%[%r%]'.%r", print.to, print.set->notable, fss_write_format_code_human_0003_s, print.set->notable, f_string_eol_s); + + // FSS-0008 (Embedded List) + fl_print_format(" - As %[%r%] format: ", print.to, print.set->notable, fss_write_embedded_list_standard_s, print.set->notable); + fl_print_format("'%[%r%]', ", print.to, print.set->notable, fss_write_format_code_short_0008_s, print.set->notable); + fl_print_format("'%[%r%]', or ", print.to, print.set->notable, fss_write_format_code_long_0008_s, print.set->notable); + fl_print_format("'%[%r%]'.%r", print.to, print.set->notable, fss_write_format_code_human_0008_s, print.set->notable, f_string_eol_s); + + // FSS-000E (Payload) + fl_print_format(" - As %[%r%] format: ", print.to, print.set->notable, fss_write_payload_standard_s, print.set->notable); + fl_print_format("'%[%r%]', ", print.to, print.set->notable, fss_write_format_code_short_000e_s, print.set->notable); + fl_print_format("'%[%r%]', or ", print.to, print.set->notable, fss_write_format_code_long_000e_s, print.set->notable); + fl_print_format("'%[%r%]'.%r", print.to, print.set->notable, fss_write_format_code_human_000e_s, print.set->notable, f_string_eol_s); + + f_print_dynamic_raw(f_string_eol_s, print.to); + + fl_print_format(" The %[%r%] format is the default when no ", print.to, print.set->notable, fss_write_basic_standard_s, print.set->notable); + fl_print_format("'%[%r%r%]' is specified.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_as_s, print.set->notable, f_string_eol_s); + + f_print_dynamic_raw(setting->line_last, print.to); + + f_file_stream_flush(print.to); + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fss_write_main_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_write/c/main/main-print.h b/level_3/fss_write/c/main/main-print.h new file mode 100644 index 0000000..e052608 --- /dev/null +++ b/level_3/fss_write/c/main/main-print.h @@ -0,0 +1,57 @@ +/** + * FLL - Level 3 + * + * Project: FSS Write + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + */ +#ifndef _fss_write_main_print_h +#define _fss_write_main_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print an error message about a value given to the --as parameter being unknown. + * + * @param setting + * The main program settings. + * + * This does not alter setting.status. + * @param print + * Designates the how and where to print. + * @param value + * A string representing the value that is of an unknown format. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fss_write_main_print_error_format_unknown_ + extern f_status_t fss_write_main_print_error_format_unknown(const fl_print_t print, const f_string_static_t value); +#endif // _di_fss_write_main_print_error_format_unknown_ + +/** + * Print help for "main" fss_write. + * + * @param setting + * The main program settings. + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fss_write_print_main_help_ + extern f_status_t fss_write_main_print_help(fss_write_setting_t * const setting, const fl_print_t print); +#endif // _di_fss_write_print_main_help_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_write_main_print_h diff --git a/level_3/fss_write/c/main/main.c b/level_3/fss_write/c/main/main.c index 3b2f07d..b695606 100644 --- a/level_3/fss_write/c/main/main.c +++ b/level_3/fss_write/c/main/main.c @@ -1,5 +1,6 @@ #include "fss_write.h" #include "main.h" +#include "main-print.h" #include "../basic/fss_write.h" #include "../basic_list/fss_write.h" #include "../extended/fss_write.h" @@ -44,76 +45,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { } #ifndef _di_fss_write_main_process_help_ - void fss_write_main_process_help(fll_program_data_t * const main, void * const void_setting) { + void fss_write_main_process_help(fll_program_data_t * const main, void * const setting) { - fss_write_setting_t * const setting = (fss_write_setting_t *) void_setting; - - f_file_stream_lock(main->message.to); - - f_print_dynamic_raw(setting->line_first, main->message.to); - - fll_program_print_help_header(main->message, fss_write_program_name_long_s, fss_write_program_version_s); - - fss_write_print_help(setting, main->message); - - fll_program_print_help_option(main->message, fss_write_short_as_s, fss_write_long_as_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Designate the supported format to write as."); - - f_print_dynamic_raw(f_string_eol_s, main->message.to); - f_print_dynamic_raw(f_string_eol_s, main->message.to); - - fll_program_print_help_usage(main->message, fss_write_program_name_s, f_string_empty_s); - - fss_write_print_help_pipe(setting, main->message); - - f_print_dynamic_raw(f_string_eol_s, main->message.to); - - fl_print_format(" The '%[%r%r%]' parameter supports the following standards with the specified possible case-sensitive values:%r", main->message.to, main->message.set->notable, f_console_symbol_long_normal_s, fss_write_long_as_s, main->message.set->notable, f_string_eol_s); - - // FSS-0000 (Basic) - fl_print_format(" - As %[%r%] format: ", main->message.to, main->message.set->notable, fss_write_basic_standard_s, main->message.set->notable); - fl_print_format("'%[%r%]', ", main->message.to, main->message.set->notable, fss_write_format_code_short_0000_s, main->message.set->notable); - fl_print_format("'%[%r%]', or ", main->message.to, main->message.set->notable, fss_write_format_code_long_0000_s, main->message.set->notable); - fl_print_format("'%[%r%]'.%r", main->message.to, main->message.set->notable, fss_write_format_code_human_0000_s, main->message.set->notable, f_string_eol_s); - - // FSS-0001 (Extended) - fl_print_format(" - As %[%r%] format: ", main->message.to, main->message.set->notable, fss_write_extended_standard_s, main->message.set->notable); - fl_print_format("'%[%r%]', ", main->message.to, main->message.set->notable, fss_write_format_code_short_0001_s, main->message.set->notable); - fl_print_format("'%[%r%]', or ", main->message.to, main->message.set->notable, fss_write_format_code_long_0001_s, main->message.set->notable); - fl_print_format("'%[%r%]'.%r", main->message.to, main->message.set->notable, fss_write_format_code_human_0001_s, main->message.set->notable, f_string_eol_s); - - // FSS-0002 (Basic List) - fl_print_format(" - As %[%r%] format: ", main->message.to, main->message.set->notable, fss_write_basic_list_standard_s, main->message.set->notable); - fl_print_format("'%[%r%]', ", main->message.to, main->message.set->notable, fss_write_format_code_short_0002_s, main->message.set->notable); - fl_print_format("'%[%r%]', or ", main->message.to, main->message.set->notable, fss_write_format_code_long_0002_s, main->message.set->notable); - fl_print_format("'%[%r%]'.%r", main->message.to, main->message.set->notable, fss_write_format_code_human_0002_s, main->message.set->notable, f_string_eol_s); - - // FSS-0003 (Extended List) - fl_print_format(" - As %[%r%] format: ", main->message.to, main->message.set->notable, fss_write_extended_list_standard_s, main->message.set->notable); - fl_print_format("'%[%r%]', ", main->message.to, main->message.set->notable, fss_write_format_code_short_0003_s, main->message.set->notable); - fl_print_format("'%[%r%]', or ", main->message.to, main->message.set->notable, fss_write_format_code_long_0003_s, main->message.set->notable); - fl_print_format("'%[%r%]'.%r", main->message.to, main->message.set->notable, fss_write_format_code_human_0003_s, main->message.set->notable, f_string_eol_s); - - // FSS-0008 (Embedded List) - fl_print_format(" - As %[%r%] format: ", main->message.to, main->message.set->notable, fss_write_embedded_list_standard_s, main->message.set->notable); - fl_print_format("'%[%r%]', ", main->message.to, main->message.set->notable, fss_write_format_code_short_0008_s, main->message.set->notable); - fl_print_format("'%[%r%]', or ", main->message.to, main->message.set->notable, fss_write_format_code_long_0008_s, main->message.set->notable); - fl_print_format("'%[%r%]'.%r", main->message.to, main->message.set->notable, fss_write_format_code_human_0008_s, main->message.set->notable, f_string_eol_s); - - // FSS-000E (Payload) - fl_print_format(" - As %[%r%] format: ", main->message.to, main->message.set->notable, fss_write_payload_standard_s, main->message.set->notable); - fl_print_format("'%[%r%]', ", main->message.to, main->message.set->notable, fss_write_format_code_short_000e_s, main->message.set->notable); - fl_print_format("'%[%r%]', or ", main->message.to, main->message.set->notable, fss_write_format_code_long_000e_s, main->message.set->notable); - fl_print_format("'%[%r%]'.%r", main->message.to, main->message.set->notable, fss_write_format_code_human_000e_s, main->message.set->notable, f_string_eol_s); - - f_print_dynamic_raw(f_string_eol_s, main->message.to); - - fl_print_format(" The %[%r%] format is the default when no ", main->message.to, main->message.set->notable, fss_write_basic_standard_s, main->message.set->notable); - fl_print_format("'%[%r%r%]' is specified.%r", main->message.to, main->message.set->notable, f_console_symbol_long_normal_s, fss_write_long_as_s, main->message.set->notable, f_string_eol_s); - - f_print_dynamic_raw(setting->line_last, main->message.to); - - f_file_stream_flush(main->message.to); - f_file_stream_unlock(main->message.to); + fss_write_main_print_help((fss_write_setting_t *) setting, main->message); } #endif // _di_fss_write_main_process_help_ @@ -148,8 +82,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { setting->process_normal = &fss_write_basic_process_normal; } else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0001_s) == F_equal_to || - fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0001_s) == F_equal_to || - fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0001_s) == F_equal_to) { + fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0001_s) == F_equal_to || + fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0001_s) == F_equal_to) { setting->program_name = &fss_write_extended_program_name_s; setting->program_name_long = &fss_write_extended_program_name_long_s; @@ -158,8 +92,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { setting->process_normal = &fss_write_extended_process_normal; } else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0002_s) == F_equal_to || - fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0002_s) == F_equal_to || - fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0002_s) == F_equal_to) { + fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0002_s) == F_equal_to || + fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0002_s) == F_equal_to) { setting->program_name = &fss_write_basic_list_program_name_s; setting->program_name_long = &fss_write_basic_list_program_name_long_s; @@ -168,8 +102,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { setting->process_normal = &fss_write_basic_list_process_normal; } else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0003_s) == F_equal_to || - fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0003_s) == F_equal_to || - fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0003_s) == F_equal_to) { + fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0003_s) == F_equal_to || + fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0003_s) == F_equal_to) { setting->program_name = &fss_write_extended_list_program_name_s; setting->program_name_long = &fss_write_extended_list_program_name_long_s; @@ -178,8 +112,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { setting->process_normal = &fss_write_extended_list_process_normal; } else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0008_s) == F_equal_to || - fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0008_s) == F_equal_to || - fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0008_s) == F_equal_to) { + fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0008_s) == F_equal_to || + fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0008_s) == F_equal_to) { setting->program_name = &fss_write_embedded_list_program_name_s; setting->program_name_long = &fss_write_embedded_list_program_name_long_s; @@ -188,8 +122,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { setting->process_normal = &fss_write_embedded_list_process_normal; } else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_000e_s) == F_equal_to || - fl_string_dynamic_compare(argv[index], fss_write_format_code_long_000e_s) == F_equal_to || - fl_string_dynamic_compare(argv[index], fss_write_format_code_human_000e_s) == F_equal_to) { + fl_string_dynamic_compare(argv[index], fss_write_format_code_long_000e_s) == F_equal_to || + fl_string_dynamic_compare(argv[index], fss_write_format_code_human_000e_s) == F_equal_to) { setting->program_name = &fss_write_payload_program_name_s; setting->program_name_long = &fss_write_payload_program_name_long_s; @@ -199,9 +133,19 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { } else { - // @todo print error + if (setting->flag & fss_write_main_flag_help_e) { + setting->status = F_status_set_error(F_parameter); + + break; + } + + if (setting->status != F_status_set_error(F_parameter)) { + fss_write_print_line_first_locked(setting, main->error); + } setting->status = F_status_set_error(F_parameter); + + fss_write_main_print_error_format_unknown(main->error, argv[index]); } } // for @@ -209,6 +153,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { if (setting->flag & fss_write_main_flag_help_e) { fss_write_main_process_help(main, setting); } + else { + fss_write_print_line_last_locked(setting, main->error); + } return; } diff --git a/level_3/fss_write/c/main/main.h b/level_3/fss_write/c/main/main.h index 0025bda..1de0ad0 100644 --- a/level_3/fss_write/c/main/main.h +++ b/level_3/fss_write/c/main/main.h @@ -6,8 +6,7 @@ * Licenses: lgpl-2.1-or-later * * This file is only ever included by main/main.c and should not normally be included anywhere else. - * Anything that wants to include this should be providing the "main" program functionality in some manner. - * Any program utilizing this should link to the "main" program library. + * Anything that wants to include this should be providing the "fss_write" program functionality in some manner. */ #ifndef _fss_write_main_h #define _fss_write_main_h @@ -38,8 +37,6 @@ extern "C" { /** * Perform the standard program setting load process for the "--as" parameter. * - * This should be called before fss_write_setting_load() is called to ensure "--as" gets processed before "--help". - * * This prints error messages as appropriate. * * If either main or setting is NULL, then this immediately retuns without doing anything. diff --git a/level_3/fss_write/c/main/print.h b/level_3/fss_write/c/main/print.h index 54ae87c..781b4e0 100644 --- a/level_3/fss_write/c/main/print.h +++ b/level_3/fss_write/c/main/print.h @@ -118,7 +118,7 @@ extern "C" { #endif // _fss_write_print_error_prepend_only_whitespace_ /** - * Print an message about a parameter New Line character '\n' (U+000A) being unsupported. + * Print an error message about a parameter New Line character '\n' (U+000A) being unsupported. * * @param setting * The main program settings. diff --git a/level_3/fss_write/c/payload/common.c b/level_3/fss_write/c/payload/common.c index 88e7991..86411d2 100644 --- a/level_3/fss_write/c/payload/common.c +++ b/level_3/fss_write/c/payload/common.c @@ -5,6 +5,8 @@ extern "C" { #endif #ifndef _di_fss_write_payload_strings_ + const f_string_static_t fss_write_payload_s = macro_f_string_static_t_initialize(FSS_WRITE_payload_s, 0, FSS_WRITE_payload_s_length); + const f_string_static_t fss_write_payload_standard_s = macro_f_string_static_t_initialize(FSS_WRITE_payload_standard_s, 0, FSS_WRITE_payload_standard_s_length); const f_string_static_t fss_write_payload_program_name_s = macro_f_string_static_t_initialize(FSS_WRITE_payload_program_name_s, 0, FSS_WRITE_payload_program_name_s_length); @@ -15,6 +17,30 @@ extern "C" { const f_string_static_t fss_write_format_code_human_000e_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_human_000e_s, 0, FSS_WRITE_format_code_human_000e_s_length); #endif // _di_fss_write_payload_strings_ +#ifndef _di_fss_write_payload_setting_load_ + void fss_write_payload_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting) { + + if (!main || !setting) return; + + f_array_lengths_t * const values = &main->parameters.array[fss_write_parameter_object_e].values; + f_string_static_t * const argv = main->parameters.arguments.array; + + if ((main->parameters.array[fss_write_parameter_object_e].result & f_console_result_value_e) && values->used) { + + for (f_array_length_t i = 0; i < values->used; ++i) { + + if (fl_string_dynamic_compare(argv[values->array[i]], fss_write_payload_s) == F_equal_to && i + 1 < values->used) { + setting->status = F_status_set_error(F_parameter); + + fss_write_payload_print_error_payload_not_last(setting, main->error); + + return; + } + } // for + } + } +#endif // _di_fss_write_payload_setting_load_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_write/c/payload/common.h b/level_3/fss_write/c/payload/common.h index 46ded67..e3493f4 100644 --- a/level_3/fss_write/c/payload/common.h +++ b/level_3/fss_write/c/payload/common.h @@ -20,6 +20,8 @@ extern "C" { * The FSS-000E (Payload) specific strings. */ #ifndef _di_fss_write_payload_strings_ + #define FSS_WRITE_payload_s "payload" + #define FSS_WRITE_payload_standard_s "FSS-000E (Payload)" #define FSS_WRITE_payload_program_name_s "fss_payload_write" @@ -29,6 +31,8 @@ extern "C" { #define FSS_WRITE_format_code_long_000e_s "fss-000e" #define FSS_WRITE_format_code_human_000e_s "payload" + #define FSS_WRITE_payload_s_length 7 + #define FSS_WRITE_payload_standard_s_length 18 #define FSS_WRITE_payload_program_name_s_length 17 @@ -38,6 +42,8 @@ extern "C" { #define FSS_WRITE_format_code_long_000e_s_length 8 #define FSS_WRITE_format_code_human_000e_s_length 7 + extern const f_string_static_t fss_write_payload_s; + extern const f_string_static_t fss_write_payload_standard_s; extern const f_string_static_t fss_write_payload_program_name_s; @@ -48,6 +54,39 @@ extern "C" { extern const f_string_static_t fss_write_format_code_human_000e_s; #endif // _di_fss_write_payload_strings_ +/** + * Perform the payload-specific program setting load process. + * + * This prints error messages as appropriate. + * + * If either main or setting is NULL, then this immediately retuns without doing anything. + * + * @param arguments + * The parameters passed to the process (often referred to as command line arguments). + * @param main + * The main program data. + * @param setting + * The main program settings. + * + * This alters setting.process_help, setting.process_normal, and setting.process_pipe. + * + * This alters setting.status: + * F_none on success. + * F_interrupt on (exit) signal received. + * + * F_parameter (with error bit) if main is NULL or setting is NULL. + * F_parameter (with error bit) on parameter error. + * + * This alters setting.status: + * F_none on success. + * F_data_not on success but nothing was provided to operate with. + * + * @see fss_write_setting_load() + */ +#ifndef _di_fss_write_payload_setting_load_ + extern void fss_write_payload_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting); +#endif // _di_fss_write_payload_setting_load_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_write/c/payload/fss_write.c b/level_3/fss_write/c/payload/fss_write.c index 9af12f8..712af00 100644 --- a/level_3/fss_write/c/payload/fss_write.c +++ b/level_3/fss_write/c/payload/fss_write.c @@ -1,7 +1,7 @@ #include "fss_write.h" +#include "../main/fss_write.h" #include "private-common.h" #include "private-write.h" -#include "../main/fss_write.h" #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_write/c/payload/fss_write.h b/level_3/fss_write/c/payload/fss_write.h index 90ce957..f956e52 100644 --- a/level_3/fss_write/c/payload/fss_write.h +++ b/level_3/fss_write/c/payload/fss_write.h @@ -44,10 +44,10 @@ #include // FSS Write includes. -#include #include -#include +#include #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_write/c/payload/main.c b/level_3/fss_write/c/payload/main.c index 6aea424..430b465 100644 --- a/level_3/fss_write/c/payload/main.c +++ b/level_3/fss_write/c/payload/main.c @@ -1,4 +1,5 @@ #include "fss_write.h" +#include "../main/fss_write.h" int main(const int argc, const f_string_t *argv, const f_string_t *envp) { @@ -26,7 +27,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_write_setting_load(arguments, &data, &setting, 0); + fss_write_setting_load(arguments, &data, &setting, &fss_write_payload_setting_load); } fss_write_main(&data, &setting); diff --git a/level_3/fss_write/c/payload/print.c b/level_3/fss_write/c/payload/print.c index 8aaec23..60a2ea0 100644 --- a/level_3/fss_write/c/payload/print.c +++ b/level_3/fss_write/c/payload/print.c @@ -5,6 +5,23 @@ extern "C" { #endif +#ifndef _di_fss_write_payload_print_error_payload_not_last_ + f_status_t fss_write_payload_print_error_payload_not_last(fss_write_setting_t * const setting, const fl_print_t print) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fss_write_print_line_first_unlocked(setting, print); + fl_print_format("%[%QThe payload may only be specified last.%]%r", print.to, print.set->error, print.prefix, print.set->error, f_string_eol_s); + fss_write_print_line_last_unlocked(setting, print); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fss_write_payload_print_error_payload_not_last_ + #ifndef _di_fss_write_payload_print_help_ f_status_t fss_write_payload_print_help(fss_write_setting_t * const setting, const fl_print_t print) { diff --git a/level_3/fss_write/c/payload/print.h b/level_3/fss_write/c/payload/print.h index 99bfcee..c65bc54 100644 --- a/level_3/fss_write/c/payload/print.h +++ b/level_3/fss_write/c/payload/print.h @@ -13,6 +13,26 @@ extern "C" { #endif /** + * Print error message about the "payload" not being specified last (when it is specified at all). + * + * @param setting + * The main program settings. + * + * This does not alter setting.status. + * @param print + * Designates the how and where to print. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * @see fll_error_print() + */ +#ifndef _di_fss_write_payload_print_error_payload_not_last_ + extern f_status_t fss_write_payload_print_error_payload_not_last(fss_write_setting_t * const setting, const fl_print_t print); +#endif // _di_fss_write_payload_print_error_payload_not_last_ + +/** * Print help for FSS-000E (Payload). * * @param setting diff --git a/level_3/fss_write/data/build/fakefile b/level_3/fss_write/data/build/fakefile index 55ac977..1830cfc 100644 --- a/level_3/fss_write/data/build/fakefile +++ b/level_3/fss_write/data/build/fakefile @@ -17,8 +17,20 @@ main: using_default: build settings - build settings.fss_write + build settings.main + #build settings.basic + #build settings.basic_list + #build settings.extended + #build settings.extended_list + #build settings.embedded_list + build settings.payload using_mode: build settings parameter:'mode:value' - build settings.fss_status_code parameter:'mode:value' + build settings.main parameter:'mode:value' + #build settings.basic parameter:'mode:value' + #build settings.basic_list parameter:'mode:value' + #build settings.extended parameter:'mode:value' + #build settings.extended_list parameter:'mode:value' + #build settings.embedded_list parameter:'mode:value' + build settings.payload parameter:'mode:value' diff --git a/level_3/fss_write/data/build/settings b/level_3/fss_write/data/build/settings index 79e81d7..caf6ea1 100644 --- a/level_3/fss_write/data/build/settings +++ b/level_3/fss_write/data/build/settings @@ -1,4 +1,7 @@ # fss-0001 +# +# Builds the main library of the project with all parts except "main" program related. +# build_name fss_write @@ -30,9 +33,7 @@ build_sources_library extended/fss_write.c extended/common.c extended/print.c ex build_sources_library extended_list/fss_write.c extended_list/common.c extended_list/print.c extended_list/private-common.c extended_list/private-write.c extended_list/private-print.c build_sources_library payload/fss_write.c payload/common.c payload/print.c payload/private-common.c payload/private-write.c payload/private-print.c -build_sources_program main/main.c - -build_sources_headers main/main.h main/fss_write.h main/common.h main/print.h main/private-common.h main/private-write.h +build_sources_headers main/fss_write.h main/common.h main/print.h main/private-common.h main/private-write.h build_sources_headers basic/fss_write.h basic/common.h basic/print.h basic/private-common.h basic/private-write.h basic/private-print.h build_sources_headers basic_list/fss_write.h basic_list/common.h basic_list/print.h basic_list/private-common.h basic_list/private-write.h basic_list/private-print.h build_sources_headers embedded_list/fss_write.h embedded_list/common.h embedded_list/print.h embedded_list/private-common.h embedded_list/private-write.h embedded_list/private-print.h diff --git a/level_3/fss_write/data/build/settings.main b/level_3/fss_write/data/build/settings.main new file mode 100644 index 0000000..632ef24 --- /dev/null +++ b/level_3/fss_write/data/build/settings.main @@ -0,0 +1,58 @@ +# fss-0001 +# +# Builds the "main" program (fss_write). +# This must be called after the "setting". +# + +build_name fss_write + +version_major 0 +version_minor 7 +version_micro 0 +version_file micro +version_target minor + +modes individual level monolithic clang test +modes_default monolithic + +build_compiler gcc +build_compiler-clang clang +build_indexer ar +build_indexer_arguments rcs +build_language c + +build_libraries -lc -lfss_write +build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_conversion -lfl_directory -lfl_fss -lfl_print -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_signal -lf_status_string -lf_string -lf_type_array -lf_utf +build_libraries-level -lfll_2 -lfll_1 -lfll_0 +build_libraries-monolithic -lfll + +build_sources_program main/main.c main/main-print.c + +build_sources_headers main/main.h main/main-print.h + +build_script yes +build_shared yes +build_static no + +path_headers program/fss_write + +has_path_standard yes +preserve_path_headers yes + +search_exclusive yes +search_shared yes +search_static yes + +environment PATH LD_LIBRARY_PATH + +#defines -D_di_libcap_ -D_di_thread_support_ +defines -D_libcap_legacy_only_ -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ + +flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces +flags-clang -Wno-logical-op-parentheses +flags-test -O0 -fstack-protector -Wall +flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ + +flags_library -fPIC +flags_object -fPIC +flags_program -fPIE diff --git a/level_3/fss_write/data/build/settings.payload b/level_3/fss_write/data/build/settings.payload new file mode 100644 index 0000000..9b95dba --- /dev/null +++ b/level_3/fss_write/data/build/settings.payload @@ -0,0 +1,56 @@ +# fss-0001 +# +# Builds the "payload" program (fss_payload_write). +# This must be called after the "setting". +# + +build_name fss_payload_write + +version_major 0 +version_minor 7 +version_micro 0 +version_file micro +version_target minor + +modes individual level monolithic clang test +modes_default monolithic + +build_compiler gcc +build_compiler-clang clang +build_indexer ar +build_indexer_arguments rcs +build_language c + +build_libraries -lc -lfss_write +build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_conversion -lfl_directory -lfl_fss -lfl_print -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_signal -lf_status_string -lf_string -lf_type_array -lf_utf +build_libraries-level -lfll_2 -lfll_1 -lfll_0 +build_libraries-monolithic -lfll + +build_sources_program payload/main.c + +build_script yes +build_shared yes +build_static no + +path_headers program/fss_write + +has_path_standard yes +preserve_path_headers yes + +search_exclusive yes +search_shared yes +search_static yes + +environment PATH LD_LIBRARY_PATH + +#defines -D_di_libcap_ -D_di_thread_support_ +defines -D_libcap_legacy_only_ -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ + +flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces +flags-clang -Wno-logical-op-parentheses +flags-test -O0 -fstack-protector -Wall +flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ + +flags_library -fPIC +flags_object -fPIC +flags_program -fPIE diff --git a/level_3/utf8/c/print.c b/level_3/utf8/c/print.c index e0b3fa8..a55f8d2 100644 --- a/level_3/utf8/c/print.c +++ b/level_3/utf8/c/print.c @@ -137,7 +137,7 @@ extern "C" { utf8_print_line_first_unlocked(setting, print); - fl_print_format("%[%QNo file specified at parameter index %]", print.to, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%QNo file specified at parameter index%] ", print.to, print.set->error, print.prefix, print.set->error); fl_print_format("%[%ul%]", print.to, print.set->notable, index, print.set->notable); fl_print_format("%[.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);