ZLIB has been ported to an
.OCX by Mark Nelson. If you don't want the overhead of an .ocx, you can
use this
zlibvb.bas file (module) to give you access to the basic routines. In
order to use it, you're going to need one of the ZLIB.DLL files from the ZLIB page; I've
included one of them in the .zip file. Here is the API.
Name | Returns | Params | Desc | ||||||||
compress | zlib error code |
|
compresses raw data
on return, dest_len contains the size of the data in the dest buffer make sure you allow enough room in the destination buffer; the recommended size is (source_len)*1001/1000+12 don't forget to truncate the dest buffer down to the size returned to you in dest_len |
||||||||
uncompress | zlib error code |
|
uncompresses the data back to its original form
on return, dest_len contains the size of the data in the dest buffer you'll have to know how big the reconstruction buffer is going to need to be before you make this call |
||||||||
gzopen | zlib file handle |
|
open the named file for compression read or write
if you read from a non-zlib-compressed file, the reads will just pass the data right through |
||||||||
gzread | number of uncompressed bytes actually read
0 for eof -1 on error |
|
|||||||||
gzwrite | the number of uncompressed bytes actually written
0 on error |
|
|||||||||
gzflush | zlib error number |
|
use a flush mode of 4 if you want to flush at the end of the file;
gzclose() does the same thing
use a flush mode of 3 to force a flush and "segment" a file; segments can be decompressed individually/independently |
||||||||
gclose | zlib error number |
|
|||||||||
addler32 | running adler32 number |
|
calculates a running Adler32 checksum
call with buf set to 0 to start the checksum |
||||||||
crc32 | running crc32 |
|
calculates a running crc32 checksum
includes one's complement code call with buf set to 0 to start the checksum |
The .zip file contains Basic test code, which serves as an illustration.