Unit aDiff

*****************************************************************} { } { Diff Maker } { Copyright (c) 1997 S.Kurinny & S.Kostinsky } { } { 2/20/98 Modified by Gregory L. Bullock (bullock@mbay.net) so } { Delphi 1.0 will compile: } { Changed "Integer" to "LongInt" } { Changed useofs & bufofs in t3word from LongInt to word. } { Changed arrays with size MaxHashValue (= 131071) to } { 2-D with subarrays smaller than $FFF0. } { Reduced BufSize from 2048*1024. } { Converted Comp(...) to Pascal. } { I haven't confirmed this, but I suspect that this } { version still compiles under D2. The only changes that } { aren't protected by a "$IFDEF Win32" directive are the } { integer-to-longint and the longint-to-word conversions. } { I believe longint and word are both 4-byte data types } { in D2, so I don't think these changes will affect D2. } { } {

Classes

Functions

CalcHash - -------------------------------------------------} { Calculates hash value 3 bytes to 0.
comp - Compares buffers and returns number of equal bytes Len - max length

----------------------------------------------------------------} {$IFDEF Win32
DiffCompress - --------------------------------------------------------
DiffStreamCompress - -------------------------------------------------
DiffStreamExtract - -------------------------------------------------
Max - -----------------------------------------
Min - -----------------------------------------

Types

PByteArray
PLongInt
TByteArray
TByteArray
TDiffCompData
TMyProcedure

Constants

BufSize
BufSize
SSmallBuffer

Variables


Functions


Function CalcHash(a,b,c:LongInt):LongInt;

-------------------------------------------------} { Calculates hash value 3 bytes to 0..32767

-------------------------------------------------


function comp(var a,b;len:LongInt):word;

Compares buffers and returns number of equal bytes Len - max length

----------------------------------------------------------------} {$IFDEF Win32


procedure DiffCompress(D:TDiffCompData);

--------------------------------------------------------

procedure DiffStreamCompress(InStream,UseStream,OutStream:TStream;Notify:TmyProcedure;MaxLev:LongInt);

-------------------------------------------------

procedure DiffStreamExtract(InStream,UseStream,OutStream:TStream;Notify:TMyProcedure);

-------------------------------------------------

Function Max(a,b:LongInt):LongInt;

-----------------------------------------

Function Min(a,b:LongInt):LongInt;

-----------------------------------------

Types


PByteArray=^TByteArray

PLongInt=^LongInt

TByteArray=Array[1..$FFFF] of byte;

TByteArray=Array[1..MaxInt] of byte;

TDiffCompData = record
InBuf : PByteArray;
UseBuf : PByteArray;
InBufSize : LongInt;
UseBufSize : LongInt;
MaxLevel : LongInt;
MaxLength : LongInt;
MinLength : LongInt;
OutBuf : PByteArray;
OutSpBuf : PByteArray;
OutBufSize : PLongInt;
OutSpBufSize : PLongInt;
EnoughLen : LongInt;
end;

TMyProcedure=procedure

Constants

BufSize = $FFF8

BufSize = 2048*1024

-------------------------------------------------

SSmallBuffer = 'Buffer size should be at least 4 bytes'

-------------------------------------------------

Variables