summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--encoder.c15
-rw-r--r--encoder.h29
2 files changed, 44 insertions, 0 deletions
diff --git a/encoder.c b/encoder.c
new file mode 100644
index 0000000..72bca9d
--- /dev/null
+++ b/encoder.c
@@ -0,0 +1,15 @@
+#include "encoder.h"
+
+gboolean encoder_init(struct encoder *encoder) {
+ return encoder->encoder->init(&encoder->data);
+}
+
+gssize encoder_encode(struct encoder *encoder, const guchar *inbuf, gsize inbuf_size,
+ guchar *outbuf, gsize outbuf_size) {
+ return encoder->encoder->encode(encoder->data, inbuf, inbuf_size,
+ outbuf, outbuf_size);
+}
+
+void encoder_close(struct encoder *encoder) {
+ encoder->encoder->close(encoder->data);
+}
diff --git a/encoder.h b/encoder.h
new file mode 100644
index 0000000..e55dfb0
--- /dev/null
+++ b/encoder.h
@@ -0,0 +1,29 @@
+#ifndef _ENCODER_H_
+#define _ENCODER_H_
+
+#include <glib.h>
+#include <gio/gio.h>
+
+struct encoder_plugin {
+ const gchar *name;
+
+ gboolean (*init)(gpointer *data);
+ gssize (*encode)(gpointer data, const guchar *inbuf, gsize inbuf_size,
+ guchar *outbuf, gsize outbuf_size);
+ void (*close)(gpointer data);
+};
+
+struct encoder {
+ const struct encoder_plugin *encoder;
+
+ gpointer data;
+};
+
+extern struct encoder_plugin *encoder_plugniss;
+
+gboolean encoder_init(struct encoder *encoder);
+gssize encoder_encode(struct encoder *encoder, const guchar *inbuf, gsize inbuf_size,
+ guchar *outbuf, gsize outbuf_size);
+void encoder_close(struct encoder *encoder);
+
+#endif