blob: 9a420705723ba228f7af968771715569bd24615e (
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
|
#include "internal.h"
int
flate·read(flate·Reader *rdr, int sz, int n, void *buf)
{
int r;
int err;
flate·Reader zrdr;
zrdr = *rdr;
zrdr.next_out = buf;
zrdr.avail_out = n*sz;
READ:
err = inflate(&zrdr.b.z, Z_STREAM_END);
switch (err) {
case Z_OK:
return n;
case Z_STREAM_END:
r = zrdr.next_out - (ubyte*)buf;
n -= r;
zrdr.avail_in = zrdr.rdr.read(zrdr.impl, 1, arrlen(zrdr.buf), zrdr.buf);
if (!zrdr.avail_in) {
return r;
}
zrdr.next_in = zrdr.buf;
goto READ;
case Z_NEED_DICT:
errorf("zlib: need input dictionary");
goto ERROR;
case Z_STREAM_ERROR:
errorf("zlib: inconsistent stream structure");
goto ERROR;
}
ERROR:
flate·closereader(rdr);
return -1;
}
|