aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorEric Wollesen <ericw@xmtp.net>2009-04-01 18:44:39 +0200
committerMax Kellermann <max@duempel.org>2009-04-01 18:44:39 +0200
commitc95fa4b441a445bcbe55707e74adfa22e783f732 (patch)
treedbbf9ba39a92f82dd059fb351bc43683ae3225af /src/command.c
parentc51e1bf1c093f823fca3ecbf3fe87e1ce1c6059a (diff)
downloadmpd-c95fa4b441a445bcbe55707e74adfa22e783f732.tar.gz
mpd-c95fa4b441a445bcbe55707e74adfa22e783f732.tar.xz
mpd-c95fa4b441a445bcbe55707e74adfa22e783f732.zip
Move db_get_song into sub-handlers. (FReq 2112)
db_get_song was being called once for all sub-handlers, but with the addition of the find command, we don't have a URI coming in, so doing db_get_song once won't work anymore. [mk: fixed initialization order]
Diffstat (limited to '')
-rw-r--r--src/command.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/command.c b/src/command.c
index 21ace50d3..aab63998e 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1510,17 +1510,17 @@ handle_idle(struct client *client,
static enum command_return
handle_sticker_song(struct client *client, int argc, char *argv[])
{
- struct song *song = db_get_song(argv[3]);
-
- if (song == NULL) {
- command_error(client, ACK_ERROR_NO_EXIST,
- "no such song");
- return COMMAND_RETURN_ERROR;
- }
-
if (argc == 5 && strcmp(argv[1], "get") == 0) {
+ struct song *song;
char *value;
+ song = db_get_song(argv[3]);
+ if (song == NULL) {
+ command_error(client, ACK_ERROR_NO_EXIST,
+ "no such song");
+ return COMMAND_RETURN_ERROR;
+ }
+
value = sticker_song_get_value(song, argv[4]);
if (value == NULL) {
command_error(client, ACK_ERROR_NO_EXIST,
@@ -1533,7 +1533,17 @@ handle_sticker_song(struct client *client, int argc, char *argv[])
return COMMAND_RETURN_OK;
} else if (argc == 4 && strcmp(argv[1], "list") == 0) {
- struct sticker *sticker = sticker_song_get(song);
+ struct song *song;
+ struct sticker *sticker;
+
+ song = db_get_song(argv[3]);
+ if (song == NULL) {
+ command_error(client, ACK_ERROR_NO_EXIST,
+ "no such song");
+ return COMMAND_RETURN_ERROR;
+ }
+
+ sticker = sticker_song_get(song);
if (NULL == sticker) {
command_error(client, ACK_ERROR_NO_EXIST,
"no stickers found");
@@ -1545,8 +1555,16 @@ handle_sticker_song(struct client *client, int argc, char *argv[])
return COMMAND_RETURN_OK;
} else if (argc == 6 && strcmp(argv[1], "set") == 0) {
+ struct song *song;
bool ret;
+ song = db_get_song(argv[3]);
+ if (song == NULL) {
+ command_error(client, ACK_ERROR_NO_EXIST,
+ "no such song");
+ return COMMAND_RETURN_ERROR;
+ }
+
ret = sticker_song_set_value(song, argv[4], argv[5]);
if (!ret) {
command_error(client, ACK_ERROR_SYSTEM,