mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 06:59:33 +01:00 
			
		
		
		
	* rename zlib.pas -> zbase.pas to overcome conflicting name with the
other zlib package
  * paszlib unit added as generic interface for all other units, this
    unit is partly compatible with the other zlib pacakge
			
			
This commit is contained in:
		
							parent
							
								
									d353155496
								
							
						
					
					
						commit
						9198133711
					
				@ -1,5 +1,5 @@
 | 
			
		||||
#
 | 
			
		||||
# Makefile generated by fpcmake v0.99.13 [2000/01/04]
 | 
			
		||||
# Makefile generated by fpcmake v0.99.13 [2000/01/06]
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
defaultrule: all
 | 
			
		||||
@ -104,27 +104,54 @@ endif
 | 
			
		||||
 | 
			
		||||
export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION
 | 
			
		||||
 | 
			
		||||
# Default FPCDIR
 | 
			
		||||
ifndef FPCDIR
 | 
			
		||||
FPCDIR=../..
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
# Test FPCDIR to look if the RTL dir exists
 | 
			
		||||
ifdef FPCDIR
 | 
			
		||||
override FPCDIR:=$(subst \,/,$(FPCDIR))
 | 
			
		||||
ifeq ($(wildcard $(FPCDIR)/rtl),)
 | 
			
		||||
override FPCDIR=
 | 
			
		||||
override FPCDIR=wrong
 | 
			
		||||
endif
 | 
			
		||||
else
 | 
			
		||||
override FPCDIR=
 | 
			
		||||
override FPCDIR=wrong
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
# Default FPCDIR
 | 
			
		||||
ifeq ($(FPCDIR),wrong)
 | 
			
		||||
override FPCDIR=../..
 | 
			
		||||
ifeq ($(wildcard $(FPCDIR)/rtl),)
 | 
			
		||||
override FPCDIR=wrong
 | 
			
		||||
endif
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
# Detect FPCDIR
 | 
			
		||||
ifeq ($(FPCDIR),)
 | 
			
		||||
ifeq ($(FPCDIR),wrong)
 | 
			
		||||
ifdef inlinux
 | 
			
		||||
FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
 | 
			
		||||
override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
 | 
			
		||||
else
 | 
			
		||||
FPCDIR:=$(subst /$(FPC)$(EXEEXT),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC)$(EXEEXT),$(SEARCHPATH))))))
 | 
			
		||||
override FPCDIR:=$(subst /$(FPC)$(EXEEXT),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC)$(EXEEXT),$(SEARCHPATH))))))
 | 
			
		||||
endif
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifndef PACKAGEDIR
 | 
			
		||||
PACKAGEDIR=$(FPCDIR)/packages
 | 
			
		||||
endif
 | 
			
		||||
ifndef COMPONENTDIR
 | 
			
		||||
COMPONENTDIR=$(FPCDIR)/components
 | 
			
		||||
endif
 | 
			
		||||
# Check if packagedir really exists else turn it off
 | 
			
		||||
ifeq ($(wildcard $(PACKAGEDIR)),)
 | 
			
		||||
PACKAGEDIR=
 | 
			
		||||
endif
 | 
			
		||||
ifeq ($(wildcard $(COMPONENTDIR)),)
 | 
			
		||||
COMPONENTDIR=
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
# Create rtl,units dir
 | 
			
		||||
ifneq ($(FPCDIR),.)
 | 
			
		||||
override UNITSDIR=$(FPCDIR)/units/$(OS_TARGET)
 | 
			
		||||
ifneq ($(wildcard $(FPCDIR)/rtl),)
 | 
			
		||||
override RTLDIR=$(FPCDIR)/rtl/$(OS_TARGET)
 | 
			
		||||
else
 | 
			
		||||
override RTLDIR=$(UNITSDIR)/rtl
 | 
			
		||||
endif
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
@ -153,7 +180,7 @@ endif
 | 
			
		||||
 | 
			
		||||
# Targets
 | 
			
		||||
 | 
			
		||||
override UNITOBJECTS+=adler crc crcasm gzio infblock infcodes inffast inftrees infutil strutils trees zcompres zdeflate zinflate zlib zuncompr zutil
 | 
			
		||||
override UNITOBJECTS+=paszlib adler crc crcasm gzio infblock infcodes inffast inftrees infutil strutils trees zcompres zdeflate zinflate zbase zuncompr zutil
 | 
			
		||||
override EXAMPLEOBJECTS+=example minigzip
 | 
			
		||||
 | 
			
		||||
# Clean
 | 
			
		||||
@ -161,24 +188,14 @@ override EXAMPLEOBJECTS+=example minigzip
 | 
			
		||||
 | 
			
		||||
# Install
 | 
			
		||||
 | 
			
		||||
UNITSUBDIR=paszlib
 | 
			
		||||
ZIPTARGET=install
 | 
			
		||||
 | 
			
		||||
# Defaults
 | 
			
		||||
 | 
			
		||||
override NEEDOPT=-Sm
 | 
			
		||||
 | 
			
		||||
# Directories
 | 
			
		||||
 | 
			
		||||
ifndef PACKAGEDIR
 | 
			
		||||
ifneq ($(wildcard $(FPCDIR)/packages),)
 | 
			
		||||
PACKAGEDIR=$(FPCDIR)/packages
 | 
			
		||||
else
 | 
			
		||||
PACKAGEDIR=$(FPCDIR)/units/$(OS_TARGET)
 | 
			
		||||
endif
 | 
			
		||||
endif
 | 
			
		||||
ifndef COMPONENTDIR
 | 
			
		||||
COMPONENTDIR=$(FPCDIR)/components
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
# Packages
 | 
			
		||||
 | 
			
		||||
@ -203,11 +220,6 @@ else
 | 
			
		||||
BASEDIR=.
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
# this can be set to 'rtl' when the RTL units are installed
 | 
			
		||||
ifndef UNITPREFIX
 | 
			
		||||
UNITPREFIX=units
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
# set the prefix directory where to install everything
 | 
			
		||||
ifndef PREFIXINSTALLDIR
 | 
			
		||||
ifdef inlinux
 | 
			
		||||
@ -218,12 +230,6 @@ endif
 | 
			
		||||
endif
 | 
			
		||||
export PREFIXINSTALLDIR
 | 
			
		||||
 | 
			
		||||
# Create rtl,fcl,units dir
 | 
			
		||||
ifneq ($(FPCDIR),.)
 | 
			
		||||
override RTLDIR=$(FPCDIR)/rtl/$(OS_TARGET)
 | 
			
		||||
override UNITSDIR=$(FPCDIR)/units/$(OS_TARGET)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
#####################################################################
 | 
			
		||||
# Install Directories
 | 
			
		||||
#####################################################################
 | 
			
		||||
@ -248,7 +254,7 @@ endif
 | 
			
		||||
 | 
			
		||||
# set the directory where to install the units.
 | 
			
		||||
