diff options
author | Tor Andersson <tor@ghostscript.com> | 2004-09-27 02:15:04 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2004-09-27 02:15:04 +0200 |
commit | 6ddde92a3a45e970b05770633dc6a337d5d013c5 (patch) | |
tree | 1dec4612d7469839478e72d16d30a0da5755243c /filter/filter.c | |
download | mupdf-6ddde92a3a45e970b05770633dc6a337d5d013c5.tar.xz |
Initial import
Diffstat (limited to 'filter/filter.c')
-rw-r--r-- | filter/filter.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/filter/filter.c b/filter/filter.c new file mode 100644 index 00000000..8e28a532 --- /dev/null +++ b/filter/filter.c @@ -0,0 +1,59 @@ +#include <fitz.h> + +fz_error fz_kioneedin = { + .msg = {"<ioneedin>"}, + .func = {"<process>"}, + .file = {"filter.c"}, + .line = 0, + .frozen = 1 +}; + +fz_error fz_kioneedout = { + .msg = {"<ioneedout>"}, + .func = {"<process>"}, + .file = {"filter.c"}, + .line = 0, + .frozen = 1 +}; + +fz_error fz_kiodone = { + .msg = {"<iodone>"}, + .func = {"<process>"}, + .file = {"filter.c"}, + .line = 0, + .frozen = 1 +}; + +fz_error * +fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out) +{ + fz_error *reason; + unsigned char *oldrp; + unsigned char *oldwp; + + assert(!out->eof); + + oldrp = in->rp; + oldwp = out->wp; + + reason = f->process(f, in, out); + + assert(in->rp <= in->wp); + assert(out->wp <= out->ep); + + f->consumed = in->rp > oldrp; + f->produced = out->wp > oldwp; + f->count += out->wp - oldwp; + + if (reason != fz_ioneedin && reason != fz_ioneedout) + out->eof = 1; + + return reason; +} + +void +fz_freefilter(fz_filter *f) +{ + f->free(f); +} + |