mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-21 14:47:03 +01:00
* g10.c (collapse_args): New function to turn argc/argv into a single
string. (main): Use it here to pass list_config() more than one argument as a single string. (print_algo_numbers): Helper to print algorithm numbers. (list_config): Use it here for "pubkey", "cipher", "hash"/"digest", and "compress" config options.
This commit is contained in:
parent
2a23fe9019
commit
3373615cfd
@ -1,3 +1,13 @@
|
||||
2004-01-15 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
* g10.c (collapse_args): New function to turn argc/argv into a
|
||||
single string.
|
||||
(main): Use it here to pass list_config() more than one argument
|
||||
as a single string.
|
||||
(print_algo_numbers): Helper to print algorithm numbers.
|
||||
(list_config): Use it here for "pubkey", "cipher",
|
||||
"hash"/"digest", and "compress" config options.
|
||||
|
||||
2004-01-13 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
* g10.c (list_config, main): New function to dump config options
|
||||
|
135
g10/g10.c
135
g10/g10.c
@ -1064,40 +1064,125 @@ check_permissions(const char *path,int item)
|
||||
}
|
||||
|
||||
|
||||
/* In the future, we can do all sorts of interesting configuration
|
||||
output here. For now, just give ugr, for User GRoups as the
|
||||
Enigmail folks need it. */
|
||||
static void
|
||||
list_config(const char *items)
|
||||
print_algo_numbers(int (*checker)(int))
|
||||
{
|
||||
struct groupitem *iter;
|
||||
int i,first=1;
|
||||
|
||||
for(i=0;i<=110;i++)
|
||||
{
|
||||
if(!checker(i))
|
||||
{
|
||||
if(first)
|
||||
first=0;
|
||||
else
|
||||
printf(";");
|
||||
printf("%d",i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* In the future, we can do all sorts of interesting configuration
|
||||
output here. For now, just give "group" as the Enigmail folks need
|
||||
it, and pubkey, cipher, hash, and compress as they may be useful
|
||||
for frontends. */
|
||||
static void
|
||||
list_config(char *items)
|
||||
{
|
||||
int show_all=(items==NULL);
|
||||
char *name;
|
||||
|
||||
if(!opt.with_colons)
|
||||
return;
|
||||
|
||||
if(!items || (items && ascii_strcasecmp(items,"ugr")==0))
|
||||
|
||||
while(show_all || (name=strsep(&items," ")))
|
||||
{
|
||||
for(iter=opt.grouplist;iter;iter=iter->next)
|
||||
if(show_all || ascii_strcasecmp(name,"pubkey")==0)
|
||||
{
|
||||
STRLIST sl;
|
||||
|
||||
printf("cfg:ugr:");
|
||||
print_string(stdout,iter->name,strlen(iter->name),':');
|
||||
printf(":");
|
||||
|
||||
for(sl=iter->values;sl;sl=sl->next)
|
||||
{
|
||||
print_string2(stdout,sl->d,strlen(sl->d),':',';');
|
||||
if(sl->next)
|
||||
printf(";");
|
||||
}
|
||||
|
||||
printf("cfg:pubkey:");
|
||||
print_algo_numbers(check_pubkey_algo);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if(show_all || ascii_strcasecmp(name,"cipher")==0)
|
||||
{
|
||||
printf("cfg:cipher:");
|
||||
print_algo_numbers(check_cipher_algo);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if(show_all
|
||||
|| ascii_strcasecmp(name,"digest")==0
|
||||
|| ascii_strcasecmp(name,"hash")==0)
|
||||
{
|
||||
printf("cfg:digest:");
|
||||
print_algo_numbers(check_digest_algo);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if(show_all || ascii_strcasecmp(name,"compress")==0)
|
||||
{
|
||||
printf("cfg:compress:");
|
||||
print_algo_numbers(check_compress_algo);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if(show_all || ascii_strcasecmp(name,"group")==0)
|
||||
{
|
||||
struct groupitem *iter;
|
||||
|
||||
for(iter=opt.grouplist;iter;iter=iter->next)
|
||||
{
|
||||
STRLIST sl;
|
||||
|
||||
printf("cfg:group:");
|
||||
print_string(stdout,iter->name,strlen(iter->name),':');
|
||||
printf(":");
|
||||
|
||||
for(sl=iter->values;sl;sl=sl->next)
|
||||
{
|
||||
print_string2(stdout,sl->d,strlen(sl->d),':',';');
|
||||
if(sl->next)
|
||||
printf(";");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
if(show_all)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Collapses argc/argv into a single string that must be freed */
|
||||
static char *
|
||||
collapse_args(int argc,char *argv[])
|
||||
{
|
||||
char *str=NULL;
|
||||
int i,first=1,len=0;
|
||||
|
||||
for(i=0;i<argc;i++)
|
||||
{
|
||||
len+=strlen(argv[i])+2;
|
||||
str=m_realloc(str,len);
|
||||
if(first)
|
||||
{
|
||||
str[0]='\0';
|
||||
first=0;
|
||||
}
|
||||
else
|
||||
strcat(str," ");
|
||||
|
||||
strcat(str,argv[i]);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
@ -2710,9 +2795,11 @@ main( int argc, char **argv )
|
||||
break;
|
||||
|
||||
case aListConfig:
|
||||
if(argc>1)
|
||||
wrong_args("--list-config [items]");
|
||||
list_config(argc?*argv:NULL);
|
||||
{
|
||||
char *str=collapse_args(argc,argv);
|
||||
list_config(str);
|
||||
m_free(str);
|
||||
}
|
||||
break;
|
||||
|
||||
case aListPackets:
|
||||
|
Loading…
x
Reference in New Issue
Block a user