mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 15:03:34 +00:00
Get bzip2 to build
This commit is contained in:
parent
a8fb68af4b
commit
5bb2275788
33 changed files with 568 additions and 5071 deletions
1
Makefile
1
Makefile
|
@ -117,6 +117,7 @@ include libc/alg/alg.mk # │
|
||||||
include libc/stdio/stdio.mk # │
|
include libc/stdio/stdio.mk # │
|
||||||
include net/net.mk # │
|
include net/net.mk # │
|
||||||
include libc/log/log.mk # │
|
include libc/log/log.mk # │
|
||||||
|
include third_party/bzip2/bzip2.mk # │
|
||||||
include dsp/core/core.mk # │
|
include dsp/core/core.mk # │
|
||||||
include libc/x/x.mk # │
|
include libc/x/x.mk # │
|
||||||
include third_party/stb/stb.mk # │
|
include third_party/stb/stb.mk # │
|
||||||
|
|
|
@ -6,6 +6,7 @@ COSMOPOLITAN_C_START_
|
||||||
extern const uint32_t kCrc32cTab[256];
|
extern const uint32_t kCrc32cTab[256];
|
||||||
|
|
||||||
void crc32init(uint32_t[hasatleast 256], uint32_t);
|
void crc32init(uint32_t[hasatleast 256], uint32_t);
|
||||||
|
uint32_t crc32a(uint32_t, const void *, size_t);
|
||||||
uint32_t crc32c(uint32_t, const void *, size_t);
|
uint32_t crc32c(uint32_t, const void *, size_t);
|
||||||
uint32_t crc32_z(uint32_t, const void *, size_t);
|
uint32_t crc32_z(uint32_t, const void *, size_t);
|
||||||
uint32_t crc32c_pure(uint32_t, const void *, size_t) strlenesque hidden;
|
uint32_t crc32c_pure(uint32_t, const void *, size_t) strlenesque hidden;
|
||||||
|
|
217
third_party/bzip2/Makefile
vendored
217
third_party/bzip2/Makefile
vendored
|
@ -1,217 +0,0 @@
|
||||||
# ------------------------------------------------------------------
|
|
||||||
# This file is part of bzip2/libbzip2, a program and library for
|
|
||||||
# lossless, block-sorting data compression.
|
|
||||||
#
|
|
||||||
# bzip2/libbzip2 version 1.0.8 of 13 July 2019
|
|
||||||
# Copyright (C) 1996-2019 Julian Seward <jseward@acm.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
|
|
||||||
|
|
||||||
# To assist in cross-compiling
|
|
||||||
CC=gcc
|
|
||||||
AR=ar
|
|
||||||
RANLIB=ranlib
|
|
||||||
LDFLAGS=
|
|
||||||
|
|
||||||
BIGFILES=-D_FILE_OFFSET_BITS=64
|
|
||||||
CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
|
|
||||||
|
|
||||||
# Where you want it installed when you do 'make install'
|
|
||||||
PREFIX=/usr/local
|
|
||||||
|
|
||||||
|
|
||||||
OBJS= blocksort.o \
|
|
||||||
huffman.o \
|
|
||||||
crctable.o \
|
|
||||||
randtable.o \
|
|
||||||
compress.o \
|
|
||||||
decompress.o \
|
|
||||||
bzlib.o
|
|
||||||
|
|
||||||
all: libbz2.a bzip2 bzip2recover test
|
|
||||||
|
|
||||||
bzip2: libbz2.a bzip2.o
|
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2
|
|
||||||
|
|
||||||
bzip2recover: bzip2recover.o
|
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o bzip2recover bzip2recover.o
|
|
||||||
|
|
||||||
libbz2.a: $(OBJS)
|
|
||||||
rm -f libbz2.a
|
|
||||||
$(AR) cq libbz2.a $(OBJS)
|
|
||||||
@if ( test -f $(RANLIB) -o -f /usr/bin/ranlib -o \
|
|
||||||
-f /bin/ranlib -o -f /usr/ccs/bin/ranlib ) ; then \
|
|
||||||
echo $(RANLIB) libbz2.a ; \
|
|
||||||
$(RANLIB) libbz2.a ; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
check: test
|
|
||||||
test: bzip2
|
|
||||||
@cat 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
|
|
||||||
cmp sample1.bz2 sample1.rb2
|
|
||||||
cmp sample2.bz2 sample2.rb2
|
|
||||||
cmp sample3.bz2 sample3.rb2
|
|
||||||
cmp sample1.tst sample1.ref
|
|
||||||
cmp sample2.tst sample2.ref
|
|
||||||
cmp sample3.tst sample3.ref
|
|
||||||
@cat words3
|
|
||||||
|
|
||||||
install: bzip2 bzip2recover
|
|
||||||
if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi
|
|
||||||
if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi
|
|
||||||
if ( test ! -d $(PREFIX)/man ) ; then mkdir -p $(PREFIX)/man ; fi
|
|
||||||
if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir -p $(PREFIX)/man/man1 ; fi
|
|
||||||
if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi
|
|
||||||
cp -f bzip2 $(PREFIX)/bin/bzip2
|
|
||||||
cp -f bzip2 $(PREFIX)/bin/bunzip2
|
|
||||||
cp -f bzip2 $(PREFIX)/bin/bzcat
|
|
||||||
cp -f bzip2recover $(PREFIX)/bin/bzip2recover
|
|
||||||
chmod a+x $(PREFIX)/bin/bzip2
|
|
||||||
chmod a+x $(PREFIX)/bin/bunzip2
|
|
||||||
chmod a+x $(PREFIX)/bin/bzcat
|
|
||||||
chmod a+x $(PREFIX)/bin/bzip2recover
|
|
||||||
cp -f bzip2.1 $(PREFIX)/man/man1
|
|
||||||
chmod a+r $(PREFIX)/man/man1/bzip2.1
|
|
||||||
cp -f bzlib.h $(PREFIX)/include
|
|
||||||
chmod a+r $(PREFIX)/include/bzlib.h
|
|
||||||
cp -f libbz2.a $(PREFIX)/lib
|
|
||||||
chmod a+r $(PREFIX)/lib/libbz2.a
|
|
||||||
cp -f bzgrep $(PREFIX)/bin/bzgrep
|
|
||||||
ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep
|
|
||||||
ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep
|
|
||||||
chmod a+x $(PREFIX)/bin/bzgrep
|
|
||||||
cp -f bzmore $(PREFIX)/bin/bzmore
|
|
||||||
ln -s -f $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless
|
|
||||||
chmod a+x $(PREFIX)/bin/bzmore
|
|
||||||
cp -f bzdiff $(PREFIX)/bin/bzdiff
|
|
||||||
ln -s -f $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp
|
|
||||||
chmod a+x $(PREFIX)/bin/bzdiff
|
|
||||||
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/bzmore.1
|
|
||||||
chmod a+r $(PREFIX)/man/man1/bzdiff.1
|
|
||||||
echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzegrep.1
|
|
||||||
echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzfgrep.1
|
|
||||||
echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1
|
|
||||||
echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o libbz2.a bzip2 bzip2recover \
|
|
||||||
sample1.rb2 sample2.rb2 sample3.rb2 \
|
|
||||||
sample1.tst sample2.tst sample3.tst
|
|
||||||
|
|
||||||
blocksort.o: blocksort.c
|
|
||||||
@cat words0
|
|
||||||
$(CC) $(CFLAGS) -c blocksort.c
|
|
||||||
huffman.o: huffman.c
|
|
||||||
$(CC) $(CFLAGS) -c huffman.c
|
|
||||||
crctable.o: crctable.c
|
|
||||||
$(CC) $(CFLAGS) -c crctable.c
|
|
||||||
randtable.o: randtable.c
|
|
||||||
$(CC) $(CFLAGS) -c randtable.c
|
|
||||||
compress.o: compress.c
|
|
||||||
$(CC) $(CFLAGS) -c compress.c
|
|
||||||
decompress.o: decompress.c
|
|
||||||
$(CC) $(CFLAGS) -c decompress.c
|
|
||||||
bzlib.o: bzlib.c
|
|
||||||
$(CC) $(CFLAGS) -c bzlib.c
|
|
||||||
bzip2.o: bzip2.c
|
|
||||||
$(CC) $(CFLAGS) -c bzip2.c
|
|
||||||
bzip2recover.o: bzip2recover.c
|
|
||||||
$(CC) $(CFLAGS) -c bzip2recover.c
|
|
||||||
|
|
||||||
|
|
||||||
distclean: clean
|
|
||||||
rm -f manual.ps manual.html manual.pdf
|
|
||||||
|
|
||||||
DISTNAME=bzip2-1.0.8
|
|
||||||
dist: check manual
|
|
||||||
rm -f $(DISTNAME)
|
|
||||||
ln -s -f . $(DISTNAME)
|
|
||||||
tar cvf $(DISTNAME).tar \
|
|
||||||
$(DISTNAME)/blocksort.c \
|
|
||||||
$(DISTNAME)/huffman.c \
|
|
||||||
$(DISTNAME)/crctable.c \
|
|
||||||
$(DISTNAME)/randtable.c \
|
|
||||||
$(DISTNAME)/compress.c \
|
|
||||||
$(DISTNAME)/decompress.c \
|
|
||||||
$(DISTNAME)/bzlib.c \
|
|
||||||
$(DISTNAME)/bzip2.c \
|
|
||||||
$(DISTNAME)/bzip2recover.c \
|
|
||||||
$(DISTNAME)/bzlib.h \
|
|
||||||
$(DISTNAME)/bzlib_private.h \
|
|
||||||
$(DISTNAME)/Makefile \
|
|
||||||
$(DISTNAME)/LICENSE \
|
|
||||||
$(DISTNAME)/bzip2.1 \
|
|
||||||
$(DISTNAME)/bzip2.1.preformatted \
|
|
||||||
$(DISTNAME)/bzip2.txt \
|
|
||||||
$(DISTNAME)/words0 \
|
|
||||||
$(DISTNAME)/words1 \
|
|
||||||
$(DISTNAME)/words2 \
|
|
||||||
$(DISTNAME)/words3 \
|
|
||||||
$(DISTNAME)/sample1.ref \
|
|
||||||
$(DISTNAME)/sample2.ref \
|
|
||||||
$(DISTNAME)/sample3.ref \
|
|
||||||
$(DISTNAME)/sample1.bz2 \
|
|
||||||
$(DISTNAME)/sample2.bz2 \
|
|
||||||
$(DISTNAME)/sample3.bz2 \
|
|
||||||
$(DISTNAME)/dlltest.c \
|
|
||||||
$(DISTNAME)/manual.html \
|
|
||||||
$(DISTNAME)/manual.pdf \
|
|
||||||
$(DISTNAME)/manual.ps \
|
|
||||||
$(DISTNAME)/README \
|
|
||||||
$(DISTNAME)/README.COMPILATION.PROBLEMS \
|
|
||||||
$(DISTNAME)/README.XML.STUFF \
|
|
||||||
$(DISTNAME)/CHANGES \
|
|
||||||
$(DISTNAME)/libbz2.def \
|
|
||||||
$(DISTNAME)/libbz2.dsp \
|
|
||||||
$(DISTNAME)/dlltest.dsp \
|
|
||||||
$(DISTNAME)/makefile.msc \
|
|
||||||
$(DISTNAME)/unzcrash.c \
|
|
||||||
$(DISTNAME)/spewG.c \
|
|
||||||
$(DISTNAME)/mk251.c \
|
|
||||||
$(DISTNAME)/bzdiff \
|
|
||||||
$(DISTNAME)/bzdiff.1 \
|
|
||||||
$(DISTNAME)/bzmore \
|
|
||||||
$(DISTNAME)/bzmore.1 \
|
|
||||||
$(DISTNAME)/bzgrep \
|
|
||||||
$(DISTNAME)/bzgrep.1 \
|
|
||||||
$(DISTNAME)/Makefile-libbz2_so \
|
|
||||||
$(DISTNAME)/bz-common.xsl \
|
|
||||||
$(DISTNAME)/bz-fo.xsl \
|
|
||||||
$(DISTNAME)/bz-html.xsl \
|
|
||||||
$(DISTNAME)/bzip.css \
|
|
||||||
$(DISTNAME)/entities.xml \
|
|
||||||
$(DISTNAME)/manual.xml \
|
|
||||||
$(DISTNAME)/format.pl \
|
|
||||||
$(DISTNAME)/xmlproc.sh
|
|
||||||
gzip -v $(DISTNAME).tar
|
|
||||||
|
|
||||||
# For rebuilding the manual from sources on my SuSE 9.1 box
|
|
||||||
|
|
||||||
MANUAL_SRCS= bz-common.xsl bz-fo.xsl bz-html.xsl bzip.css \
|
|
||||||
entities.xml manual.xml
|
|
||||||
|
|
||||||
manual: manual.html manual.ps manual.pdf
|
|
||||||
|
|
||||||
manual.ps: $(MANUAL_SRCS)
|
|
||||||
./xmlproc.sh -ps manual.xml
|
|
||||||
|
|
||||||
manual.pdf: $(MANUAL_SRCS)
|
|
||||||
./xmlproc.sh -pdf manual.xml
|
|
||||||
|
|
||||||
manual.html: $(MANUAL_SRCS)
|
|
||||||
./xmlproc.sh -html manual.xml
|
|
59
third_party/bzip2/Makefile-libbz2_so
vendored
59
third_party/bzip2/Makefile-libbz2_so
vendored
|
@ -1,59 +0,0 @@
|
||||||
|
|
||||||
# This Makefile builds a shared version of the library,
|
|
||||||
# libbz2.so.1.0.8, with soname libbz2.so.1.0,
|
|
||||||
# at least on x86-Linux (RedHat 7.2),
|
|
||||||
# with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98).
|
|
||||||
# Please see the README file for some important info
|
|
||||||
# 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.8 of 13 July 2019
|
|
||||||
# Copyright (C) 1996-2019 Julian Seward <jseward@acm.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
|
|
||||||
CC=gcc
|
|
||||||
BIGFILES=-D_FILE_OFFSET_BITS=64
|
|
||||||
CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
|
|
||||||
|
|
||||||
OBJS= blocksort.o \
|
|
||||||
huffman.o \
|
|
||||||
crctable.o \
|
|
||||||
randtable.o \
|
|
||||||
compress.o \
|
|
||||||
decompress.o \
|
|
||||||
bzlib.o
|
|
||||||
|
|
||||||
all: $(OBJS)
|
|
||||||
$(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.8 $(OBJS)
|
|
||||||
$(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.8
|
|
||||||
rm -f libbz2.so.1.0
|
|
||||||
ln -s libbz2.so.1.0.8 libbz2.so.1.0
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OBJS) bzip2.o libbz2.so.1.0.8 libbz2.so.1.0 bzip2-shared
|
|
||||||
|
|
||||||
blocksort.o: blocksort.c
|
|
||||||
$(CC) $(CFLAGS) -c blocksort.c
|
|
||||||
huffman.o: huffman.c
|
|
||||||
$(CC) $(CFLAGS) -c huffman.c
|
|
||||||
crctable.o: crctable.c
|
|
||||||
$(CC) $(CFLAGS) -c crctable.c
|
|
||||||
randtable.o: randtable.c
|
|
||||||
$(CC) $(CFLAGS) -c randtable.c
|
|
||||||
compress.o: compress.c
|
|
||||||
$(CC) $(CFLAGS) -c compress.c
|
|
||||||
decompress.o: decompress.c
|
|
||||||
$(CC) $(CFLAGS) -c decompress.c
|
|
||||||
bzlib.o: bzlib.c
|
|
||||||
$(CC) $(CFLAGS) -c bzlib.c
|
|
58
third_party/bzip2/README.COMPILATION.PROBLEMS
vendored
58
third_party/bzip2/README.COMPILATION.PROBLEMS
vendored
|
@ -1,58 +0,0 @@
|
||||||
------------------------------------------------------------------
|
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
|
||||||
lossless, block-sorting data compression.
|
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.8 of 13 July 2019
|
|
||||||
Copyright (C) 1996-2019 Julian Seward <jseward@acm.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 should compile without problems on the vast majority of
|
|
||||||
platforms. Using the supplied Makefile, I've built and tested it
|
|
||||||
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
|
|
||||||
support seems to work correctly on at least on amd64-linux.
|
|
||||||
|
|
||||||
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,
|
|
||||||
but many newer ones can. Large files are pretty huge -- most files
|
|
||||||
you'll encounter are not Large Files.
|
|
||||||
|
|
||||||
Early versions of bzip2 (0.1, 0.9.0, 0.9.5) compiled on a wide variety
|
|
||||||
of platforms without difficulty, and I hope this version will continue
|
|
||||||
in that tradition. However, in order to support large files, I've had
|
|
||||||
to include the define -D_FILE_OFFSET_BITS=64 in the Makefile. This
|
|
||||||
can cause problems.
|
|
||||||
|
|
||||||
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
|
|
||||||
file support. For more details, see the Large File Support
|
|
||||||
Specification, published by the Large File Summit, at
|
|
||||||
|
|
||||||
http://ftp.sas.com/standards/large.file
|
|
||||||
|
|
||||||
As a general comment, if you get compilation errors which you think
|
|
||||||
are related to large file support, try removing the above define from
|
|
||||||
the Makefile, ie, delete the line
|
|
||||||
|
|
||||||
BIGFILES=-D_FILE_OFFSET_BITS=64
|
|
||||||
|
|
||||||
from the Makefile, and do 'make clean ; make'. This will give you a
|
|
||||||
version of bzip2 without large file support, which, for most
|
|
||||||
applications, is probably not a problem.
|
|
||||||
|
|
||||||
Alternatively, try some of the platform-specific hints listed below.
|
|
||||||
|
|
||||||
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
|
|
||||||
any compilation problems which affect bzip2 will also affect spewG.c,
|
|
||||||
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.
|
|
45
third_party/bzip2/README.XML.STUFF
vendored
45
third_party/bzip2/README.XML.STUFF
vendored
|
@ -1,45 +0,0 @@
|
||||||
----------------------------------------------------------------
|
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
|
||||||
lossless, block-sorting data compression.
|
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.8 of 13 July 2019
|
|
||||||
Copyright (C) 1996-2019 Julian Seward <jseward@acm.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.
|
|
||||||
----------------------------------------------------------------
|
|
||||||
|
|
||||||
The script xmlproc.sh takes an xml file as input,
|
|
||||||
and processes it to create .pdf, .html or .ps output.
|
|
||||||
It uses format.pl, a perl script to format <pre> blocks nicely,
|
|
||||||
and add CDATA tags so writers do not have to use eg. <
|
|
||||||
|
|
||||||
The file "entities.xml" must be edited to reflect current
|
|
||||||
version, year, etc.
|
|
||||||
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
./xmlproc.sh -v manual.xml
|
|
||||||
Validates an xml file to ensure no dtd-compliance errors
|
|
||||||
|
|
||||||
./xmlproc.sh -html manual.xml
|
|
||||||
Output: manual.html
|
|
||||||
|
|
||||||
./xmlproc.sh -pdf manual.xml
|
|
||||||
Output: manual.pdf
|
|
||||||
|
|
||||||
./xmlproc.sh -ps manual.xml
|
|
||||||
Output: manual.ps
|
|
||||||
|
|
||||||
|
|
||||||
Notum bene:
|
|
||||||
- pdfxmltex barfs if given a filename with an underscore in it
|
|
||||||
|
|
||||||
- xmltex won't work yet - there's a bug in passivetex
|
|
||||||
which we are all waiting for Sebastian to fix.
|
|
||||||
So we are going the xml -> pdf -> ps route for the time being,
|
|
||||||
using pdfxmltex.
|
|
11
third_party/bzip2/blocksort.c
vendored
11
third_party/bzip2/blocksort.c
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- Block sorting machinery ---*/
|
/*--- Block sorting machinery ---*/
|
||||||
|
@ -19,7 +20,9 @@
|
||||||
------------------------------------------------------------------ */
|
------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
#include "bzlib_private.h"
|
#include "libc/runtime/gc.internal.h"
|
||||||
|
#include "libc/mem/mem.h"
|
||||||
|
#include "third_party/bzip2/bzlib_private.inc"
|
||||||
|
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
/*--- Fallback O(N log(N)^2) sorting ---*/
|
/*--- Fallback O(N log(N)^2) sorting ---*/
|
||||||
|
@ -757,10 +760,10 @@ void mainSort ( UInt32* ptr,
|
||||||
Int32* budget )
|
Int32* budget )
|
||||||
{
|
{
|
||||||
Int32 i, j, k, ss, sb;
|
Int32 i, j, k, ss, sb;
|
||||||
Int32 runningOrder[256];
|
|
||||||
Bool bigDone[256];
|
Bool bigDone[256];
|
||||||
Int32 copyStart[256];
|
Int32 *runningOrder = gc(calloc(256,4));
|
||||||
Int32 copyEnd [256];
|
Int32 *copyStart = gc(calloc(256,4));
|
||||||
|
Int32 *copyEnd = gc(calloc(256,4));
|
||||||
UChar c1;
|
UChar c1;
|
||||||
Int32 numQSorted;
|
Int32 numQSorted;
|
||||||
UInt16 s;
|
UInt16 s;
|
||||||
|
|
39
third_party/bzip2/bz-common.xsl
vendored
39
third_party/bzip2/bz-common.xsl
vendored
|
@ -1,39 +0,0 @@
|
||||||
<?xml version="1.0"?> <!-- -*- sgml -*- -->
|
|
||||||
<xsl:stylesheet
|
|
||||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
|
||||||
|
|
||||||
<!-- we like '1.2 Title' -->
|
|
||||||
<xsl:param name="section.autolabel" select="'1'"/>
|
|
||||||
<xsl:param name="section.label.includes.component.label" select="'1'"/>
|
|
||||||
|
|
||||||
<!-- Do not put 'Chapter' at the start of eg 'Chapter 1. Doing This' -->
|
|
||||||
<xsl:param name="local.l10n.xml" select="document('')"/>
|
|
||||||
<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
|
|
||||||
<l:l10n language="en">
|
|
||||||
<l:context name="title-numbered">
|
|
||||||
<l:template name="chapter" text="%n. %t"/>
|
|
||||||
</l:context>
|
|
||||||
</l:l10n>
|
|
||||||
</l:i18n>
|
|
||||||
|
|
||||||
<!-- don't generate sub-tocs for qanda sets -->
|
|
||||||
<xsl:param name="generate.toc">
|
|
||||||
set toc,title
|
|
||||||
book toc,title,figure,table,example,equation
|
|
||||||
chapter toc,title
|
|
||||||
section toc
|
|
||||||
sect1 toc
|
|
||||||
sect2 toc
|
|
||||||
sect3 toc
|
|
||||||
sect4 nop
|
|
||||||
sect5 nop
|
|
||||||
qandaset toc
|
|
||||||
qandadiv nop
|
|
||||||
appendix toc,title
|
|
||||||
article/appendix nop
|
|
||||||
article toc,title
|
|
||||||
preface toc,title
|
|
||||||
reference toc,title
|
|
||||||
</xsl:param>
|
|
||||||
|
|
||||||
</xsl:stylesheet>
|
|
276
third_party/bzip2/bz-fo.xsl
vendored
276
third_party/bzip2/bz-fo.xsl
vendored
|
@ -1,276 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- sgml -*- -->
|
|
||||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
||||||
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
|
|
||||||
|
|
||||||
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>
|
|
||||||
<xsl:import href="bz-common.xsl"/>
|
|
||||||
|
|
||||||
<!-- set indent = yes while debugging, then change to NO -->
|
|
||||||
<xsl:output method="xml" indent="yes"/>
|
|
||||||
|
|
||||||
<!-- ensure only passivetex extensions are on -->
|
|
||||||
<xsl:param name="stylesheet.result.type" select="'fo'"/>
|
|
||||||
<!-- fo extensions: PDF bookmarks and index terms -->
|
|
||||||
<xsl:param name="use.extensions" select="'1'"/>
|
|
||||||
<xsl:param name="xep.extensions" select="0"/>
|
|
||||||
<xsl:param name="fop.extensions" select="0"/>
|
|
||||||
<xsl:param name="saxon.extensions" select="0"/>
|
|
||||||
<xsl:param name="passivetex.extensions" select="1"/>
|
|
||||||
<xsl:param name="tablecolumns.extension" select="'1'"/>
|
|
||||||
|
|
||||||
<!-- ensure we are using single sided -->
|
|
||||||
<xsl:param name="double.sided" select="'0'"/>
|
|
||||||
|
|
||||||
<!-- insert cross references to page numbers -->
|
|
||||||
<xsl:param name="insert.xref.page.number" select="1"/>
|
|
||||||
|
|
||||||
<!-- <?custom-pagebreak?> inserts a page break at this point -->
|
|
||||||
<xsl:template match="processing-instruction('custom-pagebreak')">
|
|
||||||
<fo:block break-before='page'/>
|
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
<!-- show links in color -->
|
|
||||||
<xsl:attribute-set name="xref.properties">
|
|
||||||
<xsl:attribute name="color">blue</xsl:attribute>
|
|
||||||
</xsl:attribute-set>
|
|
||||||
|
|
||||||
<!-- make pre listings indented a bit + a bg colour -->
|
|
||||||
<xsl:template match="programlisting | screen">
|
|
||||||
<fo:block start-indent="0.25in" wrap-option="no-wrap"
|
|
||||||
white-space-collapse="false" text-align="start"
|
|
||||||
font-family="monospace" background-color="#f2f2f9"
|
|
||||||
linefeed-treatment="preserve"
|
|
||||||
xsl:use-attribute-sets="normal.para.spacing">
|
|
||||||
<xsl:apply-templates/>
|
|
||||||
</fo:block>
|
|
||||||
</xsl:template>
|
|
||||||
<!-- make verbatim output prettier -->
|
|
||||||
<xsl:template match="literallayout">
|
|
||||||
<fo:block start-indent="0.25in" wrap-option="no-wrap"
|
|
||||||
white-space-collapse="false" text-align="start"
|
|
||||||
font-family="monospace" background-color="#edf7f4"
|
|
||||||
linefeed-treatment="preserve"
|
|
||||||
space-before="0em" space-after="0em">
|
|
||||||
<xsl:apply-templates/>
|
|
||||||
</fo:block>
|
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
<!-- workaround bug in passivetex fo output for itemizedlist -->
|
|
||||||
<xsl:template match="itemizedlist/listitem">
|
|
||||||
<xsl:variable name="id">
|
|
||||||
<xsl:call-template name="object.id"/></xsl:variable>
|
|
||||||
<xsl:variable name="itemsymbol">
|
|
||||||
<xsl:call-template name="list.itemsymbol">
|
|
||||||
<xsl:with-param name="node" select="parent::itemizedlist"/>
|
|
||||||
</xsl:call-template>
|
|
||||||
</xsl:variable>
|
|
||||||
<xsl:variable name="item.contents">
|
|
||||||
<fo:list-item-label end-indent="label-end()">
|
|
||||||
<fo:block>
|
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="$itemsymbol='disc'">•</xsl:when>
|
|
||||||
<xsl:when test="$itemsymbol='bullet'">•</xsl:when>
|
|
||||||
<xsl:otherwise>•</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</fo:block>
|
|
||||||
</fo:list-item-label>
|
|
||||||
<fo:list-item-body start-indent="body-start()">
|
|
||||||
<xsl:apply-templates/> <!-- removed extra block wrapper -->
|
|
||||||
</fo:list-item-body>
|
|
||||||
</xsl:variable>
|
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="parent::*/@spacing = 'compact'">
|
|
||||||
<fo:list-item id="{$id}"
|
|
||||||
xsl:use-attribute-sets="compact.list.item.spacing">
|
|
||||||
<xsl:copy-of select="$item.contents"/>
|
|
||||||
</fo:list-item>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
|
|
||||||
<xsl:copy-of select="$item.contents"/>
|
|
||||||
</fo:list-item>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
<!-- workaround bug in passivetex fo output for orderedlist -->
|
|
||||||
<xsl:template match="orderedlist/listitem">
|
|
||||||
<xsl:variable name="id">
|
|
||||||
<xsl:call-template name="object.id"/></xsl:variable>
|
|
||||||
<xsl:variable name="item.contents">
|
|
||||||
<fo:list-item-label end-indent="label-end()">
|
|
||||||
<fo:block>
|
|
||||||
<xsl:apply-templates select="." mode="item-number"/>
|
|
||||||
</fo:block>
|
|
||||||
</fo:list-item-label>
|
|
||||||
<fo:list-item-body start-indent="body-start()">
|
|
||||||
<xsl:apply-templates/> <!-- removed extra block wrapper -->
|
|
||||||
</fo:list-item-body>
|
|
||||||
</xsl:variable>
|
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="parent::*/@spacing = 'compact'">
|
|
||||||
<fo:list-item id="{$id}"
|
|
||||||
xsl:use-attribute-sets="compact.list.item.spacing">
|
|
||||||
<xsl:copy-of select="$item.contents"/>
|
|
||||||
</fo:list-item>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
|
|
||||||
<xsl:copy-of select="$item.contents"/>
|
|
||||||
</fo:list-item>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
<!-- workaround bug in passivetex fo output for variablelist -->
|
|
||||||
<xsl:param name="variablelist.as.blocks" select="1"/>
|
|
||||||
<xsl:template match="varlistentry" mode="vl.as.blocks">
|
|
||||||
<xsl:variable name="id">
|
|
||||||
<xsl:call-template name="object.id"/></xsl:variable>
|
|
||||||
<fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
|
|
||||||
keep-together.within-column="always"
|
|
||||||
keep-with-next.within-column="always">
|
|
||||||
<xsl:apply-templates select="term"/>
|
|
||||||
</fo:block>
|
|
||||||
<fo:block start-indent="0.5in" end-indent="0in"
|
|
||||||
space-after.minimum="0.2em"
|
|
||||||
space-after.optimum="0.4em"
|
|
||||||
space-after.maximum="0.6em">
|
|
||||||
<fo:block>
|
|
||||||
<xsl:apply-templates select="listitem"/>
|
|
||||||
</fo:block>
|
|
||||||
</fo:block>
|
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- workaround bug in footers: force right-align w/two 80|30 cols -->
|
|
||||||
<xsl:template name="footer.table">
|
|
||||||
<xsl:param name="pageclass" select="''"/>
|
|
||||||
<xsl:param name="sequence" select="''"/>
|
|
||||||
<xsl:param name="gentext-key" select="''"/>
|
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="$pageclass = 'index'">
|
|
||||||
<xsl:attribute name="margin-left">0pt</xsl:attribute>
|
|
||||||
</xsl:when>
|
|
||||||
</xsl:choose>
|
|
||||||
<xsl:variable name="candidate">
|
|
||||||
<fo:table table-layout="fixed" width="100%">
|
|
||||||
<fo:table-column column-number="1" column-width="80%"/>
|
|
||||||
<fo:table-column column-number="2" column-width="20%"/>
|
|
||||||
<fo:table-body>
|
|
||||||
<fo:table-row height="14pt">
|
|
||||||
<fo:table-cell text-align="left" display-align="after">
|
|
||||||
<xsl:attribute name="relative-align">baseline</xsl:attribute>
|
|
||||||
<fo:block>
|
|
||||||
<fo:block> </fo:block><!-- empty cell -->
|
|
||||||
</fo:block>
|
|
||||||
</fo:table-cell>
|
|
||||||
<fo:table-cell text-align="center" display-align="after">
|
|
||||||
<xsl:attribute name="relative-align">baseline</xsl:attribute>
|
|
||||||
<fo:block>
|
|
||||||
<xsl:call-template name="footer.content">
|
|
||||||
<xsl:with-param name="pageclass" select="$pageclass"/>
|
|
||||||
<xsl:with-param name="sequence" select="$sequence"/>
|
|
||||||
<xsl:with-param name="position" select="'center'"/>
|
|
||||||
<xsl:with-param name="gentext-key" select="$gentext-key"/>
|
|
||||||
</xsl:call-template>
|
|
||||||
</fo:block>
|
|
||||||
</fo:table-cell>
|
|
||||||
</fo:table-row>
|
|
||||||
</fo:table-body>
|
|
||||||
</fo:table>
|
|
||||||
</xsl:variable>
|
|
||||||
<!-- Really output a footer? -->
|
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="$pageclass='titlepage' and $gentext-key='book'
|
|
||||||
and $sequence='first'">
|
|
||||||
<!-- no, book titlepages have no footers at all -->
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:when test="$sequence = 'blank' and $footers.on.blank.pages = 0">
|
|
||||||
<!-- no output -->
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:copy-of select="$candidate"/>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- fix bug in headers: force right-align w/two 40|60 cols -->
|
|
||||||
<xsl:template name="header.table">
|
|
||||||
<xsl:param name="pageclass" select="''"/>
|
|
||||||
<xsl:param name="sequence" select="''"/>
|
|
||||||
<xsl:param name="gentext-key" select="''"/>
|
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="$pageclass = 'index'">
|
|
||||||
<xsl:attribute name="margin-left">0pt</xsl:attribute>
|
|
||||||
</xsl:when>
|
|
||||||
</xsl:choose>
|
|
||||||
<xsl:variable name="candidate">
|
|
||||||
<fo:table table-layout="fixed" width="100%">
|
|
||||||
<xsl:call-template name="head.sep.rule">
|
|
||||||
<xsl:with-param name="pageclass" select="$pageclass"/>
|
|
||||||
<xsl:with-param name="sequence" select="$sequence"/>
|
|
||||||
<xsl:with-param name="gentext-key" select="$gentext-key"/>
|
|
||||||
</xsl:call-template>
|
|
||||||
<fo:table-column column-number="1" column-width="40%"/>
|
|
||||||
<fo:table-column column-number="2" column-width="60%"/>
|
|
||||||
<fo:table-body>
|
|
||||||
<fo:table-row height="14pt">
|
|
||||||
<fo:table-cell text-align="left" display-align="before">
|
|
||||||
<xsl:attribute name="relative-align">baseline</xsl:attribute>
|
|
||||||
<fo:block>
|
|
||||||
<fo:block> </fo:block><!-- empty cell -->
|
|
||||||
</fo:block>
|
|
||||||
</fo:table-cell>
|
|
||||||
<fo:table-cell text-align="center" display-align="before">
|
|
||||||
<xsl:attribute name="relative-align">baseline</xsl:attribute>
|
|
||||||
<fo:block>
|
|
||||||
<xsl:call-template name="header.content">
|
|
||||||
<xsl:with-param name="pageclass" select="$pageclass"/>
|
|
||||||
<xsl:with-param name="sequence" select="$sequence"/>
|
|
||||||
<xsl:with-param name="position" select="'center'"/>
|
|
||||||
<xsl:with-param name="gentext-key" select="$gentext-key"/>
|
|
||||||
</xsl:call-template>
|
|
||||||
</fo:block>
|
|
||||||
</fo:table-cell>
|
|
||||||
</fo:table-row>
|
|
||||||
</fo:table-body>
|
|
||||||
</fo:table>
|
|
||||||
</xsl:variable>
|
|
||||||
<!-- Really output a header? -->
|
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="$pageclass = 'titlepage' and $gentext-key = 'book'
|
|
||||||
and $sequence='first'">
|
|
||||||
<!-- no, book titlepages have no headers at all -->
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:when test="$sequence = 'blank' and $headers.on.blank.pages = 0">
|
|
||||||
<!-- no output -->
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:copy-of select="$candidate"/>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Bug-fix for Suse 10 PassiveTex version -->
|
|
||||||
<!-- Precompute attribute values 'cos PassiveTex is too stupid: -->
|
|
||||||
<xsl:attribute-set name="component.title.properties">
|
|
||||||
<xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
|
|
||||||
<xsl:attribute name="space-before.optimum">
|
|
||||||
<xsl:value-of select="concat($body.font.master, 'pt')"/>
|
|
||||||
</xsl:attribute>
|
|
||||||
<xsl:attribute name="space-before.minimum">
|
|
||||||
<xsl:value-of select="$body.font.master * 0.8"/>
|
|
||||||
<xsl:text>pt</xsl:text>
|
|
||||||
</xsl:attribute>
|
|
||||||
<xsl:attribute name="space-before.maximum">
|
|
||||||
<xsl:value-of select="$body.font.master * 1.2"/>
|
|
||||||
<xsl:text>pt</xsl:text>
|
|
||||||
</xsl:attribute>
|
|
||||||
<xsl:attribute name="hyphenate">false</xsl:attribute>
|
|
||||||
</xsl:attribute-set>
|
|
||||||
|
|
||||||
|
|
||||||
</xsl:stylesheet>
|
|
23
third_party/bzip2/bz-html.xsl
vendored
23
third_party/bzip2/bz-html.xsl
vendored
|
@ -1,23 +0,0 @@
|
||||||
<?xml version="1.0"?> <!-- -*- sgml -*- -->
|
|
||||||
<!DOCTYPE xsl:stylesheet [ <!ENTITY bz-css SYSTEM "./bzip.css"> ]>
|
|
||||||
|
|
||||||
<xsl:stylesheet
|
|
||||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
|
||||||
|
|
||||||
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
|
|
||||||
<xsl:import href="bz-common.xsl"/>
|
|
||||||
|
|
||||||
<!-- use UTF-8 encoding -->
|
|
||||||
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
|
|
||||||
|
|
||||||
<!-- we include the css as link and directly when generating one large file -->
|
|
||||||
<xsl:template name="user.head.content">
|
|
||||||
<xsl:text disable-output-escaping="yes">
|
|
||||||
<![CDATA[<]]>link rel="stylesheet" type="text/css" href="bzip.css" />
|
|
||||||
</xsl:text>
|
|
||||||
<style type="text/css" media="screen">
|
|
||||||
<xsl:text>&bz-css;</xsl:text>
|
|
||||||
</style>
|
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
</xsl:stylesheet>
|
|
22
third_party/bzip2/bz_internal_error.c
vendored
Normal file
22
third_party/bzip2/bz_internal_error.c
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||||
|
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||||
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||||
|
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||||
|
│ │
|
||||||
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||||
|
│ any purpose with or without fee is hereby granted, provided that the │
|
||||||
|
│ above copyright notice and this permission notice appear in all copies. │
|
||||||
|
│ │
|
||||||
|
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||||
|
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||||
|
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||||
|
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||||
|
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||||
|
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||||
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||||
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
|
|
||||||
|
void bz_internal_error(int err) {
|
||||||
|
asm("hlt");
|
||||||
|
}
|
74
third_party/bzip2/bzip.css
vendored
74
third_party/bzip2/bzip.css
vendored
|
@ -1,74 +0,0 @@
|
||||||
/* Colours:
|
|
||||||
#74240f dark brown h1, h2, h3, h4
|
|
||||||
#336699 medium blue links
|
|
||||||
#339999 turquoise link hover colour
|
|
||||||
#202020 almost black general text
|
|
||||||
#761596 purple md5sum text
|
|
||||||
#626262 dark gray pre border
|
|
||||||
#eeeeee very light gray pre background
|
|
||||||
#f2f2f9 very light blue nav table background
|
|
||||||
#3366cc medium blue nav table border
|
|
||||||
*/
|
|
||||||
|
|
||||||
a, a:link, a:visited, a:active { color: #336699; }
|
|
||||||
a:hover { color: #339999; }
|
|
||||||
|
|
||||||
body { font: 80%/126% sans-serif; }
|
|
||||||
h1, h2, h3, h4 { color: #74240f; }
|
|
||||||
|
|
||||||
dt { color: #336699; font-weight: bold }
|
|
||||||
dd {
|
|
||||||
margin-left: 1.5em;
|
|
||||||
padding-bottom: 0.8em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- ruler -- */
|
|
||||||
div.hr_blue {
|
|
||||||
height: 3px;
|
|
||||||
background:#ffffff url("../images/hr_blue.png") repeat-x; }
|
|
||||||
div.hr_blue hr { display:none; }
|
|
||||||
|
|
||||||
/* release styles */
|
|
||||||
#release p { margin-top: 0.4em; }
|
|
||||||
#release .md5sum { color: #761596; }
|
|
||||||
|
|
||||||
|
|
||||||
/* ------ styles for docs|manuals|howto ------ */
|
|
||||||
/* -- lists -- */
|
|
||||||
ul {
|
|
||||||
margin: 0px 4px 16px 16px;
|
|
||||||
padding: 0px;
|
|
||||||
list-style: url("../images/li-blue.png");
|
|
||||||
}
|
|
||||||
ul li {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
ul ul {
|
|
||||||
list-style-type: none;
|
|
||||||
list-style-image: none;
|
|
||||||
margin-left: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* header / footer nav tables */
|
|
||||||
table.nav {
|
|
||||||
border: solid 1px #3366cc;
|
|
||||||
background: #f2f2f9;
|
|
||||||
background-color: #f2f2f9;
|
|
||||||
margin-bottom: 0.5em;
|
|
||||||
}
|
|
||||||
/* don't have underlined links in chunked nav menus */
|
|
||||||
table.nav a { text-decoration: none; }
|
|
||||||
table.nav a:hover { text-decoration: underline; }
|
|
||||||
table.nav td { font-size: 85%; }
|
|
||||||
|
|
||||||
code, tt, pre { font-size: 120%; }
|
|
||||||
code, tt { color: #761596; }
|
|
||||||
|
|
||||||
div.literallayout, pre.programlisting, pre.screen {
|
|
||||||
color: #000000;
|
|
||||||
padding: 0.5em;
|
|
||||||
background: #eeeeee;
|
|
||||||
border: 1px solid #626262;
|
|
||||||
background-color: #eeeeee;
|
|
||||||
margin: 4px 0px 4px 0px;
|
|
||||||
}
|
|
|
@ -2,54 +2,54 @@ bzip2(1) bzip2(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NNAAMMEE
|
𝐍𝐀𝐌𝐄
|
||||||
bzip2, bunzip2 − a block‐sorting file compressor, v1.0.8
|
bzip2, bunzip2 − a block-sorting file compressor, v1.0.8
|
||||||
bzcat − decompresses files to stdout
|
bzcat − decompresses files to stdout
|
||||||
bzip2recover − recovers data from damaged bzip2 files
|
bzip2recover − recovers data from damaged bzip2 files
|
||||||
|
|
||||||
|
|
||||||
SSYYNNOOPPSSIISS
|
𝐒𝐘𝐍𝐎𝐏𝐒𝐈𝐒
|
||||||
bbzziipp22 [ −−ccddffkkqqssttvvzzVVLL112233445566778899 ] [ _f_i_l_e_n_a_m_e_s _._._. ]
|
𝗯𝘇𝗶𝗽𝟮 [ −𝗰𝗱𝗳𝗸𝗾𝘀𝘁𝘃𝘇𝐕𝐋𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵 ] [ f̲i̲l̲e̲n̲a̲m̲e̲s̲ .̲.̲.̲ ]
|
||||||
bbuunnzziipp22 [ −−ffkkvvssVVLL ] [ _f_i_l_e_n_a_m_e_s _._._. ]
|
𝗯𝘂𝗻𝘇𝗶𝗽𝟮 [ −𝗳𝗸𝘃𝘀𝐕𝐋 ] [ f̲i̲l̲e̲n̲a̲m̲e̲s̲ .̲.̲.̲ ]
|
||||||
bbzzccaatt [ −−ss ] [ _f_i_l_e_n_a_m_e_s _._._. ]
|
𝗯𝘇𝗰𝗮𝘁 [ −𝘀 ] [ f̲i̲l̲e̲n̲a̲m̲e̲s̲ .̲.̲.̲ ]
|
||||||
bbzziipp22rreeccoovveerr _f_i_l_e_n_a_m_e
|
𝗯𝘇𝗶𝗽𝟮𝗿𝗲𝗰𝗼𝘃𝗲𝗿 f̲i̲l̲e̲n̲a̲m̲e̲
|
||||||
|
|
||||||
|
|
||||||
DDEESSCCRRIIPPTTIIOONN
|
𝐃𝐄𝐒𝐂𝐑𝐈𝐏𝐓𝐈𝐎𝐍
|
||||||
_b_z_i_p_2 compresses files using the Burrows‐Wheeler block
|
b̲z̲i̲p̲2̲ compresses files using the Burrows-Wheeler block
|
||||||
sorting text compression algorithm, and Huffman coding.
|
sorting text compression algorithm, and Huffman coding.
|
||||||
Compression is generally considerably better than that
|
Compression is generally considerably better than that
|
||||||
achieved by more conventional LZ77/LZ78‐based compressors,
|
achieved by more conventional LZ77/LZ78-based compressors,
|
||||||
and approaches the performance of the PPM family of sta
|
and approaches the performance of the PPM family of sta-
|
||||||
tistical compressors.
|
tistical compressors.
|
||||||
|
|
||||||
The command‐line options are deliberately very similar to
|
The command-line options are deliberately very similar to
|
||||||
those of _G_N_U _g_z_i_p_, but they are not identical.
|
those of G̲N̲U̲ g̲z̲i̲p̲,̲ but they are not identical.
|
||||||
|
|
||||||
_b_z_i_p_2 expects a list of file names to accompany the com
|
b̲z̲i̲p̲2̲ expects a list of file names to accompany the com-
|
||||||
mand‐line flags. Each file is replaced by a compressed
|
mand-line flags. Each file is replaced by a compressed
|
||||||
version of itself, with the name "original_name.bz2".
|
version of itself, with the name "original_name.bz2".
|
||||||
Each compressed file has the same modification date, per
|
Each compressed file has the same modification date, per-
|
||||||
missions, and, when possible, ownership as the correspond
|
missions, and, when possible, ownership as the correspond-
|
||||||
ing original, so that these properties can be correctly
|
ing original, so that these properties can be correctly
|
||||||
restored at decompression time. File name handling is
|
restored at decompression time. File name handling is
|
||||||
naive in the sense that there is no mechanism for preserv
|
naive in the sense that there is no mechanism for preserv-
|
||||||
ing original file names, permissions, ownerships or dates
|
ing original file names, permissions, ownerships or dates
|
||||||
in filesystems which lack these concepts, or have serious
|
in filesystems which lack these concepts, or have serious
|
||||||
file name length restrictions, such as MS‐DOS.
|
file name length restrictions, such as MS-DOS.
|
||||||
|
|
||||||
_b_z_i_p_2 and _b_u_n_z_i_p_2 will by default not overwrite existing
|
b̲z̲i̲p̲2̲ and b̲u̲n̲z̲i̲p̲2̲ will by default not overwrite existing
|
||||||
files. If you want this to happen, specify the −f flag.
|
files. If you want this to happen, specify the −f flag.
|
||||||
|
|
||||||
If no file names are specified, _b_z_i_p_2 compresses from
|
If no file names are specified, b̲z̲i̲p̲2̲ compresses from
|
||||||
standard input to standard output. In this case, _b_z_i_p_2
|
standard input to standard output. In this case, b̲z̲i̲p̲2̲
|
||||||
will decline to write compressed output to a terminal, as
|
will decline to write compressed output to a terminal, as
|
||||||
this would be entirely incomprehensible and therefore
|
this would be entirely incomprehensible and therefore
|
||||||
pointless.
|
pointless.
|
||||||
|
|
||||||
_b_u_n_z_i_p_2 (or _b_z_i_p_2 _−_d_) decompresses all specified files.
|
b̲u̲n̲z̲i̲p̲2̲ (or b̲z̲i̲p̲2̲ −̲d̲)̲ decompresses all specified files.
|
||||||
Files which were not created by _b_z_i_p_2 will be detected and
|
Files which were not created by b̲z̲i̲p̲2̲ will be detected and
|
||||||
ignored, and a warning issued. _b_z_i_p_2 attempts to guess
|
ignored, and a warning issued. b̲z̲i̲p̲2̲ attempts to guess
|
||||||
the filename for the decompressed file from that of the
|
the filename for the decompressed file from that of the
|
||||||
compressed file as follows:
|
compressed file as follows:
|
||||||
|
|
||||||
|
@ -60,34 +60,34 @@ DDEESSCCRRIIPPTTIIOONN
|
||||||
anyothername becomes anyothername.out
|
anyothername becomes anyothername.out
|
||||||
|
|
||||||
If the file does not end in one of the recognised endings,
|
If the file does not end in one of the recognised endings,
|
||||||
_._b_z_2_, _._b_z_, _._t_b_z_2 or _._t_b_z_, _b_z_i_p_2 complains that it cannot
|
.̲b̲z̲2̲,̲ .̲b̲z̲,̲ .̲t̲b̲z̲2̲ or .̲t̲b̲z̲,̲ b̲z̲i̲p̲2̲ complains that it cannot
|
||||||
guess the name of the original file, and uses the original
|
guess the name of the original file, and uses the original
|
||||||
name with _._o_u_t appended.
|
name with .̲o̲u̲t̲ appended.
|
||||||
|
|
||||||
As with compression, supplying no filenames causes decom
|
As with compression, supplying no filenames causes decom-
|
||||||
pression from standard input to standard output.
|
pression from standard input to standard output.
|
||||||
|
|
||||||
_b_u_n_z_i_p_2 will correctly decompress a file which is the con
|
b̲u̲n̲z̲i̲p̲2̲ will correctly decompress a file which is the con-
|
||||||
catenation of two or more compressed files. The result is
|
catenation of two or more compressed files. The result is
|
||||||
the concatenation of the corresponding uncompressed files.
|
the concatenation of the corresponding uncompressed files.
|
||||||
Integrity testing (−t) of concatenated compressed files is
|
Integrity testing (−t) of concatenated compressed files is
|
||||||
also supported.
|
also supported.
|
||||||
|
|
||||||
You can also compress or decompress files to the standard
|
You can also compress or decompress files to the standard
|
||||||
output by giving the −c flag. Multiple files may be com
|
output by giving the −c flag. Multiple files may be com-
|
||||||
pressed and decompressed like this. The resulting outputs
|
pressed and decompressed like this. The resulting outputs
|
||||||
are fed sequentially to stdout. Compression of multiple
|
are fed sequentially to stdout. Compression of multiple
|
||||||
files in this manner generates a stream containing multi
|
files in this manner generates a stream containing multi-
|
||||||
ple compressed file representations. Such a stream can be
|
ple compressed file representations. Such a stream can be
|
||||||
decompressed correctly only by _b_z_i_p_2 version 0.9.0 or
|
decompressed correctly only by b̲z̲i̲p̲2̲ version 0.9.0 or
|
||||||
later. Earlier versions of _b_z_i_p_2 will stop after decom
|
later. Earlier versions of b̲z̲i̲p̲2̲ will stop after decom-
|
||||||
pressing the first file in the stream.
|
pressing the first file in the stream.
|
||||||
|
|
||||||
_b_z_c_a_t (or _b_z_i_p_2 _‐_d_c_) decompresses all specified files to
|
b̲z̲c̲a̲t̲ (or b̲z̲i̲p̲2̲ -̲d̲c̲)̲ decompresses all specified files to
|
||||||
the standard output.
|
the standard output.
|
||||||
|
|
||||||
_b_z_i_p_2 will read arguments from the environment variables
|
b̲z̲i̲p̲2̲ will read arguments from the environment variables
|
||||||
_B_Z_I_P_2 and _B_Z_I_P_, in that order, and will process them
|
B̲Z̲I̲P̲2̲ and B̲Z̲I̲P̲,̲ in that order, and will process them
|
||||||
before any arguments read from the command line. This
|
before any arguments read from the command line. This
|
||||||
gives a convenient way to supply default arguments.
|
gives a convenient way to supply default arguments.
|
||||||
|
|
||||||
|
@ -99,60 +99,60 @@ DDEESSCCRRIIPPTTIIOONN
|
||||||
most file compressors) is coded at about 8.05 bits per
|
most file compressors) is coded at about 8.05 bits per
|
||||||
byte, giving an expansion of around 0.5%.
|
byte, giving an expansion of around 0.5%.
|
||||||
|
|
||||||
As a self‐check for your protection, _b_z_i_p_2 uses 32‐bit
|
As a self-check for your protection, b̲z̲i̲p̲2̲ uses 32-bit
|
||||||
CRCs to make sure that the decompressed version of a file
|
CRCs to make sure that the decompressed version of a file
|
||||||
is identical to the original. This guards against corrup
|
is identical to the original. This guards against corrup-
|
||||||
tion of the compressed data, and against undetected bugs
|
tion of the compressed data, and against undetected bugs
|
||||||
in _b_z_i_p_2 (hopefully very unlikely). The chances of data
|
in b̲z̲i̲p̲2̲ (hopefully very unlikely). The chances of data
|
||||||
corruption going undetected is microscopic, about one
|
corruption going undetected is microscopic, about one
|
||||||
chance in four billion for each file processed. Be aware,
|
chance in four billion for each file processed. Be aware,
|
||||||
though, that the check occurs upon decompression, so it
|
though, that the check occurs upon decompression, so it
|
||||||
can only tell you that something is wrong. It can’t help
|
can only tell you that something is wrong. It can’t help
|
||||||
you recover the original uncompressed data. You can use
|
you recover the original uncompressed data. You can use
|
||||||
_b_z_i_p_2_r_e_c_o_v_e_r to try to recover data from damaged files.
|
b̲z̲i̲p̲2̲r̲e̲c̲o̲v̲e̲r̲ to try to recover data from damaged files.
|
||||||
|
|
||||||
Return values: 0 for a normal exit, 1 for environmental
|
Return values: 0 for a normal exit, 1 for environmental
|
||||||
problems (file not found, invalid flags, I/O errors, &c),
|
problems (file not found, invalid flags, I/O errors, &c),
|
||||||
2 to indicate a corrupt compressed file, 3 for an internal
|
2 to indicate a corrupt compressed file, 3 for an internal
|
||||||
consistency error (eg, bug) which caused _b_z_i_p_2 to panic.
|
consistency error (eg, bug) which caused b̲z̲i̲p̲2̲ to panic.
|
||||||
|
|
||||||
|
|
||||||
OOPPTTIIOONNSS
|
𝐎𝐏𝐓𝐈𝐎𝐍𝐒
|
||||||
−−cc ‐‐‐‐ssttddoouutt
|
−𝗰 --𝘀𝘁𝗱𝗼𝘂𝘁
|
||||||
Compress or decompress to standard output.
|
Compress or decompress to standard output.
|
||||||
|
|
||||||
−−dd ‐‐‐‐ddeeccoommpprreessss
|
−𝗱 --𝗱𝗲𝗰𝗼𝗺𝗽𝗿𝗲𝘀𝘀
|
||||||
Force decompression. _b_z_i_p_2_, _b_u_n_z_i_p_2 and _b_z_c_a_t are
|
Force decompression. b̲z̲i̲p̲2̲,̲ b̲u̲n̲z̲i̲p̲2̲ and b̲z̲c̲a̲t̲ are
|
||||||
really the same program, and the decision about
|
really the same program, and the decision about
|
||||||
what actions to take is done on the basis of which
|
what actions to take is done on the basis of which
|
||||||
name is used. This flag overrides that mechanism,
|
name is used. This flag overrides that mechanism,
|
||||||
and forces _b_z_i_p_2 to decompress.
|
and forces b̲z̲i̲p̲2̲ to decompress.
|
||||||
|
|
||||||
−−zz ‐‐‐‐ccoommpprreessss
|
−𝘇 --𝗰𝗼𝗺𝗽𝗿𝗲𝘀𝘀
|
||||||
The complement to −d: forces compression,
|
The complement to −d: forces compression,
|
||||||
regardless of the invocation name.
|
regardless of the invocation name.
|
||||||
|
|
||||||
−−tt ‐‐‐‐tteesstt
|
−𝘁 --𝘁𝗲𝘀𝘁
|
||||||
Check integrity of the specified file(s), but don’t
|
Check integrity of the specified file(s), but don’t
|
||||||
decompress them. This really performs a trial
|
decompress them. This really performs a trial
|
||||||
decompression and throws away the result.
|
decompression and throws away the result.
|
||||||
|
|
||||||
−−ff ‐‐‐‐ffoorrccee
|
−𝗳 --𝗳𝗼𝗿𝗰𝗲
|
||||||
Force overwrite of output files. Normally, _b_z_i_p_2
|
Force overwrite of output files. Normally, b̲z̲i̲p̲2̲
|
||||||
will not overwrite existing output files. Also
|
will not overwrite existing output files. Also
|
||||||
forces _b_z_i_p_2 to break hard links to files, which it
|
forces b̲z̲i̲p̲2̲ to break hard links to files, which it
|
||||||
otherwise wouldn’t do.
|
otherwise wouldn’t do.
|
||||||
|
|
||||||
bzip2 normally declines to decompress files which
|
bzip2 normally declines to decompress files which
|
||||||
don’t have the correct magic header bytes. If
|
don’t have the correct magic header bytes. If
|
||||||
forced (‐f), however, it will pass such files
|
forced (-f), however, it will pass such files
|
||||||
through unmodified. This is how GNU gzip behaves.
|
through unmodified. This is how GNU gzip behaves.
|
||||||
|
|
||||||
−−kk ‐‐‐‐kkeeeepp
|
−𝗸 --𝗸𝗲𝗲𝗽
|
||||||
Keep (don’t delete) input files during compression
|
Keep (don’t delete) input files during compression
|
||||||
or decompression.
|
or decompression.
|
||||||
|
|
||||||
−−ss ‐‐‐‐ssmmaallll
|
−𝘀 --𝘀𝗺𝗮𝗹𝗹
|
||||||
Reduce memory usage, for compression, decompression
|
Reduce memory usage, for compression, decompression
|
||||||
and testing. Files are decompressed and tested
|
and testing. Files are decompressed and tested
|
||||||
using a modified algorithm which only requires 2.5
|
using a modified algorithm which only requires 2.5
|
||||||
|
@ -167,53 +167,53 @@ OOPPTTIIOONNSS
|
||||||
megabytes or less), use −s for everything. See
|
megabytes or less), use −s for everything. See
|
||||||
MEMORY MANAGEMENT below.
|
MEMORY MANAGEMENT below.
|
||||||
|
|
||||||
−−qq ‐‐‐‐qquuiieett
|
−𝗾 --𝗾𝘂𝗶𝗲𝘁
|
||||||
Suppress non‐essential warning messages. Messages
|
Suppress non-essential warning messages. Messages
|
||||||
pertaining to I/O errors and other critical events
|
pertaining to I/O errors and other critical events
|
||||||
will not be suppressed.
|
will not be suppressed.
|
||||||
|
|
||||||
−−vv ‐‐‐‐vveerrbboossee
|
−𝘃 --𝘃𝗲𝗿𝗯𝗼𝘀𝗲
|
||||||
Verbose mode ‐‐ show the compression ratio for each
|
Verbose mode -- show the compression ratio for each
|
||||||
file processed. Further −v’s increase the ver
|
file processed. Further −v’s increase the ver-
|
||||||
bosity level, spewing out lots of information which
|
bosity level, spewing out lots of information which
|
||||||
is primarily of interest for diagnostic purposes.
|
is primarily of interest for diagnostic purposes.
|
||||||
|
|
||||||
−−LL ‐‐‐‐lliicceennssee ‐‐VV ‐‐‐‐vveerrssiioonn
|
−𝐋 --𝗹𝗶𝗰𝗲𝗻𝘀𝗲 -𝐕 --𝘃𝗲𝗿𝘀𝗶𝗼𝗻
|
||||||
Display the software version, license terms and
|
Display the software version, license terms and
|
||||||
conditions.
|
conditions.
|
||||||
|
|
||||||
−−11 ((oorr −−−−ffaasstt)) ttoo −−99 ((oorr −−−−bbeesstt))
|
−𝟭 (𝗼𝗿 −−𝗳𝗮𝘀𝘁) 𝘁𝗼 −𝟵 (𝗼𝗿 −−𝗯𝗲𝘀𝘁)
|
||||||
Set the block size to 100 k, 200 k .. 900 k when
|
Set the block size to 100 k, 200 k .. 900 k when
|
||||||
compressing. Has no effect when decompressing.
|
compressing. Has no effect when decompressing.
|
||||||
See MEMORY MANAGEMENT below. The −−fast and −−best
|
See MEMORY MANAGEMENT below. The −−fast and −−best
|
||||||
aliases are primarily for GNU gzip compatibility.
|
aliases are primarily for GNU gzip compatibility.
|
||||||
In particular, −−fast doesn’t make things signifi
|
In particular, −−fast doesn’t make things signifi-
|
||||||
cantly faster. And −−best merely selects the
|
cantly faster. And −−best merely selects the
|
||||||
default behaviour.
|
default behaviour.
|
||||||
|
|
||||||
−−‐‐ Treats all subsequent arguments as file names, even
|
−- Treats all subsequent arguments as file names, even
|
||||||
if they start with a dash. This is so you can han
|
if they start with a dash. This is so you can han-
|
||||||
dle files with names beginning with a dash, for
|
dle files with names beginning with a dash, for
|
||||||
example: bzip2 −‐ −myfilename.
|
example: bzip2 −- −myfilename.
|
||||||
|
|
||||||
−−‐‐rreeppeettiittiivvee‐‐ffaasstt ‐‐‐‐rreeppeettiittiivvee‐‐bbeesstt
|
−-𝗿𝗲𝗽𝗲𝘁𝗶𝘁𝗶𝘃𝗲-𝗳𝗮𝘀𝘁 --𝗿𝗲𝗽𝗲𝘁𝗶𝘁𝗶𝘃𝗲-𝗯𝗲𝘀𝘁
|
||||||
These flags are redundant in versions 0.9.5 and
|
These flags are redundant in versions 0.9.5 and
|
||||||
above. They provided some coarse control over the
|
above. They provided some coarse control over the
|
||||||
behaviour of the sorting algorithm in earlier ver
|
behaviour of the sorting algorithm in earlier ver-
|
||||||
sions, which was sometimes useful. 0.9.5 and above
|
sions, which was sometimes useful. 0.9.5 and above
|
||||||
have an improved algorithm which renders these
|
have an improved algorithm which renders these
|
||||||
flags irrelevant.
|
flags irrelevant.
|
||||||
|
|
||||||
|
|
||||||
MMEEMMOORRYY MMAANNAAGGEEMMEENNTT
|
𝐌𝐄𝐌𝐎𝐑𝐘 𝐌𝐀𝐍𝐀𝐆𝐄𝐌𝐄𝐍𝐓
|
||||||
_b_z_i_p_2 compresses large files in blocks. The block size
|
b̲z̲i̲p̲2̲ compresses large files in blocks. The block size
|
||||||
affects both the compression ratio achieved, and the
|
affects both the compression ratio achieved, and the
|
||||||
amount of memory needed for compression and decompression.
|
amount of memory needed for compression and decompression.
|
||||||
The flags −1 through −9 specify the block size to be
|
The flags −1 through −9 specify the block size to be
|
||||||
100,000 bytes through 900,000 bytes (the default) respec
|
100,000 bytes through 900,000 bytes (the default) respec-
|
||||||
tively. At decompression time, the block size used for
|
tively. At decompression time, the block size used for
|
||||||
compression is read from the header of the compressed
|
compression is read from the header of the compressed
|
||||||
file, and _b_u_n_z_i_p_2 then allocates itself just enough memory
|
file, and b̲u̲n̲z̲i̲p̲2̲ then allocates itself just enough memory
|
||||||
to decompress the file. Since block sizes are stored in
|
to decompress the file. Since block sizes are stored in
|
||||||
compressed files, it follows that the flags −1 to −9 are
|
compressed files, it follows that the flags −1 to −9 are
|
||||||
irrelevant to and so ignored during decompression.
|
irrelevant to and so ignored during decompression.
|
||||||
|
@ -229,30 +229,30 @@ MMEEMMOORRYY MMAANNAAGGEEMMEENNTT
|
||||||
Larger block sizes give rapidly diminishing marginal
|
Larger block sizes give rapidly diminishing marginal
|
||||||
returns. Most of the compression comes from the first two
|
returns. Most of the compression comes from the first two
|
||||||
or three hundred k of block size, a fact worth bearing in
|
or three hundred k of block size, a fact worth bearing in
|
||||||
mind when using _b_z_i_p_2 on small machines. It is also
|
mind when using b̲z̲i̲p̲2̲ on small machines. It is also
|
||||||
important to appreciate that the decompression memory
|
important to appreciate that the decompression memory
|
||||||
requirement is set at compression time by the choice of
|
requirement is set at compression time by the choice of
|
||||||
block size.
|
block size.
|
||||||
|
|
||||||
For files compressed with the default 900k block size,
|
For files compressed with the default 900k block size,
|
||||||
_b_u_n_z_i_p_2 will require about 3700 kbytes to decompress. To
|
b̲u̲n̲z̲i̲p̲2̲ will require about 3700 kbytes to decompress. To
|
||||||
support decompression of any file on a 4 megabyte machine,
|
support decompression of any file on a 4 megabyte machine,
|
||||||
_b_u_n_z_i_p_2 has an option to decompress using approximately
|
b̲u̲n̲z̲i̲p̲2̲ has an option to decompress using approximately
|
||||||
half this amount of memory, about 2300 kbytes. Decompres
|
half this amount of memory, about 2300 kbytes. Decompres-
|
||||||
sion speed is also halved, so you should use this option
|
sion speed is also halved, so you should use this option
|
||||||
only where necessary. The relevant flag is ‐s.
|
only where necessary. The relevant flag is -s.
|
||||||
|
|
||||||
In general, try and use the largest block size memory con
|
In general, try and use the largest block size memory con-
|
||||||
straints allow, since that maximises the compression
|
straints allow, since that maximises the compression
|
||||||
achieved. Compression and decompression speed are virtu
|
achieved. Compression and decompression speed are virtu-
|
||||||
ally unaffected by block size.
|
ally unaffected by block size.
|
||||||
|
|
||||||
Another significant point applies to files which fit in a
|
Another significant point applies to files which fit in a
|
||||||
single block ‐‐ that means most files you’d encounter
|
single block -- that means most files you’d encounter
|
||||||
using a large block size. The amount of real memory
|
using a large block size. The amount of real memory
|
||||||
touched is proportional to the size of the file, since the
|
touched is proportional to the size of the file, since the
|
||||||
file is smaller than a block. For example, compressing a
|
file is smaller than a block. For example, compressing a
|
||||||
file 20,000 bytes long with the flag ‐9 will cause the
|
file 20,000 bytes long with the flag -9 will cause the
|
||||||
compressor to allocate around 7600k of memory, but only
|
compressor to allocate around 7600k of memory, but only
|
||||||
touch 400k + 20000 * 8 = 560 kbytes of it. Similarly, the
|
touch 400k + 20000 * 8 = 560 kbytes of it. Similarly, the
|
||||||
decompressor will allocate 3700k but only touch 100k +
|
decompressor will allocate 3700k but only touch 100k +
|
||||||
|
@ -260,95 +260,95 @@ MMEEMMOORRYY MMAANNAAGGEEMMEENNTT
|
||||||
|
|
||||||
Here is a table which summarises the maximum memory usage
|
Here is a table which summarises the maximum memory usage
|
||||||
for different block sizes. Also recorded is the total
|
for different block sizes. Also recorded is the total
|
||||||
compressed size for 14 files of the Calgary Text Compres
|
compressed size for 14 files of the Calgary Text Compres-
|
||||||
sion Corpus totalling 3,141,622 bytes. This column gives
|
sion Corpus totalling 3,141,622 bytes. This column gives
|
||||||
some feel for how compression varies with block size.
|
some feel for how compression varies with block size.
|
||||||
These figures tend to understate the advantage of larger
|
These figures tend to understate the advantage of larger
|
||||||
block sizes for larger files, since the Corpus is domi
|
block sizes for larger files, since the Corpus is domi-
|
||||||
nated by smaller files.
|
nated by smaller files.
|
||||||
|
|
||||||
Compress Decompress Decompress Corpus
|
Compress Decompress Decompress Corpus
|
||||||
Flag usage usage ‐s usage Size
|
Flag usage usage -s usage Size
|
||||||
|
|
||||||
‐1 1200k 500k 350k 914704
|
-1 1200k 500k 350k 914704
|
||||||
‐2 2000k 900k 600k 877703
|
-2 2000k 900k 600k 877703
|
||||||
‐3 2800k 1300k 850k 860338
|
-3 2800k 1300k 850k 860338
|
||||||
‐4 3600k 1700k 1100k 846899
|
-4 3600k 1700k 1100k 846899
|
||||||
‐5 4400k 2100k 1350k 845160
|
-5 4400k 2100k 1350k 845160
|
||||||
‐6 5200k 2500k 1600k 838626
|
-6 5200k 2500k 1600k 838626
|
||||||
‐7 6100k 2900k 1850k 834096
|
-7 6100k 2900k 1850k 834096
|
||||||
‐8 6800k 3300k 2100k 828642
|
-8 6800k 3300k 2100k 828642
|
||||||
‐9 7600k 3700k 2350k 828642
|
-9 7600k 3700k 2350k 828642
|
||||||
|
|
||||||
|
|
||||||
RREECCOOVVEERRIINNGG DDAATTAA FFRROOMM DDAAMMAAGGEEDD FFIILLEESS
|
𝐑𝐄𝐂𝐎𝐕𝐄𝐑𝐈𝐍𝐆 𝐃𝐀𝐓𝐀 𝐅𝐑𝐎𝐌 𝐃𝐀𝐌𝐀𝐆𝐄𝐃 𝐅𝐈𝐋𝐄𝐒
|
||||||
_b_z_i_p_2 compresses files in blocks, usually 900kbytes long.
|
b̲z̲i̲p̲2̲ compresses files in blocks, usually 900kbytes long.
|
||||||
Each block is handled independently. If a media or trans
|
Each block is handled independently. If a media or trans-
|
||||||
mission error causes a multi‐block .bz2 file to become
|
mission error causes a multi-block .bz2 file to become
|
||||||
damaged, it may be possible to recover data from the
|
damaged, it may be possible to recover data from the
|
||||||
undamaged blocks in the file.
|
undamaged blocks in the file.
|
||||||
|
|
||||||
The compressed representation of each block is delimited
|
The compressed representation of each block is delimited
|
||||||
by a 48‐bit pattern, which makes it possible to find the
|
by a 48-bit pattern, which makes it possible to find the
|
||||||
block boundaries with reasonable certainty. Each block
|
block boundaries with reasonable certainty. Each block
|
||||||
also carries its own 32‐bit CRC, so damaged blocks can be
|
also carries its own 32-bit CRC, so damaged blocks can be
|
||||||
distinguished from undamaged ones.
|
distinguished from undamaged ones.
|
||||||
|
|
||||||
_b_z_i_p_2_r_e_c_o_v_e_r is a simple program whose purpose is to
|
b̲z̲i̲p̲2̲r̲e̲c̲o̲v̲e̲r̲ is a simple program whose purpose is to
|
||||||
search for blocks in .bz2 files, and write each block out
|
search for blocks in .bz2 files, and write each block out
|
||||||
into its own .bz2 file. You can then use _b_z_i_p_2 −t to test
|
into its own .bz2 file. You can then use b̲z̲i̲p̲2̲ −t to test
|
||||||
the integrity of the resulting files, and decompress those
|
the integrity of the resulting files, and decompress those
|
||||||
which are undamaged.
|
which are undamaged.
|
||||||
|
|
||||||
_b_z_i_p_2_r_e_c_o_v_e_r takes a single argument, the name of the dam
|
b̲z̲i̲p̲2̲r̲e̲c̲o̲v̲e̲r̲ takes a single argument, the name of the dam-
|
||||||
aged file, and writes a number of files
|
aged file, and writes a number of files
|
||||||
"rec00001file.bz2", "rec00002file.bz2", etc, containing
|
"rec00001file.bz2", "rec00002file.bz2", etc, containing
|
||||||
the extracted blocks. The output filenames are
|
the extracted blocks. The output filenames are
|
||||||
designed so that the use of wildcards in subsequent pro
|
designed so that the use of wildcards in subsequent pro-
|
||||||
cessing ‐‐ for example, "bzip2 ‐dc rec*file.bz2 > recov
|
cessing -- for example, "bzip2 -dc rec*file.bz2 > recov-
|
||||||
ered_data" ‐‐ processes the files in the correct order.
|
ered_data" -- processes the files in the correct order.
|
||||||
|
|
||||||
_b_z_i_p_2_r_e_c_o_v_e_r should be of most use dealing with large .bz2
|
b̲z̲i̲p̲2̲r̲e̲c̲o̲v̲e̲r̲ should be of most use dealing with large .bz2
|
||||||
files, as these will contain many blocks. It is clearly
|
files, as these will contain many blocks. It is clearly
|
||||||
futile to use it on damaged single‐block files, since a
|
futile to use it on damaged single-block files, since a
|
||||||
damaged block cannot be recovered. If you wish to min
|
damaged block cannot be recovered. If you wish to min-
|
||||||
imise any potential data loss through media or transmis
|
imise any potential data loss through media or transmis-
|
||||||
sion errors, you might consider compressing with a smaller
|
sion errors, you might consider compressing with a smaller
|
||||||
block size.
|
block size.
|
||||||
|
|
||||||
|
|
||||||
PPEERRFFOORRMMAANNCCEE NNOOTTEESS
|
𝐏𝐄𝐑𝐅𝐎𝐑𝐌𝐀𝐍𝐂𝐄 𝐍𝐎𝐓𝐄𝐒
|
||||||
The sorting phase of compression gathers together similar
|
The sorting phase of compression gathers together similar
|
||||||
strings in the file. Because of this, files containing
|
strings in the file. Because of this, files containing
|
||||||
very long runs of repeated symbols, like "aabaabaabaab
|
very long runs of repeated symbols, like "aabaabaabaab
|
||||||
..." (repeated several hundred times) may compress more
|
..." (repeated several hundred times) may compress more
|
||||||
slowly than normal. Versions 0.9.5 and above fare much
|
slowly than normal. Versions 0.9.5 and above fare much
|
||||||
better than previous versions in this respect. The ratio
|
better than previous versions in this respect. The ratio
|
||||||
between worst‐case and average‐case compression time is in
|
between worst-case and average-case compression time is in
|
||||||
the region of 10:1. For previous versions, this figure
|
the region of 10:1. For previous versions, this figure
|
||||||
was more like 100:1. You can use the −vvvv option to mon
|
was more like 100:1. You can use the −vvvv option to mon-
|
||||||
itor progress in great detail, if you want.
|
itor progress in great detail, if you want.
|
||||||
|
|
||||||
Decompression speed is unaffected by these phenomena.
|
Decompression speed is unaffected by these phenomena.
|
||||||
|
|
||||||
_b_z_i_p_2 usually allocates several megabytes of memory to
|
b̲z̲i̲p̲2̲ usually allocates several megabytes of memory to
|
||||||
operate in, and then charges all over it in a fairly ran
|
operate in, and then charges all over it in a fairly ran-
|
||||||
dom fashion. This means that performance, both for com
|
dom fashion. This means that performance, both for com-
|
||||||
pressing and decompressing, is largely determined by the
|
pressing and decompressing, is largely determined by the
|
||||||
speed at which your machine can service cache misses.
|
speed at which your machine can service cache misses.
|
||||||
Because of this, small changes to the code to reduce the
|
Because of this, small changes to the code to reduce the
|
||||||
miss rate have been observed to give disproportionately
|
miss rate have been observed to give disproportionately
|
||||||
large performance improvements. I imagine _b_z_i_p_2 will per
|
large performance improvements. I imagine b̲z̲i̲p̲2̲ will per-
|
||||||
form best on machines with very large caches.
|
form best on machines with very large caches.
|
||||||
|
|
||||||
|
|
||||||
CCAAVVEEAATTSS
|
𝐂𝐀𝐕𝐄𝐀𝐓𝐒
|
||||||
I/O error messages are not as helpful as they could be.
|
I/O error messages are not as helpful as they could be.
|
||||||
_b_z_i_p_2 tries hard to detect I/O errors and exit cleanly,
|
b̲z̲i̲p̲2̲ tries hard to detect I/O errors and exit cleanly,
|
||||||
but the details of what the problem is sometimes seem
|
but the details of what the problem is sometimes seem
|
||||||
rather misleading.
|
rather misleading.
|
||||||
|
|
||||||
This manual page pertains to version 1.0.8 of _b_z_i_p_2_. Com
|
This manual page pertains to version 1.0.8 of b̲z̲i̲p̲2̲.̲ Com-
|
||||||
pressed data created by this version is entirely forwards
|
pressed data created by this version is entirely forwards
|
||||||
and backwards compatible with the previous public
|
and backwards compatible with the previous public
|
||||||
releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1,
|
releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1,
|
||||||
|
@ -357,38 +357,38 @@ CCAAVVEEAATTSS
|
||||||
compressed files. 0.1pl2 cannot do this; it will stop
|
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.
|
||||||
|
|
||||||
_b_z_i_p_2_r_e_c_o_v_e_r versions prior to 1.0.2 used 32‐bit integers
|
b̲z̲i̲p̲2̲r̲e̲c̲o̲v̲e̲r̲ versions prior to 1.0.2 used 32-bit integers
|
||||||
to represent bit positions in compressed files, so they
|
to represent bit positions in compressed files, so they
|
||||||
could not handle compressed files more than 512 megabytes
|
could not handle compressed files more than 512 megabytes
|
||||||
long. Versions 1.0.2 and above use 64‐bit ints on some
|
long. Versions 1.0.2 and above use 64-bit ints on some
|
||||||
platforms which support them (GNU supported targets, and
|
platforms which support them (GNU supported targets, and
|
||||||
Windows). To establish whether or not bzip2recover was
|
Windows). To establish whether or not bzip2recover was
|
||||||
built with such a limitation, run it without arguments.
|
built with such a limitation, run it without arguments.
|
||||||
In any event you can build yourself an unlimited version
|
In any event you can build yourself an unlimited version
|
||||||
if you can recompile it with MaybeUInt64 set to be an
|
if you can recompile it with MaybeUInt64 set to be an
|
||||||
unsigned 64‐bit integer.
|
unsigned 64-bit integer.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AAUUTTHHOORR
|
𝐀𝐔𝐓𝐇𝐎𝐑
|
||||||
Julian Seward, jseward@acm.org.
|
Julian Seward, jseward@acm.org.
|
||||||
|
|
||||||
https://sourceware.org/bzip2/
|
https://sourceware.org/bzip2/
|
||||||
|
|
||||||
The ideas embodied in _b_z_i_p_2 are due to (at least) the fol
|
The ideas embodied in b̲z̲i̲p̲2̲ are due to (at least) the fol-
|
||||||
lowing people: Michael Burrows and David Wheeler (for the
|
lowing people: Michael Burrows and David Wheeler (for the
|
||||||
block sorting transformation), David Wheeler (again, for
|
block sorting transformation), David Wheeler (again, for
|
||||||
the Huffman coder), Peter Fenwick (for the structured cod
|
the Huffman coder), Peter Fenwick (for the structured cod-
|
||||||
ing model in the original _b_z_i_p_, and many refinements), and
|
ing model in the original b̲z̲i̲p̲,̲ and many refinements), and
|
||||||
Alistair Moffat, Radford Neal and Ian Witten (for the
|
Alistair Moffat, Radford Neal and Ian Witten (for the
|
||||||
arithmetic coder in the original _b_z_i_p_)_. I am much
|
arithmetic coder in the original b̲z̲i̲p̲)̲.̲ I am much
|
||||||
indebted for their help, support and advice. See the man
|
indebted for their help, support and advice. See the man-
|
||||||
ual in the source distribution for pointers to sources of
|
ual in the source distribution for pointers to sources of
|
||||||
documentation. Christian von Roques encouraged me to look
|
documentation. Christian von Roques encouraged me to look
|
||||||
for faster sorting algorithms, so as to speed up compres
|
for faster sorting algorithms, so as to speed up compres-
|
||||||
sion. Bela Lubkin encouraged me to improve the worst‐case
|
sion. Bela Lubkin encouraged me to improve the worst-case
|
||||||
compression performance. Donna Robinson XMLised the docu
|
compression performance. Donna Robinson XMLised the docu-
|
||||||
mentation. The bz* scripts are derived from those of GNU
|
mentation. The bz* scripts are derived from those of GNU
|
||||||
gzip. Many people sent patches, helped with portability
|
gzip. Many people sent patches, helped with portability
|
||||||
problems, lent machines, gave advice and were generally
|
problems, lent machines, gave advice and were generally
|
315
third_party/bzip2/bzip2.c
vendored
315
third_party/bzip2/bzip2.c
vendored
|
@ -1,3 +1,18 @@
|
||||||
|
#include "libc/calls/calls.h"
|
||||||
|
#include "libc/calls/struct/stat.h"
|
||||||
|
#include "libc/calls/struct/stat.macros.h"
|
||||||
|
#include "libc/errno.h"
|
||||||
|
#include "libc/log/log.h"
|
||||||
|
#include "libc/mem/mem.h"
|
||||||
|
#include "libc/runtime/gc.internal.h"
|
||||||
|
#include "libc/stdio/stdio.h"
|
||||||
|
#include "libc/str/str.h"
|
||||||
|
#include "libc/sysv/consts/o.h"
|
||||||
|
#include "libc/sysv/consts/s.h"
|
||||||
|
#include "libc/time/struct/utimbuf.h"
|
||||||
|
#include "libc/time/time.h"
|
||||||
|
#include "third_party/bzip2/bzlib.h"
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
/*--- A block-sorting, lossless compressor bzip2.c ---*/
|
/*--- A block-sorting, lossless compressor bzip2.c ---*/
|
||||||
|
@ -17,45 +32,13 @@
|
||||||
in the file LICENSE.
|
in the file LICENSE.
|
||||||
------------------------------------------------------------------ */
|
------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
/* 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
|
||||||
|
|
||||||
/*--
|
|
||||||
Win32, as seen by Jacob Navia's excellent
|
|
||||||
port of (Chris Fraser & David Hanson)'s excellent
|
|
||||||
lcc compiler. Or with MS Visual C.
|
|
||||||
This is selected automatically if compiled by a compiler which
|
|
||||||
defines _WIN32, not including the Cygwin GCC.
|
|
||||||
--*/
|
|
||||||
#define BZ_LCCWIN32 0
|
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
#undef BZ_LCCWIN32
|
|
||||||
#define BZ_LCCWIN32 1
|
|
||||||
#undef BZ_UNIX
|
|
||||||
#define BZ_UNIX 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
/*--
|
/*--
|
||||||
Some stuff for all platforms.
|
Some stuff for all platforms.
|
||||||
--*/
|
--*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include "bzlib.h"
|
|
||||||
|
|
||||||
#define ERROR_IF_EOF(i) { if ((i) == EOF) ioError(); }
|
#define ERROR_IF_EOF(i) { if ((i) == EOF) ioError(); }
|
||||||
#define ERROR_IF_NOT_ZERO(i) { if ((i) != 0) ioError(); }
|
#define ERROR_IF_NOT_ZERO(i) { if ((i) != 0) ioError(); }
|
||||||
#define ERROR_IF_MINUS_ONE(i) { if ((i) == (-1)) ioError(); }
|
#define ERROR_IF_MINUS_ONE(i) { if ((i) == (-1)) ioError(); }
|
||||||
|
@ -67,92 +50,18 @@
|
||||||
--*/
|
--*/
|
||||||
|
|
||||||
#if BZ_UNIX
|
#if BZ_UNIX
|
||||||
# include <fcntl.h>
|
#define PATH_SEP '/'
|
||||||
# include <sys/types.h>
|
#define MY_LSTAT lstat
|
||||||
# include <utime.h>
|
#define MY_STAT stat
|
||||||
# include <unistd.h>
|
#define MY_S_ISREG S_ISREG
|
||||||
# include <sys/stat.h>
|
#define MY_S_ISDIR S_ISDIR
|
||||||
# include <sys/times.h>
|
#define APPEND_FILESPEC(root, name) \
|
||||||
|
|
||||||
# define PATH_SEP '/'
|
|
||||||
# define MY_LSTAT lstat
|
|
||||||
# define MY_STAT stat
|
|
||||||
# define MY_S_ISREG S_ISREG
|
|
||||||
# define MY_S_ISDIR S_ISDIR
|
|
||||||
|
|
||||||
# define APPEND_FILESPEC(root, name) \
|
|
||||||
root=snocString((root), (name))
|
root=snocString((root), (name))
|
||||||
|
#define APPEND_FLAG(root, name) \
|
||||||
# define APPEND_FLAG(root, name) \
|
|
||||||
root=snocString((root), (name))
|
root=snocString((root), (name))
|
||||||
|
#define SET_BINARY_MODE(fd) /**/
|
||||||
# define SET_BINARY_MODE(fd) /**/
|
|
||||||
|
|
||||||
# ifdef __GNUC__
|
|
||||||
# define NORETURN __attribute__ ((noreturn))
|
|
||||||
# else
|
|
||||||
# define NORETURN /**/
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef __DJGPP__
|
|
||||||
# include <io.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
# undef MY_LSTAT
|
|
||||||
# undef MY_STAT
|
|
||||||
# define MY_LSTAT stat
|
|
||||||
# define MY_STAT stat
|
|
||||||
# undef SET_BINARY_MODE
|
|
||||||
# define SET_BINARY_MODE(fd) \
|
|
||||||
do { \
|
|
||||||
int retVal = setmode ( fileno ( fd ), \
|
|
||||||
O_BINARY ); \
|
|
||||||
ERROR_IF_MINUS_ONE ( retVal ); \
|
|
||||||
} while ( 0 )
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef __CYGWIN__
|
|
||||||
# include <io.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
# undef SET_BINARY_MODE
|
|
||||||
# define SET_BINARY_MODE(fd) \
|
|
||||||
do { \
|
|
||||||
int retVal = setmode ( fileno ( fd ), \
|
|
||||||
O_BINARY ); \
|
|
||||||
ERROR_IF_MINUS_ONE ( retVal ); \
|
|
||||||
} while ( 0 )
|
|
||||||
# endif
|
|
||||||
#endif /* BZ_UNIX */
|
#endif /* BZ_UNIX */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if BZ_LCCWIN32
|
|
||||||
# include <io.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
# include <sys/stat.h>
|
|
||||||
|
|
||||||
# define NORETURN /**/
|
|
||||||
# define PATH_SEP '\\'
|
|
||||||
# define MY_LSTAT _stati64
|
|
||||||
# define MY_STAT _stati64
|
|
||||||
# define MY_S_ISREG(x) ((x) & _S_IFREG)
|
|
||||||
# define MY_S_ISDIR(x) ((x) & _S_IFDIR)
|
|
||||||
|
|
||||||
# define APPEND_FLAG(root, name) \
|
|
||||||
root=snocString((root), (name))
|
|
||||||
|
|
||||||
# define APPEND_FILESPEC(root, name) \
|
|
||||||
root = snocString ((root), (name))
|
|
||||||
|
|
||||||
# define SET_BINARY_MODE(fd) \
|
|
||||||
do { \
|
|
||||||
int retVal = setmode ( fileno ( fd ), \
|
|
||||||
O_BINARY ); \
|
|
||||||
ERROR_IF_MINUS_ONE ( retVal ); \
|
|
||||||
} while ( 0 )
|
|
||||||
|
|
||||||
#endif /* BZ_LCCWIN32 */
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
/*--
|
/*--
|
||||||
Some more stuff for all platforms :-)
|
Some more stuff for all platforms :-)
|
||||||
|
@ -210,13 +119,13 @@ Char progNameReally[FILE_NAME_LEN];
|
||||||
FILE *outputHandleJustInCase;
|
FILE *outputHandleJustInCase;
|
||||||
Int32 workFactor;
|
Int32 workFactor;
|
||||||
|
|
||||||
static void panic ( const Char* ) NORETURN;
|
static void panic ( const Char* ) wontreturn;
|
||||||
static void ioError ( void ) NORETURN;
|
static void ioError ( void ) wontreturn;
|
||||||
static void outOfMemory ( void ) NORETURN;
|
static void outOfMemory ( void ) wontreturn;
|
||||||
static void configError ( void ) NORETURN;
|
static void configError ( void ) wontreturn;
|
||||||
static void crcError ( void ) NORETURN;
|
static void crcError ( void ) wontreturn;
|
||||||
static void cleanUpAndFail ( Int32 ) NORETURN;
|
static void cleanUpAndFail ( Int32 ) wontreturn;
|
||||||
static void compressedStreamEOF ( void ) NORETURN;
|
static void compressedStreamEOF ( void ) wontreturn;
|
||||||
|
|
||||||
static void copyFileName ( Char*, Char* );
|
static void copyFileName ( Char*, Char* );
|
||||||
static void* myMalloc ( Int32 );
|
static void* myMalloc ( Int32 );
|
||||||
|
@ -329,7 +238,7 @@ static
|
||||||
void compressStream ( FILE *stream, FILE *zStream )
|
void compressStream ( FILE *stream, FILE *zStream )
|
||||||
{
|
{
|
||||||
BZFILE* bzf = NULL;
|
BZFILE* bzf = NULL;
|
||||||
UChar ibuf[5000];
|
UChar *ibuf = gc(malloc(5000));
|
||||||
Int32 nIbuf;
|
Int32 nIbuf;
|
||||||
UInt32 nbytes_in_lo32, nbytes_in_hi32;
|
UInt32 nbytes_in_lo32, nbytes_in_hi32;
|
||||||
UInt32 nbytes_out_lo32, nbytes_out_hi32;
|
UInt32 nbytes_out_lo32, nbytes_out_hi32;
|
||||||
|
@ -345,7 +254,7 @@ void compressStream ( FILE *stream, FILE *zStream )
|
||||||
blockSize100k, verbosity, workFactor );
|
blockSize100k, verbosity, workFactor );
|
||||||
if (bzerr != BZ_OK) goto errhandler;
|
if (bzerr != BZ_OK) goto errhandler;
|
||||||
|
|
||||||
if (verbosity >= 2) fprintf ( stderr, "\n" );
|
if (verbosity >= 2) (fprintf) ( stderr, "\n" );
|
||||||
|
|
||||||
while (True) {
|
while (True) {
|
||||||
|
|
||||||
|
@ -380,7 +289,7 @@ void compressStream ( FILE *stream, FILE *zStream )
|
||||||
|
|
||||||
if (verbosity >= 1) {
|
if (verbosity >= 1) {
|
||||||
if (nbytes_in_lo32 == 0 && nbytes_in_hi32 == 0) {
|
if (nbytes_in_lo32 == 0 && nbytes_in_hi32 == 0) {
|
||||||
fprintf ( stderr, " no data compressed.\n");
|
(fprintf) ( stderr, " no data compressed.\n");
|
||||||
} else {
|
} else {
|
||||||
Char buf_nin[32], buf_nout[32];
|
Char buf_nin[32], buf_nout[32];
|
||||||
UInt64 nbytes_in, nbytes_out;
|
UInt64 nbytes_in, nbytes_out;
|
||||||
|
@ -393,7 +302,7 @@ void compressStream ( FILE *stream, FILE *zStream )
|
||||||
nbytes_out_d = uInt64_to_double ( &nbytes_out );
|
nbytes_out_d = uInt64_to_double ( &nbytes_out );
|
||||||
uInt64_toAscii ( buf_nin, &nbytes_in );
|
uInt64_toAscii ( buf_nin, &nbytes_in );
|
||||||
uInt64_toAscii ( buf_nout, &nbytes_out );
|
uInt64_toAscii ( buf_nout, &nbytes_out );
|
||||||
fprintf ( stderr, "%6.3f:1, %6.3f bits/byte, "
|
(fprintf) ( stderr, "%6.3f:1, %6.3f bits/byte, "
|
||||||
"%5.2f%% saved, %s in, %s out.\n",
|
"%5.2f%% saved, %s in, %s out.\n",
|
||||||
nbytes_in_d / nbytes_out_d,
|
nbytes_in_d / nbytes_out_d,
|
||||||
(8.0 * nbytes_out_d) / nbytes_in_d,
|
(8.0 * nbytes_out_d) / nbytes_in_d,
|
||||||
|
@ -434,8 +343,8 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
|
||||||
{
|
{
|
||||||
BZFILE* bzf = NULL;
|
BZFILE* bzf = NULL;
|
||||||
Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i;
|
Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i;
|
||||||
UChar obuf[5000];
|
UChar *obuf = gc(malloc(5000));
|
||||||
UChar unused[BZ_MAX_UNUSED];
|
UChar *unused = gc(malloc(BZ_MAX_UNUSED));
|
||||||
Int32 nUnused;
|
Int32 nUnused;
|
||||||
void* unusedTmpV;
|
void* unusedTmpV;
|
||||||
UChar* unusedTmp;
|
UChar* unusedTmp;
|
||||||
|
@ -498,7 +407,7 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
|
||||||
if (ret == EOF) goto errhandler_io;
|
if (ret == EOF) goto errhandler_io;
|
||||||
}
|
}
|
||||||
outputHandleJustInCase = NULL;
|
outputHandleJustInCase = NULL;
|
||||||
if (verbosity >= 2) fprintf ( stderr, "\n " );
|
if (verbosity >= 2) (fprintf) ( stderr, "\n " );
|
||||||
return True;
|
return True;
|
||||||
|
|
||||||
trycat:
|
trycat:
|
||||||
|
@ -535,7 +444,7 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
|
||||||
return False;
|
return False;
|
||||||
} else {
|
} else {
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"\n%s: %s: trailing garbage after EOF ignored\n",
|
"\n%s: %s: trailing garbage after EOF ignored\n",
|
||||||
progName, inName );
|
progName, inName );
|
||||||
return True;
|
return True;
|
||||||
|
@ -555,8 +464,8 @@ Bool testStream ( FILE *zStream )
|
||||||
{
|
{
|
||||||
BZFILE* bzf = NULL;
|
BZFILE* bzf = NULL;
|
||||||
Int32 bzerr, bzerr_dummy, ret, streamNo, i;
|
Int32 bzerr, bzerr_dummy, ret, streamNo, i;
|
||||||
UChar obuf[5000];
|
UChar *obuf = gc(malloc(5000));
|
||||||
UChar unused[BZ_MAX_UNUSED];
|
UChar *unused = gc(malloc(BZ_MAX_UNUSED));
|
||||||
Int32 nUnused;
|
Int32 nUnused;
|
||||||
void* unusedTmpV;
|
void* unusedTmpV;
|
||||||
UChar* unusedTmp;
|
UChar* unusedTmp;
|
||||||
|
@ -598,13 +507,13 @@ Bool testStream ( FILE *zStream )
|
||||||
ret = fclose ( zStream );
|
ret = fclose ( zStream );
|
||||||
if (ret == EOF) goto errhandler_io;
|
if (ret == EOF) goto errhandler_io;
|
||||||
|
|
||||||
if (verbosity >= 2) fprintf ( stderr, "\n " );
|
if (verbosity >= 2) (fprintf) ( stderr, "\n " );
|
||||||
return True;
|
return True;
|
||||||
|
|
||||||
errhandler:
|
errhandler:
|
||||||
BZ2_bzReadClose ( &bzerr_dummy, bzf );
|
BZ2_bzReadClose ( &bzerr_dummy, bzf );
|
||||||
if (verbosity == 0)
|
if (verbosity == 0)
|
||||||
fprintf ( stderr, "%s: %s: ", progName, inName );
|
(fprintf) ( stderr, "%s: %s: ", progName, inName );
|
||||||
switch (bzerr) {
|
switch (bzerr) {
|
||||||
case BZ_CONFIG_ERROR:
|
case BZ_CONFIG_ERROR:
|
||||||
configError(); break;
|
configError(); break;
|
||||||
|
@ -612,24 +521,24 @@ Bool testStream ( FILE *zStream )
|
||||||
errhandler_io:
|
errhandler_io:
|
||||||
ioError(); break;
|
ioError(); break;
|
||||||
case BZ_DATA_ERROR:
|
case BZ_DATA_ERROR:
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"data integrity (CRC) error in data\n" );
|
"data integrity (CRC) error in data\n" );
|
||||||
return False;
|
return False;
|
||||||
case BZ_MEM_ERROR:
|
case BZ_MEM_ERROR:
|
||||||
outOfMemory();
|
outOfMemory();
|
||||||
case BZ_UNEXPECTED_EOF:
|
case BZ_UNEXPECTED_EOF:
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"file ends unexpectedly\n" );
|
"file ends unexpectedly\n" );
|
||||||
return False;
|
return False;
|
||||||
case BZ_DATA_ERROR_MAGIC:
|
case BZ_DATA_ERROR_MAGIC:
|
||||||
if (zStream != stdin) fclose(zStream);
|
if (zStream != stdin) fclose(zStream);
|
||||||
if (streamNo == 1) {
|
if (streamNo == 1) {
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"bad magic number (file not created by bzip2)\n" );
|
"bad magic number (file not created by bzip2)\n" );
|
||||||
return False;
|
return False;
|
||||||
} else {
|
} else {
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"trailing garbage after EOF ignored\n" );
|
"trailing garbage after EOF ignored\n" );
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
@ -659,7 +568,7 @@ static
|
||||||
void cadvise ( void )
|
void cadvise ( void )
|
||||||
{
|
{
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf (
|
(fprintf) (
|
||||||
stderr,
|
stderr,
|
||||||
"\nIt is possible that the compressed file(s) have become corrupted.\n"
|
"\nIt is possible that the compressed file(s) have become corrupted.\n"
|
||||||
"You can use the -tvv option to test integrity of such files.\n\n"
|
"You can use the -tvv option to test integrity of such files.\n\n"
|
||||||
|
@ -674,7 +583,7 @@ static
|
||||||
void showFileNames ( void )
|
void showFileNames ( void )
|
||||||
{
|
{
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf (
|
(fprintf) (
|
||||||
stderr,
|
stderr,
|
||||||
"\tInput file = %s, output file = %s\n",
|
"\tInput file = %s, output file = %s\n",
|
||||||
inName, outName
|
inName, outName
|
||||||
|
@ -701,28 +610,28 @@ void cleanUpAndFail ( Int32 ec )
|
||||||
retVal = MY_STAT ( inName, &statBuf );
|
retVal = MY_STAT ( inName, &statBuf );
|
||||||
if (retVal == 0) {
|
if (retVal == 0) {
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: Deleting output file %s, if it exists.\n",
|
"%s: Deleting output file %s, if it exists.\n",
|
||||||
progName, outName );
|
progName, outName );
|
||||||
if (outputHandleJustInCase != NULL)
|
if (outputHandleJustInCase != NULL)
|
||||||
fclose ( outputHandleJustInCase );
|
fclose ( outputHandleJustInCase );
|
||||||
retVal = remove ( outName );
|
retVal = remove ( outName );
|
||||||
if (retVal != 0)
|
if (retVal != 0)
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: WARNING: deletion of output file "
|
"%s: WARNING: deletion of output file "
|
||||||
"(apparently) failed.\n",
|
"(apparently) failed.\n",
|
||||||
progName );
|
progName );
|
||||||
} else {
|
} else {
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: WARNING: deletion of output file suppressed\n",
|
"%s: WARNING: deletion of output file suppressed\n",
|
||||||
progName );
|
progName );
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: since input file no longer exists. Output file\n",
|
"%s: since input file no longer exists. Output file\n",
|
||||||
progName );
|
progName );
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: `%s' may be incomplete.\n",
|
"%s: `%s' may be incomplete.\n",
|
||||||
progName, outName );
|
progName, outName );
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: I suggest doing an integrity test (bzip2 -tv)"
|
"%s: I suggest doing an integrity test (bzip2 -tv)"
|
||||||
" of it.\n",
|
" of it.\n",
|
||||||
progName );
|
progName );
|
||||||
|
@ -730,7 +639,7 @@ void cleanUpAndFail ( Int32 ec )
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noisy && numFileNames > 0 && numFilesProcessed < numFileNames) {
|
if (noisy && numFileNames > 0 && numFilesProcessed < numFileNames) {
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: WARNING: some files have not been processed:\n"
|
"%s: WARNING: some files have not been processed:\n"
|
||||||
"%s: %d specified on command line, %d not processed yet.\n\n",
|
"%s: %d specified on command line, %d not processed yet.\n\n",
|
||||||
progName, progName,
|
progName, progName,
|
||||||
|
@ -745,7 +654,7 @@ void cleanUpAndFail ( Int32 ec )
|
||||||
static
|
static
|
||||||
void panic ( const 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"
|
||||||
"\t%s\n"
|
"\t%s\n"
|
||||||
"\tThis is a BUG. Please report it to:\n"
|
"\tThis is a BUG. Please report it to:\n"
|
||||||
|
@ -760,7 +669,7 @@ void panic ( const Char* s )
|
||||||
static
|
static
|
||||||
void crcError ( void )
|
void crcError ( void )
|
||||||
{
|
{
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"\n%s: Data integrity error when decompressing.\n",
|
"\n%s: Data integrity error when decompressing.\n",
|
||||||
progName );
|
progName );
|
||||||
showFileNames();
|
showFileNames();
|
||||||
|
@ -774,7 +683,7 @@ static
|
||||||
void compressedStreamEOF ( void )
|
void compressedStreamEOF ( void )
|
||||||
{
|
{
|
||||||
if (noisy) {
|
if (noisy) {
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"\n%s: Compressed file ends unexpectedly;\n\t"
|
"\n%s: Compressed file ends unexpectedly;\n\t"
|
||||||
"perhaps it is corrupted? *Possible* reason follows.\n",
|
"perhaps it is corrupted? *Possible* reason follows.\n",
|
||||||
progName );
|
progName );
|
||||||
|
@ -790,7 +699,7 @@ void compressedStreamEOF ( void )
|
||||||
static
|
static
|
||||||
void ioError ( void )
|
void ioError ( void )
|
||||||
{
|
{
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"\n%s: I/O or other error, bailing out. "
|
"\n%s: I/O or other error, bailing out. "
|
||||||
"Possible reason follows.\n",
|
"Possible reason follows.\n",
|
||||||
progName );
|
progName );
|
||||||
|
@ -804,7 +713,7 @@ void ioError ( void )
|
||||||
static
|
static
|
||||||
void mySignalCatcher ( IntNative n )
|
void mySignalCatcher ( IntNative n )
|
||||||
{
|
{
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"\n%s: Control-C or similar caught, quitting.\n",
|
"\n%s: Control-C or similar caught, quitting.\n",
|
||||||
progName );
|
progName );
|
||||||
cleanUpAndFail(1);
|
cleanUpAndFail(1);
|
||||||
|
@ -816,7 +725,7 @@ static
|
||||||
void mySIGSEGVorSIGBUScatcher ( IntNative n )
|
void mySIGSEGVorSIGBUScatcher ( IntNative n )
|
||||||
{
|
{
|
||||||
if (opMode == OM_Z)
|
if (opMode == OM_Z)
|
||||||
fprintf (
|
(fprintf) (
|
||||||
stderr,
|
stderr,
|
||||||
"\n%s: Caught a SIGSEGV or SIGBUS whilst compressing.\n"
|
"\n%s: Caught a SIGSEGV or SIGBUS whilst compressing.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -837,7 +746,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n )
|
||||||
"\n",
|
"\n",
|
||||||
progName );
|
progName );
|
||||||
else
|
else
|
||||||
fprintf (
|
(fprintf) (
|
||||||
stderr,
|
stderr,
|
||||||
"\n%s: Caught a SIGSEGV or SIGBUS whilst decompressing.\n"
|
"\n%s: Caught a SIGSEGV or SIGBUS whilst decompressing.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -871,7 +780,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n )
|
||||||
static
|
static
|
||||||
void outOfMemory ( void )
|
void outOfMemory ( void )
|
||||||
{
|
{
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"\n%s: couldn't allocate enough memory\n",
|
"\n%s: couldn't allocate enough memory\n",
|
||||||
progName );
|
progName );
|
||||||
showFileNames();
|
showFileNames();
|
||||||
|
@ -883,7 +792,7 @@ void outOfMemory ( void )
|
||||||
static
|
static
|
||||||
void configError ( void )
|
void configError ( void )
|
||||||
{
|
{
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"bzip2: I'm not configured correctly for this platform!\n"
|
"bzip2: I'm not configured correctly for this platform!\n"
|
||||||
"\tI require Int32, Int16 and Char to have sizes\n"
|
"\tI require Int32, Int16 and Char to have sizes\n"
|
||||||
"\tof 4, 2 and 1 bytes to run properly, and they don't.\n"
|
"\tof 4, 2 and 1 bytes to run properly, and they don't.\n"
|
||||||
|
@ -910,7 +819,7 @@ void pad ( Char *s )
|
||||||
Int32 i;
|
Int32 i;
|
||||||
if ( (Int32)strlen(s) >= longestFileName ) return;
|
if ( (Int32)strlen(s) >= longestFileName ) return;
|
||||||
for (i = 1; i <= longestFileName - (Int32)strlen(s); i++)
|
for (i = 1; i <= longestFileName - (Int32)strlen(s); i++)
|
||||||
fprintf ( stderr, " " );
|
(fprintf) ( stderr, " " );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -919,7 +828,7 @@ static
|
||||||
void copyFileName ( Char* to, Char* from )
|
void copyFileName ( Char* to, Char* from )
|
||||||
{
|
{
|
||||||
if ( strlen(from) > FILE_NAME_LEN-10 ) {
|
if ( strlen(from) > FILE_NAME_LEN-10 ) {
|
||||||
fprintf (
|
(fprintf) (
|
||||||
stderr,
|
stderr,
|
||||||
"bzip2: file name\n`%s'\n"
|
"bzip2: file name\n`%s'\n"
|
||||||
"is suspiciously (more than %d chars) long.\n"
|
"is suspiciously (more than %d chars) long.\n"
|
||||||
|
@ -1160,13 +1069,13 @@ void compress ( Char *name )
|
||||||
|
|
||||||
if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) {
|
if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) {
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf ( stderr, "%s: There are no files matching `%s'.\n",
|
(fprintf) ( stderr, "%s: There are no files matching `%s'.\n",
|
||||||
progName, inName );
|
progName, inName );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( srcMode != SM_I2O && !fileExists ( inName ) ) {
|
if ( srcMode != SM_I2O && !fileExists ( inName ) ) {
|
||||||
fprintf ( stderr, "%s: Can't open input file %s: %s.\n",
|
(fprintf) ( stderr, "%s: Can't open input file %s: %s.\n",
|
||||||
progName, inName, strerror(errno) );
|
progName, inName, strerror(errno) );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1174,7 +1083,7 @@ void compress ( Char *name )
|
||||||
for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) {
|
for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) {
|
||||||
if (hasSuffix(inName, zSuffix[i])) {
|
if (hasSuffix(inName, zSuffix[i])) {
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: Input file %s already has %s suffix.\n",
|
"%s: Input file %s already has %s suffix.\n",
|
||||||
progName, inName, zSuffix[i] );
|
progName, inName, zSuffix[i] );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
|
@ -1184,7 +1093,7 @@ void compress ( Char *name )
|
||||||
if ( srcMode == SM_F2F || srcMode == SM_F2O ) {
|
if ( srcMode == SM_F2F || srcMode == SM_F2O ) {
|
||||||
MY_STAT(inName, &statBuf);
|
MY_STAT(inName, &statBuf);
|
||||||
if ( MY_S_ISDIR(statBuf.st_mode) ) {
|
if ( MY_S_ISDIR(statBuf.st_mode) ) {
|
||||||
fprintf( stderr,
|
(fprintf)( stderr,
|
||||||
"%s: Input file %s is a directory.\n",
|
"%s: Input file %s is a directory.\n",
|
||||||
progName,inName);
|
progName,inName);
|
||||||
setExit(1);
|
setExit(1);
|
||||||
|
@ -1193,7 +1102,7 @@ void compress ( Char *name )
|
||||||
}
|
}
|
||||||
if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) {
|
if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) {
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf ( stderr, "%s: Input file %s is not a normal file.\n",
|
(fprintf) ( stderr, "%s: Input file %s is not a normal file.\n",
|
||||||
progName, inName );
|
progName, inName );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1202,7 +1111,7 @@ void compress ( Char *name )
|
||||||
if (forceOverwrite) {
|
if (forceOverwrite) {
|
||||||
remove(outName);
|
remove(outName);
|
||||||
} else {
|
} else {
|
||||||
fprintf ( stderr, "%s: Output file %s already exists.\n",
|
(fprintf) ( stderr, "%s: Output file %s already exists.\n",
|
||||||
progName, outName );
|
progName, outName );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1210,7 +1119,7 @@ void compress ( Char *name )
|
||||||
}
|
}
|
||||||
if ( srcMode == SM_F2F && !forceOverwrite &&
|
if ( srcMode == SM_F2F && !forceOverwrite &&
|
||||||
(n=countHardLinks ( inName )) > 0) {
|
(n=countHardLinks ( inName )) > 0) {
|
||||||
fprintf ( stderr, "%s: Input file %s has %d other link%s.\n",
|
(fprintf) ( stderr, "%s: Input file %s has %d other link%s.\n",
|
||||||
progName, inName, n, n > 1 ? "s" : "" );
|
progName, inName, n, n > 1 ? "s" : "" );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1228,10 +1137,10 @@ void compress ( Char *name )
|
||||||
inStr = stdin;
|
inStr = stdin;
|
||||||
outStr = stdout;
|
outStr = stdout;
|
||||||
if ( isatty ( fileno ( stdout ) ) ) {
|
if ( isatty ( fileno ( stdout ) ) ) {
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: I won't write compressed data to a terminal.\n",
|
"%s: I won't write compressed data to a terminal.\n",
|
||||||
progName );
|
progName );
|
||||||
fprintf ( stderr, "%s: For help, type: `%s --help'.\n",
|
(fprintf) ( stderr, "%s: For help, type: `%s --help'.\n",
|
||||||
progName, progName );
|
progName, progName );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1242,17 +1151,17 @@ void compress ( Char *name )
|
||||||
inStr = fopen ( inName, "rb" );
|
inStr = fopen ( inName, "rb" );
|
||||||
outStr = stdout;
|
outStr = stdout;
|
||||||
if ( isatty ( fileno ( stdout ) ) ) {
|
if ( isatty ( fileno ( stdout ) ) ) {
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: I won't write compressed data to a terminal.\n",
|
"%s: I won't write compressed data to a terminal.\n",
|
||||||
progName );
|
progName );
|
||||||
fprintf ( stderr, "%s: For help, type: `%s --help'.\n",
|
(fprintf) ( stderr, "%s: For help, type: `%s --help'.\n",
|
||||||
progName, progName );
|
progName, progName );
|
||||||
if ( inStr != NULL ) fclose ( inStr );
|
if ( inStr != NULL ) fclose ( inStr );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if ( inStr == NULL ) {
|
if ( inStr == NULL ) {
|
||||||
fprintf ( stderr, "%s: Can't open input file %s: %s.\n",
|
(fprintf) ( stderr, "%s: Can't open input file %s: %s.\n",
|
||||||
progName, inName, strerror(errno) );
|
progName, inName, strerror(errno) );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1263,14 +1172,14 @@ void compress ( Char *name )
|
||||||
inStr = fopen ( inName, "rb" );
|
inStr = fopen ( inName, "rb" );
|
||||||
outStr = fopen_output_safely ( outName, "wb" );
|
outStr = fopen_output_safely ( outName, "wb" );
|
||||||
if ( outStr == NULL) {
|
if ( outStr == NULL) {
|
||||||
fprintf ( stderr, "%s: Can't create output file %s: %s.\n",
|
(fprintf) ( stderr, "%s: Can't create output file %s: %s.\n",
|
||||||
progName, outName, strerror(errno) );
|
progName, outName, strerror(errno) );
|
||||||
if ( inStr != NULL ) fclose ( inStr );
|
if ( inStr != NULL ) fclose ( inStr );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( inStr == NULL ) {
|
if ( inStr == NULL ) {
|
||||||
fprintf ( stderr, "%s: Can't open input file %s: %s.\n",
|
(fprintf) ( stderr, "%s: Can't open input file %s: %s.\n",
|
||||||
progName, inName, strerror(errno) );
|
progName, inName, strerror(errno) );
|
||||||
if ( outStr != NULL ) fclose ( outStr );
|
if ( outStr != NULL ) fclose ( outStr );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
|
@ -1284,7 +1193,7 @@ void compress ( Char *name )
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity >= 1) {
|
if (verbosity >= 1) {
|
||||||
fprintf ( stderr, " %s: ", inName );
|
(fprintf) ( stderr, " %s: ", inName );
|
||||||
pad ( inName );
|
pad ( inName );
|
||||||
fflush ( stderr );
|
fflush ( stderr );
|
||||||
}
|
}
|
||||||
|
@ -1349,13 +1258,13 @@ void uncompress ( Char *name )
|
||||||
zzz:
|
zzz:
|
||||||
if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) {
|
if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) {
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf ( stderr, "%s: There are no files matching `%s'.\n",
|
(fprintf) ( stderr, "%s: There are no files matching `%s'.\n",
|
||||||
progName, inName );
|
progName, inName );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( srcMode != SM_I2O && !fileExists ( inName ) ) {
|
if ( srcMode != SM_I2O && !fileExists ( inName ) ) {
|
||||||
fprintf ( stderr, "%s: Can't open input file %s: %s.\n",
|
(fprintf) ( stderr, "%s: Can't open input file %s: %s.\n",
|
||||||
progName, inName, strerror(errno) );
|
progName, inName, strerror(errno) );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1363,7 +1272,7 @@ void uncompress ( Char *name )
|
||||||
if ( srcMode == SM_F2F || srcMode == SM_F2O ) {
|
if ( srcMode == SM_F2F || srcMode == SM_F2O ) {
|
||||||
MY_STAT(inName, &statBuf);
|
MY_STAT(inName, &statBuf);
|
||||||
if ( MY_S_ISDIR(statBuf.st_mode) ) {
|
if ( MY_S_ISDIR(statBuf.st_mode) ) {
|
||||||
fprintf( stderr,
|
(fprintf)( stderr,
|
||||||
"%s: Input file %s is a directory.\n",
|
"%s: Input file %s is a directory.\n",
|
||||||
progName,inName);
|
progName,inName);
|
||||||
setExit(1);
|
setExit(1);
|
||||||
|
@ -1372,14 +1281,14 @@ void uncompress ( Char *name )
|
||||||
}
|
}
|
||||||
if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) {
|
if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) {
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf ( stderr, "%s: Input file %s is not a normal file.\n",
|
(fprintf) ( stderr, "%s: Input file %s is not a normal file.\n",
|
||||||
progName, inName );
|
progName, inName );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( /* srcMode == SM_F2F implied && */ cantGuess ) {
|
if ( /* srcMode == SM_F2F implied && */ cantGuess ) {
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: Can't guess original name for %s -- using %s\n",
|
"%s: Can't guess original name for %s -- using %s\n",
|
||||||
progName, inName, outName );
|
progName, inName, outName );
|
||||||
/* just a warning, no return */
|
/* just a warning, no return */
|
||||||
|
@ -1388,7 +1297,7 @@ void uncompress ( Char *name )
|
||||||
if (forceOverwrite) {
|
if (forceOverwrite) {
|
||||||
remove(outName);
|
remove(outName);
|
||||||
} else {
|
} else {
|
||||||
fprintf ( stderr, "%s: Output file %s already exists.\n",
|
(fprintf) ( stderr, "%s: Output file %s already exists.\n",
|
||||||
progName, outName );
|
progName, outName );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1396,7 +1305,7 @@ void uncompress ( Char *name )
|
||||||
}
|
}
|
||||||
if ( srcMode == SM_F2F && !forceOverwrite &&
|
if ( srcMode == SM_F2F && !forceOverwrite &&
|
||||||
(n=countHardLinks ( inName ) ) > 0) {
|
(n=countHardLinks ( inName ) ) > 0) {
|
||||||
fprintf ( stderr, "%s: Input file %s has %d other link%s.\n",
|
(fprintf) ( stderr, "%s: Input file %s has %d other link%s.\n",
|
||||||
progName, inName, n, n > 1 ? "s" : "" );
|
progName, inName, n, n > 1 ? "s" : "" );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1414,10 +1323,10 @@ void uncompress ( Char *name )
|
||||||
inStr = stdin;
|
inStr = stdin;
|
||||||
outStr = stdout;
|
outStr = stdout;
|
||||||
if ( isatty ( fileno ( stdin ) ) ) {
|
if ( isatty ( fileno ( stdin ) ) ) {
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: I won't read compressed data from a terminal.\n",
|
"%s: I won't read compressed data from a terminal.\n",
|
||||||
progName );
|
progName );
|
||||||
fprintf ( stderr, "%s: For help, type: `%s --help'.\n",
|
(fprintf) ( stderr, "%s: For help, type: `%s --help'.\n",
|
||||||
progName, progName );
|
progName, progName );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1428,7 +1337,7 @@ void uncompress ( Char *name )
|
||||||
inStr = fopen ( inName, "rb" );
|
inStr = fopen ( inName, "rb" );
|
||||||
outStr = stdout;
|
outStr = stdout;
|
||||||
if ( inStr == NULL ) {
|
if ( inStr == NULL ) {
|
||||||
fprintf ( stderr, "%s: Can't open input file %s:%s.\n",
|
(fprintf) ( stderr, "%s: Can't open input file %s:%s.\n",
|
||||||
progName, inName, strerror(errno) );
|
progName, inName, strerror(errno) );
|
||||||
if ( inStr != NULL ) fclose ( inStr );
|
if ( inStr != NULL ) fclose ( inStr );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
|
@ -1440,14 +1349,14 @@ void uncompress ( Char *name )
|
||||||
inStr = fopen ( inName, "rb" );
|
inStr = fopen ( inName, "rb" );
|
||||||
outStr = fopen_output_safely ( outName, "wb" );
|
outStr = fopen_output_safely ( outName, "wb" );
|
||||||
if ( outStr == NULL) {
|
if ( outStr == NULL) {
|
||||||
fprintf ( stderr, "%s: Can't create output file %s: %s.\n",
|
(fprintf) ( stderr, "%s: Can't create output file %s: %s.\n",
|
||||||
progName, outName, strerror(errno) );
|
progName, outName, strerror(errno) );
|
||||||
if ( inStr != NULL ) fclose ( inStr );
|
if ( inStr != NULL ) fclose ( inStr );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( inStr == NULL ) {
|
if ( inStr == NULL ) {
|
||||||
fprintf ( stderr, "%s: Can't open input file %s: %s.\n",
|
(fprintf) ( stderr, "%s: Can't open input file %s: %s.\n",
|
||||||
progName, inName, strerror(errno) );
|
progName, inName, strerror(errno) );
|
||||||
if ( outStr != NULL ) fclose ( outStr );
|
if ( outStr != NULL ) fclose ( outStr );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
|
@ -1461,7 +1370,7 @@ void uncompress ( Char *name )
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity >= 1) {
|
if (verbosity >= 1) {
|
||||||
fprintf ( stderr, " %s: ", inName );
|
(fprintf) ( stderr, " %s: ", inName );
|
||||||
pad ( inName );
|
pad ( inName );
|
||||||
fflush ( stderr );
|
fflush ( stderr );
|
||||||
}
|
}
|
||||||
|
@ -1494,12 +1403,12 @@ void uncompress ( Char *name )
|
||||||
|
|
||||||
if ( magicNumberOK ) {
|
if ( magicNumberOK ) {
|
||||||
if (verbosity >= 1)
|
if (verbosity >= 1)
|
||||||
fprintf ( stderr, "done\n" );
|
(fprintf) ( stderr, "done\n" );
|
||||||
} else {
|
} else {
|
||||||
setExit(2);
|
setExit(2);
|
||||||
if (verbosity >= 1)
|
if (verbosity >= 1)
|
||||||
fprintf ( stderr, "not a bzip2 file.\n" ); else
|
(fprintf) ( stderr, "not a bzip2 file.\n" ); else
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: %s is not a bzip2 file.\n",
|
"%s: %s is not a bzip2 file.\n",
|
||||||
progName, inName );
|
progName, inName );
|
||||||
}
|
}
|
||||||
|
@ -1529,13 +1438,13 @@ void testf ( Char *name )
|
||||||
|
|
||||||
if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) {
|
if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) {
|
||||||
if (noisy)
|
if (noisy)
|
||||||
fprintf ( stderr, "%s: There are no files matching `%s'.\n",
|
(fprintf) ( stderr, "%s: There are no files matching `%s'.\n",
|
||||||
progName, inName );
|
progName, inName );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( srcMode != SM_I2O && !fileExists ( inName ) ) {
|
if ( srcMode != SM_I2O && !fileExists ( inName ) ) {
|
||||||
fprintf ( stderr, "%s: Can't open input %s: %s.\n",
|
(fprintf) ( stderr, "%s: Can't open input %s: %s.\n",
|
||||||
progName, inName, strerror(errno) );
|
progName, inName, strerror(errno) );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1543,7 +1452,7 @@ void testf ( Char *name )
|
||||||
if ( srcMode != SM_I2O ) {
|
if ( srcMode != SM_I2O ) {
|
||||||
MY_STAT(inName, &statBuf);
|
MY_STAT(inName, &statBuf);
|
||||||
if ( MY_S_ISDIR(statBuf.st_mode) ) {
|
if ( MY_S_ISDIR(statBuf.st_mode) ) {
|
||||||
fprintf( stderr,
|
(fprintf)( stderr,
|
||||||
"%s: Input file %s is a directory.\n",
|
"%s: Input file %s is a directory.\n",
|
||||||
progName,inName);
|
progName,inName);
|
||||||
setExit(1);
|
setExit(1);
|
||||||
|
@ -1555,10 +1464,10 @@ void testf ( Char *name )
|
||||||
|
|
||||||
case SM_I2O:
|
case SM_I2O:
|
||||||
if ( isatty ( fileno ( stdin ) ) ) {
|
if ( isatty ( fileno ( stdin ) ) ) {
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: I won't read compressed data from a terminal.\n",
|
"%s: I won't read compressed data from a terminal.\n",
|
||||||
progName );
|
progName );
|
||||||
fprintf ( stderr, "%s: For help, type: `%s --help'.\n",
|
(fprintf) ( stderr, "%s: For help, type: `%s --help'.\n",
|
||||||
progName, progName );
|
progName, progName );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1569,7 +1478,7 @@ void testf ( Char *name )
|
||||||
case SM_F2O: case SM_F2F:
|
case SM_F2O: case SM_F2F:
|
||||||
inStr = fopen ( inName, "rb" );
|
inStr = fopen ( inName, "rb" );
|
||||||
if ( inStr == NULL ) {
|
if ( inStr == NULL ) {
|
||||||
fprintf ( stderr, "%s: Can't open input file %s:%s.\n",
|
(fprintf) ( stderr, "%s: Can't open input file %s:%s.\n",
|
||||||
progName, inName, strerror(errno) );
|
progName, inName, strerror(errno) );
|
||||||
setExit(1);
|
setExit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -1582,7 +1491,7 @@ void testf ( Char *name )
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity >= 1) {
|
if (verbosity >= 1) {
|
||||||
fprintf ( stderr, " %s: ", inName );
|
(fprintf) ( stderr, " %s: ", inName );
|
||||||
pad ( inName );
|
pad ( inName );
|
||||||
fflush ( stderr );
|
fflush ( stderr );
|
||||||
}
|
}
|
||||||
|
@ -1591,7 +1500,7 @@ void testf ( Char *name )
|
||||||
outputHandleJustInCase = NULL;
|
outputHandleJustInCase = NULL;
|
||||||
allOK = testStream ( inStr );
|
allOK = testStream ( inStr );
|
||||||
|
|
||||||
if (allOK && verbosity >= 1) fprintf ( stderr, "ok\n" );
|
if (allOK && verbosity >= 1) (fprintf) ( stderr, "ok\n" );
|
||||||
if (!allOK) testFailsExist = True;
|
if (!allOK) testFailsExist = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1600,7 +1509,7 @@ void testf ( Char *name )
|
||||||
static
|
static
|
||||||
void license ( void )
|
void license ( void )
|
||||||
{
|
{
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
|
|
||||||
"bzip2, a block-sorting file compressor. "
|
"bzip2, a block-sorting file compressor. "
|
||||||
"Version %s.\n"
|
"Version %s.\n"
|
||||||
|
@ -1625,7 +1534,7 @@ void license ( void )
|
||||||
static
|
static
|
||||||
void usage ( Char *fullProgName )
|
void usage ( Char *fullProgName )
|
||||||
{
|
{
|
||||||
fprintf (
|
(fprintf) (
|
||||||
stderr,
|
stderr,
|
||||||
"bzip2, a block-sorting file compressor. "
|
"bzip2, a block-sorting file compressor. "
|
||||||
"Version %s.\n"
|
"Version %s.\n"
|
||||||
|
@ -1669,7 +1578,7 @@ void usage ( Char *fullProgName )
|
||||||
static
|
static
|
||||||
void redundant ( Char* flag )
|
void redundant ( Char* flag )
|
||||||
{
|
{
|
||||||
fprintf (
|
(fprintf) (
|
||||||
stderr,
|
stderr,
|
||||||
"%s: %s is redundant in versions 0.9.5 and above\n",
|
"%s: %s is redundant in versions 0.9.5 and above\n",
|
||||||
progName, flag );
|
progName, flag );
|
||||||
|
@ -1895,7 +1804,7 @@ IntNative main ( IntNative argc, Char *argv[] )
|
||||||
case 'h': usage ( progName );
|
case 'h': usage ( progName );
|
||||||
exit ( 0 );
|
exit ( 0 );
|
||||||
break;
|
break;
|
||||||
default: fprintf ( stderr, "%s: Bad flag `%s'\n",
|
default: (fprintf) ( stderr, "%s: Bad flag `%s'\n",
|
||||||
progName, aa->name );
|
progName, aa->name );
|
||||||
usage ( progName );
|
usage ( progName );
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
|
@ -1927,7 +1836,7 @@ IntNative main ( IntNative argc, Char *argv[] )
|
||||||
if (ISFLAG("--help")) { usage ( progName ); exit ( 0 ); }
|
if (ISFLAG("--help")) { usage ( progName ); exit ( 0 ); }
|
||||||
else
|
else
|
||||||
if (strncmp ( aa->name, "--", 2) == 0) {
|
if (strncmp ( aa->name, "--", 2) == 0) {
|
||||||
fprintf ( stderr, "%s: Bad flag `%s'\n", progName, aa->name );
|
(fprintf) ( stderr, "%s: Bad flag `%s'\n", progName, aa->name );
|
||||||
usage ( progName );
|
usage ( progName );
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
}
|
}
|
||||||
|
@ -1938,7 +1847,7 @@ IntNative main ( IntNative argc, Char *argv[] )
|
||||||
blockSize100k = 2;
|
blockSize100k = 2;
|
||||||
|
|
||||||
if (opMode == OM_TEST && srcMode == SM_F2O) {
|
if (opMode == OM_TEST && srcMode == SM_F2O) {
|
||||||
fprintf ( stderr, "%s: -c and -t cannot be used together.\n",
|
(fprintf) ( stderr, "%s: -c and -t cannot be used together.\n",
|
||||||
progName );
|
progName );
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
}
|
}
|
||||||
|
@ -2005,7 +1914,7 @@ IntNative main ( IntNative argc, Char *argv[] )
|
||||||
}
|
}
|
||||||
if (testFailsExist) {
|
if (testFailsExist) {
|
||||||
if (noisy) {
|
if (noisy) {
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"\n"
|
"\n"
|
||||||
"You can use the `bzip2recover' program to attempt to recover\n"
|
"You can use the `bzip2recover' program to attempt to recover\n"
|
||||||
"data from undamaged sections of corrupted files.\n\n"
|
"data from undamaged sections of corrupted files.\n\n"
|
||||||
|
|
58
third_party/bzip2/bzip2.mk
vendored
58
third_party/bzip2/bzip2.mk
vendored
|
@ -7,28 +7,32 @@ THIRD_PARTY_BZIP2_ARTIFACTS += THIRD_PARTY_BZIP2_A
|
||||||
THIRD_PARTY_BZIP2 = $(THIRD_PARTY_BZIP2_A_DEPS) $(THIRD_PARTY_BZIP2_A)
|
THIRD_PARTY_BZIP2 = $(THIRD_PARTY_BZIP2_A_DEPS) $(THIRD_PARTY_BZIP2_A)
|
||||||
THIRD_PARTY_BZIP2_A = o/$(MODE)/third_party/bzip2/bzip2.a
|
THIRD_PARTY_BZIP2_A = o/$(MODE)/third_party/bzip2/bzip2.a
|
||||||
THIRD_PARTY_BZIP2_A_FILES := $(wildcard third_party/bzip2/*)
|
THIRD_PARTY_BZIP2_A_FILES := $(wildcard third_party/bzip2/*)
|
||||||
THIRD_PARTY_BZIP2_A_HDRS = third_party/bzip2/bzip2.h
|
THIRD_PARTY_BZIP2_A_HDRS = $(filter %.h,$(THIRD_PARTY_BZIP2_A_FILES))
|
||||||
THIRD_PARTY_BZIP2_A_HDRS_ALL = $(filter %.h,$(THIRD_PARTY_BZIP2_A_FILES))
|
THIRD_PARTY_BZIP2_A_SRCS = $(filter %.c,$(THIRD_PARTY_BZIP2_A_FILES))
|
||||||
THIRD_PARTY_BZIP2_A_SRCS_S = $(filter %.S,$(THIRD_PARTY_BZIP2_A_FILES))
|
THIRD_PARTY_BZIP2_A_OBJS = $(THIRD_PARTY_BZIP2_A_SRCS:%.c=o/$(MODE)/%.o)
|
||||||
THIRD_PARTY_BZIP2_A_SRCS_C = $(filter %.c,$(THIRD_PARTY_BZIP2_A_FILES))
|
THIRD_PARTY_BZIP2_BINS = $(THIRD_PARTY_BZIP2_COMS) $(THIRD_PARTY_BZIP2_COMS:%=%.dbg)
|
||||||
|
|
||||||
THIRD_PARTY_BZIP2_A_SRCS = \
|
THIRD_PARTY_BZIP2_COMS = \
|
||||||
$(THIRD_PARTY_BZIP2_A_SRCS_S) \
|
o/$(MODE)/third_party/bzip2/bzip2.com \
|
||||||
$(THIRD_PARTY_BZIP2_A_SRCS_C)
|
o/$(MODE)/third_party/bzip2/bzip2recover.com
|
||||||
|
|
||||||
THIRD_PARTY_BZIP2_A_OBJS = \
|
|
||||||
$(THIRD_PARTY_BZIP2_A_SRCS_S:%.S=o/$(MODE)/%.o) \
|
|
||||||
$(THIRD_PARTY_BZIP2_A_SRCS_C:%.c=o/$(MODE)/%.o)
|
|
||||||
|
|
||||||
THIRD_PARTY_BZIP2_A_CHECKS = \
|
THIRD_PARTY_BZIP2_A_CHECKS = \
|
||||||
$(THIRD_PARTY_BZIP2_A).pkg \
|
$(THIRD_PARTY_BZIP2_A).pkg \
|
||||||
$(THIRD_PARTY_BZIP2_A_HDRS_ALL:%=o/$(MODE)/%.ok)
|
$(THIRD_PARTY_BZIP2_A_HDRS:%=o/$(MODE)/%.ok)
|
||||||
|
|
||||||
THIRD_PARTY_BZIP2_A_DIRECTDEPS = \
|
THIRD_PARTY_BZIP2_A_DIRECTDEPS = \
|
||||||
|
LIBC_CALLS \
|
||||||
|
LIBC_FMT \
|
||||||
LIBC_INTRIN \
|
LIBC_INTRIN \
|
||||||
|
LIBC_LOG \
|
||||||
|
LIBC_MEM \
|
||||||
LIBC_NEXGEN32E \
|
LIBC_NEXGEN32E \
|
||||||
|
LIBC_RAND \
|
||||||
|
LIBC_RUNTIME \
|
||||||
|
LIBC_STDIO \
|
||||||
LIBC_STR \
|
LIBC_STR \
|
||||||
LIBC_STUBS
|
LIBC_STUBS \
|
||||||
|
LIBC_SYSV
|
||||||
|
|
||||||
THIRD_PARTY_BZIP2_A_DEPS := \
|
THIRD_PARTY_BZIP2_A_DEPS := \
|
||||||
$(call uniq,$(foreach x,$(THIRD_PARTY_BZIP2_A_DIRECTDEPS),$($(x))))
|
$(call uniq,$(foreach x,$(THIRD_PARTY_BZIP2_A_DIRECTDEPS),$($(x))))
|
||||||
|
@ -42,10 +46,30 @@ $(THIRD_PARTY_BZIP2_A).pkg: \
|
||||||
$(THIRD_PARTY_BZIP2_A_OBJS) \
|
$(THIRD_PARTY_BZIP2_A_OBJS) \
|
||||||
$(foreach x,$(THIRD_PARTY_BZIP2_A_DIRECTDEPS),$($(x)_A).pkg)
|
$(foreach x,$(THIRD_PARTY_BZIP2_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||||
|
|
||||||
|
o/$(MODE)/third_party/bzip2/bzip2.com.dbg: \
|
||||||
|
$(THIRD_PARTY_BZIP2) \
|
||||||
|
o/$(MODE)/third_party/bzip2/bzip2.o \
|
||||||
|
o/$(MODE)/third_party/bzip2/bzip2.a.pkg \
|
||||||
|
$(CRT) \
|
||||||
|
$(APE)
|
||||||
|
-@$(APELINK)
|
||||||
|
|
||||||
|
o/$(MODE)/third_party/bzip2/bzip2recover.com.dbg: \
|
||||||
|
$(THIRD_PARTY_BZIP2) \
|
||||||
|
o/$(MODE)/third_party/bzip2/bzip2recover.o \
|
||||||
|
o/$(MODE)/third_party/bzip2/bzip2.a.pkg \
|
||||||
|
$(CRT) \
|
||||||
|
$(APE)
|
||||||
|
-@$(APELINK)
|
||||||
|
|
||||||
|
$(THIRD_PARTY_BZIP2_A_OBJS): \
|
||||||
|
OVERRIDE_CFLAGS += \
|
||||||
|
-ffunction-sections \
|
||||||
|
-fdata-sections
|
||||||
|
|
||||||
THIRD_PARTY_BZIP2_LIBS = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)))
|
THIRD_PARTY_BZIP2_LIBS = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)))
|
||||||
THIRD_PARTY_BZIP2_SRCS = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)_SRCS))
|
THIRD_PARTY_BZIP2_SRCS = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)_SRCS))
|
||||||
THIRD_PARTY_BZIP2_HDRS = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)_HDRS))
|
THIRD_PARTY_BZIP2_HDRS = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)_HDRS))
|
||||||
THIRD_PARTY_BZIP2_HDRS_ALL = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)_HDRS_ALL))
|
|
||||||
THIRD_PARTY_BZIP2_BINS = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)_BINS))
|
THIRD_PARTY_BZIP2_BINS = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)_BINS))
|
||||||
THIRD_PARTY_BZIP2_CHECKS = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)_CHECKS))
|
THIRD_PARTY_BZIP2_CHECKS = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)_CHECKS))
|
||||||
THIRD_PARTY_BZIP2_OBJS = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)_OBJS))
|
THIRD_PARTY_BZIP2_OBJS = $(foreach x,$(THIRD_PARTY_BZIP2_ARTIFACTS),$($(x)_OBJS))
|
||||||
|
@ -53,5 +77,9 @@ $(THIRD_PARTY_BZIP2_OBJS): $(BUILD_FILES) third_party/bzip2/bzip2.mk
|
||||||
|
|
||||||
.PHONY: o/$(MODE)/third_party/bzip2
|
.PHONY: o/$(MODE)/third_party/bzip2
|
||||||
o/$(MODE)/third_party/bzip2: \
|
o/$(MODE)/third_party/bzip2: \
|
||||||
$(THIRD_PARTY_BZIP2_A) \
|
$(THIRD_PARTY_BZIP2_COMS) \
|
||||||
$(THIRD_PARTY_BZIP2_CHECKS)
|
$(THIRD_PARTY_BZIP2_CHECKS)
|
||||||
|
|
||||||
|
# TODO(jart): write regression test
|
||||||
|
# master jart@nightmare:~/cosmo$ o//third_party/bzip2/bzip2.com -1 <third_party/bzip2/sample1.ref >a
|
||||||
|
# master jart@nightmare:~/cosmo$ cmp -s third_party/bzip2/sample1.bz2 a
|
||||||
|
|
68
third_party/bzip2/bzip2recover.c
vendored
68
third_party/bzip2/bzip2recover.c
vendored
|
@ -1,3 +1,11 @@
|
||||||
|
#include "libc/calls/calls.h"
|
||||||
|
#include "libc/errno.h"
|
||||||
|
#include "libc/fmt/fmt.h"
|
||||||
|
#include "libc/log/log.h"
|
||||||
|
#include "libc/runtime/runtime.h"
|
||||||
|
#include "libc/stdio/stdio.h"
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
/*--- Block recoverer program for bzip2 ---*/
|
/*--- Block recoverer program for bzip2 ---*/
|
||||||
/*--- bzip2recover.c ---*/
|
/*--- bzip2recover.c ---*/
|
||||||
|
@ -20,12 +28,6 @@
|
||||||
/* This program is a complete hack and should be rewritten properly.
|
/* This program is a complete hack and should be rewritten properly.
|
||||||
It isn't very complicated. */
|
It isn't very complicated. */
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* This program records bit locations in the file to be recovered.
|
/* This program records bit locations in the file to be recovered.
|
||||||
That means that if 64-bit ints are not supported, we will not
|
That means that if 64-bit ints are not supported, we will not
|
||||||
be able to recover .bz2 files over 512MB (2^32 bits) long.
|
be able to recover .bz2 files over 512MB (2^32 bits) long.
|
||||||
|
@ -84,11 +86,11 @@ MaybeUInt64 bytesIn = 0;
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
static 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",
|
||||||
progName, inFileName );
|
progName, inFileName );
|
||||||
perror ( progName );
|
perror ( progName );
|
||||||
fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n",
|
(fprintf) ( stderr, "%s: warning: output file(s) may be incomplete.\n",
|
||||||
progName );
|
progName );
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
}
|
}
|
||||||
|
@ -97,11 +99,11 @@ static void readError ( void )
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
static 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",
|
||||||
progName, inFileName );
|
progName, inFileName );
|
||||||
perror ( progName );
|
perror ( progName );
|
||||||
fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n",
|
(fprintf) ( stderr, "%s: warning: output file(s) may be incomplete.\n",
|
||||||
progName );
|
progName );
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
}
|
}
|
||||||
|
@ -110,10 +112,10 @@ static void writeError ( void )
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
static 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",
|
||||||
progName, n );
|
progName, n );
|
||||||
fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n",
|
(fprintf) ( stderr, "%s: warning: output file(s) may be incomplete.\n",
|
||||||
progName );
|
progName );
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
}
|
}
|
||||||
|
@ -122,13 +124,13 @@ static void mallocFail ( Int32 n )
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
static 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",
|
||||||
progName, inFileName, max_handled_blocks );
|
progName, inFileName, max_handled_blocks );
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: and cannot be handled. To fix, increase\n",
|
"%s: and cannot be handled. To fix, increase\n",
|
||||||
progName );
|
progName );
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: BZ_MAX_HANDLED_BLOCKS in bzip2recover.c, and recompile.\n",
|
"%s: BZ_MAX_HANDLED_BLOCKS in bzip2recover.c, and recompile.\n",
|
||||||
progName );
|
progName );
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
|
@ -313,26 +315,26 @@ Int32 main ( Int32 argc, Char** argv )
|
||||||
progName[BZ_MAX_FILENAME-1]='\0';
|
progName[BZ_MAX_FILENAME-1]='\0';
|
||||||
inFileName[0] = outFileName[0] = 0;
|
inFileName[0] = outFileName[0] = 0;
|
||||||
|
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"bzip2recover 1.0.8: extracts blocks from damaged .bz2 files.\n" );
|
"bzip2recover 1.0.8: 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",
|
||||||
progName, progName );
|
progName, progName );
|
||||||
switch (sizeof(MaybeUInt64)) {
|
switch (sizeof(MaybeUInt64)) {
|
||||||
case 8:
|
case 8:
|
||||||
fprintf(stderr,
|
(fprintf)(stderr,
|
||||||
"\trestrictions on size of recovered file: None\n");
|
"\trestrictions on size of recovered file: None\n");
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
fprintf(stderr,
|
(fprintf)(stderr,
|
||||||
"\trestrictions on size of recovered file: 512 MB\n");
|
"\trestrictions on size of recovered file: 512 MB\n");
|
||||||
fprintf(stderr,
|
(fprintf)(stderr,
|
||||||
"\tto circumvent, recompile with MaybeUInt64 as an\n"
|
"\tto circumvent, recompile with MaybeUInt64 as an\n"
|
||||||
"\tunsigned 64-bit int.\n");
|
"\tunsigned 64-bit int.\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
(fprintf)(stderr,
|
||||||
"\tsizeof(MaybeUInt64) is not 4 or 8 -- "
|
"\tsizeof(MaybeUInt64) is not 4 or 8 -- "
|
||||||
"configuration error.\n");
|
"configuration error.\n");
|
||||||
break;
|
break;
|
||||||
|
@ -341,7 +343,7 @@ Int32 main ( Int32 argc, Char** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(argv[1]) >= BZ_MAX_FILENAME-20) {
|
if (strlen(argv[1]) >= BZ_MAX_FILENAME-20) {
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: supplied filename is suspiciously (>= %d chars) long. Bye!\n",
|
"%s: supplied filename is suspiciously (>= %d chars) long. Bye!\n",
|
||||||
progName, (int)strlen(argv[1]) );
|
progName, (int)strlen(argv[1]) );
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -351,12 +353,12 @@ Int32 main ( Int32 argc, Char** argv )
|
||||||
|
|
||||||
inFile = fopen ( inFileName, "rb" );
|
inFile = fopen ( inFileName, "rb" );
|
||||||
if (inFile == NULL) {
|
if (inFile == NULL) {
|
||||||
fprintf ( stderr, "%s: can't read `%s'\n", progName, inFileName );
|
(fprintf) ( stderr, "%s: can't read `%s'\n", progName, inFileName );
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bsIn = bsOpenReadStream ( inFile );
|
bsIn = bsOpenReadStream ( inFile );
|
||||||
fprintf ( stderr, "%s: searching for block boundaries ...\n", progName );
|
(fprintf) ( stderr, "%s: searching for block boundaries ...\n", progName );
|
||||||
|
|
||||||
bitsRead = 0;
|
bitsRead = 0;
|
||||||
buffHi = buffLo = 0;
|
buffHi = buffLo = 0;
|
||||||
|
@ -373,7 +375,7 @@ Int32 main ( Int32 argc, Char** argv )
|
||||||
(bitsRead - bStart[currBlock]) >= 40) {
|
(bitsRead - bStart[currBlock]) >= 40) {
|
||||||
bEnd[currBlock] = bitsRead-1;
|
bEnd[currBlock] = bitsRead-1;
|
||||||
if (currBlock > 0)
|
if (currBlock > 0)
|
||||||
fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT
|
(fprintf) ( stderr, " block %d runs from " MaybeUInt64_FMT
|
||||||
" to " MaybeUInt64_FMT " (incomplete)\n",
|
" to " MaybeUInt64_FMT " (incomplete)\n",
|
||||||
currBlock, bStart[currBlock], bEnd[currBlock] );
|
currBlock, bStart[currBlock], bEnd[currBlock] );
|
||||||
} else
|
} else
|
||||||
|
@ -395,7 +397,7 @@ Int32 main ( Int32 argc, Char** argv )
|
||||||
}
|
}
|
||||||
if (currBlock > 0 &&
|
if (currBlock > 0 &&
|
||||||
(bEnd[currBlock] - bStart[currBlock]) >= 130) {
|
(bEnd[currBlock] - bStart[currBlock]) >= 130) {
|
||||||
fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT
|
(fprintf) ( stderr, " block %d runs from " MaybeUInt64_FMT
|
||||||
" to " MaybeUInt64_FMT "\n",
|
" to " MaybeUInt64_FMT "\n",
|
||||||
rbCtr+1, bStart[currBlock], bEnd[currBlock] );
|
rbCtr+1, bStart[currBlock], bEnd[currBlock] );
|
||||||
rbStart[rbCtr] = bStart[currBlock];
|
rbStart[rbCtr] = bStart[currBlock];
|
||||||
|
@ -415,17 +417,17 @@ Int32 main ( Int32 argc, Char** argv )
|
||||||
/*-- identified blocks run from 1 to rbCtr inclusive. --*/
|
/*-- identified blocks run from 1 to rbCtr inclusive. --*/
|
||||||
|
|
||||||
if (rbCtr < 1) {
|
if (rbCtr < 1) {
|
||||||
fprintf ( stderr,
|
(fprintf) ( stderr,
|
||||||
"%s: sorry, I couldn't find any block boundaries.\n",
|
"%s: sorry, I couldn't find any block boundaries.\n",
|
||||||
progName );
|
progName );
|
||||||
exit(1);
|
exit(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
fprintf ( stderr, "%s: splitting into blocks\n", progName );
|
(fprintf) ( stderr, "%s: splitting into blocks\n", progName );
|
||||||
|
|
||||||
inFile = fopen ( inFileName, "rb" );
|
inFile = fopen ( inFileName, "rb" );
|
||||||
if (inFile == NULL) {
|
if (inFile == NULL) {
|
||||||
fprintf ( stderr, "%s: can't open `%s'\n", progName, inFileName );
|
(fprintf) ( stderr, "%s: can't open `%s'\n", progName, inFileName );
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
bsIn = bsOpenReadStream ( inFile );
|
bsIn = bsOpenReadStream ( inFile );
|
||||||
|
@ -479,18 +481,18 @@ Int32 main ( Int32 argc, Char** argv )
|
||||||
}
|
}
|
||||||
/* Now split points to the start of the basename. */
|
/* Now split points to the start of the basename. */
|
||||||
ofs = split - outFileName;
|
ofs = split - outFileName;
|
||||||
sprintf (split, "rec%5d", wrBlock+1);
|
(sprintf) (split, "rec%5d", wrBlock+1);
|
||||||
for (p = split; *p != 0; p++) if (*p == ' ') *p = '0';
|
for (p = split; *p != 0; p++) if (*p == ' ') *p = '0';
|
||||||
strcat (outFileName, inFileName + ofs);
|
strcat (outFileName, inFileName + ofs);
|
||||||
|
|
||||||
if ( !endsInBz2(outFileName)) strcat ( outFileName, ".bz2" );
|
if ( !endsInBz2(outFileName)) strcat ( outFileName, ".bz2" );
|
||||||
|
|
||||||
fprintf ( stderr, " writing block %d to `%s' ...\n",
|
(fprintf) ( stderr, " writing block %d to `%s' ...\n",
|
||||||
wrBlock+1, outFileName );
|
wrBlock+1, outFileName );
|
||||||
|
|
||||||
outFile = fopen ( outFileName, "wb" );
|
outFile = fopen ( outFileName, "wb" );
|
||||||
if (outFile == NULL) {
|
if (outFile == NULL) {
|
||||||
fprintf ( stderr, "%s: can't write `%s'\n",
|
(fprintf) ( stderr, "%s: can't write `%s'\n",
|
||||||
progName, outFileName );
|
progName, outFileName );
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -505,7 +507,7 @@ Int32 main ( Int32 argc, Char** argv )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf ( stderr, "%s: finished\n", progName );
|
(fprintf) ( stderr, "%s: finished\n", progName );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
54
third_party/bzip2/bzlib.c
vendored
54
third_party/bzip2/bzlib.c
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- Library top-level functions. ---*/
|
/*--- Library top-level functions. ---*/
|
||||||
|
@ -28,7 +29,8 @@
|
||||||
bzBuffToBuffDecompress. Fixed.
|
bzBuffToBuffDecompress. Fixed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bzlib_private.h"
|
#include "libc/calls/calls.h"
|
||||||
|
#include "third_party/bzip2/bzlib_private.inc"
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
|
@ -145,7 +147,7 @@ Bool isempty_RL ( EState* s )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzCompressInit)
|
int BZ2_bzCompressInit
|
||||||
( bz_stream* strm,
|
( bz_stream* strm,
|
||||||
int blockSize100k,
|
int blockSize100k,
|
||||||
int verbosity,
|
int verbosity,
|
||||||
|
@ -404,7 +406,7 @@ Bool handle_compress ( bz_stream* strm )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
|
int BZ2_bzCompress ( bz_stream *strm, int action )
|
||||||
{
|
{
|
||||||
Bool progress;
|
Bool progress;
|
||||||
EState* s;
|
EState* s;
|
||||||
|
@ -465,7 +467,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
|
int BZ2_bzCompressEnd ( bz_stream *strm )
|
||||||
{
|
{
|
||||||
EState* s;
|
EState* s;
|
||||||
if (strm == NULL) return BZ_PARAM_ERROR;
|
if (strm == NULL) return BZ_PARAM_ERROR;
|
||||||
|
@ -489,7 +491,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzDecompressInit)
|
int BZ2_bzDecompressInit
|
||||||
( bz_stream* strm,
|
( bz_stream* strm,
|
||||||
int verbosity,
|
int verbosity,
|
||||||
int small )
|
int small )
|
||||||
|
@ -805,7 +807,7 @@ Bool unRLE_obuf_to_output_SMALL ( DState* s )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
|
int BZ2_bzDecompress ( bz_stream *strm )
|
||||||
{
|
{
|
||||||
Bool corrupt;
|
Bool corrupt;
|
||||||
DState* s;
|
DState* s;
|
||||||
|
@ -859,7 +861,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm )
|
int BZ2_bzDecompressEnd ( bz_stream *strm )
|
||||||
{
|
{
|
||||||
DState* s;
|
DState* s;
|
||||||
if (strm == NULL) return BZ_PARAM_ERROR;
|
if (strm == NULL) return BZ_PARAM_ERROR;
|
||||||
|
@ -878,7 +880,6 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef BZ_NO_STDIO
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
/*--- File I/O stuff ---*/
|
/*--- File I/O stuff ---*/
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
|
@ -913,7 +914,7 @@ static Bool myfeof ( FILE* f )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
BZFILE* BZ_API(BZ2_bzWriteOpen)
|
BZFILE* BZ2_bzWriteOpen
|
||||||
( int* bzerror,
|
( int* bzerror,
|
||||||
FILE* f,
|
FILE* f,
|
||||||
int blockSize100k,
|
int blockSize100k,
|
||||||
|
@ -961,7 +962,7 @@ BZFILE* BZ_API(BZ2_bzWriteOpen)
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
void BZ_API(BZ2_bzWrite)
|
void BZ2_bzWrite
|
||||||
( int* bzerror,
|
( int* bzerror,
|
||||||
BZFILE* b,
|
BZFILE* b,
|
||||||
void* buf,
|
void* buf,
|
||||||
|
@ -1006,7 +1007,7 @@ void BZ_API(BZ2_bzWrite)
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
void BZ_API(BZ2_bzWriteClose)
|
void BZ2_bzWriteClose
|
||||||
( int* bzerror,
|
( int* bzerror,
|
||||||
BZFILE* b,
|
BZFILE* b,
|
||||||
int abandon,
|
int abandon,
|
||||||
|
@ -1018,7 +1019,7 @@ void BZ_API(BZ2_bzWriteClose)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BZ_API(BZ2_bzWriteClose64)
|
void BZ2_bzWriteClose64
|
||||||
( int* bzerror,
|
( int* bzerror,
|
||||||
BZFILE* b,
|
BZFILE* b,
|
||||||
int abandon,
|
int abandon,
|
||||||
|
@ -1084,7 +1085,7 @@ void BZ_API(BZ2_bzWriteClose64)
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
BZFILE* BZ_API(BZ2_bzReadOpen)
|
BZFILE* BZ2_bzReadOpen
|
||||||
( int* bzerror,
|
( int* bzerror,
|
||||||
FILE* f,
|
FILE* f,
|
||||||
int verbosity,
|
int verbosity,
|
||||||
|
@ -1140,7 +1141,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b )
|
void BZ2_bzReadClose ( int *bzerror, BZFILE *b )
|
||||||
{
|
{
|
||||||
bzFile* bzf = (bzFile*)b;
|
bzFile* bzf = (bzFile*)b;
|
||||||
|
|
||||||
|
@ -1158,7 +1159,7 @@ void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzRead)
|
int BZ2_bzRead
|
||||||
( int* bzerror,
|
( int* bzerror,
|
||||||
BZFILE* b,
|
BZFILE* b,
|
||||||
void* buf,
|
void* buf,
|
||||||
|
@ -1218,7 +1219,7 @@ int BZ_API(BZ2_bzRead)
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
void BZ_API(BZ2_bzReadGetUnused)
|
void BZ2_bzReadGetUnused
|
||||||
( int* bzerror,
|
( int* bzerror,
|
||||||
BZFILE* b,
|
BZFILE* b,
|
||||||
void** unused,
|
void** unused,
|
||||||
|
@ -1236,7 +1237,6 @@ void BZ_API(BZ2_bzReadGetUnused)
|
||||||
*nUnused = bzf->strm.avail_in;
|
*nUnused = bzf->strm.avail_in;
|
||||||
*unused = bzf->strm.next_in;
|
*unused = bzf->strm.next_in;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
|
@ -1244,7 +1244,7 @@ void BZ_API(BZ2_bzReadGetUnused)
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzBuffToBuffCompress)
|
int BZ2_bzBuffToBuffCompress
|
||||||
( char* dest,
|
( char* dest,
|
||||||
unsigned int* destLen,
|
unsigned int* destLen,
|
||||||
char* source,
|
char* source,
|
||||||
|
@ -1296,7 +1296,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress)
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzBuffToBuffDecompress)
|
int BZ2_bzBuffToBuffDecompress
|
||||||
( char* dest,
|
( char* dest,
|
||||||
unsigned int* destLen,
|
unsigned int* destLen,
|
||||||
char* source,
|
char* source,
|
||||||
|
@ -1363,7 +1363,7 @@ int BZ_API(BZ2_bzBuffToBuffDecompress)
|
||||||
/*--
|
/*--
|
||||||
return version like "0.9.5d, 4-Sept-1999".
|
return version like "0.9.5d, 4-Sept-1999".
|
||||||
--*/
|
--*/
|
||||||
const char * BZ_API(BZ2_bzlibVersion)(void)
|
const char * BZ2_bzlibVersion(void)
|
||||||
{
|
{
|
||||||
return BZ_VERSION;
|
return BZ_VERSION;
|
||||||
}
|
}
|
||||||
|
@ -1457,7 +1457,7 @@ BZFILE * bzopen_or_bzdopen
|
||||||
ex) bzopen("file","w9")
|
ex) bzopen("file","w9")
|
||||||
case path="" or NULL => use stdin or stdout.
|
case path="" or NULL => use stdin or stdout.
|
||||||
--*/
|
--*/
|
||||||
BZFILE * BZ_API(BZ2_bzopen)
|
BZFILE * BZ2_bzopen
|
||||||
( const char *path,
|
( const char *path,
|
||||||
const char *mode )
|
const char *mode )
|
||||||
{
|
{
|
||||||
|
@ -1466,7 +1466,7 @@ BZFILE * BZ_API(BZ2_bzopen)
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
BZFILE * BZ_API(BZ2_bzdopen)
|
BZFILE * BZ2_bzdopen
|
||||||
( int fd,
|
( int fd,
|
||||||
const char *mode )
|
const char *mode )
|
||||||
{
|
{
|
||||||
|
@ -1475,7 +1475,7 @@ BZFILE * BZ_API(BZ2_bzdopen)
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len )
|
int BZ2_bzread (BZFILE* b, void* buf, int len )
|
||||||
{
|
{
|
||||||
int bzerr, nread;
|
int bzerr, nread;
|
||||||
if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0;
|
if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0;
|
||||||
|
@ -1489,7 +1489,7 @@ int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len )
|
int BZ2_bzwrite (BZFILE* b, void* buf, int len )
|
||||||
{
|
{
|
||||||
int bzerr;
|
int bzerr;
|
||||||
|
|
||||||
|
@ -1503,7 +1503,7 @@ int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len )
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
int BZ_API(BZ2_bzflush) (BZFILE *b)
|
int BZ2_bzflush (BZFILE *b)
|
||||||
{
|
{
|
||||||
/* do nothing now... */
|
/* do nothing now... */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1511,7 +1511,7 @@ int BZ_API(BZ2_bzflush) (BZFILE *b)
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
void BZ_API(BZ2_bzclose) (BZFILE* b)
|
void BZ2_bzclose (BZFILE* b)
|
||||||
{
|
{
|
||||||
int bzerr;
|
int bzerr;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
@ -1556,7 +1556,7 @@ static const char *bzerrorstrings[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum)
|
const char * BZ2_bzerror (BZFILE *b, int *errnum)
|
||||||
{
|
{
|
||||||
int err = ((bzFile *)b)->lastErr;
|
int err = ((bzFile *)b)->lastErr;
|
||||||
|
|
||||||
|
|
271
third_party/bzip2/bzlib.h
vendored
271
third_party/bzip2/bzlib.h
vendored
|
@ -1,30 +1,6 @@
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/*--- Public header file for the library. ---*/
|
|
||||||
/*--- bzlib.h ---*/
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
|
||||||
lossless, block-sorting data compression.
|
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.8 of 13 July 2019
|
|
||||||
Copyright (C) 1996-2019 Julian Seward <jseward@acm.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.
|
|
||||||
------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _BZLIB_H
|
#ifndef _BZLIB_H
|
||||||
#define _BZLIB_H
|
#define _BZLIB_H
|
||||||
|
#include "libc/stdio/stdio.h"
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define BZ_RUN 0
|
#define BZ_RUN 0
|
||||||
#define BZ_FLUSH 1
|
#define BZ_FLUSH 1
|
||||||
|
@ -45,181 +21,52 @@ extern "C" {
|
||||||
#define BZ_OUTBUFF_FULL (-8)
|
#define BZ_OUTBUFF_FULL (-8)
|
||||||
#define BZ_CONFIG_ERROR (-9)
|
#define BZ_CONFIG_ERROR (-9)
|
||||||
|
|
||||||
typedef
|
#define BZ_MAX_UNUSED 5000
|
||||||
struct {
|
|
||||||
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||||
|
COSMOPOLITAN_C_START_
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
char *next_in;
|
char *next_in;
|
||||||
unsigned int avail_in;
|
unsigned int avail_in;
|
||||||
unsigned int total_in_lo32;
|
unsigned int total_in_lo32;
|
||||||
unsigned int total_in_hi32;
|
unsigned int total_in_hi32;
|
||||||
|
|
||||||
char *next_out;
|
char *next_out;
|
||||||
unsigned int avail_out;
|
unsigned int avail_out;
|
||||||
unsigned int total_out_lo32;
|
unsigned int total_out_lo32;
|
||||||
unsigned int total_out_hi32;
|
unsigned int total_out_hi32;
|
||||||
|
|
||||||
void *state;
|
void *state;
|
||||||
|
void *(*bzalloc)(void *, int, int);
|
||||||
void *(*bzalloc)(void *,int,int);
|
void (*bzfree)(void *, void *);
|
||||||
void (*bzfree)(void *,void *);
|
|
||||||
void *opaque;
|
void *opaque;
|
||||||
}
|
} bz_stream;
|
||||||
bz_stream;
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef BZ_IMPORT
|
|
||||||
#define BZ_EXPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BZ_NO_STDIO
|
|
||||||
/* Need a definitition for FILE */
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
# include <windows.h>
|
|
||||||
# ifdef small
|
|
||||||
/* windows.h define small to char */
|
|
||||||
# undef small
|
|
||||||
# endif
|
|
||||||
# ifdef BZ_EXPORT
|
|
||||||
# define BZ_API(func) WINAPI func
|
|
||||||
# define BZ_EXTERN extern
|
|
||||||
# else
|
|
||||||
/* import windows dll dynamically */
|
|
||||||
# define BZ_API(func) (WINAPI * func)
|
|
||||||
# define BZ_EXTERN
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# define BZ_API(func) func
|
|
||||||
# define BZ_EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*-- Core (low-level) library functions --*/
|
/*-- Core (low-level) library functions --*/
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
|
int BZ2_bzCompressInit(bz_stream *, int, int, int);
|
||||||
bz_stream* strm,
|
int BZ2_bzCompress(bz_stream *, int);
|
||||||
int blockSize100k,
|
int BZ2_bzCompressEnd(bz_stream *);
|
||||||
int verbosity,
|
int BZ2_bzDecompressInit(bz_stream *, int, int);
|
||||||
int workFactor
|
int BZ2_bzDecompress(bz_stream *);
|
||||||
);
|
int BZ2_bzDecompressEnd(bz_stream *);
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzCompress) (
|
|
||||||
bz_stream* strm,
|
|
||||||
int action
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
|
|
||||||
bz_stream* strm
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
|
|
||||||
bz_stream *strm,
|
|
||||||
int verbosity,
|
|
||||||
int small
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
|
|
||||||
bz_stream* strm
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
|
|
||||||
bz_stream *strm
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-- High(er) level library functions --*/
|
/*-- High(er) level library functions --*/
|
||||||
|
|
||||||
#ifndef BZ_NO_STDIO
|
|
||||||
#define BZ_MAX_UNUSED 5000
|
|
||||||
|
|
||||||
typedef void BZFILE;
|
typedef void BZFILE;
|
||||||
|
|
||||||
BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
|
BZFILE *BZ2_bzReadOpen(int *, FILE *, int, int, void *, int);
|
||||||
int* bzerror,
|
void BZ2_bzReadClose(int *, BZFILE *);
|
||||||
FILE* f,
|
void BZ2_bzReadGetUnused(int *, BZFILE *, void **, int *);
|
||||||
int verbosity,
|
int BZ2_bzRead(int *, BZFILE *, void *, int);
|
||||||
int small,
|
BZFILE *BZ2_bzWriteOpen(int *, FILE *, int, int, int);
|
||||||
void* unused,
|
void BZ2_bzWrite(int *, BZFILE *, void *, int);
|
||||||
int nUnused
|
void BZ2_bzWriteClose(int *, BZFILE *, int, unsigned int *, unsigned int *);
|
||||||
);
|
void BZ2_bzWriteClose64(int *, BZFILE *, int, unsigned int *, unsigned int *,
|
||||||
|
unsigned int *, unsigned int *);
|
||||||
BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
|
int BZ2_bzBuffToBuffCompress(char *, unsigned int *, char *, unsigned int, int,
|
||||||
int* bzerror,
|
int, int);
|
||||||
BZFILE* b
|
int BZ2_bzBuffToBuffDecompress(char *, unsigned int *, char *, unsigned int,
|
||||||
);
|
int, int);
|
||||||
|
|
||||||
BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
|
|
||||||
int* bzerror,
|
|
||||||
BZFILE* b,
|
|
||||||
void** unused,
|
|
||||||
int* nUnused
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzRead) (
|
|
||||||
int* bzerror,
|
|
||||||
BZFILE* b,
|
|
||||||
void* buf,
|
|
||||||
int len
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
|
|
||||||
int* bzerror,
|
|
||||||
FILE* f,
|
|
||||||
int blockSize100k,
|
|
||||||
int verbosity,
|
|
||||||
int workFactor
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN void BZ_API(BZ2_bzWrite) (
|
|
||||||
int* bzerror,
|
|
||||||
BZFILE* b,
|
|
||||||
void* buf,
|
|
||||||
int len
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
|
|
||||||
int* bzerror,
|
|
||||||
BZFILE* b,
|
|
||||||
int abandon,
|
|
||||||
unsigned int* nbytes_in,
|
|
||||||
unsigned int* nbytes_out
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
|
|
||||||
int* bzerror,
|
|
||||||
BZFILE* b,
|
|
||||||
int abandon,
|
|
||||||
unsigned int* nbytes_in_lo32,
|
|
||||||
unsigned int* nbytes_in_hi32,
|
|
||||||
unsigned int* nbytes_out_lo32,
|
|
||||||
unsigned int* nbytes_out_hi32
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*-- Utility functions --*/
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
|
|
||||||
char* dest,
|
|
||||||
unsigned int* destLen,
|
|
||||||
char* source,
|
|
||||||
unsigned int sourceLen,
|
|
||||||
int blockSize100k,
|
|
||||||
int verbosity,
|
|
||||||
int workFactor
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
|
|
||||||
char* dest,
|
|
||||||
unsigned int* destLen,
|
|
||||||
char* source,
|
|
||||||
unsigned int sourceLen,
|
|
||||||
int small,
|
|
||||||
int verbosity
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/*--
|
/*--
|
||||||
Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
|
Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
|
||||||
|
@ -230,53 +77,15 @@ BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
|
||||||
If this code breaks, please contact both Yoshioka and me.
|
If this code breaks, please contact both Yoshioka and me.
|
||||||
--*/
|
--*/
|
||||||
|
|
||||||
BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
|
const char *BZ2_bzlibVersion(void);
|
||||||
void
|
BZFILE *BZ2_bzopen(const char *, const char *);
|
||||||
);
|
BZFILE *BZ2_bzdopen(int, const char *);
|
||||||
|
int BZ2_bzread(BZFILE *, void *, int);
|
||||||
|
int BZ2_bzwrite(BZFILE *, void *, int);
|
||||||
|
int BZ2_bzflush(BZFILE *);
|
||||||
|
void BZ2_bzclose(BZFILE *);
|
||||||
|
const char *BZ2_bzerror(BZFILE *, int *);
|
||||||
|
|
||||||
#ifndef BZ_NO_STDIO
|
COSMOPOLITAN_C_END_
|
||||||
BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||||
const char *path,
|
#endif /* _BZLIB_H */
|
||||||
const char *mode
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
|
|
||||||
int fd,
|
|
||||||
const char *mode
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzread) (
|
|
||||||
BZFILE* b,
|
|
||||||
void* buf,
|
|
||||||
int len
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzwrite) (
|
|
||||||
BZFILE* b,
|
|
||||||
void* buf,
|
|
||||||
int len
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN int BZ_API(BZ2_bzflush) (
|
|
||||||
BZFILE* b
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN void BZ_API(BZ2_bzclose) (
|
|
||||||
BZFILE* b
|
|
||||||
);
|
|
||||||
|
|
||||||
BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
|
|
||||||
BZFILE *b,
|
|
||||||
int *errnum
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/*--- end bzlib.h ---*/
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
#include "third_party/bzip2/bzlib.h"
|
||||||
|
|
||||||
|
#define BZ_NO_STDIO
|
||||||
|
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- Private header file for the library. ---*/
|
/*--- Private header file for the library. ---*/
|
||||||
|
@ -18,22 +23,6 @@
|
||||||
in the file LICENSE.
|
in the file LICENSE.
|
||||||
------------------------------------------------------------------ */
|
------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef _BZLIB_PRIVATE_H
|
|
||||||
#define _BZLIB_PRIVATE_H
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#ifndef BZ_NO_STDIO
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "bzlib.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-- General stuff. --*/
|
/*-- General stuff. --*/
|
||||||
|
|
||||||
#define BZ_VERSION "1.0.8, 13-Jul-2019"
|
#define BZ_VERSION "1.0.8, 13-Jul-2019"
|
||||||
|
@ -68,7 +57,7 @@ extern void BZ2_bz__AssertH__fail ( int errcode );
|
||||||
}}
|
}}
|
||||||
#else
|
#else
|
||||||
#define AssertD(cond,msg) /* */
|
#define AssertD(cond,msg) /* */
|
||||||
#endif
|
#endif /* BZ_DEBUG */
|
||||||
|
|
||||||
#define VPrintf0(zf) \
|
#define VPrintf0(zf) \
|
||||||
fprintf(stderr,zf)
|
fprintf(stderr,zf)
|
||||||
|
@ -83,7 +72,7 @@ extern void BZ2_bz__AssertH__fail ( int errcode );
|
||||||
#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 /* BZ_NO_STDIO */
|
||||||
|
|
||||||
extern void bz_internal_error ( int errcode );
|
extern void bz_internal_error ( int errcode );
|
||||||
#define AssertH(cond,errcode) \
|
#define AssertH(cond,errcode) \
|
||||||
|
@ -96,7 +85,7 @@ extern void bz_internal_error ( int errcode );
|
||||||
#define VPrintf4(zf,za1,za2,za3,za4) do { } while (0)
|
#define VPrintf4(zf,za1,za2,za3,za4) do { } while (0)
|
||||||
#define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0)
|
#define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0)
|
||||||
|
|
||||||
#endif
|
#endif /* BZ_NO_STDIO */
|
||||||
|
|
||||||
|
|
||||||
#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
|
#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
|
||||||
|
@ -490,20 +479,3 @@ BZ2_decompress ( DState* );
|
||||||
extern void
|
extern void
|
||||||
BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
|
BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
|
||||||
Int32, Int32, Int32 );
|
Int32, Int32, Int32 );
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/
|
|
||||||
|
|
||||||
#ifdef BZ_NO_STDIO
|
|
||||||
#ifndef NULL
|
|
||||||
#define NULL 0
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/*--- end bzlib_private.h ---*/
|
|
||||||
/*-------------------------------------------------------------*/
|
|
5
third_party/bzip2/compress.c
vendored
5
third_party/bzip2/compress.c
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- Compression machinery (not incl block sorting) ---*/
|
/*--- Compression machinery (not incl block sorting) ---*/
|
||||||
|
@ -26,7 +27,7 @@
|
||||||
so as to do a bit better on small files
|
so as to do a bit better on small files
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bzlib_private.h"
|
#include "third_party/bzip2/bzlib_private.inc"
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
|
@ -239,7 +240,7 @@ static
|
||||||
void sendMTFValues ( EState* s )
|
void sendMTFValues ( EState* s )
|
||||||
{
|
{
|
||||||
Int32 v, t, i, j, gs, ge, totc, bt, bc, iter;
|
Int32 v, t, i, j, gs, ge, totc, bt, bc, iter;
|
||||||
Int32 nSelectors, alphaSize, minLen, maxLen, selCtr;
|
Int32 nSelectors=0, alphaSize, minLen, maxLen, selCtr;
|
||||||
Int32 nGroups, nBytes;
|
Int32 nGroups, nBytes;
|
||||||
|
|
||||||
/*--
|
/*--
|
||||||
|
|
185
third_party/bzip2/crctable.c
vendored
185
third_party/bzip2/crctable.c
vendored
|
@ -1,104 +1,93 @@
|
||||||
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||||
|
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||||
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||||
|
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||||
|
│ │
|
||||||
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||||
|
│ any purpose with or without fee is hereby granted, provided that the │
|
||||||
|
│ above copyright notice and this permission notice appear in all copies. │
|
||||||
|
│ │
|
||||||
|
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||||
|
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||||
|
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||||
|
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||||
|
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||||
|
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||||
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||||
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
|
#ifdef TINY
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
uint32_t BZ2_crc32Table[256];
|
||||||
/*--- Table for doing CRCs ---*/
|
|
||||||
/*--- crctable.c ---*/
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
static textstartup void BZ2_crc32Table_init() {
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
unsigned i, j, u;
|
||||||
lossless, block-sorting data compression.
|
for (i = 0; i < 256; ++i) {
|
||||||
|
u = i << 24;
|
||||||
|
for (j = 8; j; --j) {
|
||||||
|
if ((int32_t)u < 0) {
|
||||||
|
u = (u << 1) ^ 0x04c11db7;
|
||||||
|
} else {
|
||||||
|
u <<= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BZ2_crc32Table[i] = u;
|
||||||
|
}
|
||||||
|
if (BZ2_crc32Table[0] || BZ2_crc32Table[255] != 0xb1f740b4) {
|
||||||
|
asm("hlt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.8 of 13 July 2019
|
const void *const BZ2_crc32Table_ctor[] initarray = {
|
||||||
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
|
BZ2_crc32Table_init,
|
||||||
|
|
||||||
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 "bzlib_private.h"
|
|
||||||
|
|
||||||
/*--
|
|
||||||
I think this is an implementation of the AUTODIN-II,
|
|
||||||
Ethernet & FDDI 32-bit CRC standard. Vaguely derived
|
|
||||||
from code by Rob Warnock, in Section 51 of the
|
|
||||||
comp.compression FAQ.
|
|
||||||
--*/
|
|
||||||
|
|
||||||
UInt32 BZ2_crc32Table[256] = {
|
|
||||||
|
|
||||||
/*-- Ugly, innit? --*/
|
|
||||||
|
|
||||||
0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L,
|
|
||||||
0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L,
|
|
||||||
0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L,
|
|
||||||
0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL,
|
|
||||||
0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L,
|
|
||||||
0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L,
|
|
||||||
0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L,
|
|
||||||
0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL,
|
|
||||||
0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L,
|
|
||||||
0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L,
|
|
||||||
0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L,
|
|
||||||
0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL,
|
|
||||||
0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L,
|
|
||||||
0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L,
|
|
||||||
0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L,
|
|
||||||
0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL,
|
|
||||||
0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL,
|
|
||||||
0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L,
|
|
||||||
0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L,
|
|
||||||
0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL,
|
|
||||||
0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL,
|
|
||||||
0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L,
|
|
||||||
0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L,
|
|
||||||
0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL,
|
|
||||||
0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL,
|
|
||||||
0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L,
|
|
||||||
0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L,
|
|
||||||
0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL,
|
|
||||||
0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL,
|
|
||||||
0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L,
|
|
||||||
0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L,
|
|
||||||
0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL,
|
|
||||||
0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L,
|
|
||||||
0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL,
|
|
||||||
0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL,
|
|
||||||
0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L,
|
|
||||||
0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L,
|
|
||||||
0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL,
|
|
||||||
0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL,
|
|
||||||
0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L,
|
|
||||||
0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L,
|
|
||||||
0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL,
|
|
||||||
0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL,
|
|
||||||
0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L,
|
|
||||||
0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L,
|
|
||||||
0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL,
|
|
||||||
0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL,
|
|
||||||
0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L,
|
|
||||||
0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L,
|
|
||||||
0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL,
|
|
||||||
0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L,
|
|
||||||
0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L,
|
|
||||||
0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L,
|
|
||||||
0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL,
|
|
||||||
0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L,
|
|
||||||
0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L,
|
|
||||||
0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L,
|
|
||||||
0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL,
|
|
||||||
0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L,
|
|
||||||
0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L,
|
|
||||||
0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L,
|
|
||||||
0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL,
|
|
||||||
0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L,
|
|
||||||
0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
const uint32_t BZ2_crc32Table[256] = {
|
||||||
/*--- end crctable.c ---*/
|
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
|
||||||
/*-------------------------------------------------------------*/
|
0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
|
||||||
|
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7,
|
||||||
|
0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
|
||||||
|
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3,
|
||||||
|
0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
|
||||||
|
0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef,
|
||||||
|
0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
|
||||||
|
0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb,
|
||||||
|
0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1,
|
||||||
|
0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,
|
||||||
|
0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
|
||||||
|
0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4,
|
||||||
|
0x0808d07d, 0x0cc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde,
|
||||||
|
0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08,
|
||||||
|
0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
|
||||||
|
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc,
|
||||||
|
0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6,
|
||||||
|
0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050,
|
||||||
|
0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
|
||||||
|
0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
|
||||||
|
0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637,
|
||||||
|
0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1,
|
||||||
|
0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
|
||||||
|
0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5,
|
||||||
|
0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
|
||||||
|
0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9,
|
||||||
|
0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
|
||||||
|
0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd,
|
||||||
|
0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
|
||||||
|
0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,
|
||||||
|
0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
|
||||||
|
0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2,
|
||||||
|
0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8,
|
||||||
|
0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e,
|
||||||
|
0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
|
||||||
|
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a,
|
||||||
|
0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0,
|
||||||
|
0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676,
|
||||||
|
0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
|
||||||
|
0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,
|
||||||
|
0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
|
||||||
|
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4,
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
3
third_party/bzip2/decompress.c
vendored
3
third_party/bzip2/decompress.c
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- Decompression machinery ---*/
|
/*--- Decompression machinery ---*/
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
------------------------------------------------------------------ */
|
------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
#include "bzlib_private.h"
|
#include "third_party/bzip2/bzlib_private.inc"
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
|
|
175
third_party/bzip2/dlltest.c
vendored
175
third_party/bzip2/dlltest.c
vendored
|
@ -1,175 +0,0 @@
|
||||||
/*
|
|
||||||
minibz2
|
|
||||||
libbz2.dll test program.
|
|
||||||
by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
|
|
||||||
This file is Public Domain. Welcome any email to me.
|
|
||||||
|
|
||||||
usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define BZ_IMPORT
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "bzlib.h"
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
#define BZ2_LIBNAME "libbz2-1.0.2.DLL"
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
static int BZ2DLLLoaded = 0;
|
|
||||||
static HINSTANCE BZ2DLLhLib;
|
|
||||||
int BZ2DLLLoadLibrary(void)
|
|
||||||
{
|
|
||||||
HINSTANCE hLib;
|
|
||||||
|
|
||||||
if(BZ2DLLLoaded==1){return 0;}
|
|
||||||
hLib=LoadLibrary(BZ2_LIBNAME);
|
|
||||||
if(hLib == NULL){
|
|
||||||
fprintf(stderr,"Can't load %s\n",BZ2_LIBNAME);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
BZ2_bzlibVersion=GetProcAddress(hLib,"BZ2_bzlibVersion");
|
|
||||||
BZ2_bzopen=GetProcAddress(hLib,"BZ2_bzopen");
|
|
||||||
BZ2_bzdopen=GetProcAddress(hLib,"BZ2_bzdopen");
|
|
||||||
BZ2_bzread=GetProcAddress(hLib,"BZ2_bzread");
|
|
||||||
BZ2_bzwrite=GetProcAddress(hLib,"BZ2_bzwrite");
|
|
||||||
BZ2_bzflush=GetProcAddress(hLib,"BZ2_bzflush");
|
|
||||||
BZ2_bzclose=GetProcAddress(hLib,"BZ2_bzclose");
|
|
||||||
BZ2_bzerror=GetProcAddress(hLib,"BZ2_bzerror");
|
|
||||||
|
|
||||||
if (!BZ2_bzlibVersion || !BZ2_bzopen || !BZ2_bzdopen
|
|
||||||
|| !BZ2_bzread || !BZ2_bzwrite || !BZ2_bzflush
|
|
||||||
|| !BZ2_bzclose || !BZ2_bzerror) {
|
|
||||||
fprintf(stderr,"GetProcAddress failed.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
BZ2DLLLoaded=1;
|
|
||||||
BZ2DLLhLib=hLib;
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
int BZ2DLLFreeLibrary(void)
|
|
||||||
{
|
|
||||||
if(BZ2DLLLoaded==0){return 0;}
|
|
||||||
FreeLibrary(BZ2DLLhLib);
|
|
||||||
BZ2DLLLoaded=0;
|
|
||||||
}
|
|
||||||
#endif /* WIN32 */
|
|
||||||
|
|
||||||
void usage(void)
|
|
||||||
{
|
|
||||||
puts("usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
|
||||||
{
|
|
||||||
int decompress = 0;
|
|
||||||
int level = 9;
|
|
||||||
char *fn_r = NULL;
|
|
||||||
char *fn_w = NULL;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
if(BZ2DLLLoadLibrary()<0){
|
|
||||||
fprintf(stderr,"Loading of %s failed. Giving up.\n", BZ2_LIBNAME);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
printf("Loading of %s succeeded. Library version is %s.\n",
|
|
||||||
BZ2_LIBNAME, BZ2_bzlibVersion() );
|
|
||||||
#endif
|
|
||||||
while(++argv,--argc){
|
|
||||||
if(**argv =='-' || **argv=='/'){
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
for(p=*argv+1;*p;p++){
|
|
||||||
if(*p=='d'){
|
|
||||||
decompress = 1;
|
|
||||||
}else if('1'<=*p && *p<='9'){
|
|
||||||
level = *p - '0';
|
|
||||||
}else{
|
|
||||||
usage();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(argc>=1){
|
|
||||||
fn_r = *argv;
|
|
||||||
argc--;argv++;
|
|
||||||
}else{
|
|
||||||
fn_r = NULL;
|
|
||||||
}
|
|
||||||
if(argc>=1){
|
|
||||||
fn_w = *argv;
|
|
||||||
argc--;argv++;
|
|
||||||
}else{
|
|
||||||
fn_w = NULL;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
int len;
|
|
||||||
char buff[0x1000];
|
|
||||||
char mode[10];
|
|
||||||
|
|
||||||
if(decompress){
|
|
||||||
BZFILE *BZ2fp_r = NULL;
|
|
||||||
FILE *fp_w = NULL;
|
|
||||||
|
|
||||||
if(fn_w){
|
|
||||||
if((fp_w = fopen(fn_w,"wb"))==NULL){
|
|
||||||
printf("can't open [%s]\n",fn_w);
|
|
||||||
perror("reason:");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
fp_w = stdout;
|
|
||||||
}
|
|
||||||
if((fn_r == NULL && (BZ2fp_r = BZ2_bzdopen(fileno(stdin),"rb"))==NULL)
|
|
||||||
|| (fn_r != NULL && (BZ2fp_r = BZ2_bzopen(fn_r,"rb"))==NULL)){
|
|
||||||
printf("can't bz2openstream\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
while((len=BZ2_bzread(BZ2fp_r,buff,0x1000))>0){
|
|
||||||
fwrite(buff,1,len,fp_w);
|
|
||||||
}
|
|
||||||
BZ2_bzclose(BZ2fp_r);
|
|
||||||
if(fp_w != stdout) fclose(fp_w);
|
|
||||||
}else{
|
|
||||||
BZFILE *BZ2fp_w = NULL;
|
|
||||||
FILE *fp_r = NULL;
|
|
||||||
|
|
||||||
if(fn_r){
|
|
||||||
if((fp_r = fopen(fn_r,"rb"))==NULL){
|
|
||||||
printf("can't open [%s]\n",fn_r);
|
|
||||||
perror("reason:");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
fp_r = stdin;
|
|
||||||
}
|
|
||||||
mode[0]='w';
|
|
||||||
mode[1] = '0' + level;
|
|
||||||
mode[2] = '\0';
|
|
||||||
|
|
||||||
if((fn_w == NULL && (BZ2fp_w = BZ2_bzdopen(fileno(stdout),mode))==NULL)
|
|
||||||
|| (fn_w !=NULL && (BZ2fp_w = BZ2_bzopen(fn_w,mode))==NULL)){
|
|
||||||
printf("can't bz2openstream\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
while((len=fread(buff,1,0x1000,fp_r))>0){
|
|
||||||
BZ2_bzwrite(BZ2fp_w,buff,len);
|
|
||||||
}
|
|
||||||
BZ2_bzclose(BZ2fp_w);
|
|
||||||
if(fp_r!=stdin)fclose(fp_r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef _WIN32
|
|
||||||
BZ2DLLFreeLibrary();
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
11
third_party/bzip2/huffman.c
vendored
11
third_party/bzip2/huffman.c
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- Huffman coding low-level stuff ---*/
|
/*--- Huffman coding low-level stuff ---*/
|
||||||
|
@ -19,7 +20,9 @@
|
||||||
------------------------------------------------------------------ */
|
------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
#include "bzlib_private.h"
|
#include "libc/runtime/gc.internal.h"
|
||||||
|
#include "libc/mem/mem.h"
|
||||||
|
#include "third_party/bzip2/bzlib_private.inc"
|
||||||
|
|
||||||
/*---------------------------------------------------*/
|
/*---------------------------------------------------*/
|
||||||
#define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
|
#define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
|
||||||
|
@ -72,9 +75,9 @@ void BZ2_hbMakeCodeLengths ( UChar *len,
|
||||||
Int32 nNodes, nHeap, n1, n2, i, j, k;
|
Int32 nNodes, nHeap, n1, n2, i, j, k;
|
||||||
Bool tooLong;
|
Bool tooLong;
|
||||||
|
|
||||||
Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ];
|
Int32 *heap = gc(calloc(BZ_MAX_ALPHA_SIZE + 2, 4));
|
||||||
Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
|
Int32 *weight = gc(calloc(BZ_MAX_ALPHA_SIZE * 2, 4));
|
||||||
Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ];
|
Int32 *parent = gc(calloc(BZ_MAX_ALPHA_SIZE * 2, 4));
|
||||||
|
|
||||||
for (i = 0; i < alphaSize; i++)
|
for (i = 0; i < alphaSize; i++)
|
||||||
weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
|
weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
|
||||||
|
|
27
third_party/bzip2/libbz2.def
vendored
27
third_party/bzip2/libbz2.def
vendored
|
@ -1,27 +0,0 @@
|
||||||
LIBRARY LIBBZ2
|
|
||||||
DESCRIPTION "libbzip2: library for data compression"
|
|
||||||
EXPORTS
|
|
||||||
BZ2_bzCompressInit
|
|
||||||
BZ2_bzCompress
|
|
||||||
BZ2_bzCompressEnd
|
|
||||||
BZ2_bzDecompressInit
|
|
||||||
BZ2_bzDecompress
|
|
||||||
BZ2_bzDecompressEnd
|
|
||||||
BZ2_bzReadOpen
|
|
||||||
BZ2_bzReadClose
|
|
||||||
BZ2_bzReadGetUnused
|
|
||||||
BZ2_bzRead
|
|
||||||
BZ2_bzWriteOpen
|
|
||||||
BZ2_bzWrite
|
|
||||||
BZ2_bzWriteClose
|
|
||||||
BZ2_bzWriteClose64
|
|
||||||
BZ2_bzBuffToBuffCompress
|
|
||||||
BZ2_bzBuffToBuffDecompress
|
|
||||||
BZ2_bzlibVersion
|
|
||||||
BZ2_bzopen
|
|
||||||
BZ2_bzdopen
|
|
||||||
BZ2_bzread
|
|
||||||
BZ2_bzwrite
|
|
||||||
BZ2_bzflush
|
|
||||||
BZ2_bzclose
|
|
||||||
BZ2_bzerror
|
|
2964
third_party/bzip2/manual.xml
vendored
2964
third_party/bzip2/manual.xml
vendored
File diff suppressed because it is too large
Load diff
31
third_party/bzip2/mk251.c
vendored
31
third_party/bzip2/mk251.c
vendored
|
@ -1,31 +0,0 @@
|
||||||
|
|
||||||
/* Spew out a long sequence of the byte 251. When fed to bzip2
|
|
||||||
versions 1.0.0 or 1.0.1, causes it to die with internal error
|
|
||||||
1007 in blocksort.c. This assertion misses an extremely rare
|
|
||||||
case, which is fixed in this version (1.0.2) and above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
|
||||||
lossless, block-sorting data compression.
|
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.8 of 13 July 2019
|
|
||||||
Copyright (C) 1996-2019 Julian Seward <jseward@acm.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>
|
|
||||||
|
|
||||||
int main ()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < 48500000 ; i++)
|
|
||||||
putchar(251);
|
|
||||||
return 0;
|
|
||||||
}
|
|
3
third_party/bzip2/randtable.c
vendored
3
third_party/bzip2/randtable.c
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/*--- Table for randomising repetitive blocks ---*/
|
/*--- Table for randomising repetitive blocks ---*/
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
------------------------------------------------------------------ */
|
------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
#include "bzlib_private.h"
|
#include "third_party/bzip2/bzlib_private.inc"
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------*/
|
/*---------------------------------------------*/
|
||||||
|
|
6
third_party/bzip2/spewG.c
vendored
6
third_party/bzip2/spewG.c
vendored
|
@ -1,3 +1,6 @@
|
||||||
|
#include "libc/rand/rand.h"
|
||||||
|
#include "libc/stdio/stdio.h"
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
/* spew out a thoroughly gigantic file designed so that bzip2
|
/* spew out a thoroughly gigantic file designed so that bzip2
|
||||||
can compress it reasonably rapidly. This is to help test
|
can compress it reasonably rapidly. This is to help test
|
||||||
|
@ -26,9 +29,6 @@
|
||||||
|
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
/* The number of megabytes of junk to spew out (roughly) */
|
/* The number of megabytes of junk to spew out (roughly) */
|
||||||
#define MEGABYTES 5000
|
#define MEGABYTES 5000
|
||||||
|
|
||||||
|
|
141
third_party/bzip2/unzcrash.c
vendored
141
third_party/bzip2/unzcrash.c
vendored
|
@ -1,141 +0,0 @@
|
||||||
|
|
||||||
/* A test program written to test robustness to decompression of
|
|
||||||
corrupted data. Usage is
|
|
||||||
unzcrash filename
|
|
||||||
and the program will read the specified file, compress it (in memory),
|
|
||||||
and then repeatedly decompress it, each time with a different bit of
|
|
||||||
the compressed data inverted, so as to test all possible one-bit errors.
|
|
||||||
This should not cause any invalid memory accesses. If it does,
|
|
||||||
I want to know about it!
|
|
||||||
|
|
||||||
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
|
|
||||||
many hours.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
|
||||||
lossless, block-sorting data compression.
|
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.8 of 13 July 2019
|
|
||||||
Copyright (C) 1996-2019 Julian Seward <jseward@acm.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 <assert.h>
|
|
||||||
#include "bzlib.h"
|
|
||||||
|
|
||||||
#define M_BLOCK 1000000
|
|
||||||
|
|
||||||
typedef unsigned char uchar;
|
|
||||||
|
|
||||||
#define M_BLOCK_OUT (M_BLOCK + 1000000)
|
|
||||||
uchar inbuf[M_BLOCK];
|
|
||||||
uchar outbuf[M_BLOCK_OUT];
|
|
||||||
uchar zbuf[M_BLOCK + 600 + (M_BLOCK / 100)];
|
|
||||||
|
|
||||||
int nIn, nOut, nZ;
|
|
||||||
|
|
||||||
static char *bzerrorstrings[] = {
|
|
||||||
"OK"
|
|
||||||
,"SEQUENCE_ERROR"
|
|
||||||
,"PARAM_ERROR"
|
|
||||||
,"MEM_ERROR"
|
|
||||||
,"DATA_ERROR"
|
|
||||||
,"DATA_ERROR_MAGIC"
|
|
||||||
,"IO_ERROR"
|
|
||||||
,"UNEXPECTED_EOF"
|
|
||||||
,"OUTBUFF_FULL"
|
|
||||||
,"???" /* for future */
|
|
||||||
,"???" /* for future */
|
|
||||||
,"???" /* for future */
|
|
||||||
,"???" /* for future */
|
|
||||||
,"???" /* for future */
|
|
||||||
,"???" /* for future */
|
|
||||||
};
|
|
||||||
|
|
||||||
void flip_bit ( int bit )
|
|
||||||
{
|
|
||||||
int byteno = bit / 8;
|
|
||||||
int bitno = bit % 8;
|
|
||||||
uchar mask = 1 << bitno;
|
|
||||||
//fprintf ( stderr, "(byte %d bit %d mask %d)",
|
|
||||||
// byteno, bitno, (int)mask );
|
|
||||||
zbuf[byteno] ^= mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main ( int argc, char** argv )
|
|
||||||
{
|
|
||||||
FILE* f;
|
|
||||||
int r;
|
|
||||||
int bit;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (argc != 2) {
|
|
||||||
fprintf ( stderr, "usage: unzcrash filename\n" );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
f = fopen ( argv[1], "r" );
|
|
||||||
if (!f) {
|
|
||||||
fprintf ( stderr, "unzcrash: can't open %s\n", argv[1] );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
nIn = fread ( inbuf, 1, M_BLOCK, f );
|
|
||||||
fprintf ( stderr, "%d bytes read\n", nIn );
|
|
||||||
|
|
||||||
nZ = M_BLOCK;
|
|
||||||
r = BZ2_bzBuffToBuffCompress (
|
|
||||||
zbuf, &nZ, inbuf, nIn, 9, 0, 30 );
|
|
||||||
|
|
||||||
assert (r == BZ_OK);
|
|
||||||
fprintf ( stderr, "%d after compression\n", nZ );
|
|
||||||
|
|
||||||
for (bit = 0; bit < nZ*8; bit++) {
|
|
||||||
fprintf ( stderr, "bit %d ", bit );
|
|
||||||
flip_bit ( bit );
|
|
||||||
nOut = M_BLOCK_OUT;
|
|
||||||
r = BZ2_bzBuffToBuffDecompress (
|
|
||||||
outbuf, &nOut, zbuf, nZ, 0, 0 );
|
|
||||||
fprintf ( stderr, " %d %s ", r, bzerrorstrings[-r] );
|
|
||||||
|
|
||||||
if (r != BZ_OK) {
|
|
||||||
fprintf ( stderr, "\n" );
|
|
||||||
} else {
|
|
||||||
if (nOut != nIn) {
|
|
||||||
fprintf(stderr, "nIn/nOut mismatch %d %d\n", nIn, nOut );
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < nOut; i++)
|
|
||||||
if (inbuf[i] != outbuf[i]) {
|
|
||||||
fprintf(stderr, "mismatch at %d\n", i );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (i == nOut) fprintf(stderr, "really ok!\n" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flip_bit ( bit );
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
assert (nOut == nIn);
|
|
||||||
for (i = 0; i < nOut; i++) {
|
|
||||||
if (inbuf[i] != outbuf[i]) {
|
|
||||||
fprintf ( stderr, "difference at %d !\n", i );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf ( stderr, "all ok\n" );
|
|
||||||
return 0;
|
|
||||||
}
|
|
114
third_party/bzip2/xmlproc.sh
vendored
114
third_party/bzip2/xmlproc.sh
vendored
|
@ -1,114 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# see the README file for usage etc.
|
|
||||||
#
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
# This file is part of bzip2/libbzip2, a program and library for
|
|
||||||
# lossless, block-sorting data compression.
|
|
||||||
#
|
|
||||||
# bzip2/libbzip2 version 1.0.8 of 13 July 2019
|
|
||||||
# Copyright (C) 1996-2019 Julian Seward <jseward@acm.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.
|
|
||||||
# ----------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo '';
|
|
||||||
echo 'Usage: xmlproc.sh -[option] <filename.xml>';
|
|
||||||
echo 'Specify a target from:';
|
|
||||||
echo '-v verify xml file conforms to dtd';
|
|
||||||
echo '-html output in html format (single file)';
|
|
||||||
echo '-ps output in postscript format';
|
|
||||||
echo '-pdf output in pdf format';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if test $# -ne 2; then
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
# assign the variable for the output type
|
|
||||||
action=$1; shift
|
|
||||||
# assign the output filename
|
|
||||||
xmlfile=$1; shift
|
|
||||||
# and check user input it correct
|
|
||||||
if !(test -f $xmlfile); then
|
|
||||||
echo "No such file: $xmlfile";
|
|
||||||
exit;
|
|
||||||
fi
|
|
||||||
# some other stuff we will use
|
|
||||||
OUT=output
|
|
||||||
xsl_fo=bz-fo.xsl
|
|
||||||
xsl_html=bz-html.xsl
|
|
||||||
|
|
||||||
basename=$xmlfile
|
|
||||||
basename=${basename//'.xml'/''}
|
|
||||||
|
|
||||||
fofile="${basename}.fo"
|
|
||||||
htmlfile="${basename}.html"
|
|
||||||
pdffile="${basename}.pdf"
|
|
||||||
psfile="${basename}.ps"
|
|
||||||
xmlfmtfile="${basename}.fmt"
|
|
||||||
|
|
||||||
# first process the xmlfile with CDATA tags
|
|
||||||
./format.pl $xmlfile $xmlfmtfile
|
|
||||||
# so the shell knows where the catalogs live
|
|
||||||
export XML_CATALOG_FILES=/etc/xml/catalog
|
|
||||||
|
|
||||||
# post-processing tidy up
|
|
||||||
cleanup() {
|
|
||||||
echo "Cleaning up: $@"
|
|
||||||
while [ $# != 0 ]
|
|
||||||
do
|
|
||||||
arg=$1; shift;
|
|
||||||
echo " deleting $arg";
|
|
||||||
rm $arg
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
case $action in
|
|
||||||
-v)
|
|
||||||
flags='--noout --xinclude --noblanks --postvalid'
|
|
||||||
dtd='--dtdvalid http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd'
|
|
||||||
xmllint $flags $dtd $xmlfmtfile 2> $OUT
|
|
||||||
egrep 'error' $OUT
|
|
||||||
rm $OUT
|
|
||||||
;;
|
|
||||||
|
|
||||||
-html)
|
|
||||||
echo "Creating $htmlfile ..."
|
|
||||||
xsltproc --nonet --xinclude -o $htmlfile $xsl_html $xmlfmtfile
|
|
||||||
cleanup $xmlfmtfile
|
|
||||||
;;
|
|
||||||
|
|
||||||
-pdf)
|
|
||||||
echo "Creating $pdffile ..."
|
|
||||||
xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile
|
|
||||||
pdfxmltex $fofile >$OUT </dev/null
|
|
||||||
pdfxmltex $fofile >$OUT </dev/null
|
|
||||||
pdfxmltex $fofile >$OUT </dev/null
|
|
||||||
cleanup $OUT $xmlfmtfile *.aux *.fo *.log *.out
|
|
||||||
;;
|
|
||||||
|
|
||||||
-ps)
|
|
||||||
echo "Creating $psfile ..."
|
|
||||||
xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile
|
|
||||||
pdfxmltex $fofile >$OUT </dev/null
|
|
||||||
pdfxmltex $fofile >$OUT </dev/null
|
|
||||||
pdfxmltex $fofile >$OUT </dev/null
|
|
||||||
pdftops $pdffile $psfile
|
|
||||||
cleanup $OUT $xmlfmtfile $pdffile *.aux *.fo *.log *.out
|
|
||||||
# passivetex is broken, so we can't go this route yet.
|
|
||||||
# xmltex $fofile >$OUT </dev/null
|
|
||||||
# xmltex $fofile >$OUT </dev/null
|
|
||||||
# xmltex $fofile >$OUT </dev/null
|
|
||||||
# dvips -R -q -o bzip-manual.ps *.dvi
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
esac
|
|
1
third_party/third_party.mk
vendored
1
third_party/third_party.mk
vendored
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
.PHONY: o/$(MODE)/third_party
|
.PHONY: o/$(MODE)/third_party
|
||||||
o/$(MODE)/third_party: \
|
o/$(MODE)/third_party: \
|
||||||
|
o/$(MODE)/third_party/bzip2 \
|
||||||
o/$(MODE)/third_party/chibicc \
|
o/$(MODE)/third_party/chibicc \
|
||||||
o/$(MODE)/third_party/compiler_rt \
|
o/$(MODE)/third_party/compiler_rt \
|
||||||
o/$(MODE)/third_party/dlmalloc \
|
o/$(MODE)/third_party/dlmalloc \
|
||||||
|
|
3
third_party/zlib/README.cosmo
vendored
3
third_party/zlib/README.cosmo
vendored
|
@ -1,3 +0,0 @@
|
||||||
Sourced from Chromium due to overextended influence by maintainers whose
|
|
||||||
important contributions in this field should be recognized by clarifying
|
|
||||||
claims of ownership for posterity. See also libc/str/undeflate.c
|
|
Loading…
Reference in a new issue