* g10.c (main): Use 3DES instead of CAST5 if we don't have CAST5 support.
[gnupg.git] / g10 / keyserver.c
index 59d67e3..ed7883d 100644 (file)
@@ -304,7 +304,7 @@ parse_keyrec(char *keystring)
 {
   static struct keyrec *work=NULL;
   struct keyrec *ret=NULL;
 {
   static struct keyrec *work=NULL;
   struct keyrec *ret=NULL;
-  char *record,*tok;
+  char *record;
   int i;
 
   if(keystring==NULL)
   int i;
 
   if(keystring==NULL)
@@ -342,6 +342,8 @@ parse_keyrec(char *keystring)
 
   if(ascii_strcasecmp("pub",record)==0)
     {
 
   if(ascii_strcasecmp("pub",record)==0)
     {
+      char *tok;
+
       if(work->desc.mode)
        {
          ret=work;
       if(work->desc.mode)
        {
          ret=work;
@@ -415,7 +417,6 @@ parse_keyrec(char *keystring)
   else if(ascii_strcasecmp("uid",record)==0 && work->desc.mode)
     {
       char *userid,*tok,*decoded;
   else if(ascii_strcasecmp("uid",record)==0 && work->desc.mode)
     {
       char *userid,*tok,*decoded;
-      int i=0;
 
       if((tok=strsep(&keystring,":"))==NULL)
        return ret;
 
       if((tok=strsep(&keystring,":"))==NULL)
        return ret;
@@ -428,6 +429,8 @@ parse_keyrec(char *keystring)
       /* By definition, de-%-encoding is always smaller than the
          original string so we can decode in place. */
 
       /* By definition, de-%-encoding is always smaller than the
          original string so we can decode in place. */
 
+      i=0;
+
       while(*tok)
        if(tok[0]=='%' && tok[1] && tok[2])
          {
       while(*tok)
        if(tok[0]=='%' && tok[1] && tok[2])
          {
@@ -469,7 +472,7 @@ show_prompt(KEYDB_SEARCH_DESC *desc,int numdesc,int count,const char *search)
 {
   char *answer;
 
 {
   char *answer;
 
-  if(count)
+  if(count && opt.command_fd==-1)
     {
       static int from=1;
       tty_printf("Keys %d-%d of %d for \"%s\".  ",from,numdesc,count,search);
     {
       static int from=1;
       tty_printf("Keys %d-%d of %d for \"%s\".  ",from,numdesc,count,search);
@@ -511,7 +514,7 @@ show_prompt(KEYDB_SEARCH_DESC *desc,int numdesc,int count,const char *search)
 static void
 keyserver_search_prompt(IOBUF buffer,const char *searchstr)
 {
 static void
 keyserver_search_prompt(IOBUF buffer,const char *searchstr)
 {
-  int i=0,validcount=0,started=0,count=1;
+  int i=0,validcount=0,started=0,header=0,count=1;
   unsigned int maxlen,buflen;
   KEYDB_SEARCH_DESC *desc;
   byte *line=NULL;
   unsigned int maxlen,buflen;
   KEYDB_SEARCH_DESC *desc;
   byte *line=NULL;
@@ -528,6 +531,21 @@ keyserver_search_prompt(IOBUF buffer,const char *searchstr)
       maxlen=1024;
       rl=iobuf_read_line(buffer,&line,&buflen,&maxlen);
 
       maxlen=1024;
       rl=iobuf_read_line(buffer,&line,&buflen,&maxlen);
 
+      if(opt.with_colons)
+       {
+         if(!header && ascii_strncasecmp("SEARCH ",line,7)==0
+            && ascii_strncasecmp(" BEGIN",&line[strlen(line)-7],6)==0)
+           {
+             header=1;
+             continue;
+           }
+         else if(ascii_strncasecmp("SEARCH ",line,7)==0
+                 && ascii_strncasecmp(" END",&line[strlen(line)-5],4)==0)
+           continue;
+
+         printf("%s",line);
+       }
+
       /* Look for an info: line.  The only current info: values
         defined are the version and key count. */
       if(!started && rl>0 && ascii_strncasecmp("info:",line,5)==0)
       /* Look for an info: line.  The only current info: values
         defined are the version and key count. */
       if(!started && rl>0 && ascii_strncasecmp("info:",line,5)==0)
@@ -606,15 +624,19 @@ keyserver_search_prompt(IOBUF buffer,const char *searchstr)
        {
          desc[i]=keyrec->desc;
 
        {
          desc[i]=keyrec->desc;
 
-         if(numlines+keyrec->lines>maxlines)
+         if(!opt.with_colons)
            {
            {
-             if(show_prompt(desc,i,validcount?count:0,searchstr))
-               break;
-             else
-               numlines=0;
+             if(numlines+keyrec->lines>maxlines)
+               {
+                 if(show_prompt(desc,i,validcount?count:0,searchstr))
+                   break;
+                 else
+                   numlines=0;
+               }
+
+             print_keyrec(i+1,keyrec);
            }
 
            }
 
-         print_keyrec(i+1,keyrec);
          numlines+=keyrec->lines;
          iobuf_close(keyrec->uidbuf);
          m_free(keyrec);
          numlines+=keyrec->lines;
          iobuf_close(keyrec->uidbuf);
          m_free(keyrec);
@@ -1241,17 +1263,23 @@ keyserver_refresh(STRLIST users)
   if(rc)
     return rc;
 
   if(rc)
     return rc;
 
-  if(count==1)
-    log_info(_("refreshing 1 key from %s\n"),opt.keyserver_uri);
-  else
-    log_info(_("refreshing %d keys from %s\n"),count,opt.keyserver_uri);
-
   if(count>0)
   if(count>0)
-    rc=keyserver_work(GET,NULL,desc,count);
+    {
+      if(opt.keyserver_uri)
+       {
+         if(count==1)
+           log_info(_("refreshing 1 key from %s\n"),opt.keyserver_uri);
+         else
+           log_info(_("refreshing %d keys from %s\n"),
+                    count,opt.keyserver_uri);
+       }
+
+      rc=keyserver_work(GET,NULL,desc,count);
+    }
 
   m_free(desc);
 
 
   m_free(desc);
 
-  return 0;
+  return rc;
 }
 
 int
 }
 
 int