public int blast(InputStream input, OutputStream output) throws IOException
   {
      m_input = input;
      m_output = output;

      int lit; /* true if literals are coded */
      int dict; /* log2(dictionary size) - 6 */
      int symbol; /* decoded symbol, extra bits for distance */
      int len; /* length for copy */
      int dist; /* distance for copy */
      int copy; /* copy counter */
      //unsigned char *from, *to;   /* copy pointers */

      /* read header */
      lit = bits(8);
      if (lit > 1)
      {
         return -1;
      }
      dict = bits(8);
      if (dict < 4 || dict > 6)
      {
         return -2;
      }

      /* decode literals and length/distance pairs */
      do
      {
         if (bits(1) != 0)
         {
            /* get length */
            symbol = decode(LENCODE);
            len = BASE[symbol] + bits(EXTRA[symbol]);
            if (len == 519)
            {
               break; /* end code */
            }

            /* get distance */
            symbol = len == 2 ? 2 : dict;
            dist = decode(DISTCODE) << symbol;
            dist += bits(symbol);
            dist++;
            if (m_first != 0 && dist > m_next)
            {
               return -3; /* distance too far back */
            }

            /* copy length bytes from distance bytes back */
            do
            {
               //to = m_out + m_next;
               int to = m_next;
               int from = to - dist;
               copy = MAXWIN;
               if (m_next < dist)
               {
                  from += copy;
                  copy = dist;
               }
               copy -= m_next;
               if (copy > len)
               {
                  copy = len;
               }
               len -= copy;
               m_next += copy;
               do
               {
                  //*to++ = *from++;
                  m_out[to++] = m_out[from++];
               }
               while (--copy != 0);
               if (m_next == MAXWIN)
               {
                  //if (s->outfun(s->outhow, s->out, s->next)) return 1;
                  m_output.write(m_out, 0, m_next);
                  m_next = 0;
                  m_first = 0;
               }
            }
            while (len != 0);
         }
         else
         {
            /* get literal and write it */
            symbol = lit != 0 ? decode(LITCODE) : bits(8);
            m_out[m_next++] = (byte) symbol;
            if (m_next == MAXWIN)
            {
               //if (s->outfun(s->outhow, s->out, s->next)) return 1;
               m_output.write(m_out, 0, m_next);
               m_next = 0;
               m_first = 0;
            }
         }
      }
      while (true);

      if (m_next != 0)
      {
         m_output.write(m_out, 0, m_next);
      }

      return 0;
   }
public int blast ( InputStream input , OutputStream output ) throws IOException { m_input = input ; m_output = output ; int lit ; int dict ; int symbol ; int len ; int dist ; int copy ; lit = bits ( 8 ) ; if ( lit > 1 ) { return - 1 ; } dict = bits ( 8 ) ; if ( dict < 4 || dict > 6 ) { return - 2 ; } do { if ( bits ( 1 ) != 0 ) { symbol = decode ( LENCODE ) ; len = BASE [ symbol ] + bits ( EXTRA [ symbol ] ) ; if ( len == 519 ) { break ; } symbol = len == 2 ? 2 : dict ; dist = decode ( DISTCODE ) << symbol ; dist += bits ( symbol ) ; dist ++ ; if ( m_first != 0 && dist > m_next ) { return - 3 ; } do { int to = m_next ; int from = to - dist ; copy = MAXWIN ; if ( m_next < dist ) { from += copy ; copy = dist ; } copy -= m_next ; if ( copy > len ) { copy = len ; } len -= copy ; m_next += copy ; do { m_out [ to ++ ] = m_out [ from ++ ] ; } while ( -- copy != 0 ) ; if ( m_next == MAXWIN ) { m_output . write ( m_out , 0 , m_next ) ; m_next = 0 ; m_first = 0 ; } } while ( len != 0 ) ; } else { symbol = lit != 0 ? decode ( LITCODE ) : bits ( 8 ) ; m_out [ m_next ++ ] = ( byte ) symbol ; if ( m_next == MAXWIN ) { m_output . write ( m_out , 0 , m_next ) ; m_next = 0 ; m_first = 0 ; } } } while ( true ) ; if ( m_next != 0 ) { m_output . write ( m_out , 0 , m_next ) ; } return 0 ; }
Decode PKWare Compression Library stream.

Format notes:

- First byte is 0 if literals are uncoded or 1 if they are coded.  Second
byte is 4, 5, or 6 for the number of extra bits in the distance code.
This is the base-2 logarithm of the dictionary size minus six.

- Compressed data is a combination of literals and length/distance pairs
terminated by an end code.  Literals are either Huffman coded or
uncoded bytes.  A length/distance pair is a coded length followed by a
coded distance to represent a string that occurs earlier in the
uncompressed data that occurs again at the current location.

- A bit preceding a literal or length/distance pair indicates which comes
next, 0 for literals, 1 for length/distance.

- If literals are uncoded, then the next eight bits are the literal, in the
normal bit order in the stream, i.e. no bit-reversal is needed. Similarly,
no bit reversal is needed for either the length extra bits or the distance
extra bits.

- Literal bytes are simply written to the output.  A length/distance pair is
an instruction to copy previously uncompressed bytes to the output.  The
copy is from distance bytes back in the output stream, copying for length
bytes.

- Distances pointing before the beginning of the output data are not
permitted.

- Overlapped copies, where the length is greater than the distance, are
allowed and common.  For example, a distance of one and a length of 518
simply copies the last byte 518 times.  A distance of four and a length of
twelve copies the last four bytes three times.  A simple forward copy
ignoring whether the length is greater than the distance or not implements
this correctly.

@param input InputStream instance
@param output OutputStream instance
@return status code