diff options
author | Max Kellermann <max@duempel.org> | 2009-04-01 17:30:56 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-04-01 17:30:56 +0200 |
commit | cb35d6e687f80d2357b20364fde105886ccaa34b (patch) | |
tree | 413a81089f8bae57635276aa01547f9619961fd2 /src | |
parent | efcf40f55b422f95646ba84b1ef3ee8c0a9fcf76 (diff) | |
download | mpd-cb35d6e687f80d2357b20364fde105886ccaa34b.tar.gz mpd-cb35d6e687f80d2357b20364fde105886ccaa34b.tar.xz mpd-cb35d6e687f80d2357b20364fde105886ccaa34b.zip |
sticker_print: new library for sending stickers to a client
Diffstat (limited to 'src')
-rw-r--r-- | src/command.c | 13 | ||||
-rw-r--r-- | src/sticker_print.c | 43 | ||||
-rw-r--r-- | src/sticker_print.h | 39 |
3 files changed, 85 insertions, 10 deletions
diff --git a/src/command.c b/src/command.c index 48f6b8873..21ace50d3 100644 --- a/src/command.c +++ b/src/command.c @@ -48,6 +48,7 @@ #ifdef ENABLE_SQLITE #include "sticker.h" +#include "sticker_print.h" #include "song_sticker.h" #endif @@ -1506,14 +1507,6 @@ handle_idle(struct client *client, } #ifdef ENABLE_SQLITE -static void -print_sticker(const char *name, const char *value, gpointer data) -{ - struct client *client = data; - - client_printf(client, "sticker: %s=%s\n", name, value); -} - static enum command_return handle_sticker_song(struct client *client, int argc, char *argv[]) { @@ -1535,7 +1528,7 @@ handle_sticker_song(struct client *client, int argc, char *argv[]) return COMMAND_RETURN_ERROR; } - client_printf(client, "sticker: %s=%s\n", argv[4], value); + sticker_print_value(client, argv[4], value); g_free(value); return COMMAND_RETURN_OK; @@ -1547,7 +1540,7 @@ handle_sticker_song(struct client *client, int argc, char *argv[]) return COMMAND_RETURN_ERROR; } - sticker_foreach(sticker, print_sticker, client); + sticker_print(client, sticker); sticker_free(sticker); return COMMAND_RETURN_OK; diff --git a/src/sticker_print.c b/src/sticker_print.c new file mode 100644 index 000000000..12dafd3f7 --- /dev/null +++ b/src/sticker_print.c @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2003-2009 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "sticker_print.h" +#include "sticker.h" +#include "client.h" + +void +sticker_print_value(struct client *client, + const char *name, const char *value) +{ + client_printf(client, "sticker: %s=%s\n", name, value); +} + +static void +print_sticker_cb(const char *name, const char *value, gpointer data) +{ + struct client *client = data; + + sticker_print_value(client, name, value); +} + +void +sticker_print(struct client *client, const struct sticker *sticker) +{ + sticker_foreach(sticker, print_sticker_cb, client); +} diff --git a/src/sticker_print.h b/src/sticker_print.h new file mode 100644 index 000000000..25f0deae2 --- /dev/null +++ b/src/sticker_print.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2003-2009 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_STICKER_PRINT_H +#define MPD_STICKER_PRINT_H + +struct sticker; +struct client; + +/** + * Sends one sticker value to the client. + */ +void +sticker_print_value(struct client *client, + const char *name, const char *value); + +/** + * Sends all sticker values to the client. + */ +void +sticker_print(struct client *client, const struct sticker *sticker); + +#endif |