bzip2库是用于压缩解压.bz2文件的C语言库,(用过linux的人都遇到过.tar.bz2的压缩文件吧?)根据作者的说法,在目前所有已知的压缩算法中,bzip2 可以排到百分之十到十五这样最好的一类算法中(PPM),尽管它在压缩速度时大致快两倍,而解压速度有六倍快。
从 http://www.bzip.org 下载bzip2库,目前版本是1.04. 解压到本地文件夹中,里面只有for VC的makefile(这点不如zlib,不过也没办法,谁叫Borland把C++编译器的老大地位让给M$了呢). 只好参考VC的自己写一个makefile了.
从 http://www.bzip.org 下载bzip2库,目前版本是1.04. 解压到本地文件夹中,里面只有for VC的makefile(这点不如zlib,不过也没办法,谁叫Borland把C++编译器的老大地位让给M$了呢). 只好参考VC的自己写一个makefile了.
For BCB的makefile如下,把内容拷贝到一txt文件里改名为makefile.bcc并放到bzip2库的同一文件夹里, 然后在cmd下执行 make -fmakefile.bcc 即可生成libbz2.lib. 以后如果工程里要用到bzip2压缩,把此文件加入工程并加入头文件#include "bzlib.h"即可.
CC = bcc32
AR = tlib
AR = tlib
CFLAGS = -DWIN32 -D_FILE_OFFSET_BITS=64
OBJS= blocksort.obj huffman.obj crctable.obj randtable.obj compress.obj decompress.obj bzlib.obj
POBJS= +blocksort.obj +huffman.obj +crctable.obj +randtable.obj +compress.obj +decompress.obj +bzlib.obj
POBJS= +blocksort.obj +huffman.obj +crctable.obj +randtable.obj +compress.obj +decompress.obj +bzlib.obj
all: lib bzip2 test
bzip2: lib
$(CC) $(CFLAGS) bzip2.c -L libbz2.lib
$(CC) $(CFLAGS) bzip2recover.c
$(CC) $(CFLAGS) bzip2.c -L libbz2.lib
$(CC) $(CFLAGS) bzip2recover.c
lib: $(OBJS)
$(AR) libbz2.lib $(POBJS)
$(AR) libbz2.lib $(POBJS)
test: bzip2
type words1
.//bzip2 -1 < sample1.ref > sample1.rb2
.//bzip2 -2 < sample2.ref > sample2.rb2
.//bzip2 -3 < sample3.ref > sample3.rb2
.//bzip2 -d < sample1.bz2 > sample1.tst
.//bzip2 -d < sample2.bz2 > sample2.tst
.//bzip2 -ds < sample3.bz2 > sample3.tst
@echo All six of the fc's should find no differences.
@echo If fc finds an error on sample3.bz2, this could be
@echo because WinZip's 'TAR file smart CR/LF conversion'
@echo is too clever for its own good. Disable this option.
@echo The correct size for sample3.ref is 120,244. If it
@echo is 150,251, WinZip has messed it up.
fc sample1.bz2 sample1.rb2
fc sample2.bz2 sample2.rb2
fc sample3.bz2 sample3.rb2
fc sample1.tst sample1.ref
fc sample2.tst sample2.ref
fc sample3.tst sample3.ref
type words1
.//bzip2 -1 < sample1.ref > sample1.rb2
.//bzip2 -2 < sample2.ref > sample2.rb2
.//bzip2 -3 < sample3.ref > sample3.rb2
.//bzip2 -d < sample1.bz2 > sample1.tst
.//bzip2 -d < sample2.bz2 > sample2.tst
.//bzip2 -ds < sample3.bz2 > sample3.tst
@echo All six of the fc's should find no differences.
@echo If fc finds an error on sample3.bz2, this could be
@echo because WinZip's 'TAR file smart CR/LF conversion'
@echo is too clever for its own good. Disable this option.
@echo The correct size for sample3.ref is 120,244. If it
@echo is 150,251, WinZip has messed it up.
fc sample1.bz2 sample1.rb2
fc sample2.bz2 sample2.rb2
fc sample3.bz2 sample3.rb2
fc sample1.tst sample1.ref
fc sample2.tst sample2.ref
fc sample3.tst sample3.ref
clean:
del *.obj
del libbz2.lib
del bzip2.exe
del bzip2recover.exe
del sample1.rb2
del sample2.rb2
del sample3.rb2
del sample1.tst
del sample2.tst
del sample3.tst
del *.obj
del libbz2.lib
del bzip2.exe
del bzip2recover.exe
del sample1.rb2
del sample2.rb2
del sample3.rb2
del sample1.tst
del sample2.tst
del sample3.tst
.c.obj:
$(CC) $(CFLAGS) -c $*.c -o $*.obj
$(CC) $(CFLAGS) -c $*.c -o $*.obj