From dc1cc7e7e52960cceea5514397ec33f7ffc0dd6d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 30 Jan 2009 00:40:14 +0100 Subject: input_stream: let the implementation assign is->plugin This way, plugins can manipulate the plugin pointer during open(). --- src/input_archive.c | 1 + src/input_curl.c | 1 + src/input_file.c | 1 + src/input_stream.c | 8 +++++++- 4 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/input_archive.c b/src/input_archive.c index d687d9623..387ad465a 100644 --- a/src/input_archive.c +++ b/src/input_archive.c @@ -87,6 +87,7 @@ input_archive_open(struct input_stream *is, const char *pathname) is->plugin = &input_plugin_archive; //internal handle + is->plugin = &input_plugin_archive; is->data = arch_ctx; //open archive diff --git a/src/input_curl.c b/src/input_curl.c index fd28c480e..4956cf5c9 100644 --- a/src/input_curl.c +++ b/src/input_curl.c @@ -909,6 +909,7 @@ input_curl_open(struct input_stream *is, const char *url) c->buffers = g_queue_new(); c->rewind = g_queue_new(); + is->plugin = &input_plugin_curl; is->data = c; c->multi = curl_multi_init(); diff --git a/src/input_file.c b/src/input_file.c index 5eee8101c..1b6d82f9d 100644 --- a/src/input_file.c +++ b/src/input_file.c @@ -62,6 +62,7 @@ input_file_open(struct input_stream *is, const char *filename) posix_fadvise(fd, (off_t)0, is->size, POSIX_FADV_SEQUENTIAL); #endif + is->plugin = &input_plugin_file; is->data = GINT_TO_POINTER(fd); is->ready = true; diff --git a/src/input_stream.c b/src/input_stream.c index 234511e7f..b25f3bf40 100644 --- a/src/input_stream.c +++ b/src/input_stream.c @@ -80,7 +80,13 @@ input_stream_open(struct input_stream *is, const char *url) const struct input_plugin *plugin = input_plugins[i]; if (plugin->open(is, url)) { - is->plugin = plugin; + assert(is->plugin != NULL); + assert(is->plugin->open == NULL || + is->plugin == plugin); + assert(is->plugin->close != NULL); + assert(is->plugin->read != NULL); + assert(is->plugin->eof != NULL); + return true; } } -- cgit v1.2.3