diff options
| author | Werner Koch <[email protected]> | 2015-02-23 16:54:05 +0000 |
|---|---|---|
| committer | Werner Koch <[email protected]> | 2015-02-23 16:54:05 +0000 |
| commit | ae09515b9d3aae653b62a32ea5b4a9b9e557fc52 (patch) | |
| tree | 162ad1ca241f9ac092a7a9219e7a96732fd43175 /g10/keylist.c | |
| parent | gpg: Skip legacy keys while searching keyrings. (diff) | |
| download | gnupg-ae09515b9d3aae653b62a32ea5b4a9b9e557fc52.tar.gz gnupg-ae09515b9d3aae653b62a32ea5b4a9b9e557fc52.zip | |
gpg: Add option to print fingerprints in ICAO spelling.
* g10/gpg.c: Add option --with-icao-spelling.
* g10/options.h (struct opt): Add with_icao_spelling.
* g10/keylist.c (print_icao_hexdigit): New.
(print_fingerprint): Print ICAO spelling.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/keylist.c')
| -rw-r--r-- | g10/keylist.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/g10/keylist.c b/g10/keylist.c index 5fd9eb87e..da933caa1 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -1580,6 +1580,20 @@ list_keyblock (KBNODE keyblock, int secret, int has_secret, int fpr, es_fflush (es_stdout); } + +/* Print an hex digit in ICAO spelling. */ +static void +print_icao_hexdigit (estream_t fp, int c) +{ + static const char *list[16] = { + "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", + "Eight", "Niner", "Alfa", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot" + }; + + tty_fprintf (fp, "%s", list[c&15]); +} + + /* * Function to print the finperprint. * mode 0: as used in key listings, opt.with_colons is honored @@ -1675,6 +1689,26 @@ print_fingerprint (estream_t override_fp, PKT_public_key *pk, int mode) } } tty_fprintf (fp, "\n"); + if (!opt.with_colons && opt.with_icao_spelling) + { + p = array; + tty_fprintf (fp, "%*s\"", (int)strlen(text)+1, ""); + for (i = 0; i < n; i++, p++) + { + if (!i) + ; + else if (!(i%4)) + tty_fprintf (fp, "\n%*s ", (int)strlen(text)+1, ""); + else if (!(i%2)) + tty_fprintf (fp, " "); + else + tty_fprintf (fp, " "); + print_icao_hexdigit (fp, *p >> 4); + tty_fprintf (fp, " "); + print_icao_hexdigit (fp, *p & 15); + } + tty_fprintf (fp, "\"\n"); + } } /* Print the serial number of an OpenPGP card if available. */ |
