diff options
author | David Shaw <[email protected]> | 2004-02-14 05:03:45 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2004-02-14 05:03:45 +0000 |
commit | c9aa5000d70b9d2bae7903074c8f10b75815e01d (patch) | |
tree | fb4110bcd821ed6dad24a5571e351f1a500aa6ea | |
parent | * import.c (check_prefs): Some language fixes. (sec_to_pub_keyblock, (diff) | |
download | gnupg-c9aa5000d70b9d2bae7903074c8f10b75815e01d.tar.gz gnupg-c9aa5000d70b9d2bae7903074c8f10b75815e01d.zip |
* keyserver.c (argsep): Move to misc.c.
* main.h, misc.c (parse_options), export.c (parse_export_options),
import.c (parse_import_options), g10.c (main): Use it here to allow for
options with optional arguments. Change all callers.
-rw-r--r-- | g10/ChangeLog | 6 | ||||
-rw-r--r-- | g10/export.c | 10 | ||||
-rw-r--r-- | g10/g10.c | 38 | ||||
-rw-r--r-- | g10/import.c | 16 | ||||
-rw-r--r-- | g10/keyserver.c | 59 | ||||
-rw-r--r-- | g10/main.h | 2 | ||||
-rw-r--r-- | g10/misc.c | 65 |
7 files changed, 103 insertions, 93 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index d0051ddcd..b60a6c6fe 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,5 +1,11 @@ 2004-02-13 David Shaw <[email protected]> + * keyserver.c (argsep): Move to misc.c. + + * main.h, misc.c (parse_options), export.c (parse_export_options), + import.c (parse_import_options), g10.c (main): Use it here to + allow for options with optional arguments. Change all callers. + * import.c (check_prefs): Some language fixes. (sec_to_pub_keyblock, import_secret_one): Without knowing the number of MPIs there are, we cannot try and sk-to-pk-ize a key. diff --git a/g10/export.c b/g10/export.c index c8a2be8ed..069c8e108 100644 --- a/g10/export.c +++ b/g10/export.c @@ -45,11 +45,11 @@ parse_export_options(char *str,unsigned int *options,int noisy) { struct parse_options export_opts[]= { - {"include-non-rfc",EXPORT_INCLUDE_NON_RFC}, - {"include-local-sigs",EXPORT_INCLUDE_LOCAL_SIGS}, - {"include-attributes",EXPORT_INCLUDE_ATTRIBUTES}, - {"include-sensitive-revkeys",EXPORT_INCLUDE_SENSITIVE_REVKEYS}, - {NULL,0} + {"include-non-rfc",EXPORT_INCLUDE_NON_RFC,NULL}, + {"include-local-sigs",EXPORT_INCLUDE_LOCAL_SIGS,NULL}, + {"include-attributes",EXPORT_INCLUDE_ATTRIBUTES,NULL}, + {"include-sensitive-revkeys",EXPORT_INCLUDE_SENSITIVE_REVKEYS,NULL}, + {NULL,0,NULL} /* add tags for include revoked and disabled? */ }; @@ -2096,17 +2096,17 @@ main( int argc, char **argv ) { struct parse_options lopts[]= { - {"show-photos",LIST_SHOW_PHOTOS}, - {"show-policy-urls",LIST_SHOW_POLICY_URLS}, - {"show-notations",LIST_SHOW_NOTATIONS}, - {"show-keyserver-urls",LIST_SHOW_KEYSERVER_URLS}, - {"show-validity",LIST_SHOW_VALIDITY}, - {"show-long-keyids",LIST_SHOW_LONG_KEYIDS}, - {"show-unusable-uids",LIST_SHOW_UNUSABLE_UIDS}, - {"show-unusable-subkeys",LIST_SHOW_UNUSABLE_SUBKEYS}, - {"show-keyring",LIST_SHOW_KEYRING}, - {"show-sig-expire",LIST_SHOW_SIG_EXPIRE}, - {NULL,0} + {"show-photos",LIST_SHOW_PHOTOS,NULL}, + {"show-policy-urls",LIST_SHOW_POLICY_URLS,NULL}, + {"show-notations",LIST_SHOW_NOTATIONS,NULL}, + {"show-keyserver-urls",LIST_SHOW_KEYSERVER_URLS,NULL}, + {"show-validity",LIST_SHOW_VALIDITY,NULL}, + {"show-long-keyids",LIST_SHOW_LONG_KEYIDS,NULL}, + {"show-unusable-uids",LIST_SHOW_UNUSABLE_UIDS,NULL}, + {"show-unusable-subkeys",LIST_SHOW_UNUSABLE_SUBKEYS,NULL}, + {"show-keyring",LIST_SHOW_KEYRING,NULL}, + {"show-sig-expire",LIST_SHOW_SIG_EXPIRE,NULL}, + {NULL,0,NULL} }; if(!parse_options(pargs.r.ret_str,&opt.list_options,lopts,1)) @@ -2123,14 +2123,14 @@ main( int argc, char **argv ) { struct parse_options vopts[]= { - {"show-photos",VERIFY_SHOW_PHOTOS}, - {"show-policy-urls",VERIFY_SHOW_POLICY_URLS}, - {"show-notations",VERIFY_SHOW_NOTATIONS}, - {"show-keyserver-urls",VERIFY_SHOW_KEYSERVER_URLS}, - {"show-validity",VERIFY_SHOW_VALIDITY}, - {"show-long-keyids",VERIFY_SHOW_LONG_KEYIDS}, - {"show-unusable-uids",VERIFY_SHOW_UNUSABLE_UIDS}, - {NULL,0} + {"show-photos",VERIFY_SHOW_PHOTOS,NULL}, + {"show-policy-urls",VERIFY_SHOW_POLICY_URLS,NULL}, + {"show-notations",VERIFY_SHOW_NOTATIONS,NULL}, + {"show-keyserver-urls",VERIFY_SHOW_KEYSERVER_URLS,NULL}, + {"show-validity",VERIFY_SHOW_VALIDITY,NULL}, + {"show-long-keyids",VERIFY_SHOW_LONG_KEYIDS,NULL}, + {"show-unusable-uids",VERIFY_SHOW_UNUSABLE_UIDS,NULL}, + {NULL,0,NULL} }; if(!parse_options(pargs.r.ret_str,&opt.verify_options,vopts,1)) diff --git a/g10/import.c b/g10/import.c index 9b368f681..60b8ff207 100644 --- a/g10/import.c +++ b/g10/import.c @@ -88,13 +88,13 @@ parse_import_options(char *str,unsigned int *options,int noisy) { struct parse_options import_opts[]= { - {"allow-local-sigs",IMPORT_ALLOW_LOCAL_SIGS}, - {"repair-hkp-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG}, - {"repair-pks-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG}, - {"fast-import",IMPORT_FAST_IMPORT}, - {"convert-sk-to-pk",IMPORT_SK2PK}, - {"merge-only",IMPORT_MERGE_ONLY}, - {NULL,0} + {"allow-local-sigs",IMPORT_ALLOW_LOCAL_SIGS,NULL}, + {"repair-hkp-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG,NULL}, + {"repair-pks-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG,NULL}, + {"fast-import",IMPORT_FAST_IMPORT,NULL}, + {"convert-sk-to-pk",IMPORT_SK2PK,NULL}, + {"merge-only",IMPORT_MERGE_ONLY,NULL}, + {NULL,0,NULL} }; return parse_options(str,options,import_opts,noisy); @@ -619,7 +619,7 @@ check_prefs(KBNODE keyblock) size_t fprlen=0; byte fpr[MAX_FINGERPRINT_LEN],*p; char username[(MAX_FINGERPRINT_LEN*2)+1]; - int i; + unsigned int i; p=fingerprint_from_pk(keyblock->pkt->pkt.public_key,fpr,&fprlen); for(i=0;i<fprlen;i++,p++) diff --git a/g10/keyserver.c b/g10/keyserver.c index 63287042c..a651f7165 100644 --- a/g10/keyserver.c +++ b/g10/keyserver.c @@ -72,65 +72,6 @@ struct kopts static int keyserver_work(int action,STRLIST list, KEYDB_SEARCH_DESC *desc,int count); -static char * -argsep(char **stringp,char **arg) -{ - char *tok,*next; - - tok=*stringp; - *arg=NULL; - - if(tok) - { - next=strpbrk(tok," ,="); - - if(next) - { - int sawequals=0; - - if(*next=='=') - sawequals=1; - - *next++='\0'; - *stringp=next; - - /* what we need to do now is scan along starting with *next. - If the next character we see (ignoring spaces) is a = - sign, then there is an argument. */ - - while(*next) - { - if(*next=='=') - sawequals=1; - else if(*next!=' ') - break; - next++; - } - - /* At this point, *next is either an empty string, or the - beginning of the next token (which is an argument if - sawequals is true). */ - - if(sawequals) - { - *arg=next; - next=strpbrk(*arg," ,"); - if(next) - { - *next++='\0'; - *stringp=next; - } - else - *stringp=NULL; - } - } - else - *stringp=NULL; - } - - return tok; -} - void parse_keyserver_options(char *options) { diff --git a/g10/main.h b/g10/main.h index 3b8770724..8476bd641 100644 --- a/g10/main.h +++ b/g10/main.h @@ -106,8 +106,10 @@ struct parse_options { char *name; unsigned int bit; + char **value; }; +char *argsep(char **stringp,char **arg); int parse_options(char *str,unsigned int *options, struct parse_options *opts,int noisy); diff --git a/g10/misc.c b/g10/misc.c index 2a8e29211..01f34b4a9 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -669,13 +669,72 @@ compliance_failure(void) opt.compliance=CO_GNUPG; } +char * +argsep(char **stringp,char **arg) +{ + char *tok,*next; + + tok=*stringp; + *arg=NULL; + + if(tok) + { + next=strpbrk(tok," ,="); + + if(next) + { + int sawequals=0; + + if(*next=='=') + sawequals=1; + + *next++='\0'; + *stringp=next; + + /* what we need to do now is scan along starting with *next. + If the next character we see (ignoring spaces) is a = + sign, then there is an argument. */ + + while(*next) + { + if(*next=='=') + sawequals=1; + else if(*next!=' ') + break; + next++; + } + + /* At this point, *next is either an empty string, or the + beginning of the next token (which is an argument if + sawequals is true). */ + + if(sawequals) + { + *arg=next; + next=strpbrk(*arg," ,"); + if(next) + { + *next++='\0'; + *stringp=next; + } + else + *stringp=NULL; + } + } + else + *stringp=NULL; + } + + return tok; +} + int parse_options(char *str,unsigned int *options, struct parse_options *opts,int noisy) { - char *tok; + char *tok,*arg; - while((tok=strsep(&str," ,"))) + while((tok=argsep(&str,&arg))) { int i,rev=0; char *otok=tok; @@ -715,6 +774,8 @@ parse_options(char *str,unsigned int *options, *options&=~opts[i].bit; else *options|=opts[i].bit; + if(opts[i].value) + *opts[i].value=arg?m_strdup(arg):NULL; break; } } |