From ff43d07819d50c1b96f9034f5fbb5f5ce581f4bd Mon Sep 17 00:00:00 2001 From: David Shaw Date: Sat, 31 May 2003 21:52:16 +0000 Subject: * 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. --- g10/misc.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'g10/misc.c') 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; +} -- cgit