aboutsummaryrefslogtreecommitdiffstats
path: root/g10/keyserver.c
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2003-12-28 15:46:49 +0000
committerDavid Shaw <[email protected]>2003-12-28 15:46:49 +0000
commit4cf0123a6898b87a6ee14247165c361ec707195b (patch)
treeff425ba8a414748da940500325c7657f140cc9d1 /g10/keyserver.c
parentcleaned up RISC OS code and removed lots of unnecessary stuff (diff)
downloadgnupg-4cf0123a6898b87a6ee14247165c361ec707195b.tar.gz
gnupg-4cf0123a6898b87a6ee14247165c361ec707195b.zip
* keyserver.c (argsep): New variation on strsep that knows about optional
arguments. (parse_keyserver_options): Use it here for optional arguments.
Diffstat (limited to '')
-rw-r--r--g10/keyserver.c77
1 files changed, 54 insertions, 23 deletions
diff --git a/g10/keyserver.c b/g10/keyserver.c
index 3a04cec5b..18746f7f3 100644
--- a/g10/keyserver.c
+++ b/g10/keyserver.c
@@ -74,39 +74,71 @@ struct kopts
static int keyserver_work(int action,STRLIST list,
KEYDB_SEARCH_DESC *desc,int count);
-static void
-strip_leading_space(char **stringp)
-{
- while(**stringp)
- {
- if(ascii_isspace(**stringp))
- (*stringp)++;
- else
- return;
- }
-}
-
static char *
-get_arg(char **stringp)
+argsep(char **stringp,char **arg)
{
- strip_leading_space(stringp);
+ char *tok,*next;
- if(**stringp=='=')
+ tok=*stringp;
+ *arg=NULL;
+
+ if(tok)
{
- (*stringp)++;
- strip_leading_space(stringp);
- return strsep(stringp," ,");
+ 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 NULL;
+ return tok;
}
void
parse_keyserver_options(char *options)
{
- char *tok;
+ char *tok,*arg;
- while((tok=strsep(&options," ,")))
+ while((tok=argsep(&options,&arg)))
{
int i,hit=0;
@@ -155,8 +187,7 @@ parse_keyserver_options(char *options)
!parse_export_options(tok,
&opt.keyserver_options.export_options,0))
{
- char *arg;
- if(options && (arg=get_arg(&options)))
+ if(arg)
{
char *joined;