#include "charfuncs.h"
#include "decodekey.h"
+#include "key-store.h"
#include "keydb.h"
#include "keyid.h"
#include "keystructs.h"
bool intrans)
{
static char buffer[PATH_MAX];
- int ret = 0, fd;
+ int ret = 0;
struct openpgp_packet_list *packets = NULL;
+ onak_status_t res;
if (!intrans)
fs_starttrans(dbctx);
keyid = fs_getfullkeyid(dbctx, keyid);
keypath(buffer, sizeof(buffer), keyid, dbctx->config->location);
- fd = open(buffer, O_RDONLY);
- if (fd == -1 && errno == ENOENT) {
+ res = onak_read_openpgp_file(buffer,
+ &packets);
+ if (res == ONAK_E_NOT_FOUND) {
subkeypath(buffer, sizeof(buffer), keyid,
dbctx->config->location);
- fd = open(buffer, O_RDONLY);
+ res = onak_read_openpgp_file(buffer,
+ &packets);
}
- if (fd != -1) {
+ if (res == ONAK_E_OK) {
/* File is present, load it in... */
- read_openpgp_stream(file_fetchchar, &fd, &packets, 0);
parse_keys(packets, publickey);
free_packet_list(packets);
packets = NULL;
- close(fd);
ret = 1;
}
struct openpgp_publickey **publickey)
{
static char buffer[PATH_MAX];
- int ret = 0, fd;
+ int ret = 0;
struct openpgp_packet_list *packets = NULL;
+ onak_status_t res;
skshashpath(buffer, sizeof(buffer), hash, dbctx->config->location);
- if ((fd = open(buffer, O_RDONLY)) != -1) {
- read_openpgp_stream(file_fetchchar, &fd, &packets, 0);
+ res = onak_read_openpgp_file(buffer, &packets);
+ if (res == ONAK_E_OK) {
parse_keys(packets, publickey);
free_packet_list(packets);
packets = NULL;
- close(fd);
ret = 1;
}
*
* Returns the number of keys we iterated over.
*/
-static int fs_iterate_keys(struct onak_dbctx *dbctx,
- void (*iterfunc)(void *ctx,
- struct openpgp_publickey *key), void *ctx)
+static int fs_iterate_keys(__unused struct onak_dbctx *dbctx,
+ __unused void (*iterfunc)(void *ctx,
+ struct openpgp_publickey *key),
+ __unused void *ctx)
{
return 0;
}