/* ------------------------------------------------------------------------ */ unsigned short decode_c_st0(/*void*/) { int i, j; static unsigned short blocksize = 0; if (blocksize == 0) { /* read block head */ blocksize = getbits(BUFBITS); /* read block blocksize */ read_tree_c(); if (getbits(1)) { read_tree_p(); } else { ready_made(1); } lha_make_table(NP, pt_len, 8, pt_table); } blocksize--; j = c_table[lhabitbuf >> 4]; if (j < N1) fillbuf(c_len[j]); else { fillbuf(12); i = lhabitbuf; do { if ((short) i < 0) j = lha_right[j]; else j = lha_left[j]; i <<= 1; } while (j >= N1); fillbuf(c_len[j] - 12); } if (j == N1 - 1) j += getbits(EXTRABITS); return j; }
USHORT Unpack_HEAVY(UCHAR *in, UCHAR *out, UCHAR flags, USHORT origsize){ USHORT j, i, c, bitmask; UCHAR *outend; /* Heavy 1 uses a 4Kb dictionary, Heavy 2 uses 8Kb */ if (flags & 8) { np = 15; bitmask = 0x1fff; } else { np = 14; bitmask = 0x0fff; } initbitbuf(in); if (flags & 2) { if (read_tree_c()) return 1; if (read_tree_p()) return 2; } outend = out+origsize; while (out<outend) { c = decode_c(); if (c < 256) { *out++ = text[heavy_text_loc++ & bitmask] = (UCHAR)c; } else { j = (USHORT) (c - OFFSET); i = (USHORT) (heavy_text_loc - decode_p() - 1); while(j--) *out++ = text[heavy_text_loc++ & bitmask] = text[i++ & bitmask]; } } return 0; }