From a8b225f947fc2d5e464222ea9b535c49fbce9ac9 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Sun, 7 Sep 2008 13:44:12 +0200
Subject: playlist: don't pass "fd" to storedPlaylist.c functions

Return an "enum playlist_result" value instead of calling
commandError() in storedPlaylist.c.
---
 src/command.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

(limited to 'src/command.c')

diff --git a/src/command.c b/src/command.c
index e9dc83ccb..6bdfba58b 100644
--- a/src/command.c
+++ b/src/command.c
@@ -531,7 +531,10 @@ static int handleSave(int fd, mpd_unused int *permission,
 static int handleLoad(int fd, mpd_unused int *permission,
 		      mpd_unused int argc, char *argv[])
 {
-	return loadPlaylist(fd, argv[1]);
+	enum playlist_result result;
+
+	result = loadPlaylist(fd, argv[1]);
+	return print_playlist_result(fd, result);
 }
 
 static int handleListPlaylist(int fd, mpd_unused int *permission,
@@ -575,7 +578,10 @@ static int handleRm(int fd, mpd_unused int *permission,
 static int handleRename(int fd, mpd_unused int *permission,
 			mpd_unused int argc, char *argv[])
 {
-	return renameStoredPlaylist(fd, argv[1], argv[2]);
+	enum playlist_result result;
+
+	result = renameStoredPlaylist(argv[1], argv[2]);
+	return print_playlist_result(fd, result);
 }
 
 static int handlePlaylistChanges(int fd, mpd_unused int *permission,
@@ -734,11 +740,13 @@ static int handlePlaylistDelete(int fd, mpd_unused int *permission,
 				mpd_unused int argc, char *argv[]) {
 	char *playlist = argv[1];
 	int from;
+	enum playlist_result result;
 
 	if (check_int(fd, &from, argv[2], check_integer, argv[2]) < 0)
 		return -1;
 
-	return removeOneSongFromStoredPlaylistByPath(fd, playlist, from);
+	result = removeOneSongFromStoredPlaylistByPath(playlist, from);
+	return print_playlist_result(fd, result);
 }
 
 static int handlePlaylistMove(int fd, mpd_unused int *permission,
@@ -746,13 +754,15 @@ static int handlePlaylistMove(int fd, mpd_unused int *permission,
 {
 	char *playlist = argv[1];
 	int from, to;
+	enum playlist_result result;
 
 	if (check_int(fd, &from, argv[2], check_integer, argv[2]) < 0)
 		return -1;
 	if (check_int(fd, &to, argv[3], check_integer, argv[3]) < 0)
 		return -1;
 
-	return moveSongInStoredPlaylistByPath(fd, playlist, from, to);
+	result = moveSongInStoredPlaylistByPath(playlist, from, to);
+	return print_playlist_result(fd, result);
 }
 
 static int listHandleUpdate(int fd,
@@ -1137,7 +1147,10 @@ static int handleNotcommands(int fd, mpd_unused int *permission,
 static int handlePlaylistClear(int fd, mpd_unused int *permission,
 			       mpd_unused int argc, char *argv[])
 {
-	return clearStoredPlaylist(fd, argv[1]);
+	enum playlist_result result;
+
+	result = clearStoredPlaylist(argv[1]);
+	return print_playlist_result(fd, result);
 }
 
 static int handlePlaylistAdd(int fd, mpd_unused int *permission,
@@ -1145,11 +1158,13 @@ static int handlePlaylistAdd(int fd, mpd_unused int *permission,
 {
 	char *playlist = argv[1];
 	char *path = argv[2];
+	enum playlist_result result;
 
 	if (isRemoteUrl(path))
-		return addToStoredPlaylist(fd, path, playlist);
-
-	return addAllInToStoredPlaylist(fd, path, playlist);
+		result = addToStoredPlaylist(path, playlist);
+	else
+		result = addAllInToStoredPlaylist(fd, path, playlist);
+	return print_playlist_result(fd, result);
 }
 
 void initCommands(void)
-- 
cgit v1.2.3