aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2004-11-24 05:25:03 +0000
committerDavid Shaw <[email protected]>2004-11-24 05:25:03 +0000
commit04b715e4dad23f85a38cf72950fbc96e3b33b646 (patch)
tree7cefccf89f270fe8afa106116c2f93fad5186129
parent(S_IRGRP) [HAVE_DOSISH_SYSTEM]: Define to 0. (diff)
downloadgnupg-04b715e4dad23f85a38cf72950fbc96e3b33b646.tar.gz
gnupg-04b715e4dad23f85a38cf72950fbc96e3b33b646.zip
* trustdb.h, trustdb.c (uid_trust_string_fixed): New. Return a fixed-size
translatable string similar to trust_value_to_string. This allows for easier lining up of displays. * keyedit.c (show_key_with_all_names), keylist.c (list_keyblock_print): Use it here to print validity strings. * gpgv.c: Stub.
-rw-r--r--g10/ChangeLog11
-rw-r--r--g10/gpgv.c7
-rw-r--r--g10/keyedit.c21
-rw-r--r--g10/keylist.c14
-rw-r--r--g10/trustdb.c28
-rw-r--r--g10/trustdb.h6
6 files changed, 58 insertions, 29 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 010d58b25..665769058 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,14 @@
+2004-11-24 David Shaw <[email protected]>
+
+ * trustdb.h, trustdb.c (uid_trust_string_fixed): New. Return a
+ fixed-size translatable string similar to trust_value_to_string.
+ This allows for easier lining up of displays.
+
+ * keyedit.c (show_key_with_all_names), keylist.c
+ (list_keyblock_print): Use it here to print validity strings.
+
+ * gpgv.c: Stub.
+
2004-11-18 Werner Koch <[email protected]>
* g10.c (S_IRGRP) [HAVE_DOSISH_SYSTEM]: Define to 0.
diff --git a/g10/gpgv.c b/g10/gpgv.c
index 2a316c3c7..7778953d1 100644
--- a/g10/gpgv.c
+++ b/g10/gpgv.c
@@ -251,7 +251,12 @@ trust_value_to_string (unsigned int value)
return "err";
}
-/* Stub: */
+const char *
+uid_trust_string_fixed(PKT_public_key *key,PKT_user_id *uid)
+{
+ return "err";
+}
+
int
get_ownertrust_info (PKT_public_key *pk)
{
diff --git a/g10/keyedit.c b/g10/keyedit.c
index f1ececba9..94be382de 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -892,7 +892,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
while(class==0)
{
answer = cpr_get("sign_uid.class",_("Your selection? "
- "(enter '?' for more information): "));
+ "(enter `?' for more information): "));
if(answer[0]=='\0')
class=0x10+opt.def_cert_level; /* Default */
else if(ascii_strcasecmp(answer,"0")==0)
@@ -2360,16 +2360,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
if( !only_marked || (only_marked && (node->flag & NODFLG_MARK_A)))
{
if(!only_marked)
- {
- if(uid->is_revoked)
- tty_printf(_("[%8.8s] "),_("revoked"));
- else if(uid->is_expired)
- tty_printf(_("[%8.8s] "),_("expired"));
- else if(primary)
- tty_printf(_("[%8.8s] "),
- trust_value_to_string(get_validity(primary,
- uid)));
- }
+ tty_printf("%s ",uid_trust_string_fixed(primary,uid));
if( only_marked )
tty_printf(" ");
@@ -2403,16 +2394,16 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
show_prefs (uid, selfsig, with_prefs == 2);
}
else
- tty_printf(_("There are no preferences on a "
- "PGP 2.x-style user ID.\n"));
+ tty_printf(_("There are no preferences on a"
+ " PGP 2.x-style user ID.\n"));
}
}
}
}
if (do_warn)
- tty_printf (_("Please note that the shown key validity "
- "is not necessarily correct\n"
+ tty_printf (_("Please note that the shown key validity"
+ " is not necessarily correct\n"
"unless you restart the program.\n"));
}
diff --git a/g10/keylist.c b/g10/keylist.c
index f874b2d64..e4c9e6e84 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -778,19 +778,13 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
const char *validity;
int indent;
- if(uid->is_revoked)
- validity=_("revoked");
- else if(uid->is_expired)
- validity=_("expired");
- else
- validity=trust_value_to_string(get_validity(pk,uid));
-
- indent=(keystrlen()+7)-strlen(validity);
+ validity=uid_trust_string_fixed(pk,uid);
+ indent=(keystrlen()+9)-atoi(uid_trust_string_fixed(NULL,NULL));
- if(indent<0)
+ if(indent<0 || indent>40)
indent=0;
- printf("uid%*s[%s] ",indent,"",validity);
+ printf("uid%*s%s ",indent,"",validity);
}
else
printf("uid%*s",keystrlen()+10,"");
diff --git a/g10/trustdb.c b/g10/trustdb.c
index e4e8f812c..75aa75279 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -489,6 +489,34 @@ trust_letter (unsigned int value)
}
}
+/* NOTE TO TRANSLATOR: these strings are similar to those in
+ trust_value_to_string(), but are a fixed length. This is needed to
+ make attractive information listings where columns line up
+ properly. The value "10" should be the length of the strings you
+ choose to translate to. This is the length in printable
+ columns. */
+const char *
+uid_trust_string_fixed(PKT_public_key *key,PKT_user_id *uid)
+{
+ if(!key && !uid)
+ return _("10");
+ else if(uid->is_revoked)
+ return _("[ revoked]");
+ else if(uid->is_expired)
+ return _("[ expired]");
+ else if(key)
+ switch(get_validity(key,uid)&TRUST_MASK)
+ {
+ case TRUST_UNKNOWN: return _("[ unknown]");
+ case TRUST_UNDEFINED: return _("[ undef ]");
+ case TRUST_MARGINAL: return _("[marginal]");
+ case TRUST_FULLY: return _("[ full ]");
+ case TRUST_ULTIMATE: return _("[ultimate]");
+ }
+
+ return "err";
+}
+
/* The strings here are similar to those in
pkclist.c:do_edit_ownertrust() */
const char *
diff --git a/g10/trustdb.h b/g10/trustdb.h
index ad192758e..baeab3fa4 100644
--- a/g10/trustdb.h
+++ b/g10/trustdb.h
@@ -1,6 +1,6 @@
/* trustdb.h - Trust database
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
- * Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
+ * 2004 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -22,7 +22,6 @@
#ifndef G10_TRUSTDB_H
#define G10_TRUSTDB_H
-
/* Trust values must be sorted in ascending order */
#define TRUST_MASK 15
#define TRUST_UNKNOWN 0 /* o: not yet calculated/assigned */
@@ -48,6 +47,7 @@ void init_trustdb( void );
void check_trustdb_stale(void);
void sync_trustdb( void );
+const char *uid_trust_string_fixed(PKT_public_key *key,PKT_user_id *uid);
const char *trust_value_to_string (unsigned int value);
int string_to_trust_value (const char *str);