]> the.earth.li Git - onak.git/blobdiff - hashquery.c
Cleanup various includes
[onak.git] / hashquery.c
index 478c20f9453bc5c327353fdba6a585c4b395947f..2c41598f0df4791decdb832562476cfa50035e8f 100644 (file)
@@ -17,6 +17,7 @@
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -25,7 +26,7 @@
 
 #include "charfuncs.h"
 #include "cleanup.h"
-#include "keyid.h"
+#include "keydb.h"
 #include "log.h"
 #include "marshal.h"
 #include "mem.h"
@@ -47,6 +48,7 @@ int main(int argc, char *argv[])
        uint8_t **hashes;
        struct buffer_ctx cgipostbuf;
        struct openpgp_publickey **keys;
+       struct onak_dbctx *dbctx;
 
        readconfig(NULL);
        initlogthing("hashquery", config.logfile);
@@ -88,15 +90,16 @@ int main(int argc, char *argv[])
                doerror("Couldn't allocate memory for reply.\n");
        }
 
-       if (config.dbbackend->fetch_key_skshash == NULL) {
+       catchsignals();
+       dbctx = config.dbinit(config.backend, false);
+
+       if (dbctx->fetch_key_skshash == NULL) {
+               dbctx->cleanupdb(dbctx);
                doerror("Can't fetch by skshash with this backend.");
        }
 
-       catchsignals();
-       config.dbbackend->initdb(false);
-
        for (i = 0; i < count; i++) {
-               config.dbbackend->fetch_key_skshash(
+               dbctx->fetch_key_skshash(dbctx,
                                (struct skshash *) hashes[i], &keys[found]);
                if (keys[found] != NULL) {
                        found++;
@@ -107,7 +110,7 @@ int main(int argc, char *argv[])
        free(hashes);
        hashes = NULL;
 
-       config.dbbackend->cleanupdb();
+       dbctx->cleanupdb(dbctx);
 
        puts("Content-Type: pgp/keys\n");
        marshal_array(stdout_putchar, NULL,