diff options
author | Julian Seward <jseward@acm.org> | 2000-06-24 22:13:13 +0200 |
---|---|---|
committer | Julian Seward <jseward@acm.org> | 2000-06-24 22:13:13 +0200 |
commit | 795b859eee96c700e8f3c3fe68e6a9a39d95797c (patch) | |
tree | 48f8a731cd5ec2f5f15c6d99f2207ebf4a1f35f6 /bzlib.c | |
parent | f93cd82a9a7094ad90fd19bbc6ccf6f4627f8060 (diff) | |
download | bzip2-795b859eee96c700e8f3c3fe68e6a9a39d95797c.tar.gz bzip2-795b859eee96c700e8f3c3fe68e6a9a39d95797c.tar.bz2 bzip2-795b859eee96c700e8f3c3fe68e6a9a39d95797c.zip |
bzip2-1.0.1bzip2-1.0.1
Diffstat (limited to 'bzlib.c')
-rw-r--r-- | bzlib.c | 248 |
1 files changed, 152 insertions, 96 deletions
@@ -8,7 +8,7 @@ | |||
8 | This file is a part of bzip2 and/or libbzip2, a program and | 8 | This file is a part of bzip2 and/or libbzip2, a program and |
9 | library for lossless, block-sorting data compression. | 9 | library for lossless, block-sorting data compression. |
10 | 10 | ||
11 | Copyright (C) 1996-1999 Julian R Seward. All rights reserved. | 11 | Copyright (C) 1996-2000 Julian R Seward. All rights reserved. |
12 | 12 | ||
13 | Redistribution and use in source and binary forms, with or without | 13 | Redistribution and use in source and binary forms, with or without |
14 | modification, are permitted provided that the following conditions | 14 | modification, are permitted provided that the following conditions |
@@ -43,7 +43,7 @@ | |||
43 | 43 | ||
44 | Julian Seward, Cambridge, UK. | 44 | Julian Seward, Cambridge, UK. |
45 | jseward@acm.org | 45 | jseward@acm.org |
46 | bzip2/libbzip2 version 0.9.5 of 24 May 1999 | 46 | bzip2/libbzip2 version 1.0 of 21 March 2000 |
47 | 47 | ||
48 | This program is based on (at least) the work of: | 48 | This program is based on (at least) the work of: |
49 | Mike Burrows | 49 | Mike Burrows |
@@ -83,18 +83,19 @@ | |||
83 | 83 | ||
84 | /*---------------------------------------------------*/ | 84 | /*---------------------------------------------------*/ |
85 | #ifndef BZ_NO_STDIO | 85 | #ifndef BZ_NO_STDIO |
86 | void bz__AssertH__fail ( int errcode ) | 86 | void BZ2_bz__AssertH__fail ( int errcode ) |
87 | { | 87 | { |
88 | fprintf(stderr, | 88 | fprintf(stderr, |
89 | "\n\nbzip2/libbzip2, v0.9.5d: internal error number %d.\n" | 89 | "\n\nbzip2/libbzip2: internal error number %d.\n" |
90 | "This is a bug in bzip2/libbzip2, v0.9.5d. Please report\n" | 90 | "This is a bug in bzip2/libbzip2, %s.\n" |
91 | "it to me at: jseward@acm.org. If this happened when\n" | 91 | "Please report it to me at: jseward@acm.org. If this happened\n" |
92 | "you were using some program which uses libbzip2 as a\n" | 92 | "when you were using some program which uses libbzip2 as a\n" |
93 | "component, you should also report this bug to the author(s)\n" | 93 | "component, you should also report this bug to the author(s)\n" |
94 | "of that program. Please make an effort to report this bug;\n" | 94 | "of that program. Please make an effort to report this bug;\n" |
95 | "timely and accurate bug reports eventually lead to higher\n" | 95 | "timely and accurate bug reports eventually lead to higher\n" |
96 | "quality software. Thanks. Julian Seward, 4 Sept 1999.\n\n", | 96 | "quality software. Thanks. Julian Seward, 21 March 2000.\n\n", |
97 | errcode | 97 | errcode, |
98 | BZ2_bzlibVersion() | ||
98 | ); | 99 | ); |
99 | exit(3); | 100 | exit(3); |
100 | } | 101 | } |
@@ -103,6 +104,17 @@ void bz__AssertH__fail ( int errcode ) | |||
103 | 104 | ||
104 | /*---------------------------------------------------*/ | 105 | /*---------------------------------------------------*/ |
105 | static | 106 | static |
107 | int bz_config_ok ( void ) | ||
108 | { | ||
109 | if (sizeof(int) != 4) return 0; | ||
110 | if (sizeof(short) != 2) return 0; | ||
111 | if (sizeof(char) != 1) return 0; | ||
112 | return 1; | ||
113 | } | ||
114 | |||
115 | |||
116 | /*---------------------------------------------------*/ | ||
117 | static | ||
106 | void* default_bzalloc ( void* opaque, Int32 items, Int32 size ) | 118 | void* default_bzalloc ( void* opaque, Int32 items, Int32 size ) |
107 | { | 119 | { |
108 | void* v = malloc ( items * size ); | 120 | void* v = malloc ( items * size ); |
@@ -149,7 +161,7 @@ Bool isempty_RL ( EState* s ) | |||
149 | 161 | ||
150 | 162 | ||
151 | /*---------------------------------------------------*/ | 163 | /*---------------------------------------------------*/ |
152 | int BZ_API(bzCompressInit) | 164 | int BZ_API(BZ2_bzCompressInit) |
153 | ( bz_stream* strm, | 165 | ( bz_stream* strm, |
154 | int blockSize100k, | 166 | int blockSize100k, |
155 | int verbosity, | 167 | int verbosity, |
@@ -158,6 +170,8 @@ int BZ_API(bzCompressInit) | |||
158 | Int32 n; | 170 | Int32 n; |
159 | EState* s; | 171 | EState* s; |
160 | 172 | ||
173 | if (!bz_config_ok()) return BZ_CONFIG_ERROR; | ||
174 | |||
161 | if (strm == NULL || | 175 | if (strm == NULL || |
162 | blockSize100k < 1 || blockSize100k > 9 || | 176 | blockSize100k < 1 || blockSize100k > 9 || |
163 | workFactor < 0 || workFactor > 250) | 177 | workFactor < 0 || workFactor > 250) |
@@ -197,14 +211,16 @@ int BZ_API(bzCompressInit) | |||
197 | s->verbosity = verbosity; | 211 | s->verbosity = verbosity; |
198 | s->workFactor = workFactor; | 212 | s->workFactor = workFactor; |
199 | 213 | ||
200 | s->block = (UInt16*)s->arr2; | 214 | s->block = (UChar*)s->arr2; |
201 | s->mtfv = (UInt16*)s->arr1; | 215 | s->mtfv = (UInt16*)s->arr1; |
202 | s->zbits = NULL; | 216 | s->zbits = NULL; |
203 | s->ptr = (UInt32*)s->arr1; | 217 | s->ptr = (UInt32*)s->arr1; |
204 | 218 | ||
205 | strm->state = s; | 219 | strm->state = s; |
206 | strm->total_in = 0; | 220 | strm->total_in_lo32 = 0; |
207 | strm->total_out = 0; | 221 | strm->total_in_hi32 = 0; |
222 | strm->total_out_lo32 = 0; | ||
223 | strm->total_out_hi32 = 0; | ||
208 | init_RL ( s ); | 224 | init_RL ( s ); |
209 | prepare_new_block ( s ); | 225 | prepare_new_block ( s ); |
210 | return BZ_OK; | 226 | return BZ_OK; |
@@ -223,24 +239,24 @@ void add_pair_to_block ( EState* s ) | |||
223 | s->inUse[s->state_in_ch] = True; | 239 | s->inUse[s->state_in_ch] = True; |
224 | switch (s->state_in_len) { | 240 | switch (s->state_in_len) { |
225 | case 1: | 241 | case 1: |
226 | s->block[s->nblock] = (UInt16)ch; s->nblock++; | 242 | s->block[s->nblock] = (UChar)ch; s->nblock++; |
227 | break; | 243 | break; |
228 | case 2: | 244 | case 2: |
229 | s->block[s->nblock] = (UInt16)ch; s->nblock++; | 245 | s->block[s->nblock] = (UChar)ch; s->nblock++; |
230 | s->block[s->nblock] = (UInt16)ch; s->nblock++; | 246 | s->block[s->nblock] = (UChar)ch; s->nblock++; |
231 | break; | 247 | break; |
232 | case 3: | 248 | case 3: |
233 | s->block[s->nblock] = (UInt16)ch; s->nblock++; | 249 | s->block[s->nblock] = (UChar)ch; s->nblock++; |
234 | s->block[s->nblock] = (UInt16)ch; s->nblock++; | 250 | s->block[s->nblock] = (UChar)ch; s->nblock++; |
235 | s->block[s->nblock] = (UInt16)ch; s->nblock++; | 251 | s->block[s->nblock] = (UChar)ch; s->nblock++; |
236 | break; | 252 | break; |
237 | default: | 253 | default: |
238 | s->inUse[s->state_in_len-4] = True; | 254 | s->inUse[s->state_in_len-4] = True; |
239 | s->block[s->nblock] = (UInt16)ch; s->nblock++; | 255 | s->block[s->nblock] = (UChar)ch; s->nblock++; |
240 | s->block[s->nblock] = (UInt16)ch; s->nblock++; | 256 | s->block[s->nblock] = (UChar)ch; s->nblock++; |
241 | s->block[s->nblock] = (UInt16)ch; s->nblock++; | 257 | s->block[s->nblock] = (UChar)ch; s->nblock++; |
242 | s->block[s->nblock] = (UInt16)ch; s->nblock++; | 258 | s->block[s->nblock] = (UChar)ch; s->nblock++; |
243 | s->block[s->nblock] = ((UInt16)(s->state_in_len-4)); | 259 | s->block[s->nblock] = ((UChar)(s->state_in_len-4)); |
244 | s->nblock++; | 260 | s->nblock++; |
245 | break; | 261 | break; |
246 | } | 262 | } |
@@ -266,7 +282,7 @@ void flush_RL ( EState* s ) | |||
266 | UChar ch = (UChar)(zs->state_in_ch); \ | 282 | UChar ch = (UChar)(zs->state_in_ch); \ |
267 | BZ_UPDATE_CRC( zs->blockCRC, ch ); \ | 283 | BZ_UPDATE_CRC( zs->blockCRC, ch ); \ |
268 | zs->inUse[zs->state_in_ch] = True; \ | 284 | zs->inUse[zs->state_in_ch] = True; \ |
269 | zs->block[zs->nblock] = (UInt16)ch; \ | 285 | zs->block[zs->nblock] = (UChar)ch; \ |
270 | zs->nblock++; \ | 286 | zs->nblock++; \ |
271 | zs->state_in_ch = zchh; \ | 287 | zs->state_in_ch = zchh; \ |
272 | } \ | 288 | } \ |
@@ -302,7 +318,8 @@ Bool copy_input_until_stop ( EState* s ) | |||
302 | ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); | 318 | ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); |
303 | s->strm->next_in++; | 319 | s->strm->next_in++; |
304 | s->strm->avail_in--; | 320 | s->strm->avail_in--; |
305 | s->strm->total_in++; | 321 | s->strm->total_in_lo32++; |
322 | if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++; | ||
306 | } | 323 | } |
307 | 324 | ||
308 | } else { | 325 | } else { |
@@ -319,7 +336,8 @@ Bool copy_input_until_stop ( EState* s ) | |||
319 | ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); | 336 | ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); |
320 | s->strm->next_in++; | 337 | s->strm->next_in++; |
321 | s->strm->avail_in--; | 338 | s->strm->avail_in--; |
322 | s->strm->total_in++; | 339 | s->strm->total_in_lo32++; |
340 | if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++; | ||
323 | s->avail_in_expect--; | 341 | s->avail_in_expect--; |
324 | } | 342 | } |
325 | } | 343 | } |
@@ -346,8 +364,8 @@ Bool copy_output_until_stop ( EState* s ) | |||
346 | s->state_out_pos++; | 364 | s->state_out_pos++; |
347 | s->strm->avail_out--; | 365 | s->strm->avail_out--; |
348 | s->strm->next_out++; | 366 | s->strm->next_out++; |
349 | s->strm->total_out++; | 367 | s->strm->total_out_lo32++; |
350 | 368 | if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; | |
351 | } | 369 | } |
352 | 370 | ||
353 | return progress_out; | 371 | return progress_out; |
@@ -381,12 +399,12 @@ Bool handle_compress ( bz_stream* strm ) | |||
381 | progress_in |= copy_input_until_stop ( s ); | 399 | progress_in |= copy_input_until_stop ( s ); |
382 | if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) { | 400 | if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) { |
383 | flush_RL ( s ); | 401 | flush_RL ( s ); |
384 | compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) ); | 402 | BZ2_compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) ); |
385 | s->state = BZ_S_OUTPUT; | 403 | s->state = BZ_S_OUTPUT; |
386 | } | 404 | } |
387 | else | 405 | else |
388 | if (s->nblock >= s->nblockMAX) { | 406 | if (s->nblock >= s->nblockMAX) { |
389 | compressBlock ( s, False ); | 407 | BZ2_compressBlock ( s, False ); |
390 | s->state = BZ_S_OUTPUT; | 408 | s->state = BZ_S_OUTPUT; |
391 | } | 409 | } |
392 | else | 410 | else |
@@ -402,7 +420,7 @@ Bool handle_compress ( bz_stream* strm ) | |||
402 | 420 | ||
403 | 421 | ||
404 | /*---------------------------------------------------*/ | 422 | /*---------------------------------------------------*/ |
405 | int BZ_API(bzCompress) ( bz_stream *strm, int action ) | 423 | int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) |
406 | { | 424 | { |
407 | Bool progress; | 425 | Bool progress; |
408 | EState* s; | 426 | EState* s; |
@@ -439,7 +457,8 @@ int BZ_API(bzCompress) ( bz_stream *strm, int action ) | |||
439 | 457 | ||
440 | case BZ_M_FLUSHING: | 458 | case BZ_M_FLUSHING: |
441 | if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR; | 459 | if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR; |
442 | if (s->avail_in_expect != s->strm->avail_in) return BZ_SEQUENCE_ERROR; | 460 | if (s->avail_in_expect != s->strm->avail_in) |
461 | return BZ_SEQUENCE_ERROR; | ||
443 | progress = handle_compress ( strm ); | 462 | progress = handle_compress ( strm ); |
444 | if (s->avail_in_expect > 0 || !isempty_RL(s) || | 463 | if (s->avail_in_expect > 0 || !isempty_RL(s) || |
445 | s->state_out_pos < s->numZ) return BZ_FLUSH_OK; | 464 | s->state_out_pos < s->numZ) return BZ_FLUSH_OK; |
@@ -448,7 +467,8 @@ int BZ_API(bzCompress) ( bz_stream *strm, int action ) | |||
448 | 467 | ||
449 | case BZ_M_FINISHING: | 468 | case BZ_M_FINISHING: |
450 | if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR; | 469 | if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR; |
451 | if (s->avail_in_expect != s->strm->avail_in) return BZ_SEQUENCE_ERROR; | 470 | if (s->avail_in_expect != s->strm->avail_in) |
471 | return BZ_SEQUENCE_ERROR; | ||
452 | progress = handle_compress ( strm ); | 472 | progress = handle_compress ( strm ); |
453 | if (!progress) return BZ_SEQUENCE_ERROR; | 473 | if (!progress) return BZ_SEQUENCE_ERROR; |
454 | if (s->avail_in_expect > 0 || !isempty_RL(s) || | 474 | if (s->avail_in_expect > 0 || !isempty_RL(s) || |
@@ -461,7 +481,7 @@ int BZ_API(bzCompress) ( bz_stream *strm, int action ) | |||
461 | 481 | ||
462 | 482 | ||
463 | /*---------------------------------------------------*/ | 483 | /*---------------------------------------------------*/ |
464 | int BZ_API(bzCompressEnd) ( bz_stream *strm ) | 484 | int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) |
465 | { | 485 | { |
466 | EState* s; | 486 | EState* s; |
467 | if (strm == NULL) return BZ_PARAM_ERROR; | 487 | if (strm == NULL) return BZ_PARAM_ERROR; |
@@ -485,13 +505,15 @@ int BZ_API(bzCompressEnd) ( bz_stream *strm ) | |||
485 | /*---------------------------------------------------*/ | 505 | /*---------------------------------------------------*/ |
486 | 506 | ||
487 | /*---------------------------------------------------*/ | 507 | /*---------------------------------------------------*/ |
488 | int BZ_API(bzDecompressInit) | 508 | int BZ_API(BZ2_bzDecompressInit) |
489 | ( bz_stream* strm, | 509 | ( bz_stream* strm, |
490 | int verbosity, | 510 | int verbosity, |
491 | int small ) | 511 | int small ) |
492 | { | 512 | { |
493 | DState* s; | 513 | DState* s; |
494 | 514 | ||
515 | if (!bz_config_ok()) return BZ_CONFIG_ERROR; | ||
516 | |||
495 | if (strm == NULL) return BZ_PARAM_ERROR; | 517 | if (strm == NULL) return BZ_PARAM_ERROR; |
496 | if (small != 0 && small != 1) return BZ_PARAM_ERROR; | 518 | if (small != 0 && small != 1) return BZ_PARAM_ERROR; |
497 | if (verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR; | 519 | if (verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR; |
@@ -507,8 +529,10 @@ int BZ_API(bzDecompressInit) | |||
507 | s->bsLive = 0; | 529 | s->bsLive = 0; |
508 | s->bsBuff = 0; | 530 | s->bsBuff = 0; |
509 | s->calculatedCombinedCRC = 0; | 531 | s->calculatedCombinedCRC = 0; |
510 | strm->total_in = 0; | 532 | strm->total_in_lo32 = 0; |
511 | strm->total_out = 0; | 533 | strm->total_in_hi32 = 0; |
534 | strm->total_out_lo32 = 0; | ||
535 | strm->total_out_hi32 = 0; | ||
512 | s->smallDecompress = (Bool)small; | 536 | s->smallDecompress = (Bool)small; |
513 | s->ll4 = NULL; | 537 | s->ll4 = NULL; |
514 | s->ll16 = NULL; | 538 | s->ll16 = NULL; |
@@ -538,7 +562,8 @@ void unRLE_obuf_to_output_FAST ( DState* s ) | |||
538 | s->state_out_len--; | 562 | s->state_out_len--; |
539 | s->strm->next_out++; | 563 | s->strm->next_out++; |
540 | s->strm->avail_out--; | 564 | s->strm->avail_out--; |
541 | s->strm->total_out++; | 565 | s->strm->total_out_lo32++; |
566 | if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; | ||
542 | } | 567 | } |
543 | 568 | ||
544 | /* can a new run be started? */ | 569 | /* can a new run be started? */ |
@@ -585,8 +610,9 @@ void unRLE_obuf_to_output_FAST ( DState* s ) | |||
585 | unsigned int cs_avail_out = s->strm->avail_out; | 610 | unsigned int cs_avail_out = s->strm->avail_out; |
586 | /* end restore */ | 611 | /* end restore */ |
587 | 612 | ||
588 | UInt32 avail_out_INIT = cs_avail_out; | 613 | UInt32 avail_out_INIT = cs_avail_out; |
589 | Int32 s_save_nblockPP = s->save_nblock+1; | 614 | Int32 s_save_nblockPP = s->save_nblock+1; |
615 | unsigned int total_out_lo32_old; | ||
590 | 616 | ||
591 | while (True) { | 617 | while (True) { |
592 | 618 | ||
@@ -640,7 +666,10 @@ void unRLE_obuf_to_output_FAST ( DState* s ) | |||
640 | } | 666 | } |
641 | 667 | ||
642 | return_notr: | 668 | return_notr: |
643 | s->strm->total_out += (avail_out_INIT - cs_avail_out); | 669 | total_out_lo32_old = s->strm->total_out_lo32; |
670 | s->strm->total_out_lo32 += (avail_out_INIT - cs_avail_out); | ||
671 | if (s->strm->total_out_lo32 < total_out_lo32_old) | ||
672 | s->strm->total_out_hi32++; | ||
644 | 673 | ||
645 | /* save */ | 674 | /* save */ |
646 | s->calculatedBlockCRC = c_calculatedBlockCRC; | 675 | s->calculatedBlockCRC = c_calculatedBlockCRC; |
@@ -659,7 +688,7 @@ void unRLE_obuf_to_output_FAST ( DState* s ) | |||
659 | 688 | ||
660 | 689 | ||
661 | /*---------------------------------------------------*/ | 690 | /*---------------------------------------------------*/ |
662 | __inline__ Int32 indexIntoF ( Int32 indx, Int32 *cftab ) | 691 | __inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab ) |
663 | { | 692 | { |
664 | Int32 nb, na, mid; | 693 | Int32 nb, na, mid; |
665 | nb = 0; | 694 | nb = 0; |
@@ -691,7 +720,8 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) | |||
691 | s->state_out_len--; | 720 | s->state_out_len--; |
692 | s->strm->next_out++; | 721 | s->strm->next_out++; |
693 | s->strm->avail_out--; | 722 | s->strm->avail_out--; |
694 | s->strm->total_out++; | 723 | s->strm->total_out_lo32++; |
724 | if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; | ||
695 | } | 725 | } |
696 | 726 | ||
697 | /* can a new run be started? */ | 727 | /* can a new run be started? */ |
@@ -736,7 +766,8 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) | |||
736 | s->state_out_len--; | 766 | s->state_out_len--; |
737 | s->strm->next_out++; | 767 | s->strm->next_out++; |
738 | s->strm->avail_out--; | 768 | s->strm->avail_out--; |
739 | s->strm->total_out++; | 769 | s->strm->total_out_lo32++; |
770 | if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; | ||
740 | } | 771 | } |
741 | 772 | ||
742 | /* can a new run be started? */ | 773 | /* can a new run be started? */ |
@@ -768,7 +799,7 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) | |||
768 | 799 | ||
769 | 800 | ||
770 | /*---------------------------------------------------*/ | 801 | /*---------------------------------------------------*/ |
771 | int BZ_API(bzDecompress) ( bz_stream *strm ) | 802 | int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) |
772 | { | 803 | { |
773 | DState* s; | 804 | DState* s; |
774 | if (strm == NULL) return BZ_PARAM_ERROR; | 805 | if (strm == NULL) return BZ_PARAM_ERROR; |
@@ -800,7 +831,7 @@ int BZ_API(bzDecompress) ( bz_stream *strm ) | |||
800 | } | 831 | } |
801 | } | 832 | } |
802 | if (s->state >= BZ_X_MAGIC_1) { | 833 | if (s->state >= BZ_X_MAGIC_1) { |
803 | Int32 r = decompress ( s ); | 834 | Int32 r = BZ2_decompress ( s ); |
804 | if (r == BZ_STREAM_END) { | 835 | if (r == BZ_STREAM_END) { |
805 | if (s->verbosity >= 3) | 836 | if (s->verbosity >= 3) |
806 | VPrintf2 ( "\n combined CRCs: stored = 0x%x, computed = 0x%x", | 837 | VPrintf2 ( "\n combined CRCs: stored = 0x%x, computed = 0x%x", |
@@ -820,7 +851,7 @@ int BZ_API(bzDecompress) ( bz_stream *strm ) | |||
820 | 851 | ||
821 | 852 | ||
822 | /*---------------------------------------------------*/ | 853 | /*---------------------------------------------------*/ |
823 | int BZ_API(bzDecompressEnd) ( bz_stream *strm ) | 854 | int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ) |
824 | { | 855 | { |
825 | DState* s; | 856 | DState* s; |
826 | if (strm == NULL) return BZ_PARAM_ERROR; | 857 | if (strm == NULL) return BZ_PARAM_ERROR; |
@@ -874,7 +905,7 @@ static Bool myfeof ( FILE* f ) | |||
874 | 905 | ||
875 | 906 | ||
876 | /*---------------------------------------------------*/ | 907 | /*---------------------------------------------------*/ |
877 | BZFILE* BZ_API(bzWriteOpen) | 908 | BZFILE* BZ_API(BZ2_bzWriteOpen) |
878 | ( int* bzerror, | 909 | ( int* bzerror, |
879 | FILE* f, | 910 | FILE* f, |
880 | int blockSize100k, | 911 | int blockSize100k, |
@@ -909,8 +940,8 @@ BZFILE* BZ_API(bzWriteOpen) | |||
909 | bzf->strm.opaque = NULL; | 940 | bzf->strm.opaque = NULL; |
910 | 941 | ||
911 | if (workFactor == 0) workFactor = 30; | 942 | if (workFactor == 0) workFactor = 30; |
912 | ret = bzCompressInit ( &(bzf->strm), blockSize100k, | 943 | ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, |
913 | verbosity, workFactor ); | 944 | verbosity, workFactor ); |
914 | if (ret != BZ_OK) | 945 | if (ret != BZ_OK) |
915 | { BZ_SETERR(ret); free(bzf); return NULL; }; | 946 | { BZ_SETERR(ret); free(bzf); return NULL; }; |
916 | 947 | ||
@@ -922,7 +953,7 @@ BZFILE* BZ_API(bzWriteOpen) | |||
922 | 953 | ||
923 | 954 | ||
924 | /*---------------------------------------------------*/ | 955 | /*---------------------------------------------------*/ |
925 | void BZ_API(bzWrite) | 956 | void BZ_API(BZ2_bzWrite) |
926 | ( int* bzerror, | 957 | ( int* bzerror, |
927 | BZFILE* b, | 958 | BZFILE* b, |
928 | void* buf, | 959 | void* buf, |
@@ -948,7 +979,7 @@ void BZ_API(bzWrite) | |||
948 | while (True) { | 979 | while (True) { |
949 | bzf->strm.avail_out = BZ_MAX_UNUSED; | 980 | bzf->strm.avail_out = BZ_MAX_UNUSED; |
950 | bzf->strm.next_out = bzf->buf; | 981 | bzf->strm.next_out = bzf->buf; |
951 | ret = bzCompress ( &(bzf->strm), BZ_RUN ); | 982 | ret = BZ2_bzCompress ( &(bzf->strm), BZ_RUN ); |
952 | if (ret != BZ_RUN_OK) | 983 | if (ret != BZ_RUN_OK) |
953 | { BZ_SETERR(ret); return; }; | 984 | { BZ_SETERR(ret); return; }; |
954 | 985 | ||
@@ -967,13 +998,27 @@ void BZ_API(bzWrite) | |||
967 | 998 | ||
968 | 999 | ||
969 | /*---------------------------------------------------*/ | 1000 | /*---------------------------------------------------*/ |
970 | void BZ_API(bzWriteClose) | 1001 | void BZ_API(BZ2_bzWriteClose) |
971 | ( int* bzerror, | 1002 | ( int* bzerror, |
972 | BZFILE* b, | 1003 | BZFILE* b, |
973 | int abandon, | 1004 | int abandon, |
974 | unsigned int* nbytes_in, | 1005 | unsigned int* nbytes_in, |
975 | unsigned int* nbytes_out ) | 1006 | unsigned int* nbytes_out ) |
976 | { | 1007 | { |
1008 | BZ2_bzWriteClose64 ( bzerror, b, abandon, | ||
1009 | nbytes_in, NULL, nbytes_out, NULL ); | ||
1010 | } | ||
1011 | |||
1012 | |||
1013 | void BZ_API(BZ2_bzWriteClose64) | ||
1014 | ( int* bzerror, | ||
1015 | BZFILE* b, | ||
1016 | int abandon, | ||
1017 | unsigned int* nbytes_in_lo32, | ||
1018 | unsigned int* nbytes_in_hi32, | ||
1019 | unsigned int* nbytes_out_lo32, | ||
1020 | unsigned int* nbytes_out_hi32 ) | ||
1021 | { | ||
977 | Int32 n, n2, ret; | 1022 | Int32 n, n2, ret; |
978 | bzFile* bzf = (bzFile*)b; | 1023 | bzFile* bzf = (bzFile*)b; |
979 | 1024 | ||
@@ -984,14 +1029,16 @@ void BZ_API(bzWriteClose) | |||
984 | if (ferror(bzf->handle)) | 1029 | if (ferror(bzf->handle)) |
985 | { BZ_SETERR(BZ_IO_ERROR); return; }; | 1030 | { BZ_SETERR(BZ_IO_ERROR); return; }; |
986 | 1031 | ||
987 | if (nbytes_in != NULL) *nbytes_in = 0; | 1032 | if (nbytes_in_lo32 != NULL) *nbytes_in_lo32 = 0; |
988 | if (nbytes_out != NULL) *nbytes_out = 0; | 1033 | if (nbytes_in_hi32 != NULL) *nbytes_in_hi32 = 0; |
1034 | if (nbytes_out_lo32 != NULL) *nbytes_out_lo32 = 0; | ||
1035 | if (nbytes_out_hi32 != NULL) *nbytes_out_hi32 = 0; | ||
989 | 1036 | ||
990 | if ((!abandon) && bzf->lastErr == BZ_OK) { | 1037 | if ((!abandon) && bzf->lastErr == BZ_OK) { |
991 | while (True) { | 1038 | while (True) { |
992 | bzf->strm.avail_out = BZ_MAX_UNUSED; | 1039 | bzf->strm.avail_out = BZ_MAX_UNUSED; |
993 | bzf->strm.next_out = bzf->buf; | 1040 | bzf->strm.next_out = bzf->buf; |
994 | ret = bzCompress ( &(bzf->strm), BZ_FINISH ); | 1041 | ret = BZ2_bzCompress ( &(bzf->strm), BZ_FINISH ); |
995 | if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END) | 1042 | if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END) |
996 | { BZ_SETERR(ret); return; }; | 1043 | { BZ_SETERR(ret); return; }; |
997 | 1044 | ||
@@ -1013,17 +1060,23 @@ void BZ_API(bzWriteClose) | |||
1013 | { BZ_SETERR(BZ_IO_ERROR); return; }; | 1060 | { BZ_SETERR(BZ_IO_ERROR); return; }; |
1014 | } | 1061 | } |
1015 | 1062 | ||
1016 | if (nbytes_in != NULL) *nbytes_in = bzf->strm.total_in; | 1063 | if (nbytes_in_lo32 != NULL) |
1017 | if (nbytes_out != NULL) *nbytes_out = bzf->strm.total_out; | 1064 | *nbytes_in_lo32 = bzf->strm.total_in_lo32; |
1065 | if (nbytes_in_hi32 != NULL) | ||
1066 | *nbytes_in_hi32 = bzf->strm.total_in_hi32; | ||
1067 | if (nbytes_out_lo32 != NULL) | ||
1068 | *nbytes_out_lo32 = bzf->strm.total_out_lo32; | ||
1069 | if (nbytes_out_hi32 != NULL) | ||
1070 | *nbytes_out_hi32 = bzf->strm.total_out_hi32; | ||
1018 | 1071 | ||
1019 | BZ_SETERR(BZ_OK); | 1072 | BZ_SETERR(BZ_OK); |
1020 | bzCompressEnd ( &(bzf->strm) ); | 1073 | BZ2_bzCompressEnd ( &(bzf->strm) ); |
1021 | free ( bzf ); | 1074 | free ( bzf ); |
1022 | } | 1075 | } |
1023 | 1076 | ||
1024 | 1077 | ||
1025 | /*---------------------------------------------------*/ | 1078 | /*---------------------------------------------------*/ |
1026 | BZFILE* BZ_API(bzReadOpen) | 1079 | BZFILE* BZ_API(BZ2_bzReadOpen) |
1027 | ( int* bzerror, | 1080 | ( int* bzerror, |
1028 | FILE* f, | 1081 | FILE* f, |
1029 | int verbosity, | 1082 | int verbosity, |
@@ -1066,7 +1119,7 @@ BZFILE* BZ_API(bzReadOpen) | |||
1066 | nUnused--; | 1119 | nUnused--; |
1067 | } | 1120 | } |
1068 | 1121 | ||
1069 | ret = bzDecompressInit ( &(bzf->strm), verbosity, small ); | 1122 | ret = BZ2_bzDecompressInit ( &(bzf->strm), verbosity, small ); |
1070 | if (ret != BZ_OK) | 1123 | if (ret != BZ_OK) |
1071 | { BZ_SETERR(ret); free(bzf); return NULL; }; | 1124 | { BZ_SETERR(ret); free(bzf); return NULL; }; |
1072 | 1125 | ||
@@ -1079,7 +1132,7 @@ BZFILE* BZ_API(bzReadOpen) | |||
1079 | 1132 | ||
1080 | 1133 | ||
1081 | /*---------------------------------------------------*/ | 1134 | /*---------------------------------------------------*/ |
1082 | void BZ_API(bzReadClose) ( int *bzerror, BZFILE *b ) | 1135 | void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b ) |
1083 | { | 1136 | { |
1084 | bzFile* bzf = (bzFile*)b; | 1137 | bzFile* bzf = (bzFile*)b; |
1085 | 1138 | ||
@@ -1091,13 +1144,13 @@ void BZ_API(bzReadClose) ( int *bzerror, BZFILE *b ) | |||
1091 | { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; | 1144 | { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; |
1092 | 1145 | ||
1093 | if (bzf->initialisedOk) | 1146 | if (bzf->initialisedOk) |
1094 | (void)bzDecompressEnd ( &(bzf->strm) ); | 1147 | (void)BZ2_bzDecompressEnd ( &(bzf->strm) ); |
1095 | free ( bzf ); | 1148 | free ( bzf ); |
1096 | } | 1149 | } |
1097 | 1150 | ||
1098 | 1151 | ||
1099 | /*---------------------------------------------------*/ | 1152 | /*---------------------------------------------------*/ |
1100 | int BZ_API(bzRead) | 1153 | int BZ_API(BZ2_bzRead) |
1101 | ( int* bzerror, | 1154 | ( int* bzerror, |
1102 | BZFILE* b, | 1155 | BZFILE* b, |
1103 | void* buf, | 1156 | void* buf, |
@@ -1135,7 +1188,7 @@ int BZ_API(bzRead) | |||
1135 | bzf->strm.next_in = bzf->buf; | 1188 | bzf->strm.next_in = bzf->buf; |
1136 | } | 1189 | } |
1137 | 1190 | ||
1138 | ret = bzDecompress ( &(bzf->strm) ); | 1191 | ret = BZ2_bzDecompress ( &(bzf->strm) ); |
1139 | 1192 | ||
1140 | if (ret != BZ_OK && ret != BZ_STREAM_END) | 1193 | if (ret != BZ_OK && ret != BZ_STREAM_END) |
1141 | { BZ_SETERR(ret); return 0; }; | 1194 | { BZ_SETERR(ret); return 0; }; |
@@ -1157,7 +1210,7 @@ int BZ_API(bzRead) | |||
1157 | 1210 | ||
1158 | 1211 | ||
1159 | /*---------------------------------------------------*/ | 1212 | /*---------------------------------------------------*/ |
1160 | void BZ_API(bzReadGetUnused) | 1213 | void BZ_API(BZ2_bzReadGetUnused) |
1161 | ( int* bzerror, | 1214 | ( int* bzerror, |
1162 | BZFILE* b, | 1215 | BZFILE* b, |
1163 | void** unused, | 1216 | void** unused, |
@@ -1183,7 +1236,7 @@ void BZ_API(bzReadGetUnused) | |||
1183 | /*---------------------------------------------------*/ | 1236 | /*---------------------------------------------------*/ |
1184 | 1237 | ||
1185 | /*---------------------------------------------------*/ | 1238 | /*---------------------------------------------------*/ |
1186 | int BZ_API(bzBuffToBuffCompress) | 1239 | int BZ_API(BZ2_bzBuffToBuffCompress) |
1187 | ( char* dest, | 1240 | ( char* dest, |
1188 | unsigned int* destLen, | 1241 | unsigned int* destLen, |
1189 | char* source, | 1242 | char* source, |
@@ -1206,8 +1259,8 @@ int BZ_API(bzBuffToBuffCompress) | |||
1206 | strm.bzalloc = NULL; | 1259 | strm.bzalloc = NULL; |
1207 | strm.bzfree = NULL; | 1260 | strm.bzfree = NULL; |
1208 | strm.opaque = NULL; | 1261 | strm.opaque = NULL; |
1209 | ret = bzCompressInit ( &strm, blockSize100k, | 1262 | ret = BZ2_bzCompressInit ( &strm, blockSize100k, |
1210 | verbosity, workFactor ); | 1263 | verbosity, workFactor ); |
1211 | if (ret != BZ_OK) return ret; | 1264 | if (ret != BZ_OK) return ret; |
1212 | 1265 | ||
1213 | strm.next_in = source; | 1266 | strm.next_in = source; |
@@ -1215,27 +1268,27 @@ int BZ_API(bzBuffToBuffCompress) | |||
1215 | strm.avail_in = sourceLen; | 1268 | strm.avail_in = sourceLen; |
1216 | strm.avail_out = *destLen; | 1269 | strm.avail_out = *destLen; |
1217 | 1270 | ||
1218 | ret = bzCompress ( &strm, BZ_FINISH ); | 1271 | ret = BZ2_bzCompress ( &strm, BZ_FINISH ); |
1219 | if (ret == BZ_FINISH_OK) goto output_overflow; | 1272 | if (ret == BZ_FINISH_OK) goto output_overflow; |
1220 | if (ret != BZ_STREAM_END) goto errhandler; | 1273 | if (ret != BZ_STREAM_END) goto errhandler; |
1221 | 1274 | ||
1222 | /* normal termination */ | 1275 | /* normal termination */ |
1223 | *destLen -= strm.avail_out; | 1276 | *destLen -= strm.avail_out; |
1224 | bzCompressEnd ( &strm ); | 1277 | BZ2_bzCompressEnd ( &strm ); |
1225 | return BZ_OK; | 1278 | return BZ_OK; |
1226 | 1279 | ||
1227 | output_overflow: | 1280 | output_overflow: |
1228 | bzCompressEnd ( &strm ); | 1281 | BZ2_bzCompressEnd ( &strm ); |
1229 | return BZ_OUTBUFF_FULL; | 1282 | return BZ_OUTBUFF_FULL; |
1230 | 1283 | ||
1231 | errhandler: | 1284 | errhandler: |
1232 | bzCompressEnd ( &strm ); | 1285 | BZ2_bzCompressEnd ( &strm ); |
1233 | return ret; | 1286 | return ret; |
1234 | } | 1287 | } |
1235 | 1288 | ||
1236 | 1289 | ||
1237 | /*---------------------------------------------------*/ | 1290 | /*---------------------------------------------------*/ |
1238 | int BZ_API(bzBuffToBuffDecompress) | 1291 | int BZ_API(BZ2_bzBuffToBuffDecompress) |
1239 | ( char* dest, | 1292 | ( char* dest, |
1240 | unsigned int* destLen, | 1293 | unsigned int* destLen, |
1241 | char* source, | 1294 | char* source, |
@@ -1255,7 +1308,7 @@ int BZ_API(bzBuffToBuffDecompress) | |||
1255 | strm.bzalloc = NULL; | 1308 | strm.bzalloc = NULL; |
1256 | strm.bzfree = NULL; | 1309 | strm.bzfree = NULL; |
1257 | strm.opaque = NULL; | 1310 | strm.opaque = NULL; |
1258 | ret = bzDecompressInit ( &strm, verbosity, small ); | 1311 | ret = BZ2_bzDecompressInit ( &strm, verbosity, small ); |
1259 | if (ret != BZ_OK) return ret; | 1312 | if (ret != BZ_OK) return ret; |
1260 | 1313 | ||
1261 | strm.next_in = source; | 1314 | strm.next_in = source; |
@@ -1263,26 +1316,26 @@ int BZ_API(bzBuffToBuffDecompress) | |||
1263 | strm.avail_in = sourceLen; | 1316 | strm.avail_in = sourceLen; |
1264 | strm.avail_out = *destLen; | 1317 | strm.avail_out = *destLen; |
1265 | 1318 | ||
1266 | ret = bzDecompress ( &strm ); | 1319 | ret = BZ2_bzDecompress ( &strm ); |
1267 | if (ret == BZ_OK) goto output_overflow_or_eof; | 1320 | if (ret == BZ_OK) goto output_overflow_or_eof; |
1268 | if (ret != BZ_STREAM_END) goto errhandler; | 1321 | if (ret != BZ_STREAM_END) goto errhandler; |
1269 | 1322 | ||
1270 | /* normal termination */ | 1323 | /* normal termination */ |
1271 | *destLen -= strm.avail_out; | 1324 | *destLen -= strm.avail_out; |
1272 | bzDecompressEnd ( &strm ); | 1325 | BZ2_bzDecompressEnd ( &strm ); |
1273 | return BZ_OK; | 1326 | return BZ_OK; |
1274 | 1327 | ||
1275 | output_overflow_or_eof: | 1328 | output_overflow_or_eof: |
1276 | if (strm.avail_out > 0) { | 1329 | if (strm.avail_out > 0) { |
1277 | bzDecompressEnd ( &strm ); | 1330 | BZ2_bzDecompressEnd ( &strm ); |
1278 | return BZ_UNEXPECTED_EOF; | 1331 | return BZ_UNEXPECTED_EOF; |
1279 | } else { | 1332 | } else { |
1280 | bzDecompressEnd ( &strm ); | 1333 | BZ2_bzDecompressEnd ( &strm ); |
1281 | return BZ_OUTBUFF_FULL; | 1334 | return BZ_OUTBUFF_FULL; |
1282 | }; | 1335 | }; |
1283 | 1336 | ||
1284 | errhandler: | 1337 | errhandler: |
1285 | bzDecompressEnd ( &strm ); | 1338 | BZ2_bzDecompressEnd ( &strm ); |
1286 | return ret; | 1339 | return ret; |
1287 | } | 1340 | } |
1288 | 1341 | ||
@@ -1303,7 +1356,7 @@ int BZ_API(bzBuffToBuffDecompress) | |||
1303 | /*-- | 1356 | /*-- |
1304 | return version like "0.9.0c". | 1357 | return version like "0.9.0c". |
1305 | --*/ | 1358 | --*/ |
1306 | const char * BZ_API(bzlibVersion)(void) | 1359 | const char * BZ_API(BZ2_bzlibVersion)(void) |
1307 | { | 1360 | { |
1308 | return BZ_VERSION; | 1361 | return BZ_VERSION; |
1309 | } | 1362 | } |
@@ -1377,9 +1430,11 @@ BZFILE * bzopen_or_bzdopen | |||
1377 | /* Guard against total chaos and anarchy -- JRS */ | 1430 | /* Guard against total chaos and anarchy -- JRS */ |
1378 | if (blockSize100k < 1) blockSize100k = 1; | 1431 | if (blockSize100k < 1) blockSize100k = 1; |
1379 | if (blockSize100k > 9) blockSize100k = 9; | 1432 | if (blockSize100k > 9) blockSize100k = 9; |
1380 | bzfp = bzWriteOpen(&bzerr,fp,blockSize100k,verbosity,workFactor); | 1433 | bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k, |
1434 | verbosity,workFactor); | ||
1381 | } else { | 1435 | } else { |
1382 | bzfp = bzReadOpen(&bzerr,fp,verbosity,smallMode,unused,nUnused); | 1436 | bzfp = BZ2_bzReadOpen(&bzerr,fp,verbosity,smallMode, |
1437 | unused,nUnused); | ||
1383 | } | 1438 | } |
1384 | if (bzfp == NULL) { | 1439 | if (bzfp == NULL) { |
1385 | if (fp != stdin && fp != stdout) fclose(fp); | 1440 | if (fp != stdin && fp != stdout) fclose(fp); |
@@ -1395,7 +1450,7 @@ BZFILE * bzopen_or_bzdopen | |||
1395 | ex) bzopen("file","w9") | 1450 | ex) bzopen("file","w9") |
1396 | case path="" or NULL => use stdin or stdout. | 1451 | case path="" or NULL => use stdin or stdout. |
1397 | --*/ | 1452 | --*/ |
1398 | BZFILE * BZ_API(bzopen) | 1453 | BZFILE * BZ_API(BZ2_bzopen) |
1399 | ( const char *path, | 1454 | ( const char *path, |
1400 | const char *mode ) | 1455 | const char *mode ) |
1401 | { | 1456 | { |
@@ -1404,7 +1459,7 @@ BZFILE * BZ_API(bzopen) | |||
1404 | 1459 | ||
1405 | 1460 | ||
1406 | /*---------------------------------------------------*/ | 1461 | /*---------------------------------------------------*/ |
1407 | BZFILE * BZ_API(bzdopen) | 1462 | BZFILE * BZ_API(BZ2_bzdopen) |
1408 | ( int fd, | 1463 | ( int fd, |
1409 | const char *mode ) | 1464 | const char *mode ) |
1410 | { | 1465 | { |
@@ -1413,11 +1468,11 @@ BZFILE * BZ_API(bzdopen) | |||
1413 | 1468 | ||
1414 | 1469 | ||
1415 | /*---------------------------------------------------*/ | 1470 | /*---------------------------------------------------*/ |
1416 | int BZ_API(bzread) (BZFILE* b, void* buf, int len ) | 1471 | int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len ) |
1417 | { | 1472 | { |
1418 | int bzerr, nread; | 1473 | int bzerr, nread; |
1419 | if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0; | 1474 | if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0; |
1420 | nread = bzRead(&bzerr,b,buf,len); | 1475 | nread = BZ2_bzRead(&bzerr,b,buf,len); |
1421 | if (bzerr == BZ_OK || bzerr == BZ_STREAM_END) { | 1476 | if (bzerr == BZ_OK || bzerr == BZ_STREAM_END) { |
1422 | return nread; | 1477 | return nread; |
1423 | } else { | 1478 | } else { |
@@ -1427,11 +1482,11 @@ int BZ_API(bzread) (BZFILE* b, void* buf, int len ) | |||
1427 | 1482 | ||
1428 | 1483 | ||
1429 | /*---------------------------------------------------*/ | 1484 | /*---------------------------------------------------*/ |
1430 | int BZ_API(bzwrite) (BZFILE* b, void* buf, int len ) | 1485 | int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len ) |
1431 | { | 1486 | { |
1432 | int bzerr; | 1487 | int bzerr; |
1433 | 1488 | ||
1434 | bzWrite(&bzerr,b,buf,len); | 1489 | BZ2_bzWrite(&bzerr,b,buf,len); |
1435 | if(bzerr == BZ_OK){ | 1490 | if(bzerr == BZ_OK){ |
1436 | return len; | 1491 | return len; |
1437 | }else{ | 1492 | }else{ |
@@ -1441,7 +1496,7 @@ int BZ_API(bzwrite) (BZFILE* b, void* buf, int len ) | |||
1441 | 1496 | ||
1442 | 1497 | ||
1443 | /*---------------------------------------------------*/ | 1498 | /*---------------------------------------------------*/ |
1444 | int BZ_API(bzflush) (BZFILE *b) | 1499 | int BZ_API(BZ2_bzflush) (BZFILE *b) |
1445 | { | 1500 | { |
1446 | /* do nothing now... */ | 1501 | /* do nothing now... */ |
1447 | return 0; | 1502 | return 0; |
@@ -1449,19 +1504,19 @@ int BZ_API(bzflush) (BZFILE *b) | |||
1449 | 1504 | ||
1450 | 1505 | ||
1451 | /*---------------------------------------------------*/ | 1506 | /*---------------------------------------------------*/ |
1452 | void BZ_API(bzclose) (BZFILE* b) | 1507 | void BZ_API(BZ2_bzclose) (BZFILE* b) |
1453 | { | 1508 | { |
1454 | int bzerr; | 1509 | int bzerr; |
1455 | FILE *fp = ((bzFile *)b)->handle; | 1510 | FILE *fp = ((bzFile *)b)->handle; |
1456 | 1511 | ||
1457 | if (b==NULL) {return;} | 1512 | if (b==NULL) {return;} |
1458 | if(((bzFile*)b)->writing){ | 1513 | if(((bzFile*)b)->writing){ |
1459 | bzWriteClose(&bzerr,b,0,NULL,NULL); | 1514 | BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL); |
1460 | if(bzerr != BZ_OK){ | 1515 | if(bzerr != BZ_OK){ |
1461 | bzWriteClose(NULL,b,1,NULL,NULL); | 1516 | BZ2_bzWriteClose(NULL,b,1,NULL,NULL); |
1462 | } | 1517 | } |
1463 | }else{ | 1518 | }else{ |
1464 | bzReadClose(&bzerr,b); | 1519 | BZ2_bzReadClose(&bzerr,b); |
1465 | } | 1520 | } |
1466 | if(fp!=stdin && fp!=stdout){ | 1521 | if(fp!=stdin && fp!=stdout){ |
1467 | fclose(fp); | 1522 | fclose(fp); |
@@ -1483,6 +1538,7 @@ static char *bzerrorstrings[] = { | |||
1483 | ,"IO_ERROR" | 1538 | ,"IO_ERROR" |
1484 | ,"UNEXPECTED_EOF" | 1539 | ,"UNEXPECTED_EOF" |
1485 | ,"OUTBUFF_FULL" | 1540 | ,"OUTBUFF_FULL" |
1541 | ,"CONFIG_ERROR" | ||
1486 | ,"???" /* for future */ | 1542 | ,"???" /* for future */ |
1487 | ,"???" /* for future */ | 1543 | ,"???" /* for future */ |
1488 | ,"???" /* for future */ | 1544 | ,"???" /* for future */ |
@@ -1492,7 +1548,7 @@ static char *bzerrorstrings[] = { | |||
1492 | }; | 1548 | }; |
1493 | 1549 | ||
1494 | 1550 | ||
1495 | const char * BZ_API(bzerror) (BZFILE *b, int *errnum) | 1551 | const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum) |
1496 | { | 1552 | { |
1497 | int err = ((bzFile *)b)->lastErr; | 1553 | int err = ((bzFile *)b)->lastErr; |
1498 | 1554 | ||