What is bdiff for ?
Bdiff is a small utility to create a file (D) that contains the differences
between a file (A) and another (B). Then you can patch (A) with (D) to get
(B). It's what diff(1) and patch(1) utilities do with text files. I wrote
it because I couldn't find nothing that does the same with binary files.

Known issues:
No known bugs. It seems to work fine. I tested it only on my linux/powerpc
machine. Please report any bugs you find.

How to build:
Type "make" and pray.
To build on non-POSIX.4 compliant systems: make nommap
To build PowerPC optimized version (a bit faster): make ppc

******
If you have problems compiling the md5 routine, maybe your system doesn't
like the _LIBC define. That define is necessary only on bigendian machines
(eg. PowerPC). If you have a little-endian box (eg. i386), you can safely
remove the "-D_LIBC" from the line:

	cc -O2 -D_LIBC -c lib/md5.c -o lib/md5.o

in the Makefile. Do NOT remove it on bigendian processors, otherwise it
will calculate wrong md5 checksums !


Credits:
Bdiff uses md5 routines by Ulrich Drepper.
file(1) magic entry by kromJx@crosswinds.net

Contact:
Giuliano Pochini <pochini@shiny.it>



Command line options:

BDiff v1.0.2
Usage: bdiff <options> [outfile]

** Options:
-d oldfile newfile
 Creates a diff file between given files.

-p oldfile difffile
 Patches oldfile with difffile

-q
 Be quiet: Do not display progress bar and warning/info messages. Fatal
 error messages are not suppressed.

-h or --help
 Displays help message

The following options have a meaning only if -d option
has been specified and they must preceed -d itself:

-maxb <bytes>
 Sets maximum size of the blocks that will be searched in the oldfile
 and stored in the difffile. Bdiff will allocate maxb bytes when patching.
 Default is 1048576 = 1MiB.

-maxs <bytes>
 This is the "window" lenght there the data is searched in. Default is
 3*maxb and it should be at least 2*maxb

-adv <bytes>
 Skips adv bytes when it cannot find a matching block (default 1)

-nooldmd5
 Don't create md5 checksum for oldfile

-nonewmd5
 Don't create md5 checksum for newfile

If outfile is not specified, the output file will be "difffile" or "newfile"
if -d or -p option was used respectively.

To explain what other parameters are I have to describe how bdiff works.
Suppose old and new file have the same size and we are at pos-th byte.
(*) Bdiff searches for the largest block (up to -maxb bytes long) of the new
file in the old file in the area centered over pos and -maxs bytes large. If
it doesn't find a matching block it starts looking for the next matching block.
If it doesn't find it again, it skips -adv bytes and it tries again... Until it
finds it. Then it stores the block it couldn't find and loops back to (*) until
the whole newfile has been processed.
The longer -maxs is, the higher the probability to find a matching block,
because bdiff looks for it in a larger area, but it's also slower. Each
packet stored in the difffile is at least 5 bytes long, so the larger -maxb
is, the fewer packets are stored (depending on input files), the smaller
difffile is. Larger -maxb causes slower searching.



Version history:
0.9     Initial release
0.92    Replaced block searching routine with a binary search. I don't know
        if it's faster, but it provides better results (ie. smaller
        difffile and no more lots of contiguous unmerged blocks).
0.94    Added a complete set of command line paramenters.
        Fixed a bug that could make bdiff to loop forever (sorry).
        Other minor changes.
0.95    Just some small changes. Added file(1) magic entry.
1.0rc   Minor changes and bugfixes. Useless progress bar was added.
1.0     (2002/11/08) I made just a few minor changes. Mostly docs updates.
        Nobody reported bugs and it works fine to me. Yes, it's still very
        slow. Suggestions are welcome.
1.0.1   Major speed improvement. Search window is larger by 50%. A slightly
        faster search routine written in PowerPC assembly was added.
1.0.2   Minor speed improvement and bug fixes. -minb option was removed because
        since 1.0.1 is doesn't makes sense anymore. The minimum block size is
        now the smallest possible one: 6 bytes (was 8). Compile warning
        reported by Stephan Hegel was fixed. Documentation was updated.
1.0.3   "make nodiff" has been replaced with "make nommap". It uses a workaround
        to make possible to compile it under some stupid (guess...) operating
        systems that don't provide mmap(). It will load the whole files into
        memory.
1.0.4   -perm option was added. It saves and restores the permissions of the
        newfile. Difffiles created with this option are not completely compatible
        with older versions of bdiff. It complains about an error in the difffile
        but the output file is fine and the md5sum proves it.
1.0.5	Some compile problems on non-Linux system were fixed.

