infutil.c

来自「This is a resource based on j2me embedde」· C语言 代码 · 共 116 行

C
116
字号
/* * @(#)infutil.c	1.18 06/10/10 * * Portions Copyright  2000-2008 Sun Microsystems, Inc. All Rights * Reserved.  Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER *  * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. *  * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). *  * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA *  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. *//* inflate_util.c -- data and routines common to blocks and codes * Copyright (C) 1995-1996 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"struct inflate_codes_state {int dummy;}; /* for buggy compilers *//* And'ing with mask[n] masks the lower n bits */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 */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;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?