diff options
-rw-r--r-- | src/dbUtils.c | 15 | ||||
-rw-r--r-- | src/playlist.c | 4 | ||||
-rw-r--r-- | src/song.c | 20 | ||||
-rw-r--r-- | src/song.h | 4 | ||||
-rw-r--r-- | src/songvec.c | 4 |
5 files changed, 23 insertions, 24 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c index 4cb3edcca..ff5f1883e 100644 --- a/src/dbUtils.c +++ b/src/dbUtils.c @@ -64,10 +64,9 @@ static int printDirectoryInDirectory(Directory * directory, void *data) return 0; } -static int printSongInDirectory(Song * song, mpd_unused void *data) +static int printSongInDirectory(Song * song, void *data) { - int fd = (int)(size_t)data; - printSongUrl(fd, song); + song_print_url(song, (int)(size_t)data); return 0; } @@ -83,7 +82,7 @@ static int searchInDirectory(Song * song, void *_data) LocateTagItemArray *array = &data->array; if (strstrSearchTags(song, array->numItems, array->items)) - printSongInfo(fd, song); + song_print_info(song, fd); return 0; } @@ -125,7 +124,7 @@ static int findInDirectory(Song * song, void *_data) LocateTagItemArray *array = &data->array; if (tagItemsFoundAndMatches(song, array->numItems, array->items)) - printSongInfo(fd, song); + song_print_info(song, fd); return 0; } @@ -220,9 +219,9 @@ int addAllInToStoredPlaylist(const char *name, const char *utf8file) static int directoryPrintSongInfo(Song * song, void *data) { - int fd = (int)(size_t)data; + song_print_info(song, (int)(size_t)data); - return printSongInfo(fd, song); + return 0; } static int sumSongTime(Song * song, void *data) @@ -285,7 +284,7 @@ static void visitTag(int fd, struct strset *set, struct mpd_tag *tag = song->tag; if (tagType == LOCATE_TAG_FILE_TYPE) { - printSongUrl(fd, song); + song_print_url(song, fd); return; } diff --git a/src/playlist.c b/src/playlist.c index 6207ca985..696636993 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -360,7 +360,7 @@ void readPlaylistState(FILE *fp) static void printPlaylistSongInfo(int fd, int song) { - printSongInfo(fd, playlist.songs[song]); + song_print_info(playlist.songs[song], fd); fdprintf(fd, "Pos: %i\nId: %i\n", song, playlist.positionToId[song]); } @@ -1363,7 +1363,7 @@ int PlaylistInfo(int fd, const char *utf8file, int detail) if (detail) { Song *song = getSongFromDB(temp); if (song) { - printSongInfo(fd, song); + song_print_info(song, fd); wrote = 1; } } diff --git a/src/song.c b/src/song.c index 27f48ad03..61fe78a43 100644 --- a/src/song.c +++ b/src/song.c @@ -92,24 +92,24 @@ void freeJustSong(Song * song) free(song); } -void printSongUrl(int fd, Song * song) +ssize_t song_print_url(Song *song, int fd) { - if (song->parentDir && song->parentDir->path) { - fdprintf(fd, "%s%s/%s\n", SONG_FILE, - getDirectoryPath(song->parentDir), song->url); - } else { - fdprintf(fd, "%s%s\n", SONG_FILE, song->url); - } + if (song->parentDir && song->parentDir->path) + return fdprintf(fd, "%s%s/%s\n", SONG_FILE, + getDirectoryPath(song->parentDir), song->url); + return fdprintf(fd, "%s%s\n", SONG_FILE, song->url); } -int printSongInfo(int fd, Song * song) +ssize_t song_print_info(Song *song, int fd) { - printSongUrl(fd, song); + ssize_t ret = song_print_url(song, fd); + if (ret < 0) + return ret; if (song->tag) tag_print(fd, song->tag); - return 0; + return ret; } static void insertSongIntoList(struct songvec *sv, Song *newsong) diff --git a/src/song.h b/src/song.h index 377a78814..3419cd43e 100644 --- a/src/song.h +++ b/src/song.h @@ -46,13 +46,13 @@ void freeSong(Song *); void freeJustSong(Song *); -int printSongInfo(int fd, Song * song); +ssize_t song_print_info(Song * song, int fd); void readSongInfoIntoList(FILE * fp, struct _Directory *parent); int updateSongInfo(Song * song); -void printSongUrl(int fd, Song * song); +ssize_t song_print_url(Song * song, int fd); /* * get_song_url - Returns a path of a song in UTF8-encoded form diff --git a/src/songvec.c b/src/songvec.c index 579ac7033..969e67220 100644 --- a/src/songvec.c +++ b/src/songvec.c @@ -81,7 +81,7 @@ int songvec_write(struct songvec *sv, int fd, int extra) Song *song = *sp++; if (fdprintf(fd, SONG_KEY "%s\n", song->url) < 0) return -1; - if (printSongInfo(fd, song) < 0) + if (song_print_info(song, fd) < 0) return -1; if (fdprintf(fd, SONG_MTIME "%li\n", (long)song->mtime) < 0) @@ -92,7 +92,7 @@ int songvec_write(struct songvec *sv, int fd, int extra) return -1; } else { for (i = sv->nr; --i >= 0;) - if (printSongInfo(fd, *sp++) < 0) + if (song_print_info(*sp++, fd) < 0) return -1; } |