mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02: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>
|
2004-01-13 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* g10.c (list_config, main): New function to dump config options
|
* g10.c (list_config, main): New function to dump config options
|
||||||
|
107
g10/g10.c
107
g10/g10.c
@ -1064,24 +1064,79 @@ 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
|
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)
|
if(!opt.with_colons)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!items || (items && ascii_strcasecmp(items,"ugr")==0))
|
while(show_all || (name=strsep(&items," ")))
|
||||||
{
|
{
|
||||||
|
if(show_all || ascii_strcasecmp(name,"pubkey")==0)
|
||||||
|
{
|
||||||
|
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)
|
for(iter=opt.grouplist;iter;iter=iter->next)
|
||||||
{
|
{
|
||||||
STRLIST sl;
|
STRLIST sl;
|
||||||
|
|
||||||
printf("cfg:ugr:");
|
printf("cfg:group:");
|
||||||
print_string(stdout,iter->name,strlen(iter->name),':');
|
print_string(stdout,iter->name,strlen(iter->name),':');
|
||||||
printf(":");
|
printf(":");
|
||||||
|
|
||||||
@ -1095,6 +1150,36 @@ list_config(const char *items)
|
|||||||
printf("\n");
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2710,9 +2795,11 @@ main( int argc, char **argv )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case aListConfig:
|
case aListConfig:
|
||||||
if(argc>1)
|
{
|
||||||
wrong_args("--list-config [items]");
|
char *str=collapse_args(argc,argv);
|
||||||
list_config(argc?*argv:NULL);
|
list_config(str);
|
||||||
|
m_free(str);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case aListPackets:
|
case aListPackets:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user