blob: 9af2f026db3cde7d53f51256351c0f21b10cf91d [file] [log] [blame]
Denis Vlasenko77f1ec12007-10-13 03:36:03 +00001/*
2 * bzip2 is written by Julian Seward <jseward@bzip.org>.
3 * Adapted for busybox by Denys Vlasenko <vda.linux@googlemail.com>.
4 * See README and LICENSE files in this directory for more information.
5 */
6
7/*-------------------------------------------------------------*/
8/*--- Library top-level functions. ---*/
9/*--- bzlib.c ---*/
10/*-------------------------------------------------------------*/
11
12/* ------------------------------------------------------------------
13This file is part of bzip2/libbzip2, a program and library for
14lossless, block-sorting data compression.
15
16bzip2/libbzip2 version 1.0.4 of 20 December 2006
17Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
18
19Please read the WARNING, DISCLAIMER and PATENTS sections in the
20README file.
21
22This program is released under the terms of the license contained
23in the file LICENSE.
24------------------------------------------------------------------ */
25
26/* CHANGES
27 * 0.9.0 -- original version.
28 * 0.9.0a/b -- no changes in this file.
29 * 0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress().
30 * fixed bzWrite/bzRead to ignore zero-length requests.
Denys Vlasenkofb132e42010-10-29 11:46:52 +020031 * fixed bzread to correctly handle read requests after EOF.
Denis Vlasenko77f1ec12007-10-13 03:36:03 +000032 * wrong parameter order in call to bzDecompressInit in
33 * bzBuffToBuffDecompress. Fixed.
34 */
35
36/* #include "bzlib_private.h" */
37
38/*---------------------------------------------------*/
39/*--- Compression stuff ---*/
40/*---------------------------------------------------*/
41
42/*---------------------------------------------------*/
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +000043#if BZ_LIGHT_DEBUG
44static
45void bz_assert_fail(int errcode)
Denis Vlasenko77f1ec12007-10-13 03:36:03 +000046{
47 /* if (errcode == 1007) bb_error_msg_and_die("probably bad RAM"); */
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +000048 bb_error_msg_and_die("internal error %d", errcode);
Denis Vlasenko77f1ec12007-10-13 03:36:03 +000049}
50#endif
51
Denis Vlasenko77f1ec12007-10-13 03:36:03 +000052/*---------------------------------------------------*/
53static
54void prepare_new_block(EState* s)
55{
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +000056 int i;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +000057 s->nblock = 0;
Denys Vlasenkofeafb342018-02-03 04:43:46 +010058 //indexes into s->zbits[], initialzation moved to init of s->zbits
Denys Vlasenkoe594fb22018-02-03 01:30:12 +010059 //s->posZ = s->zbits; // was: s->numZ = 0;
60 //s->state_out_pos = s->zbits;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +000061 BZ_INITIALISE_CRC(s->blockCRC);
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +000062 /* inlined memset would be nice to have here */
63 for (i = 0; i < 256; i++)
64 s->inUse[i] = 0;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +000065 s->blockNo++;
66}
67
68
69/*---------------------------------------------------*/
70static
71ALWAYS_INLINE
72void init_RL(EState* s)
73{
74 s->state_in_ch = 256;
75 s->state_in_len = 0;
76}
77
78
79static
Denis Vlasenko31acd1b2007-10-17 10:14:11 +000080int isempty_RL(EState* s)
Denis Vlasenko77f1ec12007-10-13 03:36:03 +000081{
Denis Vlasenko31acd1b2007-10-17 10:14:11 +000082 return (s->state_in_ch >= 256 || s->state_in_len <= 0);
Denis Vlasenko77f1ec12007-10-13 03:36:03 +000083}
84
85
86/*---------------------------------------------------*/
87static
88void BZ2_bzCompressInit(bz_stream *strm, int blockSize100k)
89{
Denys Vlasenkoc9ae8d72018-02-03 20:19:51 +010090 unsigned n;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +000091 EState* s;
92
93 s = xzalloc(sizeof(EState));
94 s->strm = strm;
95
96 n = 100000 * blockSize100k;
97 s->arr1 = xmalloc(n * sizeof(uint32_t));
98 s->mtfv = (uint16_t*)s->arr1;
99 s->ptr = (uint32_t*)s->arr1;
100 s->arr2 = xmalloc((n + BZ_N_OVERSHOOT) * sizeof(uint32_t));
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000101 s->block = (uint8_t*)s->arr2;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000102 s->ftab = xmalloc(65537 * sizeof(uint32_t));
103
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000104 s->crc32table = crc32_filltable(NULL, 1);
105
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000106 s->state = BZ_S_INPUT;
107 s->mode = BZ_M_RUNNING;
108 s->blockSize100k = blockSize100k;
109 s->nblockMAX = n - 19;
110
111 strm->state = s;
112 /*strm->total_in = 0;*/
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000113 strm->total_out = 0;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000114 init_RL(s);
115 prepare_new_block(s);
116}
117
118
119/*---------------------------------------------------*/
120static
121void add_pair_to_block(EState* s)
122{
123 int32_t i;
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000124 uint8_t ch = (uint8_t)(s->state_in_ch);
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000125 for (i = 0; i < s->state_in_len; i++) {
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000126 BZ_UPDATE_CRC(s, s->blockCRC, ch);
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000127 }
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000128 s->inUse[s->state_in_ch] = 1;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000129 switch (s->state_in_len) {
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000130 case 3:
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000131 s->block[s->nblock] = (uint8_t)ch; s->nblock++;
132 /* fall through */
133 case 2:
134 s->block[s->nblock] = (uint8_t)ch; s->nblock++;
135 /* fall through */
136 case 1:
137 s->block[s->nblock] = (uint8_t)ch; s->nblock++;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000138 break;
139 default:
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000140 s->inUse[s->state_in_len - 4] = 1;
141 s->block[s->nblock] = (uint8_t)ch; s->nblock++;
142 s->block[s->nblock] = (uint8_t)ch; s->nblock++;
143 s->block[s->nblock] = (uint8_t)ch; s->nblock++;
144 s->block[s->nblock] = (uint8_t)ch; s->nblock++;
145 s->block[s->nblock] = (uint8_t)(s->state_in_len - 4);
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000146 s->nblock++;
147 break;
148 }
149}
150
151
152/*---------------------------------------------------*/
153static
154void flush_RL(EState* s)
155{
156 if (s->state_in_ch < 256) add_pair_to_block(s);
157 init_RL(s);
158}
159
160
161/*---------------------------------------------------*/
162#define ADD_CHAR_TO_BLOCK(zs, zchh0) \
163{ \
164 uint32_t zchh = (uint32_t)(zchh0); \
165 /*-- fast track the common case --*/ \
166 if (zchh != zs->state_in_ch && zs->state_in_len == 1) { \
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000167 uint8_t ch = (uint8_t)(zs->state_in_ch); \
168 BZ_UPDATE_CRC(zs, zs->blockCRC, ch); \
169 zs->inUse[zs->state_in_ch] = 1; \
170 zs->block[zs->nblock] = (uint8_t)ch; \
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000171 zs->nblock++; \
172 zs->state_in_ch = zchh; \
173 } \
174 else \
175 /*-- general, uncommon cases --*/ \
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000176 if (zchh != zs->state_in_ch || zs->state_in_len == 255) { \
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000177 if (zs->state_in_ch < 256) \
178 add_pair_to_block(zs); \
179 zs->state_in_ch = zchh; \
180 zs->state_in_len = 1; \
181 } else { \
182 zs->state_in_len++; \
183 } \
184}
185
186
187/*---------------------------------------------------*/
188static
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000189void /*Bool*/ copy_input_until_stop(EState* s)
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000190{
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000191 /*Bool progress_in = False;*/
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000192
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000193#ifdef SAME_CODE_AS_BELOW
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000194 if (s->mode == BZ_M_RUNNING) {
195 /*-- fast track the common case --*/
196 while (1) {
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000197 /*-- no input? --*/
198 if (s->strm->avail_in == 0) break;
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000199 /*-- block full? --*/
200 if (s->nblock >= s->nblockMAX) break;
201 /*progress_in = True;*/
202 ADD_CHAR_TO_BLOCK(s, (uint32_t)(*(uint8_t*)(s->strm->next_in)));
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000203 s->strm->next_in++;
204 s->strm->avail_in--;
205 /*s->strm->total_in++;*/
206 }
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000207 } else
208#endif
209 {
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000210 /*-- general, uncommon case --*/
211 while (1) {
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000212 /*-- no input? --*/
213 if (s->strm->avail_in == 0) break;
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000214 /*-- block full? --*/
215 if (s->nblock >= s->nblockMAX) break;
216 //# /*-- flush/finish end? --*/
217 //# if (s->avail_in_expect == 0) break;
218 /*progress_in = True;*/
219 ADD_CHAR_TO_BLOCK(s, *(uint8_t*)(s->strm->next_in));
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000220 s->strm->next_in++;
221 s->strm->avail_in--;
222 /*s->strm->total_in++;*/
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000223 //# s->avail_in_expect--;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000224 }
225 }
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000226 /*return progress_in;*/
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000227}
228
229
230/*---------------------------------------------------*/
231static
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000232void /*Bool*/ copy_output_until_stop(EState* s)
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000233{
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000234 /*Bool progress_out = False;*/
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000235
236 while (1) {
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000237 /*-- no output space? --*/
238 if (s->strm->avail_out == 0) break;
239
240 /*-- block done? --*/
Denys Vlasenkoe594fb22018-02-03 01:30:12 +0100241 if (s->state_out_pos >= s->posZ) break;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000242
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000243 /*progress_out = True;*/
Denys Vlasenkoe594fb22018-02-03 01:30:12 +0100244 *(s->strm->next_out) = *s->state_out_pos++;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000245 s->strm->avail_out--;
246 s->strm->next_out++;
247 s->strm->total_out++;
248 }
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000249 /*return progress_out;*/
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000250}
251
252
253/*---------------------------------------------------*/
254static
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000255void /*Bool*/ handle_compress(bz_stream *strm)
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000256{
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000257 /*Bool progress_in = False;*/
258 /*Bool progress_out = False;*/
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000259 EState* s = strm->state;
Denis Vlasenko3f5fdc72007-10-14 04:55:59 +0000260
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000261 while (1) {
262 if (s->state == BZ_S_OUTPUT) {
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000263 /*progress_out |=*/ copy_output_until_stop(s);
Denys Vlasenkoe594fb22018-02-03 01:30:12 +0100264 if (s->state_out_pos < s->posZ) break;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000265 if (s->mode == BZ_M_FINISHING
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000266 //# && s->avail_in_expect == 0
267 && s->strm->avail_in == 0
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000268 && isempty_RL(s))
269 break;
270 prepare_new_block(s);
271 s->state = BZ_S_INPUT;
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000272#ifdef FLUSH_IS_UNUSED
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000273 if (s->mode == BZ_M_FLUSHING
274 && s->avail_in_expect == 0
275 && isempty_RL(s))
276 break;
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000277#endif
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000278 }
279
280 if (s->state == BZ_S_INPUT) {
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000281 /*progress_in |=*/ copy_input_until_stop(s);
282 //#if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) {
283 if (s->mode != BZ_M_RUNNING && s->strm->avail_in == 0) {
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000284 flush_RL(s);
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000285 BZ2_compressBlock(s, (s->mode == BZ_M_FINISHING));
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000286 s->state = BZ_S_OUTPUT;
287 } else
288 if (s->nblock >= s->nblockMAX) {
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000289 BZ2_compressBlock(s, 0);
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000290 s->state = BZ_S_OUTPUT;
291 } else
292 if (s->strm->avail_in == 0) {
293 break;
294 }
295 }
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000296 }
297
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000298 /*return progress_in || progress_out;*/
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000299}
300
301
302/*---------------------------------------------------*/
303static
304int BZ2_bzCompress(bz_stream *strm, int action)
305{
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000306 /*Bool progress;*/
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000307 EState* s;
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000308
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000309 s = strm->state;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000310
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000311 switch (s->mode) {
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000312 case BZ_M_RUNNING:
313 if (action == BZ_RUN) {
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000314 /*progress =*/ handle_compress(strm);
315 /*return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;*/
316 return BZ_RUN_OK;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000317 }
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000318#ifdef FLUSH_IS_UNUSED
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000319 else
320 if (action == BZ_FLUSH) {
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000321 //#s->avail_in_expect = strm->avail_in;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000322 s->mode = BZ_M_FLUSHING;
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000323 goto case_BZ_M_FLUSHING;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000324 }
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000325#endif
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000326 else
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000327 /*if (action == BZ_FINISH)*/ {
328 //#s->avail_in_expect = strm->avail_in;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000329 s->mode = BZ_M_FINISHING;
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000330 goto case_BZ_M_FINISHING;
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000331 }
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000332
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000333#ifdef FLUSH_IS_UNUSED
Denis Vlasenko31acd1b2007-10-17 10:14:11 +0000334 case_BZ_M_FLUSHING:
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000335 case BZ_M_FLUSHING:
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000336 /*if (s->avail_in_expect != s->strm->avail_in)
337 return BZ_SEQUENCE_ERROR;*/
338 /*progress =*/ handle_compress(strm);
Denys Vlasenkoe594fb22018-02-03 01:30:12 +0100339 if (s->avail_in_expect > 0 || !isempty_RL(s) || s->state_out_pos < s->posZ)
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000340 return BZ_FLUSH_OK;
341 s->mode = BZ_M_RUNNING;
342 return BZ_RUN_OK;
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000343#endif
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000344
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000345 case_BZ_M_FINISHING:
346 /*case BZ_M_FINISHING:*/
347 default:
348 /*if (s->avail_in_expect != s->strm->avail_in)
349 return BZ_SEQUENCE_ERROR;*/
350 /*progress =*/ handle_compress(strm);
351 /*if (!progress) return BZ_SEQUENCE_ERROR;*/
Denys Vlasenkoe594fb22018-02-03 01:30:12 +0100352 //#if (s->avail_in_expect > 0 || !isempty_RL(s) || s->state_out_pos < s->posZ)
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000353 //# return BZ_FINISH_OK;
Denys Vlasenkoe594fb22018-02-03 01:30:12 +0100354 if (s->strm->avail_in > 0 || !isempty_RL(s) || s->state_out_pos < s->posZ)
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000355 return BZ_FINISH_OK;
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000356 /*s->mode = BZ_M_IDLE;*/
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000357 return BZ_STREAM_END;
358 }
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000359 /* return BZ_OK; --not reached--*/
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000360}
361
362
363/*---------------------------------------------------*/
364static
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000365void BZ2_bzCompressEnd(bz_stream *strm)
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000366{
367 EState* s;
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000368
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000369 s = strm->state;
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000370 free(s->arr1);
371 free(s->arr2);
372 free(s->ftab);
373 free(s->crc32table);
Denys Vlasenkoed9b08d2010-12-30 04:43:35 +0100374 free(s);
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000375}
376
377
378/*---------------------------------------------------*/
379/*--- Misc convenience stuff ---*/
380/*---------------------------------------------------*/
381
382/*---------------------------------------------------*/
383#ifdef EXAMPLE_CODE_FOR_MEM_TO_MEM_COMPRESSION
384static
385int BZ2_bzBuffToBuffCompress(char* dest,
386 unsigned int* destLen,
387 char* source,
388 unsigned int sourceLen,
389 int blockSize100k)
390{
391 bz_stream strm;
392 int ret;
393
Denys Vlasenko6b9f1632010-01-28 02:24:24 +0100394 if (dest == NULL || destLen == NULL
395 || source == NULL
396 || blockSize100k < 1 || blockSize100k > 9
397 ) {
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000398 return BZ_PARAM_ERROR;
Denys Vlasenko6b9f1632010-01-28 02:24:24 +0100399 }
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000400
401 BZ2_bzCompressInit(&strm, blockSize100k);
402
403 strm.next_in = source;
404 strm.next_out = dest;
405 strm.avail_in = sourceLen;
406 strm.avail_out = *destLen;
407
408 ret = BZ2_bzCompress(&strm, BZ_FINISH);
409 if (ret == BZ_FINISH_OK) goto output_overflow;
410 if (ret != BZ_STREAM_END) goto errhandler;
411
412 /* normal termination */
413 *destLen -= strm.avail_out;
414 BZ2_bzCompressEnd(&strm);
415 return BZ_OK;
416
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000417 output_overflow:
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000418 BZ2_bzCompressEnd(&strm);
419 return BZ_OUTBUFF_FULL;
420
Denis Vlasenkoef3aabe2007-10-14 00:43:01 +0000421 errhandler:
Denis Vlasenko77f1ec12007-10-13 03:36:03 +0000422 BZ2_bzCompressEnd(&strm);
423 return ret;
424}
425#endif
426
427/*-------------------------------------------------------------*/
428/*--- end bzlib.c ---*/
429/*-------------------------------------------------------------*/