bzip2 and libbzip2

What is bzip2?

bzip2 is a freely available, patent free (see below),
high-quality data compressor. It typically compresses files to
within 10% to 15% of the best available techniques (the PPM
family of statistical compressors), whilst being around twice as
fast at compression and six times faster at decompression.

The current version is 1.0.6, released 20 Sept 2010.

Version 1.0.6 removes a potential security vulnerability,
CVE-2010-0405, so all users are recommended to upgrade
immediately.

Why would I want to use it?

Because it compresses well. So it packs more stuff into
your overfull disk drives, distribution CDs,
backup tapes, USB sticks, etc. And/or it reduces your
customer download times, long distance network
traffic, etc.
It's not the world's fastest compressor, but it's still fast
enough to be very useful.

Because it's open-source (BSD-style license), and, as far
as I know, patent-free. (To the best of my knowledge. I can't
afford to do a full patent search, so I can't guarantee
this. Caveat emptor). So you can use it for whatever you
like. Naturally, the source code is part of the
distribution.

Because it supports (limited) recovery from media
errors. If you are trying to restore compressed data from a
backup tape or disk, and that data contains some errors, bzip2
may still be able to decompress those parts of the file which
are undamaged.

Because you already know how to use it. bzip2's command
line flags are similar to those of GNU Gzip, so if you know how
to use gzip, you know how to use bzip2.

Because it's very portable. It should run on any 32 or
64-bit machine with an ANSI C compiler. The distribution should
compile unmodified on Unix and Win32 systems. Earlier versions
have been ported with little difficulty to a large number of
weird and wonderful systems.

The code is organised as a library with a programming
interface. The bzip2 program itself is a client of the library.
You can use the library in your own programs, to directly read
and write .bz2 files, or even just to compress data in memory
using the bzip2 algorithms.