aboutsummaryrefslogtreecommitdiffstats
path: root/src/archive/bz2_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-30 00:53:32 +0100
committerMax Kellermann <max@duempel.org>2009-01-30 00:53:32 +0100
commit82cfce76eb5787f1a24151f6a3840a999ed82659 (patch)
tree05c8ee19ff9bd9cc69e6f50c1aeeacc77efbde44 /src/archive/bz2_plugin.c
parentdc1cc7e7e52960cceea5514397ec33f7ffc0dd6d (diff)
downloadmpd-82cfce76eb5787f1a24151f6a3840a999ed82659.tar.gz
mpd-82cfce76eb5787f1a24151f6a3840a999ed82659.tar.xz
mpd-82cfce76eb5787f1a24151f6a3840a999ed82659.zip
archive: replaced setup_stream() with open_stream()
The open_stream() method opens the input_stream. This allows the archive plugin to do its own initialization, and it also allows it to use input_stream.data. We can remove input_stream.archive now, which was unnatural to have in the first place.
Diffstat (limited to '')
-rw-r--r--src/archive/bz2_plugin.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/archive/bz2_plugin.c b/src/archive/bz2_plugin.c
index b63a9ddfc..6067d2acc 100644
--- a/src/archive/bz2_plugin.c
+++ b/src/archive/bz2_plugin.c
@@ -148,22 +148,16 @@ bz2_close(struct archive_file *file)
/* single archive handling */
-static void
-bz2_setup_stream(struct archive_file *file, struct input_stream *is)
+static bool
+bz2_open_stream(struct archive_file *file, struct input_stream *is,
+ G_GNUC_UNUSED const char *path)
{
bz2_context *context = (bz2_context *) file;
//setup file ops
is->plugin = &bz2_inputplugin;
//insert back reference
- is->archive = context;
+ is->data = context;
is->seekable = false;
-}
-
-
-static bool
-bz2_is_open(struct input_stream *is, G_GNUC_UNUSED const char *url)
-{
- bz2_context *context = (bz2_context *) is->archive;
if (!bz2_alloc(context)) {
g_warning("alloc bz2 failed\n");
@@ -175,7 +169,7 @@ bz2_is_open(struct input_stream *is, G_GNUC_UNUSED const char *url)
static void
bz2_is_close(struct input_stream *is)
{
- bz2_context *context = (bz2_context *) is->archive;
+ bz2_context *context = (bz2_context *) is->data;
bz2_destroy(context);
is->data = NULL;
}
@@ -211,7 +205,7 @@ bz2_fillbuffer(bz2_context *context,
static size_t
bz2_is_read(struct input_stream *is, void *ptr, size_t size)
{
- bz2_context *context = (bz2_context *) is->archive;
+ bz2_context *context = (bz2_context *) is->data;
bz_stream *bzstream;
int bz_result;
size_t numBytes = size;
@@ -253,7 +247,7 @@ bz2_is_read(struct input_stream *is, void *ptr, size_t size)
static bool
bz2_is_eof(struct input_stream *is)
{
- bz2_context *context = (bz2_context *) is->archive;
+ bz2_context *context = (bz2_context *) is->data;
if (context->last_bz_result == BZ_STREAM_END) {
return true;
@@ -283,7 +277,6 @@ static const char *const bz2_extensions[] = {
};
static const struct input_plugin bz2_inputplugin = {
- .open = bz2_is_open,
.close = bz2_is_close,
.read = bz2_is_read,
.eof = bz2_is_eof,
@@ -296,7 +289,7 @@ const struct archive_plugin bz2_plugin = {
.open = bz2_open,
.scan_reset = bz2_scan_reset,
.scan_next = bz2_scan_next,
- .setup_stream = bz2_setup_stream,
+ .open_stream = bz2_open_stream,
.close = bz2_close,
.suffixes = bz2_extensions
};