aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command.c6
-rw-r--r--src/dbUtils.c2
-rw-r--r--src/playlist.c10
-rw-r--r--src/stored_playlist.c42
-rw-r--r--src/stored_playlist.h13
5 files changed, 39 insertions, 34 deletions
diff --git a/src/command.c b/src/command.c
index 45daa8fad..17ee7dbed 100644
--- a/src/command.c
+++ b/src/command.c
@@ -544,7 +544,7 @@ static int handleRename(struct client *client,
{
enum playlist_result result;
- result = renameStoredPlaylist(argv[1], argv[2]);
+ result = spl_rename(argv[1], argv[2]);
return print_playlist_result(client, result);
}
@@ -718,7 +718,7 @@ static int handlePlaylistDelete(struct client *client,
if (check_int(client, &from, argv[2], check_integer, argv[2]) < 0)
return -1;
- result = removeOneSongFromStoredPlaylistByPath(playlist, from);
+ result = spl_remove_index(playlist, from);
return print_playlist_result(client, result);
}
@@ -734,7 +734,7 @@ static int handlePlaylistMove(struct client *client,
if (check_int(client, &to, argv[3], check_integer, argv[3]) < 0)
return -1;
- result = moveSongInStoredPlaylistByPath(playlist, from, to);
+ result = spl_move_index(playlist, from, to);
return print_playlist_result(client, result);
}
diff --git a/src/dbUtils.c b/src/dbUtils.c
index 6092c7481..49ab6aac9 100644
--- a/src/dbUtils.c
+++ b/src/dbUtils.c
@@ -208,7 +208,7 @@ directoryAddSongToStoredPlaylist(struct song *song, void *_data)
{
struct add_data *data = _data;
- if (appendSongToStoredPlaylistByPath(data->path, song) != 0)
+ if (spl_append_song(data->path, song) != 0)
return -1;
return 0;
}
diff --git a/src/playlist.c b/src/playlist.c
index 404e8ade6..9244b8554 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -220,7 +220,7 @@ void clearPlaylist(void)
int clearStoredPlaylist(const char *utf8file)
{
- return removeAllFromStoredPlaylistByPath(utf8file);
+ return spl_clear(utf8file);
}
void showPlaylist(struct client *client)
@@ -583,14 +583,14 @@ int addToStoredPlaylist(const char *url, const char *utf8file)
song = db_get_song(url);
if (song)
- return appendSongToStoredPlaylistByPath(utf8file, song);
+ return spl_append_song(utf8file, song);
if (!isValidRemoteUtf8Url(url))
return ACK_ERROR_NO_EXIST;
song = song_remote_new(url);
if (song) {
- int ret = appendSongToStoredPlaylistByPath(utf8file, song);
+ int ret = spl_append_song(utf8file, song);
song_free(song);
return ret;
}
@@ -1343,7 +1343,7 @@ int PlaylistInfo(struct client *client, const char *utf8file, int detail)
ListNode *node;
List *list;
- if (!(list = loadStoredPlaylist(utf8file)))
+ if (!(list = spl_load(utf8file)))
return -1;
node = list->firstNode;
@@ -1375,7 +1375,7 @@ enum playlist_result loadPlaylist(struct client *client, const char *utf8file)
ListNode *node;
List *list;
- if (!(list = loadStoredPlaylist(utf8file)))
+ if (!(list = spl_load(utf8file)))
return PLAYLIST_RESULT_NO_SUCH_LIST;
node = list->firstNode;
diff --git a/src/stored_playlist.c b/src/stored_playlist.c
index 73362cae1..8b3b5de2c 100644
--- a/src/stored_playlist.c
+++ b/src/stored_playlist.c
@@ -27,7 +27,8 @@
#include "idle.h"
#include "os_compat.h"
-static ListNode *nodeOfStoredPlaylist(List *list, int idx)
+static ListNode *
+spl_get_index(List *list, int idx)
{
int forward;
ListNode *node;
@@ -63,7 +64,7 @@ static ListNode *nodeOfStoredPlaylist(List *list, int idx)
}
static enum playlist_result
-writeStoredPlaylistToPath(List *list, const char *utf8path)
+spl_save(List *list, const char *utf8path)
{
ListNode *node;
FILE *file;
@@ -87,7 +88,8 @@ writeStoredPlaylistToPath(List *list, const char *utf8path)
return PLAYLIST_RESULT_SUCCESS;
}
-List *loadStoredPlaylist(const char *utf8path)
+List *
+spl_load(const char *utf8path)
{
List *list;
FILE *file;
@@ -136,7 +138,8 @@ List *loadStoredPlaylist(const char *utf8path)
return list;
}
-static int moveSongInStoredPlaylist(List *list, int src, int dest)
+static int
+spl_move_index_internal(List *list, int src, int dest)
{
ListNode *srcNode, *destNode;
@@ -144,11 +147,11 @@ static int moveSongInStoredPlaylist(List *list, int src, int dest)
src < 0 || dest < 0 || src == dest)
return -1;
- srcNode = nodeOfStoredPlaylist(list, src);
+ srcNode = spl_get_index(list, src);
if (!srcNode)
return -1;
- destNode = nodeOfStoredPlaylist(list, dest);
+ destNode = spl_get_index(list, dest);
/* remove src */
if (srcNode->prevNode)
@@ -198,20 +201,20 @@ static int moveSongInStoredPlaylist(List *list, int src, int dest)
}
enum playlist_result
-moveSongInStoredPlaylistByPath(const char *utf8path, int src, int dest)
+spl_move_index(const char *utf8path, int src, int dest)
{
List *list;
enum playlist_result result;
- if (!(list = loadStoredPlaylist(utf8path)))
+ if (!(list = spl_load(utf8path)))
return PLAYLIST_RESULT_NO_SUCH_LIST;
- if (moveSongInStoredPlaylist(list, src, dest) != 0) {
+ if (spl_move_index_internal(list, src, dest) != 0) {
freeList(list);
return PLAYLIST_RESULT_BAD_RANGE;
}
- result = writeStoredPlaylistToPath(list, utf8path);
+ result = spl_save(list, utf8path);
freeList(list);
@@ -220,7 +223,7 @@ moveSongInStoredPlaylistByPath(const char *utf8path, int src, int dest)
}
enum playlist_result
-removeAllFromStoredPlaylistByPath(const char *utf8path)
+spl_clear(const char *utf8path)
{
char filename[MPD_PATH_MAX];
FILE *file;
@@ -240,9 +243,10 @@ removeAllFromStoredPlaylistByPath(const char *utf8path)
return PLAYLIST_RESULT_SUCCESS;
}
-static int removeOneSongFromStoredPlaylist(List *list, int pos)
+static int
+spl_remove_index_internal(List *list, int pos)
{
- ListNode *node = nodeOfStoredPlaylist(list, pos);
+ ListNode *node = spl_get_index(list, pos);
if (!node)
return -1;
@@ -252,20 +256,20 @@ static int removeOneSongFromStoredPlaylist(List *list, int pos)
}
enum playlist_result
-removeOneSongFromStoredPlaylistByPath(const char *utf8path, int pos)
+spl_remove_index(const char *utf8path, int pos)
{
List *list;
enum playlist_result result;
- if (!(list = loadStoredPlaylist(utf8path)))
+ if (!(list = spl_load(utf8path)))
return PLAYLIST_RESULT_NO_SUCH_LIST;
- if (removeOneSongFromStoredPlaylist(list, pos) != 0) {
+ if (spl_remove_index_internal(list, pos) != 0) {
freeList(list);
return PLAYLIST_RESULT_BAD_RANGE;
}
- result = writeStoredPlaylistToPath(list, utf8path);
+ result = spl_save(list, utf8path);
freeList(list);
@@ -274,7 +278,7 @@ removeOneSongFromStoredPlaylistByPath(const char *utf8path, int pos)
}
enum playlist_result
-appendSongToStoredPlaylistByPath(const char *utf8path, struct song *song)
+spl_append_song(const char *utf8path, struct song *song)
{
FILE *file;
struct stat st;
@@ -313,7 +317,7 @@ appendSongToStoredPlaylistByPath(const char *utf8path, struct song *song)
}
enum playlist_result
-renameStoredPlaylist(const char *utf8from, const char *utf8to)
+spl_rename(const char *utf8from, const char *utf8to)
{
struct stat st;
char from[MPD_PATH_MAX];
diff --git a/src/stored_playlist.h b/src/stored_playlist.h
index e0d204e23..4f02833f1 100644
--- a/src/stored_playlist.h
+++ b/src/stored_playlist.h
@@ -24,21 +24,22 @@
struct song;
-List *loadStoredPlaylist(const char *utf8path);
+List *
+spl_load(const char *utf8path);
enum playlist_result
-moveSongInStoredPlaylistByPath(const char *utf8path, int src, int dest);
+spl_move_index(const char *utf8path, int src, int dest);
enum playlist_result
-removeAllFromStoredPlaylistByPath(const char *utf8path);
+spl_clear(const char *utf8path);
enum playlist_result
-removeOneSongFromStoredPlaylistByPath(const char *utf8path, int pos);
+spl_remove_index(const char *utf8path, int pos);
enum playlist_result
-appendSongToStoredPlaylistByPath(const char *utf8path, struct song *song);
+spl_append_song(const char *utf8path, struct song *song);
enum playlist_result
-renameStoredPlaylist(const char *utf8from, const char *utf8to);
+spl_rename(const char *utf8from, const char *utf8to);
#endif