mirror of https://github.com/madler/zlib.git
parent
c34c1fcbb1
commit
14763ac7c6
58 changed files with 3773 additions and 588 deletions
@ -0,0 +1,72 @@ |
||||
|
||||
Frequently Asked Questions about zlib |
||||
|
||||
|
||||
If your question is not there, please check the zlib home page |
||||
http://www.cdrom.com/pub/infozip/zlib/ which may have more recent information. |
||||
|
||||
|
||||
1) I need a Windows DLL |
||||
2) I need a Visual Basic interface to zlib |
||||
3) compress() returns Z_BUF_ERROR |
||||
4) deflate or inflate returns Z_BUF_ERROR |
||||
5) Where is the zlib documentation (man pages, etc...)? |
||||
6) Why don't you use GNU autoconf, libtool, etc...? |
||||
7) There is a bug in zlib. |
||||
8) I get "undefined reference to gzputc" |
||||
|
||||
|
||||
|
||||
1) I need a Windows DLL |
||||
|
||||
The zlib sources can be compiled without change to produce a DLL. |
||||
If you want a precompiled DLL, see http://www.winimage.com/zLibDll |
||||
|
||||
|
||||
2) I need a Visual Basic interface to zlib |
||||
|
||||
See http://www.tcfb.com/dowseware/cmp-z-it.zip |
||||
http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm |
||||
and contrib/visual-basic.txt |
||||
|
||||
3) compress() returns Z_BUF_ERROR |
||||
|
||||
Make sure that before the call of compress, the length of the |
||||
compressed buffer is equal to the total size of the compressed buffer |
||||
and not zero. For Visual Basic, check that this parameter is passed |
||||
by reference ("as any"), not by value ("as long"). |
||||
|
||||
|
||||
4) deflate or inflate returns Z_BUF_ERROR |
||||
|
||||
Make sure that before the call avail_in and avail_out are not zero. |
||||
|
||||
|
||||
5) Where is the zlib documentation (man pages, etc...)? |
||||
|
||||
It's in zlib.h for the moment. Volunteers to transform this |
||||
to man pages, please contact jloup@gzip.org. Examples of zlib usage |
||||
are in the files example.c and minigzip.c. |
||||
|
||||
|
||||
6) Why don't you use GNU autoconf, libtool, etc...? |
||||
|
||||
Because we would like to keep zlib as a very small and simple package. |
||||
zlib is rather portable and doesn't need much configuration. |
||||
|
||||
|
||||
7) There is a bug in zlib. |
||||
|
||||
Most of the time, such problems are due to an incorrect usage |
||||
of zlib. Please try to reproduce the problem with a small |
||||
program and send us the corresponding source at zlib@quest.jpl.nasa.gov |
||||
Do not send multi-megabyte data files without prior agreement. |
||||
|
||||
|
||||
8) I get "undefined reference to gzputc" |
||||
|
||||
If "make test" produces something like |
||||
example.o(.text+0x174): |
||||
check that you don't have old files libz.* in /usr/lib, /usr/local/lib |
||||
or /usr/X11R6/lib. Remove old versions then do "make install". |
||||
|
@ -0,0 +1,43 @@ |
||||
This is a patched version of zlib modified to use |
||||
Pentium-optimized assembly code in the deflation algorithm. The files |
||||
changed/added by this patch are: |
||||
|
||||
README.586 |
||||
match.S |
||||
|
||||
The effectiveness of these modifications is a bit marginal, as the the |
||||
program's bottleneck seems to be mostly L1-cache contention, for which |
||||
there is no real way to work around without rewriting the basic |
||||
algorithm. The speedup on average is around 5-10% (which is generally |
||||
less than the amount of variance between subsequent executions). |
||||
However, when used at level 9 compression, the cache contention can |
||||
drop enough for the assembly version to achieve 10-20% speedup (and |
||||
sometimes more, depending on the amount of overall redundancy in the |
||||
files). Even here, though, cache contention can still be the limiting |
||||
factor, depending on the nature of the program using the zlib library. |
||||
This may also mean that better improvements will be seen on a Pentium |
||||
with MMX, which suffers much less from L1-cache contention, but I have |
||||
not yet verified this. |
||||
|
||||
Note that this code has been tailored for the Pentium in particular, |
||||
and will not perform well on the Pentium Pro (due to the use of a |
||||
partial register in the inner loop). |
||||
|
||||
If you are using an assembler other than GNU as, you will have to |
||||
translate match.S to use your assembler's syntax. (Have fun.) |
||||
|
||||
Brian Raiter |
||||
breadbox@muppetlabs.com |
||||
April, 1998 |
||||
|
||||
|
||||
Added for zlib 1.1.3: |
||||
|
||||
The patches come from |
||||
http://www.muppetlabs.com/~breadbox/software/assembly.html |
||||
|
||||
To compile zlib with this asm file, copy match.S to the zlib directory |
||||
then do: |
||||
|
||||
CFLAGS="-O3 -DASMV" ./configure |
||||
make OBJA=match.o |
@ -0,0 +1,354 @@ |
||||
/* match.s -- Pentium-optimized version of longest_match() |
||||
* Written for zlib 1.1.2 |
||||
* Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
|
||||
* |
||||
* This is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License. |
||||
*/ |
||||
|
||||
#ifndef NO_UNDERLINE |
||||
#define match_init _match_init |
||||
#define longest_match _longest_match |
||||
#endif |
||||
|
||||
#define MAX_MATCH (258) |
||||
#define MIN_MATCH (3) |
||||
#define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1) |
||||
#define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7) |
||||
|
||||
/* stack frame offsets */ |
||||
|
||||
#define wmask 0 /* local copy of s->wmask */ |
||||
#define window 4 /* local copy of s->window */ |
||||
#define windowbestlen 8 /* s->window + bestlen */ |
||||
#define chainlenscanend 12 /* high word: current chain len */ |
||||
/* low word: last bytes sought */ |
||||
#define scanstart 16 /* first two bytes of string */ |
||||
#define scanalign 20 /* dword-misalignment of string */ |
||||
#define nicematch 24 /* a good enough match size */ |
||||
#define bestlen 28 /* size of best match so far */ |
||||
#define scan 32 /* ptr to string wanting match */ |
||||
|
||||
#define LocalVarsSize (36) |
||||
/* saved ebx 36 */ |
||||
/* saved edi 40 */ |
||||
/* saved esi 44 */ |
||||
/* saved ebp 48 */ |
||||
/* return address 52 */ |
||||
#define deflatestate 56 /* the function arguments */ |
||||
#define curmatch 60 |
||||
|
||||
/* Offsets for fields in the deflate_state structure. These numbers |
||||
* are calculated from the definition of deflate_state, with the |
||||
* assumption that the compiler will dword-align the fields. (Thus, |
||||
* changing the definition of deflate_state could easily cause this |
||||
* program to crash horribly, without so much as a warning at |
||||
* compile time. Sigh.) |
||||
*/ |
||||
#define dsWSize 36 |
||||
#define dsWMask 44 |
||||
#define dsWindow 48 |
||||
#define dsPrev 56 |
||||
#define dsMatchLen 88 |
||||
#define dsPrevMatch 92 |
||||
#define dsStrStart 100 |
||||
#define dsMatchStart 104 |
||||
#define dsLookahead 108 |
||||
#define dsPrevLen 112 |
||||
#define dsMaxChainLen 116 |
||||
#define dsGoodMatch 132 |
||||
#define dsNiceMatch 136 |
||||
|
||||
|
||||
.file "match.S" |
||||
|
||||
.globl match_init, longest_match |
||||
|
||||
.text |
||||
|
||||
/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ |
||||
|
||||
longest_match: |
||||
|
||||
/* Save registers that the compiler may be using, and adjust %esp to */ |
||||
/* make room for our stack frame. */ |
||||
|
||||
pushl %ebp |
||||
pushl %edi |
||||
pushl %esi |
||||
pushl %ebx |
||||
subl $LocalVarsSize, %esp |
||||
|
||||
/* Retrieve the function arguments. %ecx will hold cur_match */ |
||||
/* throughout the entire function. %edx will hold the pointer to the */ |
||||
/* deflate_state structure during the function's setup (before */ |
||||
/* entering the main loop). */ |
||||
|
||||
movl deflatestate(%esp), %edx |
||||
movl curmatch(%esp), %ecx |
||||
|
||||
/* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */ |
||||
|
||||
movl dsNiceMatch(%edx), %eax |
||||
movl dsLookahead(%edx), %ebx |
||||
cmpl %eax, %ebx |
||||
jl LookaheadLess |
||||
movl %eax, %ebx |
||||
LookaheadLess: movl %ebx, nicematch(%esp) |
||||
|
||||
/* register Bytef *scan = s->window + s->strstart; */ |
||||
|
||||
movl dsWindow(%edx), %esi |
||||
movl %esi, window(%esp) |
||||
movl dsStrStart(%edx), %ebp |
||||
lea (%esi,%ebp), %edi |
||||
movl %edi, scan(%esp) |
||||
|
||||
/* Determine how many bytes the scan ptr is off from being */ |
||||
/* dword-aligned. */ |
||||
|
||||
movl %edi, %eax |
||||
negl %eax |
||||
andl $3, %eax |
||||
movl %eax, scanalign(%esp) |
||||
|
||||
/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */ |
||||
/* s->strstart - (IPos)MAX_DIST(s) : NIL; */ |
||||
|
||||
movl dsWSize(%edx), %eax |
||||
subl $MIN_LOOKAHEAD, %eax |
||||
subl %eax, %ebp |
||||
jg LimitPositive |
||||
xorl %ebp, %ebp |
||||
LimitPositive: |
||||
|
||||
/* unsigned chain_length = s->max_chain_length; */ |
||||
/* if (s->prev_length >= s->good_match) { */ |
||||
/* chain_length >>= 2; */ |
||||
/* } */ |
||||
|
||||
movl dsPrevLen(%edx), %eax |
||||
movl dsGoodMatch(%edx), %ebx |
||||
cmpl %ebx, %eax |
||||
movl dsMaxChainLen(%edx), %ebx |
||||
jl LastMatchGood |
||||
shrl $2, %ebx |
||||
LastMatchGood: |
||||
|
||||
/* chainlen is decremented once beforehand so that the function can */ |
||||
/* use the sign flag instead of the zero flag for the exit test. */ |
||||
/* It is then shifted into the high word, to make room for the scanend */ |
||||
/* scanend value, which it will always accompany. */ |
||||
|
||||
decl %ebx |
||||
shll $16, %ebx |
||||
|
||||
/* int best_len = s->prev_length; */ |
||||
|
||||
movl dsPrevLen(%edx), %eax |
||||
movl %eax, bestlen(%esp) |
||||
|
||||
/* Store the sum of s->window + best_len in %esi locally, and in %esi. */ |
||||
|
||||
addl %eax, %esi |
||||
movl %esi, windowbestlen(%esp) |
||||
|
||||
/* register ush scan_start = *(ushf*)scan; */ |
||||
/* register ush scan_end = *(ushf*)(scan+best_len-1); */ |
||||
|
||||
movw (%edi), %bx |
||||
movw %bx, scanstart(%esp) |
||||
movw -1(%edi,%eax), %bx |
||||
movl %ebx, chainlenscanend(%esp) |
||||
|
||||
/* Posf *prev = s->prev; */ |
||||
/* uInt wmask = s->w_mask; */ |
||||
|
||||
movl dsPrev(%edx), %edi |
||||
movl dsWMask(%edx), %edx |
||||
mov %edx, wmask(%esp) |
||||
|
||||
/* Jump into the main loop. */ |
||||
|
||||
jmp LoopEntry |
||||
|
||||
.balign 16
|
||||
|
||||
/* do { |
||||
* match = s->window + cur_match;
|
||||
* if (*(ushf*)(match+best_len-1) != scan_end || |
||||
* *(ushf*)match != scan_start) continue;
|
||||
* [...] |
||||
* } while ((cur_match = prev[cur_match & wmask]) > limit |
||||
* && --chain_length != 0);
|
||||
* |
||||
* Here is the inner loop of the function. The function will spend the |
||||
* majority of its time in this loop, and majority of that time will |
||||
* be spent in the first ten instructions. |
||||
* |
||||
* Within this loop: |
||||
* %ebx = chainlenscanend - i.e., ((chainlen << 16) | scanend) |
||||
* %ecx = curmatch |
||||
* %edx = curmatch & wmask |
||||
* %esi = windowbestlen - i.e., (window + bestlen) |
||||
* %edi = prev |
||||
* %ebp = limit |
||||
* |
||||
* Two optimization notes on the choice of instructions: |
||||
* |
||||
* The first instruction uses a 16-bit address, which costs an extra, |
||||
* unpairable cycle. This is cheaper than doing a 32-bit access and |
||||
* zeroing the high word, due to the 3-cycle misalignment penalty which |
||||
* would occur half the time. This also turns out to be cheaper than |
||||
* doing two separate 8-bit accesses, as the memory is so rarely in the |
||||
* L1 cache. |
||||
* |
||||
* The window buffer, however, apparently spends a lot of time in the |
||||
* cache, and so it is faster to retrieve the word at the end of the |
||||
* match string with two 8-bit loads. The instructions that test the |
||||
* word at the beginning of the match string, however, are executed |
||||
* much less frequently, and there it was cheaper to use 16-bit |
||||
* instructions, which avoided the necessity of saving off and |
||||
* subsequently reloading one of the other registers. |
||||
*/ |
||||
LookupLoop: |
||||
/* 1 U & V */ |
||||
movw (%edi,%edx,2), %cx /* 2 U pipe */ |
||||
movl wmask(%esp), %edx /* 2 V pipe */ |
||||
cmpl %ebp, %ecx /* 3 U pipe */ |
||||
jbe LeaveNow /* 3 V pipe */ |
||||
subl $0x00010000, %ebx /* 4 U pipe */ |
||||
js LeaveNow /* 4 V pipe */ |
||||
LoopEntry: movb -1(%esi,%ecx), %al /* 5 U pipe */ |
||||
andl %ecx, %edx /* 5 V pipe */ |
||||
cmpb %bl, %al /* 6 U pipe */ |
||||
jnz LookupLoop /* 6 V pipe */ |
||||
movb (%esi,%ecx), %ah |
||||
cmpb %bh, %ah |
||||
jnz LookupLoop |
||||
movl window(%esp), %eax |
||||
movw (%eax,%ecx), %ax |
||||
cmpw scanstart(%esp), %ax |
||||
jnz LookupLoop |
||||
|
||||
/* Store the current value of chainlen. */ |
||||
|
||||
movl %ebx, chainlenscanend(%esp) |
||||
|
||||
/* Point %edi to the string under scrutiny, and %esi to the string we */ |
||||
/* are hoping to match it up with. In actuality, %esi and %edi are */ |
||||
/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */ |
||||
/* initialized to -(MAX_MATCH_8 - scanalign). */ |
||||
|
||||
movl window(%esp), %esi |
||||
movl scan(%esp), %edi |
||||
addl %ecx, %esi |
||||
movl scanalign(%esp), %eax |
||||
movl $(-MAX_MATCH_8), %edx |
||||
lea MAX_MATCH_8(%edi,%eax), %edi |
||||
lea MAX_MATCH_8(%esi,%eax), %esi |
||||
|
||||
/* Test the strings for equality, 8 bytes at a time. At the end, |
||||
* adjust %edx so that it is offset to the exact byte that mismatched. |
||||
* |
||||
* We already know at this point that the first three bytes of the |
||||
* strings match each other, and they can be safely passed over before |
||||
* starting the compare loop. So what this code does is skip over 0-3 |
||||
* bytes, as much as necessary in order to dword-align the %edi |
||||
* pointer. (%esi will still be misaligned three times out of four.) |
||||
* |
||||
* It should be confessed that this loop usually does not represent |
||||
* much of the total running time. Replacing it with a more |
||||
* straightforward "rep cmpsb" would not drastically degrade |
||||
* performance. |
||||
*/ |
||||
LoopCmps: |
||||
movl (%esi,%edx), %eax |
||||
movl (%edi,%edx), %ebx |
||||
xorl %ebx, %eax |
||||
jnz LeaveLoopCmps |
||||
movl 4(%esi,%edx), %eax |
||||
movl 4(%edi,%edx), %ebx |
||||
xorl %ebx, %eax |
||||
jnz LeaveLoopCmps4 |
||||
addl $8, %edx |
||||
jnz LoopCmps |
||||
jmp LenMaximum |
||||
LeaveLoopCmps4: addl $4, %edx |
||||
LeaveLoopCmps: testl $0x0000FFFF, %eax |
||||
jnz LenLower |
||||
addl $2, %edx |
||||
shrl $16, %eax |
||||
LenLower: subb $1, %al |
||||
adcl $0, %edx |
||||
|
||||
/* Calculate the length of the match. If it is longer than MAX_MATCH, */ |
||||
/* then automatically accept it as the best possible match and leave. */ |
||||
|
||||
lea (%edi,%edx), %eax |
||||
movl scan(%esp), %edi |
||||
subl %edi, %eax |
||||
cmpl $MAX_MATCH, %eax |
||||
jge LenMaximum |
||||
|
||||
/* If the length of the match is not longer than the best match we */ |
||||
/* have so far, then forget it and return to the lookup loop. */ |
||||
|
||||
movl deflatestate(%esp), %edx |
||||
movl bestlen(%esp), %ebx |
||||
cmpl %ebx, %eax |
||||
jg LongerMatch |
||||
movl chainlenscanend(%esp), %ebx |
||||
movl windowbestlen(%esp), %esi |
||||
movl dsPrev(%edx), %edi |
||||
movl wmask(%esp), %edx |
||||
andl %ecx, %edx |
||||
jmp LookupLoop |
||||
|
||||
/* s->match_start = cur_match; */ |
||||
/* best_len = len; */ |
||||
/* if (len >= nice_match) break; */ |
||||
/* scan_end = *(ushf*)(scan+best_len-1); */ |
||||
|
||||
LongerMatch: movl nicematch(%esp), %ebx |
||||
movl %eax, bestlen(%esp) |
||||
movl %ecx, dsMatchStart(%edx) |
||||
cmpl %ebx, %eax |
||||
jge LeaveNow |
||||
movl window(%esp), %esi |
||||
addl %eax, %esi |
||||
movl %esi, windowbestlen(%esp) |
||||
movl chainlenscanend(%esp), %ebx |
||||
movw -1(%edi,%eax), %bx |
||||
movl dsPrev(%edx), %edi |
||||
movl %ebx, chainlenscanend(%esp) |
||||
movl wmask(%esp), %edx |
||||
andl %ecx, %edx |
||||
jmp LookupLoop |
||||
|
||||
/* Accept the current string, with the maximum possible length. */ |
||||
|
||||
LenMaximum: movl deflatestate(%esp), %edx |
||||
movl $MAX_MATCH, bestlen(%esp) |
||||
movl %ecx, dsMatchStart(%edx) |
||||
|
||||
/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */ |
||||
/* return s->lookahead; */ |
||||
|
||||
LeaveNow: |
||||
movl deflatestate(%esp), %edx |
||||
movl bestlen(%esp), %ebx |
||||
movl dsLookahead(%edx), %eax |
||||
cmpl %eax, %ebx |
||||
jg LookaheadRet |
||||
movl %ebx, %eax |
||||
LookaheadRet: |
||||
|
||||
/* Restore the stack and return from whence we came. */ |
||||
|
||||
addl $LocalVarsSize, %esp |
||||
popl %ebx |
||||
popl %esi |
||||
popl %edi |
||||
popl %ebp |
||||
match_init: ret |
@ -0,0 +1,34 @@ |
||||
This is a patched version of zlib, modified to use |
||||
Pentium-Pro-optimized assembly code in the deflation algorithm. The |
||||
files changed/added by this patch are: |
||||
|
||||
README.686 |
||||
match.S |
||||
|
||||
The speedup that this patch provides varies, depending on whether the |
||||
compiler used to build the original version of zlib falls afoul of the |
||||
PPro's speed traps. My own tests show a speedup of around 10-20% at |
||||
the default compression level, and 20-30% using -9, against a version |
||||
compiled using gcc 2.7.2.3. Your mileage may vary. |
||||
|
||||
Note that this code has been tailored for the PPro/PII in particular, |
||||
and will not perform particuarly well on a Pentium. |
||||
|
||||
If you are using an assembler other than GNU as, you will have to |
||||
translate match.S to use your assembler's syntax. (Have fun.) |
||||
|
||||
Brian Raiter |
||||
breadbox@muppetlabs.com |
||||
April, 1998 |
||||
|
||||
|
||||
Added for zlib 1.1.3: |
||||
|
||||
The patches come from |
||||
http://www.muppetlabs.com/~breadbox/software/assembly.html |
||||
|
||||
To compile zlib with this asm file, copy match.S to the zlib directory |
||||
then do: |
||||
|
||||
CFLAGS="-O3 -DASMV" ./configure |
||||
make OBJA=match.o |
@ -0,0 +1,327 @@ |
||||
/* match.s -- Pentium-Pro-optimized version of longest_match() |
||||
* Written for zlib 1.1.2 |
||||
* Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
|
||||
* |
||||
* This is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License. |
||||
*/ |
||||
|
||||
#ifndef NO_UNDERLINE |
||||
#define match_init _match_init |
||||
#define longest_match _longest_match |
||||
#endif |
||||
|
||||
#define MAX_MATCH (258) |
||||
#define MIN_MATCH (3) |
||||
#define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1) |
||||
#define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7) |
||||
|
||||
/* stack frame offsets */ |
||||
|
||||
#define chainlenwmask 0 /* high word: current chain len */ |
||||
/* low word: s->wmask */ |
||||
#define window 4 /* local copy of s->window */ |
||||
#define windowbestlen 8 /* s->window + bestlen */ |
||||
#define scanstart 16 /* first two bytes of string */ |
||||
#define scanend 12 /* last two bytes of string */ |
||||
#define scanalign 20 /* dword-misalignment of string */ |
||||
#define nicematch 24 /* a good enough match size */ |
||||
#define bestlen 28 /* size of best match so far */ |
||||
#define scan 32 /* ptr to string wanting match */ |
||||
|
||||
#define LocalVarsSize (36) |
||||
/* saved ebx 36 */ |
||||
/* saved edi 40 */ |
||||
/* saved esi 44 */ |
||||
/* saved ebp 48 */ |
||||
/* return address 52 */ |
||||
#define deflatestate 56 /* the function arguments */ |
||||
#define curmatch 60 |
||||
|
||||
/* Offsets for fields in the deflate_state structure. These numbers |
||||
* are calculated from the definition of deflate_state, with the |
||||
* assumption that the compiler will dword-align the fields. (Thus, |
||||
* changing the definition of deflate_state could easily cause this |
||||
* program to crash horribly, without so much as a warning at |
||||
* compile time. Sigh.) |
||||
*/ |
||||
#define dsWSize 36 |
||||
#define dsWMask 44 |
||||
#define dsWindow 48 |
||||
#define dsPrev 56 |
||||
#define dsMatchLen 88 |
||||
#define dsPrevMatch 92 |
||||
#define dsStrStart 100 |
||||
#define dsMatchStart 104 |
||||
#define dsLookahead 108 |
||||
#define dsPrevLen 112 |
||||
#define dsMaxChainLen 116 |
||||
#define dsGoodMatch 132 |
||||
#define dsNiceMatch 136 |
||||
|
||||
|
||||
.file "match.S" |
||||
|
||||
.globl match_init, longest_match |
||||
|
||||
.text |
||||
|
||||
/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ |
||||
|
||||
longest_match: |
||||
|
||||
/* Save registers that the compiler may be using, and adjust %esp to */ |
||||
/* make room for our stack frame. */ |
||||
|
||||
pushl %ebp |
||||
pushl %edi |
||||
pushl %esi |
||||
pushl %ebx |
||||
subl $LocalVarsSize, %esp |
||||
|
||||
/* Retrieve the function arguments. %ecx will hold cur_match */ |
||||
/* throughout the entire function. %edx will hold the pointer to the */ |
||||
/* deflate_state structure during the function's setup (before */ |
||||
/* entering the main loop). */ |
||||
|
||||
movl deflatestate(%esp), %edx |
||||
movl curmatch(%esp), %ecx |
||||
|
||||
/* uInt wmask = s->w_mask; */ |
||||
/* unsigned chain_length = s->max_chain_length; */ |
||||
/* if (s->prev_length >= s->good_match) { */ |
||||
/* chain_length >>= 2; */ |
||||
/* } */ |
||||
|
||||
movl dsPrevLen(%edx), %eax |
||||
movl dsGoodMatch(%edx), %ebx |
||||
cmpl %ebx, %eax |
||||
movl dsWMask(%edx), %eax |
||||
movl dsMaxChainLen(%edx), %ebx |
||||
jl LastMatchGood |
||||
shrl $2, %ebx |
||||
LastMatchGood: |
||||
|
||||
/* chainlen is decremented once beforehand so that the function can */ |
||||
/* use the sign flag instead of the zero flag for the exit test. */ |
||||
/* It is then shifted into the high word, to make room for the wmask */ |
||||
/* value, which it will always accompany. */ |
||||
|
||||
decl %ebx |
||||
shll $16, %ebx |
||||
orl %eax, %ebx |
||||
movl %ebx, chainlenwmask(%esp) |
||||
|
||||
/* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */ |
||||
|
||||
movl dsNiceMatch(%edx), %eax |
||||
movl dsLookahead(%edx), %ebx |
||||
cmpl %eax, %ebx |
||||
jl LookaheadLess |
||||
movl %eax, %ebx |
||||
LookaheadLess: movl %ebx, nicematch(%esp) |
||||
|
||||
/* register Bytef *scan = s->window + s->strstart; */ |
||||
|
||||
movl dsWindow(%edx), %esi |
||||
movl %esi, window(%esp) |
||||
movl dsStrStart(%edx), %ebp |
||||
lea (%esi,%ebp), %edi |
||||
movl %edi, scan(%esp) |
||||
|
||||
/* Determine how many bytes the scan ptr is off from being */ |
||||
/* dword-aligned. */ |
||||
|
||||
movl %edi, %eax |
||||
negl %eax |
||||
andl $3, %eax |
||||
movl %eax, scanalign(%esp) |
||||
|
||||
/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */ |
||||
/* s->strstart - (IPos)MAX_DIST(s) : NIL; */ |
||||
|
||||
movl dsWSize(%edx), %eax |
||||
subl $MIN_LOOKAHEAD, %eax |
||||
subl %eax, %ebp |
||||
jg LimitPositive |
||||
xorl %ebp, %ebp |
||||
LimitPositive: |
||||
|
||||
/* int best_len = s->prev_length; */ |
||||
|
||||
movl dsPrevLen(%edx), %eax |
||||
movl %eax, bestlen(%esp) |
||||
|
||||
/* Store the sum of s->window + best_len in %esi locally, and in %esi. */ |
||||
|
||||
addl %eax, %esi |
||||
movl %esi, windowbestlen(%esp) |
||||
|
||||
/* register ush scan_start = *(ushf*)scan; */ |
||||
/* register ush scan_end = *(ushf*)(scan+best_len-1); */ |
||||
/* Posf *prev = s->prev; */ |
||||
|
||||
movzwl (%edi), %ebx |
||||
movl %ebx, scanstart(%esp) |
||||
movzwl -1(%edi,%eax), %ebx |
||||
movl %ebx, scanend(%esp) |
||||
movl dsPrev(%edx), %edi |
||||
|
||||
/* Jump into the main loop. */ |
||||
|
||||
movl chainlenwmask(%esp), %edx |
||||
jmp LoopEntry |
||||
|
||||
.balign 16
|
||||
|
||||
/* do { |
||||
* match = s->window + cur_match;
|
||||
* if (*(ushf*)(match+best_len-1) != scan_end || |
||||
* *(ushf*)match != scan_start) continue;
|
||||
* [...] |
||||
* } while ((cur_match = prev[cur_match & wmask]) > limit |
||||
* && --chain_length != 0);
|
||||
* |
||||
* Here is the inner loop of the function. The function will spend the |
||||
* majority of its time in this loop, and majority of that time will |
||||
* be spent in the first ten instructions. |
||||
* |
||||
* Within this loop: |
||||
* %ebx = scanend |
||||
* %ecx = curmatch |
||||
* %edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) |
||||
* %esi = windowbestlen - i.e., (window + bestlen) |
||||
* %edi = prev |
||||
* %ebp = limit |
||||
*/ |
||||
LookupLoop: |
||||
andl %edx, %ecx |
||||
movzwl (%edi,%ecx,2), %ecx |
||||
cmpl %ebp, %ecx |
||||
jbe LeaveNow |
||||
subl $0x00010000, %edx |
||||
js LeaveNow |
||||
LoopEntry: movzwl -1(%esi,%ecx), %eax |
||||
cmpl %ebx, %eax |
||||
jnz LookupLoop |
||||
movl window(%esp), %eax |
||||
movzwl (%eax,%ecx), %eax |
||||
cmpl scanstart(%esp), %eax |
||||
jnz LookupLoop |
||||
|
||||
/* Store the current value of chainlen. */ |
||||
|
||||
movl %edx, chainlenwmask(%esp) |
||||
|
||||
/* Point %edi to the string under scrutiny, and %esi to the string we */ |
||||
/* are hoping to match it up with. In actuality, %esi and %edi are */ |
||||
/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */ |
||||
/* initialized to -(MAX_MATCH_8 - scanalign). */ |
||||
|
||||
movl window(%esp), %esi |
||||
movl scan(%esp), %edi |
||||
addl %ecx, %esi |
||||
movl scanalign(%esp), %eax |
||||
movl $(-MAX_MATCH_8), %edx |
||||
lea MAX_MATCH_8(%edi,%eax), %edi |
||||
lea MAX_MATCH_8(%esi,%eax), %esi |
||||
|
||||
/* Test the strings for equality, 8 bytes at a time. At the end, |
||||
* adjust %edx so that it is offset to the exact byte that mismatched. |
||||
* |
||||
* We already know at this point that the first three bytes of the |
||||
* strings match each other, and they can be safely passed over before |
||||
* starting the compare loop. So what this code does is skip over 0-3 |
||||
* bytes, as much as necessary in order to dword-align the %edi |
||||
* pointer. (%esi will still be misaligned three times out of four.) |
||||
* |
||||
* It should be confessed that this loop usually does not represent |
||||
* much of the total running time. Replacing it with a more |
||||
* straightforward "rep cmpsb" would not drastically degrade |
||||
* performance. |
||||
*/ |
||||
LoopCmps: |
||||
movl (%esi,%edx), %eax |
||||
xorl (%edi,%edx), %eax |
||||
jnz LeaveLoopCmps |
||||
movl 4(%esi,%edx), %eax |
||||
xorl 4(%edi,%edx), %eax |
||||
jnz LeaveLoopCmps4 |
||||
addl $8, %edx |
||||
jnz LoopCmps |
||||
jmp LenMaximum |
||||
LeaveLoopCmps4: addl $4, %edx |
||||
LeaveLoopCmps: testl $0x0000FFFF, %eax |
||||
jnz LenLower |
||||
addl $2, %edx |
||||
shrl $16, %eax |
||||
LenLower: subb $1, %al |
||||
adcl $0, %edx |
||||
|
||||
/* Calculate the length of the match. If it is longer than MAX_MATCH, */ |
||||
/* then automatically accept it as the best possible match and leave. */ |
||||
|
||||
lea (%edi,%edx), %eax |
||||
movl scan(%esp), %edi |
||||
subl %edi, %eax |
||||
cmpl $MAX_MATCH, %eax |
||||
jge LenMaximum |
||||
|
||||
/* If the length of the match is not longer than the best match we */ |
||||
/* have so far, then forget it and return to the lookup loop. */ |
||||
|
||||
movl deflatestate(%esp), %edx |
||||
movl bestlen(%esp), %ebx |
||||
cmpl %ebx, %eax |
||||
jg LongerMatch |
||||
movl windowbestlen(%esp), %esi |
||||
movl dsPrev(%edx), %edi |
||||
movl scanend(%esp), %ebx |
||||
movl chainlenwmask(%esp), %edx |
||||
jmp LookupLoop |
||||
|
||||
/* s->match_start = cur_match; */ |
||||
/* best_len = len; */ |
||||
/* if (len >= nice_match) break; */ |
||||
/* scan_end = *(ushf*)(scan+best_len-1); */ |
||||
|
||||
LongerMatch: movl nicematch(%esp), %ebx |
||||
movl %eax, bestlen(%esp) |
||||
movl %ecx, dsMatchStart(%edx) |
||||
cmpl %ebx, %eax |
||||
jge LeaveNow |
||||
movl window(%esp), %esi |
||||
addl %eax, %esi |
||||
movl %esi, windowbestlen(%esp) |
||||
movzwl -1(%edi,%eax), %ebx |
||||
movl dsPrev(%edx), %edi |
||||
movl %ebx, scanend(%esp) |
||||
movl chainlenwmask(%esp), %edx |
||||
jmp LookupLoop |
||||
|
||||
/* Accept the current string, with the maximum possible length. */ |
||||
|
||||
LenMaximum: movl deflatestate(%esp), %edx |
||||
movl $MAX_MATCH, bestlen(%esp) |
||||
movl %ecx, dsMatchStart(%edx) |
||||
|
||||
/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */ |
||||
/* return s->lookahead; */ |
||||
|
||||
LeaveNow: |
||||
movl deflatestate(%esp), %edx |
||||
movl bestlen(%esp), %ebx |
||||
movl dsLookahead(%edx), %eax |
||||
cmpl %eax, %ebx |
||||
jg LookaheadRet |
||||
movl %ebx, %eax |
||||
LookaheadRet: |
||||
|
||||
/* Restore the stack and return from whence we came. */ |
||||
|
||||
addl $LocalVarsSize, %esp |
||||
popl %ebx |
||||
popl %esi |
||||
popl %edi |
||||
popl %ebp |
||||
match_init: ret |
@ -0,0 +1,36 @@ |
||||
# Makefile for zlib32bd.lib
|
||||
# ------------- Borland C++ 4.5 -------------
|
||||
|
||||
# The (32-bit) zlib32bd.lib made with this makefile is intended for use
|
||||
# in making the (32-bit) DLL, png32bd.dll. It uses the "stdcall" calling
|
||||
# convention.
|
||||
|
||||
CFLAGS= -ps -O2 -C -K -N- -k- -d -3 -r- -w-par -w-aus -WDE
|
||||
CC=f:\bc45\bin\bcc32
|
||||
LIBFLAGS= /C
|
||||
LIB=f:\bc45\bin\tlib
|
||||
ZLIB=zlib32bd.lib
|
||||
|
||||
.autodepend |
||||
.c.obj: |
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
OBJ1=adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj
|
||||
OBJ2=infcodes.obj inflate.obj inftrees.obj infutil.obj inffast.obj
|
||||
OBJ3=trees.obj uncompr.obj zutil.obj
|
||||
pOBJ1=+adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infblock.obj
|
||||
pOBJ2=+infcodes.obj+inflate.obj+inftrees.obj+infutil.obj+inffast.obj
|
||||
pOBJ3=+trees.obj+uncompr.obj+zutil.obj
|
||||
|
||||
all: $(ZLIB) |
||||
|
||||
$(ZLIB): $(OBJ1) $(OBJ2) $(OBJ3) |
||||
@if exist $@ del $@
|
||||
$(LIB) @&&|
|
||||
$@ $(LIBFLAGS) & |
||||
$(pOBJ1) & |
||||
$(pOBJ2) & |
||||
$(pOBJ3) |
||||
| |
||||
|
||||
# End of makefile for zlib32bd.lib
|
@ -0,0 +1,169 @@ |
||||
unit zlibdef; |
||||
|
||||
interface |
||||
|
||||
uses |
||||
Windows; |
||||
|
||||
const |
||||
ZLIB_VERSION = '1.1.3'; |
||||
|
||||
type |
||||
voidpf = Pointer; |
||||
int = Integer; |
||||
uInt = Cardinal; |
||||
pBytef = PChar; |
||||
uLong = Cardinal; |
||||
|
||||
alloc_func = function(opaque: voidpf; items, size: uInt): voidpf; |
||||
stdcall; |
||||
free_func = procedure(opaque, address: voidpf); |
||||
stdcall; |
||||
|
||||
internal_state = Pointer; |
||||
|
||||
z_streamp = ^z_stream; |
||||
z_stream = packed record |
||||
next_in: pBytef; // next input byte |
||||
avail_in: uInt; // number of bytes available at next_in |
||||
total_in: uLong; // total nb of input bytes read so far |
||||
|
||||
next_out: pBytef; // next output byte should be put there |
||||
avail_out: uInt; // remaining free space at next_out |
||||
total_out: uLong; // total nb of bytes output so far |
||||
|
||||
msg: PChar; // last error message, NULL if no error |
||||
state: internal_state; // not visible by applications |
||||
|
||||
zalloc: alloc_func; // used to allocate the internal state |
||||
zfree: free_func; // used to free the internal state |
||||
opaque: voidpf; // private data object passed to zalloc and zfree |
||||
|
||||
data_type: int; // best guess about the data type: ascii or binary |
||||
adler: uLong; // adler32 value of the uncompressed data |
||||
reserved: uLong; // reserved for future use |
||||
end; |
||||
|
||||
const |
||||
Z_NO_FLUSH = 0; |
||||
Z_SYNC_FLUSH = 2; |
||||
Z_FULL_FLUSH = 3; |
||||
Z_FINISH = 4; |
||||
|
||||
Z_OK = 0; |
||||
Z_STREAM_END = 1; |
||||
|
||||
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; |
||||
|
||||
MAX_MEM_LEVEL = 9; |
||||
|
||||
function adler32(adler: uLong; const buf: pBytef; len: uInt): uLong; |
||||
stdcall; |
||||
function crc32(crc: uLong; const buf: pBytef; len: uInt): uLong; |
||||
stdcall; |
||||
function deflate(strm: z_streamp; flush: int): int; |
||||
stdcall; |
||||
function deflateCopy(dest, source: z_streamp): int; |
||||
stdcall; |
||||
function deflateEnd(strm: z_streamp): int; |
||||
stdcall; |
||||
function deflateInit2_(strm: z_streamp; level, method, |
||||
windowBits, memLevel, strategy: int; |
||||
const version: PChar; stream_size: int): int; |
||||
stdcall; |
||||
function deflateInit_(strm: z_streamp; level: int; |
||||
const version: PChar; stream_size: int): int; |
||||
stdcall; |
||||
function deflateParams(strm: z_streamp; level, strategy: int): int; |
||||
stdcall; |
||||
function deflateReset(strm: z_streamp): int; |
||||
stdcall; |
||||
function deflateSetDictionary(strm: z_streamp; |
||||
const dictionary: pBytef; |
||||
dictLength: uInt): int; |
||||
stdcall; |
||||
function inflate(strm: z_streamp; flush: int): int; |
||||
stdcall; |
||||
function inflateEnd(strm: z_streamp): int; |
||||
stdcall; |
||||
function inflateInit2_(strm: z_streamp; windowBits: int; |
||||
const version: PChar; stream_size: int): int; |
||||
stdcall; |
||||
function inflateInit_(strm: z_streamp; const version: PChar; |
||||
stream_size: int): int; |
||||
stdcall; |
||||
function inflateReset(strm: z_streamp): int; |
||||
stdcall; |
||||
function inflateSetDictionary(strm: z_streamp; |
||||
const dictionary: pBytef; |
||||
dictLength: uInt): int; |
||||
stdcall; |
||||
function inflateSync(strm: z_streamp): int; |
||||
stdcall; |
||||
|
||||
function deflateInit(strm: z_streamp; level: int): int; |
||||
function deflateInit2(strm: z_streamp; level, method, windowBits, |
||||
memLevel, strategy: int): int; |
||||
function inflateInit(strm: z_streamp): int; |
||||
function inflateInit2(strm: z_streamp; windowBits: int): int; |
||||
|
||||
implementation |
||||
|
||||
function deflateInit(strm: z_streamp; level: int): int; |
||||
begin |
||||
Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream)); |
||||
end; |
||||
|
||||
function deflateInit2(strm: z_streamp; level, method, windowBits, |
||||
memLevel, strategy: int): int; |
||||
begin |
||||
Result := deflateInit2_(strm, level, method, windowBits, memLevel, |
||||
strategy, ZLIB_VERSION, sizeof(z_stream)); |
||||
end; |
||||
|
||||
function inflateInit(strm: z_streamp): int; |
||||
begin |
||||
Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream)); |
||||
end; |
||||
|
||||
function inflateInit2(strm: z_streamp; windowBits: int): int; |
||||
begin |
||||
Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, |
||||
sizeof(z_stream)); |
||||
end; |
||||
|
||||
const |
||||
zlibDLL = 'png32bd.dll'; |
||||
|
||||
function adler32; external zlibDLL; |
||||
function crc32; external zlibDLL; |
||||
function deflate; external zlibDLL; |
||||
function deflateCopy; external zlibDLL; |
||||
function deflateEnd; external zlibDLL; |
||||
function deflateInit2_; external zlibDLL; |
||||
function deflateInit_; external zlibDLL; |
||||
function deflateParams; external zlibDLL; |
||||
function deflateReset; external zlibDLL; |
||||
function deflateSetDictionary; external zlibDLL; |
||||
function inflate; external zlibDLL; |
||||
function inflateEnd; external zlibDLL; |
||||
function inflateInit2_; external zlibDLL; |
||||
function inflateInit_; external zlibDLL; |
||||
function inflateReset; external zlibDLL; |
||||
function inflateSetDictionary; external zlibDLL; |
||||
function inflateSync; external zlibDLL; |
||||
|
||||
end. |
@ -0,0 +1,224 @@ |
||||
# --------------------------------------------------------------------------- |
||||
!if !$d(BCB) |
||||
BCB = $(MAKEDIR)\.. |
||||
!endif |
||||
|
||||
# --------------------------------------------------------------------------- |
||||
# IDE SECTION |
||||
# --------------------------------------------------------------------------- |
||||
# The following section of the project makefile is managed by the BCB IDE. |
||||
# It is recommended to use the IDE to change any of the values in this |
||||
# section. |
||||
# --------------------------------------------------------------------------- |
||||
|
||||
VERSION = BCB.03 |
||||
# --------------------------------------------------------------------------- |
||||
PROJECT = d_zlib.lib |
||||
OBJFILES = d_zlib.obj adler32.obj deflate.obj infblock.obj infcodes.obj inffast.obj \ |
||||
inflate.obj inftrees.obj infutil.obj trees.obj |
||||
RESFILES = |
||||
RESDEPEN = $(RESFILES) |
||||
LIBFILES = |
||||
LIBRARIES = VCL35.lib |
||||
SPARELIBS = VCL35.lib |
||||
DEFFILE = |
||||
PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi ibsmp35.bpi bcbsmp35.bpi \ |
||||
dclocx35.bpi QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi DSS35.bpi \ |
||||
NMFAST35.bpi INETDB35.bpi INET35.bpi VCLMID35.bpi |
||||
# --------------------------------------------------------------------------- |
||||
PATHCPP = .; |
||||
PATHASM = .; |
||||
PATHPAS = .; |
||||
PATHRC = .; |
||||
DEBUGLIBPATH = $(BCB)\lib\debug |
||||
RELEASELIBPATH = $(BCB)\lib\release |
||||
# --------------------------------------------------------------------------- |
||||
CFLAG1 = -O2 -Ve -d -k- -vi |
||||
CFLAG2 = -I$(BCB)\include;$(BCB)\include\vcl -H=$(BCB)\lib\vcl35.csm |
||||
CFLAG3 = -ff -pr -5 |
||||
PFLAGS = -U;$(DEBUGLIBPATH) -I$(BCB)\include;$(BCB)\include\vcl -H -W -$I- -v -JPHN -M |
||||
RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl |
||||
AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn |
||||
LFLAGS = |
||||
IFLAGS = -g -Gn |
||||
# --------------------------------------------------------------------------- |
||||
ALLOBJ = c0w32.obj $(OBJFILES) |
||||
ALLRES = $(RESFILES) |
||||
ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib |
||||
# --------------------------------------------------------------------------- |
||||
!!ifdef IDEOPTIONS |
||||
|
||||
[Version Info] |
||||
IncludeVerInfo=0 |
||||
AutoIncBuild=0 |
||||
MajorVer=1 |
||||
MinorVer=0 |
||||
Release=0 |
||||
Build=0 |
||||
Debug=0 |
||||
PreRelease=0 |
||||
Special=0 |
||||
Private=0 |
||||
DLL=0 |
||||
Locale=1040 |
||||
CodePage=1252 |
||||
|
||||
[Version Info Keys] |
||||
CompanyName= |
||||
FileDescription= |
||||
FileVersion=1.0.0.0 |
||||
InternalName= |
||||
LegalCopyright= |
||||
LegalTrademarks= |
||||
OriginalFilename= |
||||
ProductName= |
||||
ProductVersion=1.0.0.0 |
||||
Comments= |
||||
|
||||
[HistoryLists\hlIncludePath] |
||||
Count=2 |
||||
Item0=$(BCB)\include |
||||
Item1=$(BCB)\include;$(BCB)\include\vcl |
||||
|
||||
[HistoryLists\hlLibraryPath] |
||||
Count=1 |
||||
Item0=$(BCB)\lib\obj;$(BCB)\lib |
||||
|
||||
[HistoryLists\hlDebugSourcePath] |
||||
Count=1 |
||||
Item0=$(BCB)\source\vcl |
||||
|
||||
[Debugging] |
||||
DebugSourceDirs= |
||||
|
||||
[Parameters] |
||||
RunParams= |
||||
HostApplication= |
||||
|
||||
!endif |
||||
|
||||
--------------------------------------------------------------------------- |
||||
# MAKE SECTION |
||||
# --------------------------------------------------------------------------- |
||||
# This section of the project file is not used by the BCB IDE. It is for |
||||
# the benefit of building from the command-line using the MAKE utility. |
||||
# --------------------------------------------------------------------------- |
||||
|
||||
.autodepend |
||||
# --------------------------------------------------------------------------- |
||||
!if !$d(BCC32) |
||||
BCC32 = bcc32 |
||||
!endif |
||||
|
||||
!if !$d(DCC32) |
||||
DCC32 = dcc32 |
||||
!endif |
||||
|
||||
!if !$d(TASM32) |
||||
TASM32 = tasm32 |
||||
!endif |
||||
|
||||
!if !$d(LINKER) |
||||
LINKER = TLib |
||||
!endif |
||||
|
||||
!if !$d(BRCC32) |
||||
BRCC32 = brcc32 |
||||
!endif |
||||
# --------------------------------------------------------------------------- |
||||
!if $d(PATHCPP) |
||||
.PATH.CPP = $(PATHCPP) |
||||
.PATH.C = $(PATHCPP) |
||||
!endif |
||||
|
||||
!if $d(PATHPAS) |
||||
.PATH.PAS = $(PATHPAS) |
||||
!endif |
||||
|
||||
!if $d(PATHASM) |
||||
.PATH.ASM = $(PATHASM) |
||||
!endif |
||||
|
||||
!if $d(PATHRC) |
||||
.PATH.RC = $(PATHRC) |
||||
!endif |
||||
# --------------------------------------------------------------------------- |
||||
!ifdef IDEOPTIONS |
||||
|
||||
[Version Info] |
||||
IncludeVerInfo=0 |
||||
AutoIncBuild=0 |
||||
MajorVer=1 |
||||
MinorVer=0 |
||||
Release=0 |
||||
Build=0 |
||||
Debug=0 |
||||
PreRelease=0 |
||||
Special=0 |
||||
Private=0 |
||||
DLL=0 |
||||
Locale=1040 |
||||
CodePage=1252 |
||||
|
||||
[Version Info Keys] |
||||
CompanyName= |
||||
FileDescription= |
||||
FileVersion=1.0.0.0 |
||||
InternalName= |
||||
LegalCopyright= |
||||
LegalTrademarks= |
||||
OriginalFilename= |
||||
ProductName= |
||||
ProductVersion=1.0.0.0 |
||||
Comments= |
||||
|
||||
[HistoryLists\hlIncludePath] |
||||
Count=2 |
||||
Item0=$(BCB)\include;$(BCB)\include\vcl |
||||
Item1=$(BCB)\include |
||||
|
||||
[HistoryLists\hlLibraryPath] |
||||
Count=1 |
||||
Item0=$(BCB)\lib\obj;$(BCB)\lib |
||||
|
||||
[HistoryLists\hlDebugSourcePath] |
||||
Count=1 |
||||
Item0=$(BCB)\source\vcl |
||||
|
||||
[Debugging] |
||||
DebugSourceDirs= |
||||
|
||||
[Parameters] |
||||
RunParams= |
||||
HostApplication= |
||||
|
||||
!endif |
||||
|
||||
$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) |
||||
$(BCB)\BIN\$(LINKER) @&&! |
||||
$(LFLAGS) $(IFLAGS) + |
||||
$(ALLOBJ), + |
||||
$(PROJECT),, + |
||||
$(ALLLIB), + |
||||
$(DEFFILE), + |
||||
$(ALLRES) |
||||
! |
||||
# --------------------------------------------------------------------------- |
||||
.pas.hpp: |
||||
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } |
||||
|
||||
.pas.obj: |
||||
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } |
||||
|
||||
.cpp.obj: |
||||
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } |
||||
|
||||
.c.obj: |
||||
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } |
||||
|
||||
.asm.obj: |
||||
$(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ |
||||
|
||||
.rc.res: |
||||
$(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< |
||||
# --------------------------------------------------------------------------- |
@ -0,0 +1,17 @@ |
||||
#include <condefs.h> |
||||
#pragma hdrstop |
||||
//---------------------------------------------------------------------------
|
||||
USEUNIT("adler32.c"); |
||||
USEUNIT("deflate.c"); |
||||
USEUNIT("infblock.c"); |
||||
USEUNIT("infcodes.c"); |
||||
USEUNIT("inffast.c"); |
||||
USEUNIT("inflate.c"); |
||||
USEUNIT("inftrees.c"); |
||||
USEUNIT("infutil.c"); |
||||
USEUNIT("trees.c"); |
||||
//---------------------------------------------------------------------------
|
||||
#define Library |
||||
|
||||
// To add a file to the library use the Project menu 'Add to Project'.
|
||||
|
@ -0,0 +1,17 @@ |
||||
These are files used to compile zlib under Borland C++ Builder 3. |
||||
|
||||
zlib.bpg is the main project group that can be loaded in the BCB IDE and |
||||
loads all other *.bpr projects |
||||
|
||||
zlib.bpr is a project used to create a static zlib.lib library with C calling |
||||
convention for functions. |
||||
|
||||
zlib32.bpr creates a zlib32.dll dynamic link library with Windows standard |
||||
calling convention. |
||||
|
||||
d_zlib.bpr creates a set of .obj files with register calling convention. |
||||
These files are used by zlib.pas to create a Delphi unit containing zlib. |
||||
The d_zlib.lib file generated isn't useful and can be deleted. |
||||
|
||||
zlib.cpp, zlib32.cpp and d_zlib.cpp are used by the above projects. |
||||
|
@ -0,0 +1,26 @@ |
||||
#------------------------------------------------------------------------------ |
||||
VERSION = BWS.01 |
||||
#------------------------------------------------------------------------------ |
||||
!ifndef ROOT |
||||
ROOT = $(MAKEDIR)\.. |
||||
!endif |
||||
#------------------------------------------------------------------------------ |
||||
MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** |
||||
DCC = $(ROOT)\bin\dcc32.exe $** |
||||
BRCC = $(ROOT)\bin\brcc32.exe $** |
||||
#------------------------------------------------------------------------------ |
||||
PROJECTS = zlib zlib32 d_zlib |
||||
#------------------------------------------------------------------------------ |
||||
default: $(PROJECTS) |
||||
#------------------------------------------------------------------------------ |
||||
|
||||
zlib: zlib.bpr |
||||
$(MAKE) |
||||
|
||||
zlib32: zlib32.bpr |
||||
$(MAKE) |
||||
|
||||
d_zlib: d_zlib.bpr |
||||
$(MAKE) |
||||
|
||||
|
@ -0,0 +1,225 @@ |
||||
# --------------------------------------------------------------------------- |
||||
!if !$d(BCB) |
||||
BCB = $(MAKEDIR)\.. |
||||
!endif |
||||
|
||||
# --------------------------------------------------------------------------- |
||||
# IDE SECTION |
||||
# --------------------------------------------------------------------------- |
||||
# The following section of the project makefile is managed by the BCB IDE. |
||||
# It is recommended to use the IDE to change any of the values in this |
||||
# section. |
||||
# --------------------------------------------------------------------------- |
||||
|
||||
VERSION = BCB.03 |
||||
# --------------------------------------------------------------------------- |
||||
PROJECT = zlib.lib |
||||
OBJFILES = zlib.obj adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj \ |
||||
infcodes.obj inffast.obj inflate.obj inftrees.obj infutil.obj trees.obj \ |
||||
uncompr.obj zutil.obj |
||||
RESFILES = |
||||
RESDEPEN = $(RESFILES) |
||||
LIBFILES = |
||||
LIBRARIES = VCL35.lib |
||||
SPARELIBS = VCL35.lib |
||||
DEFFILE = |
||||
PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi ibsmp35.bpi bcbsmp35.bpi \ |
||||
dclocx35.bpi QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi DSS35.bpi \ |
||||
NMFAST35.bpi INETDB35.bpi INET35.bpi VCLMID35.bpi |
||||
# --------------------------------------------------------------------------- |
||||
PATHCPP = .; |
||||
PATHASM = .; |
||||
PATHPAS = .; |
||||
PATHRC = .; |
||||
DEBUGLIBPATH = $(BCB)\lib\debug |
||||
RELEASELIBPATH = $(BCB)\lib\release |
||||
# --------------------------------------------------------------------------- |
||||
CFLAG1 = -O2 -Ve -d -k- -vi |
||||
CFLAG2 = -I$(BCB)\include;$(BCB)\include\vcl -H=$(BCB)\lib\vcl35.csm |
||||
CFLAG3 = -ff -5 |
||||
PFLAGS = -U;$(DEBUGLIBPATH) -I$(BCB)\include;$(BCB)\include\vcl -H -W -$I- -v -JPHN -M |
||||
RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl |
||||
AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn |
||||
LFLAGS = |
||||
IFLAGS = -g -Gn |
||||
# --------------------------------------------------------------------------- |
||||
ALLOBJ = c0w32.obj $(OBJFILES) |
||||
ALLRES = $(RESFILES) |
||||
ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib |
||||
# --------------------------------------------------------------------------- |
||||
!!ifdef IDEOPTIONS |
||||
|
||||
[Version Info] |
||||
IncludeVerInfo=0 |
||||
AutoIncBuild=0 |
||||
MajorVer=1 |
||||
MinorVer=0 |
||||
Release=0 |
||||
Build=0 |
||||
Debug=0 |
||||
PreRelease=0 |
||||
Special=0 |
||||
Private=0 |
||||
DLL=0 |
||||
Locale=1040 |
||||
CodePage=1252 |
||||
|
||||
[Version Info Keys] |
||||
CompanyName= |
||||
FileDescription= |
||||
FileVersion=1.0.0.0 |
||||
InternalName= |
||||
LegalCopyright= |
||||
LegalTrademarks= |
||||
OriginalFilename= |
||||
ProductName= |
||||
ProductVersion=1.0.0.0 |
||||
Comments= |
||||
|
||||
[HistoryLists\hlIncludePath] |
||||
Count=2 |
||||
Item0=$(BCB)\include |
||||
Item1=$(BCB)\include;$(BCB)\include\vcl |
||||
|
||||
[HistoryLists\hlLibraryPath] |
||||
Count=1 |
||||
Item0=$(BCB)\lib\obj;$(BCB)\lib |
||||
|
||||
[HistoryLists\hlDebugSourcePath] |
||||
Count=1 |
||||
Item0=$(BCB)\source\vcl |
||||
|
||||
[Debugging] |
||||
DebugSourceDirs= |
||||
|
||||
[Parameters] |
||||
RunParams= |
||||
HostApplication= |
||||
|
||||
!endif |
||||
|
||||
--------------------------------------------------------------------------- |
||||
# MAKE SECTION |
||||
# --------------------------------------------------------------------------- |
||||
# This section of the project file is not used by the BCB IDE. It is for |
||||
# the benefit of building from the command-line using the MAKE utility. |
||||
# --------------------------------------------------------------------------- |
||||
|
||||
.autodepend |
||||
# --------------------------------------------------------------------------- |
||||
!if !$d(BCC32) |
||||
BCC32 = bcc32 |
||||
!endif |
||||
|
||||
!if !$d(DCC32) |
||||
DCC32 = dcc32 |
||||
!endif |
||||
|
||||
!if !$d(TASM32) |
||||
TASM32 = tasm32 |
||||
!endif |
||||
|
||||
!if !$d(LINKER) |
||||
LINKER = TLib |
||||
!endif |
||||
|
||||
!if !$d(BRCC32) |
||||
BRCC32 = brcc32 |
||||
!endif |
||||
# --------------------------------------------------------------------------- |
||||
!if $d(PATHCPP) |
||||
.PATH.CPP = $(PATHCPP) |
||||
.PATH.C = $(PATHCPP) |
||||
!endif |
||||
|
||||
!if $d(PATHPAS) |
||||
.PATH.PAS = $(PATHPAS) |
||||
!endif |
||||
|
||||
!if $d(PATHASM) |
||||
.PATH.ASM = $(PATHASM) |
||||
!endif |
||||
|
||||
!if $d(PATHRC) |
||||
.PATH.RC = $(PATHRC) |
||||
!endif |
||||
# --------------------------------------------------------------------------- |
||||
!ifdef IDEOPTIONS |
||||
|
||||
[Version Info] |
||||
IncludeVerInfo=0 |
||||
AutoIncBuild=0 |
||||
MajorVer=1 |
||||
MinorVer=0 |
||||
Release=0 |
||||
Build=0 |
||||
Debug=0 |
||||
PreRelease=0 |
||||
Special=0 |
||||
Private=0 |
||||
DLL=0 |
||||
Locale=1040 |
||||
CodePage=1252 |
||||
|
||||
[Version Info Keys] |
||||
CompanyName= |
||||
FileDescription= |
||||
FileVersion=1.0.0.0 |
||||
InternalName= |
||||
LegalCopyright= |
||||
LegalTrademarks= |
||||
OriginalFilename= |
||||
ProductName= |
||||
ProductVersion=1.0.0.0 |
||||
Comments= |
||||
|
||||
[HistoryLists\hlIncludePath] |
||||
Count=2 |
||||
Item0=$(BCB)\include;$(BCB)\include\vcl |
||||
Item1=$(BCB)\include |
||||
|
||||
[HistoryLists\hlLibraryPath] |
||||
Count=1 |
||||
Item0=$(BCB)\lib\obj;$(BCB)\lib |
||||
|
||||
[HistoryLists\hlDebugSourcePath] |
||||
Count=1 |
||||
Item0=$(BCB)\source\vcl |
||||
|
||||
[Debugging] |
||||
DebugSourceDirs= |
||||
|
||||
[Parameters] |
||||
RunParams= |
||||
HostApplication= |
||||
|
||||
!endif |
||||
|
||||
$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) |
||||
$(BCB)\BIN\$(LINKER) @&&! |
||||
$(LFLAGS) $(IFLAGS) + |
||||
$(ALLOBJ), + |
||||
$(PROJECT),, + |
||||
$(ALLLIB), + |
||||
$(DEFFILE), + |
||||
$(ALLRES) |
||||
! |
||||
# --------------------------------------------------------------------------- |
||||
.pas.hpp: |
||||
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } |
||||
|
||||
.pas.obj: |
||||
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } |
||||
|
||||
.cpp.obj: |
||||
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } |
||||
|
||||
.c.obj: |
||||
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } |
||||
|
||||
.asm.obj: |
||||
$(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ |
||||
|
||||
.rc.res: |
||||
$(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< |
||||
# --------------------------------------------------------------------------- |
@ -0,0 +1,22 @@ |
||||
#include <condefs.h> |
||||
#pragma hdrstop |
||||
//---------------------------------------------------------------------------
|
||||
USEUNIT("adler32.c"); |
||||
USEUNIT("compress.c"); |
||||
USEUNIT("crc32.c"); |
||||
USEUNIT("deflate.c"); |
||||
USEUNIT("gzio.c"); |
||||
USEUNIT("infblock.c"); |
||||
USEUNIT("infcodes.c"); |
||||
USEUNIT("inffast.c"); |
||||
USEUNIT("inflate.c"); |
||||
USEUNIT("inftrees.c"); |
||||
USEUNIT("infutil.c"); |
||||
USEUNIT("trees.c"); |
||||
USEUNIT("uncompr.c"); |
||||
USEUNIT("zutil.c"); |
||||
//---------------------------------------------------------------------------
|
||||
#define Library |
||||
|
||||
// To add a file to the library use the Project menu 'Add to Project'.
|
||||
|
@ -0,0 +1,534 @@ |
||||
{*******************************************************} |
||||
{ } |
||||
{ Delphi Supplemental Components } |
||||
{ ZLIB Data Compression Interface Unit } |
||||
{ } |
||||
{ Copyright (c) 1997 Borland International } |
||||
{ } |
||||
{*******************************************************} |
||||
|
||||
{ Modified for zlib 1.1.3 by Davide Moretti <dave@rimini.com } |
||||
|
||||
unit zlib; |
||||
|
||||
interface |
||||
|
||||
uses Sysutils, Classes; |
||||
|
||||
type |
||||
TAlloc = function (AppData: Pointer; Items, Size: Integer): Pointer; |
||||
TFree = procedure (AppData, Block: Pointer); |
||||
|
||||
// Internal structure. Ignore. |
||||
TZStreamRec = packed record |
||||
next_in: PChar; // next input byte |
||||
avail_in: Integer; // number of bytes available at next_in |
||||
total_in: Integer; // total nb of input bytes read so far |
||||
|
||||
next_out: PChar; // next output byte should be put here |
||||
avail_out: Integer; // remaining free space at next_out |
||||
total_out: Integer; // total nb of bytes output so far |
||||
|
||||
msg: PChar; // last error message, NULL if no error |
||||
internal: Pointer; // not visible by applications |
||||
|
||||
zalloc: TAlloc; // used to allocate the internal state |
||||
zfree: TFree; // used to free the internal state |
||||
AppData: Pointer; // private data object passed to zalloc and zfree |
||||
|
||||
data_type: Integer; // best guess about the data type: ascii or binary |
||||
adler: Integer; // adler32 value of the uncompressed data |
||||
reserved: Integer; // reserved for future use |
||||
end; |
||||
|
||||
// Abstract ancestor class |
||||
TCustomZlibStream = class(TStream) |
||||
private |
||||
FStrm: TStream; |
||||
FStrmPos: Integer; |
||||
FOnProgress: TNotifyEvent; |
||||
FZRec: TZStreamRec; |
||||
FBuffer: array [Word] of Char; |
||||
protected |
||||
procedure Progress(Sender: TObject); dynamic; |
||||
property OnProgress: TNotifyEvent read FOnProgress write FOnProgress; |
||||
constructor Create(Strm: TStream); |
||||
end; |
||||
|
||||
{ TCompressionStream compresses data on the fly as data is written to it, and |
||||
stores the compressed data to another stream. |
||||
|
||||
TCompressionStream is write-only and strictly sequential. Reading from the |
||||
stream will raise an exception. Using Seek to move the stream pointer |
||||
will raise an exception. |
||||
|
||||
Output data is cached internally, written to the output stream only when |
||||
the internal output buffer is full. All pending output data is flushed |
||||
when the stream is destroyed. |
||||
|
||||
The Position property returns the number of uncompressed bytes of |
||||
data that have been written to the stream so far. |
||||
|
||||
CompressionRate returns the on-the-fly percentage by which the original |
||||
data has been compressed: (1 - (CompressedBytes / UncompressedBytes)) * 100 |
||||
If raw data size = 100 and compressed data size = 25, the CompressionRate |
||||
is 75% |
||||
|
||||
The OnProgress event is called each time the output buffer is filled and |
||||
written to the output stream. This is useful for updating a progress |
||||
indicator when you are writing a large chunk of data to the compression |
||||
stream in a single call.} |
||||
|
||||
|
||||
TCompressionLevel = (clNone, clFastest, clDefault, clMax); |
||||
|
||||
TCompressionStream = class(TCustomZlibStream) |
||||
private |
||||
function GetCompressionRate: Single; |
||||
public |
||||
constructor Create(CompressionLevel: TCompressionLevel; Dest: TStream); |
||||
destructor Destroy; override; |
||||
function Read(var Buffer; Count: Longint): Longint; override; |
||||
function Write(const Buffer; Count: Longint): Longint; override; |
||||
function Seek(Offset: Longint; Origin: Word): Longint; override; |
||||
property CompressionRate: Single read GetCompressionRate; |
||||
property OnProgress; |
||||
end; |
||||
|
||||
{ TDecompressionStream decompresses data on the fly as data is read from it. |
||||
|
||||
Compressed data comes from a separate source stream. TDecompressionStream |
||||
is read-only and unidirectional; you can seek forward in the stream, but not |
||||
backwards. The special case of setting the stream position to zero is |
||||
allowed. Seeking forward decompresses data until the requested position in |
||||
the uncompressed data has been reached. Seeking backwards, seeking relative |
||||
to the end of the stream, requesting the size of the stream, and writing to |
||||
the stream will raise an exception. |
||||
|
||||
The Position property returns the number of bytes of uncompressed data that |
||||
have been read from the stream so far. |
||||
|
||||
The OnProgress event is called each time the internal input buffer of |
||||
compressed data is exhausted and the next block is read from the input stream. |
||||
This is useful for updating a progress indicator when you are reading a |
||||
large chunk of data from the decompression stream in a single call.} |
||||
|
||||
TDecompressionStream = class(TCustomZlibStream) |
||||
public |
||||
constructor Create(Source: TStream); |
||||
destructor Destroy; override; |
||||
function Read(var Buffer; Count: Longint): Longint; override; |
||||
function Write(const Buffer; Count: Longint): Longint; override; |
||||
function Seek(Offset: Longint; Origin: Word): Longint; override; |
||||
property OnProgress; |
||||
end; |
||||
|
||||
|
||||
|
||||
{ CompressBuf compresses data, buffer to buffer, in one call. |
||||
In: InBuf = ptr to compressed data |
||||
InBytes = number of bytes in InBuf |
||||
Out: OutBuf = ptr to newly allocated buffer containing decompressed data |
||||
OutBytes = number of bytes in OutBuf } |
||||
procedure CompressBuf(const InBuf: Pointer; InBytes: Integer; |
||||
out OutBuf: Pointer; out OutBytes: Integer); |
||||
|
||||
|
||||
{ DecompressBuf decompresses data, buffer to buffer, in one call. |
||||
In: InBuf = ptr to compressed data |
||||
InBytes = number of bytes in InBuf |
||||
OutEstimate = zero, or est. size of the decompressed data |
||||
Out: OutBuf = ptr to newly allocated buffer containing decompressed data |
||||
OutBytes = number of bytes in OutBuf } |
||||
procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer; |
||||
OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer); |
||||
|
||||
const |
||||
zlib_version = '1.1.3'; |
||||
|
||||
type |
||||
EZlibError = class(Exception); |
||||
ECompressionError = class(EZlibError); |
||||
EDecompressionError = class(EZlibError); |
||||
|
||||
function adler32(adler: Integer; buf: PChar; len: Integer): Integer; |
||||
|
||||
implementation |
||||
|
||||
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_errmsg: array[0..9] of PChar = ( |
||||
'need dictionary', // Z_NEED_DICT (2) |
||||
'stream end', // Z_STREAM_END (1) |
||||
'', // Z_OK (0) |
||||
'file error', // Z_ERRNO (-1) |
||||
'stream error', // Z_STREAM_ERROR (-2) |
||||
'data error', // Z_DATA_ERROR (-3) |
||||
'insufficient memory', // Z_MEM_ERROR (-4) |
||||
'buffer error', // Z_BUF_ERROR (-5) |
||||
'incompatible version', // Z_VERSION_ERROR (-6) |
||||
'' |
||||
); |
||||
|
||||
{$L deflate.obj} |
||||
{$L inflate.obj} |
||||
{$L inftrees.obj} |
||||
{$L trees.obj} |
||||
{$L adler32.obj} |
||||
{$L infblock.obj} |
||||
{$L infcodes.obj} |
||||
{$L infutil.obj} |
||||
{$L inffast.obj} |
||||
|
||||
procedure _tr_init; external; |
||||
procedure _tr_tally; external; |
||||
procedure _tr_flush_block; external; |
||||
procedure _tr_align; external; |
||||
procedure _tr_stored_block; external; |
||||
function adler32; external; |
||||
procedure inflate_blocks_new; external; |
||||
procedure inflate_blocks; external; |
||||
procedure inflate_blocks_reset; external; |
||||
procedure inflate_blocks_free; external; |
||||
procedure inflate_set_dictionary; external; |
||||
procedure inflate_trees_bits; external; |
||||
procedure inflate_trees_dynamic; external; |
||||
procedure inflate_trees_fixed; external; |
||||
procedure inflate_codes_new; external; |
||||
procedure inflate_codes; external; |
||||
procedure inflate_codes_free; external; |
||||
procedure _inflate_mask; external; |
||||
procedure inflate_flush; external; |
||||
procedure inflate_fast; external; |
||||
|
||||
procedure _memset(P: Pointer; B: Byte; count: Integer);cdecl; |
||||
begin |
||||
FillChar(P^, count, B); |
||||
end; |
||||
|
||||
procedure _memcpy(dest, source: Pointer; count: Integer);cdecl; |
||||
begin |
||||
Move(source^, dest^, count); |
||||
end; |
||||
|
||||
|
||||
|
||||
// deflate compresses data |
||||
function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar; |
||||
recsize: Integer): Integer; external; |
||||
function deflate(var strm: TZStreamRec; flush: Integer): Integer; external; |
||||
function deflateEnd(var strm: TZStreamRec): Integer; external; |
||||
|
||||
// inflate decompresses data |
||||
function inflateInit_(var strm: TZStreamRec; version: PChar; |
||||
recsize: Integer): Integer; external; |
||||
function inflate(var strm: TZStreamRec; flush: Integer): Integer; external; |
||||
function inflateEnd(var strm: TZStreamRec): Integer; external; |
||||
function inflateReset(var strm: TZStreamRec): Integer; external; |
||||
|
||||
|
||||
function zcalloc(AppData: Pointer; Items, Size: Integer): Pointer; |
||||
begin |
||||
GetMem(Result, Items*Size); |
||||
end; |
||||
|
||||
procedure zcfree(AppData, Block: Pointer); |
||||
begin |
||||
FreeMem(Block); |
||||
end; |
||||
|
||||
function zlibCheck(code: Integer): Integer; |
||||
begin |
||||
Result := code; |
||||
if code < 0 then |
||||
raise EZlibError.Create('error'); //!! |
||||
end; |
||||
|
||||
function CCheck(code: Integer): Integer; |
||||
begin |
||||
Result := code; |
||||
if code < 0 then |
||||
raise ECompressionError.Create('error'); //!! |
||||
end; |
||||
|
||||
function DCheck(code: Integer): Integer; |
||||
begin |
||||
Result := code; |
||||
if code < 0 then |
||||
raise EDecompressionError.Create('error'); //!! |
||||
end; |
||||
|
||||
procedure CompressBuf(const InBuf: Pointer; InBytes: Integer; |
||||
out OutBuf: Pointer; out OutBytes: Integer); |
||||
var |
||||
strm: TZStreamRec; |
||||
P: Pointer; |
||||
begin |
||||
FillChar(strm, sizeof(strm), 0); |
||||
OutBytes := ((InBytes + (InBytes div 10) + 12) + 255) and not 255; |
||||
GetMem(OutBuf, OutBytes); |
||||
try |
||||
strm.next_in := InBuf; |
||||
strm.avail_in := InBytes; |
||||
strm.next_out := OutBuf; |
||||
strm.avail_out := OutBytes; |
||||
CCheck(deflateInit_(strm, Z_BEST_COMPRESSION, zlib_version, sizeof(strm))); |
||||
try |
||||
while CCheck(deflate(strm, Z_FINISH)) <> Z_STREAM_END do |
||||
begin |
||||
P := OutBuf; |
||||
Inc(OutBytes, 256); |
||||
ReallocMem(OutBuf, OutBytes); |
||||
strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); |
||||
strm.avail_out := 256; |
||||
end; |
||||
finally |
||||
CCheck(deflateEnd(strm)); |
||||
end; |
||||
ReallocMem(OutBuf, strm.total_out); |
||||
OutBytes := strm.total_out; |
||||
except |
||||
FreeMem(OutBuf); |
||||
raise |
||||
end; |
||||
end; |
||||
|
||||
|
||||
procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer; |
||||
OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer); |
||||
var |
||||
strm: TZStreamRec; |
||||
P: Pointer; |
||||
BufInc: Integer; |
||||
begin |
||||
FillChar(strm, sizeof(strm), 0); |
||||
BufInc := (InBytes + 255) and not 255; |
||||
if OutEstimate = 0 then |
||||
OutBytes := BufInc |
||||
else |
||||
OutBytes := OutEstimate; |
||||
GetMem(OutBuf, OutBytes); |
||||
try |
||||
strm.next_in := InBuf; |
||||
strm.avail_in := InBytes; |
||||
strm.next_out := OutBuf; |
||||
strm.avail_out := OutBytes; |
||||
DCheck(inflateInit_(strm, zlib_version, sizeof(strm))); |
||||
try |
||||
while DCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END do |
||||
begin |
||||
P := OutBuf; |
||||
Inc(OutBytes, BufInc); |
||||
ReallocMem(OutBuf, OutBytes); |
||||
strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); |
||||
strm.avail_out := BufInc; |
||||
end; |
||||
finally |
||||
DCheck(inflateEnd(strm)); |
||||
end; |
||||
ReallocMem(OutBuf, strm.total_out); |
||||
OutBytes := strm.total_out; |
||||
except |
||||
FreeMem(OutBuf); |
||||
raise |
||||
end; |
||||
end; |
||||
|
||||
|
||||
// TCustomZlibStream |
||||
|
||||
constructor TCustomZLibStream.Create(Strm: TStream); |
||||
begin |
||||
inherited Create; |
||||
FStrm := Strm; |
||||
FStrmPos := Strm.Position; |
||||
end; |
||||
|
||||
procedure TCustomZLibStream.Progress(Sender: TObject); |
||||
begin |
||||
if Assigned(FOnProgress) then FOnProgress(Sender); |
||||
end; |
||||
|
||||
|
||||
// TCompressionStream |
||||
|
||||
constructor TCompressionStream.Create(CompressionLevel: TCompressionLevel; |
||||
Dest: TStream); |
||||
const |
||||
Levels: array [TCompressionLevel] of ShortInt = |
||||
(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); |
||||
CCheck(deflateInit_(FZRec, Levels[CompressionLevel], zlib_version, sizeof(FZRec))); |
||||
end; |
||||
|
||||
destructor TCompressionStream.Destroy; |
||||
begin |
||||
FZRec.next_in := nil; |
||||
FZRec.avail_in := 0; |
||||
try |
||||
if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; |
||||
while (CCheck(deflate(FZRec, Z_FINISH)) <> Z_STREAM_END) |
||||
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 |
||||
FStrm.WriteBuffer(FBuffer, sizeof(FBuffer) - FZRec.avail_out); |
||||
finally |
||||
deflateEnd(FZRec); |
||||
end; |
||||
inherited Destroy; |
||||
end; |
||||
|
||||
function TCompressionStream.Read(var Buffer; Count: Longint): Longint; |
||||
begin |
||||
raise ECompressionError.Create('Invalid stream operation'); |
||||
end; |
||||
|
||||
function TCompressionStream.Write(const Buffer; Count: Longint): Longint; |
||||
begin |
||||
FZRec.next_in := @Buffer; |
||||
FZRec.avail_in := Count; |
||||
if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; |
||||
while (FZRec.avail_in > 0) do |
||||
begin |
||||
CCheck(deflate(FZRec, 0)); |
||||
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); |
||||
end; |
||||
end; |
||||
Result := Count; |
||||
end; |
||||
|
||||
function TCompressionStream.Seek(Offset: Longint; Origin: Word): Longint; |
||||
begin |
||||
if (Offset = 0) and (Origin = soFromCurrent) then |
||||
Result := FZRec.total_in |
||||
else |
||||
raise ECompressionError.Create('Invalid stream operation'); |
||||
end; |
||||
|
||||
function TCompressionStream.GetCompressionRate: Single; |
||||
begin |
||||
if FZRec.total_in = 0 then |
||||
Result := 0 |
||||
else |
||||
Result := (1.0 - (FZRec.total_out / FZRec.total_in)) * 100.0; |
||||
end; |
||||
|
||||
|
||||
// TDecompressionStream |
||||
|
||||
constructor TDecompressionStream.Create(Source: TStream); |
||||
begin |
||||
inherited Create(Source); |
||||
FZRec.next_in := FBuffer; |
||||
FZRec.avail_in := 0; |
||||
DCheck(inflateInit_(FZRec, zlib_version, sizeof(FZRec))); |
||||
end; |
||||
|
||||
destructor TDecompressionStream.Destroy; |
||||
begin |
||||
inflateEnd(FZRec); |
||||
inherited Destroy; |
||||
end; |
||||
|
||||
function TDecompressionStream.Read(var Buffer; Count: Longint): Longint; |
||||
begin |
||||
FZRec.next_out := @Buffer; |
||||
FZRec.avail_out := Count; |
||||
if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; |
||||
while (FZRec.avail_out > 0) do |
||||
begin |
||||
if FZRec.avail_in = 0 then |
||||
begin |
||||
FZRec.avail_in := FStrm.Read(FBuffer, sizeof(FBuffer)); |
||||
if FZRec.avail_in = 0 then |
||||
begin |
||||
Result := Count - FZRec.avail_out; |
||||
Exit; |
||||
end; |
||||
FZRec.next_in := FBuffer; |
||||
FStrmPos := FStrm.Position; |
||||
Progress(Self); |
||||
end; |
||||
DCheck(inflate(FZRec, 0)); |
||||
end; |
||||
Result := Count; |
||||
end; |
||||
|
||||
function TDecompressionStream.Write(const Buffer; Count: Longint): Longint; |
||||
begin |
||||
raise EDecompressionError.Create('Invalid stream operation'); |
||||
end; |
||||
|
||||
function TDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint; |
||||
var |
||||
I: Integer; |
||||
Buf: array [0..4095] of Char; |
||||
begin |
||||
if (Offset = 0) and (Origin = soFromBeginning) then |
||||
begin |
||||
DCheck(inflateReset(FZRec)); |
||||
FZRec.next_in := FBuffer; |
||||
FZRec.avail_in := 0; |
||||
FStrm.Position := 0; |
||||
FStrmPos := 0; |
||||
end |
||||
else if ( (Offset >= 0) and (Origin = soFromCurrent)) or |
||||
( ((Offset - FZRec.total_out) > 0) and (Origin = soFromBeginning)) then |
||||
begin |
||||
if Origin = soFromBeginning then Dec(Offset, FZRec.total_out); |
||||
if Offset > 0 then |
||||
begin |
||||
for I := 1 to Offset div sizeof(Buf) do |
||||
ReadBuffer(Buf, sizeof(Buf)); |
||||
ReadBuffer(Buf, Offset mod sizeof(Buf)); |
||||
end; |
||||
end |
||||
else |
||||
raise EDecompressionError.Create('Invalid stream operation'); |
||||
Result := FZRec.total_out; |
||||
end; |
||||
|
||||
end. |
@ -0,0 +1,174 @@ |
||||
# --------------------------------------------------------------------------- |
||||
!if !$d(BCB) |
||||
BCB = $(MAKEDIR)\.. |
||||
!endif |
||||
|
||||
# --------------------------------------------------------------------------- |
||||
# IDE SECTION |
||||
# --------------------------------------------------------------------------- |
||||
# The following section of the project makefile is managed by the BCB IDE. |
||||
# It is recommended to use the IDE to change any of the values in this |
||||
# section. |
||||
# --------------------------------------------------------------------------- |
||||
|
||||
VERSION = BCB.03 |
||||
# --------------------------------------------------------------------------- |
||||
PROJECT = zlib32.dll |
||||
OBJFILES = zlib32.obj adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj \ |
||||
infcodes.obj inffast.obj inflate.obj inftrees.obj infutil.obj trees.obj \ |
||||
uncompr.obj zutil.obj |
||||
RESFILES = |
||||
RESDEPEN = $(RESFILES) |
||||
LIBFILES = |
||||
LIBRARIES = |
||||
SPARELIBS = |
||||
DEFFILE = |
||||
PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi ibsmp35.bpi bcbsmp35.bpi \ |
||||
dclocx35.bpi QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi DSS35.bpi \ |
||||
NMFAST35.bpi INETDB35.bpi INET35.bpi VCLMID35.bpi |
||||
# --------------------------------------------------------------------------- |
||||
PATHCPP = .; |
||||
PATHASM = .; |
||||
PATHPAS = .; |
||||
PATHRC = .; |
||||
DEBUGLIBPATH = $(BCB)\lib\debug |
||||
RELEASELIBPATH = $(BCB)\lib\release |
||||
# --------------------------------------------------------------------------- |
||||
CFLAG1 = -WD -O2 -Ve -d -k- -vi -c -tWD |
||||
CFLAG2 = -D_NO_VCL;ZLIB_DLL -I$(BCB)\include |
||||
CFLAG3 = -ff -5 |
||||
PFLAGS = -D_NO_VCL;ZLIB_DLL -U$(BCB)\lib;$(RELEASELIBPATH) -I$(BCB)\include -$I- -v \ |
||||
-JPHN -M |
||||
RFLAGS = -D_NO_VCL;ZLIB_DLL -i$(BCB)\include |
||||
AFLAGS = /i$(BCB)\include /d_NO_VCL /dZLIB_DLL /mx /w2 /zn |
||||
LFLAGS = -L$(BCB)\lib;$(RELEASELIBPATH) -aa -Tpd -x -Gi |
||||
IFLAGS = -Gn -g |
||||
# --------------------------------------------------------------------------- |
||||
ALLOBJ = c0d32.obj $(OBJFILES) |
||||
ALLRES = $(RESFILES) |
||||
ALLLIB = $(LIBFILES) import32.lib cw32mt.lib |
||||
# --------------------------------------------------------------------------- |
||||
!ifdef IDEOPTIONS |
||||
|
||||
[Version Info] |
||||
IncludeVerInfo=0 |
||||
AutoIncBuild=0 |
||||
MajorVer=1 |
||||
MinorVer=0 |
||||
Release=0 |
||||
Build=0 |
||||
Debug=0 |
||||
PreRelease=0 |
||||
Special=0 |
||||
Private=0 |
||||
DLL=1 |
||||
Locale=1040 |
||||
CodePage=1252 |
||||
|
||||
[Version Info Keys] |
||||
CompanyName= |
||||
FileDescription=DLL (GUI) |
||||
FileVersion=1.0.0.0 |
||||
InternalName= |
||||
LegalCopyright= |
||||
LegalTrademarks= |
||||
OriginalFilename= |
||||
ProductName= |
||||
ProductVersion=1.0.0.0 |
||||
Comments= |
||||
|
||||
[HistoryLists\hlIncludePath] |
||||
Count=1 |
||||
Item0=$(BCB)\include |
||||
|
||||
[HistoryLists\hlLibraryPath] |
||||
Count=1 |
||||
Item0=$(BCB)\lib |
||||
|
||||
[HistoryLists\hlConditionals] |
||||
Count=1 |
||||
Item0=_NO_VCL;ZLIB_DLL |
||||
|
||||
[Debugging] |
||||
DebugSourceDirs= |
||||
|
||||
[Parameters] |
||||
RunParams= |
||||
HostApplication= |
||||
|
||||
!endif |
||||
|
||||
# --------------------------------------------------------------------------- |
||||
# MAKE SECTION |
||||
# --------------------------------------------------------------------------- |
||||
# This section of the project file is not used by the BCB IDE. It is for |
||||
# the benefit of building from the command-line using the MAKE utility. |
||||
# --------------------------------------------------------------------------- |
||||
|
||||
.autodepend |
||||
# --------------------------------------------------------------------------- |
||||
!if !$d(BCC32) |
||||
BCC32 = bcc32 |
||||
!endif |
||||
|
||||
!if !$d(DCC32) |
||||
DCC32 = dcc32 |
||||
!endif |
||||
|
||||
!if !$d(TASM32) |
||||
TASM32 = tasm32 |
||||
!endif |
||||
|
||||
!if !$d(LINKER) |
||||
LINKER = ilink32 |
||||
!endif |
||||
|
||||
!if !$d(BRCC32) |
||||
BRCC32 = brcc32 |
||||
!endif |
||||
# --------------------------------------------------------------------------- |
||||
!if $d(PATHCPP) |
||||
.PATH.CPP = $(PATHCPP) |
||||
.PATH.C = $(PATHCPP) |
||||
!endif |
||||
|
||||
!if $d(PATHPAS) |
||||
.PATH.PAS = $(PATHPAS) |
||||
!endif |
||||
|
||||
!if $d(PATHASM) |
||||
.PATH.ASM = $(PATHASM) |
||||
!endif |
||||
|
||||
!if $d(PATHRC) |
||||
.PATH.RC = $(PATHRC) |
||||
!endif |
||||
# --------------------------------------------------------------------------- |
||||
$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) |
||||
$(BCB)\BIN\$(LINKER) @&&! |
||||
$(LFLAGS) $(IFLAGS) + |
||||
$(ALLOBJ), + |
||||
$(PROJECT),, + |
||||
$(ALLLIB), + |
||||
$(DEFFILE), + |
||||
$(ALLRES) |
||||
! |
||||
# --------------------------------------------------------------------------- |
||||
.pas.hpp: |
||||
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } |
||||
|
||||
.pas.obj: |
||||
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } |
||||
|
||||
.cpp.obj: |
||||
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } |
||||
|
||||
.c.obj: |
||||
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } |
||||
|
||||
.asm.obj: |
||||
$(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ |
||||
|
||||
.rc.res: |
||||
$(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< |
||||
# --------------------------------------------------------------------------- |
@ -0,0 +1,42 @@ |
||||
|
||||
#include <windows.h> |
||||
#pragma hdrstop |
||||
#include <condefs.h> |
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Important note about DLL memory management in a VCL DLL:
|
||||
//
|
||||
//
|
||||
//
|
||||
// If your DLL uses VCL and exports any functions that pass VCL String objects
|
||||
// (or structs/classes containing nested Strings) as parameter or function
|
||||
// results, you will need to build both your DLL project and any EXE projects
|
||||
// that use your DLL with the dynamic RTL (the RTL DLL). This will change your
|
||||
// DLL and its calling EXE's to use BORLNDMM.DLL as their memory manager. In
|
||||
// these cases, the file BORLNDMM.DLL should be deployed along with your DLL
|
||||
// and the RTL DLL (CP3240MT.DLL). To avoid the requiring BORLNDMM.DLL in
|
||||
// these situations, pass string information using "char *" or ShortString
|
||||
// parameters and then link with the static RTL.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
USEUNIT("adler32.c"); |
||||
USEUNIT("compress.c"); |
||||
USEUNIT("crc32.c"); |
||||
USEUNIT("deflate.c"); |
||||
USEUNIT("gzio.c"); |
||||
USEUNIT("infblock.c"); |
||||
USEUNIT("infcodes.c"); |
||||
USEUNIT("inffast.c"); |
||||
USEUNIT("inflate.c"); |
||||
USEUNIT("inftrees.c"); |
||||
USEUNIT("infutil.c"); |
||||
USEUNIT("trees.c"); |
||||
USEUNIT("uncompr.c"); |
||||
USEUNIT("zutil.c"); |
||||
//---------------------------------------------------------------------------
|
||||
#pragma argsused |
||||
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) |
||||
{ |
||||
return 1; |
||||
} |
@ -0,0 +1,69 @@ |
||||
# Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98.
|
||||
# Copyright (C) 1995-1998 Jean-loup Gailly.
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
# To compile, or to compile and test, type:
|
||||
#
|
||||
# make -fmakefile.emx; make test -fmakefile.emx
|
||||
#
|
||||
|
||||
CC=gcc
|
||||
|
||||
#CFLAGS=-MMD -O
|
||||
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
||||
#CFLAGS=-MMD -g -DDEBUG
|
||||
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
-Wstrict-prototypes -Wmissing-prototypes
|
||||
|
||||
# If cp.exe is available, replace "copy /Y" with "cp -fp" .
|
||||
CP=copy /Y
|
||||
# If gnu install.exe is available, replace $(CP) with ginstall.
|
||||
INSTALL=$(CP)
|
||||
# The default value of RM is "rm -f." If "rm.exe" is found, comment out:
|
||||
RM=del
|
||||
LDLIBS=-L. -lzlib
|
||||
LD=$(CC) -s -o
|
||||
LDSHARED=$(CC)
|
||||
|
||||
INCL=zlib.h zconf.h
|
||||
LIBS=zlib.a
|
||||
|
||||
AR=ar rcs
|
||||
|
||||
prefix=/usr/local
|
||||
exec_prefix = $(prefix)
|
||||
|
||||
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
|
||||
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
|
||||
|
||||
TEST_OBJS = example.o minigzip.o
|
||||
|
||||
all: example.exe minigzip.exe |
||||
|
||||
test: all |
||||
./example
|
||||
echo hello world | .\minigzip | .\minigzip -d
|
||||
|
||||
%.o : %.c |
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
zlib.a: $(OBJS) |
||||
$(AR) $@ $(OBJS)
|
||||
|
||||
%.exe : %.o $(LIBS) |
||||
$(LD) $@ $< $(LDLIBS)
|
||||
|
||||
|
||||
.PHONY : clean |
||||
|
||||
clean: |
||||
$(RM) *.d
|
||||
$(RM) *.o
|
||||
$(RM) *.exe
|
||||
$(RM) zlib.a
|
||||
$(RM) foo.gz
|
||||
|
||||
DEPS := $(wildcard *.d)
|
||||
ifneq ($(DEPS),) |
||||
include $(DEPS) |
||||
endif |
@ -0,0 +1,138 @@ |
||||
# Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98.
|
||||
# Copyright (C) 1995-1998 Jean-loup Gailly.
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
# To compile, or to compile and test, type:
|
||||
#
|
||||
# make -fmakefile.emx; make test -fmakefile.emx
|
||||
#
|
||||
|
||||
CC=gcc -Zwin32
|
||||
|
||||
#CFLAGS=-MMD -O
|
||||
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
||||
#CFLAGS=-MMD -g -DDEBUG
|
||||
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
-Wstrict-prototypes -Wmissing-prototypes
|
||||
|
||||
# If cp.exe is available, replace "copy /Y" with "cp -fp" .
|
||||
CP=copy /Y
|
||||
# If gnu install.exe is available, replace $(CP) with ginstall.
|
||||
INSTALL=$(CP)
|
||||
# The default value of RM is "rm -f." If "rm.exe" is found, comment out:
|
||||
RM=del
|
||||
LDLIBS=-L. -lzlib
|
||||
LD=$(CC) -s -o
|
||||
LDSHARED=$(CC)
|
||||
|
||||
INCL=zlib.h zconf.h
|
||||
LIBS=zlib.a
|
||||
|
||||
AR=ar rcs
|
||||
|
||||
prefix=/usr/local
|
||||
exec_prefix = $(prefix)
|
||||
|
||||
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
|
||||
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
|
||||
|
||||
TEST_OBJS = example.o minigzip.o
|
||||
|
||||
all: example.exe minigzip.exe |
||||
|
||||
test: all |
||||
./example
|
||||
echo hello world | .\minigzip | .\minigzip -d
|
||||
|
||||
%.o : %.c |
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
zlib.a: $(OBJS) |
||||
$(AR) $@ $(OBJS)
|
||||
|
||||
%.exe : %.o $(LIBS) |
||||
$(LD) $@ $< $(LDLIBS)
|
||||
|
||||
|
||||
.PHONY : clean |
||||
|
||||
clean: |
||||
$(RM) *.d
|
||||
$(RM) *.o
|
||||
$(RM) *.exe
|
||||
$(RM) zlib.a
|
||||
$(RM) foo.gz
|
||||
|
||||
DEPS := $(wildcard *.d)
|
||||
ifneq ($(DEPS),) |
||||
include $(DEPS) |
||||
endif |
||||
# Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98.
|
||||
# Copyright (C) 1995-1998 Jean-loup Gailly.
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
# To compile, or to compile and test, type:
|
||||
#
|
||||
# make -fmakefile.emx; make test -fmakefile.emx
|
||||
#
|
||||
|
||||
CC=gcc
|
||||
|
||||
#CFLAGS=-MMD -O
|
||||
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
||||
#CFLAGS=-MMD -g -DDEBUG
|
||||
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
-Wstrict-prototypes -Wmissing-prototypes
|
||||
|
||||
# If cp.exe is available, replace "copy /Y" with "cp -fp" .
|
||||
CP=copy /Y
|
||||
# If gnu install.exe is available, replace $(CP) with ginstall.
|
||||
INSTALL=$(CP)
|
||||
# The default value of RM is "rm -f." If "rm.exe" is found, comment out:
|
||||
RM=del
|
||||
LDLIBS=-L. -lzlib
|
||||
LD=$(CC) -s -o
|
||||
LDSHARED=$(CC)
|
||||
|
||||
INCL=zlib.h zconf.h
|
||||
LIBS=zlib.a
|
||||
|
||||
AR=ar rcs
|
||||
|
||||
prefix=/usr/local
|
||||
exec_prefix = $(prefix)
|
||||
|
||||
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
|
||||
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
|
||||
|
||||
TEST_OBJS = example.o minigzip.o
|
||||
|
||||
all: example.exe minigzip.exe |
||||
|
||||
test: all |
||||
./example
|
||||
echo hello world | .\minigzip | .\minigzip -d
|
||||
|
||||
%.o : %.c |
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
zlib.a: $(OBJS) |
||||
$(AR) $@ $(OBJS)
|
||||
|
||||
%.exe : %.o $(LIBS) |
||||
$(LD) $@ $< $(LDLIBS)
|
||||
|
||||
|
||||
.PHONY : clean |
||||
|
||||
clean: |
||||
$(RM) *.d
|
||||
$(RM) *.o
|
||||
$(RM) *.exe
|
||||
$(RM) zlib.a
|
||||
$(RM) foo.gz
|
||||
|
||||
DEPS := $(wildcard *.d)
|
||||
ifneq ($(DEPS),) |
||||
include $(DEPS) |
||||
endif |
@ -0,0 +1,87 @@ |
||||
# Makefile for zlib. Modified for mingw32 by C. Spieler, 6/16/98.
|
||||
# (This Makefile is directly derived from Makefile.dj2)
|
||||
# Copyright (C) 1995-1998 Jean-loup Gailly.
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
# To compile, or to compile and test, type:
|
||||
#
|
||||
# make -fmakefile.gcc; make test -fmakefile.gcc
|
||||
#
|
||||
# To install libz.a, zconf.h and zlib.h in the mingw32 directories, type:
|
||||
#
|
||||
# make install -fmakefile.gcc
|
||||
#
|
||||
|
||||
CC=gcc
|
||||
|
||||
#CFLAGS=-MMD -O
|
||||
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
||||
#CFLAGS=-MMD -g -DDEBUG
|
||||
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
-Wstrict-prototypes -Wmissing-prototypes
|
||||
|
||||
# If cp.exe is available, replace "copy /Y" with "cp -fp" .
|
||||
CP=copy /Y
|
||||
# If gnu install.exe is available, replace $(CP) with ginstall.
|
||||
INSTALL=$(CP)
|
||||
# The default value of RM is "rm -f." If "rm.exe" is found, comment out:
|
||||
RM=del
|
||||
LDLIBS=-L. -lz
|
||||
LD=$(CC) -s -o
|
||||
LDSHARED=$(CC)
|
||||
|
||||
INCL=zlib.h zconf.h
|
||||
LIBS=libz.a
|
||||
|
||||
AR=ar rcs
|
||||
|
||||
prefix=/usr/local
|
||||
exec_prefix = $(prefix)
|
||||
|
||||
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
|
||||
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
|
||||
|
||||
TEST_OBJS = example.o minigzip.o
|
||||
|
||||
all: example.exe minigzip.exe |
||||
|
||||
test: all |
||||
./example
|
||||
echo hello world | .\minigzip | .\minigzip -d
|
||||
|
||||
%.o : %.c |
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
libz.a: $(OBJS) |
||||
$(AR) $@ $(OBJS)
|
||||
|
||||
%.exe : %.o $(LIBS) |
||||
$(LD) $@ $< $(LDLIBS)
|
||||
|
||||
# INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env .
|
||||
|
||||
.PHONY : uninstall clean |
||||
|
||||
install: $(INCL) $(LIBS) |
||||
-@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH)
|
||||
-@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH)
|
||||
$(INSTALL) zlib.h $(INCLUDE_PATH)
|
||||
$(INSTALL) zconf.h $(INCLUDE_PATH)
|
||||
$(INSTALL) libz.a $(LIBRARY_PATH)
|
||||
|
||||
uninstall: |
||||
$(RM) $(INCLUDE_PATH)\zlib.h
|
||||
$(RM) $(INCLUDE_PATH)\zconf.h
|
||||
$(RM) $(LIBRARY_PATH)\libz.a
|
||||
|
||||
clean: |
||||
$(RM) *.d
|
||||
$(RM) *.o
|
||||
$(RM) *.exe
|
||||
$(RM) libz.a
|
||||
$(RM) foo.gz
|
||||
|
||||
DEPS := $(wildcard *.d)
|
||||
ifneq ($(DEPS),) |
||||
include $(DEPS) |
||||
endif |
@ -0,0 +1,136 @@ |
||||
# Makefile for zlib under OS/2 using GCC (PGCC)
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
# To compile and test, type:
|
||||
# cp Makefile.os2 ..
|
||||
# cd ..
|
||||
# make -f Makefile.os2 test
|
||||
|
||||
# This makefile will build a static library z.lib, a shared library
|
||||
# z.dll and a import library zdll.lib. You can use either z.lib or
|
||||
# zdll.lib by specifying either -lz or -lzdll on gcc's command line
|
||||
|
||||
CC=gcc -Zomf -s
|
||||
|
||||
CFLAGS=-O6 -Wall
|
||||
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
||||
#CFLAGS=-g -DDEBUG
|
||||
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
# -Wstrict-prototypes -Wmissing-prototypes
|
||||
|
||||
#################### BUG WARNING: #####################
|
||||
## infcodes.c hits a bug in pgcc-1.0, so you have to use either
|
||||
## -O# where # <= 4 or one of (-fno-ommit-frame-pointer or -fno-force-mem)
|
||||
## This bug is reportedly fixed in pgcc >1.0, but this was not tested
|
||||
CFLAGS+=-fno-force-mem
|
||||
|
||||
LDFLAGS=-s -L. -lzdll -Zcrtdll
|
||||
LDSHARED=$(CC) -s -Zomf -Zdll -Zcrtdll
|
||||
|
||||
VER=1.1.0
|
||||
ZLIB=z.lib
|
||||
SHAREDLIB=z.dll
|
||||
SHAREDLIBIMP=zdll.lib
|
||||
LIBS=$(ZLIB) $(SHAREDLIB) $(SHAREDLIBIMP)
|
||||
|
||||
AR=emxomfar cr
|
||||
IMPLIB=emximp
|
||||
RANLIB=echo
|
||||
TAR=tar
|
||||
SHELL=bash
|
||||
|
||||
prefix=/usr/local
|
||||
exec_prefix = $(prefix)
|
||||
|
||||
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
|
||||
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
|
||||
|
||||
TEST_OBJS = example.o minigzip.o
|
||||
|
||||
DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \
|
||||
algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \
|
||||
nt/Makefile.nt nt/zlib.dnt contrib/README.contrib contrib/*.txt \
|
||||
contrib/asm386/*.asm contrib/asm386/*.c \
|
||||
contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \
|
||||
contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \
|
||||
contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32
|
||||
|
||||
all: example.exe minigzip.exe |
||||
|
||||
test: all |
||||
@LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
|
||||
echo hello world | ./minigzip | ./minigzip -d || \
|
||||
echo ' *** minigzip test FAILED ***' ; \
|
||||
if ./example; then \
|
||||
echo ' *** zlib test OK ***'; \
|
||||
else \
|
||||
echo ' *** zlib test FAILED ***'; \
|
||||
fi
|
||||
|
||||
$(ZLIB): $(OBJS) |
||||
$(AR) $@ $(OBJS)
|
||||
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
|
||||
|
||||
$(SHAREDLIB): $(OBJS) os2/z.def |
||||
$(LDSHARED) -o $@ $^
|
||||
|
||||
$(SHAREDLIBIMP): os2/z.def |
||||
$(IMPLIB) -o $@ $^
|
||||
|
||||
example.exe: example.o $(LIBS) |
||||
$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
|
||||
|
||||
minigzip.exe: minigzip.o $(LIBS) |
||||
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
|
||||
|
||||
clean: |
||||
rm -f *.o *~ example minigzip libz.a libz.so* foo.gz
|
||||
|
||||
distclean: clean |
||||
|
||||
zip: |
||||
mv Makefile Makefile~; cp -p Makefile.in Makefile
|
||||
rm -f test.c ztest*.c
|
||||
v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
|
||||
zip -ul9 zlib$$v $(DISTFILES)
|
||||
mv Makefile~ Makefile
|
||||
|
||||
dist: |
||||
mv Makefile Makefile~; cp -p Makefile.in Makefile
|
||||
rm -f test.c ztest*.c
|
||||
d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
|
||||
rm -f $$d.tar.gz; \
|
||||
if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \
|
||||
files=""; \
|
||||
for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \
|
||||
cd ..; \
|
||||
GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \
|
||||
if test ! -d $$d; then rm -f $$d; fi
|
||||
mv Makefile~ Makefile
|
||||
|
||||
tags: |
||||
etags *.[ch]
|
||||
|
||||
depend: |
||||
makedepend -- $(CFLAGS) -- *.[ch]
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
adler32.o: zlib.h zconf.h |
||||
compress.o: zlib.h zconf.h |
||||
crc32.o: zlib.h zconf.h |
||||
deflate.o: deflate.h zutil.h zlib.h zconf.h |
||||
example.o: zlib.h zconf.h |
||||
gzio.o: zutil.h zlib.h zconf.h |
||||
infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h |
||||
infcodes.o: zutil.h zlib.h zconf.h |
||||
infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h |
||||
inffast.o: zutil.h zlib.h zconf.h inftrees.h |
||||
inffast.o: infblock.h infcodes.h infutil.h inffast.h |
||||
inflate.o: zutil.h zlib.h zconf.h infblock.h |
||||
inftrees.o: zutil.h zlib.h zconf.h inftrees.h |
||||
infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h |
||||
minigzip.o: zlib.h zconf.h |
||||
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h |
||||
uncompr.o: zlib.h zconf.h |
||||
zutil.o: zutil.h zlib.h zconf.h |
@ -0,0 +1,51 @@ |
||||
; |
||||
; Slightly modified version of ../nt/zlib.dnt :-) |
||||
; |
||||
|
||||
LIBRARY Z |
||||
DESCRIPTION "Zlib compression library for OS/2" |
||||
CODE PRELOAD MOVEABLE DISCARDABLE |
||||
DATA PRELOAD MOVEABLE MULTIPLE |
||||
|
||||
EXPORTS |
||||
adler32 |
||||
compress |
||||
crc32 |
||||
deflate |
||||
deflateCopy |
||||
deflateEnd |
||||
deflateInit2_ |
||||
deflateInit_ |
||||
deflateParams |
||||
deflateReset |
||||
deflateSetDictionary |
||||
gzclose |
||||
gzdopen |
||||
gzerror |
||||
gzflush |
||||
gzopen |
||||
gzread |
||||
gzwrite |
||||
inflate |
||||
inflateEnd |
||||
inflateInit2_ |
||||
inflateInit_ |
||||
inflateReset |
||||
inflateSetDictionary |
||||
inflateSync |
||||
uncompress |
||||
zlibVersion |
||||
gzprintf |
||||
gzputc |
||||
gzgetc |
||||
gzseek |
||||
gzrewind |
||||
gztell |
||||
gzeof |
||||
gzsetparams |
||||
zError |
||||
inflateSyncPoint |
||||
get_crc_table |
||||
compress2 |
||||
gzputs |
||||
gzgets |
Loading…
Reference in new issue