From af4cbf0ad71bd61209e3d2d0c7aaeeb040e61c72 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 26 Jan 2023 23:34:09 -0600 Subject: [PATCH] Feature: Provide program parameter for displaying copyright. Provide copyright printing that can be slighty fine tuned using verbosity. Provide a define (_di_detailed_copyright_) for reducing some of the string printed. --- level_0/f_console/c/console/common.c | 2 + level_0/f_console/c/console/common.h | 17 ++++-- level_3/byte_dump/c/byte_dump.c | 55 ++++++++++++++---- level_3/byte_dump/c/byte_dump.h | 16 ++++++ level_3/byte_dump/c/common.h | 4 +- level_3/byte_dump/data/build/defines | 2 + level_3/control/c/common.h | 4 +- level_3/control/c/control.c | 34 ++++++++++- level_3/control/c/control.h | 16 ++++++ level_3/control/data/build/defines | 2 + level_3/controller/c/common.h | 4 +- level_3/controller/c/controller.c | 38 +++++++++++-- level_3/controller/c/controller.h | 16 ++++++ level_3/controller/data/build/defines | 2 + level_3/fake/c/common.h | 4 +- level_3/fake/c/fake.c | 51 +++++++++++++---- level_3/fake/c/fake.h | 16 ++++++ level_3/fake/data/build/defines | 2 + level_3/firewall/c/common.h | 4 +- level_3/firewall/c/firewall.c | 65 ++++++++++++++++------ level_3/firewall/c/firewall.h | 16 ++++++ level_3/firewall/data/build/defines | 2 + level_3/fss_basic_list_read/c/common.h | 4 +- .../fss_basic_list_read/c/fss_basic_list_read.c | 59 +++++++++++++++----- .../fss_basic_list_read/c/fss_basic_list_read.h | 16 ++++++ level_3/fss_basic_list_read/data/build/defines | 1 + level_3/fss_basic_list_write/c/common.h | 4 +- .../fss_basic_list_write/c/fss_basic_list_write.c | 63 +++++++++++++++------ .../fss_basic_list_write/c/fss_basic_list_write.h | 16 ++++++ level_3/fss_basic_list_write/data/build/defines | 1 + level_3/fss_basic_read/c/common.h | 2 + level_3/fss_basic_read/c/fss_basic_read.c | 59 +++++++++++++++----- level_3/fss_basic_read/c/fss_basic_read.h | 16 ++++++ level_3/fss_basic_read/data/build/defines | 1 + level_3/fss_basic_write/c/common.h | 4 +- level_3/fss_basic_write/c/fss_basic_write.c | 63 +++++++++++++++------ level_3/fss_basic_write/c/fss_basic_write.h | 16 ++++++ level_3/fss_basic_write/data/build/defines | 1 + level_3/fss_embedded_list_read/c/common.h | 4 +- .../c/fss_embedded_list_read.c | 65 +++++++++++++++------- .../c/fss_embedded_list_read.h | 16 ++++++ level_3/fss_embedded_list_read/data/build/defines | 1 + level_3/fss_embedded_list_write/c/common.h | 4 +- .../c/fss_embedded_list_write.c | 63 +++++++++++++++------ .../c/fss_embedded_list_write.h | 16 ++++++ level_3/fss_embedded_list_write/data/build/defines | 1 + level_3/fss_extended_list_read/c/common.h | 4 +- .../c/fss_extended_list_read.c | 59 +++++++++++++++----- .../c/fss_extended_list_read.h | 16 ++++++ level_3/fss_extended_list_read/data/build/defines | 1 + level_3/fss_extended_list_write/c/common.h | 4 +- .../c/fss_extended_list_write.c | 63 +++++++++++++++------ .../c/fss_extended_list_write.h | 16 ++++++ level_3/fss_extended_list_write/data/build/defines | 1 + level_3/fss_extended_read/c/common.h | 4 +- level_3/fss_extended_read/c/fss_extended_read.c | 59 +++++++++++++++----- level_3/fss_extended_read/c/fss_extended_read.h | 16 ++++++ level_3/fss_extended_read/data/build/defines | 1 + level_3/fss_extended_write/c/common.h | 4 +- level_3/fss_extended_write/c/fss_extended_write.c | 63 +++++++++++++++------ level_3/fss_extended_write/c/fss_extended_write.h | 16 ++++++ level_3/fss_extended_write/data/build/defines | 1 + level_3/fss_identify/c/common.h | 4 +- level_3/fss_identify/c/fss_identify.c | 55 ++++++++++++++---- level_3/fss_identify/c/fss_identify.h | 16 ++++++ level_3/fss_identify/data/build/defines | 1 + level_3/fss_payload_read/c/common.h | 4 +- level_3/fss_payload_read/c/fss_payload_read.c | 59 +++++++++++++++----- level_3/fss_payload_read/c/fss_payload_read.h | 16 ++++++ level_3/fss_payload_read/data/build/defines | 1 + level_3/fss_payload_write/c/common.h | 4 +- level_3/fss_payload_write/c/fss_payload_write.c | 63 +++++++++++++++------ level_3/fss_payload_write/c/fss_payload_write.h | 16 ++++++ level_3/fss_payload_write/data/build/defines | 1 + level_3/fss_status_code/c/common.h | 4 +- level_3/fss_status_code/c/fss_status_code.c | 59 +++++++++++++++----- level_3/fss_status_code/c/fss_status_code.h | 16 ++++++ level_3/fss_status_code/data/build/defines | 1 + level_3/iki_read/c/common.h | 4 +- level_3/iki_read/c/iki_read.c | 65 +++++++++++++++------- level_3/iki_read/c/iki_read.h | 16 ++++++ level_3/iki_read/data/build/defines | 1 + level_3/iki_write/c/common.h | 4 +- level_3/iki_write/c/iki_write.c | 65 +++++++++++++++------- level_3/iki_write/c/iki_write.h | 16 ++++++ level_3/iki_write/data/build/defines | 1 + level_3/status_code/c/common.h | 4 +- level_3/status_code/c/status_code.c | 55 ++++++++++++++---- level_3/status_code/data/build/defines | 1 + level_3/utf8/c/common.h | 4 +- level_3/utf8/c/utf8.c | 59 +++++++++++++++----- level_3/utf8/c/utf8.h | 16 ++++++ level_3/utf8/data/build/defines | 1 + 93 files changed, 1482 insertions(+), 346 deletions(-) diff --git a/level_0/f_console/c/console/common.c b/level_0/f_console/c/console/common.c index 850cdc0..266459b 100644 --- a/level_0/f_console/c/console/common.c +++ b/level_0/f_console/c/console/common.c @@ -5,6 +5,7 @@ extern "C" { #endif #ifndef _di_f_console_standard_s_ + const f_string_static_t f_console_standard_short_copyright_s = macro_f_string_static_t_initialize((f_string_t) F_console_standard_short_copyright_s, 0, F_console_standard_short_copyright_s_length); const f_string_static_t f_console_standard_short_dark_s = macro_f_string_static_t_initialize((f_string_t) F_console_standard_short_dark_s, 0, F_console_standard_short_dark_s_length); const f_string_static_t f_console_standard_short_debug_s = macro_f_string_static_t_initialize((f_string_t) F_console_standard_short_debug_s, 0, F_console_standard_short_debug_s_length); const f_string_static_t f_console_standard_short_error_s = macro_f_string_static_t_initialize((f_string_t) F_console_standard_short_error_s, 0, F_console_standard_short_error_s_length); @@ -18,6 +19,7 @@ extern "C" { const f_string_static_t f_console_standard_short_verbose_s = macro_f_string_static_t_initialize((f_string_t) F_console_standard_short_verbose_s, 0, F_console_standard_short_verbose_s_length); const f_string_static_t f_console_standard_short_version_s = macro_f_string_static_t_initialize((f_string_t) F_console_standard_short_version_s, 0, F_console_standard_short_version_s_length); + const f_string_static_t f_console_standard_long_copyright_s = macro_f_string_static_t_initialize((f_string_t) F_console_standard_long_copyright_s, 0, F_console_standard_long_copyright_s_length); const f_string_static_t f_console_standard_long_dark_s = macro_f_string_static_t_initialize((f_string_t) F_console_standard_long_dark_s, 0, F_console_standard_long_dark_s_length); const f_string_static_t f_console_standard_long_debug_s = macro_f_string_static_t_initialize((f_string_t) F_console_standard_long_debug_s, 0, F_console_standard_long_debug_s_length); const f_string_static_t f_console_standard_long_error_s = macro_f_string_static_t_initialize((f_string_t) F_console_standard_long_error_s, 0, F_console_standard_long_error_s_length); diff --git a/level_0/f_console/c/console/common.h b/level_0/f_console/c/console/common.h index 13cd1a6..9765fc8 100644 --- a/level_0/f_console/c/console/common.h +++ b/level_0/f_console/c/console/common.h @@ -92,11 +92,12 @@ extern "C" { * - verbose: Increase verbosity, print more, in some use cases this could mean printing just about everything. * * The following are less subjective in interpretation but do allow some flexibility. - * - dark: Do display color intended for dark backgrounds (often the default behavior) when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.) - * - help: Display the help text. This does not define how the text is displayed only that the text is displayed. - * - light: Do display color intended for light backgrounds when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.) - * - no_color: Do not display color when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.) - * - version: Should always print only the version number, no colors, but what represents the version number is undefined by this project. + * - copyright: Display copyright, if compiled in (consider combining with quiet, verbose, and normal). + * - dark: Do display color intended for dark backgrounds (often the default behavior) when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.) + * - help: Display the help text. This does not define how the text is displayed only that the text is displayed. + * - light: Do display color intended for light backgrounds when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.) + * - no_color: Do not display color when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.) + * - version: Should always print only the version number, no colors, but what represents the version number is undefined by this project. * * The following options are for special purposes: * - status_in: Is intended to accept the name of an environment variable in which to read the status from. @@ -108,6 +109,7 @@ extern "C" { * - To avoid problems with the status code after a program is forcibly killed, the status_out environment variable should be cleared at program start. */ #ifndef _di_f_console_standard_s_ + #define F_console_standard_short_copyright_s "C" #define F_console_standard_short_dark_s "d" #define F_console_standard_short_debug_s "D" #define F_console_standard_short_error_s "E" @@ -121,6 +123,7 @@ extern "C" { #define F_console_standard_short_verbose_s "V" #define F_console_standard_short_version_s "v" + #define F_console_standard_short_copyright_s_length 1 #define F_console_standard_short_dark_s_length 1 #define F_console_standard_short_debug_s_length 1 #define F_console_standard_short_error_s_length 1 @@ -134,6 +137,7 @@ extern "C" { #define F_console_standard_short_verbose_s_length 1 #define F_console_standard_short_version_s_length 1 + #define F_console_standard_long_copyright_s "copyright" #define F_console_standard_long_dark_s "dark" #define F_console_standard_long_debug_s "debug" #define F_console_standard_long_error_s "error" @@ -147,6 +151,7 @@ extern "C" { #define F_console_standard_long_verbose_s "verbose" #define F_console_standard_long_version_s "version" + #define F_console_standard_long_copyright_s_length 9 #define F_console_standard_long_dark_s_length 4 #define F_console_standard_long_debug_s_length 5 #define F_console_standard_long_error_s_length 5 @@ -160,6 +165,7 @@ extern "C" { #define F_console_standard_long_verbose_s_length 7 #define F_console_standard_long_version_s_length 7 + extern const f_string_static_t f_console_standard_short_copyright_s; extern const f_string_static_t f_console_standard_short_dark_s; extern const f_string_static_t f_console_standard_short_debug_s; extern const f_string_static_t f_console_standard_short_error_s; @@ -173,6 +179,7 @@ extern "C" { extern const f_string_static_t f_console_standard_short_verbose_s; extern const f_string_static_t f_console_standard_short_version_s; + extern const f_string_static_t f_console_standard_long_copyright_s; extern const f_string_static_t f_console_standard_long_dark_s; extern const f_string_static_t f_console_standard_long_debug_s; extern const f_string_static_t f_console_standard_long_error_s; diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index d67a8d5..92c911d 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -6,6 +6,30 @@ extern "C" { #endif +#ifndef _di_byte_dump_print_copyright_ + f_status_t byte_dump_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_byte_dump_print_copyright_ + #ifndef _di_byte_dump_print_help_ f_status_t byte_dump_print_help(const f_file_t file, const f_color_context_t context) { @@ -13,16 +37,17 @@ extern "C" { fll_program_print_help_header(file, context, byte_dump_program_name_long_s, byte_dump_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -238,8 +263,6 @@ extern "C" { } } - status = F_none; - if (main->parameters.array[byte_dump_parameter_help_e].result == f_console_result_found_e) { byte_dump_print_help(main->output.to, main->context); @@ -252,6 +275,14 @@ extern "C" { return F_none; } + if (main->parameters.array[byte_dump_parameter_copyright_e].result == f_console_result_found_e) { + byte_dump_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + if (main->parameters.remaining.used || main->process_pipe) { if (main->parameters.array[byte_dump_parameter_width_e].result == f_console_result_found_e) { flockfile(main->error.to.stream); diff --git a/level_3/byte_dump/c/byte_dump.h b/level_3/byte_dump/c/byte_dump.h index b520e67..62bddff 100644 --- a/level_3/byte_dump/c/byte_dump.h +++ b/level_3/byte_dump/c/byte_dump.h @@ -54,6 +54,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_byte_dump_print_copyright_ + extern f_status_t byte_dump_print_copyright(const f_file_t file, const bool detail); +#endif // _di_byte_dump_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/byte_dump/c/common.h b/level_3/byte_dump/c/common.h index 266cc52..84fbde1 100644 --- a/level_3/byte_dump/c/common.h +++ b/level_3/byte_dump/c/common.h @@ -274,6 +274,7 @@ extern "C" { enum { byte_dump_parameter_help_e, + byte_dump_parameter_copyright_e, byte_dump_parameter_light_e, byte_dump_parameter_dark_e, byte_dump_parameter_no_color_e, @@ -308,6 +309,7 @@ extern "C" { #define byte_dump_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -335,7 +337,7 @@ extern "C" { macro_f_console_parameter_t_initialize(0, byte_dump_long_classic_s.string, 0, 0, f_console_type_normal_e), \ } - #define byte_dump_total_parameters_d 26 + #define byte_dump_total_parameters_d 27 #endif // _di_byte_dump_parameters_ #ifdef __cplusplus diff --git a/level_3/byte_dump/data/build/defines b/level_3/byte_dump/data/build/defines index c665317..5732619 100644 --- a/level_3/byte_dump/data/build/defines +++ b/level_3/byte_dump/data/build/defines @@ -1,2 +1,4 @@ # fss-0000 +_di_byte_dump_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/control/c/common.h b/level_3/control/c/common.h index 2ee3a13..e4f9775 100644 --- a/level_3/control/c/common.h +++ b/level_3/control/c/common.h @@ -95,6 +95,7 @@ extern "C" { enum { control_parameter_help_e = 0, + control_parameter_copyright_e, control_parameter_light_e, control_parameter_dark_e, control_parameter_no_color_e, @@ -114,6 +115,7 @@ extern "C" { #define control_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -129,7 +131,7 @@ extern "C" { macro_f_console_parameter_t_initialize(control_short_socket_s.string, control_long_socket_s.string, 0, 1, f_console_type_normal_e), \ } - #define control_total_parameters_d 14 + #define control_total_parameters_d 15 #endif // _di_control_parameters_ /** diff --git a/level_3/control/c/control.c b/level_3/control/c/control.c index 5b57bcd..883de1b 100644 --- a/level_3/control/c/control.c +++ b/level_3/control/c/control.c @@ -7,6 +7,30 @@ extern "C" { #endif +#ifndef _di_control_print_copyright_ + f_status_t control_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_control_print_copyright_ + #ifndef _di_control_print_help_ f_status_t control_print_help(const fll_program_data_t * const main) { @@ -135,8 +159,6 @@ extern "C" { } } - status = F_none; - if (main->parameters.array[control_parameter_help_e].result == f_console_result_found_e) { control_print_help(main); @@ -149,6 +171,14 @@ extern "C" { return F_none; } + if (main->parameters.array[control_parameter_copyright_e].result == f_console_result_found_e) { + control_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + { uint8_t ids[] = { control_parameter_name_e, diff --git a/level_3/control/c/control.h b/level_3/control/c/control.h index 2d4f23a..d189232 100644 --- a/level_3/control/c/control.h +++ b/level_3/control/c/control.h @@ -58,6 +58,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_control_print_copyright_ + extern f_status_t control_print_copyright(const f_file_t file, const bool detail); +#endif // _di_control_print_copyright_ + +/** * Print help. * * @param main diff --git a/level_3/control/data/build/defines b/level_3/control/data/build/defines index d44a0de..d3a32fd 100644 --- a/level_3/control/data/build/defines +++ b/level_3/control/data/build/defines @@ -1,5 +1,7 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). + _controller_as_init_ The controller program is compiled as an init replacement and this control program should treat it as such. _override_controller_name_socket_ Use this as the default custom file name representing the controller program socket. _override_controller_name_socket_length_ The number of bytes representing the string in _override_controller_name_socket_ (not including the terminating NULL). diff --git a/level_3/controller/c/common.h b/level_3/controller/c/common.h index 2c30750..cc2871e 100644 --- a/level_3/controller/c/common.h +++ b/level_3/controller/c/common.h @@ -117,6 +117,7 @@ extern "C" { enum { controller_parameter_help_e, + controller_parameter_copyright_e, controller_parameter_light_e, controller_parameter_dark_e, controller_parameter_no_color_e, @@ -142,6 +143,7 @@ extern "C" { #define controller_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -163,7 +165,7 @@ extern "C" { macro_f_console_parameter_t_initialize(controller_short_validate_s.string, controller_long_validate_s.string, 0, 0, f_console_type_normal_e), \ } - #define controller_total_parameters_d 20 + #define controller_total_parameters_d 21 #endif // _di_controller_parameters_ /** diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index a88cda6..9c1852d 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -12,6 +12,30 @@ extern "C" { #endif +#ifndef _di_controller_print_copyright_ + f_status_t controller_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_controller_print_copyright_ + #ifndef _di_controller_print_help_ f_status_t controller_print_help(controller_main_t * const main) { @@ -143,10 +167,6 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - - status = F_none; - if (main->parameters.array[controller_parameter_help_e].result == f_console_result_found_e) { controller_print_help(main); @@ -163,6 +183,16 @@ extern "C" { return F_none; } + if (main->parameters.array[controller_parameter_copyright_e].result == f_console_result_found_e) { + controller_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + + f_string_static_t * const argv = main->parameters.arguments.array; + controller_setting_t setting = controller_setting_t_initialize; setting.control.server.address = (struct sockaddr *) &setting.control.address; diff --git a/level_3/controller/c/controller.h b/level_3/controller/c/controller.h index 69c5971..7ac95ea 100644 --- a/level_3/controller/c/controller.h +++ b/level_3/controller/c/controller.h @@ -84,6 +84,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_controller_print_copyright_ + extern f_status_t controller_print_copyright(const f_file_t file, const bool detail); +#endif // _di_controller_print_copyright_ + +/** * Print help. * * @param main diff --git a/level_3/controller/data/build/defines b/level_3/controller/data/build/defines index 63c654f..0658605 100644 --- a/level_3/controller/data/build/defines +++ b/level_3/controller/data/build/defines @@ -1,6 +1,8 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). _di_libcap_ Disable libcap support, allow for compiling and linking without libcap (-lcap). + _libcap_legacy_only_ Disable functionality provided by later versions of libcap (2.43 and later). _controller_as_init_ Build the program to run as if it were "init" by default, including displaying the program name as "Init Program" or "Init". This changes the main.c file only, leaving the library shareable between both "controller" and "init". _override_controller_default_engine_ Provide a custom scripting engine name string to execute (such as php). diff --git a/level_3/fake/c/common.h b/level_3/fake/c/common.h index 41ef1ac..ba6a0ed 100644 --- a/level_3/fake/c/common.h +++ b/level_3/fake/c/common.h @@ -379,6 +379,7 @@ extern "C" { enum { fake_parameter_help_e, + fake_parameter_copyright_e, fake_parameter_light_e, fake_parameter_dark_e, fake_parameter_no_color_e, @@ -416,6 +417,7 @@ extern "C" { #define fake_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -446,7 +448,7 @@ extern "C" { macro_f_console_parameter_t_initialize(0, 0, fake_other_operation_skeleton_s.string, 0, f_console_type_other_e), \ } - #define fake_total_parameters_d 29 + #define fake_total_parameters_d 30 #endif // _di_fake_parameters_ #ifdef __cplusplus diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index 3cda2f8..093e88b 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -13,6 +13,30 @@ extern "C" { #endif +#ifndef _di_fake_print_copyright_ + f_status_t fake_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fake_print_copyright_ + #ifndef _di_fake_print_help_ f_status_t fake_print_help(const f_file_t file, const f_color_context_t context) { @@ -20,16 +44,17 @@ extern "C" { fll_program_print_help_header(file, context, fake_program_name_long_s, fake_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -182,6 +207,12 @@ extern "C" { return F_none; } + if (main->parameters.array[fake_parameter_copyright_e].result == f_console_result_found_e) { + fake_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + status = F_none; fake_data_t data = fake_data_t_initialize; diff --git a/level_3/fake/c/fake.h b/level_3/fake/c/fake.h index d1be40a..2f25158 100644 --- a/level_3/fake/c/fake.h +++ b/level_3/fake/c/fake.h @@ -97,6 +97,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fake_print_copyright_ + extern f_status_t fake_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fake_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fake/data/build/defines b/level_3/fake/data/build/defines index 427a9c7..c2a9432 100644 --- a/level_3/fake/data/build/defines +++ b/level_3/fake/data/build/defines @@ -1,6 +1,8 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). _di_libcap_ Disable libcap support, allow for compiling and linking without libcap (-lcap). + _libcap_legacy_only_ Disable functionality provided by later versions of libcap (2.43 and later). _pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. _pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_3/firewall/c/common.h b/level_3/firewall/c/common.h index 708e1fe..3572c56 100644 --- a/level_3/firewall/c/common.h +++ b/level_3/firewall/c/common.h @@ -348,6 +348,7 @@ extern "C" { enum { firewall_parameter_help_e, + firewall_parameter_copyright_e, firewall_parameter_light_e, firewall_parameter_dark_e, firewall_parameter_no_color_e, @@ -385,6 +386,7 @@ extern "C" { #define firewall_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -401,7 +403,7 @@ extern "C" { macro_f_console_parameter_t_initialize(0, 0, firewall_command_show_s.string, 0, f_console_type_other_e), \ } - #define firewall_total_parameters_d 15 + #define firewall_total_parameters_d 16 #endif // _di_firewall_defines_ #ifdef __cplusplus diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index 49fa48c..9cf6efa 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -12,6 +12,30 @@ extern "C" { #endif +#ifndef _di_firewall_print_copyright_ + f_status_t firewall_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_firewall_print_copyright_ + #ifndef _di_firewall_print_help_ f_status_t firewall_print_help(const f_file_t file, const f_color_context_t context) { @@ -19,16 +43,17 @@ extern "C" { fll_program_print_help_header(file, context, firewall_program_name_long_s, firewall_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); fl_print_format("%r%r %[Commands:%] ", file.stream, f_string_eol_s, f_string_eol_s, context.set.important, context.set.important); fl_print_format("%r %[%r%] Turn on the firewall.", file.stream, f_string_eol_s, context.set.standout, firewall_command_start_s, context.set.standout); @@ -117,12 +142,6 @@ extern "C" { } } - firewall_data_t data = firewall_data_t_initialize; - data.main = main; - data.argv = main->parameters.arguments.array; - - status = F_none; - if (main->parameters.array[firewall_parameter_help_e].result == f_console_result_found_e) { firewall_print_help(main->output.to, main->context); @@ -135,7 +154,19 @@ extern "C" { return F_none; } - // now determine which command was placed first + if (main->parameters.array[firewall_parameter_copyright_e].result == f_console_result_found_e) { + firewall_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + + firewall_data_t data = firewall_data_t_initialize; + data.main = main; + data.argv = main->parameters.arguments.array; + + // Now determine which command was placed first bool found_command = F_false; unsigned int command = 0; diff --git a/level_3/firewall/c/firewall.h b/level_3/firewall/c/firewall.h index 13347f6..fc3273d 100644 --- a/level_3/firewall/c/firewall.h +++ b/level_3/firewall/c/firewall.h @@ -55,6 +55,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_firewall_print_copyright_ + extern f_status_t firewall_print_copyright(const f_file_t file, const bool detail); +#endif // _di_firewall_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/firewall/data/build/defines b/level_3/firewall/data/build/defines index 427a9c7..c2a9432 100644 --- a/level_3/firewall/data/build/defines +++ b/level_3/firewall/data/build/defines @@ -1,6 +1,8 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). _di_libcap_ Disable libcap support, allow for compiling and linking without libcap (-lcap). + _libcap_legacy_only_ Disable functionality provided by later versions of libcap (2.43 and later). _pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. _pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_3/fss_basic_list_read/c/common.h b/level_3/fss_basic_list_read/c/common.h index eac7eab..1e4b680 100644 --- a/level_3/fss_basic_list_read/c/common.h +++ b/level_3/fss_basic_list_read/c/common.h @@ -186,6 +186,7 @@ extern "C" { enum { fss_basic_list_read_parameter_help_e, + fss_basic_list_read_parameter_copyright_e, fss_basic_list_read_parameter_light_e, fss_basic_list_read_parameter_dark_e, fss_basic_list_read_parameter_no_color_e, @@ -215,6 +216,7 @@ extern "C" { #define fss_basic_list_read_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, F_false, f_console_type_inverse_e), \ @@ -240,7 +242,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_basic_list_read_short_trim_s.string, fss_basic_list_read_long_trim_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_basic_list_read_total_parameters_d 24 + #define fss_basic_list_read_total_parameters_d 25 #endif // _di_fss_basic_list_read_parameters_ /** diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index 4d801a0..de9a570 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -7,6 +7,30 @@ extern "C" { #endif +#ifndef _di_fss_basic_list_read_print_copyright_ + f_status_t fss_basic_list_read_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_basic_list_read_print_copyright_ + #ifndef _di_fss_basic_list_read_print_help_ f_status_t fss_basic_list_read_print_help(const f_file_t file, const f_color_context_t context) { @@ -14,16 +38,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_basic_list_read_program_name_long_s, fss_basic_list_read_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -193,20 +218,26 @@ extern "C" { } } - status = F_none; - if (main->parameters.array[fss_basic_list_read_parameter_help_e].result == f_console_result_found_e) { fss_basic_list_read_print_help(main->output.to, main->context); - return status; + return F_none; } if (main->parameters.array[fss_basic_list_read_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_basic_list_read_program_version_s); - return status; + return F_none; } + if (main->parameters.array[fss_basic_list_read_parameter_copyright_e].result == f_console_result_found_e) { + fss_basic_list_read_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + // Provide a range designating where within the buffer a particular file exists, using a statically allocated array. fss_basic_list_read_file_t files_array[main->parameters.remaining.used + 1]; fss_basic_list_read_data_t data = fss_basic_list_read_data_t_initialize; diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.h b/level_3/fss_basic_list_read/c/fss_basic_list_read.h index 001777a..85d8544 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.h +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.h @@ -55,6 +55,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_basic_list_read_print_copyright_ + extern f_status_t fss_basic_list_read_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_basic_list_read_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_basic_list_read/data/build/defines b/level_3/fss_basic_list_read/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_basic_list_read/data/build/defines +++ b/level_3/fss_basic_list_read/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_basic_list_write/c/common.h b/level_3/fss_basic_list_write/c/common.h index b56f61a..fba1fc6 100644 --- a/level_3/fss_basic_list_write/c/common.h +++ b/level_3/fss_basic_list_write/c/common.h @@ -156,6 +156,7 @@ extern "C" { enum { fss_basic_list_write_parameter_help_e, + fss_basic_list_write_parameter_copyright_e, fss_basic_list_write_parameter_light_e, fss_basic_list_write_parameter_dark_e, fss_basic_list_write_parameter_no_color_e, @@ -180,6 +181,7 @@ extern "C" { #define fss_basic_list_write_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, F_false, f_console_type_inverse_e), \ @@ -200,7 +202,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_basic_list_write_short_trim_s.string, fss_basic_list_write_long_trim_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_basic_list_write_total_parameters_d 19 + #define fss_basic_list_write_total_parameters_d 20 #endif // _di_fss_basic_list_write_parameters_ #ifdef __cplusplus diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.c b/level_3/fss_basic_list_write/c/fss_basic_list_write.c index 854cab1..f81fd53 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.c @@ -6,6 +6,30 @@ extern "C" { #endif +#ifndef _di_fss_basic_list_write_print_copyright_ + f_status_t fss_basic_list_write_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_basic_list_write_print_copyright_ + #ifndef _di_fss_basic_list_write_print_help_ f_status_t fss_basic_list_write_print_help(const f_file_t file, const f_color_context_t context) { @@ -13,16 +37,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_basic_list_write_program_name_long_s, fss_basic_list_write_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -132,22 +157,28 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - - status = F_none; - if (main->parameters.array[fss_basic_list_write_parameter_help_e].result == f_console_result_found_e) { fss_basic_list_write_print_help(main->output.to, main->context); - return status; + return F_none; } if (main->parameters.array[fss_basic_list_write_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_basic_list_write_program_version_s); - return status; + return F_none; } + if (main->parameters.array[fss_basic_list_write_parameter_copyright_e].result == f_console_result_found_e) { + fss_basic_list_write_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + f_string_static_t * const argv = main->parameters.arguments.array; + + status = F_none; + f_file_t output = f_file_t_initialize; output.id = F_type_descriptor_output_d; diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.h b/level_3/fss_basic_list_write/c/fss_basic_list_write.h index 320dbc3..a348176 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.h +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.h @@ -47,6 +47,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_basic_list_write_print_copyright_ + extern f_status_t fss_basic_list_write_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_basic_list_write_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_basic_list_write/data/build/defines b/level_3/fss_basic_list_write/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_basic_list_write/data/build/defines +++ b/level_3/fss_basic_list_write/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_basic_read/c/common.h b/level_3/fss_basic_read/c/common.h index 20db50c..3ba5dd4 100644 --- a/level_3/fss_basic_read/c/common.h +++ b/level_3/fss_basic_read/c/common.h @@ -186,6 +186,7 @@ extern "C" { enum { fss_basic_read_parameter_help_e, + fss_basic_read_parameter_copyright_e, fss_basic_read_parameter_light_e, fss_basic_read_parameter_dark_e, fss_basic_read_parameter_no_color_e, @@ -215,6 +216,7 @@ extern "C" { #define fss_basic_read_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 35d34a8..e0caf34 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -7,6 +7,30 @@ extern "C" { #endif +#ifndef _di_fss_basic_read_print_copyright_ + f_status_t fss_basic_read_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_basic_read_print_copyright_ + #ifndef _di_fss_basic_read_print_help_ f_status_t fss_basic_read_print_help(const f_file_t file, const f_color_context_t context) { @@ -14,16 +38,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_basic_read_program_name_long_s, fss_basic_read_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -193,20 +218,26 @@ extern "C" { } } - status = F_none; - if (main->parameters.array[fss_basic_read_parameter_help_e].result == f_console_result_found_e) { fss_basic_read_print_help(main->output.to, main->context); - return status; + return F_none; } if (main->parameters.array[fss_basic_read_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_basic_read_program_version_s); - return status; + return F_none; } + if (main->parameters.array[fss_basic_read_parameter_copyright_e].result == f_console_result_found_e) { + fss_basic_read_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + // Provide a range designating where within the buffer a particular file exists, using a statically allocated array. fss_basic_read_file_t files_array[main->parameters.remaining.used + 1]; fss_basic_read_data_t data = fss_basic_read_data_t_initialize; diff --git a/level_3/fss_basic_read/c/fss_basic_read.h b/level_3/fss_basic_read/c/fss_basic_read.h index 7031f31..d94a16c 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.h +++ b/level_3/fss_basic_read/c/fss_basic_read.h @@ -55,6 +55,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_basic_read_print_copyright_ + extern f_status_t fss_basic_read_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_basic_read_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_basic_read/data/build/defines b/level_3/fss_basic_read/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_basic_read/data/build/defines +++ b/level_3/fss_basic_read/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_basic_write/c/common.h b/level_3/fss_basic_write/c/common.h index 8735002..67eae29 100644 --- a/level_3/fss_basic_write/c/common.h +++ b/level_3/fss_basic_write/c/common.h @@ -156,6 +156,7 @@ extern "C" { enum { fss_basic_write_parameter_help_e, + fss_basic_write_parameter_copyright_e, fss_basic_write_parameter_light_e, fss_basic_write_parameter_dark_e, fss_basic_write_parameter_no_color_e, @@ -180,6 +181,7 @@ extern "C" { #define fss_basic_write_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -200,7 +202,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_basic_write_short_trim_s.string, fss_basic_write_long_trim_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_basic_write_total_parameters_d 18 + #define fss_basic_write_total_parameters_d 19 #endif // _di_fss_basic_write_parameters_ #ifdef __cplusplus diff --git a/level_3/fss_basic_write/c/fss_basic_write.c b/level_3/fss_basic_write/c/fss_basic_write.c index ea614c8..ee14bc4 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -6,6 +6,30 @@ extern "C" { #endif +#ifndef _di_fss_basic_write_print_copyright_ + f_status_t fss_basic_write_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_basic_write_print_copyright_ + #ifndef _di_fss_basic_write_print_help_ f_status_t fss_basic_write_print_help(const f_file_t file, const f_color_context_t context) { @@ -13,16 +37,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_basic_write_program_name_long_s, fss_basic_write_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -132,22 +157,28 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - - status = F_none; - if (main->parameters.array[fss_basic_write_parameter_help_e].result == f_console_result_found_e) { fss_basic_write_print_help(main->output.to, main->context); - return status; + return F_none; } if (main->parameters.array[fss_basic_write_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_basic_write_program_version_s); - return status; + return F_none; } + if (main->parameters.array[fss_basic_write_parameter_copyright_e].result == f_console_result_found_e) { + fss_basic_write_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + + f_string_static_t * const argv = main->parameters.arguments.array; + f_file_t output = f_file_t_initialize; output.id = F_type_descriptor_output_d; diff --git a/level_3/fss_basic_write/c/fss_basic_write.h b/level_3/fss_basic_write/c/fss_basic_write.h index 594f265..a0e6938 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.h +++ b/level_3/fss_basic_write/c/fss_basic_write.h @@ -48,6 +48,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_basic_write_print_copyright_ + extern f_status_t fss_basic_write_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_basic_write_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_basic_write/data/build/defines b/level_3/fss_basic_write/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_basic_write/data/build/defines +++ b/level_3/fss_basic_write/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_embedded_list_read/c/common.h b/level_3/fss_embedded_list_read/c/common.h index 207c086..91e6b46 100644 --- a/level_3/fss_embedded_list_read/c/common.h +++ b/level_3/fss_embedded_list_read/c/common.h @@ -186,6 +186,7 @@ extern "C" { enum { fss_embedded_list_read_parameter_help_e, + fss_embedded_list_read_parameter_copyright_e, fss_embedded_list_read_parameter_light_e, fss_embedded_list_read_parameter_dark_e, fss_embedded_list_read_parameter_no_color_e, @@ -215,6 +216,7 @@ extern "C" { #define fss_embedded_list_read_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -240,7 +242,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_embedded_list_read_short_trim_s.string, fss_embedded_list_read_long_trim_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_embedded_list_read_total_parameters_d 24 + #define fss_embedded_list_read_total_parameters_d 25 #endif // _di_fss_embedded_list_read_parameters_ /** diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c index 54b4c6c..31e883b 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c @@ -7,6 +7,30 @@ extern "C" { #endif +#ifndef _di_fss_embedded_list_read_print_copyright_ + f_status_t fss_embedded_list_read_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_embedded_list_read_print_copyright_ + #ifndef _di_fss_embedded_list_read_print_help_ f_status_t fss_embedded_list_read_print_help(const f_file_t file, const f_color_context_t context) { @@ -14,16 +38,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_embedded_list_read_program_name_long_s, fss_embedded_list_read_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -192,28 +217,30 @@ extern "C" { } } - fss_embedded_list_read_data_t data = fss_embedded_list_read_data_t_initialize; - data.main = main; - data.argv = main->parameters.arguments.array; - - status = F_none; - if (main->parameters.array[fss_embedded_list_read_parameter_help_e].result == f_console_result_found_e) { fss_embedded_list_read_print_help(main->output.to, main->context); - fss_embedded_list_read_data_delete(&data); - return F_none; } if (main->parameters.array[fss_embedded_list_read_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_embedded_list_read_program_version_s); - fss_embedded_list_read_data_delete(&data); + return F_none; + } + + if (main->parameters.array[fss_embedded_list_read_parameter_copyright_e].result == f_console_result_found_e) { + fss_embedded_list_read_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); return F_none; } + status = F_none; + + fss_embedded_list_read_data_t data = fss_embedded_list_read_data_t_initialize; + data.main = main; + data.argv = main->parameters.arguments.array; + if (F_status_is_error_not(status) && main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { if (main->parameters.array[fss_embedded_list_read_parameter_columns_e].result == f_console_result_found_e) { if (main->error.verbosity != f_console_verbosity_quiet_e) { diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h index 74bfd90..2b44f19 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h @@ -55,6 +55,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_embedded_list_read_print_copyright_ + extern f_status_t fss_embedded_list_read_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_embedded_list_read_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_embedded_list_read/data/build/defines b/level_3/fss_embedded_list_read/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_embedded_list_read/data/build/defines +++ b/level_3/fss_embedded_list_read/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_embedded_list_write/c/common.h b/level_3/fss_embedded_list_write/c/common.h index 3823680..f931202 100644 --- a/level_3/fss_embedded_list_write/c/common.h +++ b/level_3/fss_embedded_list_write/c/common.h @@ -156,6 +156,7 @@ extern "C" { enum { fss_embedded_list_write_parameter_help_e, + fss_embedded_list_write_parameter_copyright_e, fss_embedded_list_write_parameter_light_e, fss_embedded_list_write_parameter_dark_e, fss_embedded_list_write_parameter_no_color_e, @@ -180,6 +181,7 @@ extern "C" { #define fss_embedded_list_write_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, F_false, f_console_type_inverse_e), \ @@ -200,7 +202,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_embedded_list_write_short_trim_s.string, fss_embedded_list_write_long_trim_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_embedded_list_write_total_parameters_d 19 + #define fss_embedded_list_write_total_parameters_d 20 #endif // _di_fss_embedded_list_write_parameters_ #ifdef __cplusplus diff --git a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c index 32e8f2a..116162a 100644 --- a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c +++ b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c @@ -6,6 +6,30 @@ extern "C" { #endif +#ifndef _di_fss_embedded_list_write_print_copyright_ + f_status_t fss_embedded_list_write_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_embedded_list_write_print_copyright_ + #ifndef _di_fss_embedded_list_write_print_help_ f_status_t fss_embedded_list_write_print_help(const f_file_t file, const f_color_context_t context) { @@ -13,16 +37,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_embedded_list_write_program_name_long_s, fss_embedded_list_write_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -135,22 +160,28 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - - status = F_none; - if (main->parameters.array[fss_embedded_list_write_parameter_help_e].result == f_console_result_found_e) { fss_embedded_list_write_print_help(main->output.to, main->context); - return status; + return F_none; } if (main->parameters.array[fss_embedded_list_write_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_embedded_list_write_program_version_s); - return status; + return F_none; } + if (main->parameters.array[fss_embedded_list_write_parameter_copyright_e].result == f_console_result_found_e) { + fss_embedded_list_write_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + + f_string_static_t * const argv = main->parameters.arguments.array; + f_file_t output = f_file_t_initialize; output.id = F_type_descriptor_output_d; diff --git a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.h b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.h index 69a9565..fe91b16 100644 --- a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.h +++ b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.h @@ -48,6 +48,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_embedded_list_write_print_copyright_ + extern f_status_t fss_embedded_list_write_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_embedded_list_write_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_embedded_list_write/data/build/defines b/level_3/fss_embedded_list_write/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_embedded_list_write/data/build/defines +++ b/level_3/fss_embedded_list_write/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_extended_list_read/c/common.h b/level_3/fss_extended_list_read/c/common.h index 5751268..c2a9d0b 100644 --- a/level_3/fss_extended_list_read/c/common.h +++ b/level_3/fss_extended_list_read/c/common.h @@ -186,6 +186,7 @@ extern "C" { enum { fss_extended_list_read_parameter_help_e, + fss_extended_list_read_parameter_copyright_e, fss_extended_list_read_parameter_light_e, fss_extended_list_read_parameter_dark_e, fss_extended_list_read_parameter_no_color_e, @@ -215,6 +216,7 @@ extern "C" { #define fss_extended_list_read_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, F_false, f_console_type_inverse_e), \ @@ -240,7 +242,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_extended_list_read_short_trim_s.string, fss_extended_list_read_long_trim_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_extended_list_read_total_parameters_d 24 + #define fss_extended_list_read_total_parameters_d 25 #endif // _di_fss_extended_list_read_parameters_ /** diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index 1b64538..35c4982 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -7,6 +7,30 @@ extern "C" { #endif +#ifndef _di_fss_extended_list_read_print_copyright_ + f_status_t fss_extended_list_read_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_extended_list_read_print_copyright_ + #ifndef _di_fss_extended_list_read_print_help_ f_status_t fss_extended_list_read_print_help(const f_file_t file, const f_color_context_t context) { @@ -14,16 +38,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_extended_list_read_program_name_long_s, fss_extended_list_read_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -193,20 +218,26 @@ extern "C" { } } - status = F_none; - if (main->parameters.array[fss_extended_list_read_parameter_help_e].result == f_console_result_found_e) { fss_extended_list_read_print_help(main->output.to, main->context); - return status; + return F_none; } if (main->parameters.array[fss_extended_list_read_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_extended_list_read_program_version_s); - return status; + return F_none; } + if (main->parameters.array[fss_extended_list_read_parameter_copyright_e].result == f_console_result_found_e) { + fss_extended_list_read_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + // Provide a range designating where within the buffer a particular file exists, using a statically allocated array. fss_extended_list_read_file_t files_array[main->parameters.remaining.used + 1]; fss_extended_list_read_data_t data = fss_extended_list_read_data_t_initialize; diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.h b/level_3/fss_extended_list_read/c/fss_extended_list_read.h index 1a8a67d..8a3509f 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.h +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.h @@ -55,6 +55,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_extended_list_read_print_copyright_ + extern f_status_t fss_extended_list_read_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_extended_list_read_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_extended_list_read/data/build/defines b/level_3/fss_extended_list_read/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_extended_list_read/data/build/defines +++ b/level_3/fss_extended_list_read/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_extended_list_write/c/common.h b/level_3/fss_extended_list_write/c/common.h index 66b0458..7354f4f 100644 --- a/level_3/fss_extended_list_write/c/common.h +++ b/level_3/fss_extended_list_write/c/common.h @@ -156,6 +156,7 @@ extern "C" { enum { fss_extended_list_write_parameter_help_e, + fss_extended_list_write_parameter_copyright_e, fss_extended_list_write_parameter_light_e, fss_extended_list_write_parameter_dark_e, fss_extended_list_write_parameter_no_color_e, @@ -180,6 +181,7 @@ extern "C" { #define fss_extended_list_write_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, F_false, f_console_type_inverse_e), \ @@ -200,7 +202,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_extended_list_write_short_trim_s.string, fss_extended_list_write_long_trim_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_extended_list_write_total_parameters_d 19 + #define fss_extended_list_write_total_parameters_d 20 #endif // _di_fss_extended_list_write_parameters_ /** diff --git a/level_3/fss_extended_list_write/c/fss_extended_list_write.c b/level_3/fss_extended_list_write/c/fss_extended_list_write.c index d74a4eb..f074286 100644 --- a/level_3/fss_extended_list_write/c/fss_extended_list_write.c +++ b/level_3/fss_extended_list_write/c/fss_extended_list_write.c @@ -6,6 +6,30 @@ extern "C" { #endif +#ifndef _di_fss_extended_list_write_print_copyright_ + f_status_t fss_extended_list_write_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_extended_list_write_print_copyright_ + #ifndef _di_fss_extended_list_write_print_help_ f_status_t fss_extended_list_write_print_help(const f_file_t file, const f_color_context_t context) { @@ -13,16 +37,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_extended_list_write_program_name_long_s, fss_extended_list_write_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -135,22 +160,28 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - - status = F_none; - if (main->parameters.array[fss_extended_list_write_parameter_help_e].result == f_console_result_found_e) { fss_extended_list_write_print_help(main->output.to, main->context); - return status; + return F_none; } if (main->parameters.array[fss_extended_list_write_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_extended_list_write_program_version_s); - return status; + return F_none; } + if (main->parameters.array[fss_extended_list_write_parameter_copyright_e].result == f_console_result_found_e) { + fss_extended_list_write_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + + f_string_static_t * const argv = main->parameters.arguments.array; + f_file_t output = f_file_t_initialize; output.id = F_type_descriptor_output_d; diff --git a/level_3/fss_extended_list_write/c/fss_extended_list_write.h b/level_3/fss_extended_list_write/c/fss_extended_list_write.h index 6a96c0b..8e6d08a 100644 --- a/level_3/fss_extended_list_write/c/fss_extended_list_write.h +++ b/level_3/fss_extended_list_write/c/fss_extended_list_write.h @@ -48,6 +48,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_extended_list_write_print_copyright_ + extern f_status_t fss_extended_list_write_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_extended_list_write_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_extended_list_write/data/build/defines b/level_3/fss_extended_list_write/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_extended_list_write/data/build/defines +++ b/level_3/fss_extended_list_write/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_extended_read/c/common.h b/level_3/fss_extended_read/c/common.h index 9db3db4..341815a 100644 --- a/level_3/fss_extended_read/c/common.h +++ b/level_3/fss_extended_read/c/common.h @@ -186,6 +186,7 @@ extern "C" { enum { fss_extended_read_parameter_help_e, + fss_extended_read_parameter_copyright_e, fss_extended_read_parameter_light_e, fss_extended_read_parameter_dark_e, fss_extended_read_parameter_no_color_e, @@ -215,6 +216,7 @@ extern "C" { #define fss_extended_read_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -240,7 +242,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_extended_read_short_trim_s.string, fss_extended_read_long_trim_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_extended_read_total_parameters_d 24 + #define fss_extended_read_total_parameters_d 25 #endif // _di_fss_extended_read_parameters_ /** diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index 0b560d6..1eace8f 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -7,6 +7,30 @@ extern "C" { #endif +#ifndef _di_fss_extended_read_print_copyright_ + f_status_t fss_extended_read_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_extended_read_print_copyright_ + #ifndef _di_fss_extended_read_print_help_ f_status_t fss_extended_read_print_help(const f_file_t file, const f_color_context_t context) { @@ -14,16 +38,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_extended_read_program_name_long_s, fss_extended_read_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -193,20 +218,26 @@ extern "C" { } } - status = F_none; - if (main->parameters.array[fss_extended_read_parameter_help_e].result == f_console_result_found_e) { fss_extended_read_print_help(main->output.to, main->context); - return status; + return F_none; } if (main->parameters.array[fss_extended_read_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_extended_read_program_version_s); - return status; + return F_none; } + if (main->parameters.array[fss_extended_read_parameter_copyright_e].result == f_console_result_found_e) { + fss_extended_read_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + // Provide a range designating where within the buffer a particular file exists, using a statically allocated array. fss_extended_read_file_t files_array[main->parameters.remaining.used + 1]; fss_extended_read_data_t data = fss_extended_read_data_t_initialize; diff --git a/level_3/fss_extended_read/c/fss_extended_read.h b/level_3/fss_extended_read/c/fss_extended_read.h index 740ffc2..4875792 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.h +++ b/level_3/fss_extended_read/c/fss_extended_read.h @@ -55,6 +55,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_extended_read_print_copyright_ + extern f_status_t fss_extended_read_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_extended_read_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_extended_read/data/build/defines b/level_3/fss_extended_read/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_extended_read/data/build/defines +++ b/level_3/fss_extended_read/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_extended_write/c/common.h b/level_3/fss_extended_write/c/common.h index d551c4c..f3b27c2 100644 --- a/level_3/fss_extended_write/c/common.h +++ b/level_3/fss_extended_write/c/common.h @@ -156,6 +156,7 @@ extern "C" { enum { fss_extended_write_parameter_help_e, + fss_extended_write_parameter_copyright_e, fss_extended_write_parameter_light_e, fss_extended_write_parameter_dark_e, fss_extended_write_parameter_no_color_e, @@ -180,6 +181,7 @@ extern "C" { #define fss_extended_write_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -200,7 +202,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_extended_write_short_trim_s.string, fss_extended_write_long_trim_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_extended_write_total_parameters_d 18 + #define fss_extended_write_total_parameters_d 19 #endif // _di_fss_extended_write_parameters_ #ifdef __cplusplus diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index ec25604..fb33a8c 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -6,6 +6,30 @@ extern "C" { #endif +#ifndef _di_fss_extended_write_print_copyright_ + f_status_t fss_extended_write_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_extended_write_print_copyright_ + #ifndef _di_fss_extended_write_print_help_ f_status_t fss_extended_write_print_help(const f_file_t file, const f_color_context_t context) { @@ -13,16 +37,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_extended_write_program_name_long_s, fss_extended_write_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -132,22 +157,28 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - - status = F_none; - if (main->parameters.array[fss_extended_write_parameter_help_e].result == f_console_result_found_e) { fss_extended_write_print_help(main->output.to, main->context); - return status; + return F_none; } if (main->parameters.array[fss_extended_write_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_extended_write_program_version_s); - return status; + return F_none; } + if (main->parameters.array[fss_extended_write_parameter_copyright_e].result == f_console_result_found_e) { + fss_extended_write_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + + f_string_static_t * const argv = main->parameters.arguments.array; + f_file_t output = f_file_t_initialize; output.id = F_type_descriptor_output_d; diff --git a/level_3/fss_extended_write/c/fss_extended_write.h b/level_3/fss_extended_write/c/fss_extended_write.h index 952cf1c..860b761 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.h +++ b/level_3/fss_extended_write/c/fss_extended_write.h @@ -48,6 +48,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_extended_write_print_copyright_ + extern f_status_t fss_extended_write_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_extended_write_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_extended_write/data/build/defines b/level_3/fss_extended_write/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_extended_write/data/build/defines +++ b/level_3/fss_extended_write/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_identify/c/common.h b/level_3/fss_identify/c/common.h index 14bdb20..5f4aa87 100644 --- a/level_3/fss_identify/c/common.h +++ b/level_3/fss_identify/c/common.h @@ -108,6 +108,7 @@ extern "C" { enum { fss_identify_parameter_help_e, + fss_identify_parameter_copyright_e, fss_identify_parameter_light_e, fss_identify_parameter_dark_e, fss_identify_parameter_no_color_e, @@ -128,6 +129,7 @@ extern "C" { #define fss_identify_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -144,7 +146,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_identify_short_total_s.string, fss_identify_long_total_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_identify_total_parameters_d 15 + #define fss_identify_total_parameters_d 16 #endif // _di_fss_identify_parameters_ #ifdef __cplusplus diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index 4d4fd44..21ab343 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -6,6 +6,30 @@ extern "C" { #endif +#ifndef _di_fss_identify_print_copyright_ + f_status_t fss_identify_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_identify_print_copyright_ + #ifndef _di_fss_identify_print_help_ f_status_t fss_identify_print_help(const f_file_t file, const f_color_context_t context) { @@ -13,16 +37,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_identify_program_name_long_s, fss_identify_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -140,8 +165,6 @@ extern "C" { } } - status = F_none; - if (main->parameters.array[fss_identify_parameter_help_e].result == f_console_result_found_e) { fss_identify_print_help(main->output.to, main->context); @@ -154,6 +177,14 @@ extern "C" { return F_none; } + if (main->parameters.array[fss_identify_parameter_copyright_e].result == f_console_result_found_e) { + fss_identify_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + fss_identify_data_t data = fss_identify_data_t_initialize; data.argv = main->parameters.arguments.array; diff --git a/level_3/fss_identify/c/fss_identify.h b/level_3/fss_identify/c/fss_identify.h index 09f026b..d3c244c 100644 --- a/level_3/fss_identify/c/fss_identify.h +++ b/level_3/fss_identify/c/fss_identify.h @@ -53,6 +53,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_identify_print_copyright_ + extern f_status_t fss_identify_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_identify_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_identify/data/build/defines b/level_3/fss_identify/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_identify/data/build/defines +++ b/level_3/fss_identify/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_payload_read/c/common.h b/level_3/fss_payload_read/c/common.h index 914d271..3d76dc8 100644 --- a/level_3/fss_payload_read/c/common.h +++ b/level_3/fss_payload_read/c/common.h @@ -180,6 +180,7 @@ extern "C" { enum { fss_payload_read_parameter_help_e, + fss_payload_read_parameter_copyright_e, fss_payload_read_parameter_light_e, fss_payload_read_parameter_dark_e, fss_payload_read_parameter_no_color_e, @@ -209,6 +210,7 @@ extern "C" { #define fss_payload_read_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, F_false, f_console_type_inverse_e), \ @@ -234,7 +236,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_payload_read_short_trim_s.string, fss_payload_read_long_trim_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_payload_read_total_parameters_d 24 + #define fss_payload_read_total_parameters_d 25 #endif // _di_fss_payload_read_parameters_ /** diff --git a/level_3/fss_payload_read/c/fss_payload_read.c b/level_3/fss_payload_read/c/fss_payload_read.c index 7482d83..68001da 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.c +++ b/level_3/fss_payload_read/c/fss_payload_read.c @@ -16,6 +16,30 @@ extern "C" { const f_string_static_t fss_payload_read_program_name_long_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_program_name_long_s, 0, FSS_PAYLOAD_READ_program_name_long_s_length); #endif // _di_fss_payload_read_program_name_ +#ifndef _di_fss_payload_read_print_copyright_ + f_status_t fss_payload_read_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_payload_read_print_copyright_ + #ifndef _di_fss_payload_read_print_help_ f_status_t fss_payload_read_print_help(const f_file_t file, const f_color_context_t context) { @@ -23,16 +47,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_payload_read_program_name_long_s, fss_payload_read_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -212,20 +237,26 @@ extern "C" { } } - status = F_none; - if (main->parameters.array[fss_payload_read_parameter_help_e].result == f_console_result_found_e) { fss_payload_read_print_help(main->output.to, main->context); - return status; + return F_none; } if (main->parameters.array[fss_payload_read_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_payload_read_program_version_s); - return status; + return F_none; } + if (main->parameters.array[fss_payload_read_parameter_copyright_e].result == f_console_result_found_e) { + fss_payload_read_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + // Provide a range designating where within the buffer a particular file exists, using a statically allocated array. fss_payload_read_file_t files_array[main->parameters.remaining.used + 1]; fss_payload_read_data_t data = fss_payload_read_data_t_initialize; diff --git a/level_3/fss_payload_read/c/fss_payload_read.h b/level_3/fss_payload_read/c/fss_payload_read.h index a678797..ec7cbed 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.h +++ b/level_3/fss_payload_read/c/fss_payload_read.h @@ -56,6 +56,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_payload_read_print_copyright_ + extern f_status_t fss_payload_read_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_payload_read_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_payload_read/data/build/defines b/level_3/fss_payload_read/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_payload_read/data/build/defines +++ b/level_3/fss_payload_read/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_payload_write/c/common.h b/level_3/fss_payload_write/c/common.h index d1875bf..33edc6a 100644 --- a/level_3/fss_payload_write/c/common.h +++ b/level_3/fss_payload_write/c/common.h @@ -150,6 +150,7 @@ extern "C" { enum { fss_payload_write_parameter_help_e, + fss_payload_write_parameter_copyright_e, fss_payload_write_parameter_light_e, fss_payload_write_parameter_dark_e, fss_payload_write_parameter_no_color_e, @@ -174,6 +175,7 @@ extern "C" { #define fss_payload_write_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, F_false, f_console_type_inverse_e), \ @@ -194,7 +196,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_payload_write_short_trim_s.string, fss_payload_write_long_trim_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_payload_write_total_parameters_d 19 + #define fss_payload_write_total_parameters_d 20 #endif // _di_fss_payload_write_parameters_ #ifdef __cplusplus diff --git a/level_3/fss_payload_write/c/fss_payload_write.c b/level_3/fss_payload_write/c/fss_payload_write.c index e4ec494..0dec003 100644 --- a/level_3/fss_payload_write/c/fss_payload_write.c +++ b/level_3/fss_payload_write/c/fss_payload_write.c @@ -15,6 +15,30 @@ extern "C" { const f_string_static_t fss_payload_write_program_name_long_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_program_name_long_s, 0, FSS_PAYLOAD_WRITE_program_name_long_s_length); #endif // _di_fss_payload_write_program_name_ +#ifndef _di_fss_payload_write_print_copyright_ + f_status_t fss_payload_write_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_payload_write_print_copyright_ + #ifndef _di_fss_payload_write_print_help_ f_status_t fss_payload_write_print_help(const f_file_t file, const f_color_context_t context) { @@ -22,16 +46,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_payload_write_program_name_long_s, fss_payload_write_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -141,22 +166,28 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - - status = F_none; - if (main->parameters.array[fss_payload_write_parameter_help_e].result == f_console_result_found_e) { fss_payload_write_print_help(main->output.to, main->context); - return status; + return F_none; } if (main->parameters.array[fss_payload_write_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, fss_payload_write_program_version_s); - return status; + return F_none; } + if (main->parameters.array[fss_payload_write_parameter_copyright_e].result == f_console_result_found_e) { + fss_payload_write_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + + f_string_static_t * const argv = main->parameters.arguments.array; + f_file_t output = f_file_t_initialize; output.id = F_type_descriptor_output_d; diff --git a/level_3/fss_payload_write/c/fss_payload_write.h b/level_3/fss_payload_write/c/fss_payload_write.h index 3e7c15e..133d6fd 100644 --- a/level_3/fss_payload_write/c/fss_payload_write.h +++ b/level_3/fss_payload_write/c/fss_payload_write.h @@ -48,6 +48,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_payload_write_print_copyright_ + extern f_status_t fss_payload_write_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_payload_write_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_payload_write/data/build/defines b/level_3/fss_payload_write/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_payload_write/data/build/defines +++ b/level_3/fss_payload_write/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/fss_status_code/c/common.h b/level_3/fss_status_code/c/common.h index 241df2d..559e4ff 100644 --- a/level_3/fss_status_code/c/common.h +++ b/level_3/fss_status_code/c/common.h @@ -112,6 +112,7 @@ extern "C" { enum { fss_status_code_parameter_help_e, + fss_status_code_parameter_copyright_e, fss_status_code_parameter_light_e, fss_status_code_parameter_dark_e, fss_status_code_parameter_no_color_e, @@ -131,6 +132,7 @@ extern "C" { #define fss_status_code_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -146,7 +148,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_status_code_short_number_s.string, fss_status_code_long_number_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_status_code_total_parameters_d 14 + #define fss_status_code_total_parameters_d 15 #endif // _di_fss_status_code_defines_ #ifdef __cplusplus diff --git a/level_3/fss_status_code/c/fss_status_code.c b/level_3/fss_status_code/c/fss_status_code.c index 75c8ba9..b12d8de 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -6,6 +6,30 @@ extern "C" { #endif +#ifndef _di_fss_status_code_print_copyright_ + f_status_t fss_status_code_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_fss_status_code_print_copyright_ + #ifndef _di_fss_status_code_print_help_ f_status_t fss_status_code_print_help(const f_file_t file, const f_color_context_t context) { @@ -13,16 +37,17 @@ extern "C" { fll_program_print_help_header(file, context, fss_status_code_program_name_long_s, fss_status_code_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -130,10 +155,6 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - - status = F_none; - if (main->parameters.array[fss_status_code_parameter_help_e].result == f_console_result_found_e) { fss_status_code_print_help(main->output.to, main->context); @@ -146,6 +167,16 @@ extern "C" { return F_none; } + if (main->parameters.array[fss_status_code_parameter_copyright_e].result == f_console_result_found_e) { + fss_status_code_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + status = F_none; + + f_string_static_t * const argv = main->parameters.arguments.array; + if (main->parameters.array[fss_status_code_parameter_error_e].result == f_console_result_found_e) { if (main->parameters.array[fss_status_code_parameter_warning_e].result == f_console_result_found_e) { if (main->parameters.array[fss_status_code_parameter_number_e].result == f_console_result_none_e) { diff --git a/level_3/fss_status_code/c/fss_status_code.h b/level_3/fss_status_code/c/fss_status_code.h index 30c7adf..4d2fd08 100644 --- a/level_3/fss_status_code/c/fss_status_code.h +++ b/level_3/fss_status_code/c/fss_status_code.h @@ -50,6 +50,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_fss_status_code_print_copyright_ + extern f_status_t fss_status_code_print_copyright(const f_file_t file, const bool detail); +#endif // _di_fss_status_code_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/fss_status_code/data/build/defines b/level_3/fss_status_code/data/build/defines index c665317..91fff5d 100644 --- a/level_3/fss_status_code/data/build/defines +++ b/level_3/fss_status_code/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/iki_read/c/common.h b/level_3/iki_read/c/common.h index c650328..1f51a34 100644 --- a/level_3/iki_read/c/common.h +++ b/level_3/iki_read/c/common.h @@ -157,6 +157,7 @@ extern "C" { enum { iki_read_parameter_help_e, + iki_read_parameter_copyright_e, iki_read_parameter_light_e, iki_read_parameter_dark_e, iki_read_parameter_no_color_e, @@ -184,6 +185,7 @@ extern "C" { #define iki_read_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -207,7 +209,7 @@ extern "C" { macro_f_console_parameter_t_initialize(iki_read_short_wrap_s.string, iki_read_long_wrap_s.string, 0, 3, f_console_type_normal_e), \ } - #define iki_read_total_parameters_d 22 + #define iki_read_total_parameters_d 23 #endif // _di_iki_read_parameters_ #ifndef _di_iki_read_substitution_t_ diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index fc5c4e8..6f97f9e 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -6,6 +6,30 @@ extern "C" { #endif +#ifndef _di_iki_read_print_copyright_ + f_status_t iki_read_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_iki_read_print_copyright_ + #ifndef _di_iki_read_print_help_ f_status_t iki_read_print_help(const f_file_t file, const f_color_context_t context) { @@ -13,16 +37,17 @@ extern "C" { fll_program_print_help_header(file, context, iki_read_program_name_long_s, iki_read_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -185,28 +210,30 @@ extern "C" { } } - iki_read_data_t data = iki_read_data_t_initialize; - data.main = main; - data.argv = main->parameters.arguments.array; - - status = F_none; - if (main->parameters.array[iki_read_parameter_help_e].result == f_console_result_found_e) { iki_read_print_help(main->output.to, main->context); - iki_read_data_delete(&data); - return F_none; } if (main->parameters.array[iki_read_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, iki_read_program_version_s); - iki_read_data_delete(&data); + return F_none; + } + + if (main->parameters.array[iki_read_parameter_copyright_e].result == f_console_result_found_e) { + iki_read_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); return F_none; } + iki_read_data_t data = iki_read_data_t_initialize; + data.main = main; + data.argv = main->parameters.arguments.array; + + status = F_none; + if (main->parameters.remaining.used > 0 || main->process_pipe) { if (main->parameters.array[iki_read_parameter_at_e].result == f_console_result_found_e) { if (main->error.verbosity != f_console_verbosity_quiet_e) { diff --git a/level_3/iki_read/c/iki_read.h b/level_3/iki_read/c/iki_read.h index 122c658..ea107f2 100644 --- a/level_3/iki_read/c/iki_read.h +++ b/level_3/iki_read/c/iki_read.h @@ -58,6 +58,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_iki_read_print_copyright_ + extern f_status_t iki_read_print_copyright(const f_file_t file, const bool detail); +#endif // _di_iki_read_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/iki_read/data/build/defines b/level_3/iki_read/data/build/defines index c665317..91fff5d 100644 --- a/level_3/iki_read/data/build/defines +++ b/level_3/iki_read/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/iki_write/c/common.h b/level_3/iki_write/c/common.h index 8eef528..7ff513f 100644 --- a/level_3/iki_write/c/common.h +++ b/level_3/iki_write/c/common.h @@ -108,6 +108,7 @@ extern "C" { enum { iki_write_parameter_help_e, + iki_write_parameter_copyright_e, iki_write_parameter_light_e, iki_write_parameter_dark_e, iki_write_parameter_no_color_e, @@ -128,6 +129,7 @@ extern "C" { #define iki_write_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -144,7 +146,7 @@ extern "C" { macro_f_console_parameter_t_initialize(iki_write_short_single_s.string, iki_write_long_single_s.string, 0, 0, f_console_type_normal_e), \ } - #define iki_write_total_parameters_d 15 + #define iki_write_total_parameters_d 16 #endif // _di_iki_write_parameters_ #ifdef __cplusplus diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index 0488366..1eb161a 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -6,6 +6,30 @@ extern "C" { #endif +#ifndef _di_iki_write_print_copyright_ + f_status_t iki_write_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_iki_write_print_copyright_ + #ifndef _di_iki_write_print_help_ f_status_t iki_write_print_help(const f_file_t file, const f_color_context_t context) { @@ -13,16 +37,17 @@ extern "C" { fll_program_print_help_header(file, context, iki_write_program_name_long_s, iki_write_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -132,28 +157,30 @@ extern "C" { } } - iki_write_data_t data = iki_write_data_t_initialize; - data.main = main; - data.argv = main->parameters.arguments.array; - - status = F_none; - if (main->parameters.array[iki_write_parameter_help_e].result == f_console_result_found_e) { iki_write_print_help(main->output.to, main->context); - iki_write_data_delete(&data); - return F_none; } if (main->parameters.array[iki_write_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, iki_write_program_version_s); - iki_write_data_delete(&data); + return F_none; + } + + if (main->parameters.array[iki_write_parameter_copyright_e].result == f_console_result_found_e) { + iki_write_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); return F_none; } + status = F_none; + + iki_write_data_t data = iki_write_data_t_initialize; + data.main = main; + data.argv = main->parameters.arguments.array; + f_file_t file = f_file_t_initialize; file.id = F_type_descriptor_output_d; diff --git a/level_3/iki_write/c/iki_write.h b/level_3/iki_write/c/iki_write.h index 1b849e8..5bd6d37 100644 --- a/level_3/iki_write/c/iki_write.h +++ b/level_3/iki_write/c/iki_write.h @@ -58,6 +58,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_iki_write_print_copyright_ + extern f_status_t iki_write_print_copyright(const f_file_t file, const bool detail); +#endif // _di_iki_write_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/iki_write/data/build/defines b/level_3/iki_write/data/build/defines index c665317..91fff5d 100644 --- a/level_3/iki_write/data/build/defines +++ b/level_3/iki_write/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/status_code/c/common.h b/level_3/status_code/c/common.h index 9bd454d..bdfa782 100644 --- a/level_3/status_code/c/common.h +++ b/level_3/status_code/c/common.h @@ -112,6 +112,7 @@ extern "C" { enum { status_code_parameter_help_e, + status_code_parameter_copyright_e, status_code_parameter_light_e, status_code_parameter_dark_e, status_code_parameter_no_color_e, @@ -131,6 +132,7 @@ extern "C" { #define status_code_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -146,7 +148,7 @@ extern "C" { macro_f_console_parameter_t_initialize(status_code_short_number_s.string, status_code_long_number_s.string, 0, 0, f_console_type_normal_e), \ } - #define status_code_total_parameters_d 14 + #define status_code_total_parameters_d 15 #endif // _di_status_code_parameters_ #ifdef __cplusplus diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index 4b3e05b..6ba7834 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -6,6 +6,30 @@ extern "C" { #endif +#ifndef _di_status_code_print_copyright_ + f_status_t status_code_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_status_code_print_copyright_ + #ifndef _di_status_code_print_help_ f_status_t status_code_print_help(const f_file_t file, const f_color_context_t context) { @@ -13,16 +37,17 @@ extern "C" { fll_program_print_help_header(file, context, status_code_program_name_long_s, status_code_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -128,8 +153,6 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - status = F_none; if (main->parameters.array[status_code_parameter_help_e].result == f_console_result_found_e) { @@ -144,6 +167,14 @@ extern "C" { return F_none; } + if (main->parameters.array[status_code_parameter_copyright_e].result == f_console_result_found_e) { + status_code_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + return F_none; + } + + f_string_static_t * const argv = main->parameters.arguments.array; + if (main->parameters.array[status_code_parameter_error_e].result == f_console_result_found_e) { if (main->parameters.array[status_code_parameter_warning_e].result == f_console_result_found_e) { if (main->parameters.array[status_code_parameter_number_e].result == f_console_result_none_e) { diff --git a/level_3/status_code/data/build/defines b/level_3/status_code/data/build/defines index c665317..91fff5d 100644 --- a/level_3/status_code/data/build/defines +++ b/level_3/status_code/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). diff --git a/level_3/utf8/c/common.h b/level_3/utf8/c/common.h index acc1926..50bc8e1 100644 --- a/level_3/utf8/c/common.h +++ b/level_3/utf8/c/common.h @@ -239,6 +239,7 @@ extern "C" { enum { utf8_parameter_help_e, + utf8_parameter_copyright_e, utf8_parameter_light_e, utf8_parameter_dark_e, utf8_parameter_no_color_e, @@ -269,6 +270,7 @@ extern "C" { #define utf8_console_parameter_t_initialize \ { \ macro_f_console_parameter_t_initialize(f_console_standard_short_help_s.string, f_console_standard_long_help_s.string, 0, 0, f_console_type_normal_e), \ + macro_f_console_parameter_t_initialize(f_console_standard_short_copyright_s.string, f_console_standard_long_copyright_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_light_s.string, f_console_standard_long_light_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_dark_s.string, f_console_standard_long_dark_s.string, 0, 0, f_console_type_inverse_e), \ macro_f_console_parameter_t_initialize(f_console_standard_short_no_color_s.string, f_console_standard_long_no_color_s.string, 0, 0, f_console_type_inverse_e), \ @@ -292,7 +294,7 @@ extern "C" { macro_f_console_parameter_t_initialize(utf8_short_verify_s.string, utf8_long_verify_s.string, 0, 0, f_console_type_normal_e), \ } - #define utf8_total_parameters_d 22 + #define utf8_total_parameters_d 23 #endif // _di_utf8_parameters_ /** diff --git a/level_3/utf8/c/utf8.c b/level_3/utf8/c/utf8.c index e42479f..31423c1 100644 --- a/level_3/utf8/c/utf8.c +++ b/level_3/utf8/c/utf8.c @@ -9,6 +9,30 @@ extern "C" { #endif +#ifndef _di_utf8_print_copyright_ + f_status_t utf8_print_copyright(const f_file_t file, const bool full) { + + flockfile(file.stream); + + fl_print_format("%rCopyright © 2007-2023 Kevin Day.%r", file.stream, f_string_eol_s, f_string_eol_s); + + #ifndef _di_detailed_copyright_ + if (full) { + fl_print_format("%rThis program comes with ABSOLUTELY NO WARRANTY.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("This is free software, and you are welcome to modify or redistribute in accordance to the license.%r", file.stream, f_string_eol_s); + } + #endif // _di_detailed_copyright_ + + fl_print_format("%rSource code license lgpl-2.1-or-later.%r", file.stream, f_string_eol_s, f_string_eol_s); + fl_print_format("Standard and specification license open-standard-license-1.0.%r", file.stream, f_string_eol_s); + fl_print_format("Documentation license cc-by-sa-4.0.%r%r", file.stream, f_string_eol_s, f_string_eol_s); + + funlockfile(file.stream); + + return F_none; + } +#endif // _di_utf8_print_copyright_ + #ifndef _di_utf8_print_help_ f_status_t utf8_print_help(const f_file_t file, const f_color_context_t context) { @@ -16,16 +40,17 @@ extern "C" { fll_program_print_help_header(file, context, utf8_program_name_long_s, utf8_program_version_s); - fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not print using color."); - fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); - fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); + fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); + fll_program_print_help_option(file, context, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Print the copyright."); + fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(file, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Do not print using color."); + fll_program_print_help_option(file, context, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(file, context, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(file, context, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Set verbosity to normal."); + fll_program_print_help_option(file, context, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(file, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); f_print_dynamic_raw(f_string_eol_s, file.stream); @@ -292,9 +317,6 @@ extern "C" { } } - data.argv = main->parameters.arguments.array; - status = F_none; - if (main->parameters.array[utf8_parameter_help_e].result == f_console_result_found_e) { utf8_print_help(main->output.to, main->context); @@ -311,6 +333,17 @@ extern "C" { return F_none; } + if (main->parameters.array[utf8_parameter_copyright_e].result == f_console_result_found_e) { + utf8_print_copyright(main->output.to, main->output.verbosity > f_console_verbosity_error_e); + + utf8_data_delete(&data); + + return F_none; + } + + status = F_none; + data.argv = main->parameters.arguments.array; + if (F_status_is_error_not(status)) { if (main->parameters.array[utf8_parameter_from_file_e].result == f_console_result_additional_e) { f_array_length_t i = 0; diff --git a/level_3/utf8/c/utf8.h b/level_3/utf8/c/utf8.h index a87576f..0386fb8 100644 --- a/level_3/utf8/c/utf8.h +++ b/level_3/utf8/c/utf8.h @@ -62,6 +62,22 @@ extern "C" { #endif /** + * Print copyright. + * + * @param file + * The file to print to. + * @param detail + * If TRUE, then the detailed copyright is printed (unless _di_detailed_copyright_ is set). + * If FALSE, then the short copyright is printed. + * + * @return + * F_none on success. + */ +#ifndef _di_utf8_print_copyright_ + extern f_status_t utf8_print_copyright(const f_file_t file, const bool detail); +#endif // _di_utf8_print_copyright_ + +/** * Print help. * * @param file diff --git a/level_3/utf8/data/build/defines b/level_3/utf8/data/build/defines index c665317..91fff5d 100644 --- a/level_3/utf8/data/build/defines +++ b/level_3/utf8/data/build/defines @@ -1,2 +1,3 @@ # fss-0000 +_di_detailed_copyright_ Disable the detailed copyright message (saves a small amount of space). -- 1.8.3.1