ifndef UNITINSTALLDIR
 | 
			
		||||
UNITINSTALLDIR=$(BASEINSTALLDIR)/$(UNITPREFIX)/$(OS_TARGET)
 | 
			
		||||
UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET)
 | 
			
		||||
ifdef UNITSUBDIR
 | 
			
		||||
UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR)
 | 
			
		||||
endif
 | 
			
		||||
@ -275,15 +281,15 @@ endif
 | 
			
		||||
# Where the doc files will be stored
 | 
			
		||||
ifndef DOCINSTALLDIR
 | 
			
		||||
ifdef inlinux
 | 
			
		||||
DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc/$(FPC_VERSION)
 | 
			
		||||
DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION)
 | 
			
		||||
else
 | 
			
		||||
DOCINSTALLDIR=$(BASEINSTALLDIR)/doc
 | 
			
		||||
endif
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
# Where the some extra (data)files will be stored
 | 
			
		||||
ifndef EXTRAINSTALLDIR
 | 
			
		||||
EXTRAINSTALLDIR=$(BASEINSTALLDIR)
 | 
			
		||||
ifndef DATAINSTALLDIR
 | 
			
		||||
DATAINSTALLDIR=$(BASEINSTALLDIR)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -299,18 +305,14 @@ ifneq ($(OS_TARGET),$(OS_SOURCE))
 | 
			
		||||
override FPCOPT+=-T$(OS_TARGET)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifdef NEEDOPT
 | 
			
		||||
override FPCOPT+=$(NEEDOPT)
 | 
			
		||||
ifdef UNITSDIR
 | 
			
		||||
override FPCOPT+=-Fu$(UNITSDIR)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifdef RTLDIR
 | 
			
		||||
override FPCOPT+=-Fu$(RTLDIR)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifdef UNITSDIR
 | 
			
		||||
override FPCOPT+=-Fu$(UNITSDIR)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
# Smartlinking
 | 
			
		||||
ifdef SMARTLINK
 | 
			
		||||
override FPCOPT+=-CX
 | 
			
		||||
@ -835,7 +837,7 @@ ifneq ($(INSTALLPPULIBFILES),)
 | 
			
		||||
endif
 | 
			
		||||
endif
 | 
			
		||||
ifdef EXTRAINSTALLFILES
 | 
			
		||||
	@$(ECHO) -e $(addprefix "\n"$(EXTRAINSTALLDIR)/,$(EXTRAINSTALLFILES))
 | 
			
		||||
	@$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(EXTRAINSTALLFILES))
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
fpc_install: $(INSTALLTARGET)
 | 
			
		||||
@ -860,8 +862,8 @@ ifneq ($(INSTALLPPULIBFILES),)
 | 
			
		||||
endif
 | 
			
		||||
endif
 | 
			
		||||
