mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-18 14:17:03 +01:00
gpg: Minor cleanup for key listing related code.
* g10/getkey.c (get_pubkey_next): Divert to getkey_next. (get_pubkey_end): Move code to getkey_end. * g10/keydb.c (keydb_search_reset): Add a debug statement. (dump_search_desc): Add arg HD and print the handle. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
a929f36693
commit
440e8f5170
26
g10/getkey.c
26
g10/getkey.c
@ -928,26 +928,13 @@ get_pubkey_bynames (GETKEY_CTX * retctx, PKT_public_key * pk,
|
||||
int
|
||||
get_pubkey_next (GETKEY_CTX ctx, PKT_public_key * pk, KBNODE * ret_keyblock)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = lookup (ctx, ret_keyblock, 0);
|
||||
if (!rc && pk && ret_keyblock)
|
||||
pk_from_block (ctx, pk, *ret_keyblock);
|
||||
|
||||
return rc;
|
||||
return gpg_err_code (getkey_next (ctx, pk, ret_keyblock));
|
||||
}
|
||||
|
||||
void
|
||||
get_pubkey_end (GETKEY_CTX ctx)
|
||||
{
|
||||
if (ctx)
|
||||
{
|
||||
memset (&ctx->kbpos, 0, sizeof ctx->kbpos);
|
||||
keydb_release (ctx->kr_handle);
|
||||
free_strlist (ctx->extra_list);
|
||||
if (!ctx->not_allocated)
|
||||
xfree (ctx);
|
||||
}
|
||||
getkey_end (ctx);
|
||||
}
|
||||
|
||||
|
||||
@ -1257,7 +1244,14 @@ getkey_next (getkey_ctx_t ctx, PKT_public_key *pk, kbnode_t *ret_keyblock)
|
||||
void
|
||||
getkey_end (getkey_ctx_t ctx)
|
||||
{
|
||||
get_pubkey_end (ctx);
|
||||
if (ctx)
|
||||
{
|
||||
memset (&ctx->kbpos, 0, sizeof ctx->kbpos);
|
||||
keydb_release (ctx->kr_handle);
|
||||
free_strlist (ctx->extra_list);
|
||||
if (!ctx->not_allocated)
|
||||
xfree (ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
14
g10/keydb.c
14
g10/keydb.c
@ -603,8 +603,8 @@ keydb_release (KEYDB_HANDLE hd)
|
||||
|
||||
|
||||
/* Set a flag on handle to not use cached results. This is required
|
||||
for updating a keyring. Fixme: Using a new parameter for keydb_new
|
||||
might be a better solution. */
|
||||
for updating a keyring and for key listins. Fixme: Using a new
|
||||
parameter for keydb_new might be a better solution. */
|
||||
void
|
||||
keydb_disable_caching (KEYDB_HANDLE hd)
|
||||
{
|
||||
@ -1328,6 +1328,9 @@ keydb_search_reset (KEYDB_HANDLE hd)
|
||||
if (DBG_CLOCK)
|
||||
log_clock ("keydb_search_reset");
|
||||
|
||||
if (DBG_CACHE)
|
||||
log_debug ("keydb_search: reset (hd=%p)", hd);
|
||||
|
||||
hd->skipped_long_blobs = 0;
|
||||
hd->current = 0;
|
||||
hd->found = -1;
|
||||
@ -1351,7 +1354,8 @@ keydb_search_reset (KEYDB_HANDLE hd)
|
||||
|
||||
|
||||
static void
|
||||
dump_search_desc (const char *text, KEYDB_SEARCH_DESC *desc, size_t ndesc)
|
||||
dump_search_desc (KEYDB_HANDLE hd, const char *text,
|
||||
KEYDB_SEARCH_DESC *desc, size_t ndesc)
|
||||
{
|
||||
int n;
|
||||
const char *s;
|
||||
@ -1382,7 +1386,7 @@ dump_search_desc (const char *text, KEYDB_SEARCH_DESC *desc, size_t ndesc)
|
||||
default: s = "?"; break;
|
||||
}
|
||||
if (!n)
|
||||
log_debug ("%s: mode=%s", text, s);
|
||||
log_debug ("%s: mode=%s (hd=%p)", text, s, hd);
|
||||
else
|
||||
log_debug ("%*s mode=%s", (int)strlen (text), "", s);
|
||||
if (desc[n].mode == KEYDB_SEARCH_MODE_LONG_KID)
|
||||
@ -1418,7 +1422,7 @@ keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
||||
log_clock ("keydb_search enter");
|
||||
|
||||
if (DBG_CACHE)
|
||||
dump_search_desc ("keydb_search", desc, ndesc);
|
||||
dump_search_desc (hd, "keydb_search", desc, ndesc);
|
||||
|
||||
if (!hd->no_caching
|
||||
&& ndesc == 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user