From: Kevin Day Date: Thu, 19 Sep 2024 03:50:59 +0000 (-0500) Subject: Update: Add missing fll_program function for short option, fix some parameters, and... X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=c750a9f95ada891a3d28872103a073dc7be88bcc;p=fll Update: Add missing fll_program function for short option, fix some parameters, and fix ordering of a function. The `fll_program_print_help_option_short()` function is missing, should be defined, and now is defined. The `description` parameters for these functions should have the `const` qualifier. The `fll_program_print_help_option_standard()` implementation is not in the correct alphabetical position. --- diff --git a/level_2/fll_program/c/private-program.c b/level_2/fll_program/c/private-program.c index 1599715..5194b12 100644 --- a/level_2/fll_program/c/private-program.c +++ b/level_2/fll_program/c/private-program.c @@ -68,7 +68,7 @@ extern "C" { #endif // !defined(_di_fll_program_parameter_process_context_) || !defined(_di_fll_program_parameter_process_context_standard_) #if !defined(_di_fll_program_print_help_option_) || !defined(_di_fll_program_print_help_option_standard_) - f_status_t private_fll_program_print_help_option(fl_print_t * const print, const f_string_static_t option_short, const f_string_static_t option_long, const f_string_static_t symbol_short, const f_string_static_t symbol_long, const char *description) { + f_status_t private_fll_program_print_help_option(fl_print_t * const print, const f_string_static_t option_short, const f_string_static_t option_long, const f_string_static_t symbol_short, const f_string_static_t symbol_long, const char * const description) { fl_print_format(" %Q%[%Q%]", print->to, symbol_short, print->set->standout, option_short, print->set->standout); fl_print_format(", %Q%[%Q%] %S%r", print->to, symbol_long, print->set->standout, option_long, print->set->standout, description, f_string_eol_s); diff --git a/level_2/fll_program/c/private-program.h b/level_2/fll_program/c/private-program.h index 3262cfb..4891331 100644 --- a/level_2/fll_program/c/private-program.h +++ b/level_2/fll_program/c/private-program.h @@ -80,7 +80,7 @@ extern "C" { * @see fll_program_print_help_option_standard() */ #if !defined(_di_fll_program_print_help_option_) || !defined(_di_fll_program_print_help_option_standard_) - extern f_status_t private_fll_program_print_help_option(fl_print_t * const print, const f_string_static_t option_short, const f_string_static_t option_long, const f_string_static_t symbol_short, const f_string_static_t symbol_long, const char *description) F_attribute_visibility_internal_d; + extern f_status_t private_fll_program_print_help_option(fl_print_t * const print, const f_string_static_t option_short, const f_string_static_t option_long, const f_string_static_t symbol_short, const f_string_static_t symbol_long, const char * const description) F_attribute_visibility_internal_d; #endif // !defined(_di_fll_program_print_help_option_) || !defined(_di_fll_program_print_help_option_standard_) /** diff --git a/level_2/fll_program/c/program/print.c b/level_2/fll_program/c/program/print.c index 7c59693..63e7228 100644 --- a/level_2/fll_program/c/program/print.c +++ b/level_2/fll_program/c/program/print.c @@ -574,7 +574,7 @@ extern "C" { #endif // _di_fll_program_print_help_operations_ #ifndef _di_fll_program_print_help_option_ - f_status_t fll_program_print_help_option(fl_print_t * const print, const f_string_static_t option_short, const f_string_static_t option_long, const f_string_static_t symbol_short, const f_string_static_t symbol_long, const char *description) { + f_status_t fll_program_print_help_option(fl_print_t * const print, const f_string_static_t option_short, const f_string_static_t option_long, const f_string_static_t symbol_short, const f_string_static_t symbol_long, const char * const description) { #ifndef _di_level_2_parameter_checking_ if (!print) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ @@ -583,51 +583,63 @@ extern "C" { } #endif // _di_fll_program_print_help_option_ -#ifndef _di_fll_program_print_help_option_standard_ - f_status_t fll_program_print_help_option_standard(fl_print_t * const print) { +#ifndef _di_fll_program_print_help_option_long_ + f_status_t fll_program_print_help_option_long(fl_print_t * const print, const f_string_static_t option_long, const f_string_static_t symbol_long, const char * const description) { #ifndef _di_level_2_parameter_checking_ if (!print) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ - private_fll_program_print_help_option(print, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print this help message."); - private_fll_program_print_help_option(print, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, "Print the copyright."); - private_fll_program_print_help_option(print, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Output using colors that show up better on dark backgrounds."); - private_fll_program_print_help_option(print, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Output using colors that show up better on light backgrounds."); - private_fll_program_print_help_option(print, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Do not print using color."); - private_fll_program_print_help_option(print, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Decrease verbosity, silencing most print->to."); - private_fll_program_print_help_option(print, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Decrease verbosity, using only error print->to."); - private_fll_program_print_help_option(print, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Set verbosity to normal."); - private_fll_program_print_help_option(print, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Increase verbosity beyond normal print->to."); - private_fll_program_print_help_option(print, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Enable debugging, significantly increasing verbosity beyond normal print->to."); - private_fll_program_print_help_option(print, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Print only the version number."); + fl_print_format(" %Q%[%Q%] %S%r", print->to, symbol_long, print->set->standout, option_long, print->set->standout, description, f_string_eol_s); return F_okay; } -#endif // _di_fll_program_print_help_option_standard_ +#endif // _di_fll_program_print_help_option_long_ -#ifndef _di_fll_program_print_help_option_long_ - f_status_t fll_program_print_help_option_long(fl_print_t * const print, const f_string_static_t option_long, const f_string_static_t symbol_long, const char *description) { +#ifndef _di_fll_program_print_help_option_other_ + f_status_t fll_program_print_help_option_other(fl_print_t * const print, const f_string_static_t option_other, const char * const description) { #ifndef _di_level_2_parameter_checking_ if (!print) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ - fl_print_format(" %Q%[%Q%] %S%r", print->to, symbol_long, print->set->standout, option_long, print->set->standout, description, f_string_eol_s); + fl_print_format(" %[%Q%] %S%r", print->to, print->set->standout, option_other, print->set->standout, description, f_string_eol_s); return F_okay; } -#endif // _di_fll_program_print_help_option_long_ +#endif // _di_fll_program_print_help_option_other_ -#ifndef _di_fll_program_print_help_option_other_ - f_status_t fll_program_print_help_option_other(fl_print_t * const print, const f_string_static_t option_other, const char *description) { +#ifndef _di_fll_program_print_help_option_short_ + f_status_t fll_program_print_help_option_short(fl_print_t * const print, const f_string_static_t option_short, const f_string_static_t symbol_short, const char * const description) { #ifndef _di_level_2_parameter_checking_ if (!print) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ - fl_print_format(" %[%Q%] %S%r", print->to, print->set->standout, option_other, print->set->standout, description, f_string_eol_s); + fl_print_format(" %Q%[%Q%] %S%r", print->to, symbol_short, print->set->standout, option_short, print->set->standout, description, f_string_eol_s); return F_okay; } -#endif // _di_fll_program_print_help_option_other_ +#endif // _di_fll_program_print_help_option_short_ + +#ifndef _di_fll_program_print_help_option_standard_ + f_status_t fll_program_print_help_option_standard(fl_print_t * const print) { + #ifndef _di_level_2_parameter_checking_ + if (!print) return F_status_set_error(F_parameter); + #endif // _di_level_2_parameter_checking_ + + private_fll_program_print_help_option(print, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print this help message."); + private_fll_program_print_help_option(print, f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, "Print the copyright."); + private_fll_program_print_help_option(print, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Output using colors that show up better on dark backgrounds."); + private_fll_program_print_help_option(print, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Output using colors that show up better on light backgrounds."); + private_fll_program_print_help_option(print, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Do not print using color."); + private_fll_program_print_help_option(print, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Decrease verbosity, silencing most print->to."); + private_fll_program_print_help_option(print, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Decrease verbosity, using only error print->to."); + private_fll_program_print_help_option(print, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Set verbosity to normal."); + private_fll_program_print_help_option(print, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Increase verbosity beyond normal print->to."); + private_fll_program_print_help_option(print, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Enable debugging, significantly increasing verbosity beyond normal print->to."); + private_fll_program_print_help_option(print, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Print only the version number."); + + return F_okay; + } +#endif // _di_fll_program_print_help_option_standard_ #ifndef _di_fll_program_print_help_special_options_ f_status_t fll_program_print_help_special_options(fl_print_t * const print) { diff --git a/level_2/fll_program/c/program/print.h b/level_2/fll_program/c/program/print.h index e0bc4d2..9d5acf8 100644 --- a/level_2/fll_program/c/program/print.h +++ b/level_2/fll_program/c/program/print.h @@ -866,7 +866,7 @@ extern "C" { * @see fl_print_format() */ #ifndef _di_fll_program_print_help_option_ - extern f_status_t fll_program_print_help_option(fl_print_t * const print, const f_string_static_t option_short, const f_string_static_t option_long, const f_string_static_t symbol_short, const f_string_static_t symbol_long, const char *description); + extern f_status_t fll_program_print_help_option(fl_print_t * const print, const f_string_static_t option_short, const f_string_static_t option_long, const f_string_static_t symbol_short, const f_string_static_t symbol_long, const char * const description); #endif // _di_fll_program_print_help_option_ /** @@ -894,7 +894,7 @@ extern "C" { * @see fl_print_format() */ #ifndef _di_fll_program_print_help_option_long_ - extern f_status_t fll_program_print_help_option_long(fl_print_t * const print, const f_string_static_t option_long, const f_string_static_t symbol_long, const char *description); + extern f_status_t fll_program_print_help_option_long(fl_print_t * const print, const f_string_static_t option_long, const f_string_static_t symbol_long, const char * const description); #endif // _di_fll_program_print_help_option_long_ /** @@ -920,10 +920,38 @@ extern "C" { * @see fl_print_format() */ #ifndef _di_fll_program_print_help_option_other_ - extern f_status_t fll_program_print_help_option_other(fl_print_t * const print, const f_string_static_t option_other, const char *description); + extern f_status_t fll_program_print_help_option_other(fl_print_t * const print, const f_string_static_t option_other, const char * const description); #endif // _di_fll_program_print_help_option_other_ /** + * Print standard help option (short option only). + * + * This print function does not use locking, be sure something like flockfile() and funlockfile() are appropriately called. + * + * @param print + * The output structure to print to. + * This uses but does not lock or unlock file stream. + * This requires print.set to be non-NULL. + * @param option_short + * The short name of the option. + * @param symbol_short + * The short symbol of the option. + * @param description + * A desciption associated with the option. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * @see fl_print_format() + */ +#ifndef _di_fll_program_print_help_option_short_ + extern f_status_t fll_program_print_help_option_short(fl_print_t * const print, const f_string_static_t option_short, const f_string_static_t symbol_short, const char * const description); +#endif // _di_fll_program_print_help_option_short_ + +/** * Print all standard help options. * * This print function does not use locking, be sure something like flockfile() and funlockfile() are appropriately called.