diff options
author | Tor Andersson <tor@ghostscript.com> | 2005-03-30 08:30:22 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2005-03-30 08:30:22 +0200 |
commit | ee154f16bd09a43359967f7e7b86c3677c09461d (patch) | |
tree | 08896cfa9ff55e05bfe7855965c620d45115d4d5 /stream/filt_process.c | |
parent | 460ad7040d67a4a93a153f98095ff952a2b15d37 (diff) | |
download | mupdf-ee154f16bd09a43359967f7e7b86c3677c09461d.tar.xz |
rename part 1 -- files
Diffstat (limited to 'stream/filt_process.c')
-rw-r--r-- | stream/filt_process.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/stream/filt_process.c b/stream/filt_process.c new file mode 100644 index 00000000..afe4feed --- /dev/null +++ b/stream/filt_process.c @@ -0,0 +1,51 @@ +#include <fitz.h> + +fz_error fz_kioneedin = { -1, "<ioneedin>", "<process>", "filter.c", 0 }; +fz_error fz_kioneedout = { -1, "<ioneedout>", "<process>", "filter.c", 0 }; +fz_error fz_kiodone = { -1, "<iodone>", "<process>", "filter.c", 0 }; + +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; +} + +fz_filter * +fz_keepfilter(fz_filter *f) +{ + f->refs ++; + return f; +} + +void +fz_dropfilter(fz_filter *f) +{ + if (--f->refs == 0) + { + if (f->drop) + f->drop(f); + fz_free(f); + } +} + |