From 6f0781f0396ab5e4bc8aece6986381dac8f03081 Mon Sep 17 00:00:00 2001 From: Thomas Jansen <mithi@mithi.net> Date: Fri, 9 Jan 2009 17:06:44 +0100 Subject: 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]] --- src/playlist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/playlist.c') 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); -- cgit v1.2.3