emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/JzLibInflater.java
changeset 772 d382dacfd73f
parent 771 4252bfc396fc
child 773 406faa8bc64f
     1.1 --- a/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/JzLibInflater.java	Tue Feb 26 14:55:55 2013 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,137 +0,0 @@
     1.4 -/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
     1.5 -/*
     1.6 -Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved.
     1.7 -
     1.8 -Redistribution and use in source and binary forms, with or without
     1.9 -modification, are permitted provided that the following conditions are met:
    1.10 -
    1.11 -  1. Redistributions of source code must retain the above copyright notice,
    1.12 -     this list of conditions and the following disclaimer.
    1.13 -
    1.14 -  2. Redistributions in binary form must reproduce the above copyright 
    1.15 -     notice, this list of conditions and the following disclaimer in 
    1.16 -     the documentation and/or other materials provided with the distribution.
    1.17 -
    1.18 -  3. The names of the authors may not be used to endorse or promote products
    1.19 -     derived from this software without specific prior written permission.
    1.20 -
    1.21 -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
    1.22 -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    1.23 -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
    1.24 -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
    1.25 -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.26 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
    1.27 -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    1.28 -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    1.29 -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    1.30 -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.31 - */
    1.32 -/*
    1.33 - * This program is based on zlib-1.1.3, so all credit should go authors
    1.34 - * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
    1.35 - * and contributors of zlib.
    1.36 - */
    1.37 -
    1.38 -package org.apidesign.bck2brwsr.emul.zip;
    1.39 -
    1.40 -final class JzLibInflater extends ZStream{
    1.41 -
    1.42 -  static final private int MAX_WBITS=15;        // 32K LZ77 window
    1.43 -  static final private int DEF_WBITS=MAX_WBITS;
    1.44 -
    1.45 -  public static final int Z_NO_FLUSH=0;
    1.46 -  static final private int Z_PARTIAL_FLUSH=1;
    1.47 -  static final private int Z_SYNC_FLUSH=2;
    1.48 -  static final private int Z_FULL_FLUSH=3;
    1.49 -  static final private int Z_FINISH=4;
    1.50 -
    1.51 -  static final private int MAX_MEM_LEVEL=9;
    1.52 -
    1.53 -  static final private int Z_OK=0;
    1.54 -  static final private int Z_STREAM_END=1;
    1.55 -  static final private int Z_NEED_DICT=2;
    1.56 -  static final private int Z_ERRNO=-1;
    1.57 -  static final private int Z_STREAM_ERROR=-2;
    1.58 -  static final private int Z_DATA_ERROR=-3;
    1.59 -  static final private int Z_MEM_ERROR=-4;
    1.60 -  static final private int Z_BUF_ERROR=-5;
    1.61 -  static final private int Z_VERSION_ERROR=-6;
    1.62 -
    1.63 -  public JzLibInflater() {
    1.64 -    super();
    1.65 -    init();
    1.66 -  }
    1.67 -
    1.68 -  public JzLibInflater(int w)  {
    1.69 -    this(w, false);
    1.70 -  }
    1.71 -
    1.72 -  public JzLibInflater(int w, boolean nowrap)  {
    1.73 -    super();
    1.74 -    int ret = init(w, nowrap);
    1.75 -    if(ret!=Z_OK)
    1.76 -      throw new IllegalStateException(ret+": "+msg);
    1.77 -  }
    1.78 -
    1.79 -  private boolean finished = false;
    1.80 -
    1.81 -  public int init(){
    1.82 -    return init(DEF_WBITS);
    1.83 -  }
    1.84 -
    1.85 -  public int init(boolean nowrap){
    1.86 -    return init(DEF_WBITS, nowrap);
    1.87 -  }
    1.88 -
    1.89 -  public int init(int w){
    1.90 -    return init(w, false);
    1.91 -  }
    1.92 -
    1.93 -  public int init(int w, boolean nowrap){
    1.94 -    finished = false;
    1.95 -    istate=new Inflate(this);
    1.96 -    return istate.inflateInit(nowrap?-w:w);
    1.97 -  }
    1.98 -
    1.99 -  public int inflate(int f){
   1.100 -    if(istate==null) return Z_STREAM_ERROR;
   1.101 -    int ret = istate.inflate(f);
   1.102 -    if(ret == Z_STREAM_END) 
   1.103 -      finished = true;
   1.104 -    return ret;
   1.105 -  }
   1.106 -
   1.107 -  public int end(){
   1.108 -    finished = true;
   1.109 -    if(istate==null) return Z_STREAM_ERROR;
   1.110 -    int ret=istate.inflateEnd();
   1.111 -//    istate = null;
   1.112 -    return ret;
   1.113 -  }
   1.114 -
   1.115 -  public int sync(){
   1.116 -    if(istate == null)
   1.117 -      return Z_STREAM_ERROR;
   1.118 -    return istate.inflateSync();
   1.119 -  }
   1.120 -
   1.121 -  public int syncPoint(){
   1.122 -    if(istate == null)
   1.123 -      return Z_STREAM_ERROR;
   1.124 -    return istate.inflateSyncPoint();
   1.125 -  }
   1.126 -
   1.127 -  public int setDictionary(byte[] dictionary, int dictLength){
   1.128 -    if(istate == null)
   1.129 -      return Z_STREAM_ERROR;
   1.130 -    return istate.inflateSetDictionary(dictionary, dictLength);
   1.131 -  }
   1.132 -
   1.133 -  public boolean finished(){
   1.134 -    return istate.mode==12 /*DONE*/;
   1.135 -  }
   1.136 -
   1.137 -  public boolean needDict() {
   1.138 -    return istate == null ? false : istate.mode == Inflate.DICT0;
   1.139 -  }
   1.140 -}