Only seed database for Debian install if we're using default config
[onak.git] / keydb_dynamic.h
1 /*
2  * keydb_dynamic.h - declarations for the dynamic backend
3  *
4  * Brett Parker <iDunno@sommitrealweird.co.uk>
5  *
6  * Copyright 2005 Project Purple
7  */
8 #include <stdlib.h>
9 #include <dlfcn.h>
10 #include <string.h>
11 #include <inttypes.h>
12
13 #include "charfuncs.h"
14 #include "onak-conf.h"
15 #include "keystructs.h"
16 #include "ll.h"
17 #include "log.h"
18
19 #ifndef __KEYDB_DYNAMIC_H__
20 #define __KEYDB_DYNAMIC_H__
21
22 /*
23  * Hide the ugly function definitions in typedefs that we use elsewhere
24  */
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,
37                 bool sendsync);
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),
44                 void *ctx);
45
46
47 /*
48  * Define a nice struct to hold pointers to the functions, once the backend
49  * is loaded
50  */
51 struct dynamic_backend {
52         initdbfunc_t initdb;
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;
66         char *backendsoname;
67         void *handle;
68         bool loaded;
69 };
70
71 struct dynamic_backend __dynamicdb_backend__ = {
72         NULL,   /* initdb */
73         NULL,   /* cleanupdb */
74         NULL,   /* starttrans */
75         NULL,   /* endtrans */
76         NULL,   /* fetch_key */
77         NULL,   /* store_key */
78         NULL,   /* delete_key */
79         NULL,   /* fetch_key_text */
80         NULL,   /* update_keys */
81         NULL,   /* keyid2uid */
82         NULL,   /* getkeysigs */
83         NULL,   /* cached_getkeysigs */
84         NULL,   /* getfullkeyid */
85         NULL,   /* iteratekeys */
86         NULL,   /* backendsoname */
87         NULL,   /* handle */
88         0       /* loaded */
89 };
90
91 bool load_backend(void);
92 bool close_backend(void);
93 bool backend_loaded(void);
94 struct dynamic_backend *get_backend(void);
95
96 #endif /* __KEYDB_DYNAMIC_H__ */