]> git.sur5r.net Git - cc65/blob - include/zlib.h
goto.c warning fix for implicit truncation
[cc65] / include / zlib.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  zlib.h                                   */
4 /*                                                                           */
5 /*              Decompression routines for the 'deflate' format              */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2000-2015 Piotr Fusik <fox@scene.pl>                                  */
10 /*                                                                           */
11 /* This file is based on the zlib.h from 'zlib' general purpose compression  */
12 /* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler.    */
13 /*                                                                           */
14 /*  Jean-loup Gailly        Mark Adler                                       */
15 /*  jloup@gzip.org          madler@alumni.caltech.edu                        */
16 /*                                                                           */
17 /* This software is provided 'as-is', without any expressed or implied       */
18 /* warranty.  In no event will the authors be held liable for any damages    */
19 /* arising from the use of this software.                                    */
20 /*                                                                           */
21 /* Permission is granted to anyone to use this software for any purpose,     */
22 /* including commercial applications, and to alter it and redistribute it    */
23 /* freely, subject to the following restrictions:                            */
24 /*                                                                           */
25 /* 1. The origin of this software must not be misrepresented; you must not   */
26 /*    claim that you wrote the original software. If you use this software   */
27 /*    in a product, an acknowledgment in the product documentation would be  */
28 /*    appreciated but is not required.                                       */
29 /* 2. Altered source versions must be plainly marked as such, and must not   */
30 /*    be misrepresented as being the original software.                      */
31 /* 3. This notice may not be removed or altered from any source              */
32 /*    distribution.                                                          */
33 /*                                                                           */
34 /*****************************************************************************/
35
36
37
38 #ifndef _ZLIB_H
39 #define _ZLIB_H
40
41 #define Z_OK         0
42 #define Z_DATA_ERROR (-3)
43 /* Return codes for uncompress() */
44
45 #define Z_DEFLATED   8
46 /* The deflate compression method (the only one supported) */
47
48 #define Z_NULL       0
49
50
51 unsigned __fastcall__ inflatemem (char* dest, const char* source);
52 /*
53      Decompresses the source buffer into the destination buffer.
54    Returns the size of the uncompressed data (number of bytes written starting
55    from dest).
56
57      This function expects data in the DEFLATE format, described in RFC
58    (Request for Comments) 1951 in the file
59    ftp://ds.internic.net/rfc/rfc1951.txt.
60
61      This function does not exist in the original zlib. Its implementation
62    using original zlib might be following:
63
64    unsigned inflatemem (char* dest, const char* source)
65    {
66      z_stream stream;
67
68      stream.next_in = (Bytef*) source;
69      stream.avail_in = 65535;
70
71      stream.next_out = dest;
72      stream.avail_out = 65535;
73
74      stream.zalloc = (alloc_func) 0;
75      stream.zfree = (free_func) 0;
76
77      inflateInit2(&stream, -MAX_WBITS);
78      inflate(&stream, Z_FINISH);
79      inflateEnd(&stream);
80
81      return stream.total_out;
82    }
83 */
84
85
86 int __fastcall__ uncompress (char* dest, unsigned* destLen,
87                              const char* source, unsigned sourceLen);
88 /*
89    Original zlib description:
90
91      Decompresses the source buffer into the destination buffer.  sourceLen is
92    the byte length of the source buffer. Upon entry, destLen is the total
93    size of the destination buffer, which must be large enough to hold the
94    entire uncompressed data. (The size of the uncompressed data must have
95    been saved previously by the compressor and transmitted to the decompressor
96    by some mechanism outside the scope of this compression library.)
97    Upon exit, destLen is the actual size of the compressed buffer.
98      This function can be used to decompress a whole file at once if the
99    input file is mmap'ed.
100
101      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
102    enough memory, Z_BUF_ERROR if there was not enough room in the output
103    buffer, or Z_DATA_ERROR if the input data was corrupted.
104
105    Implementation notes:
106
107      This function expects data in the ZLIB format, described in RFC 1950
108    in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is
109    essentially the DEFLATE format plus a very small header and Adler-32
110    checksum.
111
112      Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation.
113 */
114
115
116 unsigned long __fastcall__ adler32 (unsigned long adler, const char* buf,
117                                     unsigned len);
118
119 /*
120    Original zlib description:
121
122      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
123    return the updated checksum. If buf is NULL, this function returns
124    the required initial value for the checksum.
125    An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
126    much faster. Usage example:
127
128      unsigned long adler = adler32(0L, Z_NULL, 0);
129
130      while (read_buffer(buffer, length) != EOF) {
131        adler = adler32(adler, buffer, length);
132      }
133      if (adler != original_adler) error();
134
135    Implementation notes:
136
137      This function isn't actually much faster than crc32(), but it is smaller
138    and does not use any lookup tables.
139 */
140
141
142 unsigned long __fastcall__ crc32 (unsigned long crc, const char* buf,
143                                   unsigned len);
144 /*
145    Original zlib description:
146
147      Update a running crc with the bytes buf[0..len-1] and return the updated
148    crc. If buf is NULL, this function returns the required initial value
149    for the crc. Pre- and post-conditioning (one's complement) is performed
150    within this function so it shouldn't be done by the application.
151    Usage example:
152
153      unsigned long crc = crc32(0L, Z_NULL, 0);
154
155      while (read_buffer(buffer, length) != EOF) {
156        crc = crc32(crc, buffer, length);
157      }
158      if (crc != original_crc) error();
159
160    Implementation notes:
161
162      This function uses statically allocated 1 KB lookup table. The table is
163    initialised before it is used for the first time (that is, if buffer is
164    NULL or length is zero, then the lookup table isn't initialised).
165 */
166
167
168 /* end of zlib.h */
169 #endif
170
171
172