From 7fe2a9d1b5d6c971d4492a2d3e51b4d4d8a64cd9 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 29 Nov 2022 22:59:01 -0600 Subject: [PATCH] Progress: Continue program related work, updating fss_write. Relocate help and version flag assignment checks across programs. Setup individual help printing for each supported "--as" parameter in fss_write. --- level_3/byte_dump/c/common.c | 24 +++--- level_3/control/c/common.c | 24 +++--- level_3/controller/c/common.c | 24 +++--- level_3/fake/c/common.c | 24 +++--- level_3/firewall/c/common.c | 24 +++--- level_3/fss_basic_list_read/c/common.c | 24 +++--- level_3/fss_basic_list_write/c/common.c | 24 +++--- level_3/fss_basic_read/c/common.c | 24 +++--- level_3/fss_basic_write/c/common.c | 24 +++--- level_3/fss_embedded_list_read/c/common.c | 24 +++--- level_3/fss_embedded_list_write/c/common.c | 24 +++--- level_3/fss_extended_list_read/c/common.c | 24 +++--- level_3/fss_extended_list_write/c/common.c | 24 +++--- level_3/fss_extended_read/c/common.c | 24 +++--- level_3/fss_extended_write/c/common.c | 24 +++--- level_3/fss_identify/c/common.c | 24 +++--- level_3/fss_payload_read/c/common.c | 24 +++--- level_3/fss_payload_write/c/common.c | 24 +++--- level_3/fss_write/c/basic/common.c | 3 + level_3/fss_write/c/basic/common.h | 9 ++ level_3/fss_write/c/basic/main.c | 4 +- level_3/fss_write/c/basic/print.c | 12 ++- level_3/fss_write/c/basic_list/common.c | 3 + level_3/fss_write/c/basic_list/common.h | 9 ++ level_3/fss_write/c/basic_list/main.c | 4 +- level_3/fss_write/c/basic_list/print.c | 12 ++- level_3/fss_write/c/embedded_list/common.c | 3 + level_3/fss_write/c/embedded_list/common.h | 15 ++-- level_3/fss_write/c/embedded_list/main.c | 4 +- level_3/fss_write/c/embedded_list/print.c | 15 +++- level_3/fss_write/c/extended/common.c | 3 + level_3/fss_write/c/extended/common.h | 9 ++ level_3/fss_write/c/extended/main.c | 4 +- level_3/fss_write/c/extended/print.c | 12 ++- level_3/fss_write/c/extended_list/common.c | 3 + level_3/fss_write/c/extended_list/common.h | 9 ++ level_3/fss_write/c/extended_list/main.c | 4 +- level_3/fss_write/c/extended_list/print.c | 15 +++- level_3/fss_write/c/main/common.c | 40 ++++----- level_3/fss_write/c/main/common.h | 37 +++------ level_3/fss_write/c/main/main.c | 127 +++++++++++++++++++++++++++-- level_3/fss_write/c/main/main.h | 46 +++++++++++ level_3/fss_write/c/main/print.c | 13 +++ level_3/fss_write/c/main/print.h | 16 ++++ level_3/fss_write/c/payload/common.c | 3 + level_3/fss_write/c/payload/common.h | 9 ++ level_3/fss_write/c/payload/main.c | 4 +- level_3/fss_write/c/payload/print.c | 13 +-- level_3/iki_read/c/iki_read.c | 2 +- level_3/iki_write/c/common.c | 24 +++--- level_3/utf8/c/common.c | 24 +++--- 51 files changed, 610 insertions(+), 332 deletions(-) diff --git a/level_3/byte_dump/c/common.c b/level_3/byte_dump/c/common.c index b85f53f..c6bc7fd 100644 --- a/level_3/byte_dump/c/common.c +++ b/level_3/byte_dump/c/common.c @@ -149,24 +149,24 @@ extern "C" { return; } } - - if (main->parameters.array[byte_dump_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= byte_dump_main_flag_help_e; - - return; - } - - if (main->parameters.array[byte_dump_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= byte_dump_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[byte_dump_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= byte_dump_main_flag_help_e; + + return; + } + + if (main->parameters.array[byte_dump_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= byte_dump_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[byte_dump_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/control/c/common.c b/level_3/control/c/common.c index 1e6d4f5..f4c9d66 100644 --- a/level_3/control/c/common.c +++ b/level_3/control/c/common.c @@ -252,24 +252,24 @@ extern "C" { return; } } - - if (main->parameters.array[control_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= control_main_flag_help_e; - - return; - } - - if (main->parameters.array[control_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= control_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[control_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= control_main_flag_help_e; + + return; + } + + if (main->parameters.array[control_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= control_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[control_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/controller/c/common.c b/level_3/controller/c/common.c index 158e265..4389cfe 100644 --- a/level_3/controller/c/common.c +++ b/level_3/controller/c/common.c @@ -684,24 +684,24 @@ extern "C" { return; } } - - if (main->parameters.array[controller_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= controller_main_flag_help_e; - - return; - } - - if (main->parameters.array[controller_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= controller_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[controller_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= controller_main_flag_help_e; + + return; + } + + if (main->parameters.array[controller_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= controller_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[controller_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fake/c/common.c b/level_3/fake/c/common.c index acbb147..19f7e72 100644 --- a/level_3/fake/c/common.c +++ b/level_3/fake/c/common.c @@ -197,24 +197,24 @@ extern "C" { return; } } - - if (main->parameters.array[fake_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fake_main_flag_help_e; - - return; - } - - if (main->parameters.array[fake_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fake_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fake_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fake_main_flag_help_e; + + return; + } + + if (main->parameters.array[fake_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fake_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fake_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/firewall/c/common.c b/level_3/firewall/c/common.c index a3f2d79..1d16175 100644 --- a/level_3/firewall/c/common.c +++ b/level_3/firewall/c/common.c @@ -185,24 +185,24 @@ extern "C" { return; } } - - if (main->parameters.array[firewall_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= firewall_main_flag_help_e; - - return; - } - - if (main->parameters.array[firewall_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= firewall_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[firewall_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= firewall_main_flag_help_e; + + return; + } + + if (main->parameters.array[firewall_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= firewall_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[firewall_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_basic_list_read/c/common.c b/level_3/fss_basic_list_read/c/common.c index 87f82c8..66bea4b 100644 --- a/level_3/fss_basic_list_read/c/common.c +++ b/level_3/fss_basic_list_read/c/common.c @@ -143,24 +143,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_basic_list_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_list_read_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_basic_list_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_list_read_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_basic_list_read_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_basic_list_read_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_basic_list_read_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_basic_list_read_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_basic_list_read_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_basic_list_write/c/common.c b/level_3/fss_basic_list_write/c/common.c index 418f7ec..7f7a0f3 100644 --- a/level_3/fss_basic_list_write/c/common.c +++ b/level_3/fss_basic_list_write/c/common.c @@ -124,24 +124,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_basic_list_write_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_list_write_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_basic_list_write_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_list_write_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_basic_list_write_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_basic_list_write_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_basic_list_write_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_basic_list_write_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_basic_list_write_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_basic_read/c/common.c b/level_3/fss_basic_read/c/common.c index 1236c9b..0ae3213 100644 --- a/level_3/fss_basic_read/c/common.c +++ b/level_3/fss_basic_read/c/common.c @@ -142,24 +142,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_basic_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_read_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_basic_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_read_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_basic_read_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_basic_read_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_basic_read_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_basic_read_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_basic_read_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_basic_write/c/common.c b/level_3/fss_basic_write/c/common.c index f00eaee..f98f67d 100644 --- a/level_3/fss_basic_write/c/common.c +++ b/level_3/fss_basic_write/c/common.c @@ -124,24 +124,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_basic_write_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_write_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_basic_write_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_write_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_basic_write_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_basic_write_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_basic_write_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_basic_write_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_basic_write_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_embedded_list_read/c/common.c b/level_3/fss_embedded_list_read/c/common.c index ef4fcff..317a799 100644 --- a/level_3/fss_embedded_list_read/c/common.c +++ b/level_3/fss_embedded_list_read/c/common.c @@ -141,24 +141,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_embedded_list_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_embedded_list_read_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_embedded_list_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_embedded_list_read_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_embedded_list_read_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_embedded_list_read_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_embedded_list_read_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_embedded_list_read_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_embedded_list_read_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_embedded_list_write/c/common.c b/level_3/fss_embedded_list_write/c/common.c index a464a7e..88b47bc 100644 --- a/level_3/fss_embedded_list_write/c/common.c +++ b/level_3/fss_embedded_list_write/c/common.c @@ -124,24 +124,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_embedded_list_write_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_embedded_list_write_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_embedded_list_write_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_embedded_list_write_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_embedded_list_write_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_embedded_list_write_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_embedded_list_write_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_embedded_list_write_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_embedded_list_write_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_extended_list_read/c/common.c b/level_3/fss_extended_list_read/c/common.c index 43bb491..8e7ab59 100644 --- a/level_3/fss_extended_list_read/c/common.c +++ b/level_3/fss_extended_list_read/c/common.c @@ -149,24 +149,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_extended_list_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_list_read_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_extended_list_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_list_read_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_extended_list_read_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_extended_list_read_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_extended_list_read_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_extended_list_read_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_extended_list_read_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_extended_list_write/c/common.c b/level_3/fss_extended_list_write/c/common.c index dcb25d4..d4c4df5 100644 --- a/level_3/fss_extended_list_write/c/common.c +++ b/level_3/fss_extended_list_write/c/common.c @@ -131,24 +131,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_extended_list_write_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_list_write_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_extended_list_write_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_list_write_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_extended_list_write_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_extended_list_write_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_extended_list_write_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_extended_list_write_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_extended_list_write_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_extended_read/c/common.c b/level_3/fss_extended_read/c/common.c index ba3abde..9b44d52 100644 --- a/level_3/fss_extended_read/c/common.c +++ b/level_3/fss_extended_read/c/common.c @@ -142,24 +142,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_extended_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_read_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_extended_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_read_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_extended_read_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_extended_read_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_extended_read_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_extended_read_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_extended_read_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_extended_write/c/common.c b/level_3/fss_extended_write/c/common.c index 389a351..e85733e 100644 --- a/level_3/fss_extended_write/c/common.c +++ b/level_3/fss_extended_write/c/common.c @@ -124,24 +124,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_extended_write_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_write_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_extended_write_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_write_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_extended_write_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_extended_write_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_extended_write_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_extended_write_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_extended_write_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_identify/c/common.c b/level_3/fss_identify/c/common.c index c932d9c..ea366be 100644 --- a/level_3/fss_identify/c/common.c +++ b/level_3/fss_identify/c/common.c @@ -109,24 +109,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_identify_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_identify_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_identify_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_identify_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_identify_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_identify_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_identify_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_identify_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_identify_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_payload_read/c/common.c b/level_3/fss_payload_read/c/common.c index 4a537f9..e89088b 100644 --- a/level_3/fss_payload_read/c/common.c +++ b/level_3/fss_payload_read/c/common.c @@ -143,24 +143,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_payload_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_payload_read_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_payload_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_payload_read_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_payload_read_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_payload_read_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_payload_read_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_payload_read_main_flag_version_e; + + return; + } + f_string_static_t * const args = main->parameters.arguments.array; if (main->parameters.array[fss_payload_read_parameter_strip_invalid_e].result & f_console_result_found_e) { diff --git a/level_3/fss_payload_write/c/common.c b/level_3/fss_payload_write/c/common.c index 59bb985..1dfcb4e 100644 --- a/level_3/fss_payload_write/c/common.c +++ b/level_3/fss_payload_write/c/common.c @@ -132,24 +132,24 @@ extern "C" { return; } } - - if (main->parameters.array[fss_payload_write_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_payload_write_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_payload_write_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_payload_write_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[fss_payload_write_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_payload_write_main_flag_help_e; + + return; + } + + if (main->parameters.array[fss_payload_write_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_payload_write_main_flag_version_e; + + return; + } + if (main->parameters.array[fss_payload_write_parameter_file_e].result & f_console_result_value_e && main->parameters.array[fss_payload_write_parameter_file_e].values.used) { if (main->parameters.array[fss_payload_write_parameter_file_e].values.used > 1) { setting->status = F_status_set_error(F_parameter); diff --git a/level_3/fss_write/c/basic/common.c b/level_3/fss_write/c/basic/common.c index f6993c7..78d096b 100644 --- a/level_3/fss_write/c/basic/common.c +++ b/level_3/fss_write/c/basic/common.c @@ -7,6 +7,9 @@ extern "C" { #ifndef _di_fss_write_basic_strings_ const f_string_static_t fss_write_basic_standard_s = macro_f_string_static_t_initialize(FSS_WRITE_basic_standard_s, 0, FSS_WRITE_basic_standard_s_length); + const f_string_static_t fss_write_basic_program_name_s = macro_f_string_static_t_initialize(FSS_WRITE_basic_program_name_s, 0, FSS_WRITE_basic_program_name_s_length); + const f_string_static_t fss_write_basic_program_name_long_s = macro_f_string_static_t_initialize(FSS_WRITE_basic_program_name_long_s, 0, FSS_WRITE_basic_program_name_long_s_length); + const f_string_static_t fss_write_format_code_short_0000_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_short_0000_s, 0, FSS_WRITE_format_code_short_0000_s_length); const f_string_static_t fss_write_format_code_long_0000_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_long_0000_s, 0, FSS_WRITE_format_code_long_0000_s_length); const f_string_static_t fss_write_format_code_human_0000_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_human_0000_s, 0, FSS_WRITE_format_code_human_0000_s_length); diff --git a/level_3/fss_write/c/basic/common.h b/level_3/fss_write/c/basic/common.h index de6135e..b796ef9 100644 --- a/level_3/fss_write/c/basic/common.h +++ b/level_3/fss_write/c/basic/common.h @@ -22,18 +22,27 @@ extern "C" { #ifndef _di_fss_write_basic_strings_ #define FSS_WRITE_basic_standard_s "FSS-0000 (Basic)" + #define FSS_WRITE_basic_program_name_s "fss_basic_write" + #define FSS_WRITE_basic_program_name_long_s "FSS Basic Write" + #define FSS_WRITE_format_code_short_0000_s "0000" #define FSS_WRITE_format_code_long_0000_s "fss-0000" #define FSS_WRITE_format_code_human_0000_s "basic" #define FSS_WRITE_basic_standard_s_length 16 + #define FSS_WRITE_basic_program_name_s_length 15 + #define FSS_WRITE_basic_program_name_long_s_length 15 + #define FSS_WRITE_format_code_short_0000_s_length 4 #define FSS_WRITE_format_code_long_0000_s_length 8 #define FSS_WRITE_format_code_human_0000_s_length 5 extern const f_string_static_t fss_write_basic_standard_s; + extern const f_string_static_t fss_write_basic_program_name_s; + extern const f_string_static_t fss_write_basic_program_name_long_s; + extern const f_string_static_t fss_write_format_code_short_0000_s; extern const f_string_static_t fss_write_format_code_long_0000_s; extern const f_string_static_t fss_write_format_code_human_0000_s; diff --git a/level_3/fss_write/c/basic/main.c b/level_3/fss_write/c/basic/main.c index 8b9a9e8..2b95e0c 100644 --- a/level_3/fss_write/c/basic/main.c +++ b/level_3/fss_write/c/basic/main.c @@ -8,6 +8,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { setting.process_help = &fss_write_basic_process_help; setting.process_pipe = &fss_write_basic_process_pipe; setting.process_normal = &fss_write_basic_process_normal; + setting.program_name = &fss_write_basic_program_name_s; + setting.program_name_long = &fss_write_basic_program_name_long_s; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.parameters.array = parameters; @@ -24,7 +26,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); + fss_write_setting_load(arguments, &data, &setting, 0); } fss_write_basic_main(&data, &setting); diff --git a/level_3/fss_write/c/basic/print.c b/level_3/fss_write/c/basic/print.c index bc34f6b..75ff0f7 100644 --- a/level_3/fss_write/c/basic/print.c +++ b/level_3/fss_write/c/basic/print.c @@ -12,15 +12,21 @@ extern "C" { 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); + fll_program_print_help_header(print, setting->program_name_long ? *setting->program_name_long : fss_write_program_name_long_s, fss_write_program_version_s); fss_write_print_help(setting, print); 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); + fll_program_print_help_usage(print, setting->program_name ? *setting->program_name : fss_write_program_name_s, f_string_empty_s); - // @todo + fss_write_print_help_pipe(setting, print); + + fl_print_format("%r The FSS-0000 (Basic) specification does not support multi-line Content, therefore the parameter '%[%r%r%]'", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_prepend_s, print.set->notable); + fl_print_format(" does nothing.%r%r", print.to, f_string_eol_s, f_string_eol_s); + + fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print.set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print.to, f_string_eol_s); f_print_dynamic_raw(setting->line_last, print.to); diff --git a/level_3/fss_write/c/basic_list/common.c b/level_3/fss_write/c/basic_list/common.c index 477f698..4271316 100644 --- a/level_3/fss_write/c/basic_list/common.c +++ b/level_3/fss_write/c/basic_list/common.c @@ -7,6 +7,9 @@ extern "C" { #ifndef _di_fss_write_basic_list_strings_ const f_string_static_t fss_write_basic_list_standard_s = macro_f_string_static_t_initialize(FSS_WRITE_basic_list_standard_s, 0, FSS_WRITE_basic_list_standard_s_length); + const f_string_static_t fss_write_basic_list_program_name_s = macro_f_string_static_t_initialize(FSS_WRITE_basic_list_program_name_s, 0, FSS_WRITE_basic_list_program_name_s_length); + const f_string_static_t fss_write_basic_list_program_name_long_s = macro_f_string_static_t_initialize(FSS_WRITE_basic_list_program_name_long_s, 0, FSS_WRITE_basic_list_program_name_long_s_length); + const f_string_static_t fss_write_format_code_short_0002_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_short_0002_s, 0, FSS_WRITE_format_code_short_0002_s_length); const f_string_static_t fss_write_format_code_long_0002_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_long_0002_s, 0, FSS_WRITE_format_code_long_0002_s_length); const f_string_static_t fss_write_format_code_human_0002_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_human_0002_s, 0, FSS_WRITE_format_code_human_0002_s_length); diff --git a/level_3/fss_write/c/basic_list/common.h b/level_3/fss_write/c/basic_list/common.h index f0b39cd..11cfe38 100644 --- a/level_3/fss_write/c/basic_list/common.h +++ b/level_3/fss_write/c/basic_list/common.h @@ -22,18 +22,27 @@ extern "C" { #ifndef _di_fss_write_basic_list_strings_ #define FSS_WRITE_basic_list_standard_s "FSS-0002 (Basic List)" + #define FSS_WRITE_basic_list_program_name_s "fss_basic_list_write" + #define FSS_WRITE_basic_list_program_name_long_s "FSS Basic List Write" + #define FSS_WRITE_format_code_short_0002_s "0002" #define FSS_WRITE_format_code_long_0002_s "fss-0002" #define FSS_WRITE_format_code_human_0002_s "basic list" #define FSS_WRITE_basic_list_standard_s_length 21 + #define FSS_WRITE_basic_list_program_name_s_length 20 + #define FSS_WRITE_basic_list_program_name_long_s_length 20 + #define FSS_WRITE_format_code_short_0002_s_length 4 #define FSS_WRITE_format_code_long_0002_s_length 8 #define FSS_WRITE_format_code_human_0002_s_length 10 extern const f_string_static_t fss_write_basic_list_standard_s; + extern const f_string_static_t fss_write_basic_list_program_name_s; + extern const f_string_static_t fss_write_basic_list_program_name_long_s; + extern const f_string_static_t fss_write_format_code_short_0002_s; extern const f_string_static_t fss_write_format_code_long_0002_s; extern const f_string_static_t fss_write_format_code_human_0002_s; diff --git a/level_3/fss_write/c/basic_list/main.c b/level_3/fss_write/c/basic_list/main.c index 2d03b16..8e3452d 100644 --- a/level_3/fss_write/c/basic_list/main.c +++ b/level_3/fss_write/c/basic_list/main.c @@ -8,6 +8,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { setting.process_help = &fss_write_basic_list_process_help; setting.process_pipe = &fss_write_basic_list_process_pipe; setting.process_normal = &fss_write_basic_list_process_normal; + setting.program_name = &fss_write_basic_list_program_name_s; + setting.program_name_long = &fss_write_basic_list_program_name_long_s; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.parameters.array = parameters; @@ -24,7 +26,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); + fss_write_setting_load(arguments, &data, &setting, 0); } fss_write_basic_list_main(&data, &setting); diff --git a/level_3/fss_write/c/basic_list/print.c b/level_3/fss_write/c/basic_list/print.c index 51ac9d3..78a16fa 100644 --- a/level_3/fss_write/c/basic_list/print.c +++ b/level_3/fss_write/c/basic_list/print.c @@ -12,15 +12,21 @@ extern "C" { 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); + fll_program_print_help_header(print, setting->program_name_long ? *setting->program_name_long : fss_write_program_name_long_s, fss_write_program_version_s); fss_write_print_help(setting, print); 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); + fll_program_print_help_usage(print, setting->program_name ? *setting->program_name : fss_write_program_name_s, f_string_empty_s); - // @todo + fss_write_print_help_pipe(setting, print); + + fl_print_format("%r The FSS-0002 (Basic List) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print.set->notable); + fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_double_s, print.set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print.set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print.to, f_string_eol_s); f_print_dynamic_raw(setting->line_last, print.to); diff --git a/level_3/fss_write/c/embedded_list/common.c b/level_3/fss_write/c/embedded_list/common.c index 54f60c1..bedc8e7 100644 --- a/level_3/fss_write/c/embedded_list/common.c +++ b/level_3/fss_write/c/embedded_list/common.c @@ -7,6 +7,9 @@ extern "C" { #ifndef _di_fss_write_embedded_list_strings_ const f_string_static_t fss_write_embedded_list_standard_s = macro_f_string_static_t_initialize(FSS_WRITE_embedded_list_standard_s, 0, FSS_WRITE_embedded_list_standard_s_length); + const f_string_static_t fss_write_embedded_list_program_name_s = macro_f_string_static_t_initialize(FSS_WRITE_embedded_list_program_name_s, 0, FSS_WRITE_embedded_list_program_name_s_length); + const f_string_static_t fss_write_embedded_list_program_name_long_s = macro_f_string_static_t_initialize(FSS_WRITE_embedded_list_program_name_long_s, 0, FSS_WRITE_embedded_list_program_name_long_s_length); + const f_string_static_t fss_write_format_code_short_0008_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_short_0008_s, 0, FSS_WRITE_format_code_short_0008_s_length); const f_string_static_t fss_write_format_code_long_0008_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_long_0008_s, 0, FSS_WRITE_format_code_long_0008_s_length); const f_string_static_t fss_write_format_code_human_0008_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_human_0008_s, 0, FSS_WRITE_format_code_human_0008_s_length); diff --git a/level_3/fss_write/c/embedded_list/common.h b/level_3/fss_write/c/embedded_list/common.h index 296934b..f4f05e3 100644 --- a/level_3/fss_write/c/embedded_list/common.h +++ b/level_3/fss_write/c/embedded_list/common.h @@ -22,21 +22,26 @@ extern "C" { #ifndef _di_fss_write_embedded_list_strings_ #define FSS_WRITE_embedded_list_standard_s "FSS-0008 (Embedded List)" - #define FSS_WRITE_embedded_list_standard_s_length 24 - - extern const f_string_static_t fss_write_embedded_list_standard_s; + #define FSS_WRITE_embedded_list_program_name_s "fss_embedded_list_write" + #define FSS_WRITE_embedded_list_program_name_long_s "FSS Embedded List Write" #define FSS_WRITE_format_code_short_0008_s "0008" #define FSS_WRITE_format_code_long_0008_s "fss-0008" #define FSS_WRITE_format_code_human_0008_s "basic" - #define FSS_WRITE_basic_standard_s_length 16 + #define FSS_WRITE_embedded_list_standard_s_length 24 + + #define FSS_WRITE_embedded_list_program_name_s_length 23 + #define FSS_WRITE_embedded_list_program_name_long_s_length 23 #define FSS_WRITE_format_code_short_0008_s_length 4 #define FSS_WRITE_format_code_long_0008_s_length 8 #define FSS_WRITE_format_code_human_0008_s_length 5 - extern const f_string_static_t fss_write_basic_standard_s; + extern const f_string_static_t fss_write_embedded_list_standard_s; + + extern const f_string_static_t fss_write_embedded_list_program_name_s; + extern const f_string_static_t fss_write_embedded_list_program_name_long_s; extern const f_string_static_t fss_write_format_code_short_0008_s; extern const f_string_static_t fss_write_format_code_long_0008_s; diff --git a/level_3/fss_write/c/embedded_list/main.c b/level_3/fss_write/c/embedded_list/main.c index bef1732..2652249 100644 --- a/level_3/fss_write/c/embedded_list/main.c +++ b/level_3/fss_write/c/embedded_list/main.c @@ -8,6 +8,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { setting.process_help = &fss_write_embedded_list_process_help; setting.process_pipe = &fss_write_embedded_list_process_pipe; setting.process_normal = &fss_write_embedded_list_process_normal; + setting.program_name = &fss_write_embedded_list_program_name_s; + setting.program_name_long = &fss_write_embedded_list_program_name_long_s; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.parameters.array = parameters; @@ -24,7 +26,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); + fss_write_setting_load(arguments, &data, &setting, 0); } fss_write_embedded_list_main(&data, &setting); diff --git a/level_3/fss_write/c/embedded_list/print.c b/level_3/fss_write/c/embedded_list/print.c index a1ee9f1..20255fd 100644 --- a/level_3/fss_write/c/embedded_list/print.c +++ b/level_3/fss_write/c/embedded_list/print.c @@ -12,15 +12,24 @@ extern "C" { 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); + fll_program_print_help_header(print, setting->program_name_long ? *setting->program_name_long : fss_write_program_name_long_s, fss_write_program_version_s); fss_write_print_help(setting, print); 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); + fll_program_print_help_usage(print, setting->program_name ? *setting->program_name : fss_write_program_name_s, f_string_empty_s); - // @todo + fss_write_print_help_pipe(setting, print); + + fl_print_format("%r The FSS-0008 (Embedded List) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print.set->notable); + fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_double_s, print.set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The parameter '%[%r%r%]' designates to not escape any valid nested Object or Content within some Content.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print.set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print.to, f_string_eol_s); + fl_print_format(" This parameter is not used for ignoring anything from the input pipe.%r", print.to, f_string_eol_s); + fl_print_format(" This parameter must be specified after a '%[%r%r%]'", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print.set->notable); + fl_print_format(" parameter and this applies only to the Content represented by that specific '%[%r%r%]' parameter.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print.set->notable, f_string_eol_s); f_print_dynamic_raw(setting->line_last, print.to); diff --git a/level_3/fss_write/c/extended/common.c b/level_3/fss_write/c/extended/common.c index 18ea2c1..dca3a8c 100644 --- a/level_3/fss_write/c/extended/common.c +++ b/level_3/fss_write/c/extended/common.c @@ -7,6 +7,9 @@ extern "C" { #ifndef _di_fss_write_extended_strings_ const f_string_static_t fss_write_extended_standard_s = macro_f_string_static_t_initialize(FSS_WRITE_extended_standard_s, 0, FSS_WRITE_extended_standard_s_length); + const f_string_static_t fss_write_extended_program_name_s = macro_f_string_static_t_initialize(FSS_WRITE_extended_program_name_s, 0, FSS_WRITE_extended_program_name_s_length); + const f_string_static_t fss_write_extended_program_name_long_s = macro_f_string_static_t_initialize(FSS_WRITE_extended_program_name_long_s, 0, FSS_WRITE_extended_program_name_long_s_length); + const f_string_static_t fss_write_format_code_short_0001_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_short_0001_s, 0, FSS_WRITE_format_code_short_0001_s_length); const f_string_static_t fss_write_format_code_long_0001_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_long_0001_s, 0, FSS_WRITE_format_code_long_0001_s_length); const f_string_static_t fss_write_format_code_human_0001_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_human_0001_s, 0, FSS_WRITE_format_code_human_0001_s_length); diff --git a/level_3/fss_write/c/extended/common.h b/level_3/fss_write/c/extended/common.h index 4bafcbc..595cd9d 100644 --- a/level_3/fss_write/c/extended/common.h +++ b/level_3/fss_write/c/extended/common.h @@ -22,18 +22,27 @@ extern "C" { #ifndef _di_fss_write_extended_strings_ #define FSS_WRITE_extended_standard_s "FSS-0001 (Extended)" + #define FSS_WRITE_extended_program_name_s "fss_extended_write" + #define FSS_WRITE_extended_program_name_long_s "FSS Extended Write" + #define FSS_WRITE_format_code_short_0001_s "0001" #define FSS_WRITE_format_code_long_0001_s "fss-0001" #define FSS_WRITE_format_code_human_0001_s "extended" #define FSS_WRITE_extended_standard_s_length 19 + #define FSS_WRITE_extended_program_name_s_length 18 + #define FSS_WRITE_extended_program_name_long_s_length 18 + #define FSS_WRITE_format_code_short_0001_s_length 4 #define FSS_WRITE_format_code_long_0001_s_length 8 #define FSS_WRITE_format_code_human_0001_s_length 8 extern const f_string_static_t fss_write_extended_standard_s; + extern const f_string_static_t fss_write_extended_program_name_s; + extern const f_string_static_t fss_write_extended_program_name_long_s; + extern const f_string_static_t fss_write_format_code_short_0001_s; extern const f_string_static_t fss_write_format_code_long_0001_s; extern const f_string_static_t fss_write_format_code_human_0001_s; diff --git a/level_3/fss_write/c/extended/main.c b/level_3/fss_write/c/extended/main.c index 70fc136..e4777f3 100644 --- a/level_3/fss_write/c/extended/main.c +++ b/level_3/fss_write/c/extended/main.c @@ -8,6 +8,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { setting.process_help = &fss_write_extended_process_help; setting.process_pipe = &fss_write_extended_process_pipe; setting.process_normal = &fss_write_extended_process_normal; + setting.program_name = &fss_write_extended_program_name_s; + setting.program_name_long = &fss_write_extended_program_name_long_s; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.parameters.array = parameters; @@ -24,7 +26,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); + fss_write_setting_load(arguments, &data, &setting, 0); } fss_write_extended_main(&data, &setting); diff --git a/level_3/fss_write/c/extended/print.c b/level_3/fss_write/c/extended/print.c index c634825..ec4ff7f 100644 --- a/level_3/fss_write/c/extended/print.c +++ b/level_3/fss_write/c/extended/print.c @@ -12,15 +12,21 @@ extern "C" { 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); + fll_program_print_help_header(print, setting->program_name_long ? *setting->program_name_long : fss_write_program_name_long_s, fss_write_program_version_s); fss_write_print_help(setting, print); 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); + fll_program_print_help_usage(print, setting->program_name ? *setting->program_name : fss_write_program_name_s, f_string_empty_s); - // @todo + fss_write_print_help_pipe(setting, print); + + fl_print_format("%r The FSS-0001 (Extended) specification does not support multi-line Content, therefore the parameter '%[%r%r%]'", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_prepend_s, print.set->notable); + fl_print_format(" does nothing.%r%r", print.to, f_string_eol_s, f_string_eol_s); + + fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print.set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print.to, f_string_eol_s); f_print_dynamic_raw(setting->line_last, print.to); diff --git a/level_3/fss_write/c/extended_list/common.c b/level_3/fss_write/c/extended_list/common.c index 20157d4..6645cd3 100644 --- a/level_3/fss_write/c/extended_list/common.c +++ b/level_3/fss_write/c/extended_list/common.c @@ -7,6 +7,9 @@ extern "C" { #ifndef _di_fss_write_extended_list_strings_ const f_string_static_t fss_write_extended_list_standard_s = macro_f_string_static_t_initialize(FSS_WRITE_extended_list_standard_s, 0, FSS_WRITE_extended_list_standard_s_length); + const f_string_static_t fss_write_extended_list_program_name_s = macro_f_string_static_t_initialize(FSS_WRITE_extended_list_program_name_s, 0, FSS_WRITE_extended_list_program_name_s_length); + const f_string_static_t fss_write_extended_list_program_name_long_s = macro_f_string_static_t_initialize(FSS_WRITE_extended_list_program_name_long_s, 0, FSS_WRITE_extended_list_program_name_long_s_length); + const f_string_static_t fss_write_format_code_short_0003_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_short_0003_s, 0, FSS_WRITE_format_code_short_0003_s_length); const f_string_static_t fss_write_format_code_long_0003_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_long_0003_s, 0, FSS_WRITE_format_code_long_0003_s_length); const f_string_static_t fss_write_format_code_human_0003_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_human_0003_s, 0, FSS_WRITE_format_code_human_0003_s_length); diff --git a/level_3/fss_write/c/extended_list/common.h b/level_3/fss_write/c/extended_list/common.h index 5257247..f842ab1 100644 --- a/level_3/fss_write/c/extended_list/common.h +++ b/level_3/fss_write/c/extended_list/common.h @@ -22,18 +22,27 @@ extern "C" { #ifndef _di_fss_write_extended_list_strings_ #define FSS_WRITE_extended_list_standard_s "FSS-0003 (Extended List)" + #define FSS_WRITE_extended_list_program_name_s "fss_extended_list_write" + #define FSS_WRITE_extended_list_program_name_long_s "FSS Extended List Write" + #define FSS_WRITE_format_code_short_0003_s "0003" #define FSS_WRITE_format_code_long_0003_s "fss-0003" #define FSS_WRITE_format_code_human_0003_s "extended list" #define FSS_WRITE_extended_list_standard_s_length 24 + #define FSS_WRITE_extended_list_program_name_s_length 23 + #define FSS_WRITE_extended_list_program_name_long_s_length 23 + #define FSS_WRITE_format_code_short_0003_s_length 4 #define FSS_WRITE_format_code_long_0003_s_length 8 #define FSS_WRITE_format_code_human_0003_s_length 13 extern const f_string_static_t fss_write_extended_list_standard_s; + extern const f_string_static_t fss_write_extended_list_program_name_s; + extern const f_string_static_t fss_write_extended_list_program_name_long_s; + extern const f_string_static_t fss_write_format_code_short_0003_s; extern const f_string_static_t fss_write_format_code_long_0003_s; extern const f_string_static_t fss_write_format_code_human_0003_s; diff --git a/level_3/fss_write/c/extended_list/main.c b/level_3/fss_write/c/extended_list/main.c index f6714b8..20d3dd4 100644 --- a/level_3/fss_write/c/extended_list/main.c +++ b/level_3/fss_write/c/extended_list/main.c @@ -8,6 +8,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { setting.process_help = &fss_write_extended_list_process_help; setting.process_pipe = &fss_write_extended_list_process_pipe; setting.process_normal = &fss_write_extended_list_process_normal; + setting.program_name = &fss_write_extended_list_program_name_s; + setting.program_name_long = &fss_write_extended_list_program_name_long_s; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.parameters.array = parameters; @@ -24,7 +26,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); + fss_write_setting_load(arguments, &data, &setting, 0); } fss_write_extended_list_main(&data, &setting); diff --git a/level_3/fss_write/c/extended_list/print.c b/level_3/fss_write/c/extended_list/print.c index 7e882b0..0409242 100644 --- a/level_3/fss_write/c/extended_list/print.c +++ b/level_3/fss_write/c/extended_list/print.c @@ -12,15 +12,24 @@ extern "C" { 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); + fll_program_print_help_header(print, setting->program_name_long ? *setting->program_name_long : fss_write_program_name_long_s, fss_write_program_version_s); fss_write_print_help(setting, print); 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); + fll_program_print_help_usage(print, setting->program_name ? *setting->program_name : fss_write_program_name_s, f_string_empty_s); - // @todo + fss_write_print_help_pipe(setting, print); + + fl_print_format("%r The FSS-0003 (Extended List) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print.set->notable); + fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_double_s, print.set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The parameter '%[%r%r%]' designates to not escape any valid nested Object or Content within some Content.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print.set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print.to, f_string_eol_s); + fl_print_format(" This parameter is not used for ignoring anything from the input pipe.%r", print.to, f_string_eol_s); + fl_print_format(" This parameter must be specified after a '%[%r%r%]'", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print.set->notable); + fl_print_format(" parameter and this applies only to the Content represented by that specific '%[%r%r%]' parameter.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print.set->notable, f_string_eol_s); f_print_dynamic_raw(setting->line_last, print.to); diff --git a/level_3/fss_write/c/main/common.c b/level_3/fss_write/c/main/common.c index cde0e3d..69d7ccd 100644 --- a/level_3/fss_write/c/main/common.c +++ b/level_3/fss_write/c/main/common.c @@ -68,7 +68,7 @@ extern "C" { #endif // _di_fss_write_setting_delete_ #ifndef _di_fss_write_setting_load_ - void fss_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting) { + void fss_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting, void (*callback)(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting)) { if (!main || !setting) return; @@ -134,38 +134,34 @@ extern "C" { return; } } - - if (main->parameters.array[fss_write_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_write_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_write_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_write_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - if (main->parameters.array[fss_write_parameter_file_e].result & f_console_result_value_e && main->parameters.array[fss_write_parameter_file_e].values.used) { - // @todo check the "-a/--as" and select format or fallback to FSS-0000 Basic (support either digits "0000"/"0001" or simple names "basic"/"basic_list". - // Fallback only happens if -a/--as is not disabled, otherwise the callback function should be pre-defined. + if (main->parameters.array[fss_write_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= fss_write_main_flag_help_e; } - else if (main->parameters.array[fss_write_parameter_as_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); - fss_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_write_long_file_s); - fss_write_print_line_last_locked(setting, main->error); + if (main->parameters.array[fss_write_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= fss_write_main_flag_version_e; + } - return; + if (callback) { + callback(arguments, main, setting); + if (F_status_is_error(setting->status)) return; + + if (setting->status == F_done) { + setting->status = F_none; + + return; + } } + if (main->parameters.array[fss_write_parameter_help_e].result & f_console_result_found_e) return; + if (main->parameters.array[fss_write_parameter_version_e].result & f_console_result_found_e) return; + if (main->parameters.array[fss_write_parameter_file_e].result & f_console_result_value_e && main->parameters.array[fss_write_parameter_file_e].values.used) { if (main->parameters.array[fss_write_parameter_file_e].values.used > 1) { setting->status = F_status_set_error(F_parameter); diff --git a/level_3/fss_write/c/main/common.h b/level_3/fss_write/c/main/common.h index 2d5802b..fc3f3ee 100644 --- a/level_3/fss_write/c/main/common.h +++ b/level_3/fss_write/c/main/common.h @@ -86,32 +86,6 @@ extern "C" { #endif // _di_fss_write_defines_ /** - * Designate the supported formats for the main (fss_write) program. - * - * These are intended to be used for communicating or selecting an "--as" option. - * - * The digit value of the codes are intended to exactly match the numeric representation. - * - * fss_write_format_code_*_e: - * - 0000: The FSS-0000 (Basic) format. - * - 0001: The FSS-0001 (Extended) format. - * - 0002: The FSS-0002 (Basic List) format. - * - 0003: The FSS-0003 (Extended List) format. - * - 0008: The FSS-0008 (Embedded List) format. - * - 000e: The FSS-000E (Payload) format. - */ -#ifndef _di_fss_write_formats_ - enum { - fss_write_format_code_0000_e = 0x0, - fss_write_format_code_0001_e = 0x1, - fss_write_format_code_0002_e = 0x2, - fss_write_format_code_0003_e = 0x3, - fss_write_format_code_0008_e = 0x8, - fss_write_format_code_000e_e = 0xe, - }; -#endif // _di_fss_write_formats_ - -/** * A collection of static strings associated with FSS Payload Write. */ #ifndef _di_fss_write_strings_ @@ -340,6 +314,9 @@ extern "C" { f_string_dynamics_t objects; f_string_dynamics_t contents; + const f_string_static_t *program_name; + const f_string_static_t *program_name_long; + void (*process_help)(fll_program_data_t * const main, void * const setting); void (*process_normal)(fll_program_data_t * const main, void * const setting); void (*process_pipe)(fll_program_data_t * const main, void * const setting); @@ -365,6 +342,8 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ + 0, \ } #endif // _di_fss_write_setting_t_ @@ -408,6 +387,10 @@ extern "C" { * Errors (with error bit) from: f_string_dynamics_resize(). * Errors (with error bit) from: fll_program_parameter_process_context(). * Errors (with error bit) from: fll_program_parameter_process_verbosity(). + * @param callback + * (optional) Designate a function to call after performing the initial processing, but before printing help. + * If the function returns F_done, then this function immediately returns, resetting status to F_none. + * Set to NULL to disable. * * @see f_console_parameter_process() * @see f_file_stream_open() @@ -416,7 +399,7 @@ extern "C" { * @see fll_program_parameter_process_verbosity() */ #ifndef _di_fss_write_setting_load_ - extern void fss_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting); + extern void fss_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting, void (*callback)(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting)); #endif // _di_fss_write_setting_load_ /** diff --git a/level_3/fss_write/c/main/main.c b/level_3/fss_write/c/main/main.c index d8634d2..3b2f07d 100644 --- a/level_3/fss_write/c/main/main.c +++ b/level_3/fss_write/c/main/main.c @@ -12,11 +12,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { fll_program_data_t data = fll_program_data_t_initialize; fss_write_setting_t setting = fss_write_setting_t_initialize; setting.state.data = (void *) &data; - - // Default to Basic. - setting.process_help = &fss_write_main_process_help; - setting.process_pipe = &fss_write_basic_process_pipe; - setting.process_normal = &fss_write_basic_process_normal; + setting.program_name = &fss_write_program_name_s; + setting.program_name_long = &fss_write_program_name_long_s; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.parameters.array = parameters; @@ -32,7 +29,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); + fss_write_setting_load(arguments, &data, &setting, &fss_write_main_setting_load_as); } fss_write_main(&data, &setting); @@ -66,9 +63,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { 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); + 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); @@ -117,3 +116,117 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_file_stream_unlock(main->message.to); } #endif // _di_fss_write_main_process_help_ + +#ifndef _di_fss_write_main_setting_load_as_ + void fss_write_main_setting_load_as(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting) { + + if (!main || !setting || F_status_is_error(setting->status) || (setting->flag & fss_write_main_flag_version_e)) return; + + setting->program_name = &fss_write_program_name_s; + setting->program_name_long = &fss_write_program_name_long_s; + setting->process_help = &fss_write_main_process_help; + setting->process_pipe = &fss_write_basic_process_pipe; + setting->process_normal = &fss_write_basic_process_normal; + + if (main->parameters.array[fss_write_parameter_as_e].result & f_console_result_value_e && main->parameters.array[fss_write_parameter_as_e].values.used) { + + f_array_length_t index = 0; + f_string_static_t *argv = main->parameters.arguments.array; + + for (f_array_length_t i = 0; i < main->parameters.array[fss_write_parameter_as_e].values.used; ++i) { + + index = main->parameters.array[fss_write_parameter_as_e].values.array[i]; + + if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0000_s) == F_equal_to || + fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0000_s) == F_equal_to || + fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0000_s) == F_equal_to) { + + setting->program_name = &fss_write_basic_program_name_s; + setting->program_name_long = &fss_write_basic_program_name_long_s; + setting->process_help = &fss_write_basic_process_help; + setting->process_pipe = &fss_write_basic_process_pipe; + 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) { + + setting->program_name = &fss_write_extended_program_name_s; + setting->program_name_long = &fss_write_extended_program_name_long_s; + setting->process_help = &fss_write_extended_process_help; + setting->process_pipe = &fss_write_extended_process_pipe; + 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) { + + setting->program_name = &fss_write_basic_list_program_name_s; + setting->program_name_long = &fss_write_basic_list_program_name_long_s; + setting->process_help = &fss_write_basic_list_process_help; + setting->process_pipe = &fss_write_basic_list_process_pipe; + 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) { + + setting->program_name = &fss_write_extended_list_program_name_s; + setting->program_name_long = &fss_write_extended_list_program_name_long_s; + setting->process_help = &fss_write_extended_list_process_help; + setting->process_pipe = &fss_write_extended_list_process_pipe; + 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) { + + setting->program_name = &fss_write_embedded_list_program_name_s; + setting->program_name_long = &fss_write_embedded_list_program_name_long_s; + setting->process_help = &fss_write_embedded_list_process_help; + setting->process_pipe = &fss_write_embedded_list_process_pipe; + 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) { + + setting->program_name = &fss_write_payload_program_name_s; + setting->program_name_long = &fss_write_payload_program_name_long_s; + setting->process_help = &fss_write_payload_process_help; + setting->process_pipe = &fss_write_payload_process_pipe; + setting->process_normal = &fss_write_payload_process_normal; + + } + else { + // @todo print error + + setting->status = F_status_set_error(F_parameter); + } + } // for + + if (F_status_is_error(setting->status)) { + if (setting->flag & fss_write_main_flag_help_e) { + fss_write_main_process_help(main, setting); + } + + return; + } + } + else if (main->parameters.array[fss_write_parameter_as_e].result & f_console_result_found_e) { + setting->status = F_status_set_error(F_parameter); + + if (setting->flag & fss_write_main_flag_help_e) { + fss_write_main_process_help(main, setting); + + return; + } + + fss_write_print_line_first_locked(setting, main->error); + fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_write_long_as_s); + fss_write_print_line_last_locked(setting, main->error); + + return; + } + } +#endif // _di_fss_write_main_setting_load_as_ diff --git a/level_3/fss_write/c/main/main.h b/level_3/fss_write/c/main/main.h index a4b3d5d..0025bda 100644 --- a/level_3/fss_write/c/main/main.h +++ b/level_3/fss_write/c/main/main.h @@ -35,6 +35,52 @@ extern "C" { extern void fss_write_main_process_help(fll_program_data_t * const main, void * const setting); #endif // _di_fss_write_main_process_help_ +/** + * 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. + * + * @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. + * + * This alters setting.status: + * F_none on success. + * F_data_not on success but nothing was provided to operate with. + * + * Errors (with error bit) from: f_console_parameter_process(). + * Errors (with error bit) from: f_file_stream_open(). + * Errors (with error bit) from: f_string_dynamics_resize(). + * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_verbosity(). + * + * @see f_console_parameter_process() + * @see f_file_stream_open() + * @see f_string_dynamics_resize() + * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_verbosity() + * + * @see fss_write_setting_load() + */ +#ifndef _di_fss_write_main_setting_load_as_ + extern void fss_write_main_setting_load_as(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting); +#endif // _di_fss_write_main_setting_load_as_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_write/c/main/print.c b/level_3/fss_write/c/main/print.c index 8b29731..10d656e 100644 --- a/level_3/fss_write/c/main/print.c +++ b/level_3/fss_write/c/main/print.c @@ -118,6 +118,19 @@ extern "C" { } #endif // _di_fss_write_print_help_ +#ifndef _di_fss_write_print_help_pipe_ + void fss_write_print_help_pipe(fss_write_setting_t * const setting, const fl_print_t print) { + + fl_print_format("%r The pipe uses the Backspace character '%[\\b%]' (%[U+0008%]) to designate the start of a Content.%r", print.to, f_string_eol_s, print.set->notable, print.set->notable, print.set->notable, print.set->notable, f_string_eol_s); + fl_print_format(" The pipe uses the Form Feed character '%[\\f%]' (%[U+000C%]) to designate the end of the last Content.%r", print.to, print.set->notable, print.set->notable, print.set->notable, print.set->notable, f_string_eol_s); + fl_print_format(" The pipe uses the Vertical Line character '%[\\v%]' (%[U+000B%]) is used to ignore a Content range (use this both before and after the range).%r", print.to, print.set->notable, print.set->notable, print.set->notable, print.set->notable, f_string_eol_s); + fl_print_format(" For the pipe, an Object is terminated by either a Backspace character '%[\\b%]' (%[U+0008%])", print.to, print.set->notable, print.set->notable, print.set->notable, print.set->notable); + fl_print_format(" or a Form Feed character '%[\\f%]' (%[U+000C%]).%r", print.to, print.set->notable, print.set->notable, print.set->notable, print.set->notable, f_string_eol_s); + fl_print_format(" The end of the pipe represents the end of any Object or Content.%r", print.to, f_string_eol_s); + + } +#endif // _di_fss_write_print_help_pipe_ + #ifndef _di_fss_write_print_line_first_locked_ f_status_t fss_write_print_line_first_locked(fss_write_setting_t * const setting, const fl_print_t print) { diff --git a/level_3/fss_write/c/main/print.h b/level_3/fss_write/c/main/print.h index f87a8bc..54ae87c 100644 --- a/level_3/fss_write/c/main/print.h +++ b/level_3/fss_write/c/main/print.h @@ -154,6 +154,22 @@ extern "C" { #endif // _di_fss_write_print_help_ /** + * Print standard parts of the help regarding pipe usage. + * + * This is expected to be called as part of the help printing and does not perform any locking. + * + * @param setting + * The main program settings. + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + */ +#ifndef _di_fss_write_print_help_pipe_ + extern void fss_write_print_help_pipe(fss_write_setting_t * const setting, const fl_print_t print); +#endif // _di_fss_write_print_help_pipe_ + +/** * Print first new line, unless verbosity says otherwise. * * This is generally either the first line in the program or the first line printed before an error message. diff --git a/level_3/fss_write/c/payload/common.c b/level_3/fss_write/c/payload/common.c index 54bb78c..88e7991 100644 --- a/level_3/fss_write/c/payload/common.c +++ b/level_3/fss_write/c/payload/common.c @@ -7,6 +7,9 @@ extern "C" { #ifndef _di_fss_write_payload_strings_ 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); + const f_string_static_t fss_write_payload_program_name_long_s = macro_f_string_static_t_initialize(FSS_WRITE_payload_program_name_long_s, 0, FSS_WRITE_payload_program_name_long_s_length); + const f_string_static_t fss_write_format_code_short_000e_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_short_000e_s, 0, FSS_WRITE_format_code_short_000e_s_length); const f_string_static_t fss_write_format_code_long_000e_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_long_000e_s, 0, FSS_WRITE_format_code_long_000e_s_length); 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); diff --git a/level_3/fss_write/c/payload/common.h b/level_3/fss_write/c/payload/common.h index afccfc6..46ded67 100644 --- a/level_3/fss_write/c/payload/common.h +++ b/level_3/fss_write/c/payload/common.h @@ -22,18 +22,27 @@ extern "C" { #ifndef _di_fss_write_payload_strings_ #define FSS_WRITE_payload_standard_s "FSS-000E (Payload)" + #define FSS_WRITE_payload_program_name_s "fss_payload_write" + #define FSS_WRITE_payload_program_name_long_s "FSS Payload Write" + #define FSS_WRITE_format_code_short_000e_s "000e" #define FSS_WRITE_format_code_long_000e_s "fss-000e" #define FSS_WRITE_format_code_human_000e_s "payload" #define FSS_WRITE_payload_standard_s_length 18 + #define FSS_WRITE_payload_program_name_s_length 17 + #define FSS_WRITE_payload_program_name_long_s_length 17 + #define FSS_WRITE_format_code_short_000e_s_length 4 #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_standard_s; + extern const f_string_static_t fss_write_payload_program_name_s; + extern const f_string_static_t fss_write_payload_program_name_long_s; + extern const f_string_static_t fss_write_format_code_short_000e_s; extern const f_string_static_t fss_write_format_code_long_000e_s; extern const f_string_static_t fss_write_format_code_human_000e_s; diff --git a/level_3/fss_write/c/payload/main.c b/level_3/fss_write/c/payload/main.c index bfd6074..6aea424 100644 --- a/level_3/fss_write/c/payload/main.c +++ b/level_3/fss_write/c/payload/main.c @@ -8,6 +8,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { setting.process_help = &fss_write_payload_process_help; setting.process_pipe = &fss_write_payload_process_pipe; setting.process_normal = &fss_write_payload_process_normal; + setting.program_name = &fss_write_payload_program_name_s; + setting.program_name_long = &fss_write_payload_program_name_long_s; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.parameters.array = parameters; @@ -24,7 +26,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); + fss_write_setting_load(arguments, &data, &setting, 0); } 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 1421d22..8aaec23 100644 --- a/level_3/fss_write/c/payload/print.c +++ b/level_3/fss_write/c/payload/print.c @@ -12,22 +12,17 @@ extern "C" { 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); + fll_program_print_help_header(print, setting->program_name_long ? *setting->program_name_long : fss_write_program_name_long_s, fss_write_program_version_s); fss_write_print_help(setting, print); 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); + fll_program_print_help_usage(print, setting->program_name ? *setting->program_name : fss_write_program_name_s, f_string_empty_s); - fl_print_format("%r The pipe uses the Backspace character '%[\\b%]' (%[U+0008%]) to designate the start of a Content.%r", print.to, f_string_eol_s, print.set->notable, print.set->notable, print.set->notable, print.set->notable, f_string_eol_s); - fl_print_format(" The pipe uses the Form Feed character '%[\\f%]' (%[U+000C%]) to designate the end of the last Content.%r", print.to, print.set->notable, print.set->notable, print.set->notable, print.set->notable, f_string_eol_s); - fl_print_format(" The pipe uses the Vertical Line character '%[\\v%]' (%[U+000B%]) is used to ignore a Content range, which does nothing in this program.%r", print.to, print.set->notable, print.set->notable, print.set->notable, print.set->notable, f_string_eol_s); - fl_print_format(" For the pipe, an Object is terminated by either a Backspace character '%[\\b%]' (%[U+0008%])", print.to, print.set->notable, print.set->notable, print.set->notable, print.set->notable); - fl_print_format(" or a Form Feed character '%[\\f%]' (%[U+000C%]).%r", print.to, print.set->notable, print.set->notable, print.set->notable, print.set->notable, f_string_eol_s); - fl_print_format(" The end of the pipe represents the end of any Object or Content.%r%r", print.to, f_string_eol_s, f_string_eol_s); + fss_write_print_help_pipe(setting, print); - fl_print_format(" The FSS-000E (Payload) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print.set->notable); + fl_print_format("%r The FSS-000E (Payload) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print.set->notable); fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_double_s, print.set->notable, f_string_eol_s, f_string_eol_s); fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print.set->notable, f_string_eol_s); diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index 842b0c1..1433f8a 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -14,7 +14,7 @@ extern "C" { setting->status = F_none; if (setting->flag & iki_read_main_flag_help_e) { - iki_read_print_help(setting, main->message); + iki_read_print_help(main, setting, main->message); return; } diff --git a/level_3/iki_write/c/common.c b/level_3/iki_write/c/common.c index 74b6b67..a4746bf 100644 --- a/level_3/iki_write/c/common.c +++ b/level_3/iki_write/c/common.c @@ -115,24 +115,24 @@ extern "C" { return; } } - - if (main->parameters.array[iki_write_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= iki_write_main_flag_help_e; - - return; - } - - if (main->parameters.array[iki_write_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= iki_write_main_flag_version_e; - - return; - } } main->output.to.id = F_type_descriptor_output_d; main->output.to.stream = F_type_output_d; main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + if (main->parameters.array[iki_write_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= iki_write_main_flag_help_e; + + return; + } + + if (main->parameters.array[iki_write_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= iki_write_main_flag_version_e; + + return; + } + if (main->parameters.array[iki_write_parameter_file_e].result & f_console_result_value_e && main->parameters.array[iki_write_parameter_file_e].values.used) { if (main->parameters.array[iki_write_parameter_file_e].values.used > 1) { setting->status = F_status_set_error(F_parameter); diff --git a/level_3/utf8/c/common.c b/level_3/utf8/c/common.c index a6e0cca..4ee5260 100644 --- a/level_3/utf8/c/common.c +++ b/level_3/utf8/c/common.c @@ -155,18 +155,6 @@ extern "C" { } } - if (main->parameters.array[utf8_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= utf8_main_flag_help_e; - - return; - } - - if (main->parameters.array[utf8_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= utf8_main_flag_version_e; - - return; - } - // Identify and prioritize "from" mode parameters. { uint16_t choices_array[2] = { utf8_parameter_from_bytesequence_e, utf8_parameter_from_codepoint_e }; @@ -277,6 +265,18 @@ extern "C" { } } + if (main->parameters.array[utf8_parameter_help_e].result & f_console_result_found_e) { + setting->flag |= utf8_main_flag_help_e; + + return; + } + + if (main->parameters.array[utf8_parameter_version_e].result & f_console_result_found_e) { + setting->flag |= utf8_main_flag_version_e; + + return; + } + if (main->parameters.array[utf8_parameter_to_file_e].result & f_console_result_value_e) { if (main->parameters.array[utf8_parameter_to_file_e].values.used > 1) { setting->status = F_status_set_error(F_parameter); -- 1.8.3.1