]> the.earth.li Git - onak.git/blobdiff - keydb/keydb_file.c
Mark unused function parameters
[onak.git] / keydb / keydb_file.c
index ded6a9e2e0c8e9db23f245b93e02a20f67e3a369..8989d3c2ee578271916e9d05508ac503419fdc40 100644 (file)
@@ -28,7 +28,9 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "build-config.h"
 #include "charfuncs.h"
+#include "key-store.h"
 #include "keydb.h"
 #include "keyid.h"
 #include "keystructs.h"
@@ -43,7 +45,7 @@
  *
  *     This is just a no-op for flat file access.
  */
-static bool file_starttrans(struct onak_dbctx *dbctx)
+static bool file_starttrans(__unused struct onak_dbctx *dbctx)
 {
        return true;
 }
@@ -53,7 +55,7 @@ static bool file_starttrans(struct onak_dbctx *dbctx)
  *
  *     This is just a no-op for flat file access.
  */
-static void file_endtrans(struct onak_dbctx *dbctx)
+static void file_endtrans(__unused struct onak_dbctx *dbctx)
 {
        return;
 }
@@ -73,26 +75,24 @@ static void file_endtrans(struct onak_dbctx *dbctx)
 static int file_fetch_key_id(struct onak_dbctx *dbctx,
                uint64_t keyid,
                struct openpgp_publickey **publickey,
-               bool intrans)
+               __unused bool intrans)
 {
        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);
 }
 
 /**
@@ -107,8 +107,8 @@ static int file_fetch_key_id(struct onak_dbctx *dbctx,
  *     the file.
  */
 static int file_store_key(struct onak_dbctx *dbctx,
-               struct openpgp_publickey *publickey, bool intrans,
-               bool update)
+               struct openpgp_publickey *publickey, __unused bool intrans,
+               __unused bool update)
 {
        char *db_dir = (char *) dbctx->priv;
        struct openpgp_packet_list *packets = NULL;
@@ -150,7 +150,7 @@ static int file_store_key(struct onak_dbctx *dbctx,
  *     are using. Returns 0 if the key existed.
  */
 static int file_delete_key(struct onak_dbctx *dbctx,
-               struct openpgp_fingerprint *fp, bool intrans)
+               struct openpgp_fingerprint *fp, __unused bool intrans)
 {
        char *db_dir = (char *) dbctx->priv;
        char keyfile[1024];
@@ -171,9 +171,9 @@ static int file_delete_key(struct onak_dbctx *dbctx,
  *
  *     TODO: Write for flat file access. Some sort of grep?
  */
-static int file_fetch_key_text(struct onak_dbctx *dbctx,
-               const char *search,
-               struct openpgp_publickey **publickey)
+static int file_fetch_key_text(__unused struct onak_dbctx *dbctx,
+               __unused const char *search,
+               __unused struct openpgp_publickey **publickey)
 {
        return 0;
 }
@@ -199,8 +199,8 @@ static int file_iterate_keys(struct onak_dbctx *dbctx,
        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);
 
@@ -211,13 +211,10 @@ static int file_iterate_keys(struct onak_dbctx *dbctx,
                                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);
@@ -226,7 +223,6 @@ static int file_iterate_keys(struct onak_dbctx *dbctx,
                                        key = NULL;
                                        free_packet_list(packets);
                                        packets = NULL;
-                                       close(fd);
                                }
                                numkeys++;
                        }
@@ -270,7 +266,8 @@ static void file_cleanupdb(struct onak_dbctx *dbctx)
  *
  *     This is just a no-op for flat file access.
  */
-struct onak_dbctx *keydb_file_init(struct onak_db_config *dbcfg, bool readonly)
+struct onak_dbctx *keydb_file_init(struct onak_db_config *dbcfg,
+               __unused bool readonly)
 {
        struct onak_dbctx *dbctx;
 
@@ -285,8 +282,10 @@ struct onak_dbctx *keydb_file_init(struct onak_db_config *dbcfg, bool readonly)
        dbctx->cleanupdb                = file_cleanupdb;
        dbctx->starttrans               = file_starttrans;
        dbctx->endtrans                 = file_endtrans;
-       dbctx->fetch_key_id             = file_fetch_key_id;
+       /* Our fetch fp doesn't look at subkeys */
+       dbctx->fetch_key                = generic_fetch_key_fp;
        dbctx->fetch_key_fp             = generic_fetch_key_fp;
+       dbctx->fetch_key_id             = file_fetch_key_id;
        dbctx->fetch_key_text           = file_fetch_key_text;
        dbctx->store_key                = file_store_key;
        dbctx->update_keys              = generic_update_keys;