aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/simple_db_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-09-13 21:01:35 +0200
committerMax Kellermann <max@duempel.org>2011-09-13 21:01:35 +0200
commit2fe1b5034d85b9d80ec555a8736d6bbef2eaf901 (patch)
tree1a05031ab7deab2ac6a43e66544b7a1c32464d02 /src/db/simple_db_plugin.c
parentb4430839a3413893a027f7a0fc5494af8198e1bb (diff)
downloadmpd-2fe1b5034d85b9d80ec555a8736d6bbef2eaf901.tar.gz
mpd-2fe1b5034d85b9d80ec555a8736d6bbef2eaf901.tar.xz
mpd-2fe1b5034d85b9d80ec555a8736d6bbef2eaf901.zip
db_plugin: add method get_song()
New db_get_song() implementation.
Diffstat (limited to 'src/db/simple_db_plugin.c')
-rw-r--r--src/db/simple_db_plugin.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/db/simple_db_plugin.c b/src/db/simple_db_plugin.c
index 0154cb223..8218635fc 100644
--- a/src/db/simple_db_plugin.c
+++ b/src/db/simple_db_plugin.c
@@ -20,6 +20,7 @@
#include "config.h"
#include "simple_db_plugin.h"
#include "db_internal.h"
+#include "db_error.h"
#include "db_save.h"
#include "conf.h"
#include "glib_compat.h"
@@ -214,12 +215,28 @@ simple_db_close(struct db *_db)
directory_free(db->root);
}
+static struct song *
+simple_db_get_song(struct db *_db, const char *uri, GError **error_r)
+{
+ struct simple_db *db = (struct simple_db *)_db;
+
+ assert(db->root != NULL);
+
+ struct song *song = directory_lookup_song(db->root, uri);
+ if (song == NULL)
+ g_set_error(error_r, db_quark(), DB_NOT_FOUND,
+ "No such song: %s", uri);
+
+ return song;
+}
+
const struct db_plugin simple_db_plugin = {
.name = "simple",
.init = simple_db_init,
.finish = simple_db_finish,
.open = simple_db_open,
.close = simple_db_close,
+ .get_song = simple_db_get_song,
};
struct directory *