-struct dbfuncs keydb_file_funcs = {
- .initdb = file_initdb,
- .cleanupdb = file_cleanupdb,
- .starttrans = file_starttrans,
- .endtrans = file_endtrans,
- .fetch_key = file_fetch_key,
- .fetch_key_text = file_fetch_key_text,
- .store_key = file_store_key,
- .update_keys = generic_update_keys,
- .delete_key = file_delete_key,
- .getkeysigs = generic_getkeysigs,
- .cached_getkeysigs = generic_cached_getkeysigs,
- .keyid2uid = generic_keyid2uid,
- .getfullkeyid = generic_getfullkeyid,
- .iterate_keys = file_iterate_keys,
-};
+/**
+ * cleanupdb - De-initialize the key database.
+ *
+ * This is just a no-op for flat file access.
+ */
+static void file_cleanupdb(struct onak_dbctx *dbctx)
+{
+ if (dbctx->priv != NULL) {
+ free(dbctx->priv);
+ dbctx->priv = NULL;
+ }
+
+ if (dbctx != NULL) {
+ free(dbctx);
+ }
+}
+
+/**
+ * initdb - Initialize the key database.
+ *
+ * This is just a no-op for flat file access.
+ */
+struct onak_dbctx *keydb_file_init(bool readonly)
+{
+ struct onak_dbctx *dbctx;
+
+ dbctx = malloc(sizeof(struct onak_dbctx));
+ if (dbctx == NULL) {
+ return NULL;
+ }
+
+ dbctx->priv = strdup(config.db_dir);
+
+ dbctx->cleanupdb = file_cleanupdb;
+ dbctx->starttrans = file_starttrans;
+ dbctx->endtrans = file_endtrans;
+ dbctx->fetch_key_id = file_fetch_key_id;
+ dbctx->fetch_key_fp = generic_fetch_key_fp;
+ dbctx->fetch_key_text = file_fetch_key_text;
+ dbctx->store_key = file_store_key;
+ dbctx->update_keys = generic_update_keys;
+ dbctx->delete_key = file_delete_key;
+ dbctx->getkeysigs = generic_getkeysigs;
+ dbctx->cached_getkeysigs = generic_cached_getkeysigs;
+ dbctx->keyid2uid = generic_keyid2uid;
+ dbctx->getfullkeyid = generic_getfullkeyid;
+ dbctx->iterate_keys = file_iterate_keys;
+
+ return dbctx;
+}