X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb_db2.c;h=a30b62c43ba3b27413263372315641073d491191;hb=62078c1601192c2594b954a122ac44a0c319c9bd;hp=3d66c5a18ca0095f0bcebd565c317dbc6504ed00;hpb=340e776784a8902d43e6c4658c45254202e2779e;p=onak.git diff --git a/keydb_db2.c b/keydb_db2.c index 3d66c5a..a30b62c 100644 --- a/keydb_db2.c +++ b/keydb_db2.c @@ -16,6 +16,7 @@ #include #include +#include "charfuncs.h" #include "keydb.h" #include "keyid.h" #include "keyindex.h" @@ -41,40 +42,6 @@ static DB **db2_keydbfiles = NULL; */ static DB_ENV db2_env; -/* - * Shared with CGI buffer stuff... - */ -struct db2_get_ctx { - char *buffer; - int offset; - int size; -}; - -/** - * keydb_fetchchar - Fetches a char from a buffer. - */ -int keydb_fetchchar(void *ctx, int count, unsigned char *c) -{ - struct db2_get_ctx *buf = NULL; - int i; - - buf = (struct db2_get_ctx *) ctx; - for (i = 0; i < count; i++) { - c[i] = buf->buffer[buf->offset++]; - } - - return (((buf->offset) == (buf->size)) ? 1 : 0); -} - -/** - * keydb_putchar - Puts a char to a file. - */ -static int keydb_putchar(void *fd, unsigned char c) -{ -// return !(lo_write(dbconn, *(int *) fd, &c, sizeof(c))); - return 1; -} - DB *keydb(DBT *key) { /* @@ -196,7 +163,7 @@ int fetch_key(uint64_t keyid, struct openpgp_publickey **publickey, int ret; DBT key, data; char id[KEYDB_KEYID_BYTES]; - struct db2_get_ctx fetchbuf; + struct buffer_ctx fetchbuf; memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); @@ -214,7 +181,7 @@ int fetch_key(uint64_t keyid, struct openpgp_publickey **publickey, fetchbuf.buffer = data.data; fetchbuf.offset = 0; fetchbuf.size = data.size; - read_openpgp_stream(keydb_fetchchar, &fetchbuf, &packets); + read_openpgp_stream(buffer_fetchchar, &fetchbuf, &packets); parse_keys(packets, publickey); }