aboutsummaryrefslogtreecommitdiffstats
path: root/g10/keyid.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-02-13 13:01:07 +0000
committerWerner Koch <[email protected]>2020-02-13 13:07:09 +0000
commit86312b920a1d5817903d7175e9c2109bcf521b7c (patch)
treeca7c10e48d3777cb0f4e9f883aaedf372af77de8 /g10/keyid.c
parentgpg: Changes to allow direct key generation from an OpenPGP card. (diff)
downloadgnupg-86312b920a1d5817903d7175e9c2109bcf521b7c.tar.gz
gnupg-86312b920a1d5817903d7175e9c2109bcf521b7c.zip
gpg: New option --full-timestrings.
* g10/options.h (opt): Add flags.full_timestrings. * g10/gpg.c (oFullTimestrings): New. (opts): New option. (main): Set new flag. * g10/keyid.c (dateonlystr_from_pk): New. (dateonlystr_from_sig): New. (datestr_from_pk): Divert to isotimestamp if requested. (datestr_from_sig): Ditto. (expirestr_from_pk): Ditto. (expirestr_from_sig): Ditto. (revokestr_from_pk): Ditto. * g10/import.c (impex_filter_getval): Use dateonlystr_from_sig and dateonlystr_from_pk. -- Quite helpful for debugging keys. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/keyid.c')
-rw-r--r--g10/keyid.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/g10/keyid.c b/g10/keyid.c
index e6298e5da..573958e39 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -679,7 +679,7 @@ mk_datestr (char *buffer, size_t bufsize, u32 timestamp)
* Format is: yyyy-mm-dd
*/
const char *
-datestr_from_pk (PKT_public_key *pk)
+dateonlystr_from_pk (PKT_public_key *pk)
{
static char buffer[MK_DATESTR_SIZE];
@@ -687,14 +687,36 @@ datestr_from_pk (PKT_public_key *pk)
}
+/* Same as dateonlystr_from_pk but with a global option a full iso
+ * timestamp is returned. In this case it shares a static buffer with
+ * isotimestamp(). */
const char *
-datestr_from_sig (PKT_signature *sig )
+datestr_from_pk (PKT_public_key *pk)
+{
+ if (opt.flags.full_timestrings)
+ return isotimestamp (pk->timestamp);
+ else
+ return dateonlystr_from_pk (pk);
+}
+
+
+const char *
+dateonlystr_from_sig (PKT_signature *sig )
{
static char buffer[MK_DATESTR_SIZE];
return mk_datestr (buffer, sizeof buffer, sig->timestamp);
}
+const char *
+datestr_from_sig (PKT_signature *sig )
+{
+ if (opt.flags.full_timestrings)
+ return isotimestamp (sig->timestamp);
+ else
+ return dateonlystr_from_sig (sig);
+}
+
const char *
expirestr_from_pk (PKT_public_key *pk)
@@ -703,6 +725,10 @@ expirestr_from_pk (PKT_public_key *pk)
if (!pk->expiredate)
return _("never ");
+
+ if (opt.flags.full_timestrings)
+ return isotimestamp (pk->expiredate);
+
return mk_datestr (buffer, sizeof buffer, pk->expiredate);
}
@@ -714,6 +740,10 @@ expirestr_from_sig (PKT_signature *sig)
if (!sig->expiredate)
return _("never ");
+
+ if (opt.flags.full_timestrings)
+ return isotimestamp (sig->expiredate);
+
return mk_datestr (buffer, sizeof buffer, sig->expiredate);
}
@@ -725,6 +755,10 @@ revokestr_from_pk( PKT_public_key *pk )
if(!pk->revoked.date)
return _("never ");
+
+ if (opt.flags.full_timestrings)
+ return isotimestamp (pk->revoked.date);
+
return mk_datestr (buffer, sizeof buffer, pk->revoked.date);
}