1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Make more use of *_NAME macros.

* configure.ac (GPG_DISP_NAME, GPGSM_DISP_NAME): New.
(GPG_AGENT_DISP_NAME, SCDAEMON_DISP_NAME): New.
(DIRMNGR_DISP_NAME, G13_DISP_NAME): New.
(GPGCONF_DISP_NAME): New.
(SCDAEMON_SOCK_NAME): New.
* common/argparse.c (show_help): Map description string.
This commit is contained in:
Werner Koch 2014-05-07 18:18:27 +02:00
parent fb24808db9
commit cb2aeb4e11
10 changed files with 103 additions and 59 deletions

View File

@ -747,7 +747,8 @@ main (int argc, char **argv )
*/
if (default_config)
configname = make_filename (opt.homedir, "gpg-agent.conf", NULL );
configname = make_filename (opt.homedir, GPG_AGENT_NAME EXTSEP_S "conf",
NULL );
argc = orig_argc;
argv = orig_argv;
@ -956,11 +957,13 @@ main (int argc, char **argv )
char *filename_esc;
/* List options and default values in the GPG Conf format. */
filename = make_filename (opt.homedir, "gpg-agent.conf", NULL );
filename = make_filename (opt.homedir, GPG_AGENT_NAME EXTSEP_S "conf",
NULL );
filename_esc = percent_escape (filename, NULL);
es_printf ("gpgconf-gpg-agent.conf:%lu:\"%s\n",
GC_OPT_FLAG_DEFAULT, filename_esc);
es_printf ("%s-%s.conf:%lu:\"%s\n",
GPGCONF_NAME, GPG_AGENT_NAME,
GC_OPT_FLAG_DEFAULT, filename_esc);
xfree (filename);
xfree (filename_esc);

View File

@ -1126,7 +1126,7 @@ show_help (ARGPARSE_OPTS *opts, unsigned int flags)
writestrings (0, "Options:", "\n", NULL);
for (i=0; opts[i].short_opt; i++ )
{
s = _( opts[i].description );
s = map_static_macro_string (_( opts[i].description ));
if ( s && *s== '@' && !s[1] ) /* Hide this line. */
continue;
if ( s && *s == '@' ) /* Unindented comment only line. */

View File

@ -1689,13 +1689,32 @@ fi
# Define Name strings
#
AC_DEFINE_UNQUOTED(GNUPG_NAME, "GnuPG", [The name of the project])
AC_DEFINE_UNQUOTED(GPG_NAME, "gpg", [The name of the OpenPGP tool])
AC_DEFINE_UNQUOTED(GPG_DISP_NAME, "GnuPG", [The displayed name of gpg])
AC_DEFINE_UNQUOTED(GPGSM_NAME, "gpgsm", [The name of the S/MIME tool])
AC_DEFINE_UNQUOTED(GPGSM_DISP_NAME, "GPGSM", [The displayed name of gpgsm])
AC_DEFINE_UNQUOTED(GPG_AGENT_NAME, "gpg-agent", [The name of the agent])
AC_DEFINE_UNQUOTED(GPG_AGENT_DISP_NAME, "GPG Agent",
[The displayed name of gpg-agent])
AC_DEFINE_UNQUOTED(SCDAEMON_NAME, "scdaemon", [The name of the scdaemon])
AC_DEFINE_UNQUOTED(SCDAEMON_DISP_NAME, "SCDaemon",
[The displayed name of scdaemon])
AC_DEFINE_UNQUOTED(DIRMNGR_NAME, "dirmngr", [The name of the dirmngr])
AC_DEFINE_UNQUOTED(DIRMNGR_DISP_NAME, "DirMngr",
[The displayed name of dirmngr])
AC_DEFINE_UNQUOTED(G13_NAME, "g13", [The name of the g13 tool])
AC_DEFINE_UNQUOTED(G13_DISP_NAME, "G13", [The displayed name of g13])
AC_DEFINE_UNQUOTED(GPGCONF_NAME, "gpgconf", [The name of the gpgconf tool])
AC_DEFINE_UNQUOTED(GPGCONF_DISP_NAME, "GPGConf",
[The displayed name of gpgconf])
AC_DEFINE_UNQUOTED(GPGTAR_NAME, "gpgtar", [The name of the gpgtar tool])
AC_DEFINE_UNQUOTED(GPG_AGENT_INFO_NAME, "GPG_AGENT_INFO",
@ -1706,6 +1725,8 @@ AC_DEFINE_UNQUOTED(GPG_AGENT_SSH_SOCK_NAME, "S.gpg-agent.ssh",
[The name of the agent socket for ssh])
AC_DEFINE_UNQUOTED(DIRMNGR_INFO_NAME, "DIRMNGR_INFO",
[The name of the dirmngr info envvar])
AC_DEFINE_UNQUOTED(SCDAEMON_SOCK_NAME, "S.scdaemon",
[The name of the SCdaemon socket])
AC_DEFINE_UNQUOTED(DIRMNGR_SOCK_NAME, "S.dirmngr",
[The name of the dirmngr socket])

View File

@ -1697,7 +1697,8 @@ gpgconf_list (const char *configfile)
{
char *configfile_esc = percent_escape (configfile, NULL);
es_printf ("gpgconf-gpg.conf:%lu:\"%s\n",
es_printf ("%s-%s.conf:%lu:\"%s\n",
GPGCONF_NAME, GPG_NAME,
GC_OPT_FLAG_DEFAULT,
configfile_esc ? configfile_esc : "/dev/null");
es_printf ("verbose:%lu:\n", GC_OPT_FLAG_NONE);

View File

@ -1590,7 +1590,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr,
#ifdef HAVE_LIBREADLINE
tty_enable_completion (keyedit_completion);
#endif
answer = cpr_get_no_help ("keyedit.prompt", "gpg> ");
answer = cpr_get_no_help ("keyedit.prompt", GPG_NAME "> ");
cpr_kill_prompt ();
tty_disable_completion ();
}

View File

@ -489,7 +489,8 @@ main (int argc, char **argv )
if (default_config)
configname = make_filename (opt.homedir, "scdaemon.conf", NULL );
configname = make_filename (opt.homedir, SCDAEMON_NAME EXTSEP_S "conf",
NULL );
argc = orig_argc;
@ -659,10 +660,12 @@ main (int argc, char **argv )
if (config_filename)
filename = xstrdup (config_filename);
else
filename = make_filename (opt.homedir, "scdaemon.conf", NULL);
filename = make_filename (opt.homedir, SCDAEMON_NAME EXTSEP_S "conf",
NULL);
filename_esc = percent_escape (filename, NULL);
es_printf ("gpgconf-scdaemon.conf:%lu:\"%s\n",
es_printf ("%s-%s.conf:%lu:\"%s\n",
GPGCONF_NAME, SCDAEMON_NAME,
GC_OPT_FLAG_DEFAULT, filename_esc);
xfree (filename_esc);
xfree (filename);
@ -742,8 +745,8 @@ main (int argc, char **argv )
if (multi_server)
{
socket_name = create_socket_name (standard_socket,
"S.scdaemon",
"gpg-XXXXXX/S.scdaemon");
SCDAEMON_SOCK_NAME,
"gpg-XXXXXX/" SCDAEMON_SOCK_NAME);
fd = FD2INT(create_server_socket (standard_socket,
socket_name, &socket_nonce));
@ -798,8 +801,8 @@ main (int argc, char **argv )
/* Create the socket. */
socket_name = create_socket_name (standard_socket,
"S.scdaemon",
"gpg-XXXXXX/S.scdaemon");
SCDAEMON_SOCK_NAME,
"gpg-XXXXXX/" SCDAEMON_SOCK_NAME);
fd = FD2INT (create_server_socket (standard_socket,
socket_name, &socket_nonce));

View File

@ -899,7 +899,7 @@ main ( int argc, char **argv)
/*mtrace();*/
gnupg_reopen_std ("gpgsm");
gnupg_reopen_std (GPGSM_NAME);
/* trap_unaligned ();*/
gnupg_rl_initialize ();
set_strusage (my_strusage);
@ -908,7 +908,7 @@ main ( int argc, char **argv)
/* Please note that we may running SUID(ROOT), so be very CAREFUL
when adding any stuff between here and the call to secmem_init()
somewhere after the option parsing */
log_set_prefix ("gpgsm", 1);
log_set_prefix (GPGSM_NAME, 1);
/* Make sure that our subsystems are ready. */
i18n_init ();
@ -998,7 +998,7 @@ main ( int argc, char **argv)
/* Set the default option file */
if (default_config )
configname = make_filename (opt.homedir, "gpgsm.conf", NULL);
configname = make_filename (opt.homedir, GPGSM_NAME EXTSEP_S "conf", NULL);
/* Set the default policy file */
opt.policy_file = make_filename (opt.homedir, "policies.txt", NULL);
@ -1422,7 +1422,8 @@ main ( int argc, char **argv)
configname = NULL;
if (!opt.config_filename)
opt.config_filename = make_filename (opt.homedir, "gpgsm.conf", NULL);
opt.config_filename = make_filename (opt.homedir, GPG_NAME EXTSEP_S "conf",
NULL);
if (log_get_errorcount(0))
gpgsm_exit(2);
@ -1653,7 +1654,8 @@ main ( int argc, char **argv)
{ /* List options and default values in the GPG Conf format. */
char *config_filename_esc = percent_escape (opt.config_filename, NULL);
es_printf ("gpgconf-gpgsm.conf:%lu:\"%s\n",
es_printf ("%s-%s.conf:%lu:\"%s\n",
GPGCONF_NAME, GPGSM_NAME,
GC_OPT_FLAG_DEFAULT, config_filename_esc);
xfree (config_filename_esc);

View File

@ -180,20 +180,20 @@ static struct
} gc_backend[GC_BACKEND_NR] =
{
{ NULL }, /* GC_BACKEND_ANY dummy entry. */
{ GNUPG_NAME, GPGNAME, GNUPG_MODULE_NAME_GPG,
NULL, "gpgconf-gpg.conf" },
{ "GPGSM", GPGSM_NAME, GNUPG_MODULE_NAME_GPGSM,
NULL, "gpgconf-gpgsm.conf" },
{ "GPG Agent", GPG_AGENT_NAME, GNUPG_MODULE_NAME_AGENT,
gpg_agent_runtime_change, "gpgconf-gpg-agent.conf" },
{ "SCDaemon", SCDAEMON_NAME, GNUPG_MODULE_NAME_SCDAEMON,
scdaemon_runtime_change, "gpgconf-scdaemon.conf" },
{ "DirMngr", DIRMNGR_NAME, GNUPG_MODULE_NAME_DIRMNGR,
NULL, "gpgconf-dirmngr.conf" },
{ "DirMngr LDAP Server List", NULL, 0,
{ GPG_DISP_NAME, GPGNAME, GNUPG_MODULE_NAME_GPG,
NULL, GPGCONF_NAME "-" GPG_NAME ".conf" },
{ GPGSM_DISP_NAME, GPGSM_NAME, GNUPG_MODULE_NAME_GPGSM,
NULL, GPGCONF_NAME "-" GPGSM_NAME ".conf" },
{ GPG_AGENT_DISP_NAME, GPG_AGENT_NAME, GNUPG_MODULE_NAME_AGENT,
gpg_agent_runtime_change, GPGCONF_NAME"-" GPG_AGENT_NAME ".conf" },
{ SCDAEMON_DISP_NAME, SCDAEMON_NAME, GNUPG_MODULE_NAME_SCDAEMON,
scdaemon_runtime_change, GPGCONF_NAME"-" SCDAEMON_NAME ".conf" },
{ DIRMNGR_DISP_NAME, DIRMNGR_NAME, GNUPG_MODULE_NAME_DIRMNGR,
NULL, GPGCONF_NAME "-" DIRMNGR_NAME ".conf" },
{ DIRMNGR_DISP_NAME " LDAP Server List", NULL, 0,
NULL, "ldapserverlist-file", "LDAP Server" },
{ "Pinentry", "pinentry", GNUPG_MODULE_NAME_PINENTRY,
NULL, "gpgconf-pinentry.conf" },
NULL, GPGCONF_NAME "-pinentry.conf" },
};
@ -470,7 +470,8 @@ typedef struct gc_option gc_option_t;
static gc_option_t gc_options_gpg_agent[] =
{
/* The configuration file to which we write the changes. */
{ "gpgconf-gpg-agent.conf", GC_OPT_FLAG_NONE, GC_LEVEL_INTERNAL,
{ GPGCONF_NAME"-" GPG_AGENT_NAME ".conf",
GC_OPT_FLAG_NONE, GC_LEVEL_INTERNAL,
NULL, NULL, GC_ARG_TYPE_FILENAME, GC_BACKEND_GPG_AGENT },
{ "Monitor",
@ -584,7 +585,8 @@ static gc_option_t gc_options_gpg_agent[] =
static gc_option_t gc_options_scdaemon[] =
{
/* The configuration file to which we write the changes. */
{ "gpgconf-scdaemon.conf", GC_OPT_FLAG_NONE, GC_LEVEL_INTERNAL,
{ GPGCONF_NAME"-"SCDAEMON_NAME".conf",
GC_OPT_FLAG_NONE, GC_LEVEL_INTERNAL,
NULL, NULL, GC_ARG_TYPE_FILENAME, GC_BACKEND_SCDAEMON },
{ "Monitor",
@ -658,7 +660,8 @@ static gc_option_t gc_options_scdaemon[] =
static gc_option_t gc_options_gpg[] =
{
/* The configuration file to which we write the changes. */
{ "gpgconf-gpg.conf", GC_OPT_FLAG_NONE, GC_LEVEL_INTERNAL,
{ GPGCONF_NAME"-"GPG_NAME".conf",
GC_OPT_FLAG_NONE, GC_LEVEL_INTERNAL,
NULL, NULL, GC_ARG_TYPE_FILENAME, GC_BACKEND_GPG },
{ "Monitor",
@ -736,7 +739,8 @@ static gc_option_t gc_options_gpg[] =
static gc_option_t gc_options_gpgsm[] =
{
/* The configuration file to which we write the changes. */
{ "gpgconf-gpgsm.conf", GC_OPT_FLAG_NONE, GC_LEVEL_INTERNAL,
{ GPGCONF_NAME"-"GPGSM_NAME".conf",
GC_OPT_FLAG_NONE, GC_LEVEL_INTERNAL,
NULL, NULL, GC_ARG_TYPE_FILENAME, GC_BACKEND_GPGSM },
{ "Monitor",
@ -831,7 +835,8 @@ static gc_option_t gc_options_gpgsm[] =
static gc_option_t gc_options_dirmngr[] =
{
/* The configuration file to which we write the changes. */
{ "gpgconf-dirmngr.conf", GC_OPT_FLAG_NONE, GC_LEVEL_INTERNAL,
{ GPGCONF_NAME"-"DIRMNGR_NAME".conf",
GC_OPT_FLAG_NONE, GC_LEVEL_INTERNAL,
NULL, NULL, GC_ARG_TYPE_FILENAME, GC_BACKEND_DIRMNGR },
{ "Monitor",
@ -973,7 +978,8 @@ static gc_option_t gc_options_pinentry[] =
{
/* A dummy option to allow gc_component_list_components to find the
pinentry backend. Needs to be a conf file. */
{ "gpgconf-pinentry.conf", GC_OPT_FLAG_NONE, GC_LEVEL_INTERNAL,
{ GPGCONF_NAME"-pinentry.conf",
GC_OPT_FLAG_NONE, GC_LEVEL_INTERNAL,
NULL, NULL, GC_ARG_TYPE_FILENAME, GC_BACKEND_PINENTRY },
GC_OPTION_NULL
@ -2414,7 +2420,7 @@ change_options_file (gc_component_t component, gc_backend_t backend,
char **src_filenamep, char **dest_filenamep,
char **orig_filenamep)
{
static const char marker[] = "###+++--- GPGConf ---+++###";
static const char marker[] = "###+++--- " GPGCONF_DISP_NAME " ---+++###";
/* True if we are within the marker in the config file. */
int in_marker = 0;
gc_option_t *option;
@ -2441,8 +2447,10 @@ change_options_file (gc_component_t component, gc_backend_t backend,
/* Note that get_config_filename() calls percent_deescape(), so we
call this before processing the arguments. */
dest_filename = xstrdup (get_config_filename (component, backend));
src_filename = xasprintf ("%s.gpgconf.%i.new", dest_filename, (int)getpid ());
orig_filename = xasprintf ("%s.gpgconf.%i.bak", dest_filename,(int)getpid ());
src_filename = xasprintf ("%s.%s.%i.new",
dest_filename, GPGCONF_NAME, (int)getpid ());
orig_filename = xasprintf ("%s.%s.%i.bak",
dest_filename, GPGCONF_NAME, (int)getpid ());
arg = option->new_value;
if (arg && arg[0] == '\0')
@ -2579,8 +2587,8 @@ change_options_file (gc_component_t component, gc_backend_t backend,
if (!in_marker)
{
fprintf (src_file,
"# GPGConf disabled this option here at %s\n",
asctimestamp (gnupg_get_time ()));
"# %s disabled this option here at %s\n",
GPGCONF_DISP_NAME, asctimestamp (gnupg_get_time ()));
if (ferror (src_file))
goto change_file_one_err;
fprintf (src_file, "# %s", line);
@ -2648,7 +2656,8 @@ change_options_file (gc_component_t component, gc_backend_t backend,
if (!in_marker)
{
fprintf (src_file, "# GPGConf edited this configuration file.\n");
fprintf (src_file, "# %s edited this configuration file.\n",
GPGCONF_DISP_NAME);
if (ferror (src_file))
goto change_file_one_err;
fprintf (src_file, "# It will disable options before this marked "
@ -2714,7 +2723,7 @@ change_options_program (gc_component_t component, gc_backend_t backend,
char **src_filenamep, char **dest_filenamep,
char **orig_filenamep)
{
static const char marker[] = "###+++--- GPGConf ---+++###";
static const char marker[] = "###+++--- " GPGCONF_DISP_NAME " ---+++###";
/* True if we are within the marker in the config file. */
int in_marker = 0;
gc_option_t *option;
@ -2733,8 +2742,10 @@ change_options_program (gc_component_t component, gc_backend_t backend,
/* FIXME. Throughout the function, do better error reporting. */
dest_filename = xstrdup (get_config_filename (component, backend));
src_filename = xasprintf ("%s.gpgconf.%i.new", dest_filename, (int)getpid ());
orig_filename = xasprintf ("%s.gpgconf.%i.bak", dest_filename,(int)getpid ());
src_filename = xasprintf ("%s.%s.%i.new",
dest_filename, GPGCONF_NAME, (int)getpid ());
orig_filename = xasprintf ("%s.%s.%i.bak",
dest_filename, GPGCONF_NAME, (int)getpid ());
#ifdef HAVE_W32_SYSTEM
res = copy_file (dest_filename, orig_filename);
@ -2825,8 +2836,8 @@ change_options_program (gc_component_t component, gc_backend_t backend,
if (!in_marker)
{
fprintf (src_file,
"# GPGConf disabled this option here at %s\n",
asctimestamp (gnupg_get_time ()));
"# %s disabled this option here at %s\n",
GPGCONF_DISP_NAME, asctimestamp (gnupg_get_time ()));
if (ferror (src_file))
goto change_one_err;
fprintf (src_file, "# %s", line);
@ -2946,7 +2957,8 @@ change_options_program (gc_component_t component, gc_backend_t backend,
if (!in_marker)
{
fprintf (src_file, "# GPGConf edited this configuration file.\n");
fprintf (src_file, "# %s edited this configuration file.\n",
GPGCONF_DISP_NAME);
if (ferror (src_file))
goto change_one_err;
fprintf (src_file, "# It will disable options before this marked "
@ -3287,7 +3299,8 @@ gc_component_change_options (int component, estream_t in, estream_t out)
assert (dest_filename[backend]);
backup_filename = xasprintf ("%s.gpgconf.bak", dest_filename[backend]);
backup_filename = xasprintf ("%s.%s.bak",
dest_filename[backend], GPGCONF_NAME);
#ifdef HAVE_W32_SYSTEM
/* There is no atomic update on W32. */
@ -3436,7 +3449,8 @@ gc_process_gpgconf_conf (const char *fname_arg, int update, int defaults,
if (fname_arg)
fname = xstrdup (fname_arg);
else
fname = make_filename (gnupg_sysconfdir (), "gpgconf.conf", NULL);
fname = make_filename (gnupg_sysconfdir (), GPGCONF_NAME EXTSEP_S "conf",
NULL);
for (backend_id = 0; backend_id < GC_BACKEND_NR; backend_id++)
runtime[backend_id] = 0;

View File

@ -70,7 +70,7 @@ static ARGPARSE_OPTS opts[] =
{ aApplyDefaults, "apply-defaults", 256,
N_("apply global default values") },
{ aListDirs, "list-dirs", 256,
N_("get the configuration directories for gpgconf") },
N_("get the configuration directories for @GPGCONF@") },
{ aListConfig, "list-config", 256,
N_("list global configuration file") },
{ aCheckConfig, "check-config", 256,
@ -151,9 +151,9 @@ main (int argc, char **argv)
enum cmd_and_opt_values cmd = 0;
estream_t outfp = NULL;
gnupg_reopen_std ("gpgconf");
gnupg_reopen_std (GPGCONF_NAME);
set_strusage (my_strusage);
log_set_prefix ("gpgconf", 1);
log_set_prefix (GPGCONF_NAME, 1);
/* Make sure that our subsystems are ready. */
i18n_init();
@ -228,7 +228,7 @@ main (int argc, char **argv)
case aCheckOptions:
if (!fname)
{
es_fputs (_("usage: gpgconf [options] "), es_stderr);
es_fprintf (es_stderr, _("usage: %s [options] "), GPGCONF_NAME);
es_putc ('\n', es_stderr);
es_fputs (_("Need one component argument"), es_stderr);
es_putc ('\n', es_stderr);
@ -262,7 +262,7 @@ main (int argc, char **argv)
case aKill:
if (!fname)
{
es_fputs (_("usage: gpgconf [options] "), es_stderr);
es_fprintf (es_stderr, _("usage: %s [options] "), GPGCONF_NAME);
es_putc ('\n', es_stderr);
es_fputs (_("Need one component argument"), es_stderr);
es_putc ('\n', es_stderr);
@ -325,7 +325,7 @@ main (int argc, char **argv)
case aApplyDefaults:
if (fname)
{
es_fputs (_("usage: gpgconf [options] "), es_stderr);
es_fprintf (es_stderr, _("usage: %s [options] "), GPGCONF_NAME);
es_putc ('\n', es_stderr);
es_fputs (_("No argument allowed"), es_stderr);
es_putc ('\n', es_stderr);

View File

@ -172,9 +172,9 @@ main (int argc, char **argv)
assert (sizeof (struct ustar_raw_header) == 512);
gnupg_reopen_std ("gpgtar");
gnupg_reopen_std (GPGTAR_NAME);
set_strusage (my_strusage);
log_set_prefix ("gpgtar", 1);
log_set_prefix (GPGTAR_NAME, 1);
/* Make sure that our subsystems are ready. */
i18n_init();