aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist.c
diff options
context:
space:
mode:
authorThomas Jansen <mithi@mithi.net>2009-01-09 17:06:44 +0100
committerMax Kellermann <max@duempel.org>2009-01-10 16:50:34 +0100
commit6f0781f0396ab5e4bc8aece6986381dac8f03081 (patch)
treed20b32323c25d86c81f43af106952efbbdd5d3bb /src/playlist.c
parent8ed3cf3e6b31e48369a2007da8c95d686c62d184 (diff)
downloadmpd-6f0781f0396ab5e4bc8aece6986381dac8f03081.tar.gz
mpd-6f0781f0396ab5e4bc8aece6986381dac8f03081.tar.xz
mpd-6f0781f0396ab5e4bc8aece6986381dac8f03081.zip
command: playlistinfo now uses a range argument rather than just a song id
Loosely based on a patch provided by lesion in bug #1766. The playlistinfo command can now retrieve ranges of the playlist. The new argument indicates which entry is the last one that will be displayed. The number of displayed entries may be smaller than expected if the end of the playlist is reached. Previous usage: playlistinfo [start] New usage: playlistinfo [start[:end]]
Diffstat (limited to 'src/playlist.c')
-rw-r--r--src/playlist.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/playlist.c b/src/playlist.c
index df60fe99b..e6dd1cac0 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -413,7 +413,7 @@ int playlistChangesPosId(struct client *client, uint32_t version)
return 0;
}
-enum playlist_result playlistInfo(struct client *client, int song)
+enum playlist_result playlistInfo(struct client *client, int song, int max)
{
unsigned begin = 0;
unsigned end = playlist.length;
@@ -424,6 +424,11 @@ enum playlist_result playlistInfo(struct client *client, int song)
}
if (song >= (int)playlist.length)
return PLAYLIST_RESULT_BAD_RANGE;
+ if (max > 0) {
+ end = MIN((unsigned)(max + 1), playlist.length);
+ if (end <= begin)
+ return PLAYLIST_RESULT_BAD_RANGE;
+ }
for (unsigned i = begin; i < end; i++)
printPlaylistSongInfo(client, i);