00001
00002
00003
00004
00005
00006 #include "zutil.h"
00007 #include "infblock.h"
00008 #include "inftrees.h"
00009 #include "infcodes.h"
00010 #include "infutil.h"
00011
00012
00013
00014 local const uInt inflate_mask[17] = {
00015 0x0000,
00016 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
00017 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
00018 };
00019
00020
00021
00022 local int inflate_flush(
00023 inflate_blocks_statef *s,
00024 z_streamp z,
00025 int r )
00026 {
00027 uInt n;
00028 Bytef *p;
00029 Bytef *q;
00030
00031
00032 p = z->next_out;
00033 q = s->read;
00034
00035
00036 n = (uInt)((q <= s->write ? s->write : s->end) - q);
00037 if (n > z->avail_out) n = z->avail_out;
00038 if (n && r == Z_BUF_ERROR) r = Z_OK;
00039
00040
00041 z->avail_out -= n;
00042 z->total_out += n;
00043
00044
00045 if (s->checkfn != Z_NULL)
00046 z->adler = s->check = (*s->checkfn)(s->check, q, n);
00047
00048
00049 zmemcpy(p, q, n);
00050 p += n;
00051 q += n;
00052
00053
00054 if (q == s->end)
00055 {
00056
00057 q = s->window;
00058 if (s->write == s->end)
00059 s->write = s->window;
00060
00061
00062 n = (uInt)(s->write - q);
00063 if (n > z->avail_out) n = z->avail_out;
00064 if (n && r == Z_BUF_ERROR) r = Z_OK;
00065
00066
00067 z->avail_out -= n;
00068 z->total_out += n;
00069
00070
00071 if (s->checkfn != Z_NULL)
00072 z->adler = s->check = (*s->checkfn)(s->check, q, n);
00073
00074
00075 zmemcpy(p, q, n);
00076 p += n;
00077 q += n;
00078 }
00079
00080
00081 z->next_out = p;
00082 s->read = q;
00083
00084
00085 return r;
00086 }