From: Kevin Day Date: Fri, 27 Jan 2023 05:34:09 +0000 (-0600) Subject: Feature: Provide program parameter for displaying copyright. X-Git-Tag: 0.6.4~76 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=af4cbf0ad71bd61209e3d2d0c7aaeeb040e61c72;p=fll 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. --- diff --git a/level_0/f_console/c/console/common.c b/level_0/f_console/c/console/common.c index 850cdc034..266459b96 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 13cd1a6df..9765fc86d 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 d67a8d5ef..92c911dd5 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 b520e67c9..62bddffc1 100644 --- a/level_3/byte_dump/c/byte_dump.h +++ b/level_3/byte_dump/c/byte_dump.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_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. * diff --git a/level_3/byte_dump/c/common.h b/level_3/byte_dump/c/common.h index 266cc52e7..84fbde1d2 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 c6653172e..5732619cb 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 2ee3a139b..e4f9775df 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 5b57bcd6e..883de1bf4 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 2d4f23a39..d1892320c 100644 --- a/level_3/control/c/control.h +++ b/level_3/control/c/control.h @@ -57,6 +57,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. * diff --git a/level_3/control/data/build/defines b/level_3/control/data/build/defines index d44a0dec7..d3a32fd3a 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 2c3075021..cc2871e7b 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 a88cda612..9c1852def 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 69c597132..7ac95eaf7 100644 --- a/level_3/controller/c/controller.h +++ b/level_3/controller/c/controller.h @@ -83,6 +83,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. * diff --git a/level_3/controller/data/build/defines b/level_3/controller/data/build/defines index 63c654fad..06586059b 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 41ef1ac1c..ba6a0ed0e 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 3cda2f869..093e88b91 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 d1be40a10..2f2515834 100644 --- a/level_3/fake/c/fake.h +++ b/level_3/fake/c/fake.h @@ -96,6 +96,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. * diff --git a/level_3/fake/data/build/defines b/level_3/fake/data/build/defines index 427a9c7f6..c2a94328f 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 708e1fe8a..3572c56e1 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 49fa48cb8..9cf6efa51 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 13347f68c..fc3273d2c 100644 --- a/level_3/firewall/c/firewall.h +++ b/level_3/firewall/c/firewall.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_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. * diff --git a/level_3/firewall/data/build/defines b/level_3/firewall/data/build/defines index 427a9c7f6..c2a94328f 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 eac7eab03..1e4b680dd 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 4d801a051..de9a570c3 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 001777a84..85d854426 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 @@ -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_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. * diff --git a/level_3/fss_basic_list_read/data/build/defines b/level_3/fss_basic_list_read/data/build/defines index c6653172e..91fff5d31 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 b56f61a98..fba1fc60d 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 854cab1bb..f81fd53e5 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 320dbc30c..a34817619 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 @@ -46,6 +46,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. * diff --git a/level_3/fss_basic_list_write/data/build/defines b/level_3/fss_basic_list_write/data/build/defines index c6653172e..91fff5d31 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 20db50c3c..3ba5dd48c 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 35d34a864..e0caf3494 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 7031f31dc..d94a16c82 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.h +++ b/level_3/fss_basic_read/c/fss_basic_read.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_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. * diff --git a/level_3/fss_basic_read/data/build/defines b/level_3/fss_basic_read/data/build/defines index c6653172e..91fff5d31 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 873500232..67eae29bc 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 ea614c8f5..ee14bc40c 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 594f265a7..a0e6938b4 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.h +++ b/level_3/fss_basic_write/c/fss_basic_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_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. * diff --git a/level_3/fss_basic_write/data/build/defines b/level_3/fss_basic_write/data/build/defines index c6653172e..91fff5d31 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 207c0869e..91e6b4607 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 54b4c6c09..31e883b56 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 74bfd90d1..2b44f1979 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 @@ -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_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. * diff --git a/level_3/fss_embedded_list_read/data/build/defines b/level_3/fss_embedded_list_read/data/build/defines index c6653172e..91fff5d31 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 38236800e..f931202c1 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 32e8f2abe..116162a26 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 69a9565b3..fe91b160e 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 @@ -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_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. * diff --git a/level_3/fss_embedded_list_write/data/build/defines b/level_3/fss_embedded_list_write/data/build/defines index c6653172e..91fff5d31 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 57512684b..c2a9d0b0b 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 1b645387c..35c4982cc 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 1a8a67d2f..8a3509f18 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 @@ -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_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. * diff --git a/level_3/fss_extended_list_read/data/build/defines b/level_3/fss_extended_list_read/data/build/defines index c6653172e..91fff5d31 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 66b045832..7354f4fa1 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 d74a4ebcd..f07428623 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 6a96c0bad..8e6d08a5a 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 @@ -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_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. * diff --git a/level_3/fss_extended_list_write/data/build/defines b/level_3/fss_extended_list_write/data/build/defines index c6653172e..91fff5d31 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 9db3db49b..341815a4b 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 0b560d612..1eace8f8d 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 740ffc2d0..4875792d9 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.h +++ b/level_3/fss_extended_read/c/fss_extended_read.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_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. * diff --git a/level_3/fss_extended_read/data/build/defines b/level_3/fss_extended_read/data/build/defines index c6653172e..91fff5d31 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 d551c4c74..f3b27c285 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 ec25604d8..fb33a8cbc 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 952cf1c14..860b761d1 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.h +++ b/level_3/fss_extended_write/c/fss_extended_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_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. * diff --git a/level_3/fss_extended_write/data/build/defines b/level_3/fss_extended_write/data/build/defines index c6653172e..91fff5d31 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 14bdb2044..5f4aa8755 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 4d4fd44f0..21ab343ea 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 09f026b04..d3c244c8f 100644 --- a/level_3/fss_identify/c/fss_identify.h +++ b/level_3/fss_identify/c/fss_identify.h @@ -52,6 +52,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. * diff --git a/level_3/fss_identify/data/build/defines b/level_3/fss_identify/data/build/defines index c6653172e..91fff5d31 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 914d2717b..3d76dc8c8 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 7482d83e3..68001da89 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 a67879754..ec7cbed89 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.h +++ b/level_3/fss_payload_read/c/fss_payload_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_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. * diff --git a/level_3/fss_payload_read/data/build/defines b/level_3/fss_payload_read/data/build/defines index c6653172e..91fff5d31 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 d1875bf94..33edc6adb 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 e4ec49410..0dec0035f 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 3e7c15eaa..133d6fd0c 100644 --- a/level_3/fss_payload_write/c/fss_payload_write.h +++ b/level_3/fss_payload_write/c/fss_payload_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_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. * diff --git a/level_3/fss_payload_write/data/build/defines b/level_3/fss_payload_write/data/build/defines index c6653172e..91fff5d31 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 241df2dd3..559e4ff02 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 75c8ba94a..b12d8defa 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 30c7adfd0..4d2fd0856 100644 --- a/level_3/fss_status_code/c/fss_status_code.h +++ b/level_3/fss_status_code/c/fss_status_code.h @@ -49,6 +49,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. * diff --git a/level_3/fss_status_code/data/build/defines b/level_3/fss_status_code/data/build/defines index c6653172e..91fff5d31 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 c6503287e..1f51a34d0 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 fc5c4e83e..6f97f9ea0 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 122c658bc..ea107f243 100644 --- a/level_3/iki_read/c/iki_read.h +++ b/level_3/iki_read/c/iki_read.h @@ -57,6 +57,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. * diff --git a/level_3/iki_read/data/build/defines b/level_3/iki_read/data/build/defines index c6653172e..91fff5d31 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 8eef528b4..7ff513fb6 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 0488366a6..1eb161a6c 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 1b849e837..5bd6d3717 100644 --- a/level_3/iki_write/c/iki_write.h +++ b/level_3/iki_write/c/iki_write.h @@ -57,6 +57,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. * diff --git a/level_3/iki_write/data/build/defines b/level_3/iki_write/data/build/defines index c6653172e..91fff5d31 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 9bd454d0f..bdfa78286 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 4b3e05b0f..6ba783490 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 c6653172e..91fff5d31 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 acc192635..50bc8e1d1 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 e42479f1d..31423c133 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 a87576f1e..0386fb84a 100644 --- a/level_3/utf8/c/utf8.h +++ b/level_3/utf8/c/utf8.h @@ -61,6 +61,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. * diff --git a/level_3/utf8/data/build/defines b/level_3/utf8/data/build/defines index c6653172e..91fff5d31 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).