mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
* main.h, misc.c (parse_options): New general option line parser. Fix the
bug in the old version that did not handle report syntax errors after a valid entry. * import.c (parse_import_options), export.c (parse_export_options): Call it here instead of duplicating the code.
This commit is contained in:
parent
d6e7a14fa7
commit
c8abff498a
5 changed files with 60 additions and 72 deletions
37
g10/misc.c
37
g10/misc.c
|
@ -593,3 +593,40 @@ compliance_failure(void)
|
|||
log_info(_("this message may not be usable by %s\n"),compliance_string());
|
||||
opt.compliance=CO_GNUPG;
|
||||
}
|
||||
|
||||
int
|
||||
parse_options(char *str,unsigned int *options,struct parse_options *opts)
|
||||
{
|
||||
char *tok;
|
||||
|
||||
while((tok=strsep(&str," ,")))
|
||||
{
|
||||
int i,rev=0;
|
||||
|
||||
if(tok[0]=='\0')
|
||||
continue;
|
||||
|
||||
if(ascii_strncasecmp("no-",tok,3)==0)
|
||||
{
|
||||
rev=1;
|
||||
tok+=3;
|
||||
}
|
||||
|
||||
for(i=0;opts[i].name;i++)
|
||||
{
|
||||
if(ascii_strcasecmp(opts[i].name,tok)==0)
|
||||
{
|
||||
if(rev)
|
||||
*options&=~opts[i].bit;
|
||||
else
|
||||
*options|=opts[i].bit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!opts[i].name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue