aboutsummaryrefslogtreecommitdiffstats
path: root/src/dbUtils.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-07 13:48:37 +0200
committerMax Kellermann <max@duempel.org>2008-09-07 13:48:37 +0200
commitf320c9fa1dc2268fbd97ba9cb00140276c0a2e23 (patch)
treebd4102bc4a1d6914777305bf73690f3a8c5c7fa0 /src/dbUtils.c
parent528be8a0a9b8f9978b3968ab855e69a7ec2935d4 (diff)
downloadmpd-f320c9fa1dc2268fbd97ba9cb00140276c0a2e23.tar.gz
mpd-f320c9fa1dc2268fbd97ba9cb00140276c0a2e23.tar.xz
mpd-f320c9fa1dc2268fbd97ba9cb00140276c0a2e23.zip
directory: don't pass fd to traverseAllIn()
This patch continues the work of the previous patch: don't pass a file descriptor at all to traverseAllIn(). Since this fd was only used to report "directory not found" errors, we can easily move that check to the caller. This is a great relief, since it removes the dependency on a client connection from a lot of enumeration functions.
Diffstat (limited to '')
-rw-r--r--src/dbUtils.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c
index a1d7014ee..4aebaed4b 100644
--- a/src/dbUtils.c
+++ b/src/dbUtils.c
@@ -107,7 +107,7 @@ int searchForSongsIn(int fd, const char *name, int numItems,
data.array.numItems = numItems;
data.array.items = items;
- ret = traverseAllIn(fd, name, searchInDirectory, NULL, &data);
+ ret = traverseAllIn(name, searchInDirectory, NULL, &data);
for (i = 0; i < numItems; i++) {
free(items[i].needle);
@@ -139,7 +139,7 @@ int findSongsIn(int fd, const char *name, int numItems, LocateTagItem * items)
data.array.numItems = numItems;
data.array.items = items;
- return traverseAllIn(fd, name, findInDirectory, NULL, &data);
+ return traverseAllIn(name, findInDirectory, NULL, &data);
}
static void printSearchStats(int fd, SearchStats *stats)
@@ -173,7 +173,7 @@ int searchStatsForSongsIn(int fd, const char *name, int numItems,
stats.numberOfSongs = 0;
stats.playTime = 0;
- ret = traverseAllIn(fd, name, searchStatsInDirectory, NULL, &stats);
+ ret = traverseAllIn(name, searchStatsInDirectory, NULL, &stats);
if (ret == 0)
printSearchStats(fd, &stats);
@@ -182,7 +182,7 @@ int searchStatsForSongsIn(int fd, const char *name, int numItems,
int printAllIn(int fd, const char *name)
{
- return traverseAllIn(fd, name, printSongInDirectory,
+ return traverseAllIn(name, printSongInDirectory,
printDirectoryInDirectory, (void*)(size_t)fd);
}
@@ -204,18 +204,18 @@ static int directoryAddSongToStoredPlaylist(Song *song, void *_data)
return 0;
}
-int addAllIn(int fd, const char *name)
+int addAllIn(const char *name)
{
- return traverseAllIn(fd, name, directoryAddSongToPlaylist, NULL, NULL);
+ return traverseAllIn(name, directoryAddSongToPlaylist, NULL, NULL);
}
-int addAllInToStoredPlaylist(int fd, const char *name, const char *utf8file)
+int addAllInToStoredPlaylist(const char *name, const char *utf8file)
{
struct add_data data = {
.path = utf8file,
};
- return traverseAllIn(fd, name, directoryAddSongToStoredPlaylist, NULL,
+ return traverseAllIn(name, directoryAddSongToStoredPlaylist, NULL,
&data);
}
@@ -238,26 +238,26 @@ static int sumSongTime(Song * song, void *data)
int printInfoForAllIn(int fd, const char *name)
{
- return traverseAllIn(fd, name, directoryPrintSongInfo,
+ return traverseAllIn(name, directoryPrintSongInfo,
printDirectoryInDirectory, (void*)(size_t)fd);
}
-int countSongsIn(int fd, const char *name)
+int countSongsIn(const char *name)
{
int count = 0;
void *ptr = (void *)&count;
- traverseAllIn(fd, name, NULL, countSongsInDirectory, ptr);
+ traverseAllIn(name, NULL, countSongsInDirectory, ptr);
return count;
}
-unsigned long sumSongTimesIn(int fd, const char *name)
+unsigned long sumSongTimesIn(const char *name)
{
unsigned long dbPlayTime = 0;
void *ptr = (void *)&dbPlayTime;
- traverseAllIn(fd, name, sumSongTime, NULL, ptr);
+ traverseAllIn(name, sumSongTime, NULL, ptr);
return dbPlayTime;
}
@@ -332,7 +332,7 @@ int listAllUniqueTags(int fd, int type, int numConditionals,
resetVisitedFlagsInTagTracker(type);
}
- ret = traverseAllIn(fd, NULL, listUniqueTagsInDirectory, NULL,
+ ret = traverseAllIn(NULL, listUniqueTagsInDirectory, NULL,
&data);
if (type >= 0 && type <= TAG_NUM_OF_ITEM_TYPES) {
@@ -370,7 +370,7 @@ void printSavedMemoryFromFilenames(void)
{
int sum = 0;
- traverseAllIn(STDERR_FILENO, NULL, sumSavedFilenameMemoryInSong,
+ traverseAllIn(NULL, sumSavedFilenameMemoryInSong,
sumSavedFilenameMemoryInDirectory, (void *)&sum);
DEBUG("saved memory from filenames: %i\n", sum);