From 9ee103957e4136337b92d238283f8ef30fd4a7c5 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 25 Aug 2016 11:38:03 +0200 Subject: core: Add GPGME_KEYLIST_MODE_WITH_TOFU. * src/gpgme.h.in (GPGME_KEYLIST_MODE_WITH_TOFU): New. * src/engine-gpg.c (gpg_keylist_build_options): Use that. * src/keylist.c: Include limits.h. (parse_tfs_record): New. (keylist_colon_handler): Support TFS record. * tests/run-keylist.c: Include time.h. (isotimestr): New. (main): Add option --tofu. Print TOFU info. * tests/run-verify.c: Include time.h. (isotimestr): New. (print_result): Use isotimestr for TOFU dates. Signed-off-by: Werner Koch --- tests/run-verify.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'tests/run-verify.c') diff --git a/tests/run-verify.c b/tests/run-verify.c index ef4dd32e..3c18d3b6 100644 --- a/tests/run-verify.c +++ b/tests/run-verify.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -36,6 +37,26 @@ static int verbose; + +static const char * +isotimestr (unsigned long value) +{ + time_t t; + static char buffer[25+5]; + struct tm *tp; + + if (!value) + return "none"; + t = value; + + tp = gmtime (&t); + snprintf (buffer, sizeof buffer, "%04d-%02d-%02d %02d:%02d:%02d", + 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday, + tp->tm_hour, tp->tm_min, tp->tm_sec); + return buffer; +} + + static gpg_error_t status_cb (void *opaque, const char *keyword, const char *value) { @@ -177,8 +198,8 @@ print_result (gpgme_verify_result_t result) ti->policy == GPGME_TOFU_POLICY_BAD? "bad" : ti->policy == GPGME_TOFU_POLICY_ASK? "ask" : "?"); printf (" sigcount : %hu\n", ti->signcount); - printf (" firstseen: %u\n", ti->firstseen); - printf (" lastseen : %u\n", ti->lastseen); + printf (" firstseen: %s\n", isotimestr (ti->firstseen)); + printf (" lastseen : %s\n", isotimestr (ti->lastseen)); printf (" desc ....: "); print_description (nonnull (ti->description), 15); } -- cgit v1.2.3