From 5edbe4107f9c9eef62d32d1beda4d929e7ae6515 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 9 Apr 2024 21:48:15 -0500 Subject: [PATCH] Update: Have fll_program_print_copyright() use year and author as a parameter. The year and author may be more subject to change. Relocate this into a global static string and provide this is a parameter to fll_program_print_copyright(). The fll_program_print_copyright() is only intended for FLL projects. Additional programs that I write, like controller, may also depend on this. These may be operated on at a different time and thus may require the year or author to be updated. Any more changes than this and it is probably a better idea to just implement ones own copyright print function. --- level_2/fll_program/c/program/common.c | 6 ++++++ level_2/fll_program/c/program/common.h | 23 +++++++++++++++++++++++ level_2/fll_program/c/program/print.c | 4 ++-- level_2/fll_program/c/program/print.h | 4 +++- level_3/byte_dump/c/main/byte_dump.c | 2 +- level_3/control/c/main/control.c | 2 +- level_3/controller/c/controller.c | 2 +- level_3/example/c/main/example.c | 2 +- level_3/fake/c/main/fake.c | 2 +- level_3/firewall/c/main/firewall.c | 2 +- level_3/fss_identify/c/main/fss_identify.c | 2 +- level_3/fss_read/c/main/fss_read.c | 2 +- level_3/fss_write/c/main/fss_write.c | 2 +- level_3/iki_read/c/main/iki_read.c | 2 +- level_3/iki_write/c/main/iki_write.c | 2 +- level_3/status_code/c/main/status_code.c | 2 +- level_3/utf8/c/main/utf8.c | 2 +- 17 files changed, 47 insertions(+), 16 deletions(-) diff --git a/level_2/fll_program/c/program/common.c b/level_2/fll_program/c/program/common.c index b1c83ab..6da3e49 100644 --- a/level_2/fll_program/c/program/common.c +++ b/level_2/fll_program/c/program/common.c @@ -14,6 +14,12 @@ extern "C" { #endif // _di_fll_program_parameter_filenames_s_ #endif // _di_fll_program_parameter_s_ +#ifndef _di_fll_program_copyright_s_ + #ifndef _di_fll_program_copyright_year_author_s_ + const f_string_static_t fll_program_copyright_year_author_s = macro_f_string_static_t_initialize_1(FLL_program_copyright_year_author_s, 0, FLL_program_copyright_year_author_s_length); + #endif // _di_fll_program_copyright_year_author_s_ +#endif // _di_fll_program_copyright_s_ + #ifndef _di_fll_program_data_delete_ f_status_t fll_program_data_delete(fll_program_data_t * const data) { #ifndef _di_level_2_parameter_checking_ diff --git a/level_2/fll_program/c/program/common.h b/level_2/fll_program/c/program/common.h index 37666bc..04a8c02 100644 --- a/level_2/fll_program/c/program/common.h +++ b/level_2/fll_program/c/program/common.h @@ -16,6 +16,13 @@ extern "C" { #endif +/** + * Program parameter strings. + * + * fll_program_parameter_*_s: + * - filename: The file name parameter string. + * - filenames: The file name(s) parameter string. + */ #ifndef _di_fll_program_parameter_s_ #define FLL_program_parameter_filename_s "filename" #define FLL_program_parameter_filenames_s "filename(s)" @@ -33,6 +40,22 @@ extern "C" { #endif // _di_fll_program_parameter_s_ /** + * Copyright relating strings. + * + * fll_program_copyright_*_s: + * - year_author: The year and author used by the FLL project. + */ +#ifndef _di_fll_program_copyright_s_ + #define FLL_program_copyright_year_author_s "2007-2024 Kevin Day" + + #define FLL_program_copyright_year_author_s_length 19 + + #ifndef _di_fll_program_copyright_year_author_s_ + extern const f_string_static_t fll_program_copyright_year_author_s; + #endif // _di_fll_program_copyright_year_author_s_ +#endif // _di_fll_program_copyright_s_ + +/** * Program data pipe codes. * * These are bit-wise codes used to designate that a particular pipe exists and is to be used. diff --git a/level_2/fll_program/c/program/print.c b/level_2/fll_program/c/program/print.c index d693556..6f6d30d 100644 --- a/level_2/fll_program/c/program/print.c +++ b/level_2/fll_program/c/program/print.c @@ -6,14 +6,14 @@ extern "C" { #endif #ifndef _di_fll_program_print_copyright_ - f_status_t fll_program_print_copyright(fl_print_t * const print) { + f_status_t fll_program_print_copyright(fl_print_t * const print, const f_string_static_t year_author) { #ifndef _di_level_2_parameter_checking_ if (!print) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ f_file_stream_lock(print->to); - fl_print_format("Copyright © 2007-2024 Kevin Day.%r", print->to, f_string_eol_s); + fl_print_format("Copyright © %Q.%r", print->to, year_author, f_string_eol_s); #ifndef _di_detailed_copyright_ if (print->verbosity > f_console_verbosity_quiet_e) { diff --git a/level_2/fll_program/c/program/print.h b/level_2/fll_program/c/program/print.h index 41cbdef..1b2b9c2 100644 --- a/level_2/fll_program/c/program/print.h +++ b/level_2/fll_program/c/program/print.h @@ -22,6 +22,8 @@ extern "C" { * @param print * The output structure to print to. * The print.verbosity is used to determine how much detail is printed (except for when _di_detailed_copyright_ is set). + * @param year_author + * The year and author to be printed with the copyright symbol line. * * @return * F_okay on success. @@ -30,7 +32,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_fll_program_print_copyright_ - extern f_status_t fll_program_print_copyright(fl_print_t * const print); + extern f_status_t fll_program_print_copyright(fl_print_t * const print, const f_string_static_t year_author); #endif // _di_fll_program_print_copyright_ /** diff --git a/level_3/byte_dump/c/main/byte_dump.c b/level_3/byte_dump/c/main/byte_dump.c index ce24620..d4e610b 100644 --- a/level_3/byte_dump/c/main/byte_dump.c +++ b/level_3/byte_dump/c/main/byte_dump.c @@ -31,7 +31,7 @@ extern "C" { fll_program_print_version(&main->program.message, byte_dump_program_version_s); } else if (main->setting.flag & byte_dump_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & byte_dump_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { diff --git a/level_3/control/c/main/control.c b/level_3/control/c/main/control.c index 7914da0..69699c8 100644 --- a/level_3/control/c/main/control.c +++ b/level_3/control/c/main/control.c @@ -31,7 +31,7 @@ extern "C" { fll_program_print_version(&main->program.message, control_program_version_s); } else if (main->setting.flag & control_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & control_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index cfe5ab9..d5b7abe 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -31,7 +31,7 @@ extern "C" { fll_program_print_version(&main->program.message, controller_program_version_s); } else if (main->setting.flag & controller_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & controller_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { diff --git a/level_3/example/c/main/example.c b/level_3/example/c/main/example.c index d86c400..9f006ce 100644 --- a/level_3/example/c/main/example.c +++ b/level_3/example/c/main/example.c @@ -31,7 +31,7 @@ extern "C" { fll_program_print_version(&main->program.message, example_program_version_s); } else if (main->setting.flag & example_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & example_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { diff --git a/level_3/fake/c/main/fake.c b/level_3/fake/c/main/fake.c index aae7120..4606f73 100644 --- a/level_3/fake/c/main/fake.c +++ b/level_3/fake/c/main/fake.c @@ -31,7 +31,7 @@ extern "C" { fll_program_print_version(&main->program.message, fake_program_version_s); } else if (main->setting.flag & fake_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & fake_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { diff --git a/level_3/firewall/c/main/firewall.c b/level_3/firewall/c/main/firewall.c index 14fe05b..9dd4bc3 100644 --- a/level_3/firewall/c/main/firewall.c +++ b/level_3/firewall/c/main/firewall.c @@ -31,7 +31,7 @@ extern "C" { fll_program_print_version(&main->program.message, firewall_program_version_s); } else if (main->setting.flag & firewall_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & firewall_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { diff --git a/level_3/fss_identify/c/main/fss_identify.c b/level_3/fss_identify/c/main/fss_identify.c index c15ad1d..3a86aa8 100644 --- a/level_3/fss_identify/c/main/fss_identify.c +++ b/level_3/fss_identify/c/main/fss_identify.c @@ -31,7 +31,7 @@ extern "C" { fll_program_print_version(&main->program.message, fss_identify_program_version_s); } else if (main->setting.flag & fss_identify_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & fss_identify_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { diff --git a/level_3/fss_read/c/main/fss_read.c b/level_3/fss_read/c/main/fss_read.c index 9a6ec49..d76b3b7 100644 --- a/level_3/fss_read/c/main/fss_read.c +++ b/level_3/fss_read/c/main/fss_read.c @@ -79,7 +79,7 @@ extern "C" { fll_program_print_version(&main->program.message, fss_read_program_version_s); } else if (main->setting.flag & fss_read_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & fss_read_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { diff --git a/level_3/fss_write/c/main/fss_write.c b/level_3/fss_write/c/main/fss_write.c index 710bb8a..e95b4bc 100644 --- a/level_3/fss_write/c/main/fss_write.c +++ b/level_3/fss_write/c/main/fss_write.c @@ -38,7 +38,7 @@ extern "C" { fll_program_print_version(&main->program.message, fss_write_program_version_s); } else if (main->setting.flag & fss_write_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & fss_write_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { diff --git a/level_3/iki_read/c/main/iki_read.c b/level_3/iki_read/c/main/iki_read.c index 790602f..39ba8b5 100644 --- a/level_3/iki_read/c/main/iki_read.c +++ b/level_3/iki_read/c/main/iki_read.c @@ -31,7 +31,7 @@ extern "C" { fll_program_print_version(&main->program.message, iki_read_program_version_s); } else if (main->setting.flag & iki_read_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & iki_read_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { diff --git a/level_3/iki_write/c/main/iki_write.c b/level_3/iki_write/c/main/iki_write.c index 17deee2..28e1e98 100644 --- a/level_3/iki_write/c/main/iki_write.c +++ b/level_3/iki_write/c/main/iki_write.c @@ -31,7 +31,7 @@ extern "C" { fll_program_print_version(&main->program.message, iki_write_program_version_s); } else if (main->setting.flag & iki_write_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & iki_write_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { diff --git a/level_3/status_code/c/main/status_code.c b/level_3/status_code/c/main/status_code.c index 77a794a..886ab62 100644 --- a/level_3/status_code/c/main/status_code.c +++ b/level_3/status_code/c/main/status_code.c @@ -49,7 +49,7 @@ extern "C" { fll_program_print_version(&main->program.message, status_code_program_version_s); } else if (main->setting.flag & status_code_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & status_code_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { diff --git a/level_3/utf8/c/main/utf8.c b/level_3/utf8/c/main/utf8.c index 67de3a3..2fb3c88 100644 --- a/level_3/utf8/c/main/utf8.c +++ b/level_3/utf8/c/main/utf8.c @@ -31,7 +31,7 @@ extern "C" { fll_program_print_version(&main->program.message, utf8_program_version_s); } else if (main->setting.flag & utf8_main_flag_copyright_e) { - fll_program_print_copyright(&main->program.message); + fll_program_print_copyright(&main->program.message, fll_program_copyright_year_author_s); } if ((main->setting.flag & utf8_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { -- 1.8.3.1