Added test-xz as one of the things to build by default.
Realisation: I'm already passing the private structure which contains
the buffer pointer to the read function.  Therefore, it doesn't need
all these extra arguments - it only uses the parameters in that buffer
structure anyway.
Most of the way there with writing a reader-driven decompressor.

The objective is to let an external caller ask for a string similar to
fgets - fill either len characters or to the next newline, whichever is
less.  This then pulls data from an internal buffer, which in turn
(when empty) draws data from the actual file.

This is convoluted, I know, but it's the way the cfile library is
intended to work.  We don't simply give the user a chunk of data and
say "you sort it out", letting them drive when they need more file
to be decompressed - we provide a regular stdio-like interface.  That
means the caller doesn't need to know about this buffering and
decompression, it happens transparently underneath them.
For reading xz files, we need to have a separate buffer which stores data
from the file that's being fed through the decoder.  We now implement
feof and xz_read_into_buffer correctly (not tested yet).
Hmmm - two read_into_buffer definitions.  Let's just have one.

Also implement correct read / decode logic: if we need to read more
data from the file, read it and set the next_in and avail_in values.
Otherwise leave them - the decoder will keep absorbing data from that
buffer by itself.
Using tabs in libfiles declaration rather than spaces (for what it's worth);
adding CFLAGS usage to test-cat and test-xz compile arguments.  I still
don't understand why test-cat automatically gets a test-cat.o compiled for it
and a matching declaration of test-xz doesn't, so I'm using a complete
compile/link with no -g flag for test-xz.
Added cfile_xz to the list of library compile targets.  Here we go...
Well, it compiles...

Implemented:
 * xz_read_into_buffer
 * xz_open
 * xz_eof
 * xz_gets
 * xz_vprintf
 * xz_read (I think)
 * xz_write (I think)
 * xz_flush
 * xz_close

To be implemented:
 * xz_size

Much more testing required.  See test-xz.c for some of the logic, but I'm
still getting the hang of it.
Working decode routines.  It helps to pass in an output buffer that isn't
already used as our decode buffer.
When we hit end of file, terminate the string if possible and return
zero length then and there, since (for this routine) that's the signal
of a finished file.  Ergo, return the correct length with newline, and
detect the end of file in the main loop before printing the line to
the output.
Added XZ compression detection and open call to code.  Added -llzma
to Makefile to make compiling test-cat work.

Test run shows correct decompression of one block of file, but no
further reading.  More debugging required.
Fix xz decode - we start with nothing in the input buffer, and we
check the input buffer size is zero to know when to read more of the
file into it.
Tidier debugging explanation.
Rewrote write_one_line loop to resemble what we do in
cfile_xz's xz_write: break if there's still space available after
encoding, otherwise write output buffer to file and loop back to
encode again.

This code works, so progress continues on fixing the bug in cfile_xz.c
- probably either not writing the right buffer out to disk.  The output
is the same size but garbage, most likely unused bits of heap.
Fixed xz_write - write from start of buffer, not end.  For fwrite
semantics, return number of items written, not total size.

Fixed xz_close if writing: we have to send LZMA_FINISH and write chunks
of buffer until the final stream end.

test-cat now reads and writes correct xz files!
Added simple tests for xz encoding and decoding.
Slight improvement to bzip_calculate_size: use an off_t to store the
file length (as that's what we're returning), and use the cfile
structure's filename rather than the inherited filename (saves casting
to a cfile_bzip2 structure).
Added simple 'get_raw_size' program to test getting the uncompressed
size of various compressed file types via cfile.
Implemented xz_size in the less nice way: use 'xz -lv' to get the uncompressed
size and parse the string output.  The alternative is to try and implement the
fairly ugly and rather convoluted parse_indexes in xz/src/xz/list.c - and it
relies too much on a lot of its own routines and types to be easily copied
straight in.  If only it was actually implemented as a library routine.  Maybe
at some point I'll try implementing a cut down version, but for now this is
easier.
xz_size now tests for eof before 'Uncompressed size' line, since test after
won't be reached, and it exits the loop when it finds the uncompressed size
line.