aboutsummaryrefslogtreecommitdiffstats
path: root/src/archive/zip_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/zip_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/zip_plugin.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/archive/zip_plugin.c b/src/archive/zip_plugin.c
index d318adc06..9df449ab5 100644
--- a/src/archive/zip_plugin.c
+++ b/src/archive/zip_plugin.c
@@ -103,24 +103,19 @@ zip_close(struct archive_file *file)
/* single archive handling */
-static void
-zip_setup_stream(struct archive_file *file, struct input_stream *is)
+static bool
+zip_open_stream(struct archive_file *file, struct input_stream *is,
+ const char *pathname)
{
zip_context *context = (zip_context *) file;
+ ZZIP_STAT z_stat;
+
//setup file ops
is->plugin = &zip_inputplugin;
//insert back reference
- is->archive = context;
+ is->data = context;
//we are seekable (but its not recommendent to do so)
is->seekable = true;
-}
-
-
-static bool
-zip_is_open(struct input_stream *is, const char *pathname)
-{
- zip_context *context = (zip_context *) is->archive;
- ZZIP_STAT z_stat;
context->file = zzip_file_open(context->dir, pathname, 0);
if (!context->file) {
@@ -135,14 +130,14 @@ zip_is_open(struct input_stream *is, const char *pathname)
static void
zip_is_close(struct input_stream *is)
{
- zip_context *context = (zip_context *) is->archive;
+ zip_context *context = (zip_context *) is->data;
zzip_file_close (context->file);
}
static size_t
zip_is_read(struct input_stream *is, void *ptr, size_t size)
{
- zip_context *context = (zip_context *) is->archive;
+ zip_context *context = (zip_context *) is->data;
int ret;
ret = zzip_file_read(context->file, ptr, size);
if (ret < 0) {
@@ -155,7 +150,7 @@ zip_is_read(struct input_stream *is, void *ptr, size_t size)
static bool
zip_is_eof(struct input_stream *is)
{
- zip_context *context = (zip_context *) is->archive;
+ zip_context *context = (zip_context *) is->data;
return ((size_t) zzip_tell(context->file) == context->length);
}
@@ -163,7 +158,7 @@ static bool
zip_is_seek(G_GNUC_UNUSED struct input_stream *is,
G_GNUC_UNUSED off_t offset, G_GNUC_UNUSED int whence)
{
- zip_context *context = (zip_context *) is->archive;
+ zip_context *context = (zip_context *) is->data;
zzip_off_t ofs = zzip_seek(context->file, offset, whence);
if (ofs != -1) {
is->offset = ofs;
@@ -186,7 +181,6 @@ static const char *const zip_extensions[] = {
};
static const struct input_plugin zip_inputplugin = {
- .open = zip_is_open,
.close = zip_is_close,
.read = zip_is_read,
.eof = zip_is_eof,
@@ -199,7 +193,7 @@ const struct archive_plugin zip_plugin = {
.open = zip_open,
.scan_reset = zip_scan_reset,
.scan_next = zip_scan_next,
- .setup_stream = zip_setup_stream,
+ .open_stream = zip_open_stream,
.close = zip_close,
.suffixes = zip_extensions
};