From 7a5c4d215cc1e0d40960c452c7e1977bc9043902 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Sat, 11 Jan 2003 21:13:41 +0000 Subject: [PATCH] * trustdb.c (get_validity_info, get_ownertrust_info, trust_letter): Simplify by returning a ? for error directly. * keyedit.c (show_key_with_all_names): Use get_validity_string and get_ownertrust_string to show full word versions of trust (i.e. "full" instead of 'f'). * trustdb.h, trustdb.c (get_ownertrust_string, get_validity_string): Same as get_ownertrust_info, and get_validity_info, except returns a full string. * trustdb.c (get_ownertrust_with_min): New. Same as 'get_ownertrust' but takes the min_ownertrust value into account. --- g10/ChangeLog | 16 ++++++++++ g10/keyedit.c | 40 +++++++++++++---------- g10/trustdb.c | 88 ++++++++++++++++++++++++++++++++------------------- g10/trustdb.h | 6 ++-- 4 files changed, 100 insertions(+), 50 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 31310f90f..716705bd5 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,19 @@ +2003-01-11 David Shaw + + * trustdb.c (get_validity_info, get_ownertrust_info, + trust_letter): Simplify by returning a ? for error directly. + + * keyedit.c (show_key_with_all_names): Use get_validity_string and + get_ownertrust_string to show full word versions of trust + (i.e. "full" instead of 'f'). + + * trustdb.h, trustdb.c (get_ownertrust_string, + get_validity_string): Same as get_ownertrust_info, and + get_validity_info, except returns a full string. + + * trustdb.c (get_ownertrust_with_min): New. Same as + 'get_ownertrust' but takes the min_ownertrust value into account. + 2003-01-10 David Shaw * armor.c (armor_filter): Comment about PGP's end of line tab diff --git a/g10/keyedit.c b/g10/keyedit.c index 12d6f7c2b..e431bc1fc 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -1897,15 +1897,15 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker, if( node->pkt->pkttype == PKT_PUBLIC_KEY || (with_subkeys && node->pkt->pkttype == PKT_PUBLIC_SUBKEY) ) { PKT_public_key *pk = node->pkt->pkt.public_key; - int otrust=0, trust=0; + const char *otrust="err",*trust="err"; if( node->pkt->pkttype == PKT_PUBLIC_KEY ) { /* do it here, so that debug messages don't clutter the * output */ static int did_warn = 0; - trust = get_validity_info (pk, NULL); - otrust = get_ownertrust_info (pk); + trust = get_validity_string (pk, NULL); + otrust = get_ownertrust_string (pk); /* Show a warning once */ if (!did_warn @@ -1947,20 +1947,28 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker, (ulong)keyid_from_pk(pk,NULL), datestr_from_pk(pk), expirestr_from_pk(pk) ); - if( node->pkt->pkttype == PKT_PUBLIC_KEY ) { - tty_printf(_(" trust: %c/%c"), otrust, trust ); - if( node->pkt->pkttype == PKT_PUBLIC_KEY - && (get_ownertrust (pk)&TRUST_FLAG_DISABLED)) { - tty_printf("\n*** "); - tty_printf(_("This key has been disabled")); - } - - if( with_fpr ) { - tty_printf("\n"); - print_fingerprint ( pk, NULL, 2 ); - } - } tty_printf("\n"); + + if( node->pkt->pkttype == PKT_PUBLIC_KEY ) + { + tty_printf(" "); + tty_printf(_("trust: %-13s"), otrust); + tty_printf(_("validity: %s"), trust ); + tty_printf("\n"); + if( node->pkt->pkttype == PKT_PUBLIC_KEY + && (get_ownertrust (pk)&TRUST_FLAG_DISABLED)) + { + tty_printf("*** "); + tty_printf(_("This key has been disabled")); + tty_printf("\n"); + } + } + + if( node->pkt->pkttype == PKT_PUBLIC_KEY && with_fpr ) + { + print_fingerprint ( pk, NULL, 2 ); + tty_printf("\n"); + } } else if( node->pkt->pkttype == PKT_SECRET_KEY || (with_subkeys && node->pkt->pkttype == PKT_SECRET_SUBKEY) ) { diff --git a/g10/trustdb.c b/g10/trustdb.c index 16f8f7cb0..b5bdcf871 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -452,7 +452,7 @@ trust_letter (unsigned int value) case TRUST_MARGINAL: return 'm'; case TRUST_FULLY: return 'f'; case TRUST_ULTIMATE: return 'u'; - default: return 0; + default: return '?'; } } @@ -463,13 +463,13 @@ trust_string (unsigned int value) { switch( (value & TRUST_MASK) ) { - case TRUST_UNKNOWN: return _("unknown trust"); + case TRUST_UNKNOWN: return _("unknown"); case TRUST_EXPIRED: return _("expired"); - case TRUST_UNDEFINED: return _("undefined trust"); - case TRUST_NEVER: return _("do NOT trust"); - case TRUST_MARGINAL: return _("marginal trust"); - case TRUST_FULLY: return _("full trust"); - case TRUST_ULTIMATE: return _("ultimate trust"); + case TRUST_UNDEFINED: return _("undefined"); + case TRUST_NEVER: return _("never"); + case TRUST_MARGINAL: return _("marginal"); + case TRUST_FULLY: return _("full"); + case TRUST_ULTIMATE: return _("ultimate"); default: return "err"; } } @@ -629,31 +629,48 @@ get_min_ownertrust (PKT_public_key *pk) } /* - * Same as get_ownertrust but return a trust letter instead of an value. + * Same as get_ownertrust but this takes the minimum ownertrust value + * into into account, and will bump up the value as needed. + */ +static int +get_ownertrust_with_min (PKT_public_key *pk) +{ + unsigned int otrust,otrust_min; + + otrust = get_ownertrust (pk); + otrust_min = get_min_ownertrust (pk); + if(otrust