diff options
author | Werner Koch <[email protected]> | 2014-06-02 13:55:00 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2014-06-02 13:55:00 +0000 |
commit | 42c043a8ad542c131917879c9b458f234b4bb645 (patch) | |
tree | 1847bf9f4161c5fb0f3bd893fdc5a6e87f4336ec /kbx/keybox-init.c | |
parent | gpg: Fix bug parsing a zero length user id. (diff) | |
download | gnupg-42c043a8ad542c131917879c9b458f234b4bb645.tar.gz gnupg-42c043a8ad542c131917879c9b458f234b4bb645.zip |
gpgsm: Add a way to save a found state.
* kbx/keybox-defs.h (keybox_found_s): New.
(keybox_handle): Factor FOUND out to above. Add saved_found.
* kbx/keybox-init.c (keybox_release): Release saved_found.
(keybox_push_found_state, keybox_pop_found_state): New.
* sm/keydb.c (keydb_handle): Add field saved_found.
(keydb_new): Init it.
(keydb_push_found_state, keydb_pop_found_state): New.
Diffstat (limited to 'kbx/keybox-init.c')
-rw-r--r-- | kbx/keybox-init.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/kbx/keybox-init.c b/kbx/keybox-init.c index d3299412a..8ae3ec315 100644 --- a/kbx/keybox-init.c +++ b/kbx/keybox-init.c @@ -148,6 +148,7 @@ keybox_release (KEYBOX_HANDLE hd) hd->kb->handle_table[idx] = NULL; } _keybox_release_blob (hd->found.blob); + _keybox_release_blob (hd->saved_found.blob); if (hd->fp) { fclose (hd->fp); @@ -159,6 +160,35 @@ keybox_release (KEYBOX_HANDLE hd) } +/* Save the current found state in HD for later retrieval by + keybox_restore_found_state. Only one state may be saved. */ +void +keybox_push_found_state (KEYBOX_HANDLE hd) +{ + if (hd->saved_found.blob) + { + _keybox_release_blob (hd->saved_found.blob); + hd->saved_found.blob = NULL; + } + hd->saved_found = hd->found; + hd->found.blob = NULL; +} + + +/* Restore the saved found state in HD. */ +void +keybox_pop_found_state (KEYBOX_HANDLE hd) +{ + if (hd->found.blob) + { + _keybox_release_blob (hd->found.blob); + hd->found.blob = NULL; + } + hd->found = hd->saved_found; + hd->saved_found.blob = NULL; +} + + const char * keybox_get_resource_name (KEYBOX_HANDLE hd) { |