mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-24 15:17:02 +01:00
* 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.
This commit is contained in:
parent
f407bb6a97
commit
c9aa5000d7
@ -1,5 +1,11 @@
|
|||||||
2004-02-13 David Shaw <dshaw@jabberwocky.com>
|
2004-02-13 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* 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.
|
* import.c (check_prefs): Some language fixes.
|
||||||
(sec_to_pub_keyblock, import_secret_one): Without knowing the
|
(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.
|
number of MPIs there are, we cannot try and sk-to-pk-ize a key.
|
||||||
|
10
g10/export.c
10
g10/export.c
@ -45,11 +45,11 @@ parse_export_options(char *str,unsigned int *options,int noisy)
|
|||||||
{
|
{
|
||||||
struct parse_options export_opts[]=
|
struct parse_options export_opts[]=
|
||||||
{
|
{
|
||||||
{"include-non-rfc",EXPORT_INCLUDE_NON_RFC},
|
{"include-non-rfc",EXPORT_INCLUDE_NON_RFC,NULL},
|
||||||
{"include-local-sigs",EXPORT_INCLUDE_LOCAL_SIGS},
|
{"include-local-sigs",EXPORT_INCLUDE_LOCAL_SIGS,NULL},
|
||||||
{"include-attributes",EXPORT_INCLUDE_ATTRIBUTES},
|
{"include-attributes",EXPORT_INCLUDE_ATTRIBUTES,NULL},
|
||||||
{"include-sensitive-revkeys",EXPORT_INCLUDE_SENSITIVE_REVKEYS},
|
{"include-sensitive-revkeys",EXPORT_INCLUDE_SENSITIVE_REVKEYS,NULL},
|
||||||
{NULL,0}
|
{NULL,0,NULL}
|
||||||
/* add tags for include revoked and disabled? */
|
/* add tags for include revoked and disabled? */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
38
g10/g10.c
38
g10/g10.c
@ -2096,17 +2096,17 @@ main( int argc, char **argv )
|
|||||||
{
|
{
|
||||||
struct parse_options lopts[]=
|
struct parse_options lopts[]=
|
||||||
{
|
{
|
||||||
{"show-photos",LIST_SHOW_PHOTOS},
|
{"show-photos",LIST_SHOW_PHOTOS,NULL},
|
||||||
{"show-policy-urls",LIST_SHOW_POLICY_URLS},
|
{"show-policy-urls",LIST_SHOW_POLICY_URLS,NULL},
|
||||||
{"show-notations",LIST_SHOW_NOTATIONS},
|
{"show-notations",LIST_SHOW_NOTATIONS,NULL},
|
||||||
{"show-keyserver-urls",LIST_SHOW_KEYSERVER_URLS},
|
{"show-keyserver-urls",LIST_SHOW_KEYSERVER_URLS,NULL},
|
||||||
{"show-validity",LIST_SHOW_VALIDITY},
|
{"show-validity",LIST_SHOW_VALIDITY,NULL},
|
||||||
{"show-long-keyids",LIST_SHOW_LONG_KEYIDS},
|
{"show-long-keyids",LIST_SHOW_LONG_KEYIDS,NULL},
|
||||||
{"show-unusable-uids",LIST_SHOW_UNUSABLE_UIDS},
|
{"show-unusable-uids",LIST_SHOW_UNUSABLE_UIDS,NULL},
|
||||||
{"show-unusable-subkeys",LIST_SHOW_UNUSABLE_SUBKEYS},
|
{"show-unusable-subkeys",LIST_SHOW_UNUSABLE_SUBKEYS,NULL},
|
||||||
{"show-keyring",LIST_SHOW_KEYRING},
|
{"show-keyring",LIST_SHOW_KEYRING,NULL},
|
||||||
{"show-sig-expire",LIST_SHOW_SIG_EXPIRE},
|
{"show-sig-expire",LIST_SHOW_SIG_EXPIRE,NULL},
|
||||||
{NULL,0}
|
{NULL,0,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!parse_options(pargs.r.ret_str,&opt.list_options,lopts,1))
|
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[]=
|
struct parse_options vopts[]=
|
||||||
{
|
{
|
||||||
{"show-photos",VERIFY_SHOW_PHOTOS},
|
{"show-photos",VERIFY_SHOW_PHOTOS,NULL},
|
||||||
{"show-policy-urls",VERIFY_SHOW_POLICY_URLS},
|
{"show-policy-urls",VERIFY_SHOW_POLICY_URLS,NULL},
|
||||||
{"show-notations",VERIFY_SHOW_NOTATIONS},
|
{"show-notations",VERIFY_SHOW_NOTATIONS,NULL},
|
||||||
{"show-keyserver-urls",VERIFY_SHOW_KEYSERVER_URLS},
|
{"show-keyserver-urls",VERIFY_SHOW_KEYSERVER_URLS,NULL},
|
||||||
{"show-validity",VERIFY_SHOW_VALIDITY},
|
{"show-validity",VERIFY_SHOW_VALIDITY,NULL},
|
||||||
{"show-long-keyids",VERIFY_SHOW_LONG_KEYIDS},
|
{"show-long-keyids",VERIFY_SHOW_LONG_KEYIDS,NULL},
|
||||||
{"show-unusable-uids",VERIFY_SHOW_UNUSABLE_UIDS},
|
{"show-unusable-uids",VERIFY_SHOW_UNUSABLE_UIDS,NULL},
|
||||||
{NULL,0}
|
{NULL,0,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!parse_options(pargs.r.ret_str,&opt.verify_options,vopts,1))
|
if(!parse_options(pargs.r.ret_str,&opt.verify_options,vopts,1))
|
||||||
|
16
g10/import.c
16
g10/import.c
@ -88,13 +88,13 @@ parse_import_options(char *str,unsigned int *options,int noisy)
|
|||||||
{
|
{
|
||||||
struct parse_options import_opts[]=
|
struct parse_options import_opts[]=
|
||||||
{
|
{
|
||||||
{"allow-local-sigs",IMPORT_ALLOW_LOCAL_SIGS},
|
{"allow-local-sigs",IMPORT_ALLOW_LOCAL_SIGS,NULL},
|
||||||
{"repair-hkp-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG},
|
{"repair-hkp-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG,NULL},
|
||||||
{"repair-pks-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG},
|
{"repair-pks-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG,NULL},
|
||||||
{"fast-import",IMPORT_FAST_IMPORT},
|
{"fast-import",IMPORT_FAST_IMPORT,NULL},
|
||||||
{"convert-sk-to-pk",IMPORT_SK2PK},
|
{"convert-sk-to-pk",IMPORT_SK2PK,NULL},
|
||||||
{"merge-only",IMPORT_MERGE_ONLY},
|
{"merge-only",IMPORT_MERGE_ONLY,NULL},
|
||||||
{NULL,0}
|
{NULL,0,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
return parse_options(str,options,import_opts,noisy);
|
return parse_options(str,options,import_opts,noisy);
|
||||||
@ -619,7 +619,7 @@ check_prefs(KBNODE keyblock)
|
|||||||
size_t fprlen=0;
|
size_t fprlen=0;
|
||||||
byte fpr[MAX_FINGERPRINT_LEN],*p;
|
byte fpr[MAX_FINGERPRINT_LEN],*p;
|
||||||
char username[(MAX_FINGERPRINT_LEN*2)+1];
|
char username[(MAX_FINGERPRINT_LEN*2)+1];
|
||||||
int i;
|
unsigned int i;
|
||||||
|
|
||||||
p=fingerprint_from_pk(keyblock->pkt->pkt.public_key,fpr,&fprlen);
|
p=fingerprint_from_pk(keyblock->pkt->pkt.public_key,fpr,&fprlen);
|
||||||
for(i=0;i<fprlen;i++,p++)
|
for(i=0;i<fprlen;i++,p++)
|
||||||
|
@ -72,65 +72,6 @@ struct kopts
|
|||||||
static int keyserver_work(int action,STRLIST list,
|
static int keyserver_work(int action,STRLIST list,
|
||||||
KEYDB_SEARCH_DESC *desc,int count);
|
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
|
void
|
||||||
parse_keyserver_options(char *options)
|
parse_keyserver_options(char *options)
|
||||||
{
|
{
|
||||||
|
@ -106,8 +106,10 @@ struct parse_options
|
|||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
unsigned int bit;
|
unsigned int bit;
|
||||||
|
char **value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char *argsep(char **stringp,char **arg);
|
||||||
int parse_options(char *str,unsigned int *options,
|
int parse_options(char *str,unsigned int *options,
|
||||||
struct parse_options *opts,int noisy);
|
struct parse_options *opts,int noisy);
|
||||||
|
|
||||||
|
65
g10/misc.c
65
g10/misc.c
@ -669,13 +669,72 @@ compliance_failure(void)
|
|||||||
opt.compliance=CO_GNUPG;
|
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
|
int
|
||||||
parse_options(char *str,unsigned int *options,
|
parse_options(char *str,unsigned int *options,
|
||||||
struct parse_options *opts,int noisy)
|
struct parse_options *opts,int noisy)
|
||||||
{
|
{
|
||||||
char *tok;
|
char *tok,*arg;
|
||||||
|
|
||||||
while((tok=strsep(&str," ,")))
|
while((tok=argsep(&str,&arg)))
|
||||||
{
|
{
|
||||||
int i,rev=0;
|
int i,rev=0;
|
||||||
char *otok=tok;
|
char *otok=tok;
|
||||||
@ -715,6 +774,8 @@ parse_options(char *str,unsigned int *options,
|
|||||||
*options&=~opts[i].bit;
|
*options&=~opts[i].bit;
|
||||||
else
|
else
|
||||||
*options|=opts[i].bit;
|
*options|=opts[i].bit;
|
||||||
|
if(opts[i].value)
|
||||||
|
*opts[i].value=arg?m_strdup(arg):NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user