|
@@ -1,264 +0,0 @@
|
|
-*** zstream.pp Thu Nov 4 13:55:36 1999
|
|
|
|
---- ../fpk/fcl/inc/zstream.pp Wed Nov 10 21:25:37 1999
|
|
|
|
-***************
|
|
|
|
-*** 2,13 ****
|
|
|
|
-
|
|
|
|
- interface
|
|
|
|
-
|
|
|
|
-! uses Sysutils, Classes,zlib,gzio,ZUtil,ZInflate,ZDeflate;
|
|
|
|
- {$H+}
|
|
|
|
-
|
|
|
|
-- TYPE TZStream=Z_Stream;
|
|
|
|
-- PZStream=Z_StreamP;
|
|
|
|
--
|
|
|
|
- type
|
|
|
|
- // Error reporting.
|
|
|
|
-
|
|
|
|
---- 2,10 ----
|
|
|
|
-
|
|
|
|
- interface
|
|
|
|
-
|
|
|
|
-! uses Sysutils, Classes,zlib;
|
|
|
|
- {$H+}
|
|
|
|
-
|
|
|
|
- type
|
|
|
|
- // Error reporting.
|
|
|
|
-
|
|
|
|
-***************
|
|
|
|
-*** 141,148 ****
|
|
|
|
- oldout : longint;
|
|
|
|
- begin
|
|
|
|
- FillChar(strm, sizeof(strm), 0);
|
|
|
|
-! strm.zalloc := {@zlibAllocMem;} @zcalloc;
|
|
|
|
-! strm.zfree := {@zlibFreeMem;} @zcfree;
|
|
|
|
- OutBytes := ((InBytes + (InBytes div 10) + 12) + 255) and not 255;
|
|
|
|
- OutBuf:=DGetMem(OutBytes);
|
|
|
|
- try
|
|
|
|
---- 138,145 ----
|
|
|
|
- oldout : longint;
|
|
|
|
- begin
|
|
|
|
- FillChar(strm, sizeof(strm), 0);
|
|
|
|
-! strm.zalloc := @zlibAllocMem;
|
|
|
|
-! strm.zfree := @zlibFreeMem;
|
|
|
|
- OutBytes := ((InBytes + (InBytes div 10) + 12) + 255) and not 255;
|
|
|
|
- OutBuf:=DGetMem(OutBytes);
|
|
|
|
- try
|
|
|
|
-***************
|
|
|
|
-*** 150,163 ****
|
|
|
|
- strm.avail_in := InBytes;
|
|
|
|
- strm.next_out := OutBuf;
|
|
|
|
- strm.avail_out := OutBytes;
|
|
|
|
-! CompressionCheck(deflateInit_(@strm, Z_BEST_COMPRESSION, zlibversion, sizeof(strm)));
|
|
|
|
- try
|
|
|
|
- while CompressionCheck(deflate(strm, Z_FINISH)) <> Z_STREAM_END do
|
|
|
|
- begin
|
|
|
|
- P := OutBuf;
|
|
|
|
- Inc(OutBytes, 256);
|
|
|
|
- DReallocMem(OutBuf,OutBytes);
|
|
|
|
-! strm.next_out := PByteF(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P)));
|
|
|
|
- strm.avail_out := 256;
|
|
|
|
- end;
|
|
|
|
- finally
|
|
|
|
---- 147,160 ----
|
|
|
|
- strm.avail_in := InBytes;
|
|
|
|
- strm.next_out := OutBuf;
|
|
|
|
- strm.avail_out := OutBytes;
|
|
|
|
-! CompressionCheck(deflateInit_(strm, Z_BEST_COMPRESSION, zlibversion, sizeof(strm)));
|
|
|
|
- try
|
|
|
|
- while CompressionCheck(deflate(strm, Z_FINISH)) <> Z_STREAM_END do
|
|
|
|
- begin
|
|
|
|
- P := OutBuf;
|
|
|
|
- Inc(OutBytes, 256);
|
|
|
|
- DReallocMem(OutBuf,OutBytes);
|
|
|
|
-! strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P)));
|
|
|
|
- strm.avail_out := 256;
|
|
|
|
- end;
|
|
|
|
- finally
|
|
|
|
-***************
|
|
|
|
-*** 180,188 ****
|
|
|
|
- BufInc: Integer;
|
|
|
|
- begin
|
|
|
|
- FillChar(strm, sizeof(strm), 0);
|
|
|
|
-! strm.zalloc := {@zlibAllocMem;} @zcalloc;
|
|
|
|
-! strm.zfree := {@zlibFreeMem;} @zcfree;
|
|
|
|
-!
|
|
|
|
- BufInc := (InBytes + 255) and not 255;
|
|
|
|
- if OutEstimate = 0 then
|
|
|
|
- OutBytes := BufInc
|
|
|
|
---- 177,184 ----
|
|
|
|
- BufInc: Integer;
|
|
|
|
- begin
|
|
|
|
- FillChar(strm, sizeof(strm), 0);
|
|
|
|
-! strm.zalloc := @zlibAllocMem;
|
|
|
|
-! strm.zfree := @zlibFreeMem;
|
|
|
|
- BufInc := (InBytes + 255) and not 255;
|
|
|
|
- if OutEstimate = 0 then
|
|
|
|
- OutBytes := BufInc
|
|
|
|
-***************
|
|
|
|
-*** 194,207 ****
|
|
|
|
- strm.avail_in := InBytes;
|
|
|
|
- strm.next_out := OutBuf;
|
|
|
|
- strm.avail_out := OutBytes;
|
|
|
|
-! DecompressionCheck(inflateInit_(@strm, zlibversion, sizeof(strm)));
|
|
|
|
- try
|
|
|
|
- while DecompressionCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END do
|
|
|
|
- begin
|
|
|
|
- P := OutBuf;
|
|
|
|
- Inc(OutBytes, BufInc);
|
|
|
|
- DReallocMem(OutBuf, OutBytes);
|
|
|
|
-! strm.next_out := Pbytef(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P)));
|
|
|
|
- strm.avail_out := BufInc;
|
|
|
|
- end;
|
|
|
|
- finally
|
|
|
|
---- 190,203 ----
|
|
|
|
- strm.avail_in := InBytes;
|
|
|
|
- strm.next_out := OutBuf;
|
|
|
|
- strm.avail_out := OutBytes;
|
|
|
|
-! DecompressionCheck(inflateInit_(strm, zlibversion, sizeof(strm)));
|
|
|
|
- try
|
|
|
|
- while DecompressionCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END do
|
|
|
|
- begin
|
|
|
|
- P := OutBuf;
|
|
|
|
- Inc(OutBytes, BufInc);
|
|
|
|
- DReallocMem(OutBuf, OutBytes);
|
|
|
|
-! strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P)));
|
|
|
|
- strm.avail_out := BufInc;
|
|
|
|
- end;
|
|
|
|
- finally
|
|
|
|
-***************
|
|
|
|
-*** 223,230 ****
|
|
|
|
- inherited Create;
|
|
|
|
- FStrm := Strm;
|
|
|
|
- FStrmPos := Strm.Position;
|
|
|
|
-! FZRec.zalloc := {@zlibAllocMem;} @zcalloc;
|
|
|
|
-! FZRec.zfree := {@zlibFreeMem;} @zcfree;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- procedure TCustomZLibStream.Progress(Sender: TObject);
|
|
|
|
---- 219,226 ----
|
|
|
|
- inherited Create;
|
|
|
|
- FStrm := Strm;
|
|
|
|
- FStrmPos := Strm.Position;
|
|
|
|
-! FZRec.zalloc := @zlibAllocMem;
|
|
|
|
-! FZRec.zfree := @zlibFreeMem;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- procedure TCustomZLibStream.Progress(Sender: TObject);
|
|
|
|
-***************
|
|
|
|
-*** 242,250 ****
|
|
|
|
- (Z_NO_COMPRESSION, Z_BEST_SPEED, Z_DEFAULT_COMPRESSION, Z_BEST_COMPRESSION);
|
|
|
|
- begin
|
|
|
|
- inherited Create(Dest);
|
|
|
|
-! FZRec.next_out :=@FBuffer;
|
|
|
|
- FZRec.avail_out := sizeof(FBuffer);
|
|
|
|
-! CompressionCheck(deflateInit_(@FZRec, Levels[CompressionLevel], zlibversion, sizeof(FZRec)));
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- destructor TCompressionStream.Destroy;
|
|
|
|
---- 238,246 ----
|
|
|
|
- (Z_NO_COMPRESSION, Z_BEST_SPEED, Z_DEFAULT_COMPRESSION, Z_BEST_COMPRESSION);
|
|
|
|
- begin
|
|
|
|
- inherited Create(Dest);
|
|
|
|
-! FZRec.next_out := FBuffer;
|
|
|
|
- FZRec.avail_out := sizeof(FBuffer);
|
|
|
|
-! CompressionCheck(deflateInit_(FZRec, Levels[CompressionLevel], zlibversion, sizeof(FZRec)));
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- destructor TCompressionStream.Destroy;
|
|
|
|
-***************
|
|
|
|
-*** 257,263 ****
|
|
|
|
- and (FZRec.avail_out = 0) do
|
|
|
|
- begin
|
|
|
|
- FStrm.WriteBuffer(FBuffer, sizeof(FBuffer));
|
|
|
|
-! FZRec.next_out := @FBuffer;
|
|
|
|
- FZRec.avail_out := sizeof(FBuffer);
|
|
|
|
- end;
|
|
|
|
- if FZRec.avail_out < sizeof(FBuffer) then
|
|
|
|
---- 253,259 ----
|
|
|
|
- and (FZRec.avail_out = 0) do
|
|
|
|
- begin
|
|
|
|
- FStrm.WriteBuffer(FBuffer, sizeof(FBuffer));
|
|
|
|
-! FZRec.next_out := FBuffer;
|
|
|
|
- FZRec.avail_out := sizeof(FBuffer);
|
|
|
|
- end;
|
|
|
|
- if FZRec.avail_out < sizeof(FBuffer) then
|
|
|
|
-***************
|
|
|
|
-*** 295,301 ****
|
|
|
|
- if FZRec.avail_out = 0 then
|
|
|
|
- begin
|
|
|
|
- FStrm.WriteBuffer(FBuffer, sizeof(FBuffer));
|
|
|
|
-! FZRec.next_out := @FBuffer;
|
|
|
|
- FZRec.avail_out := sizeof(FBuffer);
|
|
|
|
- FStrmPos := FStrm.Position;
|
|
|
|
- Progress(Self);
|
|
|
|
---- 291,297 ----
|
|
|
|
- if FZRec.avail_out = 0 then
|
|
|
|
- begin
|
|
|
|
- FStrm.WriteBuffer(FBuffer, sizeof(FBuffer));
|
|
|
|
-! FZRec.next_out := FBuffer;
|
|
|
|
- FZRec.avail_out := sizeof(FBuffer);
|
|
|
|
- FStrmPos := FStrm.Position;
|
|
|
|
- Progress(Self);
|
|
|
|
-***************
|
|
|
|
-*** 329,337 ****
|
|
|
|
- constructor TDecompressionStream.Create(Source: TStream);
|
|
|
|
- begin
|
|
|
|
- inherited Create(Source);
|
|
|
|
-! FZRec.next_in := @FBuffer;
|
|
|
|
- FZRec.avail_in := 0;
|
|
|
|
-! DecompressionCheck(inflateInit_(@FZRec, zlibversion, sizeof(FZRec)));
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- destructor TDecompressionStream.Destroy;
|
|
|
|
---- 325,333 ----
|
|
|
|
- constructor TDecompressionStream.Create(Source: TStream);
|
|
|
|
- begin
|
|
|
|
- inherited Create(Source);
|
|
|
|
-! FZRec.next_in := FBuffer;
|
|
|
|
- FZRec.avail_in := 0;
|
|
|
|
-! DecompressionCheck(inflateInit_(FZRec, zlibversion, sizeof(FZRec)));
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- destructor TDecompressionStream.Destroy;
|
|
|
|
-***************
|
|
|
|
-*** 365,371 ****
|
|
|
|
- Result := Count - FZRec.avail_out;
|
|
|
|
- Exit;
|
|
|
|
- end;
|
|
|
|
-! FZRec.next_in := @FBuffer;
|
|
|
|
- FStrmPos := FStrm.Position;
|
|
|
|
- Progress(Self);
|
|
|
|
- end;
|
|
|
|
---- 361,367 ----
|
|
|
|
- Result := Count - FZRec.avail_out;
|
|
|
|
- Exit;
|
|
|
|
- end;
|
|
|
|
-! FZRec.next_in := FBuffer;
|
|
|
|
- FStrmPos := FStrm.Position;
|
|
|
|
- Progress(Self);
|
|
|
|
- end;
|
|
|
|
-***************
|
|
|
|
-*** 387,393 ****
|
|
|
|
- if (Offset = 0) and (Origin = soFromBeginning) then
|
|
|
|
- begin
|
|
|
|
- DecompressionCheck(inflateReset(FZRec));
|
|
|
|
-! FZRec.next_in := @FBuffer;
|
|
|
|
- FZRec.avail_in := 0;
|
|
|
|
- FStrm.Position := 0;
|
|
|
|
- FStrmPos := 0;
|
|
|
|
---- 383,389 ----
|
|
|
|
- if (Offset = 0) and (Origin = soFromBeginning) then
|
|
|
|
- begin
|
|
|
|
- DecompressionCheck(inflateReset(FZRec));
|
|
|
|
-! FZRec.next_in := FBuffer;
|
|
|
|
- FZRec.avail_in := 0;
|
|
|
|
- FStrm.Position := 0;
|
|
|
|
- FStrmPos := 0;
|
|
|
|
-***************
|
|
|
|
-*** 449,452 ****
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- end.
|
|
|
|
--
|
|
|
|
-\ No newline at end of file
|
|
|
|
---- 445,447 ----
|
|
|