diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-09-12 02:17:13 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-09-12 02:17:13 -0700 |
commit | 12d4956528b7abd34aa5d827a2f088f6eb45df98 (patch) | |
tree | 83c070df37f8d03e562ea9ad0b9274e0d4082351 /src/directory.c | |
parent | 1b6315e8f6372e7abe1a3eb08b27b2f331aa2728 (diff) | |
parent | cb0253d02dc1d51bc84c65d8c7362c8a18c116f2 (diff) | |
download | mpd-12d4956528b7abd34aa5d827a2f088f6eb45df98.tar.gz mpd-12d4956528b7abd34aa5d827a2f088f6eb45df98.tar.xz mpd-12d4956528b7abd34aa5d827a2f088f6eb45df98.zip |
Merge branch 'mk/client-merge'
* mk/client-merge: (49 commits)
client: shorten names of the struct client variables
client: simplified client_read()
client: client_input_received() returns 0
client: check for COMMAND_RETURN_CLOSE
client: renamed local variable "selret" to "ret"
client: moved CLOSE/KILL check after client_process_line()
client: don't check FD_ISSET(client->fd) on expired client
client: removed assert(client->fd)>=0
fix -Wcast-qual -Wwrite-strings warnings
playlist: return -1 after assert(0)
command: concatenate strings at compile time
audio: don't pass "fd" to {en,dis}ableAudioDevice()
volume: don't pass "fd" to changeVolumeLevel()
directory: printDirectoryInfo() does not call commandError()
directory: don't pass fd to traverseAllIn()
directory: don't pass fd to traverseAllIn() callbacks
playlist: PlaylistInfo() does not call commandError()
playlist: don't pass "fd" to storedPlaylist.c functions
playlist: don't pass "fd" to playlist.c functions
playlist: showPlaylist() and shufflePlaylist() cannot fail
...
Diffstat (limited to 'src/directory.c')
-rw-r--r-- | src/directory.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/src/directory.c b/src/directory.c index 33a862ddd..2175c54a0 100644 --- a/src/directory.c +++ b/src/directory.c @@ -20,7 +20,7 @@ #include "command.h" #include "conf.h" -#include "interface.h" +#include "client.h" #include "listen.h" #include "log.h" #include "ls.h" @@ -177,7 +177,7 @@ int updateInit(int fd, List * pathList) finishSigHandlers(); closeAllListenSockets(); - freeAllInterfaces(); + client_manager_deinit(); finishPlaylist(); finishVolume(); @@ -848,10 +848,8 @@ int printDirectoryInfo(int fd, const char *name) { Directory *directory; - if ((directory = getDirectory(name)) == NULL) { - commandError(fd, ACK_ERROR_NO_EXIST, "directory not found"); + if ((directory = getDirectory(name)) == NULL) return -1; - } printDirectoryList(fd, directory->subDirectories); printSongInfoFromList(fd, directory->songs); @@ -1153,8 +1151,8 @@ int readDirectoryDB(void) readDirectoryInfo(fp, mp3rootDirectory); while (fclose(fp) && errno == EINTR) ; - stats.numberOfSongs = countSongsIn(STDERR_FILENO, NULL); - stats.dbPlayTime = sumSongTimesIn(STDERR_FILENO, NULL); + stats.numberOfSongs = countSongsIn(NULL); + stats.dbPlayTime = sumSongTimesIn(NULL); if (stat(dbFile, &st) == 0) directory_dbModTime = st.st_mtime; @@ -1180,11 +1178,10 @@ void updateMp3Directory(void) return; } -static int traverseAllInSubDirectory(int fd, Directory * directory, - int (*forEachSong) (int, Song *, - void *), - int (*forEachDir) (int, Directory *, - void *), void *data) +static int traverseAllInSubDirectory(Directory * directory, + int (*forEachSong) (Song *, void *), + int (*forEachDir) (Directory *, void *), + void *data) { ListNode *node = directory->songs->firstNode; Song *song; @@ -1192,7 +1189,7 @@ static int traverseAllInSubDirectory(int fd, Directory * directory, int errFlag = 0; if (forEachDir) { - errFlag = forEachDir(fd, directory, data); + errFlag = forEachDir(directory, data); if (errFlag) return errFlag; } @@ -1200,7 +1197,7 @@ static int traverseAllInSubDirectory(int fd, Directory * directory, if (forEachSong) { while (node != NULL && !errFlag) { song = (Song *) node->data; - errFlag = forEachSong(fd, song, data); + errFlag = forEachSong(song, data); node = node->nextNode; } if (errFlag) @@ -1211,7 +1208,7 @@ static int traverseAllInSubDirectory(int fd, Directory * directory, while (node != NULL && !errFlag) { dir = (Directory *) node->data; - errFlag = traverseAllInSubDirectory(fd, dir, forEachSong, + errFlag = traverseAllInSubDirectory(dir, forEachSong, forEachDir, data); node = node->nextNode; } @@ -1219,23 +1216,21 @@ static int traverseAllInSubDirectory(int fd, Directory * directory, return errFlag; } -int traverseAllIn(int fd, char *name, - int (*forEachSong) (int, Song *, void *), - int (*forEachDir) (int, Directory *, void *), void *data) +int traverseAllIn(const char *name, + int (*forEachSong) (Song *, void *), + int (*forEachDir) (Directory *, void *), void *data) { Directory *directory; if ((directory = getDirectory(name)) == NULL) { Song *song; if ((song = getSongFromDB(name)) && forEachSong) { - return forEachSong(fd, song, data); + return forEachSong(song, data); } - commandError(fd, ACK_ERROR_NO_EXIST, - "directory or file not found"); return -1; } - return traverseAllInSubDirectory(fd, directory, forEachSong, forEachDir, + return traverseAllInSubDirectory(directory, forEachSong, forEachDir, data); } @@ -1256,8 +1251,8 @@ void initMp3Directory(void) mp3rootDirectory = newDirectory(NULL, NULL); exploreDirectory(mp3rootDirectory); freeAllDirectoryStats(mp3rootDirectory); - stats.numberOfSongs = countSongsIn(STDERR_FILENO, NULL); - stats.dbPlayTime = sumSongTimesIn(STDERR_FILENO, NULL); + stats.numberOfSongs = countSongsIn(NULL); + stats.dbPlayTime = sumSongTimesIn(NULL); } static Song *getSongDetails(const char *file, const char **shortnameRet, @@ -1303,7 +1298,7 @@ static Song *getSongDetails(const char *file, const char **shortnameRet, return (Song *) song; } -Song *getSongFromDB(char *file) +Song *getSongFromDB(const char *file) { return getSongDetails(file, NULL, NULL); } |