-zlib 1.0.3 is a general purpose data compression library. All the code
+zlib 1.0.4 is a general purpose data compression library. All the code
is reentrant (thread safe). The data format used by the zlib library
is described by RFCs (Request for Comments) 1950 to 1952 in the files
ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
if this fails, to the addresses given below in the Copyright section.
The zlib home page is http://quest.jpl.nasa.gov/zlib/
-The changes made in version 1.0.3 are documented in the file ChangeLog.
-The main changes since 1.0.2 are:
+The changes made in version 1.0.4 are documented in the file ChangeLog.
+The main changes since 1.0.3 are:
-- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS
- small and medium models; this makes the library incompatible with previous
- versions for these models. (No effect in large model or on other systems.)
-- return OK instead of BUF_ERROR if previous deflate call returned with
- avail_out as zero but there is nothing to do
-- as usual, a few more changes to deal with peculiarities of Mac and MSDOS
- compilers
+- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF
+ bit, so the decompressor could decompress all the correct data but went
+ on to attempt decompressing extra garbage data. This affected minigzip too.
+- zlibVersion and gzerror return const char* (needed for DLL)
+- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno)
A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk>
- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc
and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL
For help on building a zlib DLL, contact Alessandro Iacopetti
- <iaco@cicladi.unial.it>
+ <iaco@email.alessandria.alpcom.it> http://lisa.unial.it/iaco ,
+ or contact Brad Clarke <bclarke@cyberus.ca>.
+
+- gzdopen is not supported on RISCOS
Acknowledgments:
*
*/
-/* $Id: deflate.c,v 1.1 1996/07/27 02:39:43 tholo Exp $ */
+/* $Id: deflate.c,v 1.2 1997/01/19 17:11:22 millert Exp $ */
#include "deflate.h"
-char deflate_copyright[] = " deflate 1.0.3 Copyright 1995-1996 Jean-loup Gailly ";
+char deflate_copyright[] = " deflate 1.0.4 Copyright 1995-1996 Jean-loup Gailly ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
/* ===========================================================================
* Function prototypes.
*/
+typedef enum {
+ need_more, /* block not completed, need more input or more output */
+ block_done, /* block flush performed */
+ finish_started, /* finish started, need only more output at next deflate */
+ finish_done /* finish done, accept no more input or output */
+} block_state;
+
+typedef block_state (*compress_func) OF((deflate_state *s, int flush));
+/* Compression function. Returns the block state after the call. */
+
local void fill_window OF((deflate_state *s));
-local int deflate_stored OF((deflate_state *s, int flush));
-local int deflate_fast OF((deflate_state *s, int flush));
-local int deflate_slow OF((deflate_state *s, int flush));
+local block_state deflate_stored OF((deflate_state *s, int flush));
+local block_state deflate_fast OF((deflate_state *s, int flush));
+local block_state deflate_slow OF((deflate_state *s, int flush));
local void lm_init OF((deflate_state *s));
local uInt longest_match OF((deflate_state *s, IPos cur_match));
local void putShortMSB OF((deflate_state *s, uInt b));
* See deflate.c for comments about the MIN_MATCH+1.
*/
-typedef int (*compress_func) OF((deflate_state *s, int flush));
-/* Compressing function */
-
/* Values for max_lazy_match, good_match and max_chain_length, depending on
* the desired pack level (0..9). The values given below have been tuned to
* exclude worst case performance for pathological files. Better values may be
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
s->pending_buf == Z_NULL) {
- strm->msg = ERR_MSG(Z_MEM_ERROR);
+ strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
deflateEnd (strm);
return Z_MEM_ERROR;
}
*/
if (strm->avail_in != 0 || s->lookahead != 0 ||
(flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
- int quit;
+ block_state bstate;
+
+ bstate = (*(configuration_table[s->level].func))(s, flush);
- if (flush == Z_FINISH) {
+ if (bstate == finish_started || bstate == finish_done) {
s->status = FINISH_STATE;
}
- quit = (*(configuration_table[s->level].func))(s, flush);
-
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
+ if (bstate == need_more || bstate == finish_started) {
+ if (strm->avail_out == 0) {
+ s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
+ }
+ return Z_OK;
+ /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
+ * of deflate should use the same flush parameter to make sure
+ * that the flush is complete. So we don't have to output an
+ * empty block here, this will be done at next call. This also
+ * ensures that for a very small output buffer, we emit at most
+ * one empty block.
+ */
}
- if (quit || strm->avail_out == 0) return Z_OK;
- /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
- * of deflate should use the same flush parameter to make sure
- * that the flush is complete. So we don't have to output an
- * empty block here, this will be done at next call. This also
- * ensures that for a very small output buffer, we emit at most
- * one empty block.
- */
- if (flush != Z_NO_FLUSH && flush != Z_FINISH) {
+ if (bstate == block_done) {
if (flush == Z_PARTIAL_FLUSH) {
_tr_align(s);
} else { /* FULL_FLUSH or SYNC_FLUSH */
/* Same but force premature exit if necessary. */
#define FLUSH_BLOCK(s, eof) { \
FLUSH_BLOCK_ONLY(s, eof); \
- if (s->strm->avail_out == 0) return 1; \
+ if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
}
/* ===========================================================================
* Copy without compression as much as possible from the input stream, return
- * true if processing was terminated prematurely (no more input or output
- * space). This function does not insert new strings in the dictionary
- * since uncompressible data is probably not useful. This function is used
+ * the current block state.
+ * This function does not insert new strings in the dictionary since
+ * uncompressible data is probably not useful. This function is used
* only for the level=0 compression option.
* NOTE: this function should be optimized to avoid extra copying.
*/
-local int deflate_stored(s, flush)
+local block_state deflate_stored(s, flush)
deflate_state *s;
int flush;
{
s->block_start >= (long)s->w_size, "slide too late");
fill_window(s);
- if (s->lookahead == 0 && flush == Z_NO_FLUSH) return 1;
+ if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
if (s->lookahead == 0) break; /* flush the current block */
}
}
}
FLUSH_BLOCK(s, flush == Z_FINISH);
- return 0; /* normal exit */
+ return flush == Z_FINISH ? finish_done : block_done;
}
/* ===========================================================================
- * Compress as much as possible from the input stream, return true if
- * processing was terminated prematurely (no more input or output space).
+ * Compress as much as possible from the input stream, return the current
+ * block state.
* This function does not perform lazy evaluation of matches and inserts
* new strings in the dictionary only for unmatched strings or for short
* matches. It is used only for the fast compression options.
*/
-local int deflate_fast(s, flush)
+local block_state deflate_fast(s, flush)
deflate_state *s;
int flush;
{
*/
if (s->lookahead < MIN_LOOKAHEAD) {
fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) return 1;
-
+ if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
+ return need_more;
+ }
if (s->lookahead == 0) break; /* flush the current block */
}
if (bflush) FLUSH_BLOCK(s, 0);
}
FLUSH_BLOCK(s, flush == Z_FINISH);
- return 0; /* normal exit */
+ return flush == Z_FINISH ? finish_done : block_done;
}
/* ===========================================================================
* evaluation for matches: a match is finally adopted only if there is
* no better match at the next window position.
*/
-local int deflate_slow(s, flush)
+local block_state deflate_slow(s, flush)
deflate_state *s;
int flush;
{
*/
if (s->lookahead < MIN_LOOKAHEAD) {
fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) return 1;
-
+ if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
+ return need_more;
+ }
if (s->lookahead == 0) break; /* flush the current block */
}
}
s->strstart++;
s->lookahead--;
- if (s->strm->avail_out == 0) return 1;
+ if (s->strm->avail_out == 0) return need_more;
} else {
/* There is no previous match to compare with, wait for
* the next step to decide.
s->match_available = 0;
}
FLUSH_BLOCK(s, flush == Z_FINISH);
- return 0;
+ return flush == Z_FINISH ? finish_done : block_done;
}
-
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-/* $Id: gzio.c,v 1.2 1996/10/27 00:29:33 millert Exp $ */
+/* $Id: gzio.c,v 1.3 1997/01/19 17:11:23 millert Exp $ */
#include <stdio.h>
errnum is set to Z_ERRNO and the application may consult errno
to get the exact error code.
*/
-char* gzerror (file, errnum)
+const char* gzerror (file, errnum)
gzFile file;
int *errnum;
{
if (s == NULL) {
*errnum = Z_STREAM_ERROR;
- return ERR_MSG(Z_STREAM_ERROR);
+ return (const char*)ERR_MSG(Z_STREAM_ERROR);
}
*errnum = s->z_err;
- if (*errnum == Z_OK) return (char*)"";
+ if (*errnum == Z_OK) return (const char*)"";
m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
- if (m == NULL || *m == '\0') m = ERR_MSG(s->z_err);
+ if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
TRYFREE(s->msg);
s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
strcpy(s->msg, s->path);
strcat(s->msg, ": ");
strcat(s->msg, m);
- return s->msg;
-}
-
-/* ===========================================================================
- Returns true (1) if file is zipped, else returns false (0).
-*/
-int gz_iszipped (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- return(!(s->transparent));
+ return (const char*)s->msg;
}
#include "zutil.h"
#include "inftrees.h"
-char inflate_copyright[] = " inflate 1.0.3 Copyright 1995-1996 Mark Adler ";
+char inflate_copyright[] = " inflate 1.0.4 Copyright 1995-1996 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
major=1
-minor=1
+minor=2
* Addison-Wesley, 1983. ISBN 0-201-06672-6.
*/
-/* $Id: trees.c,v 1.1 1996/07/27 02:39:49 tholo Exp $ */
+/* $Id: trees.c,v 1.2 1997/01/19 17:11:24 millert Exp $ */
#include "deflate.h"
#else /* DEBUG */
# define send_code(s, c, tree) \
- { if (verbose>1) fprintf(stderr,"\ncd %3d ",(c)); \
+ { if (verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
send_bits(s, tree[c].Code, tree[c].Len); }
#endif
/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.0.3, Jul 2nd, 1996.
+ version 1.0.4, Jul 24th, 1996.
Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler
#include "zconf.h"
-#define ZLIB_VERSION "1.0.3"
+#define ZLIB_VERSION "1.0.4"
/*
The 'zlib' compression library provides in-memory compression and
/* basic functions */
-extern char EXPORT *zlibVersion OF((void));
+extern const char * EXPORT zlibVersion OF((void));
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
If the first character differs, the library code actually used is
not compatible with the zlib.h header file used by the application.
parameter and more output space (updated avail_out), until the flush is
complete (deflate returns with non-zero avail_out).
- If the parameter flush is set to Z_FINISH, all pending input is processed,
- all pending output is flushed and deflate returns with Z_STREAM_END if there
+ If the parameter flush is set to Z_FINISH, pending input is processed,
+ pending output is flushed and deflate returns with Z_STREAM_END if there
was enough output space; if deflate returns with Z_OK, this function must be
called again with Z_FINISH and more output space (updated avail_out) but no
more input data, until it returns with Z_STREAM_END or an error. After
error number (see function gzerror below).
*/
-extern char EXPORT *gzerror OF((gzFile file, int *errnum));
+extern const char * EXPORT gzerror OF((gzFile file, int *errnum));
/*
Returns the error message for the last error which occurred on the
given compressed file. errnum is set to zlib error number. If an
to get the exact error code.
*/
-/* ===========================================================================
- Returns true (1) if file is zipped, else returns false (0).
-*/
-extern int gz_iszipped OF((gzFile file));
-
/* checksum functions */
/*
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-/* $Id: zutil.c,v 1.1 1996/07/27 02:39:51 tholo Exp $ */
+/* $Id: zutil.c,v 1.2 1997/01/19 17:11:26 millert Exp $ */
#include <stdio.h>
""};
-char *zlibVersion()
+const char *zlibVersion()
{
return ZLIB_VERSION;
}
+#ifdef DEBUG
void z_error (m)
char *m;
{
fprintf(stderr, "%s\n", m);
exit(1);
}
+#endif
#ifndef HAVE_MEMCPY
return;
}
ptr = opaque; /* just to make some compilers happy */
- z_error("zcfree: ptr not found");
+ Assert(0, "zcfree: ptr not found");
}
#endif
#endif /* __TURBOC__ */
subject to change. Applications should only use zlib.h.
*/
-/* $Id: zutil.h,v 1.1 1996/07/27 02:39:51 tholo Exp $ */
+/* $Id: zutil.h,v 1.2 1997/01/19 17:11:26 millert Exp $ */
#ifndef _Z_UTIL_H
#define _Z_UTIL_H
#include "zlib.h"
-#if defined(MSDOS) || defined(VMS) || defined(CRAY) || defined(WIN32)
+#if defined(MSDOS)||defined(VMS)||defined(CRAY)||defined(WIN32)||defined(RISCOS)
# include <stddef.h>
# include <errno.h>
#else
extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
-#define ERR_MSG(err) (char*)z_errmsg[Z_NEED_DICT-(err)]
+#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
#define ERR_RETURN(strm,err) \
- return (strm->msg = ERR_MSG(err), (err))
+ return (strm->msg = (char*)ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
/* common constants */
# define OS_CODE 0x0a
#endif
-#ifdef _BEOS_
+#if defined(_BEOS_) || defined(RISCOS)
# define fdopen(fd,mode) NULL /* No fdopen() */
#endif
# ifndef verbose
# define verbose 0
# endif
+ extern void z_error OF((char *m));
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
# define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;}
typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len));
-extern void z_error OF((char *m));
-
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
void zcfree OF((voidpf opaque, voidpf ptr));