From 8d837279bce7fbbf72e1751ff1bd2c8889e96fb4 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 28 May 2025 15:19:19 +0200 Subject: common: Improve helpfile.c to provide a generic template API. * common/util.h (GET_TEMPLATE_CURRENT_LOCALE): New. (GET_TEMPLATE_SUBST_ENVVARS): New. (GET_TEMPLATE_CRLF): New. * common/helpfile.c (findkey_fname): Add arg flags and terminate line with CRLF if requested. (findkey_locale): Replace arg only_current_locale by flags and add arg domain. (gnupg_get_help_string): Factor all code out to ... (gnupg_get_template): new. Add arg domain. Handle SUBST flags. Do not trim tralins spaces with the CRLF flag. * common/t-helpfile.c (main): Require domain name and add two options. --- common/util.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'common/util.h') diff --git a/common/util.h b/common/util.h index 20456349c..ce1dc37d8 100644 --- a/common/util.h +++ b/common/util.h @@ -296,6 +296,14 @@ void gnupg_set_builddir (const char *newdir); void gnupg_rl_initialize (void); /*-- helpfile.c --*/ + +/* Bit flags for gnupg_get_template. */ +#define GET_TEMPLATE_CURRENT_LOCALE 1 /* Use only the current locale. */ +#define GET_TEMPLATE_SUBST_ENVVARS 2 /* Substitute environment variables. */ +#define GET_TEMPLATE_CRLF 4 /* Use CR+LF. */ + +char *gnupg_get_template (const char *domain, const char *key, + unsigned int flags); char *gnupg_get_help_string (const char *key, int only_current_locale); /*-- localename.c --*/ -- cgit v1.2.3