diff options
author | Neal H. Walfield <[email protected]> | 2015-11-20 11:52:04 +0000 |
---|---|---|
committer | Neal H. Walfield <[email protected]> | 2015-11-20 11:52:04 +0000 |
commit | f8a65ac96b27a0963892892ce6e93b37b8df1ad7 (patch) | |
tree | 5ffa3c976a2dc0f4ffc0c0e191fa126de4c1fe89 | |
parent | gpg: Improve an error message. (diff) | |
download | gnupg-f8a65ac96b27a0963892892ce6e93b37b8df1ad7.tar.gz gnupg-f8a65ac96b27a0963892892ce6e93b37b8df1ad7.zip |
gpg: Refactor print_seckey_info.
* g10/keylist.c (print_seckey_info): Break formatting functionality
into...
(format_seckey_info): ... this new function.
--
Signed-off-by: Neal H. Walfield <[email protected]>
-rw-r--r-- | g10/keylist.c | 21 | ||||
-rw-r--r-- | g10/main.h | 1 |
2 files changed, 17 insertions, 5 deletions
diff --git a/g10/keylist.c b/g10/keylist.c index 9b2d83f10..031612cd2 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -163,20 +163,31 @@ secret_key_list (ctrl_t ctrl, strlist_t list) list_one (ctrl, list, 1, 0); } -void -print_seckey_info (PKT_public_key *pk) +char * +format_seckey_info (PKT_public_key *pk) { u32 keyid[2]; char *p; char pkstrbuf[PUBKEY_STRING_SIZE]; + char *info; keyid_from_pk (pk, keyid); p = get_user_id_native (keyid); - tty_printf ("\nsec %s/%s %s %s\n", - pubkey_string (pk, pkstrbuf, sizeof pkstrbuf), - keystr (keyid), datestr_from_pk (pk), p); + info = xtryasprintf ("sec %s/%s %s %s", + pubkey_string (pk, pkstrbuf, sizeof pkstrbuf), + keystr (keyid), datestr_from_pk (pk), p); + + xfree (p); + return info; +} + +void +print_seckey_info (PKT_public_key *pk) +{ + char *p = format_seckey_info (pk); + tty_printf ("\n%s\n", p); xfree (p); } diff --git a/g10/main.h b/g10/main.h index be4be296a..0c2d1a940 100644 --- a/g10/main.h +++ b/g10/main.h @@ -387,6 +387,7 @@ void show_keyserver_url(PKT_signature *sig,int indent,int mode); void show_notation(PKT_signature *sig,int indent,int mode,int which); void dump_attribs (const PKT_user_id *uid, PKT_public_key *pk); void set_attrib_fd(int fd); +char *format_seckey_info (PKT_public_key *pk); void print_seckey_info (PKT_public_key *pk); void print_pubkey_info (estream_t fp, PKT_public_key *pk); void print_card_key_info (estream_t fp, KBNODE keyblock); |