diff options
author | Julian Seward <jseward@acm.org> | 2006-12-20 22:13:13 +0100 |
---|---|---|
committer | Julian Seward <jseward@acm.org> | 2006-12-20 22:13:13 +0100 |
commit | f10a33538e9bab6deb61779b3d8aae168824ef48 (patch) | |
tree | ecd1c2ed553ced58a090e0d8b7b7a20bb7c95c80 /bzlib.c | |
parent | 4d540bfc95a4b0eefc1d1f388ec33534aaeb3a2f (diff) | |
download | bzip2-f10a33538e9bab6deb61779b3d8aae168824ef48.tar.gz bzip2-f10a33538e9bab6deb61779b3d8aae168824ef48.tar.bz2 bzip2-f10a33538e9bab6deb61779b3d8aae168824ef48.zip |
bzip2-1.0.4bzip2-1.0.4
Diffstat (limited to 'bzlib.c')
-rw-r--r-- | bzlib.c | 95 |
1 files changed, 25 insertions, 70 deletions
@@ -4,74 +4,29 @@ | |||
4 | /*--- bzlib.c ---*/ | 4 | /*--- bzlib.c ---*/ |
5 | /*-------------------------------------------------------------*/ | 5 | /*-------------------------------------------------------------*/ |
6 | 6 | ||
7 | /*-- | 7 | /* ------------------------------------------------------------------ |
8 | This file is a part of bzip2 and/or libbzip2, a program and | 8 | This file is part of bzip2/libbzip2, a program and library for |
9 | library for lossless, block-sorting data compression. | 9 | lossless, block-sorting data compression. |
10 | |||
11 | Copyright (C) 1996-2005 Julian R Seward. All rights reserved. | ||
12 | |||
13 | Redistribution and use in source and binary forms, with or without | ||
14 | modification, are permitted provided that the following conditions | ||
15 | are met: | ||
16 | |||
17 | 1. Redistributions of source code must retain the above copyright | ||
18 | notice, this list of conditions and the following disclaimer. | ||
19 | |||
20 | 2. The origin of this software must not be misrepresented; you must | ||
21 | not claim that you wrote the original software. If you use this | ||
22 | software in a product, an acknowledgment in the product | ||
23 | documentation would be appreciated but is not required. | ||
24 | |||
25 | 3. Altered source versions must be plainly marked as such, and must | ||
26 | not be misrepresented as being the original software. | ||
27 | |||
28 | 4. The name of the author may not be used to endorse or promote | ||
29 | products derived from this software without specific prior written | ||
30 | permission. | ||
31 | |||
32 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS | ||
33 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
34 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
35 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
36 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
37 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
38 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
39 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
40 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
41 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
42 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
43 | |||
44 | Julian Seward, Cambridge, UK. | ||
45 | jseward@bzip.org | ||
46 | bzip2/libbzip2 version 1.0 of 21 March 2000 | ||
47 | |||
48 | This program is based on (at least) the work of: | ||
49 | Mike Burrows | ||
50 | David Wheeler | ||
51 | Peter Fenwick | ||
52 | Alistair Moffat | ||
53 | Radford Neal | ||
54 | Ian H. Witten | ||
55 | Robert Sedgewick | ||
56 | Jon L. Bentley | ||
57 | |||
58 | For more information on these sources, see the manual. | ||
59 | --*/ | ||
60 | 10 | ||
61 | /*-- | 11 | bzip2/libbzip2 version 1.0.4 of 20 December 2006 |
62 | CHANGES | 12 | Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org> |
63 | ~~~~~~~ | ||
64 | 0.9.0 -- original version. | ||
65 | 13 | ||
66 | 0.9.0a/b -- no changes in this file. | 14 | Please read the WARNING, DISCLAIMER and PATENTS sections in the |
15 | README file. | ||
67 | 16 | ||
68 | 0.9.0c | 17 | This program is released under the terms of the license contained |
69 | * made zero-length BZ_FLUSH work correctly in bzCompress(). | 18 | in the file LICENSE. |
70 | * fixed bzWrite/bzRead to ignore zero-length requests. | 19 | ------------------------------------------------------------------ */ |
71 | * fixed bzread to correctly handle read requests after EOF. | 20 | |
72 | * wrong parameter order in call to bzDecompressInit in | 21 | /* CHANGES |
73 | bzBuffToBuffDecompress. Fixed. | 22 | 0.9.0 -- original version. |
74 | --*/ | 23 | 0.9.0a/b -- no changes in this file. |
24 | 0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress(). | ||
25 | fixed bzWrite/bzRead to ignore zero-length requests. | ||
26 | fixed bzread to correctly handle read requests after EOF. | ||
27 | wrong parameter order in call to bzDecompressInit in | ||
28 | bzBuffToBuffDecompress. Fixed. | ||
29 | */ | ||
75 | 30 | ||
76 | #include "bzlib_private.h" | 31 | #include "bzlib_private.h" |
77 | 32 | ||
@@ -1394,8 +1349,7 @@ int BZ_API(BZ2_bzBuffToBuffDecompress) | |||
1394 | 1349 | ||
1395 | /*---------------------------------------------------*/ | 1350 | /*---------------------------------------------------*/ |
1396 | /*-- | 1351 | /*-- |
1397 | Code contributed by Yoshioka Tsuneo | 1352 | Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) |
1398 | (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp), | ||
1399 | to support better zlib compatibility. | 1353 | to support better zlib compatibility. |
1400 | This code is not _officially_ part of libbzip2 (yet); | 1354 | This code is not _officially_ part of libbzip2 (yet); |
1401 | I haven't tested it, documented it, or considered the | 1355 | I haven't tested it, documented it, or considered the |
@@ -1406,7 +1360,7 @@ int BZ_API(BZ2_bzBuffToBuffDecompress) | |||
1406 | 1360 | ||
1407 | /*---------------------------------------------------*/ | 1361 | /*---------------------------------------------------*/ |
1408 | /*-- | 1362 | /*-- |
1409 | return version like "0.9.0c". | 1363 | return version like "0.9.5d, 4-Sept-1999". |
1410 | --*/ | 1364 | --*/ |
1411 | const char * BZ_API(BZ2_bzlibVersion)(void) | 1365 | const char * BZ_API(BZ2_bzlibVersion)(void) |
1412 | { | 1366 | { |
@@ -1559,9 +1513,10 @@ int BZ_API(BZ2_bzflush) (BZFILE *b) | |||
1559 | void BZ_API(BZ2_bzclose) (BZFILE* b) | 1513 | void BZ_API(BZ2_bzclose) (BZFILE* b) |
1560 | { | 1514 | { |
1561 | int bzerr; | 1515 | int bzerr; |
1562 | FILE *fp = ((bzFile *)b)->handle; | 1516 | FILE *fp; |
1563 | 1517 | ||
1564 | if (b==NULL) {return;} | 1518 | if (b==NULL) {return;} |
1519 | fp = ((bzFile *)b)->handle; | ||
1565 | if(((bzFile*)b)->writing){ | 1520 | if(((bzFile*)b)->writing){ |
1566 | BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL); | 1521 | BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL); |
1567 | if(bzerr != BZ_OK){ | 1522 | if(bzerr != BZ_OK){ |
@@ -1580,7 +1535,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b) | |||
1580 | /*-- | 1535 | /*-- |
1581 | return last error code | 1536 | return last error code |
1582 | --*/ | 1537 | --*/ |
1583 | static char *bzerrorstrings[] = { | 1538 | static const char *bzerrorstrings[] = { |
1584 | "OK" | 1539 | "OK" |
1585 | ,"SEQUENCE_ERROR" | 1540 | ,"SEQUENCE_ERROR" |
1586 | ,"PARAM_ERROR" | 1541 | ,"PARAM_ERROR" |