]> granicus.if.org Git - neomutt/commitdiff
PGP key creation time fix by Roland Rosenfeld.
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 22 Mar 1999 16:00:36 +0000 (16:00 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 22 Mar 1999 16:00:36 +0000 (16:00 +0000)
doc/manual.sgml.in
gnupgparse.c
pgp.h
pgpkey.c
pgppubring.c

index 9f2cd20478e3a5b77ddf4a01043728cf9b159d53..bfd39a2cea06000e6e5b9b722b449f6ef07a659d 100644 (file)
@@ -3405,6 +3405,29 @@ Default: set
 
 If set, the PGP <em/+encrypttoself/ flag is used when encrypting messages.
 
+<sect2>pgp&lowbar;entry&lowbar;format<label id="pgp_entry_format">
+<p>
+Type: format string<newline>
+Default: &dquot;&percnt;4n &percnt;t&percnt;f &percnt;4l/0x&percnt;k &percnt;-4a &percnt;2c &percnt;u&dquot;
+
+This variable allows you to customize the PGP key selection menu to
+your personal taste. This string is similar to <ref id="index_format"
+name="&dollar;index&lowbar;format">, but has its own set of
+printf()-like sequences:
+
+<tscreen><verb>
+%n      number
+%k      key id
+%u      user id
+%a      algorithm
+%l      key length
+%f      flags
+%c      capabilities
+%t      trust/validity of the key-uid association
+%[<s>]  date of the key where <s> is an strftime(3) expression
+</verb></tscreen>
+
+
 <sect2>pgp&lowbar;gpg<label id="pgp_gpg">
 <p>
 Type: string<newline>
index d4900a6ee8306fc28530c6273f4fed10c7a6bb40..ce8074fc83f038015914931bcb9ade9b0eee4728 100644 (file)
@@ -142,7 +142,23 @@ static pgp_key_t *parse_pub_line (char *buf, int *is_subkey, pgp_key_t *k)
 
       }
       case 6:                  /* timestamp (1998-02-28) */
+      {
+       char tstr[11];
+       struct tm time;
+       if (!p)
+         break;
+       time.tm_sec = 0;
+       time.tm_min = 0;
+       time.tm_hour = 12;
+       strncpy (tstr, p, 11);
+       tstr[4] = '\0';
+       time.tm_year = atoi (tstr)-1900;
+       tstr[7] = '\0';
+       time.tm_mon = (atoi (tstr+5))-1;
+       time.tm_mday = atoi (tstr+8);
+       k->gen_time = mutt_mktime (&time, 0);
         break;
+      }
       case 7:                  /* valid for n days */
         break;
       case 8:                  /* Local id         */
diff --git a/pgp.h b/pgp.h
index ae135c1cde2b731ce0c34edf1fbfa24c836096bc..8e5580e7163335c3f2ab9b92855a276302ff103c 100644 (file)
--- a/pgp.h
+++ b/pgp.h
@@ -44,7 +44,7 @@ typedef struct pgp_keyinfo
   struct pgp_uid *address;
   int flags;
   short keylen;
-  unsigned long gen_time;
+  time_t gen_time;
   const char *algorithm;
   struct pgp_keyinfo *parent;
   struct pgp_keyinfo *next;
index 5c184f879292b041f3df75aba67b8b0238cd780c..1d847423444c361dd848545a16ae8860da1ae811 100644 (file)
--- a/pgpkey.c
+++ b/pgpkey.c
@@ -97,12 +97,13 @@ static pgp_key_t *pgp_principal_key (pgp_key_t *key)
  * 
  * %n  number
  * %k  key id          %K      key id of the principal key
- * %u  uiser id
+ * %u  user id
  * %a  algorithm       %A      algorithm of the princ. key
  * %l  length          %L      length of the princ. key
  * %f  flags           %F      flags of the princ. key
  * %c  capabilities    %C      capabilities of the princ. key
  * %t  trust/validity of the key-uid association
+ * %[...] date of key using strftime(3)
  */
 
 typedef struct pgp_entry
@@ -144,6 +145,66 @@ static const char *pgp_entry_fmt (char *dest,
   
   switch (tolower (op))
   {
+    case '[':
+
+      {
+       const char *cp;
+       char buf2[SHORT_STRING], *p;
+       int do_locales;
+       struct tm *tm;
+       size_t len;
+
+       p = dest;
+
+       cp = src;
+       if (*cp == '!')
+       {
+         do_locales = 0;
+         cp++;
+       }
+       else
+         do_locales = 1;
+
+       len = destlen - 1;
+       while (len > 0 && *cp != ']')
+       {
+         if (*cp == '%')
+         {
+           cp++;
+           if (len >= 2)
+           {
+             *p++ = '%';
+             *p++ = *cp;
+             len -= 2;
+           }
+           else
+             break; /* not enough space */
+           cp++;
+         }
+         else
+         {
+           *p++ = *cp++;
+           len--;
+         }
+       }
+       *p = 0;
+
+       if (do_locales && Locale)
+         setlocale (LC_TIME, Locale);
+
+       tm = localtime (&key->gen_time);
+
+       strftime (buf2, sizeof (buf2), dest, tm);
+
+       if (do_locales)
+         setlocale (LC_TIME, "C");
+
+       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+       snprintf (dest, destlen, fmt, buf2);
+       if (len > 0)
+         src = cp + 1;
+      }
+      break;
     case 'n':
       if (!optional)
       {
index 39cd6358b1cfe242788fa7b4cd4e98674e6775fd..ad001e781bc592d0a44ff24374fdd56a24290880 100644 (file)
@@ -506,7 +506,7 @@ static pgp_key_t *pgp_parse_pgp2_key (unsigned char *buff, size_t l)
   unsigned char alg;
   size_t expl;
   unsigned long id;
-  unsigned long gen_time = 0;
+  time_t gen_time = 0;
   unsigned short exp_days = 0;
   size_t j;
   int i, k;
@@ -520,6 +520,8 @@ static pgp_key_t *pgp_parse_pgp2_key (unsigned char *buff, size_t l)
   for (i = 0, j = 2; i < 4; i++)
     gen_time = (gen_time << 8) + buff[j++];
 
+  p->gen_time = gen_time;
+
   for (i = 0; i < 2; i++)
     exp_days = (exp_days << 8) + buff[j++];
 
@@ -610,7 +612,7 @@ static pgp_key_t *pgp_parse_pgp3_key (unsigned char *buff, size_t l)
   unsigned char alg;
   unsigned char digest[SHA_DIGEST_LENGTH];
   unsigned char scratch[LONG_STRING];
-  unsigned long gen_time = 0;
+  time_t gen_time = 0;
   unsigned long id;
   int i, k;
   short len;
@@ -680,7 +682,7 @@ static pgp_key_t *pgp_parse_keyinfo (unsigned char *buff, size_t l)
 static int pgp_parse_pgp2_sig (unsigned char *buff, size_t l, pgp_key_t * p)
 {
   unsigned char sigtype;
-  long sig_gen_time;
+  time_t sig_gen_time;
   unsigned long signerid;
   size_t j;
   int i;
@@ -712,7 +714,7 @@ static int pgp_parse_pgp3_sig (unsigned char *buff, size_t l, pgp_key_t * p)
   unsigned char pkalg;
   unsigned char hashalg;
   unsigned char skt;
-  long sig_gen_time = -1;
+  time_t sig_gen_time = -1;
   long validity = -1;
   long key_validity = -1;
   long signerid = 0;