Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

660 lines
21 KiB

  1. /*-------------------------------------------------------------*/
  2. /*--- Decompression machinery ---*/
  3. /*--- decompress.c ---*/
  4. /*-------------------------------------------------------------*/
  5. /*--
  6. This file is a part of bzip2 and/or libbzip2, a program and
  7. library for lossless, block-sorting data compression.
  8. Copyright (C) 1996-2002 Julian R Seward. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions
  11. are met:
  12. 1. Redistributions of source code must retain the above copyright
  13. notice, this list of conditions and the following disclaimer.
  14. 2. The origin of this software must not be misrepresented; you must
  15. not claim that you wrote the original software. If you use this
  16. software in a product, an acknowledgment in the product
  17. documentation would be appreciated but is not required.
  18. 3. Altered source versions must be plainly marked as such, and must
  19. not be misrepresented as being the original software.
  20. 4. The name of the author may not be used to endorse or promote
  21. products derived from this software without specific prior written
  22. permission.
  23. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  24. OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  27. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  29. GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  31. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  32. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  33. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. Julian Seward, Cambridge, UK.
  35. jseward@acm.org
  36. bzip2/libbzip2 version 1.0 of 21 March 2000
  37. This program is based on (at least) the work of:
  38. Mike Burrows
  39. David Wheeler
  40. Peter Fenwick
  41. Alistair Moffat
  42. Radford Neal
  43. Ian H. Witten
  44. Robert Sedgewick
  45. Jon L. Bentley
  46. For more information on these sources, see the manual.
  47. --*/
  48. #include "bzlib_private.h"
  49. /*---------------------------------------------------*/
  50. static
  51. void makeMaps_d ( DState* s )
  52. {
  53. Int32 i;
  54. s->nInUse = 0;
  55. for (i = 0; i < 256; i++)
  56. if (s->inUse[i]) {
  57. s->seqToUnseq[s->nInUse] = i;
  58. s->nInUse++;
  59. }
  60. }
  61. /*---------------------------------------------------*/
  62. #define RETURN(rrr) \
  63. { retVal = rrr; goto save_state_and_return; };
  64. #define GET_BITS(lll,vvv,nnn) \
  65. case lll: s->state = lll; \
  66. while (True) { \
  67. if (s->bsLive >= nnn) { \
  68. UInt32 v; \
  69. v = (s->bsBuff >> \
  70. (s->bsLive-nnn)) & ((1 << nnn)-1); \
  71. s->bsLive -= nnn; \
  72. vvv = v; \
  73. break; \
  74. } \
  75. if (s->strm->avail_in == 0) RETURN(BZ_OK); \
  76. s->bsBuff \
  77. = (s->bsBuff << 8) | \
  78. ((UInt32) \
  79. (*((UChar*)(s->strm->next_in)))); \
  80. s->bsLive += 8; \
  81. s->strm->next_in++; \
  82. s->strm->avail_in--; \
  83. s->strm->total_in_lo32++; \
  84. if (s->strm->total_in_lo32 == 0) \
  85. s->strm->total_in_hi32++; \
  86. }
  87. #define GET_UCHAR(lll,uuu) \
  88. GET_BITS(lll,uuu,8)
  89. #define GET_BIT(lll,uuu) \
  90. GET_BITS(lll,uuu,1)
  91. /*---------------------------------------------------*/
  92. #define GET_MTF_VAL(label1,label2,lval) \
  93. { \
  94. if (groupPos == 0) { \
  95. groupNo++; \
  96. if (groupNo >= nSelectors) \
  97. RETURN(BZ_DATA_ERROR); \
  98. groupPos = BZ_G_SIZE; \
  99. gSel = s->selector[groupNo]; \
  100. gMinlen = s->minLens[gSel]; \
  101. gLimit = &(s->limit[gSel][0]); \
  102. gPerm = &(s->perm[gSel][0]); \
  103. gBase = &(s->base[gSel][0]); \
  104. } \
  105. groupPos--; \
  106. zn = gMinlen; \
  107. GET_BITS(label1, zvec, zn); \
  108. while (1) { \
  109. if (zn > 20 /* the longest code */) \
  110. RETURN(BZ_DATA_ERROR); \
  111. if (zvec <= gLimit[zn]) break; \
  112. zn++; \
  113. GET_BIT(label2, zj); \
  114. zvec = (zvec << 1) | zj; \
  115. }; \
  116. if (zvec - gBase[zn] < 0 \
  117. || zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE) \
  118. RETURN(BZ_DATA_ERROR); \
  119. lval = gPerm[zvec - gBase[zn]]; \
  120. }
  121. /*---------------------------------------------------*/
  122. Int32 BZ2_decompress ( DState* s )
  123. {
  124. UChar uc;
  125. Int32 retVal;
  126. Int32 minLen, maxLen;
  127. bz_stream* strm = s->strm;
  128. /* stuff that needs to be saved/restored */
  129. Int32 i;
  130. Int32 j;
  131. Int32 t;
  132. Int32 alphaSize;
  133. Int32 nGroups;
  134. Int32 nSelectors;
  135. Int32 EOB;
  136. Int32 groupNo;
  137. Int32 groupPos;
  138. Int32 nextSym;
  139. Int32 nblockMAX;
  140. Int32 nblock;
  141. Int32 es;
  142. Int32 N;
  143. Int32 curr;
  144. Int32 zt;
  145. Int32 zn;
  146. Int32 zvec;
  147. Int32 zj;
  148. Int32 gSel;
  149. Int32 gMinlen;
  150. Int32* gLimit;
  151. Int32* gBase;
  152. Int32* gPerm;
  153. if (s->state == BZ_X_MAGIC_1) {
  154. /*initialise the save area*/
  155. s->save_i = 0;
  156. s->save_j = 0;
  157. s->save_t = 0;
  158. s->save_alphaSize = 0;
  159. s->save_nGroups = 0;
  160. s->save_nSelectors = 0;
  161. s->save_EOB = 0;
  162. s->save_groupNo = 0;
  163. s->save_groupPos = 0;
  164. s->save_nextSym = 0;
  165. s->save_nblockMAX = 0;
  166. s->save_nblock = 0;
  167. s->save_es = 0;
  168. s->save_N = 0;
  169. s->save_curr = 0;
  170. s->save_zt = 0;
  171. s->save_zn = 0;
  172. s->save_zvec = 0;
  173. s->save_zj = 0;
  174. s->save_gSel = 0;
  175. s->save_gMinlen = 0;
  176. s->save_gLimit = NULL;
  177. s->save_gBase = NULL;
  178. s->save_gPerm = NULL;
  179. }
  180. /*restore from the save area*/
  181. i = s->save_i;
  182. j = s->save_j;
  183. t = s->save_t;
  184. alphaSize = s->save_alphaSize;
  185. nGroups = s->save_nGroups;
  186. nSelectors = s->save_nSelectors;
  187. EOB = s->save_EOB;
  188. groupNo = s->save_groupNo;
  189. groupPos = s->save_groupPos;
  190. nextSym = s->save_nextSym;
  191. nblockMAX = s->save_nblockMAX;
  192. nblock = s->save_nblock;
  193. es = s->save_es;
  194. N = s->save_N;
  195. curr = s->save_curr;
  196. zt = s->save_zt;
  197. zn = s->save_zn;
  198. zvec = s->save_zvec;
  199. zj = s->save_zj;
  200. gSel = s->save_gSel;
  201. gMinlen = s->save_gMinlen;
  202. gLimit = s->save_gLimit;
  203. gBase = s->save_gBase;
  204. gPerm = s->save_gPerm;
  205. retVal = BZ_OK;
  206. switch (s->state) {
  207. GET_UCHAR(BZ_X_MAGIC_1, uc);
  208. if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC);
  209. GET_UCHAR(BZ_X_MAGIC_2, uc);
  210. if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC);
  211. GET_UCHAR(BZ_X_MAGIC_3, uc)
  212. if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC);
  213. GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
  214. if (s->blockSize100k < (BZ_HDR_0 + 1) ||
  215. s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC);
  216. s->blockSize100k -= BZ_HDR_0;
  217. if (s->smallDecompress) {
  218. s->ll16 = (UInt16 *)BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
  219. s->ll4 = (UChar *)BZALLOC(
  220. ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
  221. );
  222. if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
  223. } else {
  224. s->tt = (UInt32 *)BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
  225. if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
  226. }
  227. GET_UCHAR(BZ_X_BLKHDR_1, uc);
  228. if (uc == 0x17) goto endhdr_2;
  229. if (uc != 0x31) RETURN(BZ_DATA_ERROR);
  230. GET_UCHAR(BZ_X_BLKHDR_2, uc);
  231. if (uc != 0x41) RETURN(BZ_DATA_ERROR);
  232. GET_UCHAR(BZ_X_BLKHDR_3, uc);
  233. if (uc != 0x59) RETURN(BZ_DATA_ERROR);
  234. GET_UCHAR(BZ_X_BLKHDR_4, uc);
  235. if (uc != 0x26) RETURN(BZ_DATA_ERROR);
  236. GET_UCHAR(BZ_X_BLKHDR_5, uc);
  237. if (uc != 0x53) RETURN(BZ_DATA_ERROR);
  238. GET_UCHAR(BZ_X_BLKHDR_6, uc);
  239. if (uc != 0x59) RETURN(BZ_DATA_ERROR);
  240. s->currBlockNo++;
  241. if (s->verbosity >= 2)
  242. VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo );
  243. s->storedBlockCRC = 0;
  244. GET_UCHAR(BZ_X_BCRC_1, uc);
  245. s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
  246. GET_UCHAR(BZ_X_BCRC_2, uc);
  247. s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
  248. GET_UCHAR(BZ_X_BCRC_3, uc);
  249. s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
  250. GET_UCHAR(BZ_X_BCRC_4, uc);
  251. s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
  252. GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
  253. s->origPtr = 0;
  254. GET_UCHAR(BZ_X_ORIGPTR_1, uc);
  255. s->origPtr = (s->origPtr << 8) | ((Int32)uc);
  256. GET_UCHAR(BZ_X_ORIGPTR_2, uc);
  257. s->origPtr = (s->origPtr << 8) | ((Int32)uc);
  258. GET_UCHAR(BZ_X_ORIGPTR_3, uc);
  259. s->origPtr = (s->origPtr << 8) | ((Int32)uc);
  260. if (s->origPtr < 0)
  261. RETURN(BZ_DATA_ERROR);
  262. if (s->origPtr > 10 + 100000*s->blockSize100k)
  263. RETURN(BZ_DATA_ERROR);
  264. /*--- Receive the mapping table ---*/
  265. for (i = 0; i < 16; i++) {
  266. GET_BIT(BZ_X_MAPPING_1, uc);
  267. if (uc == 1)
  268. s->inUse16[i] = True; else
  269. s->inUse16[i] = False;
  270. }
  271. for (i = 0; i < 256; i++) s->inUse[i] = False;
  272. for (i = 0; i < 16; i++)
  273. if (s->inUse16[i])
  274. for (j = 0; j < 16; j++) {
  275. GET_BIT(BZ_X_MAPPING_2, uc);
  276. if (uc == 1) s->inUse[i * 16 + j] = True;
  277. }
  278. makeMaps_d ( s );
  279. if (s->nInUse == 0) RETURN(BZ_DATA_ERROR);
  280. alphaSize = s->nInUse+2;
  281. /*--- Now the selectors ---*/
  282. GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
  283. if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
  284. GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
  285. if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
  286. for (i = 0; i < nSelectors; i++) {
  287. j = 0;
  288. while (True) {
  289. GET_BIT(BZ_X_SELECTOR_3, uc);
  290. if (uc == 0) break;
  291. j++;
  292. if (j >= nGroups) RETURN(BZ_DATA_ERROR);
  293. }
  294. s->selectorMtf[i] = j;
  295. }
  296. /*--- Undo the MTF values for the selectors. ---*/
  297. {
  298. UChar pos[BZ_N_GROUPS], tmp, v;
  299. for (v = 0; v < nGroups; v++) pos[v] = v;
  300. for (i = 0; i < nSelectors; i++) {
  301. v = s->selectorMtf[i];
  302. tmp = pos[v];
  303. while (v > 0) { pos[v] = pos[v-1]; v--; }
  304. pos[0] = tmp;
  305. s->selector[i] = tmp;
  306. }
  307. }
  308. /*--- Now the coding tables ---*/
  309. for (t = 0; t < nGroups; t++) {
  310. GET_BITS(BZ_X_CODING_1, curr, 5);
  311. for (i = 0; i < alphaSize; i++) {
  312. while (True) {
  313. if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR);
  314. GET_BIT(BZ_X_CODING_2, uc);
  315. if (uc == 0) break;
  316. GET_BIT(BZ_X_CODING_3, uc);
  317. if (uc == 0) curr++; else curr--;
  318. }
  319. s->len[t][i] = curr;
  320. }
  321. }
  322. /*--- Create the Huffman decoding tables ---*/
  323. for (t = 0; t < nGroups; t++) {
  324. minLen = 32;
  325. maxLen = 0;
  326. for (i = 0; i < alphaSize; i++) {
  327. if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
  328. if (s->len[t][i] < minLen) minLen = s->len[t][i];
  329. }
  330. BZ2_hbCreateDecodeTables (
  331. &(s->limit[t][0]),
  332. &(s->base[t][0]),
  333. &(s->perm[t][0]),
  334. &(s->len[t][0]),
  335. minLen, maxLen, alphaSize
  336. );
  337. s->minLens[t] = minLen;
  338. }
  339. /*--- Now the MTF values ---*/
  340. EOB = s->nInUse+1;
  341. nblockMAX = 100000 * s->blockSize100k;
  342. groupNo = -1;
  343. groupPos = 0;
  344. for (i = 0; i <= 255; i++) s->unzftab[i] = 0;
  345. /*-- MTF init --*/
  346. {
  347. Int32 ii, jj, kk;
  348. kk = MTFA_SIZE-1;
  349. for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) {
  350. for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
  351. s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj);
  352. kk--;
  353. }
  354. s->mtfbase[ii] = kk + 1;
  355. }
  356. }
  357. /*-- end MTF init --*/
  358. nblock = 0;
  359. GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
  360. while (True) {
  361. if (nextSym == EOB) break;
  362. if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) {
  363. es = -1;
  364. N = 1;
  365. do {
  366. if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
  367. if (nextSym == BZ_RUNB) es = es + (1+1) * N;
  368. N = N * 2;
  369. GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
  370. }
  371. while (nextSym == BZ_RUNA || nextSym == BZ_RUNB);
  372. es++;
  373. uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ];
  374. s->unzftab[uc] += es;
  375. if (s->smallDecompress)
  376. while (es > 0) {
  377. if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
  378. s->ll16[nblock] = (UInt16)uc;
  379. nblock++;
  380. es--;
  381. }
  382. else
  383. while (es > 0) {
  384. if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
  385. s->tt[nblock] = (UInt32)uc;
  386. nblock++;
  387. es--;
  388. };
  389. continue;
  390. } else {
  391. if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
  392. /*-- uc = MTF ( nextSym-1 ) --*/
  393. {
  394. Int32 ii, jj, kk, pp, lno, off;
  395. UInt32 nn;
  396. nn = (UInt32)(nextSym - 1);
  397. if (nn < MTFL_SIZE) {
  398. /* avoid general-case expense */
  399. pp = s->mtfbase[0];
  400. uc = s->mtfa[pp+nn];
  401. while (nn > 3) {
  402. Int32 z = pp+nn;
  403. s->mtfa[(z) ] = s->mtfa[(z)-1];
  404. s->mtfa[(z)-1] = s->mtfa[(z)-2];
  405. s->mtfa[(z)-2] = s->mtfa[(z)-3];
  406. s->mtfa[(z)-3] = s->mtfa[(z)-4];
  407. nn -= 4;
  408. }
  409. while (nn > 0) {
  410. s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
  411. };
  412. s->mtfa[pp] = uc;
  413. } else {
  414. /* general case */
  415. lno = nn / MTFL_SIZE;
  416. off = nn % MTFL_SIZE;
  417. pp = s->mtfbase[lno] + off;
  418. uc = s->mtfa[pp];
  419. while (pp > s->mtfbase[lno]) {
  420. s->mtfa[pp] = s->mtfa[pp-1]; pp--;
  421. };
  422. s->mtfbase[lno]++;
  423. while (lno > 0) {
  424. s->mtfbase[lno]--;
  425. s->mtfa[s->mtfbase[lno]]
  426. = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
  427. lno--;
  428. }
  429. s->mtfbase[0]--;
  430. s->mtfa[s->mtfbase[0]] = uc;
  431. if (s->mtfbase[0] == 0) {
  432. kk = MTFA_SIZE-1;
  433. for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) {
  434. for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
  435. s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj];
  436. kk--;
  437. }
  438. s->mtfbase[ii] = kk + 1;
  439. }
  440. }
  441. }
  442. }
  443. /*-- end uc = MTF ( nextSym-1 ) --*/
  444. s->unzftab[s->seqToUnseq[uc]]++;
  445. if (s->smallDecompress)
  446. s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else
  447. s->tt[nblock] = (UInt32)(s->seqToUnseq[uc]);
  448. nblock++;
  449. GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
  450. continue;
  451. }
  452. }
  453. /* Now we know what nblock is, we can do a better sanity
  454. check on s->origPtr.
  455. */
  456. if (s->origPtr < 0 || s->origPtr >= nblock)
  457. RETURN(BZ_DATA_ERROR);
  458. s->state_out_len = 0;
  459. s->state_out_ch = 0;
  460. BZ_INITIALISE_CRC ( s->calculatedBlockCRC );
  461. s->state = BZ_X_OUTPUT;
  462. if (s->verbosity >= 2) VPrintf0 ( "rt+rld" );
  463. /*-- Set up cftab to facilitate generation of T^(-1) --*/
  464. s->cftab[0] = 0;
  465. for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
  466. for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
  467. if (s->smallDecompress) {
  468. /*-- Make a copy of cftab, used in generation of T --*/
  469. for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i];
  470. /*-- compute the T vector --*/
  471. for (i = 0; i < nblock; i++) {
  472. uc = (UChar)(s->ll16[i]);
  473. SET_LL(i, s->cftabCopy[uc]);
  474. s->cftabCopy[uc]++;
  475. }
  476. /*-- Compute T^(-1) by pointer reversal on T --*/
  477. i = s->origPtr;
  478. j = GET_LL(i);
  479. do {
  480. Int32 tmp = GET_LL(j);
  481. SET_LL(j, i);
  482. i = j;
  483. j = tmp;
  484. }
  485. while (i != s->origPtr);
  486. s->tPos = s->origPtr;
  487. s->nblock_used = 0;
  488. if (s->blockRandomised) {
  489. BZ_RAND_INIT_MASK;
  490. BZ_GET_SMALL(s->k0); s->nblock_used++;
  491. BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
  492. } else {
  493. BZ_GET_SMALL(s->k0); s->nblock_used++;
  494. }
  495. } else {
  496. /*-- compute the T^(-1) vector --*/
  497. for (i = 0; i < nblock; i++) {
  498. uc = (UChar)(s->tt[i] & 0xff);
  499. s->tt[s->cftab[uc]] |= (i << 8);
  500. s->cftab[uc]++;
  501. }
  502. s->tPos = s->tt[s->origPtr] >> 8;
  503. s->nblock_used = 0;
  504. if (s->blockRandomised) {
  505. BZ_RAND_INIT_MASK;
  506. BZ_GET_FAST(s->k0); s->nblock_used++;
  507. BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
  508. } else {
  509. BZ_GET_FAST(s->k0); s->nblock_used++;
  510. }
  511. }
  512. RETURN(BZ_OK);
  513. endhdr_2:
  514. GET_UCHAR(BZ_X_ENDHDR_2, uc);
  515. if (uc != 0x72) RETURN(BZ_DATA_ERROR);
  516. GET_UCHAR(BZ_X_ENDHDR_3, uc);
  517. if (uc != 0x45) RETURN(BZ_DATA_ERROR);
  518. GET_UCHAR(BZ_X_ENDHDR_4, uc);
  519. if (uc != 0x38) RETURN(BZ_DATA_ERROR);
  520. GET_UCHAR(BZ_X_ENDHDR_5, uc);
  521. if (uc != 0x50) RETURN(BZ_DATA_ERROR);
  522. GET_UCHAR(BZ_X_ENDHDR_6, uc);
  523. if (uc != 0x90) RETURN(BZ_DATA_ERROR);
  524. s->storedCombinedCRC = 0;
  525. GET_UCHAR(BZ_X_CCRC_1, uc);
  526. s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
  527. GET_UCHAR(BZ_X_CCRC_2, uc);
  528. s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
  529. GET_UCHAR(BZ_X_CCRC_3, uc);
  530. s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
  531. GET_UCHAR(BZ_X_CCRC_4, uc);
  532. s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
  533. s->state = BZ_X_IDLE;
  534. RETURN(BZ_STREAM_END);
  535. default: AssertH ( False, 4001 );
  536. }
  537. AssertH ( False, 4002 );
  538. save_state_and_return:
  539. s->save_i = i;
  540. s->save_j = j;
  541. s->save_t = t;
  542. s->save_alphaSize = alphaSize;
  543. s->save_nGroups = nGroups;
  544. s->save_nSelectors = nSelectors;
  545. s->save_EOB = EOB;
  546. s->save_groupNo = groupNo;
  547. s->save_groupPos = groupPos;
  548. s->save_nextSym = nextSym;
  549. s->save_nblockMAX = nblockMAX;
  550. s->save_nblock = nblock;
  551. s->save_es = es;
  552. s->save_N = N;
  553. s->save_curr = curr;
  554. s->save_zt = zt;
  555. s->save_zn = zn;
  556. s->save_zvec = zvec;
  557. s->save_zj = zj;
  558. s->save_gSel = gSel;
  559. s->save_gMinlen = gMinlen;
  560. s->save_gLimit = gLimit;
  561. s->save_gBase = gBase;
  562. s->save_gPerm = gPerm;
  563. return retVal;
  564. }
  565. /*-------------------------------------------------------------*/
  566. /*--- end decompress.c ---*/
  567. /*-------------------------------------------------------------*/