ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

infutil.c
Go to the documentation of this file.
00001 /* inflate_util.c -- data and routines common to blocks and codes
00002  * Copyright (C) 1995-2002 Mark Adler
00003  * For conditions of distribution and use, see copyright notice in zlib.h
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 /* And'ing with mask[n] masks the lower n bits */
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 /* copy as much as possible from the sliding window to the output area */
00022 local int inflate_flush( /* s, z, r) */
00023 inflate_blocks_statef *s,
00024 z_streamp z,
00025 int r )
00026 {
00027   uInt n;
00028   Bytef *p;
00029   Bytef *q;
00030 
00031   /* local copies of source and destination pointers */
00032   p = z->next_out;
00033   q = s->read;
00034 
00035   /* compute number of bytes to copy as far as end of window */
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   /* update counters */
00041   z->avail_out -= n;
00042   z->total_out += n;
00043 
00044   /* update check information */
00045   if (s->checkfn != Z_NULL)
00046     z->adler = s->check = (*s->checkfn)(s->check, q, n);
00047 
00048   /* copy as far as end of window */
00049   zmemcpy(p, q, n);
00050   p += n;
00051   q += n;
00052 
00053   /* see if more to copy at beginning of window */
00054   if (q == s->end)
00055   {
00056     /* wrap pointers */
00057     q = s->window;
00058     if (s->write == s->end)
00059       s->write = s->window;
00060 
00061     /* compute bytes to copy */
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     /* update counters */
00067     z->avail_out -= n;
00068     z->total_out += n;
00069 
00070     /* update check information */
00071     if (s->checkfn != Z_NULL)
00072       z->adler = s->check = (*s->checkfn)(s->check, q, n);
00073 
00074     /* copy */
00075     zmemcpy(p, q, n);
00076     p += n;
00077     q += n;
00078   }
00079 
00080   /* update pointers */
00081   z->next_out = p;
00082   s->read = q;
00083 
00084   /* done */
00085   return r;
00086 }

Generated on Sat May 26 2012 04:32:45 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.