Virgin import (trimmed) of Bzip2 version 1.0.4.

This commit is contained in:
Xin LI 2007-03-28 07:35:07 +00:00
parent f7a4f99f70
commit 1b79bae0f8
30 changed files with 2645 additions and 2970 deletions

View File

@ -1,3 +1,16 @@
------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------
0.9.0 0.9.0
@ -261,7 +274,7 @@ Fixes some minor bugs since the last version, 1.0.2.
decompressor to crash, loop or access memory which does not decompressor to crash, loop or access memory which does not
belong to it. If you are using bzip2 or the library to belong to it. If you are using bzip2 or the library to
decompress bitstreams from untrusted sources, an upgrade decompress bitstreams from untrusted sources, an upgrade
to 1.0.3 is recommended. to 1.0.3 is recommended. This fixes CAN-2005-1260.
* The documentation has been converted to XML, from which html * The documentation has been converted to XML, from which html
and pdf can be derived. and pdf can be derived.
@ -273,3 +286,29 @@ Fixes some minor bugs since the last version, 1.0.2.
* The BZ_NO_STDIO cpp symbol was not properly observed in 1.0.2. * The BZ_NO_STDIO cpp symbol was not properly observed in 1.0.2.
This has been fixed. This has been fixed.
1.0.4 (20 Dec 06)
~~~~~~~~~~~~~~~~~
Fixes some minor bugs since the last version, 1.0.3.
* Fix file permissions race problem (CAN-2005-0953).
* Avoid possible segfault in BZ2_bzclose. From Coverity's NetBSD
scan.
* 'const'/prototype cleanups in the C code.
* Change default install location to /usr/local, and handle multiple
'make install's without error.
* Sanitise file names more carefully in bzgrep. Fixes CAN-2005-0758
to the extent that applies to bzgrep.
* Use 'mktemp' rather than 'tempfile' in bzdiff.
* Tighten up a couple of assertions in blocksort.c following automated
analysis.
* Fix minor doc/comment bugs.

View File

@ -1,6 +1,8 @@
--------------------------------------------------------------------------
This program, "bzip2", the associated library "libbzip2", and all This program, "bzip2", the associated library "libbzip2", and all
documentation, are copyright (C) 1996-2005 Julian R Seward. All documentation, are copyright (C) 1996-2006 Julian R Seward. All
rights reserved. rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@ -35,6 +37,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK. Julian Seward, Cambridge, UK.
jseward@acm.org jseward@bzip.org
bzip2/libbzip2 version 1.0.3 of 15 February 2005 bzip2/libbzip2 version 1.0.4 of 20 December 2006
--------------------------------------------------------------------------

View File

@ -1,3 +1,16 @@
# ------------------------------------------------------------------
# This file is part of bzip2/libbzip2, a program and library for
# lossless, block-sorting data compression.
#
# bzip2/libbzip2 version 1.0.4 of 20 December 2006
# Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
#
# Please read the WARNING, DISCLAIMER and PATENTS sections in the
# README file.
#
# This program is released under the terms of the license contained
# in the file LICENSE.
# ------------------------------------------------------------------
SHELL=/bin/sh SHELL=/bin/sh
@ -8,10 +21,10 @@ RANLIB=ranlib
LDFLAGS= LDFLAGS=
BIGFILES=-D_FILE_OFFSET_BITS=64 BIGFILES=-D_FILE_OFFSET_BITS=64
CFLAGS=-Wall -Winline -O -g $(BIGFILES) CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
# Where you want it installed when you do 'make install' # Where you want it installed when you do 'make install'
PREFIX=/usr PREFIX=/usr/local
OBJS= blocksort.o \ OBJS= blocksort.o \
@ -77,14 +90,14 @@ install: bzip2 bzip2recover
cp -f libbz2.a $(PREFIX)/lib cp -f libbz2.a $(PREFIX)/lib
chmod a+r $(PREFIX)/lib/libbz2.a chmod a+r $(PREFIX)/lib/libbz2.a
cp -f bzgrep $(PREFIX)/bin/bzgrep cp -f bzgrep $(PREFIX)/bin/bzgrep
ln $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep
ln $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep
chmod a+x $(PREFIX)/bin/bzgrep chmod a+x $(PREFIX)/bin/bzgrep
cp -f bzmore $(PREFIX)/bin/bzmore cp -f bzmore $(PREFIX)/bin/bzmore
ln $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless ln -s -f $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless
chmod a+x $(PREFIX)/bin/bzmore chmod a+x $(PREFIX)/bin/bzmore
cp -f bzdiff $(PREFIX)/bin/bzdiff cp -f bzdiff $(PREFIX)/bin/bzdiff
ln $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp ln -s -f $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp
chmod a+x $(PREFIX)/bin/bzdiff chmod a+x $(PREFIX)/bin/bzdiff
cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1 cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1
chmod a+r $(PREFIX)/man/man1/bzgrep.1 chmod a+r $(PREFIX)/man/man1/bzgrep.1
@ -124,10 +137,10 @@ bzip2recover.o: bzip2recover.c
distclean: clean distclean: clean
rm -f manual.ps manual.html manual.pdf rm -f manual.ps manual.html manual.pdf
DISTNAME=bzip2-1.0.3 DISTNAME=bzip2-1.0.4
dist: check manual dist: check manual
rm -f $(DISTNAME) rm -f $(DISTNAME)
ln -sf . $(DISTNAME) ln -s -f . $(DISTNAME)
tar cvf $(DISTNAME).tar \ tar cvf $(DISTNAME).tar \
$(DISTNAME)/blocksort.c \ $(DISTNAME)/blocksort.c \
$(DISTNAME)/huffman.c \ $(DISTNAME)/huffman.c \
@ -167,7 +180,6 @@ dist: check manual
$(DISTNAME)/libbz2.dsp \ $(DISTNAME)/libbz2.dsp \
$(DISTNAME)/dlltest.dsp \ $(DISTNAME)/dlltest.dsp \
$(DISTNAME)/makefile.msc \ $(DISTNAME)/makefile.msc \
$(DISTNAME)/Y2K_INFO \
$(DISTNAME)/unzcrash.c \ $(DISTNAME)/unzcrash.c \
$(DISTNAME)/spewG.c \ $(DISTNAME)/spewG.c \
$(DISTNAME)/mk251.c \ $(DISTNAME)/mk251.c \

View File

