aboutsummaryrefslogtreecommitdiffstats
path: root/g10/trustdb.c
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2003-01-11 21:13:41 +0000
committerDavid Shaw <[email protected]>2003-01-11 21:13:41 +0000
commit7a5c4d215cc1e0d40960c452c7e1977bc9043902 (patch)
tree85d93136f0807a7c2f5dfac8a3add4656c50dd4f /g10/trustdb.c
parent* armor.c (armor_filter): Comment about PGP's end of line tab problem. (diff)
downloadgnupg-7a5c4d215cc1e0d40960c452c7e1977bc9043902.tar.gz
gnupg-7a5c4d215cc1e0d40960c452c7e1977bc9043902.zip
* 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.
Diffstat (limited to '')
-rw-r--r--g10/trustdb.c88
1 files changed, 56 insertions, 32 deletions
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.
*/
-int
-get_ownertrust_info (PKT_public_key *pk)
+static int
+get_ownertrust_with_min (PKT_public_key *pk)
{
- unsigned int otrust,otrust_min;
- int c;
+ unsigned int otrust,otrust_min;
- otrust = get_ownertrust (pk);
- otrust_min = get_min_ownertrust (pk);
- if(otrust<otrust_min)
- {
- /* If the trust that the user has set is less than the trust
- that was calculated from a trust signature chain, use the
- higher of the two. We do this here and not in
- get_ownertrust since the underlying ownertrust should not
- really be set - just the appearance of the ownertrust. */
+ otrust = get_ownertrust (pk);
+ otrust_min = get_min_ownertrust (pk);
+ if(otrust<otrust_min)
+ {
+ /* If the trust that the user has set is less than the trust
+ that was calculated from a trust signature chain, use the
+ higher of the two. We do this here and not in
+ get_ownertrust since the underlying ownertrust should not
+ really be set - just the appearance of the ownertrust. */
- otrust=otrust_min;
- }
+ otrust=otrust_min;
+ }
- c = trust_letter( otrust );
- if( !c )
- c = '?';
- return c;
+ return otrust;
+}
+
+/*
+ * Same as get_ownertrust but return a trust letter instead of an
+ * value. This takes the minimum ownertrust value into account.
+ */
+int
+get_ownertrust_info (PKT_public_key *pk)
+{
+ return trust_letter(get_ownertrust_with_min(pk));
+}
+
+/*
+ * Same as get_ownertrust but return a trust string instead of an
+ * value. This takes the minimum ownertrust value into account.
+ */
+const char *
+get_ownertrust_string (PKT_public_key *pk)
+{
+ return trust_string(get_ownertrust_with_min(pk));
}
/*
@@ -1055,15 +1072,22 @@ int
get_validity_info (PKT_public_key *pk, PKT_user_id *uid)
{
int trustlevel;
- int c;
trustlevel = get_validity (pk, uid);
if( trustlevel & TRUST_FLAG_REVOKED )
return 'r';
- c = trust_letter ( trustlevel );
- if( !c )
- c = '?';
- return c;
+ return trust_letter ( trustlevel );
+}
+
+const char *
+get_validity_string (PKT_public_key *pk, PKT_user_id *uid)
+{
+ int trustlevel;
+
+ trustlevel = get_validity (pk, uid);
+ if( trustlevel & TRUST_FLAG_REVOKED )
+ return _("revoked");
+ return trust_string(trustlevel);
}
static void