/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1993-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* huffman coding decoding
*
* David Korn
* AT&T Laboratories
*/
#include "huffman.h"
{\
return(-1); \
}
/* read <n> bits from buffer <b> */
/* return <n> bits */
static char *eof;
static void decode_header(Huff_t *);
static unsigned char *getbuff(void);
/*
* decode <input> using huffman tree defined in <hp> onto <output>
* if size>0, then decode until size bytes have been decoded
* otherwise, the complete file is decoded.
* The number of bytes written is returned or -1 on error
*/
{
register long buffer;
register int left, i, n;
register int lev = 0;
register unsigned char *outp;
register unsigned char *inp;
unsigned char *outend;
unsigned char *outbuff;
/* decode the header if called with different hp */
{
}
/* set up output buffers for faster access */
if(size>=0)
{
if(n > size)
n = size;
size -= n;
}
/* set up input buffers for faster access */
/* main decoding loop */
while (1)
{
if(lev==0)
{
if((n=(numbits[i]-1)) >= 0)
{
goto pout;
}
{
}
}
i <<= 1;
{
{
if (p == eof)
{
size = 0;
}
else
*outp++ = *p;
}
pout:
{
return(-1);
if(size==0)
{
}
return(-1);
if(size>0)
{
if(n > size)
n = size;
size -= n;
}
}
lev = 0;
}
else
lev++;
}
}
{
register int c, i, n, k;
eof = &characters[0];
{
for (c=0; c < (1<<CHAR_BIT); c++)
{
*eof++ = c;
}
}
/*
* convert intnodes[i] to be number of
* internal nodes possessed by level i
*/
{
c = intnodes[i];
intnodes[i] = n /= 2;
n += c;
}
/* compute output char and number of bits used for each CHUNK of bits */
for (i=1; i<=CHUNK; i++)
{
{
for(n=0; n < 1<<(CHUNK-i); n++)
{
}
}
}
{
}
while(c >=0)
numbits[c--] = 0;
}
static unsigned char *getbuff(void)
{
register int n;
register unsigned char *cp;
if(!cp && n<0)
return(cp);
return(inbuff);
}