/* inflate.c -- zlib interface to inflate modules
* Copyright (C) 1995-2002 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zutil.h"
#include "infblock.h"
typedef enum {
/* inflate private state */
struct internal_state {
/* mode */
/* mode dependent information */
union {
struct {
/* mode independent information */
};
z_streamp z;
{
return Z_STREAM_ERROR;
return Z_OK;
}
z_streamp z;
{
return Z_STREAM_ERROR;
return Z_OK;
}
z_streamp z;
int w;
const char *version;
int stream_size;
{
stream_size != sizeof(z_stream))
return Z_VERSION_ERROR;
/* initialize state */
if (z == Z_NULL)
return Z_STREAM_ERROR;
{
}
return Z_MEM_ERROR;
/* handle undocumented nowrap option (no zlib header or check) */
if (w < 0)
{
w = - w;
}
/* set window size */
if (w < 8 || w > 15)
{
inflateEnd(z);
return Z_STREAM_ERROR;
}
/* create inflate_blocks state */
== Z_NULL)
{
inflateEnd(z);
return Z_MEM_ERROR;
}
/* reset state */
inflateReset(z);
return Z_OK;
}
z_streamp z;
const char *version;
int stream_size;
{
}
z_streamp z;
int f;
{
int r;
uInt b;
return Z_STREAM_ERROR;
r = Z_BUF_ERROR;
{
case METHOD:
{
z->msg = (char*)"unknown compression method";
break;
}
{
z->msg = (char*)"invalid window size";
break;
}
case FLAG:
b = NEXTBYTE;
{
z->msg = (char*)"incorrect header check";
break;
}
if (!(b & PRESET_DICT))
{
break;
}
case DICT4:
case DICT3:
case DICT2:
case DICT1:
return Z_NEED_DICT;
case DICT0:
z->msg = (char*)"need dictionary";
return Z_STREAM_ERROR;
case BLOCKS:
if (r == Z_DATA_ERROR)
{
break;
}
if (r == Z_OK)
r = f;
if (r != Z_STREAM_END)
return r;
r = f;
{
break;
}
case CHECK4:
case CHECK3:
case CHECK2:
case CHECK1:
{
z->msg = (char*)"incorrect data check";
break;
}
case DONE:
return Z_STREAM_END;
case BAD:
return Z_DATA_ERROR;
default:
return Z_STREAM_ERROR;
}
#ifdef NEED_DUMMY_RETURN
return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
#endif
}
z_streamp z;
const Bytef *dictionary;
{
return Z_STREAM_ERROR;
z->adler = 1L;
{
}
return Z_OK;
}
z_streamp z;
{
uInt n; /* number of bytes to look at */
Bytef *p; /* pointer to bytes */
uInt m; /* number of marker bytes found in a row */
uLong r, w; /* temporaries to save total_in and total_out */
/* set up */
return Z_STREAM_ERROR;
{
}
if ((n = z->avail_in) == 0)
return Z_BUF_ERROR;
p = z->next_in;
/* search */
while (n && m < 4)
{
if (*p == mark[m])
m++;
else if (*p)
m = 0;
else
m = 4 - m;
p++, n--;
}
/* restore */
z->next_in = p;
z->avail_in = n;
/* return no joy or set up to restart on a new block */
if (m != 4)
return Z_DATA_ERROR;
inflateReset(z);
return Z_OK;
}
/* Returns true if inflate is currently at the end of a block generated
* by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
* implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
* but removes the length bytes of the resulting empty stored block. When
* decompressing, PPP checks that at the end of input packet, inflate is
* waiting for these length bytes.
*/
z_streamp z;
{
return Z_STREAM_ERROR;
}