-/* inflate_util.c -- data and routines common to blocks and codes\r
- * Copyright (C) 1995-2002 Mark Adler\r
- * For conditions of distribution and use, see copyright notice in zlib.h\r
- */\r
-\r
-#include "zutil.h"\r
-#include "infblock.h"\r
-#include "inftrees.h"\r
-#include "infcodes.h"\r
-#include "infutil.h"\r
-\r
-\r
-/* And'ing with mask[n] masks the lower n bits */\r
-local const uInt inflate_mask[17] = {\r
- 0x0000,\r
- 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,\r
- 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff\r
-};\r
-\r
-\r
-/* copy as much as possible from the sliding window to the output area */\r
-local int inflate_flush( /* s, z, r) */\r
-inflate_blocks_statef *s,\r
-z_streamp z,\r
-int r )\r
-{\r
- uInt n;\r
- Bytef *p;\r
- Bytef *q;\r
-\r
- /* local copies of source and destination pointers */\r
- p = z->next_out;\r
- q = s->read;\r
-\r
- /* compute number of bytes to copy as far as end of window */\r
- n = (uInt)((q <= s->write ? s->write : s->end) - q);\r
- if (n > z->avail_out) n = z->avail_out;\r
- if (n && r == Z_BUF_ERROR) r = Z_OK;\r
-\r
- /* update counters */\r
- z->avail_out -= n;\r
- z->total_out += n;\r
-\r
- /* update check information */\r
- if (s->checkfn != Z_NULL)\r
- z->adler = s->check = (*s->checkfn)(s->check, q, n);\r
-\r
- /* copy as far as end of window */\r
- zmemcpy(p, q, n);\r
- p += n;\r
- q += n;\r
-\r
- /* see if more to copy at beginning of window */\r
- if (q == s->end)\r
- {\r
- /* wrap pointers */\r
- q = s->window;\r
- if (s->write == s->end)\r
- s->write = s->window;\r
-\r
- /* compute bytes to copy */\r
- n = (uInt)(s->write - q);\r
- if (n > z->avail_out) n = z->avail_out;\r
- if (n && r == Z_BUF_ERROR) r = Z_OK;\r
-\r
- /* update counters */\r
- z->avail_out -= n;\r
- z->total_out += n;\r
-\r
- /* update check information */\r
- if (s->checkfn != Z_NULL)\r
- z->adler = s->check = (*s->checkfn)(s->check, q, n);\r
-\r
- /* copy */\r
- zmemcpy(p, q, n);\r
- p += n;\r
- q += n;\r
- }\r
-\r
- /* update pointers */\r
- z->next_out = p;\r
- s->read = q;\r
-\r
- /* done */\r
- return r;\r
-}\r
+/* inflate_util.c -- data and routines common to blocks and codes
+ * Copyright (C) 1995-2002 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include "zutil.h"
+#include "infblock.h"
+#include "inftrees.h"
+#include "infcodes.h"
+#include "infutil.h"
+
+
+/* And'ing with mask[n] masks the lower n bits */
+local const uInt inflate_mask[17] = {
+ 0x0000,
+ 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
+ 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
+};
+
+
+/* copy as much as possible from the sliding window to the output area */
+local int inflate_flush( /* s, z, r) */
+inflate_blocks_statef *s,
+z_streamp z,
+int r )
+{
+ uInt n;
+ Bytef *p;
+ Bytef *q;
+
+ /* local copies of source and destination pointers */
+ p = z->next_out;
+ q = s->read;
+
+ /* compute number of bytes to copy as far as end of window */
+ n = (uInt)((q <= s->write ? s->write : s->end) - q);
+ if (n > z->avail_out) n = z->avail_out;
+ if (n && r == Z_BUF_ERROR) r = Z_OK;
+
+ /* update counters */
+ z->avail_out -= n;
+ z->total_out += n;
+
+ /* update check information */
+ if (s->checkfn != Z_NULL)
+ z->adler = s->check = (*s->checkfn)(s->check, q, n);
+
+ /* copy as far as end of window */
+ zmemcpy(p, q, n);
+ p += n;
+ q += n;
+
+ /* see if more to copy at beginning of window */
+ if (q == s->end)
+ {
+ /* wrap pointers */
+ q = s->window;
+ if (s->write == s->end)
+ s->write = s->window;
+
+ /* compute bytes to copy */
+ n = (uInt)(s->write - q);
+ if (n > z->avail_out) n = z->avail_out;
+ if (n && r == Z_BUF_ERROR) r = Z_OK;
+
+ /* update counters */
+ z->avail_out -= n;
+ z->total_out += n;
+
+ /* update check information */
+ if (s->checkfn != Z_NULL)
+ z->adler = s->check = (*s->checkfn)(s->check, q, n);
+
+ /* copy */
+ zmemcpy(p, q, n);
+ p += n;
+ q += n;
+ }
+
+ /* update pointers */
+ z->next_out = p;
+ s->read = q;
+
+ /* done */
+ return r;
+}