aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-08-08 08:36:14 +0200
committerMax Kellermann <max@duempel.org>2012-08-08 09:28:13 +0200
commitb46bb611b331869734c687394b8d0a516052798e (patch)
tree7c181f67f27b1a7619cee718accdf39d81426ea3
parentaa55d759f555782dc9cf2f9f6d489502310490a6 (diff)
DatabaseGlue: pass block to db_init()
Let the caller take care for legacy conversion.
-rw-r--r--src/DatabaseGlue.cxx11
-rw-r--r--src/database.h4
-rw-r--r--src/main.c7
3 files changed, 9 insertions, 13 deletions
diff --git a/src/DatabaseGlue.cxx b/src/DatabaseGlue.cxx
index a0246253..370a264a 100644
--- a/src/DatabaseGlue.cxx
+++ b/src/DatabaseGlue.cxx
@@ -51,21 +51,12 @@ static Database *db;
static bool db_is_open;
bool
-db_init(const struct config_param *path, GError **error_r)
+db_init(const struct config_param *param, GError **error_r)
{
assert(db == NULL);
assert(!db_is_open);
- if (path == NULL)
- return true;
-
- struct config_param *param = config_new_param("database", path->line);
- config_add_block_param(param, "path", path->value, path->line);
-
db = simple_db_plugin.create(param, error_r);
-
- config_param_free(param);
-
return db != NULL;
}
diff --git a/src/database.h b/src/database.h
index a22fea82..d8d86fa5 100644
--- a/src/database.h
+++ b/src/database.h
@@ -35,10 +35,10 @@ struct db_visitor;
/**
* Initialize the database library.
*
- * @param path the absolute path of the database file
+ * @param param the database configuration block
*/
bool
-db_init(const struct config_param *path, GError **error_r);
+db_init(const struct config_param *param, GError **error_r);
void
db_finish(void);
diff --git a/src/main.c b/src/main.c
index 99918c48..00bbf720 100644
--- a/src/main.c
+++ b/src/main.c
@@ -169,9 +169,14 @@ glue_db_init_and_load(void)
if (path == NULL)
MPD_ERROR(CONF_DB_FILE " setting missing");
- if (!db_init(path, &error))
+ struct config_param *param = config_new_param("database", path->line);
+ config_add_block_param(param, "path", path->value, path->line);
+
+ if (!db_init(param, &error))
MPD_ERROR("%s", error->message);
+ config_param_free(param);
+
ret = db_load(&error);
if (!ret)
MPD_ERROR("%s", error->message);