diff options
author | Werner Koch <wk@gnupg.org> | 2019-11-27 11:58:47 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2019-11-27 11:58:47 +0100 |
commit | 61f41cdce5b60b9df05d6531ab1b7aab84ada659 (patch) | |
tree | 746f62b9932050dba10681bb38faee097ceaec73 /g10/keydb.c | |
parent | dirmngr: Rework of the LDAP code, part 1. (diff) | |
download | gnupg2-61f41cdce5b60b9df05d6531ab1b7aab84ada659.tar.xz gnupg2-61f41cdce5b60b9df05d6531ab1b7aab84ada659.zip |
gpg: Move a keydb function to another file.
* g10/keydb.c (build_keyblock_image): Move to ...
* g10/build-packet.c (build_keyblock_image): here.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10/keydb.c')
-rw-r--r-- | g10/keydb.c | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/g10/keydb.c b/g10/keydb.c index aeb62abfc..57d51e7b7 100644 --- a/g10/keydb.c +++ b/g10/keydb.c @@ -1359,48 +1359,6 @@ internal_keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb) } -/* Build a keyblock image from KEYBLOCK. Returns 0 on success and - * only then stores a new iobuf object at R_IOBUF. */ -static gpg_error_t -build_keyblock_image (kbnode_t keyblock, iobuf_t *r_iobuf) -{ - gpg_error_t err; - iobuf_t iobuf; - kbnode_t kbctx, node; - - *r_iobuf = NULL; - - iobuf = iobuf_temp (); - for (kbctx = NULL; (node = walk_kbnode (keyblock, &kbctx, 0));) - { - /* Make sure to use only packets valid on a keyblock. */ - switch (node->pkt->pkttype) - { - case PKT_PUBLIC_KEY: - case PKT_PUBLIC_SUBKEY: - case PKT_SIGNATURE: - case PKT_USER_ID: - case PKT_ATTRIBUTE: - case PKT_RING_TRUST: - break; - default: - continue; - } - - err = build_packet_and_meta (iobuf, node->pkt); - if (err) - { - iobuf_close (iobuf); - return err; - } - } - - keydb_stats.build_keyblocks++; - *r_iobuf = iobuf; - return 0; -} - - /* Update the keyblock KB (i.e., extract the fingerprint and find the * corresponding keyblock in the keyring). * keydb_update_keyblock diverts to here in the non-keyboxd mode. @@ -1473,6 +1431,7 @@ internal_keydb_update_keyblock (ctrl_t ctrl, KEYDB_HANDLE hd, kbnode_t kb) err = build_keyblock_image (kb, &iobuf); if (!err) { + keydb_stats.build_keyblocks++; err = keybox_update_keyblock (hd->active[hd->found].u.kb, iobuf_get_temp_buffer (iobuf), iobuf_get_temp_length (iobuf)); @@ -1543,6 +1502,7 @@ internal_keydb_insert_keyblock (KEYDB_HANDLE hd, kbnode_t kb) err = build_keyblock_image (kb, &iobuf); if (!err) { + keydb_stats.build_keyblocks++; err = keybox_insert_keyblock (hd->active[idx].u.kb, iobuf_get_temp_buffer (iobuf), iobuf_get_temp_length (iobuf)); |