gpgscm: Add 'finally', rework all macros.
[gnupg.git] / kbx / keybox.h
index 03a9245..5c2824a 100644 (file)
@@ -14,7 +14,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef KEYBOX_H
@@ -29,15 +29,6 @@ extern "C" {
 #include "../common/iobuf.h"
 #include "keybox-search-desc.h"
 
-#define KEYBOX_WITH_OPENPGP 1
-#define KEYBOX_WITH_X509 1
-
-
-#ifdef KEYBOX_WITH_OPENPGP
-#  undef KEYBOX_WITH_OPENPGP
-/*#include <lib-to-handle-gpg-data-structs.h>*/
-#endif
-
 #ifdef KEYBOX_WITH_X509
 # include <ksba.h>
 #endif
@@ -62,35 +53,52 @@ typedef enum
 #define KEYBOX_FLAG_BLOB_SECRET     1
 #define KEYBOX_FLAG_BLOB_EPHEMERAL  2
 
+/* The keybox blob types.  */
+typedef enum
+  {
+    KEYBOX_BLOBTYPE_EMPTY  = 0,
+    KEYBOX_BLOBTYPE_HEADER = 1,
+    KEYBOX_BLOBTYPE_PGP    = 2,
+    KEYBOX_BLOBTYPE_X509   = 3
+  } keybox_blobtype_t;
 
 
 /*-- keybox-init.c --*/
-void *keybox_register_file (const char *fname, int secret);
+gpg_error_t keybox_register_file (const char *fname, int secret,
+                                  void **r_token);
 int keybox_is_writable (void *token);
 
-KEYBOX_HANDLE keybox_new (void *token, int secret);
+KEYBOX_HANDLE keybox_new_openpgp (void *token, int secret);
+KEYBOX_HANDLE keybox_new_x509 (void *token, int secret);
 void keybox_release (KEYBOX_HANDLE hd);
+void keybox_push_found_state (KEYBOX_HANDLE hd);
+void keybox_pop_found_state (KEYBOX_HANDLE hd);
 const char *keybox_get_resource_name (KEYBOX_HANDLE hd);
 int keybox_set_ephemeral (KEYBOX_HANDLE hd, int yes);
 
-int keybox_lock (KEYBOX_HANDLE hd, int yes);
+gpg_error_t keybox_lock (KEYBOX_HANDLE hd, int yes);
 
 /*-- keybox-file.c --*/
 /* Fixme: This function does not belong here: Provide a better
    interface to create a new keybox file.  */
-int _keybox_write_header_blob (FILE *fp);
+int _keybox_write_header_blob (FILE *fp, int openpgp_flag);
 
 /*-- keybox-search.c --*/
-gpg_error_t keybox_get_keyblock (KEYBOX_HANDLE hd,
-                                 iobuf_t *r_iobuf, u32 **sigstatus);
+gpg_error_t keybox_get_keyblock (KEYBOX_HANDLE hd, iobuf_t *r_iobuf,
+                                 int *r_uid_no, int *r_pk_no, u32 **sigstatus);
 #ifdef KEYBOX_WITH_X509
 int keybox_get_cert (KEYBOX_HANDLE hd, ksba_cert_t *ret_cert);
 #endif /*KEYBOX_WITH_X509*/
 int keybox_get_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int *value);
 
-int keybox_search_reset (KEYBOX_HANDLE hd);
-int keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc);
+gpg_error_t keybox_search_reset (KEYBOX_HANDLE hd);
+gpg_error_t keybox_search (KEYBOX_HANDLE hd,
+                           KEYBOX_SEARCH_DESC *desc, size_t ndesc,
+                           keybox_blobtype_t want_blobtype,
+                           size_t *r_descindex, unsigned long *r_skipped);
 
+off_t keybox_offset (KEYBOX_HANDLE hd);
+gpg_error_t keybox_seek (KEYBOX_HANDLE hd, off_t offset);
 
 /*-- keybox-update.c --*/
 gpg_error_t keybox_insert_keyblock (KEYBOX_HANDLE hd,
@@ -114,10 +122,7 @@ int keybox_compress (KEYBOX_HANDLE hd);
 /*--  --*/
 
 #if 0
-int keybox_get_keyblock (KEYBOX_HANDLE hd, KBNODE *ret_kb);
 int keybox_locate_writable (KEYBOX_HANDLE hd);
-int keybox_search_reset (KEYBOX_HANDLE hd);
-int keybox_search (KEYBOX_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc);
 int keybox_rebuild_cache (void *);
 #endif
 
@@ -127,6 +132,9 @@ void keybox_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
                                void *(*new_realloc_func)(void *p, size_t n),
                                void (*new_free_func)(void*) );
 
+gpg_error_t keybox_tmp_names (const char *filename, int for_keyring,
+                              char **r_bakname, char **r_tmpname);
+
 
 #ifdef __cplusplus
 }