diff options
author | Max Kellermann <max@duempel.org> | 2008-09-23 13:15:42 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-23 13:15:42 +0200 |
commit | 72ad9955c8d5c9abe28d8d59301e159493087976 (patch) | |
tree | 1a40e0e4808ec3e207b4022a0204f94b357ece1b /src | |
parent | ca8a4cf4d050457f633edd13f0052e119629a9f6 (diff) | |
download | mpd-72ad9955c8d5c9abe28d8d59301e159493087976.tar.gz mpd-72ad9955c8d5c9abe28d8d59301e159493087976.tar.xz mpd-72ad9955c8d5c9abe28d8d59301e159493087976.zip |
lyrics: configurable global plugin directory
The lyrics library loads all plugins from the directory configured
with "--with-lyrics-plugin-dir".
Diffstat (limited to '')
-rw-r--r-- | src/lyrics.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/lyrics.c b/src/lyrics.c index 7a6124b69..e6cb5d2b3 100644 --- a/src/lyrics.c +++ b/src/lyrics.c @@ -18,6 +18,7 @@ #include "lyrics.h" #include "gcc.h" +#include "../config.h" #include <assert.h> #include <stdlib.h> @@ -62,12 +63,26 @@ static int lyrics_register_plugin(const char *path0) void lyrics_init(void) { + GDir *dir; + plugins = g_ptr_array_new(); - /* XXX configurable paths */ - lyrics_register_plugin("./lyrics/hd.py"); - lyrics_register_plugin("./lyrics/leoslyrics.py"); - lyrics_register_plugin("./lyrics/lyricswiki.rb"); + dir = g_dir_open(LYRICS_PLUGIN_DIR, 0, NULL); + if (dir != NULL) { + const char *name; + char path[sizeof(LYRICS_PLUGIN_DIR) + 128]; + + memcpy(path, LYRICS_PLUGIN_DIR, sizeof(LYRICS_PLUGIN_DIR) - 1); + path[sizeof(LYRICS_PLUGIN_DIR) - 1] = G_DIR_SEPARATOR; + + while ((name = g_dir_read_name(dir)) != NULL) { + g_strlcpy(path + sizeof(LYRICS_PLUGIN_DIR), name, + sizeof(path) - sizeof(LYRICS_PLUGIN_DIR)); + lyrics_register_plugin(path); + } + + g_dir_close(dir); + } } void lyrics_deinit(void) |