aboutsummaryrefslogtreecommitdiff
path: root/src/archive
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-16 16:28:26 +0100
committerMax Kellermann <max@duempel.org>2009-12-16 17:09:58 +0100
commit0bc8c0c1da4490aad502dddbbc7c60564c4083a7 (patch)
tree3a7b9ed55fbbdb757e4822e7ea262237d0562dbc /src/archive
parent74156d5bed810209a777ba6ade7ef279691f3091 (diff)
archive_plugin: wrap method calls
Make archive_file a "real" struct, extended by all plugins. Add the plugin pointer to it. Wrap all method calls in functions.
Diffstat (limited to 'src/archive')
-rw-r--r--src/archive/bz2_archive_plugin.c5
-rw-r--r--src/archive/iso9660_archive_plugin.c6
-rw-r--r--src/archive/zzip_archive_plugin.c6
3 files changed, 14 insertions, 3 deletions
diff --git a/src/archive/bz2_archive_plugin.c b/src/archive/bz2_archive_plugin.c
index 766c558e..e8e5c556 100644
--- a/src/archive/bz2_archive_plugin.c
+++ b/src/archive/bz2_archive_plugin.c
@@ -40,6 +40,8 @@
#define BZ_BUFSIZE 5000
struct bz2_archive_file {
+ struct archive_file base;
+
char *name;
bool reset;
struct input_stream istream;
@@ -102,6 +104,7 @@ bz2_open(const char *pathname)
int len;
context = g_malloc(sizeof(*context));
+ archive_file_init(&context->base, &bz2_archive_plugin);
//open archive
if (!input_stream_open(&context->istream, pathname, NULL)) {
@@ -118,7 +121,7 @@ bz2_open(const char *pathname)
context->name[len - 4] = 0; //remove .bz2 suffix
}
- return (struct archive_file *) context;
+ return &context->base;
}
static void
diff --git a/src/archive/iso9660_archive_plugin.c b/src/archive/iso9660_archive_plugin.c
index 0c21d512..ccab9e61 100644
--- a/src/archive/iso9660_archive_plugin.c
+++ b/src/archive/iso9660_archive_plugin.c
@@ -35,6 +35,8 @@
#define CEILING(x, y) ((x+(y-1))/y)
struct iso9660_archive_file {
+ struct archive_file base;
+
iso9660_t *iso;
iso9660_stat_t *statbuf;
size_t cur_ofs;
@@ -93,6 +95,8 @@ iso9660_archive_open(const char *pathname)
struct iso9660_archive_file *context =
g_new(struct iso9660_archive_file, 1);
+ archive_file_init(&context->base, &iso9660_archive_plugin);
+
context->list = NULL;
/* open archive */
@@ -104,7 +108,7 @@ iso9660_archive_open(const char *pathname)
listdir_recur("/", context);
- return (struct archive_file *)context;
+ return &context->base;
}
static void
diff --git a/src/archive/zzip_archive_plugin.c b/src/archive/zzip_archive_plugin.c
index ba89e82b..1174629a 100644
--- a/src/archive/zzip_archive_plugin.c
+++ b/src/archive/zzip_archive_plugin.c
@@ -32,6 +32,8 @@
#include <string.h>
struct zzip_archive {
+ struct archive_file base;
+
ZZIP_DIR *dir;
ZZIP_FILE *file;
size_t length;
@@ -55,6 +57,8 @@ zzip_archive_open(const char *pathname)
struct zzip_archive *context = g_malloc(sizeof(*context));
ZZIP_DIRENT dirent;
+ archive_file_init(&context->base, &zzip_archive_plugin);
+
// open archive
context->list = NULL;
context->dir = zzip_dir_open(pathname, NULL);
@@ -71,7 +75,7 @@ zzip_archive_open(const char *pathname)
}
}
- return (struct archive_file *)context;
+ return &context->base;
}
static void