summaryrefslogtreecommitdiffstats
path: root/pgpkey.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-03-22 16:00:36 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-03-22 16:00:36 +0000
commit5856b6fff90bdc15915d17ae4bf38716eb8cf10b (patch)
treeb8e7148e8a6bdac1b74b62473df592fc0ea2557c /pgpkey.c
parentc278a285ca8ec6b761d9ebbcd97370ab76b48547 (diff)
PGP key creation time fix by Roland Rosenfeld.
Diffstat (limited to 'pgpkey.c')
-rw-r--r--pgpkey.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/pgpkey.c b/pgpkey.c
index 5c184f87..1d847423 100644
--- 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)
{