aboutsummaryrefslogtreecommitdiff
path: root/src/input_stream.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-30 23:27:37 +0100
committerMax Kellermann <max@duempel.org>2010-01-01 17:25:07 +0100
commitd3b763a48c09a60a0c0b5ccb6cccd9376875c470 (patch)
tree83b8794f78ef8941806cf5757888d8abf2eaa126 /src/input_stream.h
parent816b6ad4a71c3ade95e62b62396f2b0415c03f20 (diff)
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).
Diffstat (limited to 'src/input_stream.h')
-rw-r--r--src/input_stream.h27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/input_stream.h b/src/input_stream.h
index 069a9f58..e48f7eb2 100644
--- a/src/input_stream.h
+++ b/src/input_stream.h
@@ -39,11 +39,6 @@ struct input_stream {
const struct input_plugin *plugin;
/**
- * an opaque pointer managed by the plugin
- */
- void *data;
-
- /**
* indicates whether the stream is ready for reading and
* whether the other attributes in this struct are valid
*/
@@ -70,20 +65,28 @@ struct input_stream {
char *mime;
};
+static inline void
+input_stream_init(struct input_stream *is, const struct input_plugin *plugin)
+{
+ is->plugin = plugin;
+ is->ready = false;
+ is->seekable = false;
+ is->size = -1;
+ is->offset = 0;
+ is->mime = NULL;
+}
+
/**
* Opens a new input stream. You may not access it until the "ready"
* flag is set.
*
- * @param is the input_stream object allocated by the caller
- * @return true on success
+ * @return an #input_stream object on success, NULL on error
*/
-bool
-input_stream_open(struct input_stream *is, const char *url, GError **error_r);
+struct input_stream *
+input_stream_open(const char *uri, GError **error_r);
/**
- * Closes the input stream and free resources. This does not free the
- * input_stream pointer itself, because it is assumed to be allocated
- * by the caller.
+ * Close the input stream and free resources.
*/
void
input_stream_close(struct input_stream *is);