]> granicus.if.org Git - neomutt/commitdiff
Pull is_numerical_keyid() into crypt.c.
authorKevin McCarthy <kevin@8t8.us>
Mon, 30 Mar 2015 22:45:51 +0000 (15:45 -0700)
committerKevin McCarthy <kevin@8t8.us>
Mon, 30 Mar 2015 22:45:51 +0000 (15:45 -0700)
A subsequent patch (re?)-introduces a call to is_numerical_keyid inside
find_keys().  Rather than duplicate the function, this patch pulls it
into crypt.c, where find_keys() and pgp_findKeys() can both call it.

crypt.c
mutt_crypt.h
pgp.c

diff --git a/crypt.c b/crypt.c
index 446352b0759fc6743f5e59985d3302fb44f580db..0d5f456c5eb9908c365db165cf4ec85dfe9abdd8 100644 (file)
--- a/crypt.c
+++ b/crypt.c
@@ -997,3 +997,25 @@ const char* crypt_get_fingerprint_or_id (char *p, const char **pphint,
   *pps = ps;
   return pfcopy;
 }
+
+
+/*
+ * Used by pgp_findKeys and find_keys to check if a crypt-hook
+ * value is a key id.
+ */
+
+short crypt_is_numerical_keyid (const char *s)
+{
+  /* or should we require the "0x"? */
+  if (strncmp (s, "0x", 2) == 0)
+    s += 2;
+  if (strlen (s) % 8)
+    return 0;
+  while (*s)
+    if (strchr ("0123456789ABCDEFabcdef", *s++) == NULL)
+      return 0;
+
+  return 1;
+}
+
+
index 8619c5c50e52d603b7dc8037ed318f05c3ccc048..dc92ff3f03955acd0b75772a572373d39fe07426 100644 (file)
@@ -167,6 +167,9 @@ int crypt_write_signed(BODY *a, STATE *s, const char *tempf);
 const char* crypt_get_fingerprint_or_id (char *p, const char **pphint,
     const char **ppl, const char **pps);
 
+/* Check if a string contains a numerical key */
+short crypt_is_numerical_keyid (const char *s);
+
 
 
 /*-- cryptglue.c --*/
diff --git a/pgp.c b/pgp.c
index 7d041c8b5d9d8847a567b072a7bdd8cacd597a8d..5d022bed9e888c31255a63588f5d257a12ed04ad 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -31,6 +31,7 @@
 #endif
 
 #include "mutt.h"
+#include "mutt_crypt.h"
 #include "mutt_curses.h"
 #include "pgp.h"
 #include "mime.h"
@@ -1166,20 +1167,6 @@ BODY *pgp_sign_message (BODY *a)
   return (a);
 }
 
-static short is_numerical_keyid (const char *s)
-{
-  /* or should we require the "0x"? */
-  if (strncmp (s, "0x", 2) == 0)
-    s += 2;
-  if (strlen (s) % 8)
-    return 0;
-  while (*s)
-    if (strchr ("0123456789ABCDEFabcdef", *s++) == NULL)
-      return 0;
-  
-  return 1;
-}
-
 /* This routine attempts to find the keyids of the recipients of a message.
  * It returns NULL if any of the keys can not be found.
  * If oppenc_mode is true, only keys that can be determined without
@@ -1209,7 +1196,7 @@ char *pgp_findKeys (ADDRESS *adrlist, int oppenc_mode)
       snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
       if ((r = mutt_yesorno (buf, M_YES)) == M_YES)
       {
-       if (is_numerical_keyid (keyID))
+       if (crypt_is_numerical_keyid (keyID))
        {
          if (strncmp (keyID, "0x", 2) == 0)
            keyID += 2;