X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fzlib.h;h=9bc5dcb270a583b18728947222d1788b2c7c7154;hb=9fbc99eb6d74a6cb4a6d50bbe987b83453fa597c;hp=e7a1453072209ff6fe99c3b55f875a69140ec947;hpb=c053b91f7a825a45e3671aa2ebb5adcda07a6271;p=cc65 diff --git a/include/zlib.h b/include/zlib.h index e7a145307..9bc5dcb27 100644 --- a/include/zlib.h +++ b/include/zlib.h @@ -1,53 +1,172 @@ -/*****************************************************************************/ -/* */ -/* zlib.h */ -/* */ -/* Decompression routines for the 'deflate' format */ -/* */ -/* */ -/* */ -/* (C) 2000-2001 Piotr Fusik */ -/* a.k.a. Fox/Taquart */ -/* EMail: fox@scene.pl */ -/* */ -/* */ -/* This software is provided 'as-is', without any expressed or implied */ -/* warranty. In no event will the authors be held liable for any damages */ -/* arising from the use of this software. */ -/* */ -/* Permission is granted to anyone to use this software for any purpose, */ -/* including commercial applications, and to alter it and redistribute it */ -/* freely, subject to the following restrictions: */ -/* */ -/* 1. The origin of this software must not be misrepresented; you must not */ -/* claim that you wrote the original software. If you use this software */ -/* in a product, an acknowledgment in the product documentation would be */ -/* appreciated but is not required. */ -/* 2. Altered source versions must be plainly marked as such, and must not */ -/* be misrepresented as being the original software. */ -/* 3. This notice may not be removed or altered from any source */ -/* distribution. */ -/* */ -/*****************************************************************************/ - - - -#ifndef _ZLIB_H -#define _ZLIB_H - - - -void* inflatemem (void* dest, void* src); -/* Read the deflate compressed data starting from src and store - * the uncompressed data starting from dest. - * Return pointer to a byte after the decompressed data. That is, the result - * minus dest is the size of the decompressed data. - */ - - - -/* end of zlib.h */ -#endif - - - +/*****************************************************************************/ +/* */ +/* zlib.h */ +/* */ +/* Decompression routines for the 'deflate' format */ +/* */ +/* */ +/* */ +/* (C) 2000-2001 Piotr Fusik */ +/* */ +/* This file is based on the zlib.h from 'zlib' general purpose compression */ +/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler. */ +/* */ +/* Jean-loup Gailly Mark Adler */ +/* jloup@gzip.org madler@alumni.caltech.edu */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#ifndef _ZLIB_H +#define _ZLIB_H + +#define Z_OK 0 +#define Z_DATA_ERROR (-3) +/* Return codes for uncompress() */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported) */ + +#define Z_NULL 0 + + +unsigned __fastcall__ inflatemem (char* dest, const char* source); +/* + Decompresses the source buffer into the destination buffer. + Returns the size of the uncompressed data (number of bytes written starting + from dest). + + This function expects data in the DEFLATE format, described in RFC + (Request for Comments) 1951 in the file + ftp://ds.internic.net/rfc/rfc1951.txt. + + This function does not exist in the original zlib. Its implementation + using original zlib might be following: + + unsigned inflatemem (char* dest, const char* source) + { + z_stream stream; + + stream.next_in = (Bytef*) source; + stream.avail_in = 65535; + + stream.next_out = dest; + stream.avail_out = 65535; + + stream.zalloc = (alloc_func) 0; + stream.zfree = (free_func) 0; + + inflateInit2(&stream, -MAX_WBITS); + inflate(&stream, Z_FINISH); + inflateEnd(&stream); + + return stream.total_out; + } +*/ + + +int uncompress (char* dest, unsigned* destLen, + const char* source, unsigned sourceLen); +/* + Original zlib description: + + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. + + Implementation notes: + + This function expects data in the ZLIB format, described in RFC 1950 + in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is + essentially the DEFLATE format plus a very small header and Adler-32 + checksum. + + Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation. +*/ + + +unsigned long __fastcall__ adler32 (unsigned long adler, const char* buf, + unsigned len); + +/* + Original zlib description: + + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + unsigned long adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); + + Implementation notes: + + This function isn't actually much faster than crc32(), but it is smaller + and does not use any lookup tables. +*/ + + +unsigned long __fastcall__ crc32 (unsigned long crc, const char* buf, + unsigned len); +/* + Original zlib description: + + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + unsigned long crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); + + Implementation notes: + + This function uses statically allocated 1 KB lookup table. The table is + initialised before it is used for the first time (that is, if buffer is + NULL or length is zero, then the lookup table isn't initialised). +*/ + + +/* end of zlib.h */ +#endif + + +