~ubuntu-branches/ubuntu/utopic/jzlib/utopic

« back to all changes in this revision

Viewing changes to com/jcraft/jzlib/ZInputStream.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2005-03-02 22:32:57 UTC
  • mfrom: (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050302223257-rbtp310soyl5gjw4
Tags: 1.0.5-1.1
NMU: Corrected kaffe-javac call (using
/usr/lib/kaffe/bin/javac). Closes: #273613 (rc, ftbfs).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*-mode:java; c-basic-offset:2; -*- */
2
 
/* JZlib -- zlib in pure Java
3
 
 *
4
 
 * Copyright (C) 2001 Lapo Luchini.
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the GNU Library General Public License
8
 
 * as published by the Free Software Foundation; either version 2 of
9
 
 * the License, or (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU Library General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU Library General Public
17
 
 * License along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
2
/*
 
3
Copyright (c) 2001 Lapo Luchini.
 
4
 
 
5
Redistribution and use in source and binary forms, with or without
 
6
modification, are permitted provided that the following conditions are met:
 
7
 
 
8
  1. Redistributions of source code must retain the above copyright notice,
 
9
     this list of conditions and the following disclaimer.
 
10
 
 
11
  2. Redistributions in binary form must reproduce the above copyright 
 
12
     notice, this list of conditions and the following disclaimer in 
 
13
     the documentation and/or other materials provided with the distribution.
 
14
 
 
15
  3. The names of the authors may not be used to endorse or promote products
 
16
     derived from this software without specific prior written permission.
 
17
 
 
18
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
 
19
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 
20
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS
 
21
OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
 
22
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
23
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 
24
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 
25
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 
26
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 
27
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
28
 */
20
29
/*
21
30
 * This program is based on zlib-1.1.3, so all credit should go authors
26
35
package com.jcraft.jzlib;
27
36
import java.io.*;
28
37
 
29
 
public class ZInputStream extends InputStream {
 
38
public class ZInputStream extends FilterInputStream {
30
39
 
31
40
  protected ZStream z=new ZStream();
32
41
  protected int bufsize=512;
38
47
  private InputStream in=null;
39
48
 
40
49
  public ZInputStream(InputStream in) {
41
 
    super();
 
50
    super(in);
42
51
    this.in=in;
43
52
    z.inflateInit();
44
53
    compress=false;
48
57
  }
49
58
 
50
59
  public ZInputStream(InputStream in, int level) {
51
 
    super();
 
60
    super(in);
52
61
    this.in=in;
53
62
    z.deflateInit(level);
54
63
    compress=true;
95
104
        throw new ZStreamException((compress ? "de" : "in")+"flating: "+z.msg);
96
105
      if(nomoreinput&&(z.avail_out==len))
97
106
        return(-1);
98
 
    } while(z.avail_out==len);
 
107
    } 
 
108
    while(z.avail_out==len&&err==JZlib.Z_OK);
99
109
    //System.err.print("("+(len-z.avail_out)+")");
100
110
    return(len-z.avail_out);
101
111
  }