2  * keydb_dynamic.h - declarations for the dynamic backend
 
   4  * Brett Parker <iDunno@sommitrealweird.co.uk>
 
   6  * Copyright 2005 Project Purple
 
  13 #include "charfuncs.h"
 
  14 #include "onak-conf.h"
 
  15 #include "keystructs.h"
 
  19 #ifndef __KEYDB_DYNAMIC_H__
 
  20 #define __KEYDB_DYNAMIC_H__
 
  23  * Hide the ugly function definitions in typedefs that we use elsewhere
 
  25 typedef void (*initdbfunc_t)(bool);
 
  26 typedef void (*cleanupdbfunc_t)(void);
 
  27 typedef bool (*starttransfunc_t)(void);
 
  28 typedef bool (*endtransfunc_t)(void);
 
  29 typedef int (*fetch_keyfunc_t)(uint64_t keyid,
 
  30                 struct openpgp_publickey **publickey, bool intrans);
 
  31 typedef int (*store_keyfunc_t)(struct openpgp_publickey *publickey,
 
  32                 bool intrans, bool update);
 
  33 typedef int (*delete_keyfunc_t)(uint64_t keyid, bool intrans);
 
  34 typedef int (*fetch_key_textfunc_t)(const char *search,
 
  35                 struct openpgp_publickey **publickey);
 
  36 typedef int (*update_keysfunc_t)(struct openpgp_publickey **keys,
 
  38 typedef char *(*keyid2uidfunc_t)(uint64_t keyid);
 
  39 typedef struct ll *(*getkeysigsfunc_t)(uint64_t keyid, bool *revoked);
 
  40 typedef struct ll *(*cached_getkeysigsfunc_t)(uint64_t keyid);
 
  41 typedef uint64_t (*getfullkeyidfunc_t)(uint64_t keyid);
 
  42 typedef int (*iterate_keysfunc_t)(
 
  43                 void (*iterfunc) (void *ctx, struct openpgp_publickey *key),
 
  48  * Define a nice struct to hold pointers to the functions, once the backend
 
  51 struct dynamic_backend {
 
  53         cleanupdbfunc_t cleanupdb;
 
  54         starttransfunc_t starttrans;
 
  55         endtransfunc_t endtrans;
 
  56         fetch_keyfunc_t fetch_key;
 
  57         store_keyfunc_t store_key;
 
  58         delete_keyfunc_t delete_key;
 
  59         fetch_key_textfunc_t fetch_key_text;
 
  60         update_keysfunc_t update_keys;
 
  61         keyid2uidfunc_t keyid2uid;
 
  62         getkeysigsfunc_t getkeysigs;
 
  63         cached_getkeysigsfunc_t cached_getkeysigs;
 
  64         getfullkeyidfunc_t getfullkeyid;
 
  65         iterate_keysfunc_t iterate_keys;
 
  71 struct dynamic_backend __dynamicdb_backend__ = {
 
  74         NULL,   /* starttrans */
 
  78         NULL,   /* delete_key */
 
  79         NULL,   /* fetch_key_text */
 
  80         NULL,   /* update_keys */
 
  82         NULL,   /* getkeysigs */
 
  83         NULL,   /* cached_getkeysigs */
 
  84         NULL,   /* getfullkeyid */
 
  85         NULL,   /* iteratekeys */
 
  86         NULL,   /* backendsoname */
 
  91 bool load_backend(void);
 
  92 bool close_backend(void);
 
  93 bool backend_loaded(void);
 
  94 struct dynamic_backend *get_backend(void);
 
  96 #endif /* __KEYDB_DYNAMIC_H__ */