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
180 if (window < 15 || window > 21)
return NULL;
193 if (
window == 20) posn_slots = 42;
194 else if (
window == 21) posn_slots = 50;
195 else posn_slots =
window << 1;
201 pState->
R0 = pState->
R1 = pState->
R2 = 1;
231 pState->
R0 = pState->
R1 = pState->
R2 = 1;
268#define ULONG_BITS (sizeof(ULONG)<<3)
270#define INIT_BITSTREAM do { bitsleft = 0; bitbuf = 0; } while (0)
272#define ENSURE_BITS(n) \
273 while (bitsleft < (n)) { \
274 bitbuf |= ((inpos[1]<<8)|inpos[0]) << (ULONG_BITS-16 - bitsleft); \
275 bitsleft += 16; inpos+=2; \
278#define PEEK_BITS(n) (bitbuf >> (ULONG_BITS - (n)))
279#define REMOVE_BITS(n) ((bitbuf <<= (n)), (bitsleft -= (n)))
281#define READ_BITS(v,n) do { \
283 (v) = PEEK_BITS(n); \
290#define TABLEBITS(tbl) (LZX_##tbl##_TABLEBITS)
291#define MAXSYMBOLS(tbl) (LZX_##tbl##_MAXSYMBOLS)
292#define SYMTABLE(tbl) (pState->tbl##_table)
293#define LENTABLE(tbl) (pState->tbl##_len)
300#define BUILD_TABLE(tbl) \
301 if (make_decode_table( \
302 MAXSYMBOLS(tbl), TABLEBITS(tbl), LENTABLE(tbl), SYMTABLE(tbl) \
303 )) { return DECR_ILLEGALDATA; }
309#define READ_HUFFSYM(tbl,var) do { \
311 hufftbl = SYMTABLE(tbl); \
312 if ((i = hufftbl[PEEK_BITS(TABLEBITS(tbl))]) >= MAXSYMBOLS(tbl)) { \
313 j = 1 << (ULONG_BITS - TABLEBITS(tbl)); \
315 j >>= 1; i <<= 1; i |= (bitbuf & j) ? 1 : 0; \
316 if (!j) { return DECR_ILLEGALDATA; } \
317 } while ((i = hufftbl[i]) >= MAXSYMBOLS(tbl)); \
319 j = LENTABLE(tbl)[(var) = i]; \
328#define READ_LENGTHS(tbl,first,last) do { \
329 lb.bb = bitbuf; lb.bl = bitsleft; lb.ip = inpos; \
330 if (lzx_read_lens(pState, LENTABLE(tbl),(first),(last),&lb)) { \
331 return DECR_ILLEGALDATA; \
333 bitbuf = lb.bb; bitsleft = lb.bl; inpos = lb.ip; \
354 register UBYTE bit_num = 1;
357 ULONG table_mask = 1 << nbits;
358 ULONG bit_mask = table_mask >> 1;
359 ULONG next_symbol = bit_mask;
362 while (bit_num <= nbits) {
363 for (sym = 0; sym < nsyms; sym++) {
364 if (
length[sym] == bit_num) {
367 if((
pos += bit_mask) > table_mask)
return 1;
379 if (
pos != table_mask) {
381 for (sym =
pos; sym < table_mask; sym++)
table[sym] = 0;
388 while (bit_num <= 16) {
389 for (sym = 0; sym < nsyms; sym++) {
390 if (
length[sym] == bit_num) {
394 if (
table[leaf] == 0) {
395 table[(next_symbol << 1)] = 0;
396 table[(next_symbol << 1) + 1] = 0;
397 table[leaf] = next_symbol++;
400 leaf =
table[leaf] << 1;
401 if ((
pos >> (15-
fill)) & 1) leaf++;
405 if ((
pos += bit_mask) > table_mask)
return 1;
414 if (
pos == table_mask)
return 0;
417 for (sym = 0; sym < nsyms; sym++)
if (
length[sym])
return 1;
431 register ULONG bitbuf = lb->
bb;
432 register int bitsleft = lb->
bl;
436 for (
x = 0;
x < 20;
x++) {
446 while (
y--) lens[
x++] = 0;
450 while (
y--) lens[
x++] = 0;
455 z = lens[
x] -
z;
if (
z < 0)
z += 17;
456 while (
y--) lens[
x++] =
z;
459 z = lens[
x] -
z;
if (
z < 0)
z += 17;
471 UBYTE *endinp = inpos + inlen;
473 UBYTE *runsrc, *rundest;
482 register ULONG bitbuf;
483 register int bitsleft;
487 int togo = outlen, this_run, main_element, aligned_bits;
488 int match_length, length_footer,
extra, verbatim_bits;
534 if (bitsleft > 16) inpos -= 2;
535 R0 = inpos[0]|(inpos[1]<<8)|(inpos[2]<<16)|(inpos[3]<<24);inpos+=4;
536 R1 = inpos[0]|(inpos[1]<<8)|(inpos[2]<<16)|(inpos[3]<<24);inpos+=4;
537 R2 = inpos[0]|(inpos[1]<<8)|(inpos[2]<<16)|(inpos[3]<<24);inpos+=4;
546 if (inpos > endinp) {
559 if (this_run > togo) this_run = togo;
564 window_posn &= window_size - 1;
566 if ((window_posn + this_run) > window_size)
572 while (this_run > 0) {
577 window[window_posn++] = main_element;
587 match_length += length_footer;
591 match_offset = main_element >> 3;
593 if (match_offset > 2) {
595 if (match_offset != 3) {
598 match_offset =
position_base[match_offset] - 2 + verbatim_bits;
607 else if (match_offset == 0) {
610 else if (match_offset == 1) {
612 R1 =
R0;
R0 = match_offset;
616 R2 =
R0;
R0 = match_offset;
619 rundest =
window + window_posn;
620 this_run -= match_length;
623 if (window_posn >= match_offset) {
625 runsrc = rundest - match_offset;
627 runsrc = rundest + (window_size - match_offset);
628 copy_length = match_offset - window_posn;
629 if (copy_length < match_length) {
630 match_length -= copy_length;
631 window_posn += copy_length;
632 while (copy_length-- > 0) *rundest++ = *runsrc++;
636 window_posn += match_length;
639 while (match_length-- > 0) *rundest++ = *runsrc++;
646 while (this_run > 0) {
651 window[window_posn++] = main_element;
661 match_length += length_footer;
665 match_offset = main_element >> 3;
667 if (match_offset > 2) {
675 match_offset += (verbatim_bits << 3);
677 match_offset += aligned_bits;
679 else if (
extra == 3) {
682 match_offset += aligned_bits;
684 else if (
extra > 0) {
687 match_offset += verbatim_bits;
697 else if (match_offset == 0) {
700 else if (match_offset == 1) {
702 R1 =
R0;
R0 = match_offset;
706 R2 =
R0;
R0 = match_offset;
709 rundest =
window + window_posn;
710 this_run -= match_length;
713 if (window_posn >= match_offset) {
715 runsrc = rundest - match_offset;
717 runsrc = rundest + (window_size - match_offset);
718 copy_length = match_offset - window_posn;
719 if (copy_length < match_length) {
720 match_length -= copy_length;
721 window_posn += copy_length;
722 while (copy_length-- > 0) *rundest++ = *runsrc++;
726 window_posn += match_length;
729 while (match_length-- > 0) *rundest++ = *runsrc++;
738 inpos += this_run; window_posn += this_run;
749 memcpy(outpos,
window + ((!window_posn) ? window_size : window_posn) - outlen, (
size_t) outlen);
758 if (outlen <= 6 || !pState->intel_started) {
766 LONG abs_off, rel_off;
770 while (
data < dataend) {
771 if (*
data++ != 0xE8) { curpos++;
continue; }
773 if ((abs_off >= -curpos) && (abs_off < filesize)) {
774 rel_off = (abs_off >= 0) ? abs_off - curpos : abs_off + filesize;
788#ifdef LZX_CHM_TESTDRIVER
805 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
GLuint GLuint GLsizei count
GLint GLint GLint GLint GLint GLint y
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)
cab_ULONG block_remaining
LZX_DECLARE_TABLE(PRETREE)
LZX_DECLARE_TABLE(ALIGNED)
LZX_DECLARE_TABLE(LENGTH)