summaryrefslogtreecommitdiff
path: root/fitz/filt_copy.c
diff options
context:
space:
mode:
Diffstat (limited to 'fitz/filt_copy.c')
-rw-r--r--fitz/filt_copy.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/fitz/filt_copy.c b/fitz/filt_copy.c
new file mode 100644
index 00000000..f6a00ec0
--- /dev/null
+++ b/fitz/filt_copy.c
@@ -0,0 +1,50 @@
+#include "fitz_base.h"
+#include "fitz_stream.h"
+
+typedef struct fz_copyfilter_s fz_copyfilter;
+
+struct fz_copyfilter_s
+{
+ fz_filter super;
+};
+
+fz_error
+fz_newcopyfilter(fz_filter **fp)
+{
+ FZ_NEWFILTER(fz_copyfilter, f, copyfilter);
+ return fz_okay;
+}
+
+void
+fz_dropcopyfilter(fz_filter *f)
+{
+}
+
+fz_error
+fz_processcopyfilter(fz_filter *filter, fz_buffer *in, fz_buffer *out)
+{
+ fz_copyfilter *f = (fz_copyfilter*)filter;
+ int n;
+
+ while (1)
+ {
+ if (in->rp + 1 > in->wp)
+ {
+ if (in->eof)
+ return fz_iodone;
+ return fz_ioneedin;
+ }
+
+ if (out->wp + 1 > out->ep)
+ return fz_ioneedout;
+
+ n = MIN(in->wp - in->rp, out->ep - out->wp);
+ if (n)
+ {
+ memcpy(out->wp, in->rp, n);
+ in->rp += n;
+ out->wp += n;
+ }
+ }
+}
+