aboutsummaryrefslogtreecommitdiffstats
path: root/src/input_file.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-26 20:38:44 +0100
committerMax Kellermann <max@duempel.org>2008-10-26 20:38:44 +0100
commitf08041f0eb8512304584b583073508629a934c88 (patch)
tree6a0d548ac1ee174b5505abe621fcb6f67afc688b /src/input_file.c
parentdbc7e9ba2f57c71a9b73cd6d035ba2906190be72 (diff)
downloadmpd-f08041f0eb8512304584b583073508629a934c88.tar.gz
mpd-f08041f0eb8512304584b583073508629a934c88.tar.xz
mpd-f08041f0eb8512304584b583073508629a934c88.zip
input_stream: added struct input_plugin
Instead of managing a set of method pointers in each input_stream struct, move these into the new input_plugin struct. Each input_stream has only a pointer to the plugin struct. Pointers to all implementations are kept in the array "input_plugins".
Diffstat (limited to 'src/input_file.c')
-rw-r--r--src/input_file.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/input_file.c b/src/input_file.c
index 6918a1d54..a176d55f2 100644
--- a/src/input_file.c
+++ b/src/input_file.c
@@ -21,30 +21,15 @@
#include "log.h"
#include "os_compat.h"
-static int
-input_file_seek(struct input_stream *is, long offset, int whence);
-
-static size_t
-input_file_read(struct input_stream *is, void *ptr, size_t size);
-
-static int
-input_file_close(struct input_stream *is);
-
-static int
-input_file_eof(struct input_stream *is);
-
-static int
-input_file_buffer(struct input_stream *is);
-
-int
-input_file_open(struct input_stream *is, char *filename)
+static bool
+input_file_open(struct input_stream *is, const char *filename)
{
FILE *fp;
fp = fopen(filename, "r");
if (!fp) {
is->error = errno;
- return -1;
+ return false;
}
is->seekable = 1;
@@ -58,15 +43,9 @@ input_file_open(struct input_stream *is, char *filename)
#endif
is->data = fp;
- is->seekFunc = input_file_seek;
- is->closeFunc = input_file_close;
- is->readFunc = input_file_read;
- is->atEOFFunc = input_file_eof;
- is->bufferFunc = input_file_buffer;
-
is->ready = 1;
- return 0;
+ return true;
}
static int
@@ -128,3 +107,12 @@ input_file_buffer(mpd_unused struct input_stream *is)
{
return 0;
}
+
+const struct input_plugin input_plugin_file = {
+ .open = input_file_open,
+ .close = input_file_close,
+ .buffer = input_file_buffer,
+ .read = input_file_read,
+ .eof = input_file_eof,
+ .seek = input_file_seek,
+};