#include <unistd.h>
#include "charfuncs.h"
+#include "key-store.h"
#include "keydb.h"
#include "keyid.h"
#include "keystructs.h"
char *db_dir = (char *) dbctx->priv;
struct openpgp_packet_list *packets = NULL;
char keyfile[1024];
- int fd = -1;
+ onak_status_t res;
snprintf(keyfile, 1023, "%s/0x%" PRIX64, db_dir,
keyid & 0xFFFFFFFF);
- fd = open(keyfile, O_RDONLY); // | O_SHLOCK);
+ res = onak_read_openpgp_file(keyfile, &packets);
- if (fd > -1) {
- read_openpgp_stream(file_fetchchar, &fd, &packets, 0);
+ if (res == ONAK_E_OK) {
parse_keys(packets, publickey);
free_packet_list(packets);
packets = NULL;
- close(fd);
}
- return (fd > -1);
+ return (res == ONAK_E_OK);
}
/**
struct openpgp_publickey *key = NULL;
DIR *dir;
char keyfile[1024];
- int fd = -1;
struct dirent *curfile = NULL;
+ onak_status_t res;
dir = opendir(db_dir);
snprintf(keyfile, 1023, "%s/%s",
db_dir,
curfile->d_name);
- fd = open(keyfile, O_RDONLY);
+ res = onak_read_openpgp_file(keyfile,
+ &packets);
- if (fd > -1) {
- read_openpgp_stream(file_fetchchar,
- &fd,
- &packets,
- 0);
+ if (res == ONAK_E_OK) {
parse_keys(packets, &key);
iterfunc(ctx, key);
key = NULL;
free_packet_list(packets);
packets = NULL;
- close(fd);
}
numkeys++;
}