Path: blob/main/epkcompiler/src/com/jcraft/jzlib/JZlib.java
8645 views
/* -*-mode:java; c-basic-offset:2; -*- */1/*2Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved.34Redistribution and use in source and binary forms, with or without5modification, are permitted provided that the following conditions are met:671. Redistributions of source code must retain the above copyright notice,8this list of conditions and the following disclaimer.9102. Redistributions in binary form must reproduce the above copyright11notice, this list of conditions and the following disclaimer in12the documentation and/or other materials provided with the distribution.13143. The names of the authors may not be used to endorse or promote products15derived from this software without specific prior written permission.1617THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,18INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND19FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,20INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,21INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,23OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF24LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING25NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,26EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.27*/28/*29* This program is based on zlib-1.1.3, so all credit should go authors30* Jean-loup Gailly([email protected]) and Mark Adler([email protected])31* and contributors of zlib.32*/3334package com.jcraft.jzlib;3536final public class JZlib{37private static final String version="1.1.0";38public static String version(){return version;}3940static final public int MAX_WBITS=15; // 32K LZ77 window41static final public int DEF_WBITS=MAX_WBITS;4243public enum WrapperType {44NONE, ZLIB, GZIP, ANY45}4647public static final WrapperType W_NONE = WrapperType.NONE;48public static final WrapperType W_ZLIB = WrapperType.ZLIB;49public static final WrapperType W_GZIP = WrapperType.GZIP;50public static final WrapperType W_ANY = WrapperType.ANY;5152// compression levels53static final public int Z_NO_COMPRESSION=0;54static final public int Z_BEST_SPEED=1;55static final public int Z_BEST_COMPRESSION=9;56static final public int Z_DEFAULT_COMPRESSION=(-1);5758// compression strategy59static final public int Z_FILTERED=1;60static final public int Z_HUFFMAN_ONLY=2;61static final public int Z_DEFAULT_STRATEGY=0;6263static final public int Z_NO_FLUSH=0;64static final public int Z_PARTIAL_FLUSH=1;65static final public int Z_SYNC_FLUSH=2;66static final public int Z_FULL_FLUSH=3;67static final public int Z_FINISH=4;6869static final public int Z_OK=0;70static final public int Z_STREAM_END=1;71static final public int Z_NEED_DICT=2;72static final public int Z_ERRNO=-1;73static final public int Z_STREAM_ERROR=-2;74static final public int Z_DATA_ERROR=-3;75static final public int Z_MEM_ERROR=-4;76static final public int Z_BUF_ERROR=-5;77static final public int Z_VERSION_ERROR=-6;7879// The three kinds of block type80static final public byte Z_BINARY = 0;81static final public byte Z_ASCII = 1;82static final public byte Z_UNKNOWN = 2;8384public static long adler32_combine(long adler1, long adler2, long len2){85return Adler32.combine(adler1, adler2, len2);86}8788public static long crc32_combine(long crc1, long crc2, long len2){89return CRC32.combine(crc1, crc2, len2);90}91}929394