annotate src/com/jcraft/jzlib/Deflater.java @ 407:85bf5f9c7983

bump version number
author Carl Byington <carl@five-ten-sg.com>
date Fri, 24 Oct 2014 14:24:19 -0700
parents 46c2115ae1c8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2 /*
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
3 Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved.
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 Redistribution and use in source and binary forms, with or without
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6 modification, are permitted provided that the following conditions are met:
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8 1. Redistributions of source code must retain the above copyright notice,
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 this list of conditions and the following disclaimer.
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
11 2. Redistributions in binary form must reproduce the above copyright
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
12 notice, this list of conditions and the following disclaimer in
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13 the documentation and/or other materials provided with the distribution.
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 3. The names of the authors may not be used to endorse or promote products
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 derived from this software without specific prior written permission.
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21 INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
28 */
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
29 /*
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
30 * This program is based on zlib-1.1.3, so all credit should go authors
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
31 * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
32 * and contributors of zlib.
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
33 */
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
34
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
35 package com.jcraft.jzlib;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
36
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
37 final public class Deflater extends ZStream{
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
38
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
39 static final private int MAX_WBITS=15; // 32K LZ77 window
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
40 static final private int DEF_WBITS=MAX_WBITS;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
41
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
42 static final private int Z_NO_FLUSH=0;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
43 static final private int Z_PARTIAL_FLUSH=1;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
44 static final private int Z_SYNC_FLUSH=2;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
45 static final private int Z_FULL_FLUSH=3;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
46 static final private int Z_FINISH=4;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
47
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
48 static final private int MAX_MEM_LEVEL=9;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
49
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
50 static final private int Z_OK=0;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
51 static final private int Z_STREAM_END=1;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
52 static final private int Z_NEED_DICT=2;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
53 static final private int Z_ERRNO=-1;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
54 static final private int Z_STREAM_ERROR=-2;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
55 static final private int Z_DATA_ERROR=-3;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
56 static final private int Z_MEM_ERROR=-4;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
57 static final private int Z_BUF_ERROR=-5;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
58 static final private int Z_VERSION_ERROR=-6;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
59
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
60 private boolean finished = false;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
61
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
62 public Deflater(){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
63 super();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
64 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
65
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
66 public Deflater(int level) throws GZIPException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
67 this(level, MAX_WBITS);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
68 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
69
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
70 public Deflater(int level, boolean nowrap) throws GZIPException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
71 this(level, MAX_WBITS, nowrap);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
72 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
73
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
74 public Deflater(int level, int bits) throws GZIPException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
75 this(level, bits, false);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
76 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
77
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
78 public Deflater(int level, int bits, boolean nowrap) throws GZIPException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
79 super();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
80 int ret = init(level, bits, nowrap);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
81 if(ret!=Z_OK)
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
82 throw new GZIPException(ret+": "+msg);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
83 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
84
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
85 public Deflater(int level, int bits, int memlevel, JZlib.WrapperType wrapperType) throws GZIPException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
86 super();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
87 int ret = init(level, bits, memlevel, wrapperType);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
88 if(ret!=Z_OK)
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
89 throw new GZIPException(ret+": "+msg);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
90 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
91
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
92 public Deflater(int level, int bits, int memlevel) throws GZIPException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
93 super();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
94 int ret = init(level, bits, memlevel);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
95 if(ret!=Z_OK)
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
96 throw new GZIPException(ret+": "+msg);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
97 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
98
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
99 public int init(int level){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
100 return init(level, MAX_WBITS);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
101 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
102 public int init(int level, boolean nowrap){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
103 return init(level, MAX_WBITS, nowrap);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
104 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
105 public int init(int level, int bits){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
106 return init(level, bits, false);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
107 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
108 public int init(int level, int bits, int memlevel, JZlib.WrapperType wrapperType){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
109 if(bits < 9 || bits > 15){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
110 return Z_STREAM_ERROR;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
111 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
112 if(wrapperType == JZlib.W_NONE) {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
113 bits *= -1;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
114 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
115 else if(wrapperType == JZlib.W_GZIP) {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
116 bits += 16;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
117 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
118 else if(wrapperType == JZlib.W_ANY) {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
119 return Z_STREAM_ERROR;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
120 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
121 else if(wrapperType == JZlib.W_ZLIB) {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
122 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
123 return init(level, bits, memlevel);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
124 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
125 public int init(int level, int bits, int memlevel){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
126 finished = false;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
127 dstate=new Deflate(this);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
128 return dstate.deflateInit(level, bits, memlevel);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
129 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
130 public int init(int level, int bits, boolean nowrap){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
131 finished = false;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
132 dstate=new Deflate(this);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
133 return dstate.deflateInit(level, nowrap?-bits:bits);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
134 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
135
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
136 public int deflate(int flush){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
137 if(dstate==null){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
138 return Z_STREAM_ERROR;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
139 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
140 int ret = dstate.deflate(flush);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
141 if(ret == Z_STREAM_END)
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
142 finished = true;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
143 return ret;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
144 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
145 public int end(){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
146 finished = true;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
147 if(dstate==null) return Z_STREAM_ERROR;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
148 int ret=dstate.deflateEnd();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
149 dstate=null;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
150 free();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
151 return ret;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
152 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
153 public int params(int level, int strategy){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
154 if(dstate==null) return Z_STREAM_ERROR;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
155 return dstate.deflateParams(level, strategy);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
156 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
157 public int setDictionary (byte[] dictionary, int dictLength){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
158 if(dstate == null)
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
159 return Z_STREAM_ERROR;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
160 return dstate.deflateSetDictionary(dictionary, dictLength);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
161 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
162
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
163 public boolean finished(){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
164 return finished;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
165 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
166
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
167 public int copy(Deflater src){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
168 this.finished = src.finished;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
169 return Deflate.deflateCopy(this, src);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
170 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
171 }