@ -1,15 +1,30 @@
# This Makefile builds a shared version of the library, # This Makefile builds a shared version of the library,
# libbz2.so.1.0.3, with soname libbz2.so.1.0, # libbz2.so.1.0.4, with soname libbz2.so.1.0,
# at least on x86-Linux (RedHat 7.2), # at least on x86-Linux (RedHat 7.2),
# with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98). # with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98).
# Please see the README file for some # Please see the README file for some important info
# important info about building the library like this. # about building the library like this.
# ------------------------------------------------------------------
# This file is part of bzip2/libbzip2, a program and library for
# lossless, block-sorting data compression.
#
# bzip2/libbzip2 version 1.0.4 of 20 December 2006
# Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
#
# Please read the WARNING, DISCLAIMER and PATENTS sections in the
# README file.
#
# This program is released under the terms of the license contained
# in the file LICENSE.
# ------------------------------------------------------------------
SHELL=/bin/sh SHELL=/bin/sh
CC=gcc CC=gcc
BIGFILES=-D_FILE_OFFSET_BITS=64 BIGFILES=-D_FILE_OFFSET_BITS=64
CFLAGS=-fpic -fPIC -Wall -Winline -O -g CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
OBJS= blocksort.o \ OBJS= blocksort.o \
huffman.o \ huffman.o \
@ -20,13 +35,13 @@ OBJS= blocksort.o \
bzlib.o bzlib.o
all: $(OBJS) all: $(OBJS)
$(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.3 $(OBJS) $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.4 $(OBJS)
$(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.3 $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.4
rm -f libbz2.so.1.0 rm -f libbz2.so.1.0
ln -s libbz2.so.1.0.3 libbz2.so.1.0 ln -s libbz2.so.1.0.4 libbz2.so.1.0
clean: clean:
rm -f $(OBJS) bzip2.o libbz2.so.1.0.3 libbz2.so.1.0 bzip2-shared rm -f $(OBJS) bzip2.o libbz2.so.1.0.4 libbz2.so.1.0 bzip2-shared
blocksort.o: blocksort.c blocksort.o: blocksort.c
$(CC) $(CFLAGS) -c blocksort.c $(CC) $(CFLAGS) -c blocksort.c

View File

@ -1,33 +1,48 @@
This is the README for bzip2, a block-sorting file compressor, version This is the README for bzip2/libzip2.
1.0.3. This version is fully compatible with the previous public This version is fully compatible with the previous public releases.
releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and 1.0.2.
bzip2-1.0.3 is distributed under a BSD-style license. For details, ------------------------------------------------------------------
see the file LICENSE. This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in this file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------
Complete documentation is available in Postscript form (manual.ps), Complete documentation is available in Postscript form (manual.ps),
PDF (manual.pdf) or html (manual.html). A plain-text version of the PDF (manual.pdf) or html (manual.html). A plain-text version of the
manual page is available as bzip2.txt. A statement about Y2K issues manual page is available as bzip2.txt.
is now included in the file Y2K_INFO.
HOW TO BUILD -- UNIX HOW TO BUILD -- UNIX
Type `make'. This builds the library libbz2.a and then the Type 'make'. This builds the library libbz2.a and then the programs
programs bzip2 and bzip2recover. Six self-tests are run. bzip2 and bzip2recover. Six self-tests are run. If the self-tests
If the self-tests complete ok, carry on to installation: complete ok, carry on to installation:
To install in /usr/local/bin, /usr/local/lib, /usr/local/man and
/usr/local/include, type
To install in /usr/bin, /usr/lib, /usr/man and /usr/include, type
make install make install
To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type
To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type
make install PREFIX=/xxx/yyy make install PREFIX=/xxx/yyy
If you are (justifiably) paranoid and want to see what 'make install' If you are (justifiably) paranoid and want to see what 'make install'
is going to do, you can first do is going to do, you can first do
make -n install or make -n install or
make -n install PREFIX=/xxx/yyy respectively. make -n install PREFIX=/xxx/yyy respectively.
The -n instructs make to show the commands it would execute, but
not actually execute them. The -n instructs make to show the commands it would execute, but not
actually execute them.
HOW TO BUILD -- UNIX, shared library libbz2.so. HOW TO BUILD -- UNIX, shared library libbz2.so.
@ -49,23 +64,25 @@ Important note for people upgrading .so's from 0.9.0/0.9.5 to version
bzCompress to BZ2_bzCompress, to avoid namespace pollution. bzCompress to BZ2_bzCompress, to avoid namespace pollution.
Unfortunately this means that the libbz2.so created by Unfortunately this means that the libbz2.so created by
Makefile-libbz2_so will not work with any program which used an older Makefile-libbz2_so will not work with any program which used an older
version of the library. Sorry. I do encourage library clients to version of the library. I do encourage library clients to make the
make the effort to upgrade to use version 1.0, since it is both faster effort to upgrade to use version 1.0, since it is both faster and more
and more robust than previous versions. robust than previous versions.
HOW TO BUILD -- Windows 95, NT, DOS, Mac, etc. HOW TO BUILD -- Windows 95, NT, DOS, Mac, etc.
It's difficult for me to support compilation on all these platforms. It's difficult for me to support compilation on all these platforms.
My approach is to collect binaries for these platforms, and put them My approach is to collect binaries for these platforms, and put them
on the master web page (http://sources.redhat.com/bzip2). Look there. on the master web site (http://www.bzip.org). Look there. However
However (FWIW), bzip2-1.0.X is very standard ANSI C and should compile (FWIW), bzip2-1.0.X is very standard ANSI C and should compile
unmodified with MS Visual C. If you have difficulties building, you unmodified with MS Visual C. If you have difficulties building, you
might want to read README.COMPILATION.PROBLEMS. might want to read README.COMPILATION.PROBLEMS.
At least using MS Visual C++ 6, you can build from the unmodified At least using MS Visual C++ 6, you can build from the unmodified
sources by issuing, in a command shell: sources by issuing, in a command shell:
nmake -f makefile.msc nmake -f makefile.msc
(you may need to first run the MSVC-provided script VCVARS32.BAT (you may need to first run the MSVC-provided script VCVARS32.BAT
so as to set up paths to the MSVC tools correctly). so as to set up paths to the MSVC tools correctly).
@ -86,18 +103,19 @@ Please read and be aware of the following:
WARNING: WARNING:
This program (attempts to) compress data by performing several This program and library (attempts to) compress data by
non-trivial transformations on it. Unless you are 100% familiar performing several non-trivial transformations on it.
with *all* the algorithms contained herein, and with the Unless you are 100% familiar with *all* the algorithms
consequences of modifying them, you should NOT meddle with the contained herein, and with the consequences of modifying them,
compression or decompression machinery. Incorrect changes can and you should NOT meddle with the compression or decompression
very likely *will* lead to disastrous loss of data. machinery. Incorrect changes can and very likely *will*
lead to disastrous loss of data.
DISCLAIMER: DISCLAIMER:
I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE
USE OF THIS PROGRAM, HOWSOEVER CAUSED. USE OF THIS PROGRAM/LIBRARY, HOWSOEVER CAUSED.
Every compression of a file implies an assumption that the Every compression of a file implies an assumption that the
compressed file can be decompressed to reproduce the original. compressed file can be decompressed to reproduce the original.
@ -110,19 +128,18 @@ DISCLAIMER:
PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER
SMALL, THAT THE DATA WILL NOT BE RECOVERABLE. SMALL, THAT THE DATA WILL NOT BE RECOVERABLE.
That is not to say this program is inherently unreliable. Indeed, That is not to say this program is inherently unreliable.
I very much hope the opposite is true. bzip2 has been carefully Indeed, I very much hope the opposite is true. bzip2/libbzip2
constructed and extensively tested. has been carefully constructed and extensively tested.
PATENTS: PATENTS:
To the best of my knowledge, bzip2 does not use any patented To the best of my knowledge, bzip2/libbzip2 does not use any
algorithms. However, I do not have the resources to carry out patented algorithms. However, I do not have the resources
a patent search. Therefore I cannot give any guarantee of the to carry out a patent search. Therefore I cannot give any
above statement. guarantee of the above statement.
End of legalities.
WHAT'S NEW IN 0.9.0 (as compared to 0.1pl2) ? WHAT'S NEW IN 0.9.0 (as compared to 0.1pl2) ?
@ -156,21 +173,23 @@ WHAT'S NEW IN 1.0.3 ?
See the CHANGES file. See the CHANGES file.
WHAT'S NEW IN 1.0.4 ?
See the CHANGES file.
I hope you find bzip2 useful. Feel free to contact me at I hope you find bzip2 useful. Feel free to contact me at
jseward@bzip.org jseward@bzip.org
if you have any suggestions or queries. Many people mailed me with if you have any suggestions or queries. Many people mailed me with
comments, suggestions and patches after the releases of bzip-0.15, comments, suggestions and patches after the releases of bzip-0.15,
bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1,
1.0.2, and the changes in bzip2 are largely a result of this feedback. 1.0.2 and 1.0.3, and the changes in bzip2 are largely a result of this
I thank you for your comments. feedback. I thank you for your comments.
At least for the time being, bzip2's "home" is (or can be reached via) bzip2's "home" is http://www.bzip.org/
http://www.bzip.org
Julian Seward Julian Seward
jseward@bzip.org jseward@bzip.org
Cambridge, UK. Cambridge, UK.
18 July 1996 (version 0.15) 18 July 1996 (version 0.15)
@ -183,3 +202,4 @@ Cambridge, UK.
5 May 2000 (bzip2, version 1.0pre8) 5 May 2000 (bzip2, version 1.0pre8)
30 December 2001 (bzip2, version 1.0.2pre1) 30 December 2001 (bzip2, version 1.0.2pre1)
15 February 2005 (bzip2, version 1.0.3) 15 February 2005 (bzip2, version 1.0.3)
20 December 2006 (bzip2, version 1.0.4)

View File

@ -1,32 +1,47 @@
------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2-1.0.3 should compile without problems on the vast majority of bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------
bzip2-1.0.4 should compile without problems on the vast majority of
platforms. Using the supplied Makefile, I've built and tested it platforms. Using the supplied Makefile, I've built and tested it
myself for x86-linux and x86_64-linux. With makefile.msc, Visual C++ myself for x86-linux and amd64-linux. With makefile.msc, Visual C++
6.0 and nmake, you can build a native Win32 version too. Large file 6.0 and nmake, you can build a native Win32 version too. Large file
support seems to work correctly on at least alpha-tru64unix and support seems to work correctly on at least on amd64-linux.
x86-cygwin32 (on Windows 2000).
When I say "large file" I mean a file of size 2,147,483,648 (2^31) When I say "large file" I mean a file of size 2,147,483,648 (2^31)
bytes or above. Many older OSs can't handle files above this size, bytes or above. Many older OSs can't handle files above this size,
but many newer ones can. Large files are pretty huge -- most files but many newer ones can. Large files are pretty huge -- most files
you'll encounter are not Large Files. you'll encounter are not Large Files.
Earlier versions of bzip2 (0.1, 0.9.0, 0.9.5) compiled on a wide Early versions of bzip2 (0.1, 0.9.0, 0.9.5) compiled on a wide variety
variety of platforms without difficulty, and I hope this version will of platforms without difficulty, and I hope this version will continue
continue in that tradition. However, in order to support large files, in that tradition. However, in order to support large files, I've had
I've had to include the define -D_FILE_OFFSET_BITS=64 in the Makefile. to include the define -D_FILE_OFFSET_BITS=64 in the Makefile. This
This can cause problems. can cause problems.
The technique of adding -D_FILE_OFFSET_BITS=64 to get large file The technique of adding -D_FILE_OFFSET_BITS=64 to get large file
support is, as far as I know, the Recommended Way to get correct large support is, as far as I know, the Recommended Way to get correct large
file support. For more details, see the Large File Support file support. For more details, see the Large File Support
Specification, published by the Large File Summit, at Specification, published by the Large File Summit, at
http://ftp.sas.com/standards/large.file http://ftp.sas.com/standards/large.file
As a general comment, if you get compilation errors which you think As a general comment, if you get compilation errors which you think
are related to large file support, try removing the above define from are related to large file support, try removing the above define from
the Makefile, ie, delete the line the Makefile, ie, delete the line
BIGFILES=-D_FILE_OFFSET_BITS=64 BIGFILES=-D_FILE_OFFSET_BITS=64
from the Makefile, and do 'make clean ; make'. This will give you a from the Makefile, and do 'make clean ; make'. This will give you a
version of bzip2 without large file support, which, for most version of bzip2 without large file support, which, for most
applications, is probably not a problem. applications, is probably not a problem.
@ -37,3 +52,7 @@ You can use the spewG.c program to generate huge files to test bzip2's
large file support, if you are feeling paranoid. Be aware though that large file support, if you are feeling paranoid. Be aware though that
any compilation problems which affect bzip2 will also affect spewG.c, any compilation problems which affect bzip2 will also affect spewG.c,
alas. alas.
AIX: I have reports that for large file support, you need to specify
-D_LARGE_FILES rather than -D_FILE_OFFSET_BITS=64. I have not tested
this myself.

View File

@ -4,66 +4,19 @@
/*--- blocksort.c ---*/ /*--- blocksort.c ---*/
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
/*-- /* ------------------------------------------------------------------
This file is a part of bzip2 and/or libbzip2, a program and This file is part of bzip2/libbzip2, a program and library for
library for lossless, block-sorting data compression. lossless, block-sorting data compression.
Copyright (C) 1996-2005 Julian R Seward. All rights reserved. bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Redistribution and use in source and binary forms, with or without Please read the WARNING, DISCLAIMER and PATENTS sections in the
modification, are permitted provided that the following conditions README file.
are met:
1. Redistributions of source code must retain the above copyright This program is released under the terms of the license contained
notice, this list of conditions and the following disclaimer. in the file LICENSE.
------------------------------------------------------------------ */
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@bzip.org
bzip2/libbzip2 version 1.0 of 21 March 2000
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
To get some idea how the block sorting algorithms in this file
work, read my paper
On the Performance of BWT Sorting Algorithms
in Proceedings of the IEEE Data Compression Conference 2000,
Snowbird, Utah, USA, 27-30 March 2000. The main sort in this
file implements the algorithm called cache in the paper.
--*/
#include "bzlib_private.h" #include "bzlib_private.h"
@ -155,7 +108,7 @@ void fallbackQSort3 ( UInt32* fmap,
while (sp > 0) { while (sp > 0) {
AssertH ( sp < FALLBACK_QSORT_STACK_SIZE, 1004 ); AssertH ( sp < FALLBACK_QSORT_STACK_SIZE - 1, 1004 );
fpop ( lo, hi ); fpop ( lo, hi );
if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) { if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) {
@ -690,7 +643,7 @@ void mainQSort3 ( UInt32* ptr,
while (sp > 0) { while (sp > 0) {
AssertH ( sp < MAIN_QSORT_STACK_SIZE, 1001 ); AssertH ( sp < MAIN_QSORT_STACK_SIZE - 2, 1001 );
mpop ( lo, hi, d ); mpop ( lo, hi, d );
if (hi - lo < MAIN_QSORT_SMALL_THRESH || if (hi - lo < MAIN_QSORT_SMALL_THRESH ||

View File

@ -1,7 +1,7 @@
.PU .PU
.TH bzip2 1 .TH bzip2 1
.SH NAME .SH NAME
bzip2, bunzip2 \- a block-sorting file compressor, v1.0.3 bzip2, bunzip2 \- a block-sorting file compressor, v1.0.4
.br .br
bzcat \- decompresses files to stdout bzcat \- decompresses files to stdout
.br .br
@ -405,11 +405,11 @@ I/O error messages are not as helpful as they could be.
tries hard to detect I/O errors and exit cleanly, but the details of tries hard to detect I/O errors and exit cleanly, but the details of
what the problem is sometimes seem rather misleading. what the problem is sometimes seem rather misleading.
This manual page pertains to version 1.0.3 of This manual page pertains to version 1.0.4 of
.I bzip2. .I bzip2.
Compressed data created by this version is entirely forwards and Compressed data created by this version is entirely forwards and
backwards compatible with the previous public releases, versions backwards compatible with the previous public releases, versions
0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and 1.0.2, but with the following 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, 1.0.2 and 1.0.3, but with the following
exception: 0.9.0 and above can correctly decompress multiple exception: 0.9.0 and above can correctly decompress multiple
concatenated compressed files. 0.1pl2 cannot do this; it will stop concatenated compressed files. 0.1pl2 cannot do this; it will stop
after decompressing just the first file in the stream. after decompressing just the first file in the stream.

View File

@ -3,118 +3,26 @@
/*--- A block-sorting, lossless compressor bzip2.c ---*/ /*--- A block-sorting, lossless compressor bzip2.c ---*/
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/*-- /* ------------------------------------------------------------------
This file is a part of bzip2 and/or libbzip2, a program and This file is part of bzip2/libbzip2, a program and library for
library for lossless, block-sorting data compression. lossless, block-sorting data compression.
Copyright (C) 1996-2005 Julian R Seward. All rights reserved. bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Redistribution and use in source and binary forms, with or without Please read the WARNING, DISCLAIMER and PATENTS sections in the
modification, are permitted provided that the following conditions README file.
are met:
1. Redistributions of source code must retain the above copyright This program is released under the terms of the license contained
notice, this list of conditions and the following disclaimer. in the file LICENSE.
------------------------------------------------------------------ */
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@bzip.org
bzip2/libbzip2 version 1.0 of 21 March 2000
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
--*/
/*----------------------------------------------------*/ /* Place a 1 beside your platform, and 0 elsewhere.
/*--- IMPORTANT ---*/ Generic 32-bit Unix.
/*----------------------------------------------------*/ Also works on 64-bit Unix boxes.
This is the default.
/*-- */
WARNING:
This program and library (attempts to) compress data by
performing several non-trivial transformations on it.
Unless you are 100% familiar with *all* the algorithms
contained herein, and with the consequences of modifying them,
you should NOT meddle with the compression or decompression
machinery. Incorrect changes can and very likely *will*
lead to disasterous loss of data.
DISCLAIMER:
I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE
USE OF THIS PROGRAM, HOWSOEVER CAUSED.
Every compression of a file implies an assumption that the
compressed file can be decompressed to reproduce the original.
Great efforts in design, coding and testing have been made to
ensure that this program works correctly. However, the
complexity of the algorithms, and, in particular, the presence
of various special cases in the code which occur with very low
but non-zero probability make it impossible to rule out the
possibility of bugs remaining in the program. DO NOT COMPRESS
ANY DATA WITH THIS PROGRAM AND/OR LIBRARY UNLESS YOU ARE PREPARED
TO ACCEPT THE POSSIBILITY, HOWEVER SMALL, THAT THE DATA WILL
NOT BE RECOVERABLE.
That is not to say this program is inherently unreliable.
Indeed, I very much hope the opposite is true. bzip2/libbzip2
has been carefully constructed and extensively tested.
PATENTS:
To the best of my knowledge, bzip2/libbzip2 does not use any
patented algorithms. However, I do not have the resources
available to carry out a full patent search. Therefore I cannot
give any guarantee of the above statement.
--*/
/*----------------------------------------------------*/
/*--- and now for something much more pleasant :-) ---*/
/*----------------------------------------------------*/
/*---------------------------------------------*/
/*--
Place a 1 beside your platform, and 0 elsewhere.
--*/
/*--
Generic 32-bit Unix.
Also works on 64-bit Unix boxes.
This is the default.
--*/
#define BZ_UNIX 1 #define BZ_UNIX 1
/*-- /*--
@ -302,16 +210,17 @@ Char progNameReally[FILE_NAME_LEN];
FILE *outputHandleJustInCase; FILE *outputHandleJustInCase;
Int32 workFactor; Int32 workFactor;
static void panic ( Char* ) NORETURN; static void panic ( const Char* ) NORETURN;
static void ioError ( void ) NORETURN; static void ioError ( void ) NORETURN;
static void outOfMemory ( void ) NORETURN; static void outOfMemory ( void ) NORETURN;
static void configError ( void ) NORETURN; static void configError ( void ) NORETURN;
static void crcError ( void ) NORETURN; static void crcError ( void ) NORETURN;
static void cleanUpAndFail ( Int32 ) NORETURN; static void cleanUpAndFail ( Int32 ) NORETURN;
static void compressedStreamEOF ( void ) NORETURN; static void compressedStreamEOF ( void ) NORETURN;
static void copyFileName ( Char*, Char* ); static void copyFileName ( Char*, Char* );
static void* myMalloc ( Int32 ); static void* myMalloc ( Int32 );
static void applySavedFileAttrToOutputFile ( IntNative fd );
@ -457,6 +366,9 @@ void compressStream ( FILE *stream, FILE *zStream )
ret = fflush ( zStream ); ret = fflush ( zStream );
if (ret == EOF) goto errhandler_io; if (ret == EOF) goto errhandler_io;
if (zStream != stdout) { if (zStream != stdout) {
Int32 fd = fileno ( zStream );
if (fd < 0) goto errhandler_io;
applySavedFileAttrToOutputFile ( fd );
ret = fclose ( zStream ); ret = fclose ( zStream );
outputHandleJustInCase = NULL; outputHandleJustInCase = NULL;
if (ret == EOF) goto errhandler_io; if (ret == EOF) goto errhandler_io;
@ -569,6 +481,11 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
closeok: closeok:
if (ferror(zStream)) goto errhandler_io; if (ferror(zStream)) goto errhandler_io;
if (stream != stdout) {
Int32 fd = fileno ( stream );
if (fd < 0) goto errhandler_io;
applySavedFileAttrToOutputFile ( fd );
}
ret = fclose ( zStream ); ret = fclose ( zStream );
if (ret == EOF) goto errhandler_io; if (ret == EOF) goto errhandler_io;
@ -826,7 +743,7 @@ void cleanUpAndFail ( Int32 ec )
/*---------------------------------------------*/ /*---------------------------------------------*/
static static
void panic ( Char* s ) void panic ( const Char* s )
{ {
fprintf ( stderr, fprintf ( stderr,
"\n%s: PANIC -- internal consistency error:\n" "\n%s: PANIC -- internal consistency error:\n"
@ -1039,6 +956,7 @@ Bool fileExists ( Char* name )
For non-Unix platforms, if we are not worrying about For non-Unix platforms, if we are not worrying about
security issues, simple this simply behaves like fopen. security issues, simple this simply behaves like fopen.
*/ */
static
FILE* fopen_output_safely ( Char* name, const char* mode ) FILE* fopen_output_safely ( Char* name, const char* mode )
{ {
# if BZ_UNIX # if BZ_UNIX
@ -1129,7 +1047,7 @@ void saveInputFileMetaInfo ( Char *srcName )
static static
void applySavedMetaInfoToOutputFile ( Char *dstName ) void applySavedTimeInfoToOutputFile ( Char *dstName )
{ {
# if BZ_UNIX # if BZ_UNIX
IntNative retVal; IntNative retVal;
@ -1138,13 +1056,21 @@ void applySavedMetaInfoToOutputFile ( Char *dstName )
uTimBuf.actime = fileMetaInfo.st_atime; uTimBuf.actime = fileMetaInfo.st_atime;
uTimBuf.modtime = fileMetaInfo.st_mtime; uTimBuf.modtime = fileMetaInfo.st_mtime;
retVal = chmod ( dstName, fileMetaInfo.st_mode );
ERROR_IF_NOT_ZERO ( retVal );
retVal = utime ( dstName, &uTimBuf ); retVal = utime ( dstName, &uTimBuf );
ERROR_IF_NOT_ZERO ( retVal ); ERROR_IF_NOT_ZERO ( retVal );
# endif
}
retVal = chown ( dstName, fileMetaInfo.st_uid, fileMetaInfo.st_gid ); static
void applySavedFileAttrToOutputFile ( IntNative fd )
{
# if BZ_UNIX
IntNative retVal;
retVal = fchmod ( fd, fileMetaInfo.st_mode );
ERROR_IF_NOT_ZERO ( retVal );
(void) fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
/* chown() will in many cases return with EPERM, which can /* chown() will in many cases return with EPERM, which can
be safely ignored. be safely ignored.
*/ */
@ -1175,13 +1101,13 @@ Bool containsDubiousChars ( Char* name )
/*---------------------------------------------*/ /*---------------------------------------------*/
#define BZ_N_SUFFIX_PAIRS 4 #define BZ_N_SUFFIX_PAIRS 4
Char* zSuffix[BZ_N_SUFFIX_PAIRS] const Char* zSuffix[BZ_N_SUFFIX_PAIRS]
= { ".bz2", ".bz", ".tbz2", ".tbz" }; = { ".bz2", ".bz", ".tbz2", ".tbz" };
Char* unzSuffix[BZ_N_SUFFIX_PAIRS] const Char* unzSuffix[BZ_N_SUFFIX_PAIRS]
= { "", "", ".tar", ".tar" }; = { "", "", ".tar", ".tar" };
static static
Bool hasSuffix ( Char* s, Char* suffix ) Bool hasSuffix ( Char* s, const Char* suffix )
{ {
Int32 ns = strlen(s); Int32 ns = strlen(s);
Int32 nx = strlen(suffix); Int32 nx = strlen(suffix);
@ -1192,7 +1118,8 @@ Bool hasSuffix ( Char* s, Char* suffix )
static static
Bool mapSuffix ( Char* name, Bool mapSuffix ( Char* name,
Char* oldSuffix, Char* newSuffix ) const Char* oldSuffix,
const Char* newSuffix )
{ {
if (!hasSuffix(name,oldSuffix)) return False; if (!hasSuffix(name,oldSuffix)) return False;
name[strlen(name)-strlen(oldSuffix)] = 0; name[strlen(name)-strlen(oldSuffix)] = 0;
@ -1217,8 +1144,8 @@ void compress ( Char *name )
switch (srcMode) { switch (srcMode) {
case SM_I2O: case SM_I2O:
copyFileName ( inName, "(stdin)" ); copyFileName ( inName, (Char*)"(stdin)" );
copyFileName ( outName, "(stdout)" ); copyFileName ( outName, (Char*)"(stdout)" );
break; break;
case SM_F2F: case SM_F2F:
copyFileName ( inName, name ); copyFileName ( inName, name );
@ -1227,7 +1154,7 @@ void compress ( Char *name )
break; break;
case SM_F2O: case SM_F2O:
copyFileName ( inName, name ); copyFileName ( inName, name );
copyFileName ( outName, "(stdout)" ); copyFileName ( outName, (Char*)"(stdout)" );
break; break;
} }
@ -1370,7 +1297,7 @@ void compress ( Char *name )
/*--- If there was an I/O error, we won't get here. ---*/ /*--- If there was an I/O error, we won't get here. ---*/
if ( srcMode == SM_F2F ) { if ( srcMode == SM_F2F ) {
applySavedMetaInfoToOutputFile ( outName ); applySavedTimeInfoToOutputFile ( outName );
deleteOutputOnInterrupt = False; deleteOutputOnInterrupt = False;
if ( !keepInputFiles ) { if ( !keepInputFiles ) {
IntNative retVal = remove ( inName ); IntNative retVal = remove ( inName );
@ -1401,8 +1328,8 @@ void uncompress ( Char *name )
cantGuess = False; cantGuess = False;
switch (srcMode) { switch (srcMode) {
case SM_I2O: case SM_I2O:
copyFileName ( inName, "(stdin)" ); copyFileName ( inName, (Char*)"(stdin)" );
copyFileName ( outName, "(stdout)" ); copyFileName ( outName, (Char*)"(stdout)" );
break; break;
case SM_F2F: case SM_F2F:
copyFileName ( inName, name ); copyFileName ( inName, name );
@ -1415,7 +1342,7 @@ void uncompress ( Char *name )
break; break;
case SM_F2O: case SM_F2O:
copyFileName ( inName, name ); copyFileName ( inName, name );
copyFileName ( outName, "(stdout)" ); copyFileName ( outName, (Char*)"(stdout)" );
break; break;
} }
@ -1548,7 +1475,7 @@ void uncompress ( Char *name )
/*--- If there was an I/O error, we won't get here. ---*/ /*--- If there was an I/O error, we won't get here. ---*/
if ( magicNumberOK ) { if ( magicNumberOK ) {
if ( srcMode == SM_F2F ) { if ( srcMode == SM_F2F ) {
applySavedMetaInfoToOutputFile ( outName ); applySavedTimeInfoToOutputFile ( outName );
deleteOutputOnInterrupt = False; deleteOutputOnInterrupt = False;
if ( !keepInputFiles ) { if ( !keepInputFiles ) {
IntNative retVal = remove ( inName ); IntNative retVal = remove ( inName );
@ -1593,9 +1520,9 @@ void testf ( Char *name )
if (name == NULL && srcMode != SM_I2O) if (name == NULL && srcMode != SM_I2O)
panic ( "testf: bad modes\n" ); panic ( "testf: bad modes\n" );
copyFileName ( outName, "(none)" ); copyFileName ( outName, (Char*)"(none)" );
switch (srcMode) { switch (srcMode) {
case SM_I2O: copyFileName ( inName, "(stdin)" ); break; case SM_I2O: copyFileName ( inName, (Char*)"(stdin)" ); break;
case SM_F2F: copyFileName ( inName, name ); break; case SM_F2F: copyFileName ( inName, name ); break;
case SM_F2O: copyFileName ( inName, name ); break; case SM_F2O: copyFileName ( inName, name ); break;
} }
@ -1678,11 +1605,11 @@ void license ( void )
"bzip2, a block-sorting file compressor. " "bzip2, a block-sorting file compressor. "
"Version %s.\n" "Version %s.\n"
" \n" " \n"
" Copyright (C) 1996-2005 by Julian Seward.\n" " Copyright (C) 1996-2006 by Julian Seward.\n"
" \n" " \n"
" This program is free software; you can redistribute it and/or modify\n" " This program is free software; you can redistribute it and/or modify\n"
" it under the terms set out in the LICENSE file, which is included\n" " it under the terms set out in the LICENSE file, which is included\n"
" in the bzip2-1.0 source distribution.\n" " in the bzip2-1.0.4 source distribution.\n"
" \n" " \n"
" This program is distributed in the hope that it will be useful,\n" " This program is distributed in the hope that it will be useful,\n"
" but WITHOUT ANY WARRANTY; without even the implied warranty of\n" " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
@ -1885,8 +1812,8 @@ IntNative main ( IntNative argc, Char *argv[] )
# endif # endif
# endif # endif
copyFileName ( inName, "(none)" ); copyFileName ( inName, (Char*)"(none)" );
copyFileName ( outName, "(none)" ); copyFileName ( outName, (Char*)"(none)" );
copyFileName ( progNameReally, argv[0] ); copyFileName ( progNameReally, argv[0] );
progName = &progNameReally[0]; progName = &progNameReally[0];
@ -1898,8 +1825,8 @@ IntNative main ( IntNative argc, Char *argv[] )
expand filename wildcards in arg list. expand filename wildcards in arg list.
--*/ --*/
argList = NULL; argList = NULL;
addFlagsFromEnvVar ( &argList, "BZIP2" ); addFlagsFromEnvVar ( &argList, (Char*)"BZIP2" );
addFlagsFromEnvVar ( &argList, "BZIP" ); addFlagsFromEnvVar ( &argList, (Char*)"BZIP" );
for (i = 1; i <= argc-1; i++) for (i = 1; i <= argc-1; i++)
APPEND_FILESPEC(argList, argv[i]); APPEND_FILESPEC(argList, argv[i]);

View File

@ -1,56 +1,24 @@
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/*--- Block recoverer program for bzip2 ---*/ /*--- Block recoverer program for bzip2 ---*/
/*--- bzip2recover.c ---*/ /*--- bzip2recover.c ---*/
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/*-- /* ------------------------------------------------------------------
This program is bzip2recover, a program to attempt data This file is part of bzip2/libbzip2, a program and library for
salvage from damaged files created by the accompanying lossless, block-sorting data compression.
bzip2-1.0.3 program.
Copyright (C) 1996-2005 Julian R Seward. All rights reserved. bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Redistribution and use in source and binary forms, with or without Please read the WARNING, DISCLAIMER and PATENTS sections in the
modification, are permitted provided that the following conditions README file.
are met:
1. Redistributions of source code must retain the above copyright This program is released under the terms of the license contained
notice, this list of conditions and the following disclaimer. in the file LICENSE.
------------------------------------------------------------------ */
2. The origin of this software must not be misrepresented; you must /* This program is a complete hack and should be rewritten properly.
not claim that you wrote the original software. If you use this It isn't very complicated. */
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@bzip.org
bzip2/libbzip2 version 1.0.3 of 15 February 2005
--*/
/*--
This program is a complete hack and should be rewritten
properly. It isn't very complicated.
--*/
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
@ -114,7 +82,7 @@ MaybeUInt64 bytesIn = 0;
/*---------------------------------------------------*/ /*---------------------------------------------------*/
/*---------------------------------------------*/ /*---------------------------------------------*/
void readError ( void ) static void readError ( void )
{ {
fprintf ( stderr, fprintf ( stderr,
"%s: I/O error reading `%s', possible reason follows.\n", "%s: I/O error reading `%s', possible reason follows.\n",
@ -127,7 +95,7 @@ void readError ( void )
/*---------------------------------------------*/ /*---------------------------------------------*/
void writeError ( void ) static void writeError ( void )
{ {
fprintf ( stderr, fprintf ( stderr,
"%s: I/O error reading `%s', possible reason follows.\n", "%s: I/O error reading `%s', possible reason follows.\n",
@ -140,7 +108,7 @@ void writeError ( void )
/*---------------------------------------------*/ /*---------------------------------------------*/
void mallocFail ( Int32 n ) static void mallocFail ( Int32 n )
{ {
fprintf ( stderr, fprintf ( stderr,
"%s: malloc failed on request for %d bytes.\n", "%s: malloc failed on request for %d bytes.\n",
@ -152,7 +120,7 @@ void mallocFail ( Int32 n )
/*---------------------------------------------*/ /*---------------------------------------------*/
void tooManyBlocks ( Int32 max_handled_blocks ) static void tooManyBlocks ( Int32 max_handled_blocks )
{ {
fprintf ( stderr, fprintf ( stderr,
"%s: `%s' appears to contain more than %d blocks\n", "%s: `%s' appears to contain more than %d blocks\n",
@ -183,7 +151,7 @@ typedef
/*---------------------------------------------*/ /*---------------------------------------------*/
BitStream* bsOpenReadStream ( FILE* stream ) static BitStream* bsOpenReadStream ( FILE* stream )
{ {
BitStream *bs = malloc ( sizeof(BitStream) ); BitStream *bs = malloc ( sizeof(BitStream) );
if (bs == NULL) mallocFail ( sizeof(BitStream) ); if (bs == NULL) mallocFail ( sizeof(BitStream) );
@ -196,7 +164,7 @@ BitStream* bsOpenReadStream ( FILE* stream )
/*---------------------------------------------*/ /*---------------------------------------------*/
BitStream* bsOpenWriteStream ( FILE* stream ) static BitStream* bsOpenWriteStream ( FILE* stream )
{ {
BitStream *bs = malloc ( sizeof(BitStream) ); BitStream *bs = malloc ( sizeof(BitStream) );
if (bs == NULL) mallocFail ( sizeof(BitStream) ); if (bs == NULL) mallocFail ( sizeof(BitStream) );
@ -209,7 +177,7 @@ BitStream* bsOpenWriteStream ( FILE* stream )
/*---------------------------------------------*/ /*---------------------------------------------*/
void bsPutBit ( BitStream* bs, Int32 bit ) static void bsPutBit ( BitStream* bs, Int32 bit )
{ {
if (bs->buffLive == 8) { if (bs->buffLive == 8) {
Int32 retVal = putc ( (UChar) bs->buffer, bs->handle ); Int32 retVal = putc ( (UChar) bs->buffer, bs->handle );
@ -228,7 +196,7 @@ void bsPutBit ( BitStream* bs, Int32 bit )
/*-- /*--
Returns 0 or 1, or 2 to indicate EOF. Returns 0 or 1, or 2 to indicate EOF.
--*/ --*/
Int32 bsGetBit ( BitStream* bs ) static Int32 bsGetBit ( BitStream* bs )
{ {
if (bs->buffLive > 0) { if (bs->buffLive > 0) {
bs->buffLive --; bs->buffLive --;
@ -247,7 +215,7 @@ Int32 bsGetBit ( BitStream* bs )
/*---------------------------------------------*/ /*---------------------------------------------*/
void bsClose ( BitStream* bs ) static void bsClose ( BitStream* bs )
{ {
Int32 retVal; Int32 retVal;
@ -271,7 +239,7 @@ void bsClose ( BitStream* bs )
/*---------------------------------------------*/ /*---------------------------------------------*/
void bsPutUChar ( BitStream* bs, UChar c ) static void bsPutUChar ( BitStream* bs, UChar c )
{ {
Int32 i; Int32 i;
for (i = 7; i >= 0; i--) for (i = 7; i >= 0; i--)
@ -280,7 +248,7 @@ void bsPutUChar ( BitStream* bs, UChar c )
/*---------------------------------------------*/ /*---------------------------------------------*/
void bsPutUInt32 ( BitStream* bs, UInt32 c ) static void bsPutUInt32 ( BitStream* bs, UInt32 c )
{ {
Int32 i; Int32 i;
@ -290,7 +258,7 @@ void bsPutUInt32 ( BitStream* bs, UInt32 c )
/*---------------------------------------------*/ /*---------------------------------------------*/
Bool endsInBz2 ( Char* name ) static Bool endsInBz2 ( Char* name )
{ {
Int32 n = strlen ( name ); Int32 n = strlen ( name );
if (n <= 4) return False; if (n <= 4) return False;
@ -345,7 +313,7 @@ Int32 main ( Int32 argc, Char** argv )
inFileName[0] = outFileName[0] = 0; inFileName[0] = outFileName[0] = 0;
fprintf ( stderr, fprintf ( stderr,
"bzip2recover 1.0.3: extracts blocks from damaged .bz2 files.\n" ); "bzip2recover 1.0.4: extracts blocks from damaged .bz2 files.\n" );
if (argc != 2) { if (argc != 2) {
fprintf ( stderr, "%s: usage is `%s damaged_file_name'.\n", fprintf ( stderr, "%s: usage is `%s damaged_file_name'.\n",

View File

@ -4,74 +4,29 @@
/*--- bzlib.c ---*/ /*--- bzlib.c ---*/
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
/*-- /* ------------------------------------------------------------------
This file is a part of bzip2 and/or libbzip2, a program and This file is part of bzip2/libbzip2, a program and library for
library for lossless, block-sorting data compression. lossless, block-sorting data compression.
Copyright (C) 1996-2005 Julian R Seward. All rights reserved. bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Redistribution and use in source and binary forms, with or without Please read the WARNING, DISCLAIMER and PATENTS sections in the
modification, are permitted provided that the following conditions README file.
are met:
1. Redistributions of source code must retain the above copyright This program is released under the terms of the license contained
notice, this list of conditions and the following disclaimer. in the file LICENSE.
------------------------------------------------------------------ */
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@bzip.org
bzip2/libbzip2 version 1.0 of 21 March 2000
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
--*/
/*--
CHANGES
~~~~~~~
0.9.0 -- original version.
/* CHANGES
0.9.0 -- original version.
0.9.0a/b -- no changes in this file. 0.9.0a/b -- no changes in this file.
0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress().
0.9.0c fixed bzWrite/bzRead to ignore zero-length requests.
* made zero-length BZ_FLUSH work correctly in bzCompress(). fixed bzread to correctly handle read requests after EOF.
* fixed bzWrite/bzRead to ignore zero-length requests. wrong parameter order in call to bzDecompressInit in
* fixed bzread to correctly handle read requests after EOF. bzBuffToBuffDecompress. Fixed.
* wrong parameter order in call to bzDecompressInit in */
bzBuffToBuffDecompress. Fixed.
--*/
#include "bzlib_private.h" #include "bzlib_private.h"
@ -1394,8 +1349,7 @@ int BZ_API(BZ2_bzBuffToBuffDecompress)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
/*-- /*--
Code contributed by Yoshioka Tsuneo Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
(QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
to support better zlib compatibility. to support better zlib compatibility.
This code is not _officially_ part of libbzip2 (yet); This code is not _officially_ part of libbzip2 (yet);
I haven't tested it, documented it, or considered the I haven't tested it, documented it, or considered the
@ -1406,7 +1360,7 @@ int BZ_API(BZ2_bzBuffToBuffDecompress)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
/*-- /*--
return version like "0.9.0c". return version like "0.9.5d, 4-Sept-1999".
--*/ --*/
const char * BZ_API(BZ2_bzlibVersion)(void) const char * BZ_API(BZ2_bzlibVersion)(void)
{ {
@ -1559,9 +1513,10 @@ int BZ_API(BZ2_bzflush) (BZFILE *b)
void BZ_API(BZ2_bzclose) (BZFILE* b) void BZ_API(BZ2_bzclose) (BZFILE* b)
{ {
int bzerr; int bzerr;
FILE *fp = ((bzFile *)b)->handle; FILE *fp;
if (b==NULL) {return;} if (b==NULL) {return;}
fp = ((bzFile *)b)->handle;
if(((bzFile*)b)->writing){ if(((bzFile*)b)->writing){
BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL); BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL);
if(bzerr != BZ_OK){ if(bzerr != BZ_OK){
@ -1580,7 +1535,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b)
/*-- /*--
return last error code return last error code
--*/ --*/
static char *bzerrorstrings[] = { static const char *bzerrorstrings[] = {
"OK" "OK"
,"SEQUENCE_ERROR" ,"SEQUENCE_ERROR"
,"PARAM_ERROR" ,"PARAM_ERROR"

View File

@ -4,59 +4,19 @@
/*--- bzlib.h ---*/ /*--- bzlib.h ---*/
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
/*-- /* ------------------------------------------------------------------
This file is a part of bzip2 and/or libbzip2, a program and This file is part of bzip2/libbzip2, a program and library for
library for lossless, block-sorting data compression. lossless, block-sorting data compression.
Copyright (C) 1996-2005 Julian R Seward. All rights reserved. bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Redistribution and use in source and binary forms, with or without Please read the WARNING, DISCLAIMER and PATENTS sections in the
modification, are permitted provided that the following conditions README file.
are met:
1. Redistributions of source code must retain the above copyright This program is released under the terms of the license contained
notice, this list of conditions and the following disclaimer. in the file LICENSE.
------------------------------------------------------------------ */
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@bzip.org
bzip2/libbzip2 version 1.0 of 21 March 2000
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
--*/
#ifndef _BZLIB_H #ifndef _BZLIB_H
@ -262,8 +222,7 @@ BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
/*-- /*--
Code contributed by Yoshioka Tsuneo Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
(QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
to support better zlib compatibility. to support better zlib compatibility.
This code is not _officially_ part of libbzip2 (yet); This code is not _officially_ part of libbzip2 (yet);
I haven't tested it, documented it, or considered the I haven't tested it, documented it, or considered the

View File

@ -4,59 +4,19 @@
/*--- bzlib_private.h ---*/ /*--- bzlib_private.h ---*/
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
/*-- /* ------------------------------------------------------------------
This file is a part of bzip2 and/or libbzip2, a program and This file is part of bzip2/libbzip2, a program and library for
library for lossless, block-sorting data compression. lossless, block-sorting data compression.
Copyright (C) 1996-2005 Julian R Seward. All rights reserved. bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Redistribution and use in source and binary forms, with or without Please read the WARNING, DISCLAIMER and PATENTS sections in the
modification, are permitted provided that the following conditions README file.
are met:
1. Redistributions of source code must retain the above copyright This program is released under the terms of the license contained
notice, this list of conditions and the following disclaimer. in the file LICENSE.
------------------------------------------------------------------ */
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@bzip.org
bzip2/libbzip2 version 1.0 of 21 March 2000
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
--*/
#ifndef _BZLIB_PRIVATE_H #ifndef _BZLIB_PRIVATE_H
@ -76,7 +36,7 @@
/*-- General stuff. --*/ /*-- General stuff. --*/
#define BZ_VERSION "1.0.3, 15-Feb-2005" #define BZ_VERSION "1.0.4, 20-Dec-2006"
typedef char Char; typedef char Char;
typedef unsigned char Bool; typedef unsigned char Bool;
@ -94,9 +54,11 @@ typedef unsigned short UInt16;
#endif #endif
#ifndef BZ_NO_STDIO #ifndef BZ_NO_STDIO
extern void BZ2_bz__AssertH__fail ( int errcode ); extern void BZ2_bz__AssertH__fail ( int errcode );
#define AssertH(cond,errcode) \ #define AssertH(cond,errcode) \
{ if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); } { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
#if BZ_DEBUG #if BZ_DEBUG
#define AssertD(cond,msg) \ #define AssertD(cond,msg) \
{ if (!(cond)) { \ { if (!(cond)) { \
@ -107,6 +69,7 @@ extern void BZ2_bz__AssertH__fail ( int errcode );
#else #else
#define AssertD(cond,msg) /* */ #define AssertD(cond,msg) /* */
#endif #endif
#define VPrintf0(zf) \ #define VPrintf0(zf) \
fprintf(stderr,zf) fprintf(stderr,zf)
#define VPrintf1(zf,za1) \ #define VPrintf1(zf,za1) \
@ -119,17 +82,20 @@ extern void BZ2_bz__AssertH__fail ( int errcode );
fprintf(stderr,zf,za1,za2,za3,za4) fprintf(stderr,zf,za1,za2,za3,za4)
#define VPrintf5(zf,za1,za2,za3,za4,za5) \ #define VPrintf5(zf,za1,za2,za3,za4,za5) \
fprintf(stderr,zf,za1,za2,za3,za4,za5) fprintf(stderr,zf,za1,za2,za3,za4,za5)
#else #else
extern void bz_internal_error ( int errcode ); extern void bz_internal_error ( int errcode );
#define AssertH(cond,errcode) \ #define AssertH(cond,errcode) \
{ if (!(cond)) bz_internal_error ( errcode ); } { if (!(cond)) bz_internal_error ( errcode ); }
#define AssertD(cond,msg) /* */ #define AssertD(cond,msg) do { } while (0)
#define VPrintf0(zf) /* */ #define VPrintf0(zf) do { } while (0)
#define VPrintf1(zf,za1) /* */ #define VPrintf1(zf,za1) do { } while (0)
#define VPrintf2(zf,za1,za2) /* */ #define VPrintf2(zf,za1,za2) do { } while (0)
#define VPrintf3(zf,za1,za2,za3) /* */ #define VPrintf3(zf,za1,za2,za3) do { } while (0)
#define VPrintf4(zf,za1,za2,za3,za4) /* */ #define VPrintf4(zf,za1,za2,za3,za4) do { } while (0)
#define VPrintf5(zf,za1,za2,za3,za4,za5) /* */ #define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0)
#endif #endif

View File

@ -4,71 +4,27 @@
/*--- compress.c ---*/ /*--- compress.c ---*/
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
/*-- /* ------------------------------------------------------------------
This file is a part of bzip2 and/or libbzip2, a program and This file is part of bzip2/libbzip2, a program and library for
library for lossless, block-sorting data compression. lossless, block-sorting data compression.
Copyright (C) 1996-2005 Julian R Seward. All rights reserved. bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Redistribution and use in source and binary forms, with or without Please read the WARNING, DISCLAIMER and PATENTS sections in the
modification, are permitted provided that the following conditions README file.
are met:
1. Redistributions of source code must retain the above copyright This program is released under the terms of the license contained
notice, this list of conditions and the following disclaimer. in the file LICENSE.
------------------------------------------------------------------ */
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must /* CHANGES
not be misrepresented as being the original software. 0.9.0 -- original version.
0.9.0a/b -- no changes in this file.
4. The name of the author may not be used to endorse or promote 0.9.0c -- changed setting of nGroups in sendMTFValues()
products derived from this software without specific prior written so as to do a bit better on small files
permission. */
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@bzip.org
bzip2/libbzip2 version 1.0 of 21 March 2000
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
--*/
/*--
CHANGES
~~~~~~~
0.9.0 -- original version.
0.9.0a/b -- no changes in this file.
0.9.0c
* changed setting of nGroups in sendMTFValues() so as to
do a bit better on small files
--*/
#include "bzlib_private.h" #include "bzlib_private.h"

View File

@ -4,59 +4,19 @@
/*--- crctable.c ---*/ /*--- crctable.c ---*/
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
/*-- /* ------------------------------------------------------------------
This file is a part of bzip2 and/or libbzip2, a program and This file is part of bzip2/libbzip2, a program and library for
library for lossless, block-sorting data compression. lossless, block-sorting data compression.
Copyright (C) 1996-2005 Julian R Seward. All rights reserved. bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Redistribution and use in source and binary forms, with or without Please read the WARNING, DISCLAIMER and PATENTS sections in the
modification, are permitted provided that the following conditions README file.
are met:
1. Redistributions of source code must retain the above copyright This program is released under the terms of the license contained
notice, this list of conditions and the following disclaimer. in the file LICENSE.
------------------------------------------------------------------ */
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@bzip.org
bzip2/libbzip2 version 1.0 of 21 March 2000
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
--*/
#include "bzlib_private.h" #include "bzlib_private.h"

View File

@ -4,59 +4,19 @@
/*--- decompress.c ---*/ /*--- decompress.c ---*/
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
/*-- /* ------------------------------------------------------------------
This file is a part of bzip2 and/or libbzip2, a program and This file is part of bzip2/libbzip2, a program and library for
library for lossless, block-sorting data compression. lossless, block-sorting data compression.
Copyright (C) 1996-2005 Julian R Seward. All rights reserved. bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Redistribution and use in source and binary forms, with or without Please read the WARNING, DISCLAIMER and PATENTS sections in the
modification, are permitted provided that the following conditions README file.
are met:
1. Redistributions of source code must retain the above copyright This program is released under the terms of the license contained
notice, this list of conditions and the following disclaimer. in the file LICENSE.
------------------------------------------------------------------ */
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@bzip.org
bzip2/libbzip2 version 1.0 of 21 March 2000
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
--*/
#include "bzlib_private.h" #include "bzlib_private.h"

View File

@ -1,9 +1,8 @@
/* /*
minibz2 minibz2
libbz2.dll test program. libbz2.dll test program.
by Yoshioka Tsuneo(QWF00133@nifty.ne.jp/tsuneo-y@is.aist-nara.ac.jp) by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
This file is Public Domain. This file is Public Domain. Welcome any email to me.
welcome any email to me.
usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename] usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]
*/ */

View File

@ -4,59 +4,19 @@
/*--- huffman.c ---*/ /*--- huffman.c ---*/
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
/*-- /* ------------------------------------------------------------------
This file is a part of bzip2 and/or libbzip2, a program and This file is part of bzip2/libbzip2, a program and library for
library for lossless, block-sorting data compression. lossless, block-sorting data compression.
Copyright (C) 1996-2005 Julian R Seward. All rights reserved. bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Redistribution and use in source and binary forms, with or without Please read the WARNING, DISCLAIMER and PATENTS sections in the
modification, are permitted provided that the following conditions README file.
are met:
1. Redistributions of source code must retain the above copyright This program is released under the terms of the license contained
notice, this list of conditions and the following disclaimer. in the file LICENSE.
------------------------------------------------------------------ */
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@bzip.org
bzip2/libbzip2 version 1.0 of 21 March 2000
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
--*/
#include "bzlib_private.h" #include "bzlib_private.h"

View File

@ -4,59 +4,19 @@
/*--- randtable.c ---*/ /*--- randtable.c ---*/
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
/*-- /* ------------------------------------------------------------------
This file is a part of bzip2 and/or libbzip2, a program and This file is part of bzip2/libbzip2, a program and library for
library for lossless, block-sorting data compression. lossless, block-sorting data compression.
Copyright (C) 1996-2005 Julian R Seward. All rights reserved. bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Redistribution and use in source and binary forms, with or without Please read the WARNING, DISCLAIMER and PATENTS sections in the
modification, are permitted provided that the following conditions README file.
are met:
1. Redistributions of source code must retain the above copyright This program is released under the terms of the license contained
notice, this list of conditions and the following disclaimer. in the file LICENSE.
------------------------------------------------------------------ */
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@bzip.org
bzip2/libbzip2 version 1.0 of 21 March 2000
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
--*/
#include "bzlib_private.h" #include "bzlib_private.h"

View File

@ -1,4 +1,4 @@
begin 640 sample1.bz2 begin 644 sample1.bz2
M0EIH,3%!62936<SQM:4`OJ;_____________________________________ M0EIH,3%!62936<SQM:4`OJ;_____________________________________
M________X)3?>``^"5D```4[8=N[8K7,-JP,#+WT`WUMF`[!Z#H>Z]G#Z!`$ M________X)3?>``^"5D```4[8=N[8K7,-JP,#+WT`WUMF`[!Z#H>Z]G#Z!`$
M``&]F(!NO=V[[M9NCTWNY[8+SDJPX]LV]K.-S+;KAZ-ZL2V8*;.;77MW;VVY M``&]F(!NO=V[[M9NCTWNY[8+SDJPX]LV]K.-S+;KAZ-ZL2V8*;.;77MW;VVY

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
begin 640 sample2.bz2 begin 644 sample2.bz2
M0EIH,C%!629367PQR6$!@_U_____________________________________ M0EIH,C%!629367PQR6$!@_U_____________________________________
M________X3T-[WV#SN>48``!H*!H`-``'3:NO$JCVP/<L%=``>N!K+L'U2AE M________X3T-[WV#SN>48``!H*!H`-``'3:NO$JCVP/<L%=``>N!K+L'U2AE
M@`!.QH[YW>@&]ZXY```0:`^@``,G'WQSWQ[NC('@`0T7L!W84*!XU@`/30*N M@`!.QH[YW>@&]ZXY```0:`^@``,G'WQSWQ[NC('@`0T7L!W84*!XU@`/30*N

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
begin 640 sample3.bz2 begin 644 sample3.bz2
M0EIH,S%!62936;K-,\D`.K;?@``00&4P```@!``_[][@,`#:VT-3`IDGZIFF M0EIH,S%!62936;K-,\D`.K;?@``00&4P```@!``_[][@,`#:VT-3`IDGZIFF
MHT](;4T&@H]-0R`!HT`BD%'I--&)H&C32IEOWIG15$$195,\[7SNV^DXEM\G MHT](;4T&@H]-0R`!HT`BD%'I--&)H&C32IEOWIG15$$195,\[7SNV^DXEM\G
M0\ZRK;7W3[@]P7B>KPBU87N[XI5>!/TRY1JZE9UN&;!6ZH,60K?O=56)J;1@ M0\ZRK;7W3[@]P7B>KPBU87N[XI5>!/TRY1JZE9UN&;!6ZH,60K?O=56)J;1@

View File

@ -1,5 +1,5 @@
begin 640 sample3.ref.gz begin 644 sample3.ref.gz
M'XL("'K+9T$"`W-A;7!L93,N<F5F`.W/08[;,`P%T+U/P>4$"`)T;M%]+Z!F M'XL("%<.FT4"`W-A;7!L93,N<F5F`.W/08[;,`P%T+U/P>4$"`)T;M%]+Z!F
MZ-B(8P>2@S:W'R7HNB=XBP=1$#\E_9KF%N.\9/0U_YXSO^;ULCSC]U9[<8KX MZ-B(8P>2@S:W'R7HNB=XBP=1$#\E_9KF%N.\9/0U_YXSO^;ULCSC]U9[<8KX
M.<9S>_2>]>M5U);+.-0LK[Z8]V/<ERPMX^/'(?9R[8/V&.MVBUO&/I7]G3Z7 M.<9S>_2>]>M5U);+.-0LK[Z8]V/<ERPMX^/'(?9R[8/V&.MVBUO&/I7]G3Z7
M-5H9<WD.ET>V%G]>)_N44;/ML8WO^OV.5I[M&*7?]O%YB)9YC7O=QAZ:M[4L M-5H9<WD.ET>V%G]>)_N44;/ML8WO^OV.5I[M&*7?]O%YB)9YC7O=QAZ:M[4L

View File

@ -9,6 +9,21 @@
(but is otherwise harmless). (but is otherwise harmless).
*/ */
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#include <stdio.h> #include <stdio.h>

View File

@ -8,11 +8,26 @@
This should not cause any invalid memory accesses. If it does, This should not cause any invalid memory accesses. If it does,
I want to know about it! I want to know about it!
p.s. As you can see from the above description, the process is PS. As you can see from the above description, the process is
incredibly slow. A file of size eg 5KB will cause it to run for incredibly slow. A file of size eg 5KB will cause it to run for
many hours. many hours.
*/ */
/* ------------------------------------------------------------------
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.4 of 20 December 2006
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------ */
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include "bzlib.h" #include "bzlib.h"

View File

@ -1,5 +1,9 @@
If compilation produces errors, or a large number of warnings, If compilation produces errors, or a large number of warnings,
please read README.COMPILATION.PROBLEMS -- you might be able to please read README.COMPILATION.PROBLEMS -- you might be able to
adjust the flags in this Makefile to improve matters. adjust the flags in this Makefile to improve matters.
Also in README.COMPILATION.PROBLEMS are some hints that may help
if your build produces an executable which is unable to correctly
handle so-called 'large files' -- files of size 2GB or more.

View File

@ -1,5 +1,5 @@
Checking test results. If any of the four "cmp"s which follow Checking test results. If any of the four "cmp"s which follow
report any differences, something is wrong. If you can't easily report any differences, something is wrong. If you can't easily
figure out what, please let me know (jseward@acm.org). figure out what, please let me know (jseward@bzip.org).

View File

@ -1,22 +1,29 @@
If you got this far and the "cmp"s didn't complain, it looks If you got this far and the 'cmp's didn't complain, it looks
like you're in business. like you're in business.
To install in /usr/bin, /usr/lib, /usr/man and /usr/include, type To install in /usr/local/bin, /usr/local/lib, /usr/local/man and
/usr/local/include, type
make install make install
To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type
make install PREFIX=/xxx/yyy make install PREFIX=/xxx/yyy
If you are (justifiably) paranoid and want to see what 'make install' If you are (justifiably) paranoid and want to see what 'make install'
is going to do, you can first do is going to do, you can first do
make -n install or make -n install or
make -n install PREFIX=/xxx/yyy respectively. make -n install PREFIX=/xxx/yyy respectively.
The -n instructs make to show the commands it would execute, but The -n instructs make to show the commands it would execute, but
not actually execute them. not actually execute them.
Instructions for use are in the preformatted manual page, in the file Instructions for use are in the preformatted manual page, in the file
bzip2.txt. For more detailed documentation, read the full manual. bzip2.txt. For more detailed documentation, read the full manual.
It is available in Postscript form (manual.ps), PDF form (manual.pdf), It is available in Postscript form (manual.ps), PDF form (manual.pdf),
and HTML form (manual_toc.html). and HTML form (manual.html).
You can also do "bzip2 --help" to see some helpful information. You can also do "bzip2 --help" to see some helpful information.
"bzip2 -L" displays the software license. "bzip2 -L" displays the software license.