aboutsummaryrefslogtreecommitdiffstats
path: root/src/directory.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-07 13:48:24 +0200
committerMax Kellermann <max@duempel.org>2008-09-07 13:48:24 +0200
commit528be8a0a9b8f9978b3968ab855e69a7ec2935d4 (patch)
treeb7374d05e21cd7966ef93fca41cf059f147ce7b1 /src/directory.c
parentd8ef33b71025decd52eaec5bb8417ad8e6dff873 (diff)
downloadmpd-528be8a0a9b8f9978b3968ab855e69a7ec2935d4.tar.gz
mpd-528be8a0a9b8f9978b3968ab855e69a7ec2935d4.tar.xz
mpd-528be8a0a9b8f9978b3968ab855e69a7ec2935d4.zip
directory: don't pass fd to traverseAllIn() callbacks
Database traversal should be generic, and not bound to a client connection. This is the first step: no file descriptor for the callback functions forEachSong() and forEachDir(). If a callback needs the file descriptor, it has to be passed in the void*data pointer somehow; some callbacks might need a new struct for passing more than one parameter. This might look a bit cumbersome right now, but our goal is to have a clean API.
Diffstat (limited to 'src/directory.c')
-rw-r--r--src/directory.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/directory.c b/src/directory.c
index 154547ce5..23c2d274f 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -1182,11 +1182,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;
@@ -1194,7 +1193,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;
}
@@ -1202,7 +1201,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)
@@ -1213,7 +1212,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;
}
@@ -1222,22 +1221,22 @@ static int traverseAllInSubDirectory(int fd, Directory * directory,
}
int traverseAllIn(int fd, const char *name,
- int (*forEachSong) (int, Song *, void *),
- int (*forEachDir) (int, Directory *, void *), void *data)
+ 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);
}