input_stream: let the implementation assign is->plugin

This way, plugins can manipulate the plugin pointer during open().
This commit is contained in:
Max Kellermann 2009-01-30 00:40:14 +01:00
parent 297101c3f8
commit dc1cc7e7e5
4 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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();

View File

@ -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;

View File

@ -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;
}
}