auto updated version number.
[gpgme.git] / gpgme / key.c
index 0b3b787..879be14 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
+#include <ctype.h>
 
 #include "util.h"
 #include "ops.h"
@@ -627,17 +628,28 @@ _gpgme_key_append_name (GpgmeKey key, const char *s)
          *d++ = '\\';
          *d++ = '\0'; 
         }
-      else if (s[1] == 'x' && my_isdigit (s[2]) && my_isdigit (s[3]))
+      else if (s[1] == 'x' && isxdigit (s[2]) && isxdigit (s[3]))
        {
-         unsigned int val = (s[2]-'0')*16 + (s[3]-'0');
-         if (!val)
+         int val = hextobyte (&s[2]);
+         if (val == -1)
            {
-             *d++ = '\\';
-             *d++ = '\0'; 
-            }
-         else 
-           *(byte*)d++ = val;
-         s += 3;
+             /* Should not happen.  */
+             *d++ = *s++;
+             *d++ = *s++;
+             *d++ = *s++;
+             *d++ = *s++;
+           }
+         else
+           {
+             if (!val)
+               {
+                 *d++ = '\\';
+                 *d++ = '\0'; 
+               }
+             else 
+               *(byte*)d++ = val;
+             s += 4;
+           }
         }
       else
        {
@@ -887,8 +899,15 @@ gpgme_key_get_string_attr (GpgmeKey key, GpgmeAttr what,
     case GPGME_ATTR_EXPIRE:  
       /* Use another get function.  */
       break;
-    case GPGME_ATTR_OTRUST:
-      val = "[fixme]";
+    case GPGME_ATTR_OTRUST:  
+      switch (key->otrust)
+        {
+        case GPGME_VALIDITY_NEVER:     val = "n"; break;
+        case GPGME_VALIDITY_MARGINAL:  val = "m"; break;
+        case GPGME_VALIDITY_FULL:      val = "f"; break;
+        case GPGME_VALIDITY_ULTIMATE:  val = "u"; break;
+        default:   val = "?"; break;
+        }
       break;
     case GPGME_ATTR_USERID:  
       for (u = key->uids; u && idx; u = u->next, idx--)
@@ -965,12 +984,13 @@ gpgme_key_get_string_attr (GpgmeKey key, GpgmeAttr what,
       val = key->issuer_serial;
       break;
     case GPGME_ATTR_ISSUER:
-      val = key->issuer_name;
+      val = idx? NULL : key->issuer_name;
       break;
     case GPGME_ATTR_CHAINID:
       val = key->chain_id;
       break;
     case GPGME_ATTR_SIG_STATUS:
+    case GPGME_ATTR_ERRTOK:
       /* Not of any use here.  */
       break;
     }
@@ -1041,6 +1061,9 @@ gpgme_key_get_ulong_attr (GpgmeKey key, GpgmeAttr what,
       if (u)
        val = u->validity;
       break;
+    case GPGME_ATTR_OTRUST:
+      val = key->otrust;
+      break;
     case GPGME_ATTR_IS_SECRET:
       val = !!key->secret;
       break;