mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
2004-02-25 Marcus Brinkmann <marcus@g10code.de>
* gpgconf-comp.c (struct gc_option): Add new member new_flags. (option_check_validity): Check OPTION->new_flags beside OPTION->new_value. Add new argument FLAGS. (gc_component_change_options): Support default flag correctly. (change_options_program): Likewise.
This commit is contained in:
parent
8f8c5c47dd
commit
8817c66900
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
* gpgconf-comp.c (gc_component_list_options): Correct output for
|
* gpgconf-comp.c (gc_component_list_options): Correct output for
|
||||||
lists of arg type none.
|
lists of arg type none.
|
||||||
|
(struct gc_option): Add new member new_flags.
|
||||||
|
(option_check_validity): Check OPTION->new_flags beside
|
||||||
|
OPTION->new_value. Add new argument FLAGS.
|
||||||
|
(gc_component_change_options): Support default flag correctly.
|
||||||
|
(change_options_program): Likewise.
|
||||||
|
|
||||||
2004-02-24 Marcus Brinkmann <marcus@g10code.de>
|
2004-02-24 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
@ -386,6 +386,11 @@ struct gc_option
|
|||||||
/* The current value of this option. */
|
/* The current value of this option. */
|
||||||
char *value;
|
char *value;
|
||||||
|
|
||||||
|
/* The new flags for this option. The only defined flag is actually
|
||||||
|
GC_OPT_FLAG_DEFAULT, and it means that the option should be
|
||||||
|
deleted. In this case, NEW_VALUE is NULL. */
|
||||||
|
unsigned long new_flags;
|
||||||
|
|
||||||
/* The new value of this option. */
|
/* The new value of this option. */
|
||||||
char *new_value;
|
char *new_value;
|
||||||
};
|
};
|
||||||
@ -1213,11 +1218,16 @@ gc_component_retrieve_options (int component)
|
|||||||
|
|
||||||
/* Perform a simple validity check based on the type. */
|
/* Perform a simple validity check based on the type. */
|
||||||
static void
|
static void
|
||||||
option_check_validity (gc_option_t *option, const char *new_value)
|
option_check_validity (gc_option_t *option, unsigned long flags,
|
||||||
|
const char *new_value)
|
||||||
{
|
{
|
||||||
if (option->new_value)
|
if (option->new_flags || option->new_value)
|
||||||
gc_error (1, 0, "option %s already changed", option->name);
|
gc_error (1, 0, "option %s already changed", option->name);
|
||||||
|
|
||||||
|
if ((flags & GC_OPT_FLAG_DEFAULT) && *new_value)
|
||||||
|
gc_error (1, 0, "value %s provided for deleted option %s",
|
||||||
|
new_value, option->name);
|
||||||
|
|
||||||
if (!*new_value)
|
if (!*new_value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1332,7 +1342,7 @@ change_options_program (gc_component_t component, gc_backend_t backend,
|
|||||||
|
|
||||||
option = find_option (component, start, backend);
|
option = find_option (component, start, backend);
|
||||||
*end = saved_end;
|
*end = saved_end;
|
||||||
if (option && option->new_value)
|
if (option && (option->new_flags & GC_OPT_FLAG_DEFAULT))
|
||||||
disable = 1;
|
disable = 1;
|
||||||
}
|
}
|
||||||
if (disable)
|
if (disable)
|
||||||
@ -1379,7 +1389,7 @@ change_options_program (gc_component_t component, gc_backend_t backend,
|
|||||||
option = gc_component[component].options;
|
option = gc_component[component].options;
|
||||||
while (option->name)
|
while (option->name)
|
||||||
{
|
{
|
||||||
/* FIXME: Add support for lists. */
|
/* FIXME: Add support for lists and default arg (new_value eq ""). */
|
||||||
if (!(option->flags & GC_OPT_FLAG_GROUP)
|
if (!(option->flags & GC_OPT_FLAG_GROUP)
|
||||||
&& option->backend == backend
|
&& option->backend == backend
|
||||||
&& option->new_value
|
&& option->new_value
|
||||||
@ -1487,7 +1497,7 @@ gc_component_change_options (int component, FILE *in)
|
|||||||
{
|
{
|
||||||
char *linep;
|
char *linep;
|
||||||
unsigned long flags = 0;
|
unsigned long flags = 0;
|
||||||
char *new_value = NULL;
|
char *new_value = "";
|
||||||
|
|
||||||
/* Strip newline and carriage return, if present. */
|
/* Strip newline and carriage return, if present. */
|
||||||
while (length > 0
|
while (length > 0
|
||||||
@ -1528,8 +1538,7 @@ gc_component_change_options (int component, FILE *in)
|
|||||||
if (end)
|
if (end)
|
||||||
*(end++) = '\0';
|
*(end++) = '\0';
|
||||||
|
|
||||||
if (!(flags & GC_OPT_FLAG_DEFAULT))
|
new_value = linep;
|
||||||
new_value = linep;
|
|
||||||
|
|
||||||
linep = end;
|
linep = end;
|
||||||
}
|
}
|
||||||
@ -1538,13 +1547,11 @@ gc_component_change_options (int component, FILE *in)
|
|||||||
if (!option)
|
if (!option)
|
||||||
gc_error (1, 0, "unknown option %s", line);
|
gc_error (1, 0, "unknown option %s", line);
|
||||||
|
|
||||||
/* FIXME: This is not correct, as it ignores the optional arg
|
option_check_validity (option, flags, new_value);
|
||||||
case. */
|
|
||||||
if (flags & GC_OPT_FLAG_DEFAULT)
|
|
||||||
new_value = "";
|
|
||||||
|
|
||||||
option_check_validity (option, new_value);
|
option->new_flags = flags;
|
||||||
option->new_value = xstrdup (new_value);
|
if (!(flags & GC_OPT_FLAG_DEFAULT))
|
||||||
|
option->new_value = xstrdup (new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now that we have collected and locally verified the changes,
|
/* Now that we have collected and locally verified the changes,
|
||||||
@ -1555,7 +1562,7 @@ gc_component_change_options (int component, FILE *in)
|
|||||||
{
|
{
|
||||||
/* Go on if we have already seen this backend, or if there is
|
/* Go on if we have already seen this backend, or if there is
|
||||||
nothing to do. */
|
nothing to do. */
|
||||||
if (src_pathname[option->backend] || !option->new_value)
|
if (src_pathname[option->backend] || !(option->new_flags || option->new_value))
|
||||||
{
|
{
|
||||||
option++;
|
option++;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user