ifdef EXTRAINSTALLFILES
 | 
			
		||||
	$(MKDIR) $(EXTRAINSTALLDIR)
 | 
			
		||||
	$(INSTALL) $(EXTRAINSTALLFILES) $(EXTRAINSTALLDIR)
 | 
			
		||||
	$(MKDIR) $(DATAINSTALLDIR)
 | 
			
		||||
	$(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
#####################################################################
 | 
			
		||||
@ -1028,6 +1030,6 @@ endif
 | 
			
		||||
	@$(ECHO)  UnitInstallDir....... $(UNITINSTALLDIR)
 | 
			
		||||
	@$(ECHO)  SourceInstallDir..... $(SOURCEINSTALLDIR)
 | 
			
		||||
	@$(ECHO)  DocInstallDir........ $(DOCINSTALLDIR)
 | 
			
		||||
	@$(ECHO)  ExtraInstallDir...... $(EXTRAINSTALLDIR)
 | 
			
		||||
	@$(ECHO)  DataInstallDir....... $(DATAINSTALLDIR)
 | 
			
		||||
	@$(ECHO)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -3,11 +3,11 @@
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
[targets]
 | 
			
		||||
units=adler crc crcasm gzio infblock infcodes inffast inftrees infutil strutils trees zcompres zdeflate zinflate zlib zuncompr zutil
 | 
			
		||||
units=paszlib adler crc crcasm gzio infblock infcodes inffast inftrees infutil strutils trees zcompres zdeflate zinflate zbase zuncompr zutil
 | 
			
		||||
examples=example minigzip
 | 
			
		||||
 | 
			
		||||
[require]
 | 
			
		||||
options=-Sm
 | 
			
		||||
[install]
 | 
			
		||||
unitsubdir=paszlib
 | 
			
		||||
 | 
			
		||||
[dirs]
 | 
			
		||||
fpcdir=../..
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,7 @@ interface
 | 
			
		||||
{$I zconf.inc}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  zutil, zlib;
 | 
			
		||||
  zutil, zbase;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function crc32(crc : uLong; buf : pBytef; len : uInt) : uLong;
 | 
			
		||||
@ -38,7 +38,7 @@ function crc32(crc : uLong; buf : pBytef; len : uInt) : uLong;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function get_crc_table : puLong;  { can be used by asm versions of crc32() }
 | 
			
		||||
function get_crc_table : pointer;  { can be used by asm versions of crc32() }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
implementation
 | 
			
		||||
@ -175,13 +175,13 @@ const
 | 
			
		||||
{ =========================================================================
 | 
			
		||||
  This function can be used by asm versions of crc32() }
 | 
			
		||||
 | 
			
		||||
function get_crc_table : {const} puLong;
 | 
			
		||||
function get_crc_table : {const} pointer;
 | 
			
		||||
begin
 | 
			
		||||
{$ifdef DYNAMIC_CRC_TABLE}
 | 
			
		||||
  if (crc_table_empty) then
 | 
			
		||||
    make_crc_table;
 | 
			
		||||
{$endif}
 | 
			
		||||
  get_crc_table :=  {const} puLong(@crc_table);
 | 
			
		||||
  get_crc_table :=  {const} pointer(@crc_table);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
{ ========================================================================= }
 | 
			
		||||
 | 
			
		||||
@ -24,7 +24,7 @@ interface
 | 
			
		||||
{$ENDIF}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  zutil, zlib;
 | 
			
		||||
  zutil, zbase;
 | 
			
		||||
 | 
			
		||||
function crc32(crc : uLong; buf : pBytef; len : uInt) : uLong;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -21,12 +21,13 @@ uses
 | 
			
		||||
  {$else}
 | 
			
		||||
  SysUtils,
 | 
			
		||||
  {$endif}
 | 
			
		||||
  zutil, zlib, crc, zdeflate, zinflate;
 | 
			
		||||
  zutil, zbase, crc, zdeflate, zinflate;
 | 
			
		||||
 | 
			
		||||
type gzFile = voidp;
 | 
			
		||||
type z_off_t = long;
 | 
			
		||||
 | 
			
		||||
function gzopen  (path:string; mode:string) : gzFile;
 | 
			
		||||
function gzsetparams (f:gzfile; level:int; strategy:int) : int;
 | 
			
		||||
function gzread  (f:gzFile; buf:voidp; len:uInt) : int;
 | 
			
		||||
function gzgetc  (f:gzfile) : int;
 | 
			
		||||
function gzgets  (f:gzfile; buf:PChar; len:int) : PChar;
 | 
			
		||||
@ -43,10 +44,12 @@ function gzflush (f:gzFile; flush:int)           : int;
 | 
			
		||||
  {$endif}
 | 
			
		||||
{$endif}
 | 
			
		||||
 | 
			
		||||
function gzseek  (f:gzfile; offset:z_off_t; whence:int) : z_off_t;
 | 
			
		||||
function gztell  (f:gzfile) : z_off_t;
 | 
			
		||||
function gzclose (f:gzFile)                      : int;
 | 
			
		||||
function gzerror (f:gzFile; var errnum:Int)      : string;
 | 
			
		||||
function gzseek   (f:gzfile; offset:z_off_t; whence:int) : z_off_t;
 | 
			
		||||
function gzrewind (f:gzFile) : int;
 | 
			
		||||
function gztell   (f:gzfile) : z_off_t;
 | 
			
		||||
function gzeof    (f:gzfile) : boolean;
 | 
			
		||||
function gzclose  (f:gzFile)                      : int;
 | 
			
		||||
function gzerror  (f:gzFile; var errnum:Int)      : string;
 | 
			
		||||
 | 
			
		||||
const
 | 
			
		||||
  SEEK_SET {: z_off_t} = 0; { seek from beginning of file }
 | 
			
		||||
@ -123,7 +126,7 @@ var
 | 
			
		||||
  s        : gz_streamp;
 | 
			
		||||
{$IFDEF MSDOS}
 | 
			
		||||
  attr     : word;       { file attributes }
 | 
			
		||||
{$ENDIF}  
 | 
			
		||||
{$ENDIF}
 | 
			
		||||
 | 
			
		||||
{$IFNDEF NO_DEFLATE}
 | 
			
		||||
  gzheader : array [0..9] of byte;
 | 
			
		||||
@ -222,7 +225,7 @@ begin
 | 
			
		||||
    Reset (s^.gzfile,1);
 | 
			
		||||
  {$else}
 | 
			
		||||
  if (not FileExists(s^.path)) and (s^.mode='w') then
 | 
			
		||||
    ReWrite (s^.gzfile,1)  
 | 
			
		||||
    ReWrite (s^.gzfile,1)
 | 
			
		||||
  else
 | 
			
		||||
    Reset (s^.gzfile,1);
 | 
			
		||||
  {$endif}
 | 
			
		||||
@ -407,7 +410,7 @@ begin
 | 
			
		||||
      if (c <> Z_EOF) then begin
 | 
			
		||||
        Inc(s^.stream.avail_in);
 | 
			
		||||
        Dec(s^.stream.next_in);
 | 
			
		||||
	s^.transparent := TRUE;
 | 
			
		||||
        s^.transparent := TRUE;
 | 
			
		||||
      end;
 | 
			
		||||
      if (s^.stream.avail_in <> 0) then s^.z_err := Z_OK
 | 
			
		||||
      else s^.z_err := Z_STREAM_END;
 | 
			
		||||
@ -584,9 +587,9 @@ begin
 | 
			
		||||
      {$I+}
 | 
			
		||||
      if (s^.stream.avail_in = 0) then begin
 | 
			
		||||
        s^.z_eof := true;
 | 
			
		||||
	if (IOResult <> 0) then begin
 | 
			
		||||
	  s^.z_err := Z_ERRNO;
 | 
			
		||||
	  break;
 | 
			
		||||
        if (IOResult <> 0) then begin
 | 
			
		||||
          s^.z_err := Z_ERRNO;
 | 
			
		||||
          break;
 | 
			
		||||
        end;
 | 
			
		||||
      end;
 | 
			
		||||
      s^.stream.next_in := s^.inbuf;
 | 
			
		||||
@ -610,18 +613,18 @@ begin
 | 
			
		||||
 | 
			
		||||
      if (s^.crc <> filecrc) or (s^.stream.total_out <> filelen)
 | 
			
		||||
        then s^.z_err := Z_DATA_ERROR
 | 
			
		||||
	else begin
 | 
			
		||||
	  { Check for concatenated .gz files: }
 | 
			
		||||
	  check_header(s);
 | 
			
		||||
	  if (s^.z_err = Z_OK) then begin
 | 
			
		||||
        else begin
 | 
			
		||||
          { Check for concatenated .gz files: }
 | 
			
		||||
          check_header(s);
 | 
			
		||||
          if (s^.z_err = Z_OK) then begin
 | 
			
		||||
            total_in := s^.stream.total_in;
 | 
			
		||||
            total_out := s^.stream.total_out;
 | 
			
		||||
 | 
			
		||||
	    inflateReset (s^.stream);
 | 
			
		||||
	    s^.stream.total_in := total_in;
 | 
			
		||||
	    s^.stream.total_out := total_out;
 | 
			
		||||
	    s^.crc := crc32 (0, Z_NULL, 0);
 | 
			
		||||
	  end;
 | 
			
		||||
            inflateReset (s^.stream);
 | 
			
		||||
            s^.stream.total_in := total_in;
 | 
			
		||||
            s^.stream.total_out := total_out;
 | 
			
		||||
            s^.crc := crc32 (0, Z_NULL, 0);
 | 
			
		||||
          end;
 | 
			
		||||
      end; {IF-THEN-ELSE}
 | 
			
		||||
    end;
 | 
			
		||||
 | 
			
		||||
@ -768,10 +771,10 @@ var
 | 
			
		||||
begin
 | 
			
		||||
{$ifdef HAS_snprintf}
 | 
			
		||||
    snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
 | 
			
		||||
	     a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
 | 
			
		||||
             a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
 | 
			
		||||
{$else}
 | 
			
		||||
    sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
 | 
			
		||||
	    a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
 | 
			
		||||
            a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
 | 
			
		||||
{$endif}
 | 
			
		||||
    len := strlen(buf); { old sprintf doesn't return the nb of bytes written }
 | 
			
		||||
    if (len <= 0) return 0;
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@ uses
 | 
			
		||||
  {$IFDEF DEBUG}
 | 
			
		||||
  strutils,
 | 
			
		||||
  {$ENDIF}
 | 
			
		||||
  zutil, zlib;
 | 
			
		||||
  zutil, zbase;
 | 
			
		||||
 | 
			
		||||
function inflate_blocks_new(var z : z_stream;
 | 
			
		||||
                            c : check_func;  { check function }
 | 
			
		||||
@ -162,7 +162,7 @@ begin
 | 
			
		||||
  Inc(s^.zend, w);
 | 
			
		||||
  s^.checkfn := c;
 | 
			
		||||
  s^.mode := ZTYPE;
 | 
			
		||||
  {$IFDEF DEBUG}  
 | 
			
		||||
  {$IFDEF DEBUG}
 | 
			
		||||
  Tracev('inflate:   blocks allocated');
 | 
			
		||||
  {$ENDIF}
 | 
			
		||||
  inflate_blocks_reset(s^, z, Z_NULL);
 | 
			
		||||
@ -299,7 +299,7 @@ begin
 | 
			
		||||
                Tracev('inflate:     dynamic codes block (last)')
 | 
			
		||||
              else
 | 
			
		||||
                Tracev('inflate:     dynamic codes block');
 | 
			
		||||
              {$ENDIF}                
 | 
			
		||||
              {$ENDIF}
 | 
			
		||||
              {DUMPBITS(3);}
 | 
			
		||||
              b := b shr 3;
 | 
			
		||||
              Dec(k, 3);
 | 
			
		||||
@ -762,7 +762,7 @@ begin
 | 
			
		||||
          end;
 | 
			
		||||
          {$IFDEF DEBUG}
 | 
			
		||||
          Tracev('inflate:       trees ok');
 | 
			
		||||
          {$ENDIF}          
 | 
			
		||||
          {$ENDIF}
 | 
			
		||||
          { c renamed to cs }
 | 
			
		||||
          cs := inflate_codes_new(bl, bd, tl, td, z);
 | 
			
		||||
          if (cs = Z_NULL) then
 | 
			
		||||
@ -926,7 +926,7 @@ begin
 | 
			
		||||
  ZFREE(z, s);
 | 
			
		||||
  {$IFDEF DEBUG}
 | 
			
		||||
  Trace('inflate:   blocks freed');
 | 
			
		||||
  {$ENDIF}  
 | 
			
		||||
  {$ENDIF}
 | 
			
		||||
  inflate_blocks_free := Z_OK;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,7 @@ uses
 | 
			
		||||
  {$IFDEF DEBUG}
 | 
			
		||||
  strutils,
 | 
			
		||||
  {$ENDIF}
 | 
			
		||||
  zutil, zlib;
 | 
			
		||||
  zutil, zbase;
 | 
			
		||||
 | 
			
		||||
function inflate_codes_new (bl : uInt;
 | 
			
		||||
                            bd : uInt;
 | 
			
		||||
@ -175,7 +175,7 @@ begin
 | 
			
		||||
          Tracevv('inflate:         literal '+char(t^.base))
 | 
			
		||||
        else
 | 
			
		||||
          Tracevv('inflate:         literal '+IntToStr(t^.base));
 | 
			
		||||
        {$ENDIF}          
 | 
			
		||||
        {$ENDIF}
 | 
			
		||||
        c^.mode := LIT;
 | 
			
		||||
        continue;  { break switch statement }
 | 
			
		||||
      end;
 | 
			
		||||
@ -196,7 +196,7 @@ begin
 | 
			
		||||
      begin
 | 
			
		||||
        {$IFDEF DEBUG}
 | 
			
		||||
        Tracevv('inflate:         end of block');
 | 
			
		||||
        {$ENDIF}        
 | 
			
		||||
        {$ENDIF}
 | 
			
		||||
        c^.mode := WASH;
 | 
			
		||||
        continue;         { break C-switch statement }
 | 
			
		||||
      end;
 | 
			
		||||
@ -568,7 +568,7 @@ procedure inflate_codes_free(c : pInflate_codes_state;
 | 
			
		||||
                             var z : z_stream);
 | 
			
		||||
begin
 | 
			
		||||
  ZFREE(z, c);
 | 
			
		||||
  {$IFDEF DEBUG}  
 | 
			
		||||
  {$IFDEF DEBUG}
 | 
			
		||||
  Tracev('inflate:       codes free');
 | 
			
		||||
  {$ENDIF}
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
@ -19,7 +19,7 @@ uses
 | 
			
		||||
  {$ifdef DEBUG}
 | 
			
		||||
  strutils,
 | 
			
		||||
  {$ENDIF}
 | 
			
		||||
  zutil, zlib;
 | 
			
		||||
  zutil, zbase;
 | 
			
		||||
 | 
			
		||||
function inflate_fast( bl : uInt;
 | 
			
		||||
                       bd : uInt;
 | 
			
		||||
@ -244,7 +244,7 @@ begin
 | 
			
		||||
            Tracevv('inflate:         * literal '+char(t^.base))
 | 
			
		||||
          else
 | 
			
		||||
            Tracevv('inflate:         * literal '+IntToStr(t^.base));
 | 
			
		||||
          {$ENDIF}            
 | 
			
		||||
          {$ENDIF}
 | 
			
		||||
          q^ := Byte(t^.base);
 | 
			
		||||
          Inc(q);
 | 
			
		||||
          Dec(m);
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,7 @@ interface
 | 
			
		||||
{$I zconf.inc}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  zutil, zlib;
 | 
			
		||||
  zutil, zbase;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{ Maximum size of dynamic tree.  The maximum found in a long but non-
 | 
			
		||||
 | 
			
		||||
@ -17,7 +17,7 @@ interface
 | 
			
		||||
{$I zconf.inc}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  zutil, zlib;
 | 
			
		||||
  zutil, zbase;
 | 
			
		||||
 | 
			
		||||
{ copy as much as possible from the sliding window to the output area }
 | 
			
		||||
function inflate_flush(var s : inflate_blocks_state;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										328
									
								
								packages/paszlib/paszlib.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										328
									
								
								packages/paszlib/paszlib.pas
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,328 @@
 | 
			
		||||
unit paszlib;
 | 
			
		||||
 | 
			
		||||
interface
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  zbase;
 | 
			
		||||
 | 
			
		||||
type
 | 
			
		||||
  { Compatibility types }
 | 
			
		||||
  Uint = cardinal;
 | 
			
		||||
  Ulong = Cardinal;
 | 
			
		||||
  Ulongf = Cardinal;
 | 
			
		||||
  Pulongf = ^Ulongf;
 | 
			
		||||
  z_off_t = longint;
 | 
			
		||||
 | 
			
		||||
  TAllocfunc = function (opaque:pointer; items:uInt; size:uInt):pointer;
 | 
			
		||||
  TFreeFunc = procedure (opaque:pointer; address:pointer);
 | 
			
		||||
 | 
			
		||||
  TInternalState = record
 | 
			
		||||
    end;
 | 
			
		||||
  PInternalState = ^TInternalstate;
 | 
			
		||||
 | 
			
		||||
  TZStream = z_stream;
 | 
			
		||||
  PZstream = ^TZStream;
 | 
			
		||||
 | 
			
		||||
  gzFile = pointer;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const
 | 
			
		||||
  Z_NO_FLUSH = 0;
 | 
			
		||||
 | 
			
		||||
  Z_PARTIAL_FLUSH = 1;
 | 
			
		||||
  Z_SYNC_FLUSH = 2;
 | 
			
		||||
  Z_FULL_FLUSH = 3;
 | 
			
		||||
  Z_FINISH = 4;
 | 
			
		||||
 | 
			
		||||
  Z_OK = 0;
 | 
			
		||||
  Z_STREAM_END = 1;
 | 
			
		||||
  Z_NEED_DICT = 2;
 | 
			
		||||
  Z_ERRNO = -(1);
 | 
			
		||||
  Z_STREAM_ERROR = -(2);
 | 
			
		||||
  Z_DATA_ERROR = -(3);
 | 
			
		||||
  Z_MEM_ERROR = -(4);
 | 
			
		||||
  Z_BUF_ERROR = -(5);
 | 
			
		||||
  Z_VERSION_ERROR = -(6);
 | 
			
		||||
 | 
			
		||||
  Z_NO_COMPRESSION = 0;
 | 
			
		||||
  Z_BEST_SPEED = 1;
 | 
			
		||||
  Z_BEST_COMPRESSION = 9;
 | 
			
		||||
  Z_DEFAULT_COMPRESSION = -(1);
 | 
			
		||||
 | 
			
		||||
  Z_FILTERED = 1;
 | 
			
		||||
  Z_HUFFMAN_ONLY = 2;
 | 
			
		||||
  Z_DEFAULT_STRATEGY = 0;
 | 
			
		||||
 | 
			
		||||
  Z_BINARY = 0;
 | 
			
		||||
  Z_ASCII = 1;
 | 
			
		||||
  Z_UNKNOWN = 2;
 | 
			
		||||
 | 
			
		||||
  Z_DEFLATED = 8;
 | 
			
		||||
 | 
			
		||||
  Z_NULL = 0;
 | 
			
		||||
 | 
			
		||||
function zlibVersion:string;
 | 
			
		||||
function deflate(var strm:TZstream; flush:longint):longint;
 | 
			
		||||
function deflateEnd(var strm:TZstream):longint;
 | 
			
		||||
function inflate(var strm:TZstream; flush:longint):longint;
 | 
			
		||||
function inflateEnd(var strm:TZstream):longint;
 | 
			
		||||
function deflateSetDictionary(var strm:TZstream;dictionary : pchar; dictLength:uInt):longint;
 | 
			
		||||
function deflateCopy(var dest,source:TZstream):longint;
 | 
			
		||||
function deflateReset(var strm:TZstream):longint;
 | 
			
		||||
function deflateParams(var strm:TZstream; level:longint; strategy:longint):longint;
 | 
			
		||||
function inflateSetDictionary(var strm:TZStream;dictionary : pchar; dictLength:uInt):longint;
 | 
			
		||||
function inflateSync(var strm:TZStream):longint;
 | 
			
		||||
function inflateReset(var strm:TZStream):longint;
 | 
			
		||||
function compress(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong):longint;
 | 
			
		||||
function compress2(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong; level:longint):longint;
 | 
			
		||||
function uncompress(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong):longint;
 | 
			
		||||
function gzopen(path:pchar; mode:pchar):gzFile;
 | 
			
		||||
function gzsetparams(Thefile:gzFile; level:longint; strategy:longint):longint;
 | 
			
		||||
function gzread(thefile:gzFile; buf : pointer; len:cardinal):longint;
 | 
			
		||||
function gzwrite(thefile:gzFile; buf: pointer; len:cardinal):longint;
 | 
			
		||||
function gzputs(thefile:gzFile; s:pchar):longint;
 | 
			
		||||
function gzgets(thefile:gzFile; buf:pchar; len:longint):pchar;
 | 
			
		||||
function gzputc(thefile:gzFile; c:char):longint;
 | 
			
		||||
function gzgetc(thefile:gzFile):char;
 | 
			
		||||
function gzflush(thefile:gzFile; flush:longint):longint;
 | 
			
		||||
function gzseek(thefile:gzFile; offset:z_off_t; whence:longint):z_off_t;
 | 
			
		||||
function gzrewind(thefile:gzFile):longint;
 | 
			
		||||
function gztell(thefile:gzFile):z_off_t;
 | 
			
		||||
function gzeof(thefile:gzFile):longbool;
 | 
			
		||||
function gzclose(thefile:gzFile):longint;
 | 
			
		||||
function gzerror(thefile:gzFile; var errnum:longint):string;
 | 
			
		||||
function adler32(theadler:uLong;buf : pchar; len:uInt):uLong;
 | 
			
		||||
function crc32(thecrc:uLong;buf : pchar; len:uInt):uLong;
 | 
			
		||||
function deflateInit_(var strm:TZStream; level:longint; version:pchar; stream_size:longint):longint;
 | 
			
		||||
function inflateInit_(var strm:TZStream; version:pchar; stream_size:longint):longint;
 | 
			
		||||
function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;strategy:longint; version:pchar; stream_size:longint):longint;
 | 
			
		||||
function inflateInit2_(var strm:TZStream; windowBits:longint; version:pchar; stream_size:longint):longint;
 | 
			
		||||
function deflateInit(var strm:TZStream;level : longint) : longint;
 | 
			
		||||
function inflateInit(var strm:TZStream) : longint;
 | 
			
		||||
function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
 | 
			
		||||
function inflateInit2(var strm:TZStream; windowBits : longint) : longint;
 | 
			
		||||
function zError(err:longint):string;
 | 
			
		||||
function inflateSyncPoint(z:PZstream):longint;
 | 
			
		||||
function get_crc_table:pointer;
 | 
			
		||||
 | 
			
		||||
implementation
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  zutil,zdeflate,zinflate,zcompres,zuncompr,gzio,adler,crc;
 | 
			
		||||
 | 
			
		||||
function zlibVersion:string;
 | 
			
		||||
begin
 | 
			
		||||
  zlibversion:=zbase.zlibversion;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function deflate(var strm:TZstream; flush:longint):longint;
 | 
			
		||||
begin
 | 
			
		||||
  deflate:=zdeflate.deflate(strm,flush);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function deflateEnd(var strm:TZstream):longint;
 | 
			
		||||
begin
 | 
			
		||||
  deflateEnd:=zdeflate.deflateEnd(strm);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function inflate(var strm:TZstream; flush:longint):longint;
 | 
			
		||||
begin
 | 
			
		||||
  inflate:=zinflate.inflate(strm,flush);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function inflateEnd(var strm:TZstream):longint;
 | 
			
		||||
begin
 | 
			
		||||
  inflateEnd:=zinflate.inflateEnd(strm);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function deflateSetDictionary(var strm:TZstream;dictionary : pchar; dictLength:uInt):longint;
 | 
			
		||||
begin
 | 
			
		||||
  deflateSetDictionary:=zdeflate.deflateSetDictionary(strm,pbytef(dictionary),dictlength);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function deflateCopy(var dest,source:TZstream):longint;
 | 
			
		||||
begin
 | 
			
		||||
  deflateCopy:=zdeflate.deflateCopy(@dest,@source);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function deflateReset(var strm:TZstream):longint;
 | 
			
		||||
begin
 | 
			
		||||
  deflateReset:=zdeflate.deflateReset(strm);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function deflateParams(var strm:TZstream; level:longint; strategy:longint):longint;
 | 
			
		||||
begin
 | 
			
		||||
  deflateParams:=zdeflate.deflateParams(strm,level,strategy);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function inflateSetDictionary(var strm:TZStream;dictionary : pchar; dictLength:uInt):longint;
 | 
			
		||||
begin
 | 
			
		||||
  inflateSetDictionary:=zinflate.inflateSetDictionary(strm,pbytef(dictionary),dictlength);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function inflateSync(var strm:TZStream):longint;
 | 
			
		||||
begin
 | 
			
		||||
  inflateSync:=zinflate.inflateSync(strm);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function inflateReset(var strm:TZStream):longint;
 | 
			
		||||
begin
 | 
			
		||||
  inflateReset:=zinflate.inflateReset(strm);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function compress(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong):longint;
 | 
			
		||||
begin
 | 
			
		||||
  compress:=zcompres.compress(pbytef(dest),destlen,pbytef(source),sourcelen);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function compress2(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong; level:longint):longint;
 | 
			
		||||
begin
 | 
			
		||||
  compress2:=zcompres.compress2(pbytef(dest),destlen,pbytef(source),sourcelen,level);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function uncompress(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong):longint;
 | 
			
		||||
begin
 | 
			
		||||
  uncompress:=zuncompr.uncompress(pbytef(dest),destlen,pbytef(source),sourcelen);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzopen(path:pchar; mode:pchar):gzFile;
 | 
			
		||||
begin
 | 
			
		||||
  gzopen:=gzio.gzopen(path,mode);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzsetparams(Thefile:gzFile; level:longint; strategy:longint):longint;
 | 
			
		||||
begin
 | 
			
		||||
  gzsetparams:=gzio.gzsetparams(thefile,level,strategy);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzread(thefile:gzFile; buf : pointer; len:cardinal):longint;
 | 
			
		||||
begin
 | 
			
		||||
  gzread:=gzio.gzread(thefile,buf,len);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzwrite(thefile:gzFile; buf: pointer; len:cardinal):longint;
 | 
			
		||||
begin
 | 
			
		||||
  gzwrite:=gzio.gzwrite(thefile,buf,len);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzputs(thefile:gzFile; s:pchar):longint;
 | 
			
		||||
begin
 | 
			
		||||
  gzputs:=gzio.gzputs(thefile,s);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzgets(thefile:gzFile; buf:pchar; len:longint):pchar;
 | 
			
		||||
begin
 | 
			
		||||
  gzgets:=gzio.gzgets(thefile,buf,len);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzputc(thefile:gzFile; c:char):longint;
 | 
			
		||||
begin
 | 
			
		||||
  gzputc:=gzio.gzputc(thefile,c);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzgetc(thefile:gzFile):char;
 | 
			
		||||
begin
 | 
			
		||||
  gzgetc:=chr(gzio.gzgetc(thefile));
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzflush(thefile:gzFile; flush:longint):longint;
 | 
			
		||||
begin
 | 
			
		||||
  gzflush:=gzio.gzflush(thefile,flush);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzseek(thefile:gzFile; offset:z_off_t; whence:longint):z_off_t;
 | 
			
		||||
begin
 | 
			
		||||
  gzseek:=gzio.gzseek(thefile,offset,whence);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzrewind(thefile:gzFile):longint;
 | 
			
		||||
begin
 | 
			
		||||
  gzrewind:=gzio.gzrewind(thefile);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gztell(thefile:gzFile):z_off_t;
 | 
			
		||||
begin
 | 
			
		||||
  gztell:=gzio.gztell(thefile);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzeof(thefile:gzFile):longbool;
 | 
			
		||||
begin
 | 
			
		||||
  gzeof:=gzio.gzeof(thefile);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzclose(thefile:gzFile):longint;
 | 
			
		||||
begin
 | 
			
		||||
  gzclose:=gzio.gzclose(thefile);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function gzerror(thefile:gzFile; var errnum:longint):string;
 | 
			
		||||
begin
 | 
			
		||||
  gzerror:=gzio.gzerror(thefile,errnum);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function adler32(theadler:uLong;buf : pchar; len:uInt):uLong;
 | 
			
		||||
begin
 | 
			
		||||
  adler32:=adler.adler32(theadler,pbytef(buf),len);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function crc32(thecrc:uLong;buf : pchar; len:uInt):uLong;
 | 
			
		||||
begin
 | 
			
		||||
  crc32:=crc.crc32(thecrc,pbytef(buf),len);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function deflateInit_(var strm:TZStream; level:longint; version:pchar; stream_size:longint):longint;
 | 
			
		||||
begin
 | 
			
		||||
  deflateInit_:=zdeflate.deflateInit_(@strm,level,version,stream_size);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function inflateInit_(var strm:TZStream; version:pchar; stream_size:longint):longint;
 | 
			
		||||
begin
 | 
			
		||||
  inflateInit_:=zinflate.inflateInit_(@strm,version,stream_size);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;strategy:longint; version:pchar; stream_size:longint):longint;
 | 
			
		||||
begin
 | 
			
		||||
  deflateInit2_:=zdeflate.deflateInit2_(strm,level,method,windowBits,memlevel,strategy,version,stream_size);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function inflateInit2_(var strm:TZStream; windowBits:longint; version:pchar; stream_size:longint):longint;
 | 
			
		||||
begin
 | 
			
		||||
  inflateInit2_:=zinflate.inflateInit2_(strm,windowBits,version,stream_size);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function deflateInit(var strm:TZStream;level : longint) : longint;
 | 
			
		||||
begin
 | 
			
		||||
  deflateInit:=zdeflate.deflateInit(strm,level);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function inflateInit(var strm:TZStream) : longint;
 | 
			
		||||
begin
 | 
			
		||||
  inflateInit:=zinflate.inflateInit(strm);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
 | 
			
		||||
begin
 | 
			
		||||
  deflateInit2:=zdeflate.deflateInit2(strm,level,method,windowbits,memlevel,strategy);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function inflateInit2(var strm:TZStream; windowBits : longint) : longint;
 | 
			
		||||
begin
 | 
			
		||||
  inflateInit2:=zinflate.inflateInit2_(strm,windowBits,ZLIB_VERSION,sizeof(TZStream));
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function zError(err:longint):string;
 | 
			
		||||
begin
 | 
			
		||||
  zerror:=zbase.zerror(err);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function inflateSyncPoint(z:PZstream):longint;
 | 
			
		||||
begin
 | 
			
		||||
  inflateSyncPoint:=zinflate.inflateSyncPoint(z^);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function get_crc_table:pointer;
 | 
			
		||||
begin
 | 
			
		||||
  get_crc_table:=crc.get_crc_table;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
end.
 | 
			
		||||
@ -45,7 +45,7 @@ uses
 | 
			
		||||
  {$ifdef DEBUG}
 | 
			
		||||
  strutils,
 | 
			
		||||
  {$ENDIF}
 | 
			
		||||
  zutil, zlib;
 | 
			
		||||
  zutil, zbase;
 | 
			
		||||
 | 
			
		||||
{ ===========================================================================
 | 
			
		||||
  Internal compression state. }
 | 
			
		||||
@ -319,7 +319,7 @@ function _tr_tally (var s : deflate_state;
 | 
			
		||||
function _tr_flush_block (var s : deflate_state;
 | 
			
		||||
                          buf : pcharf;
 | 
			
		||||
                          stored_len : ulg;
 | 
			
		||||
			  eof : boolean) : ulg;
 | 
			
		||||
                          eof : boolean) : ulg;
 | 
			
		||||
 | 
			
		||||
procedure _tr_align(var s : deflate_state);
 | 
			
		||||
 | 
			
		||||
@ -508,7 +508,7 @@ const
 | 
			
		||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
{ First normalized length for each code (0 = MIN_MATCH) }
 | 
			
		||||
  base_length : array[0..LENGTH_CODES-1] of int = (
 | 
			
		||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
 | 
			
		||||
@ -956,42 +956,42 @@ begin
 | 
			
		||||
  for i := 0 to L_CODES+2-1 do
 | 
			
		||||
  begin
 | 
			
		||||
    WriteLn(header, '((%3u),(%3u))%s', static_ltree[i].Code,
 | 
			
		||||
		static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
 | 
			
		||||
                static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  WriteLn(header, 'local const ct_data static_dtree[D_CODES] := (');
 | 
			
		||||
  for i := 0 to D_CODES-1 do
 | 
			
		||||
  begin
 | 
			
		||||
    WriteLn(header, '((%2u),(%2u))%s', static_dtree[i].Code,
 | 
			
		||||
		static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
 | 
			
		||||
                static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  WriteLn(header, 'const uch _dist_code[DIST_CODE_LEN] := (');
 | 
			
		||||
  for i := 0 to DIST_CODE_LEN-1 do
 | 
			
		||||
  begin
 | 
			
		||||
    WriteLn(header, '%2u%s', _dist_code[i],
 | 
			
		||||
		SEPARATOR(i, DIST_CODE_LEN-1, 20));
 | 
			
		||||
                SEPARATOR(i, DIST_CODE_LEN-1, 20));
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  WriteLn(header, 'const uch _length_code[MAX_MATCH-MIN_MATCH+1]= (');
 | 
			
		||||
  for i := 0 to MAX_MATCH-MIN_MATCH+1-1 do
 | 
			
		||||
  begin
 | 
			
		||||
    WriteLn(header, '%2u%s', _length_code[i],
 | 
			
		||||
		SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
 | 
			
		||||
                SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  WriteLn(header, 'local const int base_length[LENGTH_CODES] := (');
 | 
			
		||||
  for i := 0 to LENGTH_CODES-1 do
 | 
			
		||||
  begin
 | 
			
		||||
    WriteLn(header, '%1u%s', base_length[i],
 | 
			
		||||
		SEPARATOR(i, LENGTH_CODES-1, 20));
 | 
			
		||||
                SEPARATOR(i, LENGTH_CODES-1, 20));
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  WriteLn(header, 'local const int base_dist[D_CODES] := (');
 | 
			
		||||
  for i := 0 to D_CODES-1 do
 | 
			
		||||
  begin
 | 
			
		||||
    WriteLn(header, '%5u%s', base_dist[i],
 | 
			
		||||
		SEPARATOR(i, D_CODES-1, 10));
 | 
			
		||||
                SEPARATOR(i, D_CODES-1, 10));
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  close(header);
 | 
			
		||||
@ -2064,8 +2064,8 @@ begin
 | 
			
		||||
 | 
			
		||||
    {$ifdef DEBUG}
 | 
			
		||||
    Tracev(^M'opt %lu(%lu) stat %lu(%lu) stored %lu lit %u '+
 | 
			
		||||
	    '{opt_lenb, s.opt_len, static_lenb, s.static_len, stored_len,'+
 | 
			
		||||
	    's.last_lit}');
 | 
			
		||||
            '{opt_lenb, s.opt_len, static_lenb, s.static_len, stored_len,'+
 | 
			
		||||
            's.last_lit}');
 | 
			
		||||
    {$ENDIF}
 | 
			
		||||
 | 
			
		||||
    if (static_lenb <= opt_lenb) then
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
Unit Zlib;
 | 
			
		||||
Unit Zbase;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{ Original:
 | 
			
		||||
@ -168,7 +168,7 @@ type
 | 
			
		||||
  check_func = function(check : uLong;
 | 
			
		||||
                        buf : pBytef;
 | 
			
		||||
                        {const buf : array of byte;}
 | 
			
		||||
	                len : uInt) : uLong;
 | 
			
		||||
                        len : uInt) : uLong;
 | 
			
		||||
type
 | 
			
		||||
  inflate_block_mode =
 | 
			
		||||
     (ZTYPE,    { get type bits (3, including end bit) }
 | 
			
		||||
@ -288,10 +288,10 @@ type
 | 
			
		||||
    adler : uLong;        { adler32 value of the uncompressed data }
 | 
			
		||||
    reserved : uLong;     { reserved for future use }
 | 
			
		||||
  end;
 | 
			
		||||
{$ifdef fpc}  
 | 
			
		||||
{$ifdef fpc}
 | 
			
		||||
  TZStream = z_stream;
 | 
			
		||||
  PZStream = ^TZStream;
 | 
			
		||||
{$endif}  
 | 
			
		||||
{$endif}
 | 
			
		||||
 | 
			
		||||
{  The application must update next_in and avail_in when avail_in has
 | 
			
		||||
   dropped to zero. It must update next_out and avail_out when avail_out
 | 
			
		||||
@ -13,14 +13,14 @@ interface
 | 
			
		||||
{$I zconf.inc}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  zutil, zlib, zDeflate;
 | 
			
		||||
  zutil, zbase, zDeflate;
 | 
			
		||||
 | 
			
		||||
                        { utility functions }
 | 
			
		||||
 | 
			
		||||
{EXPORT}
 | 
			
		||||
function compress (dest : pBytef;
 | 
			
		||||
                   var destLen : uLong;
 | 
			
		||||
                   const source : array of Byte;
 | 
			
		||||
                   source : pBytef;
 | 
			
		||||
                   sourceLen : uLong) : int;
 | 
			
		||||
 | 
			
		||||
 { Compresses the source buffer into the destination buffer.  sourceLen is
 | 
			
		||||
@ -37,7 +37,7 @@ function compress (dest : pBytef;
 | 
			
		||||
{EXPORT}
 | 
			
		||||
function compress2 (dest : pBytef;
 | 
			
		||||
                    var destLen : uLong;
 | 
			
		||||
                    const source : array of byte;
 | 
			
		||||
                    source : pBytef;
 | 
			
		||||
                    sourceLen : uLong;
 | 
			
		||||
                    level : int) : int;
 | 
			
		||||
{  Compresses the source buffer into the destination buffer. The level
 | 
			
		||||
@ -56,14 +56,14 @@ implementation
 | 
			
		||||
}
 | 
			
		||||
function compress2 (dest : pBytef;
 | 
			
		||||
                    var destLen : uLong;
 | 
			
		||||
                    const source : array of byte;
 | 
			
		||||
                    source : pbytef;
 | 
			
		||||
                    sourceLen : uLong;
 | 
			
		||||
                    level : int) : int;
 | 
			
		||||
var
 | 
			
		||||
  stream : z_stream;
 | 
			
		||||
  err : int;
 | 
			
		||||
begin
 | 
			
		||||
  stream.next_in := pBytef(@source);
 | 
			
		||||
  stream.next_in := source;
 | 
			
		||||
  stream.avail_in := uInt(sourceLen);
 | 
			
		||||
{$ifdef MAXSEG_64K}
 | 
			
		||||
  { Check for source > 64K on 16-bit machine: }
 | 
			
		||||
@ -112,7 +112,7 @@ end;
 | 
			
		||||
 }
 | 
			
		||||
function compress (dest : pBytef;
 | 
			
		||||
                   var destLen : uLong;
 | 
			
		||||
                   const source : array of Byte;
 | 
			
		||||
                   source : pBytef;
 | 
			
		||||
                   sourceLen : uLong) : int;
 | 
			
		||||
begin
 | 
			
		||||
  compress := compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
 | 
			
		||||
 | 
			
		||||
@ -62,7 +62,7 @@ interface
 | 
			
		||||
{$I zconf.inc}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  zutil, zlib;
 | 
			
		||||
  zutil, zbase;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function deflateInit_(strm : z_streamp;
 | 
			
		||||
@ -180,6 +180,14 @@ function deflateEnd (var strm : z_stream) : int;
 | 
			
		||||
 | 
			
		||||
{ The following functions are needed only in some special applications. }
 | 
			
		||||
 | 
			
		||||
function deflateInit2_(var strm : z_stream;
 | 
			
		||||
                       level : int;
 | 
			
		||||
                       method : int;
 | 
			
		||||
                       windowBits : int;
 | 
			
		||||
                       memLevel : int;
 | 
			
		||||
                       strategy : int;
 | 
			
		||||
                       const version : string;
 | 
			
		||||
                       stream_size : int) : int;
 | 
			
		||||
 | 
			
		||||
{EXPORT}
 | 
			
		||||
function deflateInit2 (var strm : z_stream;
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,7 @@ interface
 | 
			
		||||
{$I zconf.inc}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  zutil, zlib, infblock, infutil;
 | 
			
		||||
  zutil, zbase, infblock, infutil;
 | 
			
		||||
 | 
			
		||||
function inflateInit(var z : z_stream) : int;
 | 
			
		||||
 | 
			
		||||
@ -134,7 +134,7 @@ function inflate(var z : z_stream;
 | 
			
		||||
 | 
			
		||||
     If a preset dictionary is needed at this point (see inflateSetDictionary
 | 
			
		||||
  below), inflate sets strm-adler to the adler32 checksum of the
 | 
			
		||||
  dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise 
 | 
			
		||||
  dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
 | 
			
		||||
  it sets strm->adler to the adler32 checksum of all output produced
 | 
			
		||||
  so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
 | 
			
		||||
  an error code as described below. At the end of the stream, inflate()
 | 
			
		||||
@ -254,7 +254,7 @@ begin
 | 
			
		||||
  { initialize state }
 | 
			
		||||
  { SetLength(strm.msg, 255); }
 | 
			
		||||
  z.msg := '';
 | 
			
		||||
{$ifdef fpc}  
 | 
			
		||||
{$ifdef fpc}
 | 
			
		||||
  if not Assigned(z.zalloc) then
 | 
			
		||||
  begin
 | 
			
		||||
    z.zalloc := @zcalloc;
 | 
			
		||||
@ -262,7 +262,7 @@ begin
 | 
			
		||||
  end;
 | 
			
		||||
  if not Assigned(z.zfree) then
 | 
			
		||||
    z.zfree := @zcfree;
 | 
			
		||||
{$else}    
 | 
			
		||||
{$else}
 | 
			
		||||
  if not Assigned(z.zalloc) then
 | 
			
		||||
  begin
 | 
			
		||||
    z.zalloc := zcalloc;
 | 
			
		||||
@ -529,7 +529,7 @@ begin
 | 
			
		||||
        if ((b and PRESET_DICT) = 0) then
 | 
			
		||||
        begin
 | 
			
		||||
          z.state^.mode := BLOCKS;
 | 
			
		||||
	  continue;      { break C-switch }
 | 
			
		||||
          continue;      { break C-switch }
 | 
			
		||||
        end;
 | 
			
		||||
        z.state^.mode := DICT4;
 | 
			
		||||
        { falltrough }
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,7 @@ interface
 | 
			
		||||
{$I zconf.inc}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  zutil, zlib, zInflate;
 | 
			
		||||
  zutil, zbase, zInflate;
 | 
			
		||||
 | 
			
		||||
{ ===========================================================================
 | 
			
		||||
     Decompresses the source buffer into the destination buffer.  sourceLen is
 | 
			
		||||
@ -33,20 +33,20 @@ uses
 | 
			
		||||
 | 
			
		||||
function uncompress (dest : pBytef;
 | 
			
		||||
                     var destLen : uLong;
 | 
			
		||||
                     const source : array of byte;
 | 
			
		||||
                     source : pBytef;
 | 
			
		||||
                     sourceLen : uLong) : int;
 | 
			
		||||
 | 
			
		||||
implementation
 | 
			
		||||
 | 
			
		||||
function uncompress (dest : pBytef;
 | 
			
		||||
                     var destLen : uLong;
 | 
			
		||||
                     const source : array of byte;
 | 
			
		||||
                     source : pBytef;
 | 
			
		||||
                     sourceLen : uLong) : int;
 | 
			
		||||
var
 | 
			
		||||
  stream : z_stream;
 | 
			
		||||
  err : int;
 | 
			
		||||
begin
 | 
			
		||||
  stream.next_in := pBytef(@source);
 | 
			
		||||
  stream.next_in := source;
 | 
			
		||||
  stream.avail_in := uInt(sourceLen);
 | 
			
		||||
  { Check for source > 64K on 16-bit machine: }
 | 
			
		||||
  if (uLong(stream.avail_in) <> sourceLen) then
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user