mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-01 16:33:02 +01:00
* g10.c (main, rm_group): Add --ungroup command to remove a particular
group. (add_group): When adding a group with the same name as an already existing group, merge the two groups. (list_config): Show an error message when listing a config item that doesn't exist.
This commit is contained in:
parent
8e2a476fb7
commit
bd31906a21
@ -1,3 +1,12 @@
|
||||
2004-01-28 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
* g10.c (main, rm_group): Add --ungroup command to remove a
|
||||
particular group.
|
||||
(add_group): When adding a group with the same name as an already
|
||||
existing group, merge the two groups.
|
||||
(list_config): Show an error message when listing a config item
|
||||
that doesn't exist.
|
||||
|
||||
2004-01-27 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
* getkey.c: Set MAX_PK_CACHE_ENTRIES and MAX_UID_CACHE_ENTRIES to
|
||||
|
63
g10/g10.c
63
g10/g10.c
@ -298,6 +298,7 @@ enum cmd_and_opt_values
|
||||
oLCctype,
|
||||
oLCmessages,
|
||||
oGroup,
|
||||
oUnGroup,
|
||||
oNoGroups,
|
||||
oStrict,
|
||||
oNoStrict,
|
||||
@ -606,6 +607,7 @@ static ARGPARSE_OPTS opts[] = {
|
||||
{ oLCctype, "lc-ctype", 2, "@" },
|
||||
{ oLCmessages, "lc-messages", 2, "@" },
|
||||
{ oGroup, "group", 2, "@" },
|
||||
{ oUnGroup, "ungroup", 2, "@" },
|
||||
{ oNoGroups, "no-groups", 0, "@" },
|
||||
{ oStrict, "strict", 0, "@" },
|
||||
{ oNoStrict, "no-strict", 0, "@" },
|
||||
@ -861,7 +863,6 @@ add_group(char *string)
|
||||
{
|
||||
char *name,*value;
|
||||
struct groupitem *item;
|
||||
STRLIST values=NULL;
|
||||
|
||||
/* Break off the group name */
|
||||
name=strsep(&string,"=");
|
||||
@ -873,21 +874,52 @@ add_group(char *string)
|
||||
|
||||
trim_trailing_ws(name,strlen(name));
|
||||
|
||||
/* Does this group already exist? */
|
||||
for(item=opt.grouplist;item;item=item->next)
|
||||
if(strcasecmp(item->name,name)==0)
|
||||
break;
|
||||
|
||||
if(!item)
|
||||
{
|
||||
item=m_alloc(sizeof(struct groupitem));
|
||||
item->name=name;
|
||||
item->next=opt.grouplist;
|
||||
item->values=NULL;
|
||||
opt.grouplist=item;
|
||||
}
|
||||
|
||||
/* Break apart the values */
|
||||
while ((value=strsep (&string," \t")))
|
||||
{
|
||||
if (*value)
|
||||
add_to_strlist2(&values,value,utf8_strings);
|
||||
add_to_strlist2(&item->values,value,utf8_strings);
|
||||
}
|
||||
|
||||
item=m_alloc(sizeof(struct groupitem));
|
||||
item->name=name;
|
||||
item->values=values;
|
||||
item->next=opt.grouplist;
|
||||
|
||||
opt.grouplist=item;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
rm_group(char *name)
|
||||
{
|
||||
struct groupitem *item,*last=NULL;
|
||||
|
||||
trim_trailing_ws(name,strlen(name));
|
||||
|
||||
for(item=opt.grouplist;item;last=item,item=item->next)
|
||||
{
|
||||
if(strcasecmp(item->name,name)==0)
|
||||
{
|
||||
if(last)
|
||||
last->next=item->next;
|
||||
else
|
||||
opt.grouplist=item->next;
|
||||
|
||||
free_strlist(item->values);
|
||||
m_free(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* We need to check three things.
|
||||
|
||||
0) The homedir. It must be x00, a directory, and owned by the
|
||||
@ -1098,6 +1130,8 @@ list_config(char *items)
|
||||
|
||||
while(show_all || (name=strsep(&items," ")))
|
||||
{
|
||||
int any=0;
|
||||
|
||||
if(show_all || ascii_strcasecmp(name,"group")==0)
|
||||
{
|
||||
struct groupitem *iter;
|
||||
@ -1119,6 +1153,8 @@ list_config(char *items)
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
any=1;
|
||||
}
|
||||
|
||||
if(show_all || ascii_strcasecmp(name,"version")==0)
|
||||
@ -1126,6 +1162,7 @@ list_config(char *items)
|
||||
printf("cfg:version:");
|
||||
print_string(stdout,VERSION,strlen(VERSION),':');
|
||||
printf("\n");
|
||||
any=1;
|
||||
}
|
||||
|
||||
if(show_all || ascii_strcasecmp(name,"pubkey")==0)
|
||||
@ -1133,6 +1170,7 @@ list_config(char *items)
|
||||
printf("cfg:pubkey:");
|
||||
print_algo_numbers(check_pubkey_algo);
|
||||
printf("\n");
|
||||
any=1;
|
||||
}
|
||||
|
||||
if(show_all || ascii_strcasecmp(name,"cipher")==0)
|
||||
@ -1140,6 +1178,7 @@ list_config(char *items)
|
||||
printf("cfg:cipher:");
|
||||
print_algo_numbers(check_cipher_algo);
|
||||
printf("\n");
|
||||
any=1;
|
||||
}
|
||||
|
||||
if(show_all
|
||||
@ -1149,6 +1188,7 @@ list_config(char *items)
|
||||
printf("cfg:digest:");
|
||||
print_algo_numbers(check_digest_algo);
|
||||
printf("\n");
|
||||
any=1;
|
||||
}
|
||||
|
||||
if(show_all || ascii_strcasecmp(name,"compress")==0)
|
||||
@ -1156,10 +1196,14 @@ list_config(char *items)
|
||||
printf("cfg:compress:");
|
||||
print_algo_numbers(check_compress_algo);
|
||||
printf("\n");
|
||||
any=1;
|
||||
}
|
||||
|
||||
if(show_all)
|
||||
break;
|
||||
|
||||
if(!any)
|
||||
log_error(_("unknown configuration item \"%s\"\n"),name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1862,6 +1906,7 @@ main( int argc, char **argv )
|
||||
case oLCctype: opt.lc_ctype = pargs.r.ret_str; break;
|
||||
case oLCmessages: opt.lc_messages = pargs.r.ret_str; break;
|
||||
case oGroup: add_group(pargs.r.ret_str); break;
|
||||
case oUnGroup: rm_group(pargs.r.ret_str); break;
|
||||
case oNoGroups:
|
||||
while(opt.grouplist)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user