52#define LZX_MIN_MATCH (2)
53#define LZX_MAX_MATCH (257)
54#define LZX_NUM_CHARS (256)
55#define LZX_BLOCKTYPE_INVALID (0)
56#define LZX_BLOCKTYPE_VERBATIM (1)
57#define LZX_BLOCKTYPE_ALIGNED (2)
58#define LZX_BLOCKTYPE_UNCOMPRESSED (3)
59#define LZX_PRETREE_NUM_ELEMENTS (20)
60#define LZX_ALIGNED_NUM_ELEMENTS (8)
61#define LZX_NUM_PRIMARY_LENGTHS (7)
62#define LZX_NUM_SECONDARY_LENGTHS (249)
65#define LZX_PRETREE_MAXSYMBOLS (LZX_PRETREE_NUM_ELEMENTS)
66#define LZX_PRETREE_TABLEBITS (6)
67#define LZX_MAINTREE_MAXSYMBOLS (LZX_NUM_CHARS + 50*8)
68#define LZX_MAINTREE_TABLEBITS (12)
69#define LZX_LENGTH_MAXSYMBOLS (LZX_NUM_SECONDARY_LENGTHS+1)
70#define LZX_LENGTH_TABLEBITS (12)
71#define LZX_ALIGNED_MAXSYMBOLS (LZX_ALIGNED_NUM_ELEMENTS)
72#define LZX_ALIGNED_TABLEBITS (7)
74#define LZX_LENTABLE_SAFETY (64)
76#define LZX_DECLARE_TABLE(tbl) \
77 UWORD tbl##_table[(1<<LZX_##tbl##_TABLEBITS) + (LZX_##tbl##_MAXSYMBOLS<<1)];\
78 UBYTE tbl##_len [LZX_##tbl##_MAXSYMBOLS + LZX_LENTABLE_SAFETY]
159 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
160 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14,
161 15, 15, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
166 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192,
167 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576, 32768, 49152,
168 65536, 98304, 131072, 196608, 262144, 393216, 524288, 655360, 786432, 917504, 1048576, 1179648, 1310720, 1441792, 1572864, 1703936,
169 1835008, 1966080, 2097152
192 pState->
R0 = pState->
R1 = pState->
R2 = 1;
222 pState->
R0 = pState->
R1 = pState->
R2 = 1;
259#define ULONG_BITS (sizeof(ULONG)<<3)
261#define INIT_BITSTREAM do { bitsleft = 0; bitbuf = 0; } while (0)
263#define ENSURE_BITS(n) \
264 while (bitsleft < (n)) { \
265 bitbuf |= ((inpos[1]<<8)|inpos[0]) << (ULONG_BITS-16 - bitsleft); \
266 bitsleft += 16; inpos+=2; \
269#define PEEK_BITS(n) (bitbuf >> (ULONG_BITS - (n)))
270#define REMOVE_BITS(n) ((bitbuf <<= (n)), (bitsleft -= (n)))
272#define READ_BITS(v,n) do { \
274 (v) = PEEK_BITS(n); \
281#define TABLEBITS(tbl) (LZX_##tbl##_TABLEBITS)
282#define MAXSYMBOLS(tbl) (LZX_##tbl##_MAXSYMBOLS)
283#define SYMTABLE(tbl) (pState->tbl##_table)
284#define LENTABLE(tbl) (pState->tbl##_len)
291#define BUILD_TABLE(tbl) \
292 if (make_decode_table( \
293 MAXSYMBOLS(tbl), TABLEBITS(tbl), LENTABLE(tbl), SYMTABLE(tbl) \
294 )) { return DECR_ILLEGALDATA; }
300#define READ_HUFFSYM(tbl,var) do { \
302 hufftbl = SYMTABLE(tbl); \
303 if ((i = hufftbl[PEEK_BITS(TABLEBITS(tbl))]) >= MAXSYMBOLS(tbl)) { \
304 j = 1 << (ULONG_BITS - TABLEBITS(tbl)); \
306 j >>= 1; i <<= 1; i |= (bitbuf & j) ? 1 : 0; \
307 if (!j) { return DECR_ILLEGALDATA; } \
308 } while ((i = hufftbl[i]) >= MAXSYMBOLS(tbl)); \
310 j = LENTABLE(tbl)[(var) = i]; \
319#define READ_LENGTHS(tbl,first,last) do { \
320 lb.bb = bitbuf; lb.bl = bitsleft; lb.ip = inpos; \
321 if (lzx_read_lens(pState, LENTABLE(tbl),(first),(last),&lb)) { \
322 return DECR_ILLEGALDATA; \
324 bitbuf = lb.bb; bitsleft = lb.bl; inpos = lb.ip; \
345 register UBYTE bit_num = 1;
348 ULONG table_mask = 1 << nbits;
349 ULONG bit_mask = table_mask >> 1;
350 ULONG next_symbol = bit_mask;
353 while (bit_num <= nbits) {
354 for (sym = 0; sym < nsyms; sym++) {
355 if (
length[sym] == bit_num) {
358 if((
pos += bit_mask) > table_mask)
return 1;
370 if (
pos != table_mask) {
372 for (sym =
pos; sym < table_mask; sym++)
table[sym] = 0;
379 while (bit_num <= 16) {
380 for (sym = 0; sym < nsyms; sym++) {
381 if (
length[sym] == bit_num) {
385 if (
table[leaf] == 0) {
386 table[(next_symbol << 1)] = 0;
387 table[(next_symbol << 1) + 1] = 0;
388 table[leaf] = next_symbol++;
391 leaf =
table[leaf] << 1;
392 if ((
pos >> (15-
fill)) & 1) leaf++;
396 if ((
pos += bit_mask) > table_mask)
return 1;
405 if (
pos == table_mask)
return 0;
408 for (sym = 0; sym < nsyms; sym++)
if (
length[sym])
return 1;
422 register ULONG bitbuf = lb->
bb;
423 register int bitsleft = lb->
bl;
427 for (
x = 0;
x < 20;
x++) {
437 while (
y--) lens[
x++] = 0;
441 while (
y--) lens[
x++] = 0;
446 z = lens[
x] -
z;
if (
z < 0)
z += 17;
447 while (
y--) lens[
x++] =
z;
450 z = lens[
x] -
z;
if (
z < 0)
z += 17;
462 UBYTE *endinp = inpos + inlen;
464 UBYTE *runsrc, *rundest;
473 register ULONG bitbuf;
474 register int bitsleft;
478 int togo = outlen, this_run, main_element, aligned_bits;
479 int match_length, length_footer,
extra, verbatim_bits;
525 if (bitsleft > 16) inpos -= 2;
526 R0 = inpos[0]|(inpos[1]<<8)|(inpos[2]<<16)|(inpos[3]<<24);inpos+=4;
527 R1 = inpos[0]|(inpos[1]<<8)|(inpos[2]<<16)|(inpos[3]<<24);inpos+=4;
528 R2 = inpos[0]|(inpos[1]<<8)|(inpos[2]<<16)|(inpos[3]<<24);inpos+=4;
537 if (inpos > endinp) {
550 if (this_run > togo) this_run = togo;
555 window_posn &= window_size - 1;
557 if ((window_posn + this_run) > window_size)
563 while (this_run > 0) {
568 window[window_posn++] = main_element;
578 match_length += length_footer;
582 match_offset = main_element >> 3;
584 if (match_offset > 2) {
586 if (match_offset != 3) {
589 match_offset =
position_base[match_offset] - 2 + verbatim_bits;
598 else if (match_offset == 0) {
601 else if (match_offset == 1) {
603 R1 =
R0;
R0 = match_offset;
607 R2 =
R0;
R0 = match_offset;
610 rundest =
window + window_posn;
611 this_run -= match_length;
614 if (window_posn >= match_offset) {
616 runsrc = rundest - match_offset;
618 runsrc = rundest + (window_size - match_offset);
619 copy_length = match_offset - window_posn;
620 if (copy_length < match_length) {
621 match_length -= copy_length;
622 window_posn += copy_length;
623 while (copy_length-- > 0) *rundest++ = *runsrc++;
627 window_posn += match_length;
630 while (match_length-- > 0) *rundest++ = *runsrc++;
637 while (this_run > 0) {
642 window[window_posn++] = main_element;
652 match_length += length_footer;
656 match_offset = main_element >> 3;
658 if (match_offset > 2) {
666 match_offset += (verbatim_bits << 3);
668 match_offset += aligned_bits;
670 else if (
extra == 3) {
673 match_offset += aligned_bits;
675 else if (
extra > 0) {
678 match_offset += verbatim_bits;
688 else if (match_offset == 0) {
691 else if (match_offset == 1) {
693 R1 =
R0;
R0 = match_offset;
697 R2 =
R0;
R0 = match_offset;
700 rundest =
window + window_posn;
701 this_run -= match_length;
704 if (window_posn >= match_offset) {
706 runsrc = rundest - match_offset;
708 runsrc = rundest + (window_size - match_offset);
709 copy_length = match_offset - window_posn;
710 if (copy_length < match_length) {
711 match_length -= copy_length;
712 window_posn += copy_length;
713 while (copy_length-- > 0) *rundest++ = *runsrc++;
717 window_posn += match_length;
720 while (match_length-- > 0) *rundest++ = *runsrc++;
729 inpos += this_run; window_posn += this_run;
740 memcpy(outpos,
window + ((!window_posn) ? window_size : window_posn) - outlen, (
size_t) outlen);
749 if (outlen <= 6 || !pState->intel_started) {
757 LONG abs_off, rel_off;
761 while (
data < dataend) {
762 if (*
data++ != 0xE8) { curpos++;
continue; }
764 if ((abs_off >= -curpos) && (abs_off < filesize)) {
765 rel_off = (abs_off >= 0) ? abs_off - curpos : abs_off + filesize;
779#ifdef LZX_CHM_TESTDRIVER
796 ilen =
fread(ibuf, 1, 16384, fin);
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
#define HeapFree(x, y, z)
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLuint GLsizei GLsizei * length
GLubyte GLubyte GLubyte GLubyte w
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
void LZXteardown(struct LZXstate *pState)
int LZXdecompress(struct LZXstate *pState, unsigned char *inpos, unsigned char *outpos, int inlen, int outlen)
#define LZX_BLOCKTYPE_INVALID
#define READ_LENGTHS(tbl, first, last)
#define LZX_MAINTREE_MAXSYMBOLS
#define LZX_BLOCKTYPE_ALIGNED
#define LZX_NUM_SECONDARY_LENGTHS
#define LZX_BLOCKTYPE_VERBATIM
#define LZX_LENGTH_MAXSYMBOLS
#define LZX_NUM_PRIMARY_LENGTHS
#define READ_HUFFSYM(tbl, var)
#define LZX_BLOCKTYPE_UNCOMPRESSED
static const ULONG position_base[51]
struct LZXstate * LZXinit(int wndsize)
static int make_decode_table(ULONG nsyms, ULONG nbits, UBYTE *length, UWORD *table)
int LZXreset(struct LZXstate *pState)
static int lzx_read_lens(struct LZXstate *pState, UBYTE *lens, ULONG first, ULONG last, struct lzx_bits *lb)
#define LZX_LENTABLE_SAFETY
static const UBYTE extra_bits[51]
#define memcpy(s1, s2, n)
static IHTMLWindow2 * window
#define R1(v, w, x, y, z, i)
#define R2(v, w, x, y, z, i)
#define R0(v, w, x, y, z, i)
LZX_DECLARE_TABLE(MAINTREE)
LZX_DECLARE_TABLE(PRETREE)
LZX_DECLARE_TABLE(ALIGNED)
LZX_DECLARE_TABLE(LENGTH)