From 32d6d4499e315a5a2f224beaa54faad03ff80a16 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 30 Jan 2009 00:58:03 +0100 Subject: input_stream: make seek(), buffer() optional Make those two methods optional to implement, and let input_stream.c provide fallbacks. The buffer() method will be removed one day, and there is now only one implementation left (input_curl.c). --- src/input_stream.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/input_stream.c') diff --git a/src/input_stream.c b/src/input_stream.c index b25f3bf40..4375db948 100644 --- a/src/input_stream.c +++ b/src/input_stream.c @@ -86,6 +86,7 @@ input_stream_open(struct input_stream *is, const char *url) assert(is->plugin->close != NULL); assert(is->plugin->read != NULL); assert(is->plugin->eof != NULL); + assert(!is->seekable || is->plugin->seek != NULL); return true; } @@ -97,6 +98,9 @@ input_stream_open(struct input_stream *is, const char *url) bool input_stream_seek(struct input_stream *is, off_t offset, int whence) { + if (is->plugin->seek == NULL) + return false; + return is->plugin->seek(is, offset, whence); } @@ -133,5 +137,8 @@ bool input_stream_eof(struct input_stream *is) int input_stream_buffer(struct input_stream *is) { + if (is->plugin->buffer == NULL) + return 0; + return is->plugin->buffer(is); } -- cgit v1.2.3