X-Git-Url: https://the.earth.li/gitweb/?p=onak.git;a=blobdiff_plain;f=hashquery.c;h=5c056a2d3298ab3bb37769cbcd92eb1c0faae7f4;hp=a0f8e1ececcda69ae814c3f820ca1da14457a868;hb=adc800dbc424a1e246dd4a82a0c2e88eeda25531;hpb=5d25774c5cd9f80709f852f79bce26d582fad360 diff --git a/hashquery.c b/hashquery.c index a0f8e1e..5c056a2 100644 --- a/hashquery.c +++ b/hashquery.c @@ -2,8 +2,21 @@ * hashquery.c - CGI to handle SKS style /pks/hashquery requests * * Copyright 2011 Jonathan McDowell + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the 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 . */ +#include #include #include #include @@ -12,7 +25,7 @@ #include "charfuncs.h" #include "cleanup.h" -#include "keyid.h" +#include "keydb.h" #include "log.h" #include "marshal.h" #include "mem.h" @@ -34,6 +47,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); @@ -75,15 +89,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++; @@ -94,7 +109,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,