aboutsummaryrefslogtreecommitdiffstats
path: root/g10/misc.c
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2003-05-31 21:52:16 +0000
committerDavid Shaw <[email protected]>2003-05-31 21:52:16 +0000
commitff43d07819d50c1b96f9034f5fbb5f5ce581f4bd (patch)
tree13e3845bc9b9392d862f4d9d335bc376016c5be6 /g10/misc.c
parent* keylist.c (list_one): Don't show the keyring filename when in (diff)
downloadgnupg-ff43d07819d50c1b96f9034f5fbb5f5ce581f4bd.tar.gz
gnupg-ff43d07819d50c1b96f9034f5fbb5f5ce581f4bd.zip
* 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.
Diffstat (limited to 'g10/misc.c')
-rw-r--r--g10/misc.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/g10/misc.c b/g10/misc.c
index 44deb5737..1b8e6172a 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -639,3 +639,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;
+}