Blame view
include/u-boot/zlib.h
26.5 KB
4a5b6a356 Initial revision |
1 |
/* |
dce3d7971 zlib: updated to ... |
2 |
* This file is derived from zlib.h and zconf.h from the zlib-1.2.3 |
4a5b6a356 Initial revision |
3 4 5 6 |
* distribution by Jean-loup Gailly and Mark Adler, with some additions * by Paul Mackerras to aid in implementing Deflate compression and * decompression for PPP packets. */ |
dce3d7971 zlib: updated to ... |
7 8 9 10 11 12 |
/* * ==FILEVERSION 960122== * * This marker is used by the Linux installation script to determine * whether an up-to-date version of this file is already installed. */ |
4a5b6a356 Initial revision |
13 14 |
/* zlib.h -- interface of the 'zlib' general purpose compression library |
dce3d7971 zlib: updated to ... |
15 |
version 1.2.3, July 18th, 2005 |
4a5b6a356 Initial revision |
16 |
|
dce3d7971 zlib: updated to ... |
17 |
Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler |
4a5b6a356 Initial revision |
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
This software is provided 'as-is', without any express 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. Jean-loup Gailly Mark Adler |
dce3d7971 zlib: updated to ... |
36 |
jloup@gzip.org madler@alumni.caltech.edu |
b201171f2 zlib: updated to ... |
37 |
|
dce3d7971 zlib: updated to ... |
38 39 40 41 42 43 44 45 46 47 48 |
The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). */ #ifndef ZLIB_H #define ZLIB_H #ifdef __cplusplus extern "C" { #endif |
4a5b6a356 Initial revision |
49 |
|
dce3d7971 zlib: updated to ... |
50 51 |
#define ZLIB_VERSION "1.2.3" #define ZLIB_VERNUM 0x1230 |
4a5b6a356 Initial revision |
52 |
|
dce3d7971 zlib: updated to ... |
53 |
/* #include "zconf.h" */ /* included directly here */ |
4a5b6a356 Initial revision |
54 |
/* zconf.h -- configuration of the zlib compression library |
dce3d7971 zlib: updated to ... |
55 |
* Copyright (C) 1995-2005 Jean-loup Gailly. |
4a5b6a356 Initial revision |
56 57 |
* For conditions of distribution and use, see copyright notice in zlib.h */ |
dce3d7971 zlib: updated to ... |
58 |
/* Begin of new zconf.h */ |
4a5b6a356 Initial revision |
59 |
/* |
dce3d7971 zlib: updated to ... |
60 61 |
* If you *really* need a unique prefix for all types and library functions, * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. |
4a5b6a356 Initial revision |
62 |
*/ |
dce3d7971 zlib: updated to ... |
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
#ifdef Z_PREFIX # define deflateInit_ z_deflateInit_ # define deflate z_deflate # define deflateEnd z_deflateEnd # define inflateInit_ z_inflateInit_ # define inflate z_inflate # define inflateEnd z_inflateEnd # define deflateInit2_ z_deflateInit2_ # define deflateSetDictionary z_deflateSetDictionary # define deflateCopy z_deflateCopy # define deflateReset z_deflateReset # define deflateParams z_deflateParams # define deflateBound z_deflateBound # define deflatePrime z_deflatePrime # define inflateInit2_ z_inflateInit2_ # define inflateSetDictionary z_inflateSetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateCopy z_inflateCopy # define inflateReset z_inflateReset # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd # define compress z_compress # define compress2 z_compress2 # define compressBound z_compressBound # define uncompress z_uncompress # define adler32 z_adler32 # define crc32 z_crc32 # define get_crc_table z_get_crc_table # define zError z_zError # define alloc_func z_alloc_func # define free_func z_free_func # define in_func z_in_func # define out_func z_out_func # define Byte z_Byte # define uInt z_uInt # define uLong z_uLong # define Bytef z_Bytef # define charf z_charf # define intf z_intf # define uIntf z_uIntf # define uLongf z_uLongf # define voidpf z_voidpf # define voidp z_voidp #endif #if defined(__MSDOS__) && !defined(MSDOS) # define MSDOS #endif #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) # define OS2 #endif #if defined(_WINDOWS) && !defined(WINDOWS) # define WINDOWS #endif #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) # ifndef WIN32 # define WIN32 # endif #endif #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) # ifndef SYS16BIT # define SYS16BIT # endif # endif #endif |
4a5b6a356 Initial revision |
131 132 133 134 |
/* * Compile with -DMAXSEG_64K if the alloc function cannot allocate more * than 64k bytes at a time (needed on systems with 16-bit int). |
4a5b6a356 Initial revision |
135 |
*/ |
dce3d7971 zlib: updated to ... |
136 137 138 139 140 141 |
#ifdef SYS16BIT # define MAXSEG_64K #endif #ifdef MSDOS # define UNALIGNED_OK #endif |
b201171f2 zlib: updated to ... |
142 |
|
dce3d7971 zlib: updated to ... |
143 144 |
#ifdef __STDC_VERSION__ # ifndef STDC |
f33b325af Revert "zlib: upd... |
145 |
# define STDC |
b201171f2 zlib: updated to ... |
146 |
# endif |
dce3d7971 zlib: updated to ... |
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# if __STDC_VERSION__ >= 199901L # ifndef STDC99 # define STDC99 # endif # endif #endif #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) # define STDC #endif #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) # define STDC #endif #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) # define STDC #endif #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) # define STDC #endif #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ # define STDC #endif #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const /* note: need a more gentle solution here */ # endif |
4a5b6a356 Initial revision |
174 |
#endif |
dce3d7971 zlib: updated to ... |
175 176 177 |
/* Some Mac compilers merge all .h files incorrectly: */ #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) # define NO_DUMMY_DECL |
4a5b6a356 Initial revision |
178 179 180 181 182 183 184 185 186 187 |
#endif /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL # ifdef MAXSEG_64K # define MAX_MEM_LEVEL 8 # else # define MAX_MEM_LEVEL 9 # endif #endif |
dce3d7971 zlib: updated to ... |
188 189 190 191 192 |
/* Maximum value for windowBits in deflateInit2 and inflateInit2. * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files * created by gzip. (Files created by minigzip can still be extracted by * gzip.) */ |
4a5b6a356 Initial revision |
193 194 195 196 197 |
#ifndef MAX_WBITS # define MAX_WBITS 15 /* 32K LZ77 window */ #endif /* The memory requirements for deflate are (in bytes): |
dce3d7971 zlib: updated to ... |
198 |
(1 << (windowBits+2)) + (1 << (memLevel+9)) |
4a5b6a356 Initial revision |
199 200 201 202 203 204 205 206 207 208 |
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) plus a few kilobytes for small objects. For example, if you want to reduce the default memory requirements from 256K to 128K, compile with make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" Of course this will generally degrade compression (there's no free lunch). The memory requirements for inflate are (in bytes) 1 << windowBits that is, 32K for windowBits=15 (default value) plus a few kilobytes for small objects. */ |
dce3d7971 zlib: updated to ... |
209 |
/* Type declarations */ |
4a5b6a356 Initial revision |
210 211 212 213 214 215 216 217 |
#ifndef OF /* function prototypes */ # ifdef STDC # define OF(args) args # else # define OF(args) () # endif #endif |
dce3d7971 zlib: updated to ... |
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
/* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, * just define FAR to be empty. */ #ifdef SYS16BIT # if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */ # define SMALL_MEDIUM # ifdef _MSC_VER # define FAR _far # else # define FAR far # endif # endif # if (defined(__SMALL__) || defined(__MEDIUM__)) /* Turbo C small or medium model */ # define SMALL_MEDIUM # ifdef __BORLANDC__ # define FAR _far # else # define FAR far # endif # endif #endif #if defined(WINDOWS) || defined(WIN32) /* If building or using zlib as a DLL, define ZLIB_DLL. * This is not mandatory, but it offers a little performance increase. */ # ifdef ZLIB_DLL # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) # ifdef ZLIB_INTERNAL # define ZEXTERN extern __declspec(dllexport) # else # define ZEXTERN extern __declspec(dllimport) # endif # endif # endif /* ZLIB_DLL */ /* If building or using zlib with the WINAPI/WINAPIV calling convention, * define ZLIB_WINAPI. * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. */ # ifdef ZLIB_WINAPI # ifdef FAR # undef FAR # endif # include <windows.h> /* No need for _export, use ZLIB.DEF instead. */ /* For complete Windows compatibility, use WINAPI, not __stdcall. */ # define ZEXPORT WINAPI # ifdef WIN32 # define ZEXPORTVA WINAPIV # else # define ZEXPORTVA FAR CDECL # endif # endif #endif #if defined (__BEOS__) # ifdef ZLIB_DLL # ifdef ZLIB_INTERNAL # define ZEXPORT __declspec(dllexport) # define ZEXPORTVA __declspec(dllexport) # else # define ZEXPORT __declspec(dllimport) # define ZEXPORTVA __declspec(dllimport) # endif # endif #endif #ifndef ZEXTERN # define ZEXTERN extern #endif #ifndef ZEXPORT # define ZEXPORT #endif #ifndef ZEXPORTVA # define ZEXPORTVA #endif #ifndef FAR # define FAR #endif #if !defined(__MACTYPES__) |
4a5b6a356 Initial revision |
305 |
typedef unsigned char Byte; /* 8 bits */ |
dce3d7971 zlib: updated to ... |
306 |
#endif |
4a5b6a356 Initial revision |
307 308 |
typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned long uLong; /* 32 bits or more */ |
dce3d7971 zlib: updated to ... |
309 310 311 312 313 314 315 316 317 |
#ifdef SMALL_MEDIUM /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ # define Bytef Byte FAR #else typedef Byte FAR Bytef; #endif typedef char FAR charf; typedef int FAR intf; typedef uInt FAR uIntf; |
4a5b6a356 Initial revision |
318 319 320 |
typedef uLong FAR uLongf; #ifdef STDC |
dce3d7971 zlib: updated to ... |
321 322 323 |
typedef void const *voidpc; typedef void FAR *voidpf; typedef void *voidp; |
4a5b6a356 Initial revision |
324 |
#else |
dce3d7971 zlib: updated to ... |
325 326 327 |
typedef Byte const *voidpc; typedef Byte FAR *voidpf; typedef Byte *voidp; |
b201171f2 zlib: updated to ... |
328 |
#endif |
4a5b6a356 Initial revision |
329 |
|
dce3d7971 zlib: updated to ... |
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# ifdef VMS # include <unixio.h> /* for off_t */ # endif # define z_off_t off_t #ifndef SEEK_SET # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t # define z_off_t long #endif #if defined(__OS400__) # define NO_vsnprintf #endif |
b201171f2 zlib: updated to ... |
346 |
|
dce3d7971 zlib: updated to ... |
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
#if defined(__MVS__) # define NO_vsnprintf # ifdef FAR # undef FAR # endif #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) # pragma map(deflateInit_,"DEIN") # pragma map(deflateInit2_,"DEIN2") # pragma map(deflateEnd,"DEEND") # pragma map(deflateBound,"DEBND") # pragma map(inflateInit_,"ININ") # pragma map(inflateInit2_,"ININ2") # pragma map(inflateEnd,"INEND") # pragma map(inflateSync,"INSY") # pragma map(inflateSetDictionary,"INSEDI") # pragma map(compressBound,"CMBND") # pragma map(inflate_table,"INTABL") # pragma map(inflate_fast,"INFA") # pragma map(inflate_copyright,"INCOPY") #endif /* End of new zconf.h */ |
4a5b6a356 Initial revision |
371 372 373 374 375 |
/* The 'zlib' compression library provides in-memory compression and decompression functions, including integrity checks of the uncompressed data. This version of the library supports only one compression method |
dce3d7971 zlib: updated to ... |
376 |
(deflation) but other algorithms will be added later and will have the same |
4a5b6a356 Initial revision |
377 |
stream interface. |
4a5b6a356 Initial revision |
378 379 380 381 382 |
Compression can be done in a single step if the buffers are large enough (for example if an input file is mmap'ed), or can be done by repeated calls of the compression function. In the latter case, the application must provide more input and/or consume the output (providing more output space) before each call. |
f33b325af Revert "zlib: upd... |
383 |
|
dce3d7971 zlib: updated to ... |
384 385 386 |
The compressed data format used by default by the in-memory functions is the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped around a deflate stream, which is itself documented in RFC 1951. |
4a5b6a356 Initial revision |
387 |
|
dce3d7971 zlib: updated to ... |
388 389 390 391 |
The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio using the functions that start with "gz". The gzip format is different from the zlib format. gzip is a gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. |
f33b325af Revert "zlib: upd... |
392 |
|
dce3d7971 zlib: updated to ... |
393 |
This library can optionally read and write gzip streams in memory as well. |
f33b325af Revert "zlib: upd... |
394 |
|
dce3d7971 zlib: updated to ... |
395 396 397 398 |
The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single- file compression on file systems, has a larger header than zlib to maintain directory information, and uses a different, slower check method than zlib. |
f33b325af Revert "zlib: upd... |
399 |
|
dce3d7971 zlib: updated to ... |
400 401 402 403 |
The library does not install any signal handler. The decoder checks the consistency of the compressed data, so the library should never crash even in case of corrupted input. */ |
4a5b6a356 Initial revision |
404 |
|
dce3d7971 zlib: updated to ... |
405 406 407 |
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); typedef void (*free_func) OF((voidpf opaque, voidpf address, uInt size)); typedef void (*cb_func) OF((Bytef *buf, uInt len)); |
f33b325af Revert "zlib: upd... |
408 |
|
dce3d7971 zlib: updated to ... |
409 |
struct internal_state; |
f33b325af Revert "zlib: upd... |
410 |
|
dce3d7971 zlib: updated to ... |
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
typedef struct z_stream_s { Bytef *next_in; /* next input byte */ uInt avail_in; /* number of bytes available at next_in */ uLong total_in; /* total nb of input bytes read so far */ Bytef *next_out; /* next output byte should be put there */ uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total nb of bytes output so far */ char *msg; /* last error message, NULL if no error */ struct internal_state FAR *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ free_func zfree; /* used to free the internal state */ voidpf opaque; /* private data object passed to zalloc and zfree */ int data_type; /* best guess about the data type: binary or text */ cb_func outcb; /* called regularly just before blocks of output */ uLong adler; /* adler32 value of the uncompressed data */ uLong reserved; /* reserved for future use */ |
f33b325af Revert "zlib: upd... |
428 |
} z_stream; |
b201171f2 zlib: updated to ... |
429 |
|
dce3d7971 zlib: updated to ... |
430 |
typedef z_stream FAR *z_streamp; |
4a5b6a356 Initial revision |
431 |
/* |
dce3d7971 zlib: updated to ... |
432 433 |
gzip header information passed to and from zlib routines. See RFC 1952 for more details on the meanings of these fields. |
4a5b6a356 Initial revision |
434 |
*/ |
dce3d7971 zlib: updated to ... |
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
typedef struct gz_header_s { int text; /* true if compressed data believed to be text */ uLong time; /* modification time */ int xflags; /* extra flags (not used when writing a gzip file) */ int os; /* operating system */ Bytef *extra; /* pointer to extra field or Z_NULL if none */ uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ uInt extra_max; /* space at extra (only when reading header) */ Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ uInt name_max; /* space at name (only when reading header) */ Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ uInt comm_max; /* space at comment (only when reading header) */ int hcrc; /* true if there was or will be a header crc */ int done; /* true when done reading gzip header (not used when writing a gzip file) */ } gz_header; typedef gz_header FAR *gz_headerp; /* constants */ |
4a5b6a356 Initial revision |
455 |
#define Z_NO_FLUSH 0 |
dce3d7971 zlib: updated to ... |
456 457 458 |
#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ #define Z_SYNC_FLUSH 2 #define Z_FULL_FLUSH 3 |
4a5b6a356 Initial revision |
459 |
#define Z_FINISH 4 |
dce3d7971 zlib: updated to ... |
460 461 |
#define Z_BLOCK 5 /* Allowed flush values; see deflate() and inflate() below for details */ |
4a5b6a356 Initial revision |
462 463 464 |
#define Z_OK 0 #define Z_STREAM_END 1 |
dce3d7971 zlib: updated to ... |
465 |
#define Z_NEED_DICT 2 |
4a5b6a356 Initial revision |
466 467 468 469 470 |
#define Z_ERRNO (-1) #define Z_STREAM_ERROR (-2) #define Z_DATA_ERROR (-3) #define Z_MEM_ERROR (-4) #define Z_BUF_ERROR (-5) |
dce3d7971 zlib: updated to ... |
471 472 473 474 |
#define Z_VERSION_ERROR (-6) /* Return codes for the compression/decompression functions. Negative * values are errors, positive values are used for special but normal events. */ |
4a5b6a356 Initial revision |
475 |
|
dce3d7971 zlib: updated to ... |
476 |
#define Z_NO_COMPRESSION 0 |
4a5b6a356 Initial revision |
477 478 479 480 481 482 483 |
#define Z_BEST_SPEED 1 #define Z_BEST_COMPRESSION 9 #define Z_DEFAULT_COMPRESSION (-1) /* compression levels */ #define Z_FILTERED 1 #define Z_HUFFMAN_ONLY 2 |
dce3d7971 zlib: updated to ... |
484 485 |
#define Z_RLE 3 #define Z_FIXED 4 |
4a5b6a356 Initial revision |
486 |
#define Z_DEFAULT_STRATEGY 0 |
dce3d7971 zlib: updated to ... |
487 |
/* compression strategy; see deflateInit2() below for details */ |
4a5b6a356 Initial revision |
488 489 |
#define Z_BINARY 0 |
dce3d7971 zlib: updated to ... |
490 491 |
#define Z_TEXT 1 #define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ |
4a5b6a356 Initial revision |
492 |
#define Z_UNKNOWN 2 |
dce3d7971 zlib: updated to ... |
493 494 495 496 |
/* Possible values of the data_type field (though see inflate()) */ #define Z_DEFLATED 8 /* The deflate compression method (the only one supported in this version) */ |
4a5b6a356 Initial revision |
497 |
|
ee820b5e5 lib/zlib: sparse ... |
498 |
#define Z_NULL (void *)0 /* for initializing zalloc, zfree, opaque */ |
4a5b6a356 Initial revision |
499 |
|
dce3d7971 zlib: updated to ... |
500 501 502 |
/* basic functions */ /* The application can compare zlibVersion and ZLIB_VERSION for consistency. |
4a5b6a356 Initial revision |
503 504 |
If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. |
dce3d7971 zlib: updated to ... |
505 |
This check is automatically made by deflateInit and inflateInit. |
7a32b98da lib: zlib: includ... |
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
*/ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, const char *version, int stream_size)); ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size)); ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)); ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gz_headerp head)); ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, int bits, int value)); ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy)); ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain)); ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen)); ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, z_streamp source)); ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, const char *version, int stream_size)); |
dce3d7971 zlib: updated to ... |
541 |
ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); |
4a5b6a356 Initial revision |
542 |
/* |
dce3d7971 zlib: updated to ... |
543 544 545 546 |
inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. |
4a5b6a356 Initial revision |
547 |
|
dce3d7971 zlib: updated to ... |
548 549 |
The detailed semantics are as follows. inflate performs one or both of the following actions: |
4a5b6a356 Initial revision |
550 551 552 553 554 555 556 |
- Decompress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in is updated and processing will resume at this point for the next call of inflate(). - Provide more output starting at next_out and update next_out and avail_out |
dce3d7971 zlib: updated to ... |
557 558 559 |
accordingly. inflate() provides as much output as possible, until there is no more input data or no more space in the output buffer (see below about the flush parameter). |
4a5b6a356 Initial revision |
560 561 562 563 564 565 |
Before the call of inflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating the next_* and avail_* values accordingly. The application can consume the uncompressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each |
dce3d7971 zlib: updated to ... |
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
call of inflate(). If inflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much output as possible to the output buffer. Z_BLOCK requests that inflate() stop if and when it gets to the next deflate block boundary. When decoding the zlib or gzip format, this will cause inflate() to return immediately after the header and before the first block. When doing a raw inflate, inflate() will go ahead and process the first block, and will return when it gets to the end of that block, or when it runs out of data. The Z_BLOCK option assists in appending to or combining deflate streams. Also to assist in this, on return inflate() will set strm->data_type to the number of unused bits in the last byte taken from strm->next_in, plus 64 if inflate() is currently decoding the last block in the deflate stream, plus 128 if inflate() returned immediately after decoding an end-of-block code or decoding the complete header up to just before the first byte of the deflate stream. The end-of-block will not be indicated until all of the uncompressed data from that block has been written to strm->next_out. The number of unused bits may in general be greater than seven, except when bit 7 of data_type is set, in which case the number of unused bits will be less than eight. |
4a5b6a356 Initial revision |
590 591 592 593 594 595 596 597 598 |
inflate() should normally be called until it returns Z_STREAM_END or an error. However if all decompression is to be performed in a single step (a single call of inflate), the parameter flush should be set to Z_FINISH. In this case all pending input is processed and all pending output is flushed; avail_out must be large enough to hold all the uncompressed data. (The size of the uncompressed data may have been saved by the compressor for this purpose.) The next operation on this stream must be inflateEnd to deallocate the decompression state. The use of Z_FINISH |
dce3d7971 zlib: updated to ... |
599 |
is never required, but can be used to inform inflate that a faster approach |
4a5b6a356 Initial revision |
600 |
may be used for the single inflate() call. |
dce3d7971 zlib: updated to ... |
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 |
In this implementation, inflate() always flushes as much output as possible to the output buffer, and always uses the faster approach on the first call. So the only effect of the flush parameter in this implementation is on the return value of inflate(), as noted below, or when it returns early because Z_BLOCK is used. If a preset dictionary is needed after this call (see inflateSetDictionary below), inflate sets strm->adler to the adler32 checksum of the dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise it sets strm->adler to the adler32 checksum of all output produced so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described below. At the end of the stream, inflate() checks that its computed adler32 checksum is equal to that saved by the compressor and returns Z_STREAM_END only if the checksum is correct. inflate() will decompress and check either zlib-wrapped or gzip-wrapped deflate data. The header type is detected automatically. Any information contained in the gzip header is not retained, so applications that need that information should instead use raw inflate, see inflateInit2() below, or inflateBack() and perform their own processing of the gzip header and trailer. inflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if the end of the compressed data has been reached and all uncompressed output has been produced, Z_NEED_DICT if a preset dictionary is needed at this point, Z_DATA_ERROR if the input data was corrupted (input stream not conforming to the zlib format or incorrect check value), Z_STREAM_ERROR if the stream structure was inconsistent (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no progress is possible or if there was not enough room in the output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and inflate() can be called again with more input and more output space to continue decompressing. If Z_DATA_ERROR is returned, the application may then call inflateSync() to look for a good compression block if a partial recovery of the data is desired. */ |
4a5b6a356 Initial revision |
637 |
|
dce3d7971 zlib: updated to ... |
638 |
ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); |
4a5b6a356 Initial revision |
639 640 641 642 643 644 645 646 647 |
/* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent. In the error case, msg may be set but then points to a static string (which must not be deallocated). */ |
dce3d7971 zlib: updated to ... |
648 |
/* Advanced functions */ |
4a5b6a356 Initial revision |
649 |
|
dce3d7971 zlib: updated to ... |
650 |
ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); |
f33b325af Revert "zlib: upd... |
651 |
|
dce3d7971 zlib: updated to ... |
652 |
/* utility functions */ |
f33b325af Revert "zlib: upd... |
653 |
|
f33b325af Revert "zlib: upd... |
654 |
/* |
dce3d7971 zlib: updated to ... |
655 656 657 658 659 |
The following utility functions are implemented on top of the basic stream-oriented functions. To simplify the interface, some default options are assumed (compression level and memory usage, standard memory allocation functions). The source code of these utility functions can easily be modified if you need special options. |
f33b325af Revert "zlib: upd... |
660 |
*/ |
dce3d7971 zlib: updated to ... |
661 |
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); |
4a5b6a356 Initial revision |
662 663 664 665 666 667 668 669 670 671 672 673 674 675 |
/* 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: uLong adler = adler32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { adler = adler32(adler, buffer, length); } if (adler != original_adler) error(); */ |
dce3d7971 zlib: updated to ... |
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
/* Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. */ ZEXTERN uInt ZEXPORT crc32 OF((uInt crc, const Bytef *buf, uInt len)); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. If buf is NULL, this function returns the required initial value for the 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: uLong crc = crc32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { crc = crc32(crc, buffer, length); } if (crc != original_crc) error(); */ ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size)); #define inflateInit(strm) \ inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit2(strm, windowBits) \ inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) struct internal_state {int dummy;}; /* hack for buggy compilers */ #endif |
e3ed0575a gunzip: rename z{... |
709 710 |
extern void *gzalloc(void *, unsigned, unsigned); extern void gzfree(void *, void *, unsigned); |
dce3d7971 zlib: updated to ... |
711 712 |
#ifdef __cplusplus } |
4a5b6a356 Initial revision |
713 |
#endif |
dce3d7971 zlib: updated to ... |
714 |
#endif /* ZLIB_H */ |