From d3b763a48c09a60a0c0b5ccb6cccd9376875c470 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 30 Dec 2009 23:27:37 +0100 Subject: input_stream: return allocated input_stream objects Major API redesign: don't let the caller allocate the input_stream object. Let each input plugin allocate its own (derived/extended) input_stream pointer. The "data" attribute can now be removed, and all input plugins simply cast the input_stream pointer to their own structure (with an "struct input_stream base" as the first attribute). --- src/input/archive_input_plugin.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/input/archive_input_plugin.c') diff --git a/src/input/archive_input_plugin.c b/src/input/archive_input_plugin.c index 9e3e79692..97e4836ff 100644 --- a/src/input/archive_input_plugin.c +++ b/src/input/archive_input_plugin.c @@ -33,24 +33,23 @@ * parent_stream so tar plugin fetches file data from gzip * plugin and gzip fetches file from disk */ -static bool -input_archive_open(struct input_stream *is, const char *pathname, - GError **error_r) +static struct input_stream * +input_archive_open(const char *pathname, GError **error_r) { const struct archive_plugin *arplug; struct archive_file *file; char *archive, *filename, *suffix, *pname; - bool opened; + struct input_stream *is; if (!g_path_is_absolute(pathname)) - return false; + return NULL; pname = g_strdup(pathname); // archive_lookup will modify pname when true is returned if (!archive_lookup(pname, &archive, &filename, &suffix)) { g_debug("not an archive, lookup %s failed\n", pname); g_free(pname); - return false; + return NULL; } //check which archive plugin to use (by ext) @@ -58,19 +57,19 @@ input_archive_open(struct input_stream *is, const char *pathname, if (!arplug) { g_warning("can't handle archive %s\n",archive); g_free(pname); - return false; + return NULL; } file = archive_file_open(arplug, archive, error_r); if (file == NULL) - return false; + return NULL; //setup fileops - opened = archive_file_open_stream(file, is, filename, error_r); + is = archive_file_open_stream(file, filename, error_r); archive_file_close(file); g_free(pname); - return opened; + return is; } const struct input_plugin input_plugin_archive = { -- cgit v1.2.3