blob: e83b6d5a62ef2000968ae9ca8ace96329ce655e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include <fitz.h>
typedef struct fz_nullfilter_s fz_nullfilter;
struct fz_nullfilter_s
{
fz_filter super;
int len;
int cur;
};
fz_error *
fz_newnullfilter(fz_filter **fp, int len)
{
FZ_NEWFILTER(fz_nullfilter, f, nullfilter);
f->len = len;
f->cur = 0;
return nil;
}
void
fz_dropnullfilter(fz_filter *f)
{
}
fz_error *
fz_processnullfilter(fz_filter *filter, fz_buffer *in, fz_buffer *out)
{
fz_nullfilter *f = (fz_nullfilter*)filter;
int n;
n = MIN(MIN(in->wp - in->rp, out->ep - out->wp), f->len - f->cur);
if (n) {
memcpy(out->wp, in->rp, n);
in->rp += n;
out->wp += n;
f->cur += n;
}
if (f->cur == f->len)
return fz_iodone;
if (in->rp == in->wp)
return fz_ioneedin;
if (out->wp == out->ep)
return fz_ioneedout;
return fz_throw("braindead programmer in nullfilter");
